@univerjs/sheets-data-validation-ui 0.6.6 → 0.6.7-nightly.202503261607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js ADDED
@@ -0,0 +1,3008 @@
1
+ var Wo = Object.defineProperty;
2
+ var Ho = (t, e, o) => e in t ? Wo(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var E = (t, e, o) => Ho(t, typeof e != "symbol" ? e + "" : e, o);
4
+ import { jsxs as Y, jsx as m, Fragment as Rt } from "react/jsx-runtime";
5
+ import { Inject as b, LocaleService as Q, Disposable as Vt, DataValidationErrorStyle as de, DataValidationStatus as Kt, ICommandService as tt, dayjs as qe, numfmt as Je, CellValueType as xo, UniverInstanceType as X, toDisposable as jo, IUniverInstanceService as rt, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Yo, DisposableCollection as Xo, CommandType as ae, BuildTextUtils as zo, DataValidationRenderMode as ct, DataValidationType as K, IConfigService as mn, debounce as Ko, UndoCommand as Go, RedoCommand as Zo, isUnitRangesEqual as qo, shallowEqual as En, ThemeService as zn, ColorKit as Jo, Injector as Wt, ObjectMatrix as Ie, Range as Qo, Rectangle as we, queryObjectMatrix as Qe, Optional as ta, RxDisposable as gn, InterceptorEffectEnum as Kn, sequenceExecute as Gn, bufferDebounceTime as ea, isFormulaString as kt, Tools as tn, VerticalAlign as ht, HorizontalAlign as Gt, DEFAULT_STYLES as dt, WrapStrategy as It, DocumentDataModel as na, BooleanNumber as ie, DEFAULT_EMPTY_DOCUMENT_VALUE as oa, Plugin as Zn, merge as qn } from "@univerjs/core";
6
+ import { Button as Bt, DatePanel as aa, Scrollbar as ia, FormLayout as q, RadioGroup as fn, Radio as Nt, Checkbox as Pe, Input as Ut, Select as en, DraggableList as ra, clsx as sa } from "@univerjs/design";
7
+ import { DeviceInputEventType as nn, IRenderManagerService as yt, fixLineWidthByScale as bn, Transform as la, CheckboxShape as da, getCurrentTypeOfRenderer as Zt, CURSOR_TYPE as qt, FontCache as ca, Shape as ua, Rect as Jn, getFontStyleString as Be, getDocsSkeletonPageSize as re, Documents as ha, DocumentViewModel as pa, DocumentSkeleton as ma } from "@univerjs/engine-render";
8
+ import { SheetInterceptorService as vn, VALIDATE_CELL as ga, SetRangeValuesCommand as _n, SheetsSelectionsService as Qn, getSheetCommandTarget as to, SheetPermissionCheckController as eo, WorksheetEditPermission as Re, RangeProtectionPermissionEditPoint as De, WorkbookEditablePermission as Ve, checkRangesEditablePermission as fa, rangeToDiscreteRange as va, WorksheetSetCellStylePermission as on, INTERCEPTOR_POINT as no, InterceptCellContentPriority as oo } from "@univerjs/sheets";
9
+ import { SheetDataValidationModel as at, SheetsDataValidationValidatorService as _a, getCellValueOrigin as mt, getDataValidationCellValue as Sa, deserializeListOptions as ao, serializeListOptions as io, UpdateSheetDataValidationRangeCommand as ro, UpdateSheetDataValidationSettingCommand as On, UpdateSheetDataValidationOptionsCommand as Ca, RemoveSheetDataValidationCommand as so, RemoveSheetAllDataValidationCommand as Ia, createDefaultNewRule as lo, AddSheetDataValidationCommand as Sn, DATA_VALIDATION_PLUGIN_NAME as co, getDataValidationDiffMutations as an, DataValidationCacheService as uo, DataValidationFormulaController as wa, DataValidationFormulaService as Ra, CHECKBOX_FORMULA_2 as Da, CHECKBOX_FORMULA_1 as Va, getFormulaResult as $e, isLegalFormulaResult as Ln, transformCheckboxValue as ya } from "@univerjs/sheets-data-validation";
10
+ import { getPatternType as Ma } from "@univerjs/sheets-numfmt";
11
+ import { SetCellEditVisibleOperation as rn, SheetCanvasPopManagerService as Ea, IEditorBridgeService as ho, IMarkSelectionService as ba, HoverManagerService as Oa, CellAlertManagerService as La, CellAlertType as Ta, IAutoFillService as Pa, APPLY_TYPE as se, virtualizeDiscreteRanges as sn, getAutoFillRepeatRange as Aa, ISheetClipboardService as ka, COPY_TYPE as Tn, PREDEFINED_HOOK_NAME as he, getRepeatRange as Pn, getCurrentRangeDisable$ as Fa, AutoHeightController as po, SheetSkeletonManagerService as ye } from "@univerjs/sheets-ui";
12
+ import { IDialogService as Na, useDependency as T, KeyCode as ln, ISidebarService as mo, useObservable as St, ComponentManager as Ae, IZenZoneService as go, RectPopup as Ua, useEvent as dn, MenuItemType as Cn, getMenuHiddenObservable as Ba, RibbonStartGroup as $a, IMenuManagerService as Wa, useSidebarClick as fo } from "@univerjs/ui";
13
+ import An, { useState as j, forwardRef as Mt, useRef as Jt, createElement as Et, useMemo as $t, useEffect as wt } from "react";
14
+ import { DataValidatorRegistryService as bt, DataValidationModel as ke, DataValidatorRegistryScope as Ha, TWO_FORMULA_OPERATOR_COUNT as xa, getRuleOptions as kn, getRuleSetting as Fn } from "@univerjs/data-validation";
15
+ import { RichTextEditingMutation as ja } from "@univerjs/docs";
16
+ import { filter as In, BehaviorSubject as Nn, distinctUntilChanged as Ya, Subject as Xa, debounceTime as wn, of as za, bufferTime as vo } from "rxjs";
17
+ import { deserializeRangeWithSheet as Ka, serializeRange as _o } from "@univerjs/engine-formula";
18
+ import { RangeSelector as Ga, FormulaEditor as So } from "@univerjs/sheets-formula-ui";
19
+ var Za = Object.getOwnPropertyDescriptor, qa = (t, e, o, n) => {
20
+ for (var a = n > 1 ? void 0 : n ? Za(e, o) : e, i = t.length - 1, r; i >= 0; i--)
21
+ (r = t[i]) && (a = r(a) || a);
22
+ return a;
23
+ }, xt = (t, e) => (o, n) => e(o, n, t);
24
+ let ce = class extends Vt {
25
+ constructor(t, e, o, n, a, i) {
26
+ super(), this._sheetInterceptorService = t, this._dataValidationModel = e, this._dataValidatorRegistryService = o, this._dialogService = n, this._localeService = a, this._sheetsDataValidationValidatorService = i, this._initEditorBridgeInterceptor();
27
+ }
28
+ _initEditorBridgeInterceptor() {
29
+ this._sheetInterceptorService.writeCellInterceptor.intercept(
30
+ ga,
31
+ {
32
+ handler: async (t, e, o) => {
33
+ const n = await t, { row: a, col: i, unitId: r, subUnitId: s } = e, l = this._dataValidationModel.getRuleIdByLocation(r, s, a, i), c = l ? this._dataValidationModel.getRuleById(r, s, l) : void 0;
34
+ if (n === !1)
35
+ return o(Promise.resolve(!1));
36
+ if (!c || c.errorStyle !== de.STOP)
37
+ return o(Promise.resolve(!0));
38
+ const u = this._dataValidatorRegistryService.getValidatorItem(c.type);
39
+ return !u || await this._sheetsDataValidationValidatorService.validatorCell(r, s, a, i) === Kt.VALID ? o(Promise.resolve(!0)) : (this._dialogService.open({
40
+ width: 368,
41
+ title: {
42
+ title: this._localeService.t("dataValidation.alert.title")
43
+ },
44
+ id: "reject-input-dialog",
45
+ children: {
46
+ title: u.getRuleFinalError(c, { row: a, col: i, unitId: r, subUnitId: s })
47
+ },
48
+ footer: {
49
+ title: An.createElement(
50
+ Bt,
51
+ {
52
+ type: "primary",
53
+ onClick: () => this._dialogService.close("reject-input-dialog")
54
+ },
55
+ this._localeService.t("dataValidation.alert.ok")
56
+ )
57
+ },
58
+ onClose: () => {
59
+ this._dialogService.close("reject-input-dialog");
60
+ }
61
+ }), o(Promise.resolve(!1)));
62
+ }
63
+ }
64
+ );
65
+ }
66
+ showReject(t) {
67
+ this._dialogService.open({
68
+ width: 368,
69
+ title: {
70
+ title: this._localeService.t("dataValidation.alert.title")
71
+ },
72
+ id: "reject-input-dialog",
73
+ children: {
74
+ title: t
75
+ },
76
+ footer: {
77
+ title: An.createElement(
78
+ Bt,
79
+ {
80
+ type: "primary",
81
+ onClick: () => this._dialogService.close("reject-input-dialog")
82
+ },
83
+ this._localeService.t("dataValidation.alert.ok")
84
+ )
85
+ },
86
+ onClose: () => {
87
+ this._dialogService.close("reject-input-dialog");
88
+ }
89
+ });
90
+ }
91
+ };
92
+ ce = qa([
93
+ xt(0, b(vn)),
94
+ xt(1, b(at)),
95
+ xt(2, b(bt)),
96
+ xt(3, Na),
97
+ xt(4, b(Q)),
98
+ xt(5, b(_a))
99
+ ], ce);
100
+ const Ja = "univer-dv-date-dropdown", Qa = "univer-dv-date-dropdown-btns", Un = {
101
+ dvDateDropdown: Ja,
102
+ dvDateDropdownBtns: Qa
103
+ }, ti = (t) => {
104
+ if (t == null || typeof t == "boolean")
105
+ return;
106
+ if (typeof t == "number" || !Number.isNaN(+t))
107
+ return qe(Je.format("yyyy-MM-dd HH:mm:ss", Number(t)));
108
+ const e = qe(t);
109
+ if (e.isValid())
110
+ return e;
111
+ };
112
+ function ei(t) {
113
+ var v;
114
+ const { location: e, hideFn: o } = t, { worksheet: n, row: a, col: i, unitId: r, subUnitId: s, workbook: l } = e, c = T(tt), u = T(ce), h = n.getCell(a, i), d = mt(n.getCellRaw(a, i)), C = ti(d), [p, R] = j(C), w = p && p.isValid() ? p : qe(), g = T(Q), f = T(at), _ = f.getRuleByLocation(r, s, a, i);
115
+ if (!_)
116
+ return null;
117
+ const V = f.getValidator(_.type);
118
+ if (!h || !V)
119
+ return;
120
+ const S = !!((v = _.bizInfo) != null && v.showTime), I = async () => {
121
+ var F, N, B;
122
+ if (!w)
123
+ return;
124
+ const P = w.format(S ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), U = (F = Je.parseDate(P)) == null ? void 0 : F.v, O = l.getStyles().getStyleByCell(h), L = (B = (N = O == null ? void 0 : O.n) == null ? void 0 : N.pattern) != null ? B : "", A = Ma(L);
125
+ _.errorStyle !== de.STOP || await V.validator({
126
+ value: U,
127
+ unitId: r,
128
+ subUnitId: s,
129
+ row: a,
130
+ column: i,
131
+ worksheet: n,
132
+ workbook: l,
133
+ interceptValue: P.replace("Z", "").replace("T", " "),
134
+ t: xo.NUMBER
135
+ }, _) ? (o(), await c.executeCommand(rn.id, {
136
+ visible: !1,
137
+ eventType: nn.Keyboard,
138
+ unitId: r,
139
+ keycode: ln.ESC
140
+ }), await c.executeCommand(_n.id, {
141
+ unitId: r,
142
+ subUnitId: s,
143
+ range: {
144
+ startColumn: i,
145
+ endColumn: i,
146
+ startRow: a,
147
+ endRow: a
148
+ },
149
+ value: {
150
+ v: U,
151
+ t: 2,
152
+ p: null,
153
+ f: null,
154
+ si: null,
155
+ s: {
156
+ n: {
157
+ pattern: S ? A === "datetime" ? L : "yyyy-MM-dd hh:mm:ss" : A === "date" ? L : "yyyy-MM-dd"
158
+ }
159
+ }
160
+ }
161
+ })) : u.showReject(V.getRuleFinalError(_, { row: a, col: i, unitId: r, subUnitId: s }));
162
+ };
163
+ return /* @__PURE__ */ Y("div", { className: Un.dvDateDropdown, children: [
164
+ /* @__PURE__ */ m(
165
+ aa,
166
+ {
167
+ defaultValue: w,
168
+ pickerValue: w,
169
+ showTime: S || void 0,
170
+ onSelect: async (y) => {
171
+ R(y);
172
+ },
173
+ onPanelChange: (y) => {
174
+ R(y);
175
+ },
176
+ disabledDate: (y) => !Je.parseDate(y.format("YYYY-MM-DD"))
177
+ }
178
+ ),
179
+ /* @__PURE__ */ m("div", { className: Un.dvDateDropdownBtns, children: /* @__PURE__ */ m(Bt, { size: "small", type: "primary", onClick: I, disabled: !w.isValid(), children: g.t("dataValidation.alert.ok") }) })
180
+ ] });
181
+ }
182
+ var ut = function() {
183
+ return ut = Object.assign || function(t) {
184
+ for (var e, o = 1, n = arguments.length; o < n; o++) {
185
+ e = arguments[o];
186
+ for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && (t[a] = e[a]);
187
+ }
188
+ return t;
189
+ }, ut.apply(this, arguments);
190
+ }, ni = function(t, e) {
191
+ var o = {};
192
+ for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (o[n] = t[n]);
193
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
194
+ for (var a = 0, n = Object.getOwnPropertySymbols(t); a < n.length; a++)
195
+ e.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[a]) && (o[n[a]] = t[n[a]]);
196
+ return o;
197
+ }, Ot = Mt(function(t, e) {
198
+ var o = t.icon, n = t.id, a = t.className, i = t.extend, r = ni(t, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(n, " ").concat(a || "").trim(), l = Jt("_".concat(ii()));
199
+ return Co(o, "".concat(n), { defIds: o.defIds, idSuffix: l.current }, ut({ ref: e, className: s }, r), i);
200
+ });
201
+ function Co(t, e, o, n, a) {
202
+ return Et(t.tag, ut(ut({ key: e }, oi(t, o, a)), n), (ai(t, o).children || []).map(function(i, r) {
203
+ return Co(i, "".concat(e, "-").concat(t.tag, "-").concat(r), o, void 0, a);
204
+ }));
205
+ }
206
+ function oi(t, e, o) {
207
+ var n = ut({}, t.attrs);
208
+ o != null && o.colorChannel1 && n.fill === "colorChannel1" && (n.fill = o.colorChannel1), t.tag === "mask" && n.id && (n.id = n.id + e.idSuffix), Object.entries(n).forEach(function(i) {
209
+ var r = i[0], s = i[1];
210
+ r === "mask" && typeof s == "string" && (n[r] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
211
+ });
212
+ var a = e.defIds;
213
+ return !a || a.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(i) {
214
+ var r = i[0], s = i[1];
215
+ typeof s == "string" && (n[r] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
216
+ })), n;
217
+ }
218
+ function ai(t, e) {
219
+ var o, n = e.defIds;
220
+ return !n || n.length === 0 ? t : t.tag === "defs" && (!((o = t.children) === null || o === void 0) && o.length) ? ut(ut({}, t), { children: t.children.map(function(a) {
221
+ return typeof a.attrs.id == "string" && n && n.indexOf(a.attrs.id) > -1 ? ut(ut({}, a), { attrs: ut(ut({}, a.attrs), { id: a.attrs.id + e.idSuffix }) }) : a;
222
+ }) }) : t;
223
+ }
224
+ function ii() {
225
+ return Math.random().toString(36).substring(2, 8);
226
+ }
227
+ Ot.displayName = "UniverIcon";
228
+ var ri = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Io = Mt(function(t, e) {
229
+ return Et(Ot, Object.assign({}, t, {
230
+ id: "check-mark-single",
231
+ ref: e,
232
+ icon: ri
233
+ }));
234
+ });
235
+ Io.displayName = "CheckMarkSingle";
236
+ var si = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, wo = Mt(function(t, e) {
237
+ return Et(Ot, Object.assign({}, t, {
238
+ id: "data-validation-single",
239
+ ref: e,
240
+ icon: si
241
+ }));
242
+ });
243
+ wo.displayName = "DataValidationSingle";
244
+ var li = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Rn = Mt(function(t, e) {
245
+ return Et(Ot, Object.assign({}, t, {
246
+ id: "delete-single",
247
+ ref: e,
248
+ icon: li
249
+ }));
250
+ });
251
+ Rn.displayName = "DeleteSingle";
252
+ var di = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] }, Ro = Mt(function(t, e) {
253
+ return Et(Ot, Object.assign({}, t, {
254
+ id: "increase-single",
255
+ ref: e,
256
+ icon: di
257
+ }));
258
+ });
259
+ Ro.displayName = "IncreaseSingle";
260
+ var ci = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Do = Mt(function(t, e) {
261
+ return Et(Ot, Object.assign({}, t, {
262
+ id: "more-down-single",
263
+ ref: e,
264
+ icon: ci
265
+ }));
266
+ });
267
+ Do.displayName = "MoreDownSingle";
268
+ var ui = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Vo = Mt(function(t, e) {
269
+ return Et(Ot, Object.assign({}, t, {
270
+ id: "more-up-single",
271
+ ref: e,
272
+ icon: ui
273
+ }));
274
+ });
275
+ Vo.displayName = "MoreUpSingle";
276
+ var hi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_622_8", style: { maskType: "alpha" }, width: 16, height: 16, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#D9D9D9", d: "M0 0H16V16H0z" } }] }, { tag: "g", attrs: { fill: "currentColor", mask: "url(#mask0_622_8)" }, children: [{ tag: "path", attrs: { d: "M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z" } }] }] }, yo = Mt(function(t, e) {
277
+ return Et(Ot, Object.assign({}, t, {
278
+ id: "sequence-single",
279
+ ref: e,
280
+ icon: hi
281
+ }));
282
+ });
283
+ yo.displayName = "SequenceSingle";
284
+ var pi = Object.getOwnPropertyDescriptor, mi = (t, e, o, n) => {
285
+ for (var a = n > 1 ? void 0 : n ? pi(e, o) : e, i = t.length - 1, r; i >= 0; i--)
286
+ (r = t[i]) && (a = r(a) || a);
287
+ return a;
288
+ }, Bn = (t, e) => (o, n) => e(o, n, t);
289
+ let ft = class extends Vt {
290
+ constructor(e, o) {
291
+ super();
292
+ E(this, "_open$", new Nn(!1));
293
+ E(this, "open$", this._open$.pipe(Ya()));
294
+ E(this, "_activeRule");
295
+ E(this, "_activeRule$", new Nn(void 0));
296
+ E(this, "activeRule$", this._activeRule$.asObservable());
297
+ E(this, "_closeDisposable", null);
298
+ this._univerInstanceService = e, this._sidebarService = o, this.disposeWithMe(
299
+ this._univerInstanceService.getCurrentTypeOfUnit$(X.UNIVER_SHEET).pipe(In((n) => !n)).subscribe(() => {
300
+ this.close();
301
+ })
302
+ ), this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((n) => {
303
+ n.id === Me && (n.visible || setTimeout(() => {
304
+ this._sidebarService.sidebarOptions$.next({ visible: !1 });
305
+ }));
306
+ }));
307
+ }
308
+ get activeRule() {
309
+ return this._activeRule;
310
+ }
311
+ get isOpen() {
312
+ return this._open$.getValue();
313
+ }
314
+ dispose() {
315
+ var e;
316
+ super.dispose(), this._open$.next(!1), this._open$.complete(), this._activeRule$.complete(), (e = this._closeDisposable) == null || e.dispose();
317
+ }
318
+ open() {
319
+ this._open$.next(!0);
320
+ }
321
+ close() {
322
+ var e;
323
+ this._open$.next(!1), (e = this._closeDisposable) == null || e.dispose();
324
+ }
325
+ setCloseDisposable(e) {
326
+ this._closeDisposable = jo(() => {
327
+ e.dispose(), this._closeDisposable = null;
328
+ });
329
+ }
330
+ setActiveRule(e) {
331
+ this._activeRule = e, this._activeRule$.next(e);
332
+ }
333
+ };
334
+ ft = mi([
335
+ Bn(0, rt),
336
+ Bn(1, mo)
337
+ ], ft);
338
+ function gi() {
339
+ const t = T(Dt), e = St(t.activeDropdown$, t.activeDropdown), o = T(Ae);
340
+ if (!e)
341
+ return null;
342
+ const { location: n, componentKey: a } = e, i = o.get(a), r = `${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;
343
+ return i ? /* @__PURE__ */ m(
344
+ i,
345
+ {
346
+ location: n,
347
+ hideFn: () => {
348
+ t.hideDropdown();
349
+ }
350
+ },
351
+ r
352
+ ) : null;
353
+ }
354
+ const Mo = "sheet.ui.dropdown";
355
+ var fi = Object.getOwnPropertyDescriptor, vi = (t, e, o, n) => {
356
+ for (var a = n > 1 ? void 0 : n ? fi(e, o) : e, i = t.length - 1, r; i >= 0; i--)
357
+ (r = t[i]) && (a = r(a) || a);
358
+ return a;
359
+ }, Lt = (t, e) => (o, n) => e(o, n, t);
360
+ let Dt = class extends Vt {
361
+ constructor(e, o, n, a, i, r, s) {
362
+ super();
363
+ E(this, "_activeDropdown");
364
+ E(this, "_activeDropdown$", new Xa());
365
+ E(this, "_currentPopup", null);
366
+ E(this, "activeDropdown$", this._activeDropdown$.asObservable());
367
+ E(this, "_zenVisible", !1);
368
+ this._canvasPopupManagerService = e, this._univerInstanceService = o, this._dataValidatorRegistryService = n, this._zenZoneService = a, this._renderManagerService = i, this._dataValidationModel = r, this._sheetsSelectionsService = s, this._init(), this._initSelectionChange(), this.disposeWithMe(() => {
369
+ this._activeDropdown$.complete();
370
+ });
371
+ }
372
+ get activeDropdown() {
373
+ return this._activeDropdown;
374
+ }
375
+ _init() {
376
+ this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
377
+ this._zenVisible = e, e && this.hideDropdown();
378
+ }));
379
+ }
380
+ _getDropdownByCell(e, o, n, a) {
381
+ const i = e ? this._univerInstanceService.getUnit(e, X.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(X.UNIVER_SHEET);
382
+ if (!i)
383
+ return;
384
+ const r = o ? i.getSheetBySheetId(o) : i.getActiveSheet();
385
+ if (!r)
386
+ return;
387
+ const s = this._dataValidationModel.getRuleByLocation(i.getUnitId(), r.getSheetId(), n, a);
388
+ if (!s)
389
+ return;
390
+ const l = this._dataValidatorRegistryService.getValidatorItem(s.type);
391
+ return l == null ? void 0 : l.dropdown;
392
+ }
393
+ _initSelectionChange() {
394
+ this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe((e) => {
395
+ e && e.every((o) => !(o.primary && this._getDropdownByCell(o.primary.unitId, o.primary.sheetId, o.primary.actualRow, o.primary.actualColumn))) && this.hideDropdown();
396
+ }));
397
+ }
398
+ showDropdown(e, o = !0) {
399
+ const { location: n } = e, { row: a, col: i, unitId: r, subUnitId: s } = n;
400
+ if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
401
+ return;
402
+ this._activeDropdown = e, this._activeDropdown$.next(this._activeDropdown);
403
+ const l = this._renderManagerService.getRenderById(Yo), c = this._canvasPopupManagerService.attachPopupToCell(
404
+ a,
405
+ i,
406
+ {
407
+ componentKey: Mo,
408
+ onClickOutside: () => {
409
+ o && this.hideDropdown();
410
+ },
411
+ offset: [0, 3],
412
+ excludeOutside: [l == null ? void 0 : l.engine.getCanvasElement()].filter(Boolean)
413
+ },
414
+ r,
415
+ s
416
+ );
417
+ if (!c)
418
+ throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");
419
+ const u = new Xo();
420
+ u.add(c), u.add({
421
+ dispose: () => {
422
+ var h, d;
423
+ (d = (h = this._activeDropdown) == null ? void 0 : h.onHide) == null || d.call(h);
424
+ }
425
+ }), this._currentPopup = u;
426
+ }
427
+ hideDropdown() {
428
+ this._activeDropdown && (this._currentPopup && this._currentPopup.dispose(), this._currentPopup = null, this._activeDropdown = null, this._activeDropdown$.next(null));
429
+ }
430
+ showDataValidationDropdown(e, o, n, a, i) {
431
+ const r = this._univerInstanceService.getUnit(e, X.UNIVER_SHEET);
432
+ if (!r)
433
+ return;
434
+ const s = r.getSheetBySheetId(o);
435
+ if (!s)
436
+ return;
437
+ const l = this._dataValidationModel.getRuleByLocation(r.getUnitId(), s.getSheetId(), n, a);
438
+ if (!l)
439
+ return;
440
+ const c = this._dataValidatorRegistryService.getValidatorItem(l.type);
441
+ if (!c || !c.dropdown) {
442
+ this.hideDropdown();
443
+ return;
444
+ }
445
+ this.showDropdown({
446
+ location: {
447
+ workbook: r,
448
+ worksheet: s,
449
+ row: n,
450
+ col: a,
451
+ unitId: e,
452
+ subUnitId: o
453
+ },
454
+ componentKey: c.dropdown,
455
+ onHide: i
456
+ });
457
+ }
458
+ };
459
+ Dt = vi([
460
+ Lt(0, b(Ea)),
461
+ Lt(1, rt),
462
+ Lt(2, b(bt)),
463
+ Lt(3, go),
464
+ Lt(4, yt),
465
+ Lt(5, b(at)),
466
+ Lt(6, b(Qn))
467
+ ], Dt);
468
+ const Me = "DataValidationPanel", Ht = {
469
+ id: "data-validation.operation.open-validation-panel",
470
+ type: ae.OPERATION,
471
+ handler(t, e) {
472
+ if (!e)
473
+ return !1;
474
+ const { ruleId: o, isAdd: n } = e, a = t.get(ft), i = t.get(ke), r = t.get(rt), s = t.get(mo), l = to(r);
475
+ if (!l) return !1;
476
+ const { unitId: c, subUnitId: u } = l, h = o ? i.getRuleById(c, u, o) : void 0;
477
+ a.open(), a.setActiveRule(h && {
478
+ unitId: c,
479
+ subUnitId: u,
480
+ rule: h
481
+ });
482
+ const d = s.open({
483
+ id: Me,
484
+ header: { title: n ? "dataValidation.panel.addTitle" : "dataValidation.panel.title" },
485
+ children: { label: Me },
486
+ width: 312,
487
+ onClose: () => a.close()
488
+ });
489
+ return a.setCloseDisposable(d), !0;
490
+ }
491
+ }, Dn = {
492
+ id: "data-validation.operation.close-validation-panel",
493
+ type: ae.OPERATION,
494
+ handler(t) {
495
+ return t.get(ft).close(), !0;
496
+ }
497
+ }, Eo = {
498
+ id: "data-validation.operation.toggle-validation-panel",
499
+ type: ae.OPERATION,
500
+ handler(t) {
501
+ const e = t.get(tt), o = t.get(ft);
502
+ return o.open(), o.isOpen ? e.executeCommand(Dn.id) : e.executeCommand(Ht.id), !0;
503
+ }
504
+ }, Fe = {
505
+ type: ae.OPERATION,
506
+ id: "sheet.operation.show-data-validation-dropdown",
507
+ handler(t, e) {
508
+ if (!e)
509
+ return !1;
510
+ const o = t.get(Dt), { unitId: n, subUnitId: a, row: i, column: r } = e, s = o.activeDropdown, l = s == null ? void 0 : s.location;
511
+ return l && l.unitId === n && l.subUnitId === a && l.row === i && l.col === r || o.showDataValidationDropdown(
512
+ n,
513
+ a,
514
+ i,
515
+ r
516
+ ), !0;
517
+ }
518
+ }, bo = {
519
+ type: ae.OPERATION,
520
+ id: "sheet.operation.hide-data-validation-dropdown",
521
+ handler(t, e) {
522
+ return e ? (t.get(Dt).hideDropdown(), !0) : !1;
523
+ }
524
+ }, Ft = "#ECECEC", Vn = "sheets-data-validation-ui.config", Ee = {}, _i = "univer-dv-list-dropdown", Si = "univer-dv-list-dropdown-title", Ci = "univer-dv-list-dropdown-list", Ii = "univer-dv-list-dropdown-list-container", wi = "univer-dv-list-dropdown-selected-icon", Ri = "univer-dv-list-dropdown-item-container", Di = "univer-dv-list-dropdown-item", Vi = "univer-dv-list-dropdown-split", yi = "univer-dv-list-dropdown-edit", _t = {
525
+ dvListDropdown: _i,
526
+ dvListDropdownTitle: Si,
527
+ dvListDropdownList: Ci,
528
+ dvListDropdownListContainer: Ii,
529
+ dvListDropdownSelectedIcon: wi,
530
+ dvListDropdownItemContainer: Ri,
531
+ dvListDropdownItem: Di,
532
+ dvListDropdownSplit: Vi,
533
+ dvListDropdownEdit: yi
534
+ }, Mi = (t) => {
535
+ var S, I;
536
+ const { value: e, onChange: o, multiple: n, options: a, title: i, onEdit: r, style: s, filter: l, location: c } = t, u = T(Q), h = T(mn), d = l == null ? void 0 : l.toLowerCase(), { row: C, col: p, unitId: R, subUnitId: w } = c, g = a.filter((v) => d ? v.label.toLowerCase().includes(d) : !0), f = (I = (S = h.getConfig(Vn)) == null ? void 0 : S.showEditOnDropdown) != null ? I : !0, _ = T(eo), V = $t(() => _.permissionCheckWithRanges(
537
+ {
538
+ workbookTypes: [Ve],
539
+ rangeTypes: [De],
540
+ worksheetTypes: [Re]
541
+ },
542
+ [{ startColumn: p, startRow: C, endColumn: p, endRow: C }],
543
+ R,
544
+ w
545
+ ), [_, p, C, R, w]);
546
+ return /* @__PURE__ */ Y("div", { className: _t.dvListDropdown, style: s, children: [
547
+ /* @__PURE__ */ m("div", { className: _t.dvListDropdownTitle, children: i }),
548
+ /* @__PURE__ */ m("div", { className: _t.dvListDropdownList, children: /* @__PURE__ */ m(ia, { children: /* @__PURE__ */ m("div", { className: _t.dvListDropdownListContainer, children: g.map((v, y) => {
549
+ const P = e.indexOf(v.value) > -1, U = () => {
550
+ let L;
551
+ P ? L = new Set(e.filter((F) => F !== v.value)) : L = new Set(n ? [...e, v.value] : [v.value]);
552
+ const A = [];
553
+ a.forEach((F) => {
554
+ L.has(F.value) && A.push(F.value);
555
+ }), o(A);
556
+ }, O = v.label.toLocaleLowerCase().indexOf(d);
557
+ return /* @__PURE__ */ Y("div", { className: _t.dvListDropdownItemContainer, onClick: U, children: [
558
+ /* @__PURE__ */ m("div", { className: _t.dvListDropdownItem, style: { background: v.color || Ft }, children: d && v.label.toLowerCase().includes(d) ? /* @__PURE__ */ Y(Rt, { children: [
559
+ /* @__PURE__ */ m("span", { children: v.label.substring(0, O) }),
560
+ /* @__PURE__ */ m("span", { style: { fontWeight: "bold" }, children: v.label.substring(O, O + d.length) }),
561
+ /* @__PURE__ */ m("span", { children: v.label.substring(O + d.length) })
562
+ ] }) : v.label }),
563
+ /* @__PURE__ */ m("div", { className: _t.dvListDropdownSelectedIcon, children: P ? /* @__PURE__ */ m(Io, {}) : null })
564
+ ] }, y);
565
+ }) }) }, l) }),
566
+ f && V ? /* @__PURE__ */ Y(Rt, { children: [
567
+ /* @__PURE__ */ m("div", { className: _t.dvListDropdownSplit }),
568
+ /* @__PURE__ */ m("div", { className: _t.dvListDropdownEdit, children: /* @__PURE__ */ m("a", { onClick: r, children: u.t("dataValidation.list.edit") }) })
569
+ ] }) : null
570
+ ] });
571
+ };
572
+ function Ei(t) {
573
+ var N, B, x, z;
574
+ const { location: e, hideFn: o } = t, { worksheet: n, row: a, col: i, unitId: r, subUnitId: s } = e, l = T(ke), [c, u] = j(""), h = T(tt), d = T(Q), [C, p] = j(""), R = T(ho), w = T(rt), g = $t(() => l.ruleChange$.pipe(wn(16)), []), f = T(at);
575
+ St(g);
576
+ const _ = Ua.useContext(), V = ((B = (N = _.current) == null ? void 0 : N.right) != null ? B : 0) - ((z = (x = _.current) == null ? void 0 : x.left) != null ? z : 0);
577
+ if (wt(() => {
578
+ const H = h.onCommandExecuted((G) => {
579
+ var J, et;
580
+ if (G.id === ja.id) {
581
+ const nt = G.params, { unitId: st } = nt, it = w.getUnit(st, X.UNIVER_DOC);
582
+ if (!it || !R.isVisible().visible) return;
583
+ const lt = zo.transform.getPlainText((et = (J = it.getSnapshot().body) == null ? void 0 : J.dataStream) != null ? et : "");
584
+ u(lt);
585
+ }
586
+ });
587
+ return () => {
588
+ H.dispose();
589
+ };
590
+ }, [h, R, w]), !n)
591
+ return null;
592
+ const S = f.getRuleByLocation(r, s, a, i);
593
+ if (!S)
594
+ return null;
595
+ const I = f.getValidator(S.type);
596
+ if (!I)
597
+ return null;
598
+ const v = n.getCell(a, i), y = (S == null ? void 0 : S.renderMode) === ct.CUSTOM || (S == null ? void 0 : S.renderMode) === void 0;
599
+ if (!v || !S || !I || I.id.indexOf(K.LIST) !== 0)
600
+ return;
601
+ const P = S.type === K.LIST_MULTIPLE, U = I.getListWithColor(S, r, s), O = C || Sa(n.getCellRaw(a, i)), L = ao(O), A = () => {
602
+ h.executeCommand(Ht.id, {
603
+ ruleId: S.uid
604
+ }), o();
605
+ }, F = U.map((H) => ({
606
+ label: H.label,
607
+ value: H.label,
608
+ color: y || H.color ? H.color : "transparent"
609
+ }));
610
+ return /* @__PURE__ */ m(
611
+ Mi,
612
+ {
613
+ style: { minWidth: V, maxWidth: Math.max(V, 200) },
614
+ title: P ? d.t("dataValidation.listMultiple.dropdown") : d.t("dataValidation.list.dropdown"),
615
+ value: L,
616
+ multiple: P,
617
+ onChange: async (H) => {
618
+ const G = io(H), J = {
619
+ unitId: r,
620
+ subUnitId: s,
621
+ range: {
622
+ startColumn: i,
623
+ endColumn: i,
624
+ startRow: a,
625
+ endRow: a
626
+ },
627
+ value: {
628
+ v: G,
629
+ p: null,
630
+ f: null,
631
+ si: null
632
+ }
633
+ };
634
+ R.isVisible() && h.executeCommand(rn.id, {
635
+ visible: !1,
636
+ eventType: nn.Keyboard,
637
+ unitId: r,
638
+ keycode: ln.ESC
639
+ }), p(G), P || o(), R.isVisible().visible && await h.executeCommand(rn.id, {
640
+ visible: !1,
641
+ eventType: nn.Keyboard,
642
+ unitId: r,
643
+ keycode: ln.ESC
644
+ }), h.executeCommand(_n.id, J);
645
+ },
646
+ options: F,
647
+ onEdit: A,
648
+ filter: c,
649
+ location: e
650
+ }
651
+ );
652
+ }
653
+ const bi = "univer-data-validation-options-button", Oi = "univer-data-validation-options-button-icon", We = {
654
+ dataValidationOptionsButton: bi,
655
+ dataValidationOptionsButtonIcon: Oi
656
+ };
657
+ function Li(t) {
658
+ var c;
659
+ const e = T(Q), o = T(Ae), { value: n, onChange: a, extraComponent: i } = t, [r, s] = j(!1), l = i ? o.get(i) : null;
660
+ return /* @__PURE__ */ Y(Rt, { children: [
661
+ /* @__PURE__ */ Y("div", { className: We.dataValidationOptionsButton, onClick: () => s(!r), children: [
662
+ e.t("dataValidation.panel.options"),
663
+ r ? /* @__PURE__ */ m(Vo, { className: We.dataValidationOptionsButtonIcon }) : /* @__PURE__ */ m(Do, { className: We.dataValidationOptionsButtonIcon })
664
+ ] }),
665
+ r && /* @__PURE__ */ Y(Rt, { children: [
666
+ l ? /* @__PURE__ */ m(l, { value: n, onChange: a }) : null,
667
+ /* @__PURE__ */ m(
668
+ q,
669
+ {
670
+ label: e.t("dataValidation.panel.invalid"),
671
+ children: /* @__PURE__ */ Y(
672
+ fn,
673
+ {
674
+ value: `${(c = n.errorStyle) != null ? c : de.WARNING}`,
675
+ onChange: (u) => a({ ...n, errorStyle: +u }),
676
+ children: [
677
+ /* @__PURE__ */ m(Nt, { value: `${de.WARNING}`, children: e.t("dataValidation.panel.showWarning") }),
678
+ /* @__PURE__ */ m(Nt, { value: `${de.STOP}`, children: e.t("dataValidation.panel.rejectInput") })
679
+ ]
680
+ }
681
+ )
682
+ }
683
+ ),
684
+ /* @__PURE__ */ m(
685
+ q,
686
+ {
687
+ label: e.t("dataValidation.panel.messageInfo"),
688
+ children: /* @__PURE__ */ m(
689
+ Pe,
690
+ {
691
+ checked: n.showErrorMessage,
692
+ onChange: () => a({
693
+ ...n,
694
+ showErrorMessage: !n.showErrorMessage
695
+ }),
696
+ children: e.t("dataValidation.panel.showInfo")
697
+ }
698
+ )
699
+ }
700
+ ),
701
+ n.showErrorMessage ? /* @__PURE__ */ m(q, { children: /* @__PURE__ */ m(Ut, { value: n.error, onChange: (u) => a({ ...n, error: u }) }) }) : null
702
+ ] })
703
+ ] });
704
+ }
705
+ const Ti = "univer-data-validation-detail", Pi = "univer-data-validation-detail-form-item", Ai = "univer-data-validation-detail-buttons", ki = "univer-data-validation-detail-button", jt = {
706
+ dataValidationDetail: Ti,
707
+ dataValidationDetailFormItem: Pi,
708
+ dataValidationDetailButtons: Ai,
709
+ dataValidationDetailButton: ki
710
+ }, Fi = (t) => Ko(
711
+ async (e, o, n, a) => {
712
+ const i = await t.executeCommand(e, o, n);
713
+ a == null || a(i);
714
+ },
715
+ 1e3
716
+ );
717
+ function Ni(t, e, o) {
718
+ var n, a, i, r;
719
+ return e ? ((a = (n = t.getUnit(e)) == null ? void 0 : n.getSheetBySheetName(o)) == null ? void 0 : a.getSheetId()) || "" : ((r = (i = t.getCurrentUnitForType(X.UNIVER_SHEET)) == null ? void 0 : i.getSheetBySheetName(o)) == null ? void 0 : r.getSheetId()) || "";
720
+ }
721
+ function Ui() {
722
+ var lt;
723
+ const [t, e] = j(0), o = T(ft), n = St(o.activeRule$, o.activeRule), { unitId: a, subUnitId: i, rule: r } = n || {}, s = r.uid, l = T(bt), c = T(rt), u = T(Ae), h = T(tt), d = T(ke), C = T(Q), [p, R] = j(r), w = l.getValidatorItem(p.type), [g, f] = j(!1), _ = l.getValidatorsByScope(Ha.SHEET), [V, S] = j(() => p.ranges.map((M) => ({ unitId: "", sheetId: "", range: M }))), I = $t(() => Fi(h), [h]), [v, y] = j(!1), [P, U] = j(!1), O = Jt(null), L = T(Qn);
724
+ if (wt(() => () => {
725
+ const M = L.getCurrentLastSelection();
726
+ M && L.setSelections([M]);
727
+ }, [L]), wt(() => {
728
+ h.onCommandExecuted((M) => {
729
+ (M.id === Go.id || M.id === Zo.id) && setTimeout(() => {
730
+ const D = d.getRuleById(a, i, s);
731
+ e((k) => k + 1), D && (R(D), S(D.ranges.map((k) => ({ unitId: "", sheetId: "", range: k }))));
732
+ }, 20);
733
+ });
734
+ }, [h, d, s, i, a]), !w)
735
+ return null;
736
+ const A = w.operators, F = w.operatorNames, N = p.operator ? xa.includes(p.operator) : !1, B = () => {
737
+ var M, D, k;
738
+ (D = (M = O.current) == null ? void 0 : M.editor) != null && D.isFocus() && x((k = O.current) == null ? void 0 : k.getValue()), !(!p.ranges.length || v) && (w.validatorFormula(p, a, i).success ? o.setActiveRule(null) : f(!0));
739
+ }, x = dn((M) => {
740
+ const D = M.split(",").filter(Boolean).map(Ka).map((W) => {
741
+ const Ct = W.sheetName;
742
+ if (Ct) {
743
+ const $o = Ni(c, W.unitId, Ct);
744
+ return { ...W, sheetId: $o };
745
+ }
746
+ return {
747
+ ...W,
748
+ sheetId: ""
749
+ };
750
+ });
751
+ if (qo(D, V))
752
+ return;
753
+ S(D);
754
+ const k = D.filter((W) => (!W.unitId || W.unitId === a) && (!W.sheetId || W.sheetId === i)).map((W) => W.range);
755
+ if (R({
756
+ ...p,
757
+ ranges: k
758
+ }), k.length === 0)
759
+ return;
760
+ const $ = {
761
+ unitId: a,
762
+ subUnitId: i,
763
+ ruleId: s,
764
+ ranges: k
765
+ };
766
+ I(ro.id, $);
767
+ }), z = (M) => {
768
+ if (En(M, Fn(p)))
769
+ return;
770
+ R({
771
+ ...p,
772
+ ...M
773
+ });
774
+ const D = {
775
+ unitId: a,
776
+ subUnitId: i,
777
+ ruleId: s,
778
+ setting: M
779
+ };
780
+ I(
781
+ On.id,
782
+ D,
783
+ void 0
784
+ );
785
+ }, H = async () => {
786
+ await h.executeCommand(so.id, {
787
+ ruleId: s,
788
+ unitId: a,
789
+ subUnitId: i
790
+ }), o.setActiveRule(null);
791
+ }, G = {
792
+ type: p.type,
793
+ operator: p.operator,
794
+ formula1: p.formula1,
795
+ formula2: p.formula2,
796
+ allowBlank: p.allowBlank
797
+ }, J = (M) => {
798
+ const D = l.getValidatorItem(M);
799
+ if (!D)
800
+ return;
801
+ const k = D.operators, $ = d.getRuleById(a, i, s), W = M === ($ == null ? void 0 : $.type) || M.includes("list") && ($ != null && $.type.includes("list")) ? {
802
+ ...$,
803
+ type: M
804
+ } : {
805
+ ...p,
806
+ type: M,
807
+ operator: k[0],
808
+ formula1: void 0,
809
+ formula2: void 0
810
+ };
811
+ R(W), h.executeCommand(On.id, {
812
+ unitId: a,
813
+ subUnitId: i,
814
+ ruleId: p.uid,
815
+ setting: Fn(W)
816
+ });
817
+ }, et = u.get(w.formulaInput), nt = $t(() => V.map((M) => _o(M.range)).join(","), []), st = kn(p), it = (M) => {
818
+ En(M, kn(p)) || (R({
819
+ ...p,
820
+ ...M
821
+ }), I(
822
+ Ca.id,
823
+ {
824
+ unitId: a,
825
+ subUnitId: i,
826
+ ruleId: s,
827
+ options: M
828
+ }
829
+ ));
830
+ };
831
+ return /* @__PURE__ */ Y("div", { className: jt.dataValidationDetail, children: [
832
+ /* @__PURE__ */ m(
833
+ q,
834
+ {
835
+ label: C.t("dataValidation.panel.range"),
836
+ error: !p.ranges.length || v ? C.t("dataValidation.panel.rangeError") : "",
837
+ children: /* @__PURE__ */ m(
838
+ Ga,
839
+ {
840
+ selectorRef: O,
841
+ unitId: a,
842
+ subUnitId: i,
843
+ initialValue: nt,
844
+ onChange: (M, D) => {
845
+ var k;
846
+ !P && ((k = O.current) != null && k.verify()) && x(D);
847
+ },
848
+ onFocusChange: (M, D) => {
849
+ var k;
850
+ U(M), !M && D && ((k = O.current) != null && k.verify()) && x(D);
851
+ },
852
+ onVerify: (M) => y(!M)
853
+ }
854
+ )
855
+ }
856
+ ),
857
+ /* @__PURE__ */ m(q, { label: C.t("dataValidation.panel.type"), children: /* @__PURE__ */ m(
858
+ en,
859
+ {
860
+ options: _ == null ? void 0 : _.map((M) => ({
861
+ label: C.t(M.title),
862
+ value: M.id
863
+ })),
864
+ value: p.type,
865
+ onChange: J,
866
+ className: jt.dataValidationDetailFormItem
867
+ }
868
+ ) }),
869
+ A != null && A.length ? /* @__PURE__ */ m(q, { label: C.t("dataValidation.panel.operator"), children: /* @__PURE__ */ m(
870
+ en,
871
+ {
872
+ options: A.map((M, D) => ({
873
+ value: `${M}`,
874
+ label: F[D]
875
+ })),
876
+ value: `${p.operator}`,
877
+ onChange: (M) => {
878
+ z({
879
+ ...G,
880
+ operator: M
881
+ });
882
+ },
883
+ className: jt.dataValidationDetailFormItem
884
+ }
885
+ ) }) : null,
886
+ et ? /* @__PURE__ */ m(q, { children: /* @__PURE__ */ m(
887
+ et,
888
+ {
889
+ isTwoFormula: N,
890
+ value: {
891
+ formula1: p.formula1,
892
+ formula2: p.formula2
893
+ },
894
+ onChange: (M) => {
895
+ z({
896
+ ...G,
897
+ ...M
898
+ });
899
+ },
900
+ showError: g,
901
+ validResult: w.validatorFormula(p, a, i),
902
+ unitId: a,
903
+ subUnitId: i,
904
+ ruleId: s
905
+ },
906
+ t + p.type
907
+ ) }) : null,
908
+ /* @__PURE__ */ m(q, { children: /* @__PURE__ */ m(
909
+ Pe,
910
+ {
911
+ checked: (lt = p.allowBlank) != null ? lt : !0,
912
+ onChange: () => {
913
+ var M;
914
+ return z({
915
+ ...G,
916
+ allowBlank: !((M = p.allowBlank) == null || M)
917
+ });
918
+ },
919
+ children: C.t("dataValidation.panel.allowBlank")
920
+ }
921
+ ) }),
922
+ /* @__PURE__ */ m(Li, { value: st, onChange: it, extraComponent: w.optionsInput }),
923
+ /* @__PURE__ */ Y("div", { className: jt.dataValidationDetailButtons, children: [
924
+ /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, onClick: H, children: C.t("dataValidation.panel.removeRule") }),
925
+ /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, type: "primary", onClick: B, children: C.t("dataValidation.panel.done") })
926
+ ] })
927
+ ] });
928
+ }
929
+ const Bi = "univer-data-validation-item-container", $i = "univer-data-validation-item-title", Wi = "univer-data-validation-item-content", Hi = "univer-data-validation-item-icon", pe = {
930
+ dataValidationItemContainer: Bi,
931
+ dataValidationItemTitle: $i,
932
+ dataValidationItemContent: Wi,
933
+ dataValidationItemIcon: Hi
934
+ }, xi = (t) => {
935
+ const { rule: e, onClick: o, unitId: n, subUnitId: a, disable: i } = t, r = T(bt), s = T(tt), l = T(ba), c = r.getValidatorItem(e.type), u = Jt(void 0), [h, d] = j(!1), C = T(zn), p = St(C.currentTheme$), R = $t(() => {
936
+ var _;
937
+ const g = (_ = p == null ? void 0 : p.loopColor2) != null ? _ : "#49B811", f = new Jo(g).toRgb();
938
+ return {
939
+ fill: `rgba(${f.r}, ${f.g}, ${f.b}, 0.1)`,
940
+ stroke: g
941
+ };
942
+ }, [p]), w = (g) => {
943
+ s.executeCommand(so.id, {
944
+ ruleId: e.uid,
945
+ unitId: n,
946
+ subUnitId: a
947
+ }), g.stopPropagation();
948
+ };
949
+ return wt(() => () => {
950
+ var g;
951
+ u.current && ((g = u.current) == null || g.forEach((f) => {
952
+ f && l.removeShape(f);
953
+ }));
954
+ }, [l]), /* @__PURE__ */ Y(
955
+ "div",
956
+ {
957
+ className: pe.dataValidationItemContainer,
958
+ onClick: o,
959
+ onMouseEnter: () => {
960
+ i || (d(!0), u.current = e.ranges.map((g) => l.addShape({
961
+ range: g,
962
+ style: R,
963
+ primary: null
964
+ })));
965
+ },
966
+ onMouseLeave: () => {
967
+ var g;
968
+ d(!1), (g = u.current) == null || g.forEach((f) => {
969
+ f && l.removeShape(f);
970
+ }), u.current = void 0;
971
+ },
972
+ children: [
973
+ /* @__PURE__ */ m("div", { className: pe.dataValidationItemTitle, children: c == null ? void 0 : c.generateRuleName(e) }),
974
+ /* @__PURE__ */ m("div", { className: pe.dataValidationItemContent, children: e.ranges.map((g) => _o(g)).join(",") }),
975
+ h ? /* @__PURE__ */ m("div", { className: pe.dataValidationItemIcon, onClick: w, children: /* @__PURE__ */ m(Rn, {}) }) : null
976
+ ]
977
+ }
978
+ );
979
+ }, ji = "univer-data-validation-list", Yi = "univer-data-validation-list-buttons", Xi = "univer-data-validation-list-button", me = {
980
+ dataValidationList: ji,
981
+ dataValidationListButtons: Yi,
982
+ dataValidationListButton: Xi
983
+ };
984
+ function zi(t) {
985
+ const e = T(at), o = T(rt), n = T(tt), a = T(Wt), i = T(ft), r = T(Q), [s, l] = j([]), { workbook: c } = t, u = St(c.activeSheet$, void 0, !0), h = c.getUnitId(), d = u == null ? void 0 : u.getSheetId();
986
+ wt(() => {
987
+ l(e.getRules(h, d));
988
+ const f = e.ruleChange$.subscribe((_) => {
989
+ _.unitId === h && _.subUnitId === d && l(e.getRules(h, d));
990
+ });
991
+ return () => {
992
+ f.unsubscribe();
993
+ };
994
+ }, [h, d, e]);
995
+ const C = async () => {
996
+ const f = lo(a), _ = {
997
+ unitId: h,
998
+ subUnitId: d,
999
+ rule: f
1000
+ };
1001
+ await n.executeCommand(Sn.id, _), i.setActiveRule({
1002
+ unitId: h,
1003
+ subUnitId: d,
1004
+ rule: f
1005
+ });
1006
+ }, p = () => {
1007
+ n.executeCommand(Ia.id, {
1008
+ unitId: h,
1009
+ subUnitId: d
1010
+ });
1011
+ }, w = ((f) => {
1012
+ const _ = o.getCurrentUnitForType(X.UNIVER_SHEET), V = _.getActiveSheet(), S = _.getUnitId(), I = V.getSheetId();
1013
+ return f.map((y) => fa(a, S, I, y.ranges) ? { ...y } : { ...y, disable: !0 });
1014
+ })(s), g = w == null ? void 0 : w.some((f) => f.disable);
1015
+ return /* @__PURE__ */ Y("div", { className: me.dataValidationList, children: [
1016
+ w == null ? void 0 : w.map((f) => {
1017
+ var _;
1018
+ return /* @__PURE__ */ m(
1019
+ xi,
1020
+ {
1021
+ unitId: h,
1022
+ subUnitId: d,
1023
+ onClick: () => {
1024
+ f.disable || i.setActiveRule({
1025
+ unitId: h,
1026
+ subUnitId: d,
1027
+ rule: f
1028
+ });
1029
+ },
1030
+ rule: f,
1031
+ disable: (_ = f.disable) != null ? _ : !1
1032
+ },
1033
+ f.uid
1034
+ );
1035
+ }),
1036
+ /* @__PURE__ */ Y("div", { className: me.dataValidationListButtons, children: [
1037
+ s.length && !g ? /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, onClick: p, children: r.t("dataValidation.panel.removeAll") }) : null,
1038
+ /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, type: "primary", onClick: C, children: r.t("dataValidation.panel.add") })
1039
+ ] })
1040
+ ] });
1041
+ }
1042
+ const Ki = () => {
1043
+ const t = T(ft), e = St(t.activeRule$, t.activeRule), o = T(rt), n = St(
1044
+ () => o.getCurrentTypeOfUnit$(X.UNIVER_SHEET),
1045
+ void 0,
1046
+ void 0,
1047
+ []
1048
+ ), a = St(() => {
1049
+ var i;
1050
+ return (i = n == null ? void 0 : n.activeSheet$) != null ? i : za(null);
1051
+ }, void 0, void 0, []);
1052
+ return !n || !a ? null : e && e.subUnitId === a.getSheetId() ? /* @__PURE__ */ m(Ui, {}, e.rule.uid) : /* @__PURE__ */ m(zi, { workbook: n });
1053
+ }, yn = "data-validation.list.dropdown", Oo = "data-validation.date.dropdown", Ne = {
1054
+ type: ae.COMMAND,
1055
+ id: "data-validation.command.addRuleAndOpen",
1056
+ handler(t) {
1057
+ const e = t.get(rt), o = to(e);
1058
+ if (!o) return !1;
1059
+ const { workbook: n, worksheet: a } = o, i = lo(t), r = t.get(tt), s = n.getUnitId(), l = a.getSheetId(), c = {
1060
+ rule: i,
1061
+ unitId: s,
1062
+ subUnitId: l
1063
+ };
1064
+ return r.syncExecuteCommand(Sn.id, c) ? (r.syncExecuteCommand(Ht.id, {
1065
+ ruleId: i.uid,
1066
+ isAdd: !0
1067
+ }), !0) : !1;
1068
+ }
1069
+ };
1070
+ var Gi = Object.getOwnPropertyDescriptor, Zi = (t, e, o, n) => {
1071
+ for (var a = n > 1 ? void 0 : n ? Gi(e, o) : e, i = t.length - 1, r; i >= 0; i--)
1072
+ (r = t[i]) && (a = r(a) || a);
1073
+ return a;
1074
+ }, Yt = (t, e) => (o, n) => e(o, n, t);
1075
+ const Tt = "SHEET_DATA_VALIDATION_ALERT";
1076
+ let ue = class extends Vt {
1077
+ constructor(t, e, o, n, a, i) {
1078
+ super(), this._hoverManagerService = t, this._cellAlertManagerService = e, this._univerInstanceService = o, this._localeService = n, this._zenZoneService = a, this._dataValidationModel = i, this._init();
1079
+ }
1080
+ _init() {
1081
+ this._initCellAlertPopup(), this._initZenService();
1082
+ }
1083
+ _initCellAlertPopup() {
1084
+ this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(wn(100)).subscribe((t) => {
1085
+ var e;
1086
+ if (t) {
1087
+ const o = this._univerInstanceService.getUnit(t.location.unitId, X.UNIVER_SHEET), n = o.getSheetBySheetId(t.location.subUnitId);
1088
+ if (!n) return;
1089
+ const a = this._dataValidationModel.getRuleByLocation(t.location.unitId, t.location.subUnitId, t.location.row, t.location.col);
1090
+ if (!a) {
1091
+ this._cellAlertManagerService.removeAlert(Tt);
1092
+ return;
1093
+ }
1094
+ if (this._dataValidationModel.validator(a, { ...t.location, workbook: o, worksheet: n }) === Kt.INVALID) {
1095
+ const r = this._cellAlertManagerService.currentAlert.get(Tt), s = (e = r == null ? void 0 : r.alert) == null ? void 0 : e.location;
1096
+ if (s && s.row === t.location.row && s.col === t.location.col && s.subUnitId === t.location.subUnitId && s.unitId === t.location.unitId) {
1097
+ this._cellAlertManagerService.removeAlert(Tt);
1098
+ return;
1099
+ }
1100
+ const l = this._dataValidationModel.getValidator(a.type);
1101
+ if (!l) {
1102
+ this._cellAlertManagerService.removeAlert(Tt);
1103
+ return;
1104
+ }
1105
+ this._cellAlertManagerService.showAlert({
1106
+ type: Ta.ERROR,
1107
+ title: this._localeService.t("dataValidation.error.title"),
1108
+ message: l == null ? void 0 : l.getRuleFinalError(a, t.location),
1109
+ location: t.location,
1110
+ width: 200,
1111
+ height: 74,
1112
+ key: Tt
1113
+ });
1114
+ return;
1115
+ }
1116
+ }
1117
+ this._cellAlertManagerService.removeAlert(Tt);
1118
+ }));
1119
+ }
1120
+ _initZenService() {
1121
+ this.disposeWithMe(this._zenZoneService.visible$.subscribe((t) => {
1122
+ t && this._cellAlertManagerService.removeAlert(Tt);
1123
+ }));
1124
+ }
1125
+ };
1126
+ ue = Zi([
1127
+ Yt(0, b(Oa)),
1128
+ Yt(1, b(La)),
1129
+ Yt(2, rt),
1130
+ Yt(3, b(Q)),
1131
+ Yt(4, go),
1132
+ Yt(5, b(at))
1133
+ ], ue);
1134
+ var qi = Object.getOwnPropertyDescriptor, Ji = (t, e, o, n) => {
1135
+ for (var a = n > 1 ? void 0 : n ? qi(e, o) : e, i = t.length - 1, r; i >= 0; i--)
1136
+ (r = t[i]) && (a = r(a) || a);
1137
+ return a;
1138
+ }, He = (t, e) => (o, n) => e(o, n, t);
1139
+ let Qt = class extends Vt {
1140
+ constructor(t, e, o) {
1141
+ super(), this._autoFillService = t, this._sheetDataValidationModel = e, this._injector = o, this._initAutoFill();
1142
+ }
1143
+ // eslint-disable-next-line max-lines-per-function
1144
+ _initAutoFill() {
1145
+ const t = () => ({ redos: [], undos: [] }), e = (n, a) => {
1146
+ const { source: i, target: r, unitId: s, subUnitId: l } = n, c = this._sheetDataValidationModel.getRuleObjectMatrix(s, l).clone(), u = sn([i, r]), [h, d] = u.ranges, { mapFunc: C } = u, p = {
1147
+ row: h.startRow,
1148
+ col: h.startColumn
1149
+ }, R = Aa(h, d), w = new Ie(), g = /* @__PURE__ */ new Set();
1150
+ R.forEach((I) => {
1151
+ const v = I.repeatStartCell, y = I.relativeRange, P = {
1152
+ startRow: p.row,
1153
+ startColumn: p.col,
1154
+ endColumn: p.col,
1155
+ endRow: p.row
1156
+ }, U = {
1157
+ startRow: v.row,
1158
+ startColumn: v.col,
1159
+ endColumn: v.col,
1160
+ endRow: v.row
1161
+ };
1162
+ Qo.foreach(y, (O, L) => {
1163
+ const A = we.getPositionRange(
1164
+ {
1165
+ startRow: O,
1166
+ startColumn: L,
1167
+ endColumn: L,
1168
+ endRow: O
1169
+ },
1170
+ P
1171
+ ), { row: F, col: N } = C(A.startRow, A.startColumn), B = this._sheetDataValidationModel.getRuleIdByLocation(s, l, F, N) || "", x = we.getPositionRange(
1172
+ {
1173
+ startRow: O,
1174
+ startColumn: L,
1175
+ endColumn: L,
1176
+ endRow: O
1177
+ },
1178
+ U
1179
+ ), { row: z, col: H } = C(x.startRow, x.startColumn);
1180
+ w.setValue(z, H, B), g.add(B);
1181
+ });
1182
+ });
1183
+ const f = Array.from(g).map((I) => ({ id: I, ranges: Qe(w, (v) => v === I) }));
1184
+ c.addRangeRules(f);
1185
+ const _ = c.diff(this._sheetDataValidationModel.getRules(s, l)), { redoMutations: V, undoMutations: S } = an(s, l, _, this._injector, "patched", a === se.ONLY_FORMAT);
1186
+ return {
1187
+ undos: S,
1188
+ redos: V
1189
+ };
1190
+ }, o = {
1191
+ id: co,
1192
+ onBeforeFillData: (n) => {
1193
+ const { source: a, unitId: i, subUnitId: r } = n;
1194
+ for (const s of a.rows)
1195
+ for (const l of a.cols) {
1196
+ const c = this._sheetDataValidationModel.getRuleByLocation(i, r, s, l);
1197
+ if (c && c.type === K.CHECKBOX) {
1198
+ this._autoFillService.setDisableApplyType(se.SERIES, !0);
1199
+ return;
1200
+ }
1201
+ }
1202
+ },
1203
+ onFillData: (n, a, i) => i === se.COPY || i === se.ONLY_FORMAT || i === se.SERIES ? e(n, i) : t(),
1204
+ onAfterFillData: () => {
1205
+ }
1206
+ };
1207
+ this.disposeWithMe(this._autoFillService.addHook(o));
1208
+ }
1209
+ };
1210
+ Qt = Ji([
1211
+ He(0, Pa),
1212
+ He(1, b(at)),
1213
+ He(2, b(Wt))
1214
+ ], Qt);
1215
+ var Qi = Object.getOwnPropertyDescriptor, tr = (t, e, o, n) => {
1216
+ for (var a = n > 1 ? void 0 : n ? Qi(e, o) : e, i = t.length - 1, r; i >= 0; i--)
1217
+ (r = t[i]) && (a = r(a) || a);
1218
+ return a;
1219
+ }, xe = (t, e) => (o, n) => e(o, n, t);
1220
+ let te = class extends Vt {
1221
+ constructor(e, o, n) {
1222
+ super();
1223
+ E(this, "_copyInfo");
1224
+ this._sheetClipboardService = e, this._sheetDataValidationModel = o, this._injector = n, this._initCopyPaste();
1225
+ }
1226
+ _initCopyPaste() {
1227
+ this._sheetClipboardService.addClipboardHook({
1228
+ id: co,
1229
+ onBeforeCopy: (e, o, n) => this._collect(e, o, n),
1230
+ onPasteCells: (e, o, n, a) => {
1231
+ const { copyType: i = Tn.COPY, pasteType: r } = a, { range: s } = e || {}, { range: l, unitId: c, subUnitId: u } = o;
1232
+ return this._generateMutations(l, { copyType: i, pasteType: r, copyRange: s, unitId: c, subUnitId: u });
1233
+ }
1234
+ });
1235
+ }
1236
+ _collect(e, o, n) {
1237
+ const a = new Ie();
1238
+ this._copyInfo = {
1239
+ unitId: e,
1240
+ subUnitId: o,
1241
+ matrix: a
1242
+ };
1243
+ const i = this._injector.invoke((l) => va(n, l, e, o));
1244
+ if (!i)
1245
+ return;
1246
+ const { rows: r, cols: s } = i;
1247
+ r.forEach((l, c) => {
1248
+ s.forEach((u, h) => {
1249
+ const d = this._sheetDataValidationModel.getRuleIdByLocation(e, o, l, u);
1250
+ a.setValue(c, h, d != null ? d : "");
1251
+ });
1252
+ });
1253
+ }
1254
+ // eslint-disable-next-line max-lines-per-function
1255
+ _generateMutations(e, o) {
1256
+ if (!this._copyInfo)
1257
+ return { redos: [], undos: [] };
1258
+ if (o.copyType === Tn.CUT)
1259
+ return this._copyInfo = null, { redos: [], undos: [] };
1260
+ if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !o.copyRange)
1261
+ return { redos: [], undos: [] };
1262
+ if ([
1263
+ he.SPECIAL_PASTE_COL_WIDTH,
1264
+ he.SPECIAL_PASTE_VALUE,
1265
+ he.SPECIAL_PASTE_FORMAT,
1266
+ he.SPECIAL_PASTE_FORMULA
1267
+ ].includes(o.pasteType))
1268
+ return { redos: [], undos: [] };
1269
+ const { unitId: a, subUnitId: i } = this._copyInfo;
1270
+ if (o.unitId !== a || i !== o.subUnitId) {
1271
+ const r = this._sheetDataValidationModel.getRuleObjectMatrix(o.unitId, o.subUnitId).clone(), s = new Ie(), l = /* @__PURE__ */ new Set(), { ranges: [c, u], mapFunc: h } = sn([o.copyRange, e]), d = Pn(c, u, !0), C = /* @__PURE__ */ new Map();
1272
+ d.forEach(({ startRange: g }) => {
1273
+ var f;
1274
+ (f = this._copyInfo) == null || f.matrix.forValue((_, V, S) => {
1275
+ const I = we.getPositionRange(
1276
+ {
1277
+ startRow: _,
1278
+ endRow: _,
1279
+ startColumn: V,
1280
+ endColumn: V
1281
+ },
1282
+ g
1283
+ ), v = `${i}-${S}`, y = this._sheetDataValidationModel.getRuleById(a, i, S);
1284
+ !this._sheetDataValidationModel.getRuleById(o.unitId, o.subUnitId, v) && y && C.set(v, { ...y, uid: v });
1285
+ const { row: P, col: U } = h(I.startRow, I.startColumn);
1286
+ l.add(v), s.setValue(P, U, v);
1287
+ });
1288
+ });
1289
+ const p = Array.from(l).map((g) => ({ id: g, ranges: Qe(s, (f) => f === g) }));
1290
+ r.addRangeRules(p);
1291
+ const { redoMutations: R, undoMutations: w } = an(
1292
+ o.unitId,
1293
+ o.subUnitId,
1294
+ r.diffWithAddition(this._sheetDataValidationModel.getRules(o.unitId, o.subUnitId), C.values()),
1295
+ this._injector,
1296
+ "patched",
1297
+ !1
1298
+ );
1299
+ return {
1300
+ redos: R,
1301
+ undos: w
1302
+ };
1303
+ } else {
1304
+ const r = this._sheetDataValidationModel.getRuleObjectMatrix(a, i).clone(), s = new Ie(), l = /* @__PURE__ */ new Set(), { ranges: [c, u], mapFunc: h } = sn([o.copyRange, e]);
1305
+ Pn(c, u, !0).forEach(({ startRange: w }) => {
1306
+ var g;
1307
+ (g = this._copyInfo) == null || g.matrix.forValue((f, _, V) => {
1308
+ const S = we.getPositionRange(
1309
+ {
1310
+ startRow: f,
1311
+ endRow: f,
1312
+ startColumn: _,
1313
+ endColumn: _
1314
+ },
1315
+ w
1316
+ ), { row: I, col: v } = h(S.startRow, S.startColumn);
1317
+ s.setValue(I, v, V), l.add(V);
1318
+ });
1319
+ });
1320
+ const C = Array.from(l).map((w) => ({ id: w, ranges: Qe(s, (g) => g === w) }));
1321
+ r.addRangeRules(C);
1322
+ const { redoMutations: p, undoMutations: R } = an(
1323
+ a,
1324
+ i,
1325
+ r.diff(this._sheetDataValidationModel.getRules(a, i)),
1326
+ this._injector,
1327
+ "patched",
1328
+ !1
1329
+ );
1330
+ return {
1331
+ redos: p,
1332
+ undos: R
1333
+ };
1334
+ }
1335
+ }
1336
+ };
1337
+ te = tr([
1338
+ xe(0, ka),
1339
+ xe(1, b(at)),
1340
+ xe(2, b(Wt))
1341
+ ], te);
1342
+ var er = Object.getOwnPropertyDescriptor, nr = (t, e, o, n) => {
1343
+ for (var a = n > 1 ? void 0 : n ? er(e, o) : e, i = t.length - 1, r; i >= 0; i--)
1344
+ (r = t[i]) && (a = r(a) || a);
1345
+ return a;
1346
+ }, je = (t, e) => (o, n) => e(o, n, t);
1347
+ let ee = class extends Vt {
1348
+ constructor(t, e, o) {
1349
+ super(), this._localeService = t, this._commandService = e, this._sheetPermissionCheckController = o, this._commandExecutedListener();
1350
+ }
1351
+ _commandExecutedListener() {
1352
+ this.disposeWithMe(
1353
+ this._commandService.beforeCommandExecuted((t) => {
1354
+ t.id === Sn.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
1355
+ workbookTypes: [Ve],
1356
+ rangeTypes: [De],
1357
+ worksheetTypes: [Re, on]
1358
+ }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))), t.id === ro.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
1359
+ workbookTypes: [Ve],
1360
+ rangeTypes: [De],
1361
+ worksheetTypes: [Re, on]
1362
+ }, t.params.ranges) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")));
1363
+ })
1364
+ );
1365
+ }
1366
+ };
1367
+ ee = nr([
1368
+ je(0, b(Q)),
1369
+ je(1, tt),
1370
+ je(2, b(eo))
1371
+ ], ee);
1372
+ const Lo = "data-validation-single", To = "sheet.menu.data-validation";
1373
+ function or(t) {
1374
+ return {
1375
+ id: To,
1376
+ type: Cn.SUBITEMS,
1377
+ icon: Lo,
1378
+ tooltip: "dataValidation.title",
1379
+ hidden$: Ba(t, X.UNIVER_SHEET),
1380
+ disabled$: Fa(t, { workbookTypes: [Ve], worksheetTypes: [on, Re], rangeTypes: [De] })
1381
+ };
1382
+ }
1383
+ function ar(t) {
1384
+ return {
1385
+ id: Ht.id,
1386
+ title: "dataValidation.panel.title",
1387
+ type: Cn.BUTTON
1388
+ };
1389
+ }
1390
+ function ir(t) {
1391
+ return {
1392
+ id: Ne.id,
1393
+ title: "dataValidation.panel.add",
1394
+ type: Cn.BUTTON
1395
+ };
1396
+ }
1397
+ const rr = {
1398
+ [$a.FORMULAS_INSERT]: {
1399
+ [To]: {
1400
+ order: 9,
1401
+ menuItemFactory: or,
1402
+ [Ht.id]: {
1403
+ order: 0,
1404
+ menuItemFactory: ar
1405
+ },
1406
+ [Ne.id]: {
1407
+ order: 1,
1408
+ menuItemFactory: ir
1409
+ }
1410
+ }
1411
+ }
1412
+ };
1413
+ var sr = Object.getOwnPropertyDescriptor, Po = (t, e, o, n) => {
1414
+ for (var a = n > 1 ? void 0 : n ? sr(e, o) : e, i = t.length - 1, r; i >= 0; i--)
1415
+ (r = t[i]) && (a = r(a) || a);
1416
+ return a;
1417
+ }, Z = (t, e) => (o, n) => e(o, n, t);
1418
+ const Ao = {
1419
+ tr: {
1420
+ size: 6,
1421
+ color: "#fe4b4b"
1422
+ }
1423
+ };
1424
+ let ne = class extends gn {
1425
+ constructor(t, e, o, n, a, i, r, s, l, c, u) {
1426
+ super(), this._commandService = t, this._menuManagerService = e, this._renderManagerService = o, this._univerInstanceService = n, this._autoHeightController = a, this._dropdownManagerService = i, this._sheetDataValidationModel = r, this._dataValidatorRegistryService = s, this._sheetInterceptorService = l, this._dataValidationCacheService = c, this._editorBridgeService = u, this._initMenu(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
1427
+ }
1428
+ _initMenu() {
1429
+ this._menuManagerService.mergeMenu(rr);
1430
+ }
1431
+ _initDropdown() {
1432
+ this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((t) => {
1433
+ var o;
1434
+ if (!t.visible) {
1435
+ ((o = this._dropdownManagerService.activeDropdown) == null ? void 0 : o.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
1436
+ return;
1437
+ }
1438
+ const e = this._editorBridgeService.getEditCellState();
1439
+ if (e) {
1440
+ const { unitId: n, sheetId: a, row: i, column: r } = e, s = this._univerInstanceService.getUniverSheetInstance(n);
1441
+ if (!s)
1442
+ return;
1443
+ const l = this._sheetDataValidationModel.getRuleByLocation(n, a, i, r);
1444
+ if (!l)
1445
+ return;
1446
+ const c = this._dataValidatorRegistryService.getValidatorItem(l.type);
1447
+ if (!(c != null && c.dropdown))
1448
+ return;
1449
+ const u = s.getActiveSheet();
1450
+ if (!u) return;
1451
+ const h = this._dropdownManagerService.activeDropdown, d = h == null ? void 0 : h.location;
1452
+ if (d && d.unitId === n && d.subUnitId === a && d.row === i && d.col === r)
1453
+ return;
1454
+ this._dropdownManagerService.showDropdown(
1455
+ {
1456
+ location: {
1457
+ unitId: n,
1458
+ subUnitId: a,
1459
+ row: i,
1460
+ col: r,
1461
+ workbook: s,
1462
+ worksheet: u
1463
+ },
1464
+ componentKey: c.dropdown,
1465
+ onHide: () => {
1466
+ },
1467
+ trigger: "editor-bridge"
1468
+ },
1469
+ !1
1470
+ );
1471
+ }
1472
+ }));
1473
+ }
1474
+ // eslint-disable-next-line max-lines-per-function
1475
+ _initViewModelIntercept() {
1476
+ this.disposeWithMe(
1477
+ this._sheetInterceptorService.intercept(
1478
+ no.CELL_CONTENT,
1479
+ {
1480
+ effect: Kn.Style,
1481
+ // must be after numfmt
1482
+ priority: oo.DATA_VALIDATION,
1483
+ // eslint-disable-next-line max-lines-per-function, complexity
1484
+ handler: (t, e, o) => {
1485
+ var g, f, _, V, S;
1486
+ const { row: n, col: a, unitId: i, subUnitId: r, workbook: s, worksheet: l } = e, c = this._sheetDataValidationModel.getRuleIdByLocation(i, r, n, a);
1487
+ if (!c)
1488
+ return o(t);
1489
+ const u = this._sheetDataValidationModel.getRuleById(i, r, c);
1490
+ if (!u)
1491
+ return o(t);
1492
+ const h = (g = this._dataValidationCacheService.getValue(i, r, n, a)) != null ? g : Kt.VALID, d = this._dataValidatorRegistryService.getValidatorItem(u.type), C = e.rawData;
1493
+ let p;
1494
+ const R = {
1495
+ get value() {
1496
+ var I;
1497
+ return p !== void 0 || (p = (I = mt(C)) != null ? I : null), p;
1498
+ }
1499
+ }, w = {
1500
+ get value() {
1501
+ var I;
1502
+ return `${(I = R.value) != null ? I : ""}`;
1503
+ }
1504
+ };
1505
+ return o({
1506
+ ...t,
1507
+ markers: {
1508
+ ...t == null ? void 0 : t.markers,
1509
+ ...h === Kt.INVALID ? Ao : null
1510
+ },
1511
+ customRender: [
1512
+ ...(f = t == null ? void 0 : t.customRender) != null ? f : [],
1513
+ ...d != null && d.canvasRender ? [d.canvasRender] : []
1514
+ ],
1515
+ fontRenderExtension: {
1516
+ ...t == null ? void 0 : t.fontRenderExtension,
1517
+ isSkip: ((_ = t == null ? void 0 : t.fontRenderExtension) == null ? void 0 : _.isSkip) || ((V = d == null ? void 0 : d.skipDefaultFontRender) == null ? void 0 : V.call(d, u, R.value, e))
1518
+ },
1519
+ interceptorStyle: {
1520
+ ...t == null ? void 0 : t.interceptorStyle,
1521
+ ...d == null ? void 0 : d.getExtraStyle(u, w.value, {
1522
+ get style() {
1523
+ const I = s.getStyles();
1524
+ return (typeof (t == null ? void 0 : t.s) == "string" ? I.get(t == null ? void 0 : t.s) : t == null ? void 0 : t.s) || {};
1525
+ }
1526
+ }, n, a)
1527
+ },
1528
+ interceptorAutoHeight: () => {
1529
+ var P, U, O, L, A, F;
1530
+ const I = (U = (P = this._renderManagerService.getRenderById(i)) == null ? void 0 : P.with(ye).getSkeletonParam(r)) == null ? void 0 : U.skeleton;
1531
+ if (!I)
1532
+ return;
1533
+ const v = I.worksheet.getMergedCell(n, a), y = {
1534
+ data: t,
1535
+ style: I.getStyles().getStyleByCell(t),
1536
+ primaryWithCoord: I.getCellWithCoordByIndex((O = v == null ? void 0 : v.startRow) != null ? O : n, (L = v == null ? void 0 : v.startColumn) != null ? L : a),
1537
+ unitId: i,
1538
+ subUnitId: r,
1539
+ row: n,
1540
+ col: a,
1541
+ workbook: s,
1542
+ worksheet: l
1543
+ };
1544
+ return (F = (A = d == null ? void 0 : d.canvasRender) == null ? void 0 : A.calcCellAutoHeight) == null ? void 0 : F.call(A, y);
1545
+ },
1546
+ interceptorAutoWidth: () => {
1547
+ var P, U, O, L, A, F;
1548
+ const I = (U = (P = this._renderManagerService.getRenderById(i)) == null ? void 0 : P.with(ye).getSkeletonParam(r)) == null ? void 0 : U.skeleton;
1549
+ if (!I)
1550
+ return;
1551
+ const v = I.worksheet.getMergedCell(n, a), y = {
1552
+ data: t,
1553
+ style: I.getStyles().getStyleByCell(t),
1554
+ primaryWithCoord: I.getCellWithCoordByIndex((O = v == null ? void 0 : v.startRow) != null ? O : n, (L = v == null ? void 0 : v.startColumn) != null ? L : a),
1555
+ unitId: i,
1556
+ subUnitId: r,
1557
+ row: n,
1558
+ col: a,
1559
+ workbook: s,
1560
+ worksheet: l
1561
+ };
1562
+ return (F = (A = d == null ? void 0 : d.canvasRender) == null ? void 0 : A.calcCellAutoWidth) == null ? void 0 : F.call(A, y);
1563
+ },
1564
+ coverable: ((S = t == null ? void 0 : t.coverable) != null ? S : !0) && !(u.type === K.LIST || u.type === K.LIST_MULTIPLE)
1565
+ });
1566
+ }
1567
+ }
1568
+ )
1569
+ );
1570
+ }
1571
+ _initAutoHeight() {
1572
+ this._sheetDataValidationModel.ruleChange$.pipe(
1573
+ // patched data-validation change don't need to re-calc row height
1574
+ // re-calc of row height will be triggered precisely by the origin command
1575
+ In((t) => t.source === "command"),
1576
+ vo(100)
1577
+ ).subscribe((t) => {
1578
+ if (t.length === 0)
1579
+ return;
1580
+ const e = [];
1581
+ if (t.forEach((o) => {
1582
+ var n;
1583
+ (o.rule.type === K.LIST_MULTIPLE || o.rule.type === K.LIST) && (n = o.rule) != null && n.ranges && e.push(...o.rule.ranges);
1584
+ }), e.length) {
1585
+ const o = this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);
1586
+ Gn(o.redos, this._commandService);
1587
+ }
1588
+ });
1589
+ }
1590
+ };
1591
+ ne = Po([
1592
+ Z(0, tt),
1593
+ Z(1, Wa),
1594
+ Z(2, yt),
1595
+ Z(3, rt),
1596
+ Z(4, b(po)),
1597
+ Z(5, b(Dt)),
1598
+ Z(6, b(at)),
1599
+ Z(7, b(bt)),
1600
+ Z(8, b(vn)),
1601
+ Z(9, b(uo)),
1602
+ Z(10, ta(ho))
1603
+ ], ne);
1604
+ let $n = class extends gn {
1605
+ constructor(t, e, o, n, a, i, r) {
1606
+ super(), this._commandService = t, this._renderManagerService = e, this._autoHeightController = o, this._dataValidatorRegistryService = n, this._sheetInterceptorService = a, this._sheetDataValidationModel = i, this._dataValidationCacheService = r, this._initViewModelIntercept(), this._initAutoHeight();
1607
+ }
1608
+ _initViewModelIntercept() {
1609
+ this.disposeWithMe(
1610
+ this._sheetInterceptorService.intercept(
1611
+ no.CELL_CONTENT,
1612
+ {
1613
+ effect: Kn.Style,
1614
+ // must be after numfmt
1615
+ priority: oo.DATA_VALIDATION,
1616
+ // eslint-disable-next-line complexity
1617
+ handler: (t, e, o) => {
1618
+ var w, g, f, _, V;
1619
+ const { row: n, col: a, unitId: i, subUnitId: r, workbook: s, worksheet: l } = e, c = this._sheetDataValidationModel.getRuleIdByLocation(i, r, n, a);
1620
+ if (!c)
1621
+ return o(t);
1622
+ const u = this._sheetDataValidationModel.getRuleById(i, r, c);
1623
+ if (!u)
1624
+ return o(t);
1625
+ const h = (w = this._dataValidationCacheService.getValue(i, r, n, a)) != null ? w : Kt.VALID, d = this._dataValidatorRegistryService.getValidatorItem(u.type), C = l.getCellRaw(n, a), p = mt(C), R = `${p != null ? p : ""}`;
1626
+ return o({
1627
+ ...t,
1628
+ markers: {
1629
+ ...t == null ? void 0 : t.markers,
1630
+ ...h === Kt.INVALID ? Ao : null
1631
+ },
1632
+ customRender: [
1633
+ ...(g = t == null ? void 0 : t.customRender) != null ? g : [],
1634
+ ...d != null && d.canvasRender ? [d.canvasRender] : []
1635
+ ],
1636
+ fontRenderExtension: {
1637
+ ...t == null ? void 0 : t.fontRenderExtension,
1638
+ isSkip: ((f = t == null ? void 0 : t.fontRenderExtension) == null ? void 0 : f.isSkip) || ((_ = d == null ? void 0 : d.skipDefaultFontRender) == null ? void 0 : _.call(d, u, p, e))
1639
+ },
1640
+ interceptorStyle: {
1641
+ ...t == null ? void 0 : t.interceptorStyle,
1642
+ ...d == null ? void 0 : d.getExtraStyle(u, R, {
1643
+ get style() {
1644
+ const S = s.getStyles();
1645
+ return (typeof (t == null ? void 0 : t.s) == "string" ? S.get(t == null ? void 0 : t.s) : t == null ? void 0 : t.s) || {};
1646
+ }
1647
+ }, n, a)
1648
+ },
1649
+ interceptorAutoHeight: () => {
1650
+ var y, P, U, O, L, A;
1651
+ const S = (P = (y = this._renderManagerService.getRenderById(i)) == null ? void 0 : y.with(ye).getSkeletonParam(r)) == null ? void 0 : P.skeleton;
1652
+ if (!S)
1653
+ return;
1654
+ const I = S.worksheet.getMergedCell(n, a), v = {
1655
+ data: t,
1656
+ style: S.getStyles().getStyleByCell(t),
1657
+ primaryWithCoord: S.getCellWithCoordByIndex((U = I == null ? void 0 : I.startRow) != null ? U : n, (O = I == null ? void 0 : I.startColumn) != null ? O : a),
1658
+ unitId: i,
1659
+ subUnitId: r,
1660
+ row: n,
1661
+ col: a,
1662
+ workbook: s,
1663
+ worksheet: l
1664
+ };
1665
+ return (A = (L = d == null ? void 0 : d.canvasRender) == null ? void 0 : L.calcCellAutoHeight) == null ? void 0 : A.call(L, v);
1666
+ },
1667
+ coverable: ((V = t == null ? void 0 : t.coverable) != null ? V : !0) && !(u.type === K.LIST || u.type === K.LIST_MULTIPLE)
1668
+ });
1669
+ }
1670
+ }
1671
+ )
1672
+ );
1673
+ }
1674
+ _initAutoHeight() {
1675
+ this._sheetDataValidationModel.ruleChange$.pipe(
1676
+ In((t) => t.source === "command"),
1677
+ vo(16)
1678
+ ).subscribe((t) => {
1679
+ const e = [];
1680
+ if (t.forEach((o) => {
1681
+ var n;
1682
+ (n = o.rule) != null && n.ranges && e.push(...o.rule.ranges);
1683
+ }), e.length) {
1684
+ const o = this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);
1685
+ Gn(o.redos, this._commandService);
1686
+ }
1687
+ });
1688
+ }
1689
+ };
1690
+ $n = Po([
1691
+ Z(0, tt),
1692
+ Z(1, yt),
1693
+ Z(2, b(po)),
1694
+ Z(3, b(bt)),
1695
+ Z(4, b(vn)),
1696
+ Z(5, b(at)),
1697
+ Z(6, b(uo))
1698
+ ], $n);
1699
+ var lr = Object.getOwnPropertyDescriptor, dr = (t, e, o, n) => {
1700
+ for (var a = n > 1 ? void 0 : n ? lr(e, o) : e, i = t.length - 1, r; i >= 0; i--)
1701
+ (r = t[i]) && (a = r(a) || a);
1702
+ return a;
1703
+ }, Wn = (t, e) => (o, n) => e(o, n, t);
1704
+ let be = class extends Vt {
1705
+ constructor(t, e, o) {
1706
+ super(), this._context = t, this._sheetDataValidationModel = e, this._sheetSkeletonManagerService = o, this._initSkeletonChange();
1707
+ }
1708
+ _initSkeletonChange() {
1709
+ const t = (e) => {
1710
+ var n;
1711
+ if (!e.length)
1712
+ return;
1713
+ const o = /* @__PURE__ */ new Set();
1714
+ e.forEach((a) => {
1715
+ o.add(a.subUnitId);
1716
+ }), o.forEach((a) => {
1717
+ var i;
1718
+ (i = this._sheetSkeletonManagerService.getSkeletonParam(a)) == null || i.skeleton.makeDirty(!0);
1719
+ }), (n = this._context.mainComponent) == null || n.makeForceDirty();
1720
+ };
1721
+ this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(ea(16)).subscribe(t));
1722
+ }
1723
+ };
1724
+ be = dr([
1725
+ Wn(1, b(at)),
1726
+ Wn(2, b(ye))
1727
+ ], be);
1728
+ const cr = "univer-data-validation-formula", ur = "univer-data-validation-formula-and", hr = "univer-data-validation-formula-list-item", pr = "univer-data-validation-formula-list-item-icon", mr = "univer-data-validation-formula-list-item-drag", gr = "univer-data-validation-formula-list-add", fr = "univer-data-validation-formula-color-select", vr = "univer-data-validation-formula-color-select-panel", _r = "univer-data-validation-formula-color-item", ot = {
1729
+ dataValidationFormula: cr,
1730
+ dataValidationFormulaAnd: ur,
1731
+ dataValidationFormulaListItem: hr,
1732
+ dataValidationFormulaListItemIcon: pr,
1733
+ dataValidationFormulaListItemDrag: mr,
1734
+ dataValidationFormulaListAdd: gr,
1735
+ dataValidationFormulaColorSelect: fr,
1736
+ dataValidationFormulaColorSelectPanel: vr,
1737
+ dataValidationFormulaColorItem: _r
1738
+ }, Sr = (t) => {
1739
+ const { isTwoFormula: e = !1, value: o, onChange: n, showError: a, validResult: i } = t, r = T(Q), s = a ? i == null ? void 0 : i.formula1 : "", l = a ? i == null ? void 0 : i.formula2 : "";
1740
+ return e ? /* @__PURE__ */ Y(Rt, { children: [
1741
+ /* @__PURE__ */ m(q, { error: s, children: /* @__PURE__ */ m(
1742
+ Ut,
1743
+ {
1744
+ className: ot.dataValidationFormula,
1745
+ placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
1746
+ value: o == null ? void 0 : o.formula1,
1747
+ onChange: (c) => {
1748
+ n == null || n({
1749
+ ...o,
1750
+ formula1: c
1751
+ });
1752
+ }
1753
+ }
1754
+ ) }),
1755
+ /* @__PURE__ */ m("div", { className: ot.dataValidationFormulaAnd, children: r.t("dataValidation.panel.formulaAnd") }),
1756
+ /* @__PURE__ */ m(q, { error: l, children: /* @__PURE__ */ m(
1757
+ Ut,
1758
+ {
1759
+ className: ot.dataValidationFormula,
1760
+ placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
1761
+ value: o == null ? void 0 : o.formula2,
1762
+ onChange: (c) => {
1763
+ n == null || n({
1764
+ ...o,
1765
+ formula2: c
1766
+ });
1767
+ }
1768
+ }
1769
+ ) })
1770
+ ] }) : /* @__PURE__ */ m(q, { error: s, children: /* @__PURE__ */ m(
1771
+ Ut,
1772
+ {
1773
+ className: ot.dataValidationFormula,
1774
+ placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
1775
+ value: o == null ? void 0 : o.formula1,
1776
+ onChange: (c) => {
1777
+ n == null || n({ formula1: c });
1778
+ }
1779
+ }
1780
+ ) });
1781
+ };
1782
+ function Cr(t) {
1783
+ const { value: e, onChange: o, showError: n, validResult: a } = t, i = T(Q), r = n ? a == null ? void 0 : a.formula1 : "", s = n ? a == null ? void 0 : a.formula2 : "", [l, c] = j(!((e == null ? void 0 : e.formula1) === void 0 && (e == null ? void 0 : e.formula2) === void 0));
1784
+ return /* @__PURE__ */ Y(Rt, { children: [
1785
+ /* @__PURE__ */ m(q, { children: /* @__PURE__ */ m(
1786
+ Pe,
1787
+ {
1788
+ checked: l,
1789
+ onChange: (u) => {
1790
+ u ? c(!0) : (c(!1), o == null || o({
1791
+ ...e,
1792
+ formula1: void 0,
1793
+ formula2: void 0
1794
+ }));
1795
+ },
1796
+ children: i.t("dataValidation.checkbox.tips")
1797
+ }
1798
+ ) }),
1799
+ l ? /* @__PURE__ */ m(q, { label: i.t("dataValidation.checkbox.checked"), error: r, children: /* @__PURE__ */ m(
1800
+ Ut,
1801
+ {
1802
+ className: ot.dataValidationFormula,
1803
+ placeholder: i.t("dataValidation.panel.valuePlaceholder"),
1804
+ value: e == null ? void 0 : e.formula1,
1805
+ onChange: (u) => {
1806
+ o == null || o({
1807
+ ...e,
1808
+ formula1: u || void 0
1809
+ });
1810
+ }
1811
+ }
1812
+ ) }) : null,
1813
+ l ? /* @__PURE__ */ m(q, { label: i.t("dataValidation.checkbox.unchecked"), error: s, children: /* @__PURE__ */ m(
1814
+ Ut,
1815
+ {
1816
+ className: ot.dataValidationFormula,
1817
+ placeholder: i.t("dataValidation.panel.valuePlaceholder"),
1818
+ value: e == null ? void 0 : e.formula2,
1819
+ onChange: (u) => {
1820
+ o == null || o({
1821
+ ...e,
1822
+ formula2: u || void 0
1823
+ });
1824
+ }
1825
+ }
1826
+ ) }) : null
1827
+ ] });
1828
+ }
1829
+ function Ir(t) {
1830
+ var h;
1831
+ const { unitId: e, subUnitId: o, value: n, onChange: a, showError: i, validResult: r } = t, s = i ? r == null ? void 0 : r.formula1 : void 0, l = Jt({}), [c, u] = j(!1);
1832
+ return fo((d) => {
1833
+ var p;
1834
+ const C = (p = l.current) == null ? void 0 : p.handleOutClick;
1835
+ C && C(d, () => u(!1));
1836
+ }), /* @__PURE__ */ m(
1837
+ So,
1838
+ {
1839
+ initValue: (h = n == null ? void 0 : n.formula1) != null ? h : "=",
1840
+ unitId: e,
1841
+ subUnitId: o,
1842
+ isFocus: c,
1843
+ onChange: (d) => {
1844
+ const C = (d != null ? d : "").trim();
1845
+ C !== (n == null ? void 0 : n.formula1) && (a == null || a({
1846
+ ...n,
1847
+ formula1: C
1848
+ }));
1849
+ },
1850
+ errorText: s,
1851
+ onFocus: () => u(!0),
1852
+ actions: l.current,
1853
+ isSupportAcrossSheet: !0
1854
+ }
1855
+ );
1856
+ }
1857
+ const wr = [
1858
+ "#FFFFFF",
1859
+ "#FEE7E7",
1860
+ "#FEF0E6",
1861
+ "#EFFBD0",
1862
+ "#E4F4FE",
1863
+ "#E8ECFD",
1864
+ "#F1EAFA",
1865
+ "#FDE8F3",
1866
+ "#E5E5E5",
1867
+ "#FDCECE",
1868
+ "#FDC49B",
1869
+ "#DEF6A2",
1870
+ "#9FDAFF",
1871
+ "#D0D9FB",
1872
+ "#E3D5F6",
1873
+ "#FBD0E8",
1874
+ "#656565",
1875
+ "#FE4B4B",
1876
+ "#FF8C51",
1877
+ "#8BBB11",
1878
+ "#0B9EFB",
1879
+ "#3A60F7",
1880
+ "#9E6DE3",
1881
+ "#F248A6"
1882
+ ], Rr = (t) => {
1883
+ const { value: e, onChange: o, disabled: n } = t, [a, i] = j(!1);
1884
+ return /* @__PURE__ */ m(
1885
+ en,
1886
+ {
1887
+ disabled: n,
1888
+ open: a,
1889
+ onDropdownVisibleChange: i,
1890
+ dropdownStyle: { width: 112 },
1891
+ style: { width: 96, cursor: "pointer" },
1892
+ className: ot.dataValidationFormulaColorSelect,
1893
+ value: e,
1894
+ onChange: o,
1895
+ labelRender: (r) => /* @__PURE__ */ m(
1896
+ "div",
1897
+ {
1898
+ className: ot.dataValidationFormulaColorItem,
1899
+ style: { background: r.value, marginTop: 5 }
1900
+ }
1901
+ ),
1902
+ dropdownRender: () => /* @__PURE__ */ m("div", { className: ot.dataValidationFormulaColorSelectPanel, children: wr.map(
1903
+ (r) => /* @__PURE__ */ m(
1904
+ "div",
1905
+ {
1906
+ onClick: () => {
1907
+ o(r), i(!1);
1908
+ },
1909
+ className: ot.dataValidationFormulaColorItem,
1910
+ style: { background: r }
1911
+ },
1912
+ r
1913
+ )
1914
+ ) })
1915
+ }
1916
+ );
1917
+ }, Hn = (t) => {
1918
+ const { item: e, commonProps: o, style: n } = t, { onItemChange: a, onItemDelete: i } = o;
1919
+ return /* @__PURE__ */ Y("div", { className: ot.dataValidationFormulaListItem, style: n, children: [
1920
+ e.isRef ? null : /* @__PURE__ */ m("div", { className: sa(ot.dataValidationFormulaListItemDrag, "draggableHandle"), children: /* @__PURE__ */ m(yo, {}) }),
1921
+ /* @__PURE__ */ m(
1922
+ Rr,
1923
+ {
1924
+ value: e.color,
1925
+ onChange: (r) => {
1926
+ a(e.id, e.label, r);
1927
+ }
1928
+ }
1929
+ ),
1930
+ /* @__PURE__ */ m(
1931
+ Ut,
1932
+ {
1933
+ disabled: e.isRef,
1934
+ value: e.label,
1935
+ onChange: (r) => {
1936
+ a(e.id, r, e.color);
1937
+ }
1938
+ }
1939
+ ),
1940
+ e.isRef ? null : /* @__PURE__ */ m("div", { className: ot.dataValidationFormulaListItemIcon, children: /* @__PURE__ */ m(Rn, { onClick: () => i(e.id) }) })
1941
+ ] });
1942
+ };
1943
+ function Dr(t) {
1944
+ const { value: e, onChange: o = () => {
1945
+ }, unitId: n, subUnitId: a, validResult: i, showError: r, ruleId: s } = t, { formula1: l = "", formula2: c = "" } = e || {}, u = Jt(null), [h, d] = j(() => kt(l) ? "1" : "0"), [C, p] = j(h === "1" ? l : "="), [R, w] = j(h === "1" ? l : "="), g = T(Q), f = T(bt), _ = T(ke), V = T(wa), [S, I] = j(() => c.split(",")), v = f.getValidatorItem(K.LIST), [y, P] = j([]), [U, O] = j(""), L = r ? i == null ? void 0 : i.formula1 : "", A = $t(() => _.ruleChange$.pipe(wn(16)), []), F = St(A), N = dn(o);
1946
+ wt(() => {
1947
+ (async () => {
1948
+ await new Promise(($) => {
1949
+ setTimeout(() => $(!0), 100);
1950
+ });
1951
+ const D = _.getRuleById(n, a, s), k = D == null ? void 0 : D.formula1;
1952
+ if (kt(k) && v && D) {
1953
+ const $ = await v.getListAsync(D, n, a);
1954
+ P($);
1955
+ }
1956
+ })();
1957
+ }, [_, F, v, s, a, n]), wt(() => {
1958
+ kt(l) && l !== R && (p(l), w(R));
1959
+ }, [R, l]);
1960
+ const [B, x] = j(() => {
1961
+ const D = h !== "1" ? ao(l) : [], k = c.split(",");
1962
+ return D.map(($, W) => ({
1963
+ label: $,
1964
+ color: k[W] || Ft,
1965
+ isRef: !1,
1966
+ id: tn.generateRandomId(4)
1967
+ }));
1968
+ }), z = (D, k, $) => {
1969
+ const W = B.find((Ct) => Ct.id === D);
1970
+ W && (W.label = k, W.color = $, x([...B]));
1971
+ }, H = (D) => {
1972
+ const k = B.findIndex(($) => $.id === D);
1973
+ k !== -1 && (B.splice(k, 1), x([...B]));
1974
+ }, G = c.split(","), J = $t(() => y.map((D, k) => ({
1975
+ label: D,
1976
+ color: G[k] || Ft,
1977
+ id: `${k}`,
1978
+ isRef: !0
1979
+ })), [G, y]), et = (D, k, $) => {
1980
+ const W = [...S];
1981
+ W[+D] = $, I(W), N({
1982
+ formula1: l,
1983
+ formula2: W.join(",")
1984
+ });
1985
+ }, nt = () => {
1986
+ x([
1987
+ ...B,
1988
+ {
1989
+ label: "",
1990
+ color: Ft,
1991
+ isRef: !1,
1992
+ id: tn.generateRandomId(4)
1993
+ }
1994
+ ]);
1995
+ };
1996
+ wt(() => {
1997
+ if (h === "1")
1998
+ return;
1999
+ const D = /* @__PURE__ */ new Set(), k = [];
2000
+ B.map(($) => ({
2001
+ labelList: $.label.split(","),
2002
+ item: $
2003
+ })).forEach(({ item: $, labelList: W }) => {
2004
+ W.forEach((Ct) => {
2005
+ D.has(Ct) || (D.add(Ct), k.push({
2006
+ label: Ct,
2007
+ color: $.color
2008
+ }));
2009
+ });
2010
+ }), N({
2011
+ formula1: io(k.map(($) => $.label)),
2012
+ formula2: k.map(($) => $.color === Ft ? "" : $.color).join(",")
2013
+ });
2014
+ }, [B, N, h, R, S]);
2015
+ const st = dn(async (D) => {
2016
+ if (!kt(D)) {
2017
+ N == null || N({
2018
+ formula1: "",
2019
+ formula2: c
2020
+ });
2021
+ return;
2022
+ }
2023
+ V.getFormulaRefCheck(D) ? (N == null || N({
2024
+ formula1: kt(D) ? D : "",
2025
+ formula2: c
2026
+ }), O("")) : (N == null || N({
2027
+ formula1: "",
2028
+ formula2: c
2029
+ }), p("="), O(g.t("dataValidation.validFail.formulaError")));
2030
+ }), it = Jt({}), [lt, M] = j(!1);
2031
+ return fo((D) => {
2032
+ var $;
2033
+ const k = ($ = it.current) == null ? void 0 : $.handleOutClick;
2034
+ k && k(D, () => M(!1));
2035
+ }), /* @__PURE__ */ Y(Rt, { children: [
2036
+ /* @__PURE__ */ m(q, { label: g.t("dataValidation.list.options"), children: /* @__PURE__ */ Y(
2037
+ fn,
2038
+ {
2039
+ value: h,
2040
+ onChange: (D) => {
2041
+ d(D), p(R), D === "1" && N({
2042
+ formula1: R === "=" ? "" : R,
2043
+ formula2: S.join(",")
2044
+ });
2045
+ },
2046
+ children: [
2047
+ /* @__PURE__ */ m(Nt, { value: "0", children: g.t("dataValidation.list.customOptions") }),
2048
+ /* @__PURE__ */ m(Nt, { value: "1", children: g.t("dataValidation.list.refOptions") })
2049
+ ]
2050
+ }
2051
+ ) }),
2052
+ h === "1" ? /* @__PURE__ */ Y(Rt, { children: [
2053
+ /* @__PURE__ */ m(
2054
+ So,
2055
+ {
2056
+ initValue: C,
2057
+ unitId: n,
2058
+ subUnitId: a,
2059
+ isFocus: lt,
2060
+ onChange: (D = "") => {
2061
+ const k = (D != null ? D : "").trim();
2062
+ w(k), st(k);
2063
+ },
2064
+ errorText: L || U || void 0,
2065
+ onFocus: () => M(!0),
2066
+ actions: it.current,
2067
+ isSupportAcrossSheet: !0
2068
+ }
2069
+ ),
2070
+ /* @__PURE__ */ m("div", { ref: u, style: { marginTop: "12px" }, children: J.map((D) => /* @__PURE__ */ m(Hn, { item: D, commonProps: { onItemChange: et }, style: { marginBottom: 12 } }, D.id)) })
2071
+ ] }) : /* @__PURE__ */ m(q, { error: L, children: /* @__PURE__ */ Y("div", { ref: u, style: { marginTop: "-12px" }, children: [
2072
+ /* @__PURE__ */ m(
2073
+ ra,
2074
+ {
2075
+ list: B,
2076
+ onListChange: x,
2077
+ rowHeight: 32,
2078
+ margin: [0, 12],
2079
+ draggableHandle: ".draggableHandle",
2080
+ itemRender: (D) => /* @__PURE__ */ m(
2081
+ Hn,
2082
+ {
2083
+ item: D,
2084
+ commonProps: {
2085
+ onItemChange: z,
2086
+ onItemDelete: H
2087
+ }
2088
+ },
2089
+ D.id
2090
+ ),
2091
+ idKey: "id"
2092
+ }
2093
+ ),
2094
+ /* @__PURE__ */ Y("a", { className: ot.dataValidationFormulaListAdd, onClick: nt, children: [
2095
+ /* @__PURE__ */ m(Ro, {}),
2096
+ g.t("dataValidation.list.add")
2097
+ ] })
2098
+ ] }) })
2099
+ ] });
2100
+ }
2101
+ const ko = "data-validation.custom-formula-input", Ue = "data-validation.formula-input", Mn = "data-validation.list-formula-input", Fo = "data-validation.checkbox-formula-input", Vr = [
2102
+ [
2103
+ ko,
2104
+ Ir
2105
+ ],
2106
+ [
2107
+ Ue,
2108
+ Sr
2109
+ ],
2110
+ [
2111
+ Mn,
2112
+ Dr
2113
+ ],
2114
+ [
2115
+ Fo,
2116
+ Cr
2117
+ ]
2118
+ ], yr = "LIST_RENDER_MODE_OPTION_INPUT";
2119
+ function Oe(t) {
2120
+ var a;
2121
+ const { value: e, onChange: o } = t, n = T(Q);
2122
+ return /* @__PURE__ */ m(q, { label: n.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ Y(fn, { value: `${(a = e.renderMode) != null ? a : ct.CUSTOM}`, onChange: (i) => o({ ...e, renderMode: +i }), children: [
2123
+ /* @__PURE__ */ m(Nt, { value: `${ct.CUSTOM}`, children: n.t("dataValidation.renderMode.chip") }),
2124
+ /* @__PURE__ */ m(Nt, { value: `${ct.ARROW}`, children: n.t("dataValidation.renderMode.arrow") }),
2125
+ /* @__PURE__ */ m(Nt, { value: `${ct.TEXT}`, children: n.t("dataValidation.renderMode.text") })
2126
+ ] }) });
2127
+ }
2128
+ Oe.componentKey = yr;
2129
+ const Mr = "DATE_SHOW_TIME_OPTION";
2130
+ function Le(t) {
2131
+ var a;
2132
+ const { value: e, onChange: o } = t, n = T(Q);
2133
+ return /* @__PURE__ */ m(q, { children: /* @__PURE__ */ m(
2134
+ Pe,
2135
+ {
2136
+ checked: (a = e.bizInfo) == null ? void 0 : a.showTime,
2137
+ onChange: (i) => {
2138
+ o({
2139
+ ...e,
2140
+ bizInfo: {
2141
+ ...e.bizInfo,
2142
+ showTime: i
2143
+ }
2144
+ });
2145
+ },
2146
+ children: n.t("dataValidation.showTime.label")
2147
+ }
2148
+ ) });
2149
+ }
2150
+ Le.componentKey = Mr;
2151
+ var Er = Object.getOwnPropertyDescriptor, br = (t, e, o, n) => {
2152
+ for (var a = n > 1 ? void 0 : n ? Er(e, o) : e, i = t.length - 1, r; i >= 0; i--)
2153
+ (r = t[i]) && (a = r(a) || a);
2154
+ return a;
2155
+ }, Xt = (t, e) => (o, n) => e(o, n, t);
2156
+ const ge = 6;
2157
+ let cn = class {
2158
+ constructor(t, e, o, n, a, i) {
2159
+ this._commandService = t, this._univerInstanceService = e, this._formulaService = o, this._themeService = n, this._renderManagerService = a, this._dataValidationModel = i;
2160
+ }
2161
+ _calc(t, e) {
2162
+ var c, u, h;
2163
+ const { vt: o, ht: n } = e || {}, a = t.endX - t.startX - ge * 2, i = t.endY - t.startY, r = ((c = e == null ? void 0 : e.fs) != null ? c : 10) * 1.6;
2164
+ let s = 0, l = 0;
2165
+ switch (o) {
2166
+ case ht.TOP:
2167
+ l = 0;
2168
+ break;
2169
+ case ht.BOTTOM:
2170
+ l = 0 + (i - r);
2171
+ break;
2172
+ default:
2173
+ l = 0 + (i - r) / 2;
2174
+ break;
2175
+ }
2176
+ switch (n) {
2177
+ case Gt.LEFT:
2178
+ s = ge;
2179
+ break;
2180
+ case Gt.RIGHT:
2181
+ s = ge + (a - r);
2182
+ break;
2183
+ default:
2184
+ s = ge + (a - r) / 2;
2185
+ break;
2186
+ }
2187
+ return {
2188
+ left: t.startX + s,
2189
+ top: t.startY + l,
2190
+ width: ((u = e == null ? void 0 : e.fs) != null ? u : 10) * 1.6,
2191
+ height: ((h = e == null ? void 0 : e.fs) != null ? h : 10) * 1.6
2192
+ };
2193
+ }
2194
+ calcCellAutoHeight(t) {
2195
+ var o;
2196
+ const { style: e } = t;
2197
+ return ((o = e == null ? void 0 : e.fs) != null ? o : 10) * 1.6;
2198
+ }
2199
+ calcCellAutoWidth(t) {
2200
+ var o;
2201
+ const { style: e } = t;
2202
+ return ((o = e == null ? void 0 : e.fs) != null ? o : 10) * 1.6;
2203
+ }
2204
+ async _parseFormula(t, e, o) {
2205
+ var c, u, h, d, C, p, R, w, g;
2206
+ const { formula1: n = Va, formula2: a = Da } = t, i = await this._formulaService.getRuleFormulaResult(e, o, t.uid), r = $e((h = (u = (c = i == null ? void 0 : i[0]) == null ? void 0 : c.result) == null ? void 0 : u[0]) == null ? void 0 : h[0]), s = $e((p = (C = (d = i == null ? void 0 : i[1]) == null ? void 0 : d.result) == null ? void 0 : C[0]) == null ? void 0 : p[0]), l = Ln(String(r)) && Ln(String(s));
2207
+ return {
2208
+ formula1: kt(n) ? $e((g = (w = (R = i == null ? void 0 : i[0]) == null ? void 0 : R.result) == null ? void 0 : w[0]) == null ? void 0 : g[0]) : n,
2209
+ formula2: kt(a) ? s : a,
2210
+ isFormulaValid: l
2211
+ };
2212
+ }
2213
+ drawWith(t, e) {
2214
+ var L, A, F, N;
2215
+ const { style: o, primaryWithCoord: n, unitId: a, subUnitId: i, worksheet: r, row: s, col: l } = e, c = n.isMergedMainCell ? n.mergeInfo : n, u = mt(r.getCellRaw(s, l)), h = this._dataValidationModel.getRuleByLocation(a, i, s, l);
2216
+ if (!h)
2217
+ return;
2218
+ const d = this._dataValidationModel.getValidator(h.type);
2219
+ if (!d)
2220
+ return;
2221
+ const C = this._themeService.getCurrentTheme();
2222
+ if (!((L = d.skipDefaultFontRender) != null && L.call(d, h, u, { unitId: a, subUnitId: i, row: s, column: l })))
2223
+ return;
2224
+ const p = d.parseFormulaSync(h, a, i), { formula1: R } = p, w = this._calc(c, o), { a: g, d: f } = t.getTransform(), _ = bn(w.left, g), V = bn(w.top, f), S = la.create().composeMatrix({
2225
+ left: _,
2226
+ top: V,
2227
+ scaleX: 1,
2228
+ scaleY: 1,
2229
+ angle: 0,
2230
+ skewX: 0,
2231
+ skewY: 0,
2232
+ flipX: !1,
2233
+ flipY: !1
2234
+ }), I = c.endX - c.startX, v = c.endY - c.startY;
2235
+ t.save(), t.beginPath(), t.rect(c.startX, c.startY, I, v), t.clip();
2236
+ const y = S.getMatrix();
2237
+ t.transform(y[0], y[1], y[2], y[3], y[4], y[5]);
2238
+ const P = ((A = o == null ? void 0 : o.fs) != null ? A : 10) * 1.6, U = String(u) === String(R), O = C.hyacinth500;
2239
+ da.drawWith(t, {
2240
+ checked: U,
2241
+ width: P,
2242
+ height: P,
2243
+ fill: (N = (F = o == null ? void 0 : o.cl) == null ? void 0 : F.rgb) != null ? N : O
2244
+ }), t.restore();
2245
+ }
2246
+ isHit(t, e) {
2247
+ const o = e.primaryWithCoord.isMergedMainCell ? e.primaryWithCoord.mergeInfo : e.primaryWithCoord, n = this._calc(o, e.style), a = n.top, i = n.top + n.height, r = n.left, s = n.left + n.width, { x: l, y: c } = t;
2248
+ return l <= s && l >= r && c <= i && c >= a;
2249
+ }
2250
+ async onPointerDown(t, e) {
2251
+ var p;
2252
+ if (e.button === 2)
2253
+ return;
2254
+ const { primaryWithCoord: o, unitId: n, subUnitId: a, worksheet: i, row: r, col: s } = t, l = mt(i.getCellRaw(r, s)), c = this._dataValidationModel.getRuleByLocation(n, a, r, s);
2255
+ if (!c)
2256
+ return;
2257
+ const u = this._dataValidationModel.getValidator(c.type);
2258
+ if (!u || !((p = u.skipDefaultFontRender) != null && p.call(u, c, l, { unitId: n, subUnitId: a, row: r, column: s })))
2259
+ return;
2260
+ const { formula1: h, formula2: d } = await this._parseFormula(c, n, a), C = {
2261
+ range: {
2262
+ startColumn: o.actualColumn,
2263
+ endColumn: o.actualColumn,
2264
+ startRow: o.actualRow,
2265
+ endRow: o.actualRow
2266
+ },
2267
+ value: {
2268
+ v: String(l) === ya(String(h)) ? d : h,
2269
+ p: null
2270
+ }
2271
+ };
2272
+ this._commandService.executeCommand(
2273
+ _n.id,
2274
+ C
2275
+ );
2276
+ }
2277
+ onPointerEnter(t, e) {
2278
+ var o, n;
2279
+ (n = (o = Zt(X.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : o.mainComponent) == null || n.setCursor(qt.POINTER);
2280
+ }
2281
+ onPointerLeave(t, e) {
2282
+ var o, n;
2283
+ (n = (o = Zt(X.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : o.mainComponent) == null || n.setCursor(qt.DEFAULT);
2284
+ }
2285
+ };
2286
+ cn = br([
2287
+ Xt(0, tt),
2288
+ Xt(1, rt),
2289
+ Xt(2, b(Ra)),
2290
+ Xt(3, b(zn)),
2291
+ Xt(4, b(yt)),
2292
+ Xt(5, b(at))
2293
+ ], cn);
2294
+ var Or = Object.getOwnPropertyDescriptor, Lr = (t, e, o, n) => {
2295
+ for (var a = n > 1 ? void 0 : n ? Or(e, o) : e, i = t.length - 1, r; i >= 0; i--)
2296
+ (r = t[i]) && (a = r(a) || a);
2297
+ return a;
2298
+ }, Tr = (t, e) => (o, n) => e(o, n, t);
2299
+ let vt = class {
2300
+ constructor(t) {
2301
+ E(this, "canvasRender", null);
2302
+ E(this, "dropdown");
2303
+ E(this, "optionsInput");
2304
+ E(this, "formulaInput", Mn);
2305
+ this.injector = t;
2306
+ }
2307
+ };
2308
+ vt = Lr([
2309
+ Tr(0, b(Wt))
2310
+ ], vt);
2311
+ class Pr extends vt {
2312
+ constructor() {
2313
+ super(...arguments);
2314
+ E(this, "id", K.CHECKBOX);
2315
+ E(this, "canvasRender", this.injector.createInstance(cn));
2316
+ E(this, "formulaInput", Fo);
2317
+ }
2318
+ }
2319
+ class Ar extends vt {
2320
+ constructor() {
2321
+ super(...arguments);
2322
+ E(this, "id", K.CUSTOM);
2323
+ E(this, "formulaInput", ko);
2324
+ }
2325
+ }
2326
+ const kr = "data-validation.formula-input";
2327
+ class Fr extends vt {
2328
+ constructor() {
2329
+ super(...arguments);
2330
+ E(this, "id", K.DATE);
2331
+ E(this, "formulaInput", kr);
2332
+ E(this, "optionsInput", Le.componentKey);
2333
+ E(this, "dropdown", Oo);
2334
+ }
2335
+ }
2336
+ class Nr extends vt {
2337
+ constructor() {
2338
+ super(...arguments);
2339
+ E(this, "id", K.DECIMAL);
2340
+ E(this, "formulaInput", Ue);
2341
+ }
2342
+ }
2343
+ const No = 4, Ur = 0, Ye = 4, Uo = 4, un = 6, Te = 6, At = 14;
2344
+ function Br(t, e) {
2345
+ const o = ca.getTextSize(t, e), n = o.width + No * 2, { ba: a, bd: i } = o, r = a + i;
2346
+ return {
2347
+ width: n,
2348
+ height: r + Ur * 2,
2349
+ ba: a
2350
+ };
2351
+ }
2352
+ function Xe(t, e, o, n) {
2353
+ const a = At + un * 2, i = o - a, r = n - Te * 2, s = t.map((d) => ({
2354
+ layout: Br(d, e),
2355
+ text: d
2356
+ }));
2357
+ let l;
2358
+ const c = [];
2359
+ s.forEach((d) => {
2360
+ const { layout: C } = d, { width: p, height: R } = C;
2361
+ !l || l.width + p + Ye > i ? (l = {
2362
+ width: p,
2363
+ height: R,
2364
+ items: [{
2365
+ ...d,
2366
+ left: 0
2367
+ }]
2368
+ }, c.push(l)) : (l.items.push({
2369
+ ...d,
2370
+ left: l.width + Ye
2371
+ }), l.width = l.width + p + Ye);
2372
+ });
2373
+ let u = 0, h = 0;
2374
+ return c.forEach((d, C) => {
2375
+ h = Math.max(h, d.width), C === c.length - 1 ? u += d.height : u += d.height + Uo;
2376
+ }), {
2377
+ lines: c,
2378
+ totalHeight: u,
2379
+ contentWidth: i,
2380
+ contentHeight: r,
2381
+ cellAutoHeight: u + Te * 2,
2382
+ calcAutoWidth: h + a
2383
+ };
2384
+ }
2385
+ const $r = 8;
2386
+ class Wr extends ua {
2387
+ static drawWith(e, o) {
2388
+ const { fontString: n, info: a, fill: i, color: r } = o, { layout: s, text: l } = a;
2389
+ e.save(), Jn.drawWith(e, {
2390
+ width: s.width,
2391
+ height: s.height,
2392
+ radius: $r,
2393
+ fill: i || Ft
2394
+ }), e.translateWithPrecision(No, s.ba), e.font = n, e.fillStyle = r, e.fillText(l, 0, 0), e.restore();
2395
+ }
2396
+ }
2397
+ var Hr = Object.getOwnPropertyDescriptor, xr = (t, e, o, n) => {
2398
+ for (var a = n > 1 ? void 0 : n ? Hr(e, o) : e, i = t.length - 1, r; i >= 0; i--)
2399
+ (r = t[i]) && (a = r(a) || a);
2400
+ return a;
2401
+ }, fe = (t, e) => (o, n) => e(o, n, t);
2402
+ const jr = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
2403
+ let hn = class {
2404
+ constructor(t, e, o, n) {
2405
+ E(this, "zIndex");
2406
+ E(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
2407
+ this._commandService = t, this._univerInstanceService = e, this._renderManagerService = o, this._dataValidationModel = n;
2408
+ }
2409
+ _ensureMap(t) {
2410
+ let e = this._dropdownInfoMap.get(t);
2411
+ return e || (e = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(t, e)), e;
2412
+ }
2413
+ _generateKey(t, e) {
2414
+ return `${t}.${e}`;
2415
+ }
2416
+ _drawDownIcon(t, e, o, n, a) {
2417
+ const i = o - At + 4;
2418
+ let r = 4;
2419
+ switch (a) {
2420
+ case ht.MIDDLE:
2421
+ r = (n - At) / 2 + 4;
2422
+ break;
2423
+ case ht.BOTTOM:
2424
+ r = n - At + 4;
2425
+ break;
2426
+ }
2427
+ t.save(), t.translateWithPrecision(e.startX + i, e.startY + r), t.fillStyle = "#565656", t.fill(jr), t.restore();
2428
+ }
2429
+ // eslint-disable-next-line max-lines-per-function
2430
+ drawWith(t, e, o, n) {
2431
+ var z, H;
2432
+ const { primaryWithCoord: a, row: i, col: r, style: s, data: l, subUnitId: c } = e, u = a.isMergedMainCell ? a.mergeInfo : a, h = l == null ? void 0 : l.fontRenderExtension, { leftOffset: d = 0, rightOffset: C = 0, topOffset: p = 0, downOffset: R = 0 } = h || {}, w = this._ensureMap(c), g = this._generateKey(i, r), f = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, i, r);
2433
+ if (!f)
2434
+ return;
2435
+ const _ = this._dataValidationModel.getValidator(f.type);
2436
+ if (!_)
2437
+ return;
2438
+ const V = {
2439
+ startX: u.startX + d,
2440
+ endX: u.endX - C,
2441
+ startY: u.startY + p,
2442
+ endY: u.endY - R
2443
+ }, S = V.endX - V.startX, I = V.endY - V.startY, { cl: v } = s || {}, y = (z = typeof v == "object" ? v == null ? void 0 : v.rgb : v) != null ? z : "#000", P = Be(s != null ? s : void 0), { vt: U, ht: O } = s || {}, L = U != null ? U : ht.MIDDLE, A = (H = mt(l)) != null ? H : "", F = _.parseCellValue(A), N = _.getListWithColorMap(f), B = Xe(F, P, S, I);
2444
+ this._drawDownIcon(t, V, S, I, L), t.save(), t.translateWithPrecision(V.startX, V.startY), t.beginPath(), t.rect(0, 0, S - At, I), t.clip(), t.translateWithPrecision(un, Te);
2445
+ let x = 0;
2446
+ switch (L) {
2447
+ case ht.MIDDLE:
2448
+ x = (B.contentHeight - B.totalHeight) / 2;
2449
+ break;
2450
+ case ht.BOTTOM:
2451
+ x = B.contentHeight - B.totalHeight;
2452
+ break;
2453
+ }
2454
+ t.translateWithPrecision(0, x), B.lines.forEach((G, J) => {
2455
+ t.save();
2456
+ const { width: et, height: nt, items: st } = G;
2457
+ let it = 0;
2458
+ switch (O) {
2459
+ case Gt.RIGHT:
2460
+ it = B.contentWidth - et;
2461
+ break;
2462
+ case Gt.CENTER:
2463
+ it = (B.contentWidth - et) / 2;
2464
+ break;
2465
+ }
2466
+ t.translate(it, J * (nt + Uo)), st.forEach((lt) => {
2467
+ t.save(), t.translateWithPrecision(lt.left, 0), Wr.drawWith(t, {
2468
+ ...P,
2469
+ info: lt,
2470
+ color: y,
2471
+ fill: N[lt.text]
2472
+ }), t.restore();
2473
+ }), t.restore();
2474
+ }), t.restore(), w.set(g, {
2475
+ left: V.startX,
2476
+ top: V.startY,
2477
+ width: B.contentWidth + un + At,
2478
+ height: B.contentHeight + Te * 2
2479
+ });
2480
+ }
2481
+ calcCellAutoHeight(t) {
2482
+ var S;
2483
+ const { primaryWithCoord: e, style: o, data: n, row: a, col: i } = t, r = n == null ? void 0 : n.fontRenderExtension, { leftOffset: s = 0, rightOffset: l = 0, topOffset: c = 0, downOffset: u = 0 } = r || {}, h = e.isMergedMainCell ? e.mergeInfo : e, d = {
2484
+ startX: h.startX + s,
2485
+ endX: h.endX - l,
2486
+ startY: h.startY + c,
2487
+ endY: h.endY - u
2488
+ }, C = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, a, i);
2489
+ if (!C)
2490
+ return;
2491
+ const p = this._dataValidationModel.getValidator(C.type);
2492
+ if (!p)
2493
+ return;
2494
+ const R = d.endX - d.startX, w = d.endY - d.startY, g = (S = mt(n)) != null ? S : "", f = p.parseCellValue(g), _ = Be(o != null ? o : void 0);
2495
+ return Xe(f, _, R, w).cellAutoHeight;
2496
+ }
2497
+ calcCellAutoWidth(t) {
2498
+ var S;
2499
+ const { primaryWithCoord: e, style: o, data: n, row: a, col: i } = t, r = n == null ? void 0 : n.fontRenderExtension, { leftOffset: s = 0, rightOffset: l = 0, topOffset: c = 0, downOffset: u = 0 } = r || {}, h = e.isMergedMainCell ? e.mergeInfo : e, d = {
2500
+ startX: h.startX + s,
2501
+ endX: h.endX - l,
2502
+ startY: h.startY + c,
2503
+ endY: h.endY - u
2504
+ }, C = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, a, i);
2505
+ if (!C)
2506
+ return;
2507
+ const p = this._dataValidationModel.getValidator(C.type);
2508
+ if (!p)
2509
+ return;
2510
+ const R = d.endX - d.startX, w = d.endY - d.startY, g = (S = mt(n)) != null ? S : "", f = p.parseCellValue(g), _ = Be(o != null ? o : void 0);
2511
+ return Xe(f, _, R, w).calcAutoWidth;
2512
+ }
2513
+ isHit(t, e) {
2514
+ const { primaryWithCoord: o } = e, n = o.isMergedMainCell ? o.mergeInfo : o, { endX: a } = n, { x: i } = t;
2515
+ return i >= a - At && i <= a;
2516
+ }
2517
+ onPointerDown(t, e) {
2518
+ if (e.button === 2)
2519
+ return;
2520
+ const { unitId: o, subUnitId: n, row: a, col: i } = t, r = {
2521
+ unitId: o,
2522
+ subUnitId: n,
2523
+ row: a,
2524
+ column: i
2525
+ };
2526
+ this._commandService.executeCommand(Fe.id, r);
2527
+ }
2528
+ onPointerEnter(t, e) {
2529
+ var o, n;
2530
+ return (n = (o = Zt(X.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : o.mainComponent) == null ? void 0 : n.setCursor(qt.POINTER);
2531
+ }
2532
+ onPointerLeave(t, e) {
2533
+ var o, n;
2534
+ return (n = (o = Zt(X.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : o.mainComponent) == null ? void 0 : n.setCursor(qt.DEFAULT);
2535
+ }
2536
+ };
2537
+ hn = xr([
2538
+ fe(0, tt),
2539
+ fe(1, rt),
2540
+ fe(2, b(yt)),
2541
+ fe(3, b(at))
2542
+ ], hn);
2543
+ class Yr extends vt {
2544
+ constructor() {
2545
+ super(...arguments);
2546
+ E(this, "id", K.LIST_MULTIPLE);
2547
+ E(this, "canvasRender", this.injector.createInstance(hn));
2548
+ E(this, "dropdown", yn);
2549
+ }
2550
+ }
2551
+ var Xr = Object.getOwnPropertyDescriptor, zr = (t, e, o, n) => {
2552
+ for (var a = n > 1 ? void 0 : n ? Xr(e, o) : e, i = t.length - 1, r; i >= 0; i--)
2553
+ (r = t[i]) && (a = r(a) || a);
2554
+ return a;
2555
+ }, le = (t, e) => (o, n) => e(o, n, t);
2556
+ const Pt = 4, ve = 4, pt = 14, gt = 6, zt = 4, ze = 8, Kr = "#565656", xn = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
2557
+ function Gr(t, e) {
2558
+ const o = t.length;
2559
+ return {
2560
+ id: "d",
2561
+ body: {
2562
+ dataStream: `${t}${oa}`,
2563
+ textRuns: [
2564
+ {
2565
+ ts: {
2566
+ fs: 11,
2567
+ ff: void 0,
2568
+ it: ie.FALSE,
2569
+ bl: ie.FALSE,
2570
+ ul: {
2571
+ s: ie.FALSE
2572
+ },
2573
+ st: {
2574
+ s: ie.FALSE
2575
+ },
2576
+ ol: {
2577
+ s: ie.FALSE
2578
+ },
2579
+ cl: void 0,
2580
+ ...e,
2581
+ bg: void 0,
2582
+ bd: void 0
2583
+ },
2584
+ st: 0,
2585
+ ed: o
2586
+ }
2587
+ ]
2588
+ },
2589
+ documentStyle: {
2590
+ pageSize: {
2591
+ width: Number.POSITIVE_INFINITY,
2592
+ height: Number.POSITIVE_INFINITY
2593
+ }
2594
+ }
2595
+ };
2596
+ }
2597
+ function Bo(t, e, o) {
2598
+ const n = Gr(t, o), a = new na(n), i = new pa(a);
2599
+ return {
2600
+ documentSkeleton: ma.create(i, e),
2601
+ docModel: a,
2602
+ docViewModel: i
2603
+ };
2604
+ }
2605
+ function _e(t, e, o) {
2606
+ const {
2607
+ documentSkeleton: n,
2608
+ docModel: a,
2609
+ docViewModel: i
2610
+ } = Bo(t, e, o);
2611
+ return {
2612
+ documents: new ha(`DOCUMENTS_${tn.generateRandomId()}`, n, {
2613
+ pageMarginLeft: 0,
2614
+ pageMarginTop: 0
2615
+ }),
2616
+ documentSkeleton: n,
2617
+ docModel: a,
2618
+ docViewModel: i
2619
+ };
2620
+ }
2621
+ function jn(t, e, o, n, a, i, r = !0) {
2622
+ let s = 0;
2623
+ const l = r ? zt : 0;
2624
+ switch (a) {
2625
+ case ht.BOTTOM:
2626
+ s = e - n - l;
2627
+ break;
2628
+ case ht.MIDDLE:
2629
+ s = (e - n) / 2;
2630
+ break;
2631
+ default:
2632
+ s = l;
2633
+ break;
2634
+ }
2635
+ s = Math.max(zt, s);
2636
+ let c = 0;
2637
+ switch (i) {
2638
+ case Gt.CENTER:
2639
+ c = (t - o) / 2;
2640
+ break;
2641
+ case Gt.RIGHT:
2642
+ c = t - o;
2643
+ break;
2644
+ }
2645
+ return c = Math.max(gt, c), {
2646
+ paddingLeft: c,
2647
+ paddingTop: s
2648
+ };
2649
+ }
2650
+ let pn = class {
2651
+ constructor(t, e, o, n, a) {
2652
+ E(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
2653
+ E(this, "zIndex");
2654
+ this._univerInstanceService = t, this._localeService = e, this._commandService = o, this._renderManagerService = n, this._dataValidationModel = a;
2655
+ }
2656
+ _ensureMap(t) {
2657
+ let e = this._dropdownInfoMap.get(t);
2658
+ return e || (e = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(t, e)), e;
2659
+ }
2660
+ _generateKey(t, e) {
2661
+ return `${t}.${e}`;
2662
+ }
2663
+ _drawDownIcon(t, e, o, n, a, i, r) {
2664
+ const { t: s = dt.pd.t, b: l = dt.pd.b } = r, c = o - pt;
2665
+ let u;
2666
+ switch (i) {
2667
+ case ht.MIDDLE:
2668
+ u = (n - ve) / 2;
2669
+ break;
2670
+ case ht.BOTTOM:
2671
+ u = n - l - a - zt + (a / 2 - ve / 2);
2672
+ break;
2673
+ default:
2674
+ u = s + zt + (a / 2 - ve / 2);
2675
+ break;
2676
+ }
2677
+ t.save(), t.translateWithPrecision(e.startX + c, e.startY + u), t.fillStyle = "#565656", t.fill(xn), t.restore();
2678
+ }
2679
+ // eslint-disable-next-line max-lines-per-function, complexity
2680
+ drawWith(t, e, o) {
2681
+ const { primaryWithCoord: n, row: a, col: i, style: r, data: s, subUnitId: l } = e, c = n.isMergedMainCell ? n.mergeInfo : n, u = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
2682
+ if (!u)
2683
+ return;
2684
+ const h = this._dataValidationModel.getValidator(u.type);
2685
+ if (!h)
2686
+ return;
2687
+ const d = s == null ? void 0 : s.fontRenderExtension, { leftOffset: C = 0, rightOffset: p = 0, topOffset: R = 0, downOffset: w = 0 } = d || {};
2688
+ if (!u || !h || !h || h.id.indexOf(K.LIST) !== 0 || !h.skipDefaultFontRender(u))
2689
+ return;
2690
+ const g = {
2691
+ startX: c.startX + C,
2692
+ endX: c.endX - p,
2693
+ startY: c.startY + R,
2694
+ endY: c.endY - w
2695
+ }, f = g.endX - g.startX, _ = g.endY - g.startY, V = this._ensureMap(l), S = this._generateKey(a, i), I = h.getListWithColor(u), v = mt(s), y = `${v != null ? v : ""}`, P = I.find((F) => F.label === y);
2696
+ let { tb: U, vt: O, ht: L, pd: A } = r || {};
2697
+ if (U = U != null ? U : It.WRAP, O = O != null ? O : ht.BOTTOM, L = L != null ? L : dt.ht, A = A != null ? A : dt.pd, u.renderMode === ct.ARROW) {
2698
+ const { l: F = dt.pd.l, t: N = dt.pd.t, r: B = dt.pd.r, b: x = dt.pd.b } = A, z = f - F - B - pt - 4, { documentSkeleton: H, documents: G, docModel: J } = _e(y, this._localeService, r);
2699
+ U === It.WRAP && J.updateDocumentDataPageSize(Math.max(z, 1)), H.calculate(), H.getActualSize();
2700
+ const et = re(H), { height: nt, width: st } = et, { paddingTop: it, paddingLeft: lt } = jn(z, _ - N - x, st, nt, O, L, !0);
2701
+ this._drawDownIcon(t, g, f, _, nt, O, A), t.save(), t.translateWithPrecision(g.startX + F, g.startY + N), t.beginPath(), t.rect(0, 0, f - F - B, _ - N - x), t.clip(), t.translateWithPrecision(0, it), t.save(), t.translateWithPrecision(Pt, 0), t.beginPath(), t.rect(0, 0, z, nt), t.clip(), G.render(t), t.translateWithPrecision(lt, 0), t.restore(), t.restore(), V.set(S, {
2702
+ left: g.endX + F + o.rowHeaderWidth - pt,
2703
+ top: g.startY + N + o.columnHeaderHeight,
2704
+ width: pt,
2705
+ height: _ - N - x
2706
+ });
2707
+ } else {
2708
+ t.save(), t.translateWithPrecision(g.startX, g.startY), t.beginPath(), t.rect(0, 0, f, _), t.clip();
2709
+ const F = f - gt * 2 - Pt - pt - 4, { documentSkeleton: N, documents: B, docModel: x } = _e(y, this._localeService, r);
2710
+ U === It.WRAP && x.updateDocumentDataPageSize(Math.max(F, 1)), N.calculate();
2711
+ const z = re(N), { height: H, width: G } = z, { paddingTop: J, paddingLeft: et } = jn(F, _, G, H, O, L);
2712
+ t.translateWithPrecision(gt, J);
2713
+ const nt = Math.max(f - gt * 2, 1), st = H;
2714
+ Jn.drawWith(t, {
2715
+ width: nt,
2716
+ height: st,
2717
+ fill: (P == null ? void 0 : P.color) || Ft,
2718
+ radius: ze
2719
+ }), t.save(), t.translateWithPrecision(Pt, 0), t.beginPath(), t.rect(0, 0, F, H), t.clip(), t.translateWithPrecision(et, 0), B.render(t), t.restore(), t.translateWithPrecision(F + Pt + 4, (H - ve) / 2), t.fillStyle = Kr, t.fill(xn), t.restore(), V.set(S, {
2720
+ left: g.startX + gt + o.rowHeaderWidth,
2721
+ top: g.startY + J + o.columnHeaderHeight,
2722
+ width: nt,
2723
+ height: st
2724
+ });
2725
+ }
2726
+ }
2727
+ calcCellAutoHeight(t) {
2728
+ const { primaryWithCoord: e, style: o, data: n, row: a, col: i } = t, r = e.isMergedMainCell ? e.mergeInfo : e, s = n == null ? void 0 : n.fontRenderExtension, { leftOffset: l = 0, rightOffset: c = 0, topOffset: u = 0, downOffset: h = 0 } = s || {}, d = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, a, i);
2729
+ if (!d || d.renderMode === ct.TEXT)
2730
+ return;
2731
+ const C = {
2732
+ startX: r.startX + l,
2733
+ endX: r.endX - c,
2734
+ startY: r.startY + u,
2735
+ endY: r.endY - h
2736
+ }, p = C.endX - C.startX, R = mt(n), w = `${R != null ? R : ""}`;
2737
+ let { tb: g, pd: f } = o || {};
2738
+ const { t: _ = dt.pd.t, b: V = dt.pd.b } = f != null ? f : {};
2739
+ if (g = g != null ? g : It.WRAP, d.renderMode === ct.ARROW) {
2740
+ const S = p - pt, { documentSkeleton: I, docModel: v } = _e(w, this._localeService, o);
2741
+ g === It.WRAP && v.updateDocumentDataPageSize(Math.max(S, 1)), I.calculate(), I.getActualSize();
2742
+ const y = re(I), { height: P } = y;
2743
+ return P + _ + V + zt * 2;
2744
+ } else {
2745
+ const S = p - gt * 2 - Pt - pt, { documentSkeleton: I, docModel: v } = Bo(w, this._localeService, o);
2746
+ g === It.WRAP && v.updateDocumentDataPageSize(Math.max(S, 1)), I.calculate();
2747
+ const y = re(I), {
2748
+ height: P
2749
+ } = y;
2750
+ return P + zt * 2;
2751
+ }
2752
+ }
2753
+ calcCellAutoWidth(t) {
2754
+ const { primaryWithCoord: e, style: o, data: n, row: a, col: i } = t, r = e.isMergedMainCell ? e.mergeInfo : e, s = n == null ? void 0 : n.fontRenderExtension, { leftOffset: l = 0, rightOffset: c = 0, topOffset: u = 0, downOffset: h = 0 } = s || {}, d = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, a, i);
2755
+ if (!d || d.renderMode === ct.TEXT)
2756
+ return;
2757
+ const C = {
2758
+ startX: r.startX + l,
2759
+ endX: r.endX - c,
2760
+ startY: r.startY + u,
2761
+ endY: r.endY - h
2762
+ }, p = C.endX - C.startX, R = mt(n), w = `${R != null ? R : ""}`;
2763
+ let { tb: g, pd: f } = o || {};
2764
+ const { l: _ = dt.pd.l, r: V = dt.pd.r } = f != null ? f : {};
2765
+ g = g != null ? g : It.WRAP;
2766
+ let S = gt * 2 + pt;
2767
+ switch (d.renderMode) {
2768
+ case ct.ARROW:
2769
+ S = pt + gt * 2 + V + _;
2770
+ break;
2771
+ case ct.CUSTOM:
2772
+ S = pt + gt * 2 + Pt * 2 + V + _ + ze / 2 + 1;
2773
+ break;
2774
+ // default is CUSTOM
2775
+ default:
2776
+ S = pt + gt * 2 + Pt * 2 + V + _ + ze / 2 + 1;
2777
+ }
2778
+ const I = p - S, { documentSkeleton: v, docModel: y } = _e(w, this._localeService, o);
2779
+ return g === It.WRAP && y.updateDocumentDataPageSize(Math.max(I, 1)), v.calculate(), v.getActualSize(), re(v).width + S;
2780
+ }
2781
+ isHit(t, e) {
2782
+ const { subUnitId: o, row: n, col: a } = e, r = this._ensureMap(o).get(this._generateKey(n, a)), s = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, n, a);
2783
+ if (!s || !r || s.renderMode === ct.TEXT)
2784
+ return !1;
2785
+ const { top: l, left: c, width: u, height: h } = r, { x: d, y: C } = t;
2786
+ return d >= c && d <= c + u && C >= l && C <= l + h;
2787
+ }
2788
+ onPointerDown(t, e) {
2789
+ if (e.button === 2)
2790
+ return;
2791
+ const { unitId: o, subUnitId: n, row: a, col: i } = t, r = {
2792
+ unitId: o,
2793
+ subUnitId: n,
2794
+ row: a,
2795
+ column: i
2796
+ };
2797
+ this._commandService.executeCommand(Fe.id, r);
2798
+ }
2799
+ onPointerEnter(t, e) {
2800
+ var o, n;
2801
+ (n = (o = Zt(X.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : o.mainComponent) == null || n.setCursor(qt.POINTER);
2802
+ }
2803
+ onPointerLeave(t, e) {
2804
+ var o, n;
2805
+ (n = (o = Zt(X.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService)) == null ? void 0 : o.mainComponent) == null || n.setCursor(qt.DEFAULT);
2806
+ }
2807
+ };
2808
+ pn = zr([
2809
+ le(0, rt),
2810
+ le(1, b(Q)),
2811
+ le(2, tt),
2812
+ le(3, b(yt)),
2813
+ le(4, b(at))
2814
+ ], pn);
2815
+ class Zr extends vt {
2816
+ constructor() {
2817
+ super(...arguments);
2818
+ E(this, "id", K.LIST);
2819
+ E(this, "canvasRender", this.injector.createInstance(pn));
2820
+ E(this, "dropdown", yn);
2821
+ E(this, "optionsInput", Oe.componentKey);
2822
+ E(this, "formulaInput", Mn);
2823
+ }
2824
+ }
2825
+ class qr extends vt {
2826
+ constructor() {
2827
+ super(...arguments);
2828
+ E(this, "id", K.TEXT_LENGTH);
2829
+ E(this, "formulaInput", Ue);
2830
+ }
2831
+ }
2832
+ class Jr extends vt {
2833
+ constructor() {
2834
+ super(...arguments);
2835
+ E(this, "id", K.WHOLE);
2836
+ E(this, "formulaInput", Ue);
2837
+ }
2838
+ }
2839
+ var Qr = Object.getOwnPropertyDescriptor, ts = (t, e, o, n) => {
2840
+ for (var a = n > 1 ? void 0 : n ? Qr(e, o) : e, i = t.length - 1, r; i >= 0; i--)
2841
+ (r = t[i]) && (a = r(a) || a);
2842
+ return a;
2843
+ }, Ke = (t, e) => (o, n) => e(o, n, t);
2844
+ let oe = class extends gn {
2845
+ constructor(t, e, o) {
2846
+ super(), this._injector = t, this._componentManger = e, this._dataValidatorRegistryService = o, this._initComponents(), this._registerValidatorViews();
2847
+ }
2848
+ _initComponents() {
2849
+ [
2850
+ [Lo, wo],
2851
+ [Me, Ki],
2852
+ [Mo, gi],
2853
+ [yn, Ei],
2854
+ [Oo, ei],
2855
+ [Oe.componentKey, Oe],
2856
+ [Le.componentKey, Le],
2857
+ ...Vr
2858
+ ].forEach(([t, e]) => {
2859
+ this.disposeWithMe(this._componentManger.register(
2860
+ t,
2861
+ e
2862
+ ));
2863
+ });
2864
+ }
2865
+ _registerValidatorViews() {
2866
+ [
2867
+ Nr,
2868
+ Jr,
2869
+ qr,
2870
+ Fr,
2871
+ Pr,
2872
+ Zr,
2873
+ Yr,
2874
+ Ar
2875
+ ].forEach((t) => {
2876
+ const e = this._injector.createInstance(t), o = this._dataValidatorRegistryService.getValidatorItem(e.id);
2877
+ o && (o.formulaInput = e.formulaInput, o.canvasRender = e.canvasRender, o.dropdown = e.dropdown, o.optionsInput = e.optionsInput);
2878
+ });
2879
+ }
2880
+ };
2881
+ oe = ts([
2882
+ Ke(0, b(Wt)),
2883
+ Ke(1, b(Ae)),
2884
+ Ke(2, b(bt))
2885
+ ], oe);
2886
+ var es = Object.getOwnPropertyDescriptor, ns = (t, e, o, n) => {
2887
+ for (var a = n > 1 ? void 0 : n ? es(e, o) : e, i = t.length - 1, r; i >= 0; i--)
2888
+ (r = t[i]) && (a = r(a) || a);
2889
+ return a;
2890
+ }, Ge = (t, e) => (o, n) => e(o, n, t);
2891
+ const os = "SHEET_DATA_VALIDATION_UI_PLUGIN";
2892
+ var Se;
2893
+ let Yn = (Se = class extends Zn {
2894
+ constructor(t = Ee, e, o, n) {
2895
+ super(), this._config = t, this._injector = e, this._commandService = o, this._configService = n;
2896
+ const { menu: a, ...i } = qn(
2897
+ {},
2898
+ Ee,
2899
+ this._config
2900
+ );
2901
+ a && this._configService.setConfig("menu", a, { merge: !0 }), this._configService.setConfig(Vn, i);
2902
+ }
2903
+ onStarting() {
2904
+ [
2905
+ [ft],
2906
+ [Dt],
2907
+ [ue],
2908
+ [Qt],
2909
+ [ne],
2910
+ [ee],
2911
+ [te],
2912
+ [ce],
2913
+ [oe]
2914
+ ].forEach((t) => {
2915
+ this._injector.add(t);
2916
+ }), [
2917
+ Ne,
2918
+ Fe,
2919
+ bo,
2920
+ Dn,
2921
+ Ht,
2922
+ Eo
2923
+ ].forEach((t) => {
2924
+ this._commandService.registerCommand(t);
2925
+ });
2926
+ }
2927
+ onReady() {
2928
+ this._injector.get(te), this._injector.get(ee), this._injector.get(ce), this._injector.get(ue), this._injector.get(yt).registerRenderModule(
2929
+ X.UNIVER_SHEET,
2930
+ [be]
2931
+ );
2932
+ }
2933
+ onRendered() {
2934
+ this._injector.get(oe), this._injector.get(ne);
2935
+ }
2936
+ onSteady() {
2937
+ this._injector.get(Qt);
2938
+ }
2939
+ }, E(Se, "pluginName", os), E(Se, "type", X.UNIVER_SHEET), Se);
2940
+ Yn = ns([
2941
+ Ge(1, b(Wt)),
2942
+ Ge(2, tt),
2943
+ Ge(3, mn)
2944
+ ], Yn);
2945
+ var as = Object.getOwnPropertyDescriptor, is = (t, e, o, n) => {
2946
+ for (var a = n > 1 ? void 0 : n ? as(e, o) : e, i = t.length - 1, r; i >= 0; i--)
2947
+ (r = t[i]) && (a = r(a) || a);
2948
+ return a;
2949
+ }, Ze = (t, e) => (o, n) => e(o, n, t);
2950
+ const rs = "SHEET_DATA_VALIDATION_UI_PLUGIN";
2951
+ var Ce;
2952
+ let Xn = (Ce = class extends Zn {
2953
+ constructor(t = Ee, e, o, n) {
2954
+ super(), this._config = t, this._injector = e, this._commandService = o, this._configService = n;
2955
+ const { menu: a, ...i } = qn(
2956
+ {},
2957
+ Ee,
2958
+ this._config
2959
+ );
2960
+ a && this._configService.setConfig("menu", a, { merge: !0 }), this._configService.setConfig(Vn, i);
2961
+ }
2962
+ onStarting() {
2963
+ [
2964
+ [ft],
2965
+ [Dt],
2966
+ [ue],
2967
+ [Qt],
2968
+ [ne],
2969
+ [ee],
2970
+ [te],
2971
+ [oe]
2972
+ ].forEach((t) => {
2973
+ this._injector.add(t);
2974
+ }), [
2975
+ Ne,
2976
+ Fe,
2977
+ bo,
2978
+ Dn,
2979
+ Ht,
2980
+ Eo
2981
+ ].forEach((t) => {
2982
+ this._commandService.registerCommand(t);
2983
+ });
2984
+ }
2985
+ onReady() {
2986
+ this._injector.get(te), this._injector.get(ee), this._injector.get(yt).registerRenderModule(
2987
+ X.UNIVER_SHEET,
2988
+ [be]
2989
+ );
2990
+ }
2991
+ onRendered() {
2992
+ this._injector.get(oe), this._injector.get(ne);
2993
+ }
2994
+ onSteady() {
2995
+ this._injector.get(Qt);
2996
+ }
2997
+ }, E(Ce, "pluginName", rs), E(Ce, "type", X.UNIVER_SHEET), Ce);
2998
+ Xn = is([
2999
+ Ze(1, b(Wt)),
3000
+ Ze(2, tt),
3001
+ Ze(3, mn)
3002
+ ], Xn);
3003
+ export {
3004
+ Oo as DATE_DROPDOWN_KEY,
3005
+ yn as LIST_DROPDOWN_KEY,
3006
+ Xn as UniverSheetsDataValidationMobileUIPlugin,
3007
+ Yn as UniverSheetsDataValidationUIPlugin
3008
+ };