var ro = Object.defineProperty; var oo = (e, t, n) => t in e ? ro(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var Q = (e, t, n) => oo(e, typeof t != "symbol" ? t + "" : t, n); import { CommandType as $e, ICommandService as ye, createIdentifier as so, IContextService as hn, IUniverInstanceService as pe, Rectangle as io, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as dn, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as tr, DEFAULT_EMPTY_DOCUMENT_VALUE as nr, isRealNum as co, CellValueType as Fn, getCellValueType as ao, toDisposable as rr, DisposableCollection as st, RANGE_TYPE as Te, Inject as ee, Injector as _t, ThemeService as Rt, useDependency as y, Tools as vt, ColorKit as or, getBodySlice as yn, UniverInstanceType as Me, Direction as he, EDITOR_ACTIVATED as Ft, LocaleService as Xe, createInternalEditorID as sr, generateRandomId as ir, useObservable as it, BuildTextUtils as cr, isFormulaString as Ge, isFormulaId as ct, FOCUSING_DOC as lo, FOCUSING_UNIVER_EDITOR as uo, Disposable as It, isICellData as fo, ObjectMatrix as Et, ILogService as ho, RxDisposable as mo, InterceptorEffectEnum as go, useInjector as po, connectInjector as Tn, Plugin as So, merge as vo, touchDependencies as Co, DependentOn as _o, IConfigService as Ro } from "@univerjs/core"; import { SheetPasteCommand as Io, PREDEFINED_HOOK_NAME as rt, IEditorBridgeService as ar, BaseSelectionRenderService as Eo, getCoordByOffset as On, checkInHeaderRanges as Mn, getAllSelection as bo, genNormalSelectionStyle as lr, getSheetObject as xo, attachSelectionWithCoord as on, SelectionControl as ur, SheetSkeletonManagerService as kt, MoveSelectionCommand as Pn, JumpOver as An, ExpandSelectionCommand as Ln, RANGE_SELECTOR_SYMBOLS as No, SetCellEditVisibleOperation as Fo, EMBEDDING_FORMULA_EDITOR as yo, CellAlertType as To, HoverManagerService as Oo, CellAlertManagerService as Mo, DATA_TYPE as wn, APPLY_TYPE as Po, IAutoFillService as Ao, COPY_TYPE as Lo, ISheetClipboardService as wo, SELECTION_SHAPE_DEPTH as $o, useActiveWorkbook as Do, getCurrentRangeDisable$ as fr, PASTE_SPECIAL_MENU_ID as ko, whenFormulaEditorActivated as bt, SheetsUIPart as jo, RANGE_SELECTOR_COMPONENT_KEY as Ho, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY as Wo } from "@univerjs/sheets-ui"; import { sequenceNodeType as G, serializeRange as Ve, matchToken as ge, LexerTreeBuilder as Be, deserializeRangeWithSheet as we, matchRefDrawToken as Uo, isFormulaLexerToken as Vo, serializeRangeWithSheet as Tt, operatorToken as hr, ERROR_TYPE_SET as Bo, ErrorType as Se, FormulaDataModel as jt, SetFormulaCalculationResultMutation as qo, SetArrayFormulaDataMutation as Ko, SetFormulaCalculationStopMutation as Yo, FunctionType as zo, UniverFormulaEnginePlugin as Zo } from "@univerjs/engine-formula"; import { Subject as ft, filter as sn, map as Ht, merge as cn, distinctUntilChanged as dr, throttleTime as mn, noop as $n, BehaviorSubject as Go, debounceTime as gn, combineLatestWith as Xo, switchMap as Jo, of as Dn, Observable as Qo } from "rxjs"; import { IEditorService as qe, ReplaceTextRunsCommand as kn, DocSelectionRenderService as mr, MoveSelectionOperation as es, MoveCursorOperation as ts, useResize as gr, DocBackScrollRenderController as pr, useKeyboardEvent as ns } from "@univerjs/docs-ui"; import { DeviceInputEventType as De, ScrollTimerType as Zt, SHEET_VIEWPORT_KEY as jn, Vector2 as Hn, IRenderManagerService as ve } from "@univerjs/engine-render"; import { SheetsSelectionsService as Sr, getSheetCommandTarget as vr, getCellAtRowCol as rs, SetSelectionsOperation as Cr, SelectionMoveType as Gt, convertSelectionDataToRange as os, IRefSelectionsService as Wt, setEndForRange as ss, REF_SELECTIONS_ENABLED as Wn, SetWorksheetActiveOperation as Un, SetRangeValuesMutation as Vn, SetRangeValuesUndoMutationFactory as is, SheetInterceptorService as _r, BEFORE_CELL_EDIT as cs, SetWorksheetRowAutoHeightMutation as as, INTERCEPTOR_POINT as ls, WorkbookEditablePermission as Rr, WorksheetEditPermission as Ir, WorksheetSetCellValuePermission as Er, RangeProtectionPermissionEditPoint as br } from "@univerjs/sheets"; import { InsertFunctionCommand as us, IDescriptionService as xt, TriggerCalculationController as fs, UniverSheetsFormulaPlugin as hs } from "@univerjs/sheets-formula"; import { ISidebarService as Ut, IShortcutService as Vt, useEvent as Ee, KeyCode as $, MetaKeys as Y, IContextMenuService as ds, RectPopup as xr, useUpdateEffect as ms, IZenZoneService as gs, ProgressBar as ps, ILayoutService as Ss, MenuItemType as pn, getMenuHiddenObservable as vs, IClipboardInterfaceService as Bn, RibbonStartGroup as Cs, BuiltInUIPart as _s, ComponentManager as Nr, IMenuManagerService as Rs, IUIPartsService as Is } from "@univerjs/ui"; import Es, { forwardRef as ke, useRef as q, createElement as Ke, useEffect as D, useCallback as at, useMemo as Z, useState as H, useLayoutEffect as lt } from "react"; import { Tooltip as bs, Dialog as xs, Button as ot, Input as Fr, Popup as yr, Select as Ns } from "@univerjs/design"; import { DocSelectionManagerService as Tr, RichTextEditingMutation as Fs } from "@univerjs/docs"; import { throttleTime as ys, debounceTime as qn, map as Ts, distinctUntilChanged as Os } from "rxjs/operators"; const Sn = { id: "sheet.command.paste-formula", type: $e.COMMAND, handler: async (e) => e.get(ye).executeCommand(Io.id, { value: rt.SPECIAL_PASTE_FORMULA }) }, ut = { id: "formula-ui.operation.select-editor-formula", type: $e.OPERATION, handler: (e, t) => !0 }; var Ms = Object.defineProperty, Ps = Object.getOwnPropertyDescriptor, As = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? Ps(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && Ms(t, n, r), r; }, Ls = (e, t) => (n, o) => t(n, o, e); const ws = "FORMULA_PROMPT_ACTIVATED", Nt = so("formula-ui.prompt-service"); let an = class { constructor(e) { Q(this, "_search$", new ft()); Q(this, "_help$", new ft()); Q(this, "_navigate$", new ft()); Q(this, "_accept$", new ft()); Q(this, "_acceptFormulaName$", new ft()); Q(this, "search$", this._search$.asObservable()); Q(this, "help$", this._help$.asObservable()); Q(this, "navigate$", this._navigate$.asObservable()); Q(this, "accept$", this._accept$.asObservable()); Q(this, "acceptFormulaName$", this._acceptFormulaName$.asObservable()); Q(this, "_searching", !1); Q(this, "_helping", !1); Q(this, "_sequenceNodes", []); Q(this, "_isLockedOnSelectionChangeRefString", !1); Q(this, "_isLockedOnSelectionInsertRefString", !1); this._contextService = e; } dispose() { this._search$.complete(), this._help$.complete(), this._navigate$.complete(), this._accept$.complete(), this._acceptFormulaName$.complete(), this._sequenceNodes = []; } search(e) { this._contextService.setContextValue(ws, e.visible), this._searching = e.visible, this._search$.next(e); } isSearching() { return this._searching; } help(e) { this._helping = e.visible, this._help$.next(e); } isHelping() { return this._helping; } navigate(e) { this._navigate$.next(e); } accept(e) { this._accept$.next(e); } acceptFormulaName(e) { this._acceptFormulaName$.next(e); } getSequenceNodes() { return [...this._sequenceNodes]; } setSequenceNodes(e) { this._sequenceNodes = e; } clearSequenceNodes() { this._sequenceNodes = []; } getCurrentSequenceNode(e) { return this._sequenceNodes[this.getCurrentSequenceNodeIndex(e)]; } getCurrentSequenceNodeByIndex(e) { return this._sequenceNodes[e]; } /** * Query the text coordinates in the sequenceNodes and determine the actual insertion index. * @param strIndex */ getCurrentSequenceNodeIndex(e) { let t = 0; const n = this._sequenceNodes[0]; for (let o = 0, r = this._sequenceNodes.length; o < r; o++) { const i = this._sequenceNodes[o]; if (typeof i == "string") t++; else { const { endIndex: s } = i; t = s; } if (e <= t) return typeof n == "string" && e !== 0 ? o + 1 : o; } return this._sequenceNodes.length; } /** * Synchronize the reference text based on the changes of the selection. * @param nodeIndex * @param refString */ updateSequenceRef(e, t) { const n = this._sequenceNodes[e]; if (typeof n == "string" || n.nodeType !== G.REFERENCE) return; const o = t.length - n.token.length, r = { ...n }; r.token = t, r.endIndex += o, this._sequenceNodes[e] = r; for (let i = e + 1, s = this._sequenceNodes.length; i < s; i++) { const c = this._sequenceNodes[i]; if (typeof c == "string") continue; const a = { ...c }; a.startIndex += o, a.endIndex += o, this._sequenceNodes[i] = a; } } /** * When the cursor is on the right side of a formula token, * you can add reference text to the formula by drawing a selection. * @param index * @param refString */ insertSequenceRef(e, t) { const n = t.length, o = this.getCurrentSequenceNodeIndex(e); this._sequenceNodes.splice(o, 0, { token: t, startIndex: e, endIndex: e + n - 1, nodeType: G.REFERENCE }); for (let r = o + 1, i = this._sequenceNodes.length; r < i; r++) { const s = this._sequenceNodes[r]; if (typeof s == "string") continue; const c = { ...s }; c.startIndex += n, c.endIndex += n, this._sequenceNodes[r] = c; } } /** * Insert a string at the cursor position in the text corresponding to the sequenceNodes. * @param index * @param content */ insertSequenceString(e, t) { const n = this.getCurrentSequenceNodeIndex(e), o = t.split(""); this._sequenceNodes.splice(n, 0, ...o); const r = o.length; for (let i = n + r, s = this._sequenceNodes.length; i < s; i++) { const c = this._sequenceNodes[i]; if (typeof c == "string") continue; const a = { ...c }; a.startIndex += r, a.endIndex += r, this._sequenceNodes[i] = a; } } enableLockedSelectionChange() { this._isLockedOnSelectionChangeRefString = !0; } disableLockedSelectionChange() { this._isLockedOnSelectionChangeRefString = !1; } isLockedSelectionChange() { return this._isLockedOnSelectionChangeRefString; } enableLockedSelectionInsert() { this._isLockedOnSelectionInsertRefString = !0; } disableLockedSelectionInsert() { this._isLockedOnSelectionInsertRefString = !1; } isLockedSelectionInsert() { return this._isLockedOnSelectionInsertRefString; } }; an = As([ Ls(0, hn) ], an); const $s = { id: "formula-ui.operation.help-function", type: $e.OPERATION, handler: async (e, t) => (e.get(Nt).help(t), !0) }, vn = { id: "formula-ui.operation.insert-function", type: $e.OPERATION, // eslint-disable-next-line max-lines-per-function handler: async (e, t) => { var C, _; const n = e.get(Sr), o = e.get(qe), r = n.getCurrentSelections(); if (!r || !r.length) return !1; const i = vr(e.get(pe)); if (!i) return !1; const { worksheet: s, unitId: c, subUnitId: a } = i, d = s.getCellMatrix(), { value: u } = t, h = e.get(ye), f = e.get(ar), g = []; let l = null, m = 0, S = 0, R = ""; if (r.length === 1 && (js(r[0].range) || Hs(r[0].range))) { const { range: E, primary: x } = r[0], M = (C = x == null ? void 0 : x.actualRow) != null ? C : E.startRow, T = (_ = x == null ? void 0 : x.actualColumn) != null ? _ : E.startColumn; l = E, m = M, S = T; const P = Kn(d, M, T); P && (R = Ve(P)); } else r.some((E) => { var w, I; const { range: x, primary: M } = E, T = (w = M == null ? void 0 : M.actualRow) != null ? w : x.startRow, P = (I = M == null ? void 0 : M.actualColumn) != null ? I : x.startColumn, A = Kn(d, T, P); if (!A) return l = x, m = T, S = P, !0; const N = Ve(A), b = `=${u}(${N})`; return g.push({ range: x, primary: { row: T, column: P }, formula: b }), !1; }); if (l) { const E = rs(m, S, s), x = { range: io.clone(l), primary: { startRow: E.startRow, startColumn: E.startColumn, endRow: E.endRow, endColumn: E.endColumn, actualRow: m, actualColumn: S, isMerged: E.isMerged, isMergedMainCell: E.startRow === m && E.startColumn === S } }, M = { unitId: c, subUnitId: a, selections: [x] }; await h.executeCommand(Cr.id, M); const T = o.getEditor(dn), P = o.getEditor(tr); f.changeVisible({ visible: !0, unitId: c, eventType: De.Dblclick }); const A = `=${u}(${R}`; T == null || T.replaceText(A), P == null || P.replaceText(A, !1); } return g.length === 0 ? !1 : h.executeCommand(us.id, { list: g }); } }; function Kn(e, t, n) { const o = Ds(e, t, n); if (o !== t) return { startRow: o, endRow: t - 1, startColumn: n, endColumn: n }; const r = ks(e, t, n); return r !== n ? { startRow: t, endRow: t, startColumn: r, endColumn: n - 1 } : null; } function Ds(e, t, n) { let o = !1; if (t === 0) return t; for (let r = t - 1; r >= 0; r--) { const i = e.getValue(r, n); if (Ot(i) && !o) { if (r === 0) return 0; o = !0; } else { if (o && !Ot(i)) return r + 1; if (o && r === 0) return 0; } } return t; } function ks(e, t, n) { let o = !1; if (n === 0) return n; for (let r = n - 1; r >= 0; r--) { const i = e.getValue(t, r); if (Ot(i) && !o) { if (r === 0) return 0; o = !0; } else { if (o && !Ot(i)) return r + 1; if (o && r === 0) return 0; } } return n; } function Ot(e) { if (e != null && e.p) { const t = e == null ? void 0 : e.p.body; if (t == null) return !1; const n = t.dataStream, r = n.substring(n.length - 2, n.length) === nr ? n.substring(0, n.length - 2) : n; return co(r); } return e && (e.t === Fn.NUMBER || ao(e) === Fn.NUMBER); } function js(e) { return e.startRow === e.endRow && e.startColumn === e.endColumn; } function Hs(e) { return e.startRow !== e.endRow && e.startColumn !== e.endColumn; } const Or = "SHEET_FORMULA_UI_PLUGIN", Mr = `${Or}_MORE_FUNCTIONS_COMPONENT`, Cn = { id: "formula-ui.operation.more-functions", type: $e.OPERATION, handler: async (e) => (e.get(Ut).open({ header: { title: "formula.insert.tooltip" }, children: { label: Mr } }), !0) }, Pr = { id: "formula-ui.operation.change-ref-to-absolute", type: $e.OPERATION, handler: async (e) => !0 }, Ws = { id: "formula-ui.operation.search-function", type: $e.OPERATION, handler: async (e, t) => (e.get(Nt).search(t), !0) }; var Xt = { exports: {} }, ht = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Yn; function Us() { if (Yn) return ht; Yn = 1; var e = Es, t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, r = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 }; function s(c, a, d) { var u, h = {}, f = null, g = null; d !== void 0 && (f = "" + d), a.key !== void 0 && (f = "" + a.key), a.ref !== void 0 && (g = a.ref); for (u in a) o.call(a, u) && !i.hasOwnProperty(u) && (h[u] = a[u]); if (c && c.defaultProps) for (u in a = c.defaultProps, a) h[u] === void 0 && (h[u] = a[u]); return { $$typeof: t, type: c, key: f, ref: g, props: h, _owner: r.current }; } return ht.Fragment = n, ht.jsx = s, ht.jsxs = s, ht; } var zn; function Vs() { return zn || (zn = 1, Xt.exports = Us()), Xt.exports; } var p = Vs(), Ie = function() { return Ie = Object.assign || function(e) { for (var t, n = 1, o = arguments.length; n < o; n++) { t = arguments[n]; for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]); } return e; }, Ie.apply(this, arguments); }, Bs = function(e, t) { var n = {}; for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]); if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var r = 0, o = Object.getOwnPropertySymbols(e); r < o.length; r++) t.indexOf(o[r]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[r]) && (n[o[r]] = e[o[r]]); return n; }, Ye = ke(function(e, t) { var n = e.icon, o = e.id, r = e.className, i = e.extend, s = Bs(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(o, " ").concat(r || "").trim(), a = q("_".concat(Ys())); return Ar(n, "".concat(o), { defIds: n.defIds, idSuffix: a.current }, Ie({ ref: t, className: c }, s), i); }); function Ar(e, t, n, o, r) { return Ke(e.tag, Ie(Ie({ key: t }, qs(e, n, r)), o), (Ks(e, n).children || []).map(function(i, s) { return Ar(i, "".concat(t, "-").concat(e.tag, "-").concat(s), n, void 0, r); })); } function qs(e, t, n) { var o = Ie({}, e.attrs); n != null && n.colorChannel1 && o.fill === "colorChannel1" && (o.fill = n.colorChannel1); var r = t.defIds; return !r || r.length === 0 || (e.tag === "use" && o["xlink:href"] && (o["xlink:href"] = o["xlink:href"] + t.idSuffix), Object.entries(o).forEach(function(i) { var s = i[0], c = i[1]; typeof c == "string" && (o[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")"))); })), o; } function Ks(e, t) { var n, o = t.defIds; return !o || o.length === 0 ? e : e.tag === "defs" && (!((n = e.children) === null || n === void 0) && n.length) ? Ie(Ie({}, e), { children: e.children.map(function(r) { return typeof r.attrs.id == "string" && o && o.indexOf(r.attrs.id) > -1 ? Ie(Ie({}, r), { attrs: Ie(Ie({}, r.attrs), { id: r.attrs.id + t.idSuffix }) }) : r; }) }) : e; } function Ys() { return Math.random().toString(36).substring(2, 8); } Ye.displayName = "UniverIcon"; var zs = { 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" } }] }, Lr = ke(function(e, t) { return Ke(Ye, Object.assign({}, e, { id: "check-mark-single", ref: t, icon: zs })); }); Lr.displayName = "CheckMarkSingle"; var Zs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, Bt = ke(function(e, t) { return Ke(Ye, Object.assign({}, e, { id: "close-single", ref: t, icon: Zs })); }); Bt.displayName = "CloseSingle"; var Gs = { 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" } }] }, wr = ke(function(e, t) { return Ke(Ye, Object.assign({}, e, { id: "delete-single", ref: t, icon: Gs })); }); wr.displayName = "DeleteSingle"; var Xs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.75 5.32495C8.75 5.73916 8.41421 6.07495 8 6.07495 7.58579 6.07495 7.25 5.73916 7.25 5.32495 7.25 4.91074 7.58579 4.57495 8 4.57495 8.41421 4.57495 8.75 4.91074 8.75 5.32495zM8.5999 7.52505C8.5999 7.19368 8.33127 6.92505 7.9999 6.92505 7.66853 6.92505 7.3999 7.19368 7.3999 7.52505V11.425C7.3999 11.7564 7.66853 12.025 7.9999 12.025 8.33127 12.025 8.5999 11.7564 8.5999 11.425V7.52505z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M0.899902 8.00002C0.899902 4.0788 4.07868 0.900024 7.9999 0.900024C11.9211 0.900024 15.0999 4.0788 15.0999 8.00002C15.0999 11.9212 11.9211 15.1 7.9999 15.1C4.07868 15.1 0.899902 11.9212 0.899902 8.00002ZM7.9999 2.10002C4.74142 2.10002 2.0999 4.74154 2.0999 8.00002C2.0999 11.2585 4.74142 13.9 7.9999 13.9C11.2584 13.9 13.8999 11.2585 13.8999 8.00002C13.8999 4.74154 11.2584 2.10002 7.9999 2.10002Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, $r = ke(function(e, t) { return Ke(Ye, Object.assign({}, e, { id: "details-single", ref: t, icon: Xs })); }); $r.displayName = "DetailsSingle"; var Js = { 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" } }] }, Dr = ke(function(e, t) { return Ke(Ye, Object.assign({}, e, { id: "increase-single", ref: t, icon: Js })); }); Dr.displayName = "IncreaseSingle"; var Qs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, _n = ke(function(e, t) { return Ke(Ye, Object.assign({}, e, { id: "more-single", ref: t, icon: Qs })); }); _n.displayName = "MoreSingle"; var ei = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.6185 12.4423C12.5907 12.2749 12.7773 12.15 12.9343 12.2308L15.4242 13.5126C15.6102 13.6084 15.5544 13.8745 15.3439 13.8955L14.2456 14.184L13.4521 15.1286C13.3495 15.2939 13.085 15.2463 13.0534 15.0568L12.6185 12.4423Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1 3.6C1 2.16406 2.16406 1 3.6 1H12.3C13.7359 1 14.9 2.16406 14.9 3.6V5.81156C14.9003 5.81881 14.9004 5.82609 14.9004 5.8334C14.9004 5.84071 14.9003 5.84799 14.9 5.85524V10.045C14.9003 10.0522 14.9004 10.0595 14.9004 10.0668C14.9004 10.3982 14.6318 10.6668 14.3004 10.6668H11.1668C10.8907 10.6668 10.6668 10.8907 10.6668 11.1668V14.3C10.6668 14.6314 10.3982 14.9 10.0668 14.9L10.05 14.8998L3.6 14.9C2.16406 14.9 1 13.7359 1 12.3V3.6ZM13.2 5.2334C13.4761 5.2334 13.7 5.00954 13.7 4.7334V3.6C13.7 2.8268 13.0732 2.2 12.3 2.2H11.1668C10.8907 2.2 10.6668 2.42386 10.6668 2.7V4.7334C10.6668 5.00954 10.8907 5.2334 11.1668 5.2334H13.2ZM10.6668 6.9334C10.6668 6.65726 10.8907 6.4334 11.1668 6.4334H13.2C13.4761 6.4334 13.7 6.65726 13.7 6.9334V8.9668C13.7 9.24294 13.4761 9.4668 13.2 9.4668H11.1668C10.8907 9.4668 10.6668 9.24294 10.6668 8.9668V6.9334ZM8.9668 5.2334C9.24294 5.2334 9.4668 5.00954 9.4668 4.7334V2.7C9.4668 2.42386 9.24294 2.2 8.9668 2.2H6.9334C6.65726 2.2 6.4334 2.42386 6.4334 2.7V4.7334C6.4334 5.00954 6.65726 5.2334 6.9334 5.2334L8.9668 5.2334ZM6.4334 6.9334C6.4334 6.65726 6.65726 6.4334 6.9334 6.4334L8.9668 6.4334C9.24294 6.4334 9.4668 6.65726 9.4668 6.9334V8.9668C9.4668 9.24294 9.24294 9.4668 8.9668 9.4668L6.9334 9.4668C6.65726 9.4668 6.4334 9.24294 6.4334 8.9668V6.9334ZM4.7334 5.2334C5.00954 5.2334 5.2334 5.00954 5.2334 4.7334V2.7C5.2334 2.42386 5.00954 2.2 4.7334 2.2H3.6C2.8268 2.2 2.2 2.8268 2.2 3.6V4.7334C2.2 5.00954 2.42386 5.2334 2.7 5.2334H4.7334ZM2.2 6.9334C2.2 6.65726 2.42386 6.4334 2.7 6.4334H4.7334C5.00954 6.4334 5.2334 6.65725 5.2334 6.9334V8.9668C5.2334 9.24294 5.00954 9.4668 4.7334 9.4668H2.7C2.42386 9.4668 2.2 9.24294 2.2 8.9668V6.9334ZM5.2334 11.1668C5.2334 10.8907 5.00954 10.6668 4.7334 10.6668H2.7C2.42386 10.6668 2.2 10.8907 2.2 11.1668V12.3C2.2 13.0732 2.8268 13.7 3.6 13.7H4.7334C5.00954 13.7 5.2334 13.4761 5.2334 13.2V11.1668ZM9.4668 11.1668C9.4668 10.8907 9.24294 10.6668 8.9668 10.6668H6.9334C6.65726 10.6668 6.4334 10.8907 6.4334 11.1668V13.2C6.4334 13.4761 6.65726 13.7 6.9334 13.7H8.9668C9.24294 13.7 9.4668 13.4761 9.4668 13.2V11.1668Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, kr = ke(function(e, t) { return Ke(Ye, Object.assign({}, e, { id: "select-range-single", ref: t, icon: ei })); }); kr.displayName = "SelectRangeSingle"; function jr(e) { var t, n, o = ""; if (typeof e == "string" || typeof e == "number") o += e; else if (typeof e == "object") if (Array.isArray(e)) { var r = e.length; for (t = 0; t < r; t++) e[t] && (n = jr(e[t])) && (o && (o += " "), o += n); } else for (n in e) e[n] && (o && (o += " "), o += n); return o; } function ln() { for (var e, t, n = 0, o = "", r = arguments.length; n < r; n++) (e = arguments[n]) && (t = jr(e)) && (o && (o += " "), o += t); return o; } var ti = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, ri = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? ni(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && ti(t, n, r), r; }, tt = (e, t) => (n, o) => t(n, o, e); let Fe = class extends Eo { constructor(t, n, o, r, i, s, c) { super( n, o, r, i, s ); Q(this, "_workbookSelections"); Q(this, "_eventDisposables"); this._context = t, this._contextService = s, this._refSelectionsService = c, this._workbookSelections = this._refSelectionsService.getWorkbookSelections(this._context.unitId), this._initSelectionChangeListener(), this._initSkeletonChangeListener(), this._initUserActionSyncListener(), this._setSelectionStyle(oi(this._themeService)), this._remainLastEnabled = !0, this._highlightHeader = !1; } getLocation() { return this._skeleton.getLocation(); } setRemainLastEnabled(t) { this._remainLastEnabled = t; } /** * This is set to true when you need to add a new selection. * @param {boolean} enabled * @memberof RefSelectionsRenderService */ setSkipLastEnabled(t) { this._skipLastEnabled = t; } clearLastSelection() { const t = this._selectionControls[this._selectionControls.length - 1]; t && (t.dispose(), this._selectionControls.pop()); } /** * Call this method and user will be able to select on the canvas to update selections. */ enableSelectionChanging() { return this._disableSelectionChanging(), this._eventDisposables = this._initCanvasEventListeners(), rr(() => this._disableSelectionChanging()); } _disableSelectionChanging() { var t; (t = this._eventDisposables) == null || t.dispose(), this._eventDisposables = null; } disableSelectionChanging() { this._disableSelectionChanging(); } _initCanvasEventListeners() { const t = this._getSheetObject(), { spreadsheetRowHeader: n, spreadsheetColumnHeader: o, spreadsheet: r, spreadsheetLeftTopPlaceholder: i } = t, { scene: s } = this._context, c = new st(); return c.add(r == null ? void 0 : r.onPointerDown$.subscribeEvent((a, d) => { this.inRefSelectionMode() && (this._onPointerDown(a, r.zIndex + 1, Te.NORMAL, this._getActiveViewport(a)), a.button !== 2 && d.stopPropagation()); })), c.add( n == null ? void 0 : n.onPointerDown$.subscribeEvent((a, d) => { if (!this.inRefSelectionMode()) return; const u = this._sheetSkeletonManagerService.getCurrent().skeleton, { row: h } = On(a.offsetX, a.offsetY, s, u); Mn(this._workbookSelections.getCurrentSelections(), h, Te.ROW) || (this._onPointerDown(a, (r.zIndex || 1) + 1, Te.ROW, this._getActiveViewport(a), Zt.Y), a.button !== 2 && d.stopPropagation()); }) ), c.add(o == null ? void 0 : o.onPointerDown$.subscribeEvent((a, d) => { if (!this.inRefSelectionMode()) return; const u = this._sheetSkeletonManagerService.getCurrent().skeleton, { column: h } = On(a.offsetX, a.offsetY, s, u); Mn(this._workbookSelections.getCurrentSelections(), h, Te.COLUMN) || (this._onPointerDown(a, (r.zIndex || 1) + 1, Te.COLUMN, this._getActiveViewport(a), Zt.X), a.button !== 2 && d.stopPropagation()); })), c.add(i == null ? void 0 : i.onPointerDown$.subscribeEvent((a, d) => { if (this._reset(), !this.inRefSelectionMode()) return; const u = this._sheetSkeletonManagerService.getCurrent().skeleton, h = bo(u); this._addSelectionControlByModelData(h), this._selectionMoveStart$.next(this.getSelectionDataWithStyle()); const f = s.onPointerUp$.subscribeEvent(() => { f.unsubscribe(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()); }); a.button !== 2 && d.stopPropagation(); })), c; } /** * Add a selection in spreadsheet, create a new SelectionControl and then update this control by range derives from selection. * For ref selection, create selectionShapeExtension to handle user action. * @param {ISelectionWithCoord} selectionWithStyle */ _addSelectionControlByModelData(t) { var s; const n = this._skeleton, o = (s = t.style) != null ? s : lr(this._themeService), r = this._scene; return t.style = o, this.newSelectionControl(r, n, t); } _initSelectionChangeListener() { this.disposeWithMe(this._refSelectionsService.selectionSet$.subscribe((t) => { this._reset(), this._skeleton && this.resetSelectionsByModelData(t || []); })); } /** * Update selectionModel in this._workbookSelections by user action in spreadsheet area. */ _initUserActionSyncListener() { this.disposeWithMe(this.selectionMoveStart$.subscribe((t) => { this._updateSelections(t, Gt.MOVE_START); })), this.disposeWithMe(this.selectionMoving$.subscribe((t) => { this._updateSelections(t, Gt.MOVING); })), this.disposeWithMe(this.selectionMoveEnd$.subscribe((t) => { this._updateSelections(t, Gt.MOVE_END); })); } _updateSelections(t, n) { const r = this._context.unit.getActiveSheet().getSheetId(); t.length !== 0 && this._workbookSelections.setSelections( r, t.map((i) => os(i)), n ); } _initSkeletonChangeListener() { this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((t) => { if (!t) return; const { skeleton: n } = t, { scene: o } = this._context, r = o.getViewport(jn.VIEW_MAIN); this._skeleton && this._skeleton.worksheet.getSheetId() !== n.worksheet.getSheetId() && this._reset(), this._changeRuntime(n, o, r); const i = this._workbookSelections.getCurrentSelections(); this.resetSelectionsByModelData(i); })); } _getActiveViewport(t) { const n = this._getSheetObject(); return n == null ? void 0 : n.scene.getActiveViewportByCoord(Hn.FromArray([t.offsetX, t.offsetY])); } _getSheetObject() { return xo(this._context.unit, this._context); } /** * Handle pointer down event, bind pointermove & pointerup handler. * then trigger selectionMoveStart$. * * @param evt * @param _zIndex * @param rangeType * @param viewport * @param scrollTimerType */ // eslint-disable-next-line complexity, max-lines-per-function _onPointerDown(t, n = 0, o = Te.NORMAL, r, i = Zt.ALL) { var N; this._rangeType = o; const s = this._skeleton, c = this._scene; if (!c || !s) return; r && (this._activeViewport = r); const { offsetX: a, offsetY: d } = t, u = c.getViewport(jn.VIEW_MAIN); if (!u) return; const h = c.getCoordRelativeToViewport(Hn.FromArray([a, d])), { x: f, y: g } = h; this._startViewportPosX = f, this._startViewportPosY = g; const l = c.getScrollXYInfoByViewport(h), { scaleX: m, scaleY: S } = c.getAncestorScale(), R = this._skeleton.getCellByOffset(f, g, m, S, l); if (!R) return; switch (o) { case Te.NORMAL: break; case Te.ROW: R.startColumn = 0, R.endColumn = this._skeleton.getColumnCount() - 1; break; case Te.COLUMN: R.startRow = 0, R.endRow = this._skeleton.getRowCount() - 1; break; case Te.ALL: R.startRow = 0, R.startColumn = 0, R.endRow = this._skeleton.getRowCount() - 1, R.endColumn = this._skeleton.getColumnCount() - 1; } const C = { range: R, primary: R, style: null }; C.range.rangeType = o; const _ = on(C, this._skeleton); this._startRangeWhenPointerDown = { ..._.rangeWithCoord }; const E = { ..._.rangeWithCoord, rangeType: o }; let x = this.getActiveSelectionControl(); const M = this.getSelectionControls(); for (const b of M) { if (t.button === 2 && b.model.isInclude(E)) { x = b; return; } if (b.model.isEqual(E)) { x = b; break; } } this._checkClearPreviousControls(t); const T = x == null ? void 0 : x.model.currentCell, P = t.shiftKey && T, A = this._remainLastEnabled && !t.ctrlKey && !t.shiftKey && !this._skipLastEnabled && !this._singleSelectionEnabled; P && T ? this._makeSelectionByTwoCells( T, E, s, o, x // Get updated in this method ) : A && x ? x.updateRangeBySelectionWithCoord(_) : x = this.newSelectionControl(c, s, C); for (let b = 0; b < this.getSelectionControls().length - 1; b++) this.getSelectionControls()[b].clearHighlight(); this._selectionMoveStart$.next(this.getSelectionDataWithStyle()), c.disableObjectsEvent(), this._clearUpdatingListeners(), this._addEndingListeners(), (N = c.getTransformer()) == null || N.clearSelectedObjects(), this._setupPointerMoveListener(u, x, o, i, f, g), this._escapeShortcutDisposable = this._shortcutService.forceEscape(), this._scenePointerUpSub = c.onPointerUp$.subscribeEvent(() => { var b; this._clearUpdatingListeners(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()), (b = this._escapeShortcutDisposable) == null || b.dispose(), this._escapeShortcutDisposable = null; }); } /** * Diff between normal selection, no highlightHeader for ref selections. * @param scene * @param skeleton * @param selectionWithCoord * @returns {SelectionControl} selectionControl just created */ newSelectionControl(t, n, o) { const r = this.getSelectionControls().length, { rowHeaderWidth: i, columnHeaderHeight: s } = n, c = new ur(t, r, this._themeService, { highlightHeader: this._highlightHeader, enableAutoFill: !1, rowHeaderWidth: i, columnHeaderHeight: s }), a = on(o, n); return c.updateRangeBySelectionWithCoord(a), this._selectionControls.push(c), c.setControlExtension({ skeleton: n, scene: t, themeService: this._themeService, injector: this._injector, selectionHooks: { selectionMoveEnd: () => { this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()); } } }), c; } }; Fe = ri([ tt(1, ee(_t)), tt(2, ee(Rt)), tt(3, Vt), tt(4, ee(kt)), tt(5, hn), tt(6, Wt) ], Fe); function oi(e) { const t = lr(e); return t.widgets = { tl: !0, tc: !0, tr: !0, ml: !0, mr: !0, bl: !0, bc: !0, br: !0 }, t; } const si = (e, t, n) => { const r = y(ve).getRenderById(e), i = r == null ? void 0 : r.with(Fe); D(() => { if (n && i) { const s = n.input$.subscribe((c) => { c.content === ge.COMMA ? i.setSkipLastEnabled(!0) : i.setSkipLastEnabled(!1); }); return () => { s.unsubscribe(); }; } }, [n, i]), D(() => { i && (t.endsWith(ge.COMMA) || i.setSkipLastEnabled(!1)); }, [t, i]); }, qt = () => { const e = y(Be); return at((n) => e.sequenceNodesBuilder(n) || [], [e]); }, ii = (e, t, n, o, r, i) => { const s = qt(), c = q(!0); D(() => { var a, d; if (i) { if (c.current) { const u = s(e); if (u.length) { const h = o(i, u); n && r(h); } else { const h = i.getDocumentData(), g = { dataStream: (d = (a = h.body) == null ? void 0 : a.dataStream) != null ? d : `${t}\r `, ...h.body }; i.setDocumentData({ ...h, body: g }); } c.current = !1; } else if (n) { const u = s(e), h = o(i, u); r(h); } } }, [i, n]); }, Hr = (e) => Ee((n) => { var o, r; if (e) { e.focus(); const i = [...e.getSelectionRanges()]; if (vt.isDefine(n)) e.setSelectionRanges([{ startOffset: n, endOffset: n }]); else if (!i.length && !e.docSelectionRenderService.isOnPointerEvent) { const s = (r = (o = e.getDocumentData().body) == null ? void 0 : o.dataStream) != null ? r : `\r `, c = Math.max(s.length - 2, 0); e.setSelectionRanges([{ startOffset: c, endOffset: c }]); } } }); function ci(e, t, n) { const o = e.getCurrentTheme(), r = new or(t).setAlpha(0.05).toRgbString(); return { id: n, strokeWidth: 1, stroke: t, fill: r, widgets: { tl: !0, tc: !0, tr: !0, ml: !0, mr: !0, bl: !0, bc: !0, br: !0 }, widgetSize: 6, widgetStrokeWidth: 1, widgetStroke: o.colorWhite }; } function Wr(e) { var R, C, _; const { unitId: t, subUnitId: n, refSelections: o, editor: r, refSelectionsService: i, refSelectionsRenderService: s, sheetSkeletonManagerService: c, themeService: a, univerInstanceService: d } = e, u = d.getUnit(t, Me.UNIVER_SHEET), h = u == null ? void 0 : u.getActiveSheet(), f = []; if (!u || !h) { i.setSelections(f); return; } const g = h.getSheetId(), l = (E) => { var x; return (x = u == null ? void 0 : u.getSheetBySheetName(E)) == null ? void 0 : x.getSheetId(); }; if (!((R = c == null ? void 0 : c.getWorksheetSkeleton(g)) == null ? void 0 : R.skeleton)) return; const S = []; for (let E = 0, x = o.length; E < x; E++) { const M = o[E], { themeColor: T, token: P, refIndex: A, endIndex: N } = M, b = we(P), { unitId: w, sheetName: I, range: v } = b; if (w && t !== w) continue; const F = l(I); if (F && F !== g || !F && g !== n) continue; const O = ss(v, h.getRowCount(), h.getColumnCount()); f.push({ range: O, primary: null, style: ci(a, T, A.toString()) }), S.push(N); } if (r) { const E = (_ = (C = r.getSelectionRanges()) == null ? void 0 : C[0]) == null ? void 0 : _.startOffset, x = S.findIndex((M) => M + 2 === E); x !== -1 ? s == null || s.setActiveSelectionIndex(x) : s == null || s.resetActiveSelectionIndex(); } return f; } function Rn(e, t) { const n = y(pe), o = y(Rt), r = y(Wt), s = y(ve).getRenderById(e), c = s == null ? void 0 : s.with(Fe), a = s == null ? void 0 : s.with(kt), d = at((u, h) => { const f = Wr({ unitId: e, subUnitId: t, refSelections: u, editor: h, refSelectionsService: r, refSelectionsRenderService: c, sheetSkeletonManagerService: a, themeService: o, univerInstanceService: n }); if (!f) return; ((c == null ? void 0 : c.getSelectionControls()) || []).length === f.length ? c == null || c.resetSelectionsByModelData(f) : r.setSelections(f); }, [c, r, a, o, e, t, n]); return D(() => () => { c == null || c.resetActiveSelectionIndex(); }, [c]), d; } function Ur(e = "") { const t = y(xt), n = Vr(), o = y(ye), r = Z(() => e.length, [e]); return at((s, c, a = !0, d) => { const u = s.getDocumentData(), h = s.getEditorId(); if (!u) return []; const f = u.body; if (!f) return []; const g = f.dataStream.slice(0, f.dataStream.length - 2), l = { dataStream: "", ...u.body }; if (!g.startsWith(e)) return []; if (c == null || c.length === 0) return l.textRuns = [], o.syncExecuteCommand(kn.id, { unitId: h, body: yn(l, 0, l.dataStream.length - 2) }), []; { const { textRuns: m, refSelections: S } = Br(t, n, c); r && m.forEach((_) => { _.ed = _.ed + r, _.st = _.st + r; }), l.textRuns = [{ st: 0, ed: 1, ts: { fs: 11 } }, ...m]; const R = c.reduce((_, E) => typeof E == "string" ? `${_}${E}` : `${_}${E.token}`, ""); l.dataStream = `${e}${R}\r `; let C; if (a) { C = s.getSelectionRanges(); const _ = l.dataStream.length - 2 + r; C.forEach((E) => { E.startOffset = Math.max(0, Math.min(E.startOffset, _)), E.endOffset = Math.max(0, Math.min(E.endOffset, _)); }); } return o.syncExecuteCommand(kn.id, { unitId: h, body: yn(l, 0, l.dataStream.length - 2), textRanges: d != null ? d : C }), S; } }, [o, t, n, r, e]); } function Vr() { const t = y(Rt).getCurrentTheme(); return Z(() => { const o = [ t.loopColor1, t.loopColor2, t.loopColor3, t.loopColor4, t.loopColor5, t.loopColor6, t.loopColor7, t.loopColor8, t.loopColor9, t.loopColor10, t.loopColor11, t.loopColor12 ], r = t.hyacinth700, i = t.verdancy800, s = t.colorBlack; return { formulaRefColors: o, numberColor: r, stringColor: i, plainTextColor: s }; }, [t]); } function Br(e, t, n) { const { formulaRefColors: o, numberColor: r, stringColor: i, plainTextColor: s } = t, c = [], a = [], d = /* @__PURE__ */ new Map(); let u = 0; for (let h = 0, f = n.length; h < f; h++) { const g = n[h]; if (typeof g == "string") { const _ = c[c.length - 1], E = _ ? _.ed : 0, x = E + g.length; c.push({ st: E, ed: x, ts: { cl: { rgb: s }, fs: 11 } }); continue; } if (e.hasDefinedNameDescription(g.token.trim())) { c.push({ st: g.startIndex, ed: g.endIndex + 1, ts: { cl: { rgb: s }, fs: 11 } }); continue; } const { startIndex: l, endIndex: m, nodeType: S, token: R } = g; let C = ""; if (S === G.REFERENCE) { if (d.has(R)) C = d.get(R); else { const _ = u % o.length; C = o[_], d.set(R, C), u++; } a.push({ refIndex: h, themeColor: C, token: R, startIndex: g.startIndex, endIndex: g.endIndex, index: a.length }); } else S === G.NUMBER ? C = r : (S === G.STRING || S === G.ARRAY) && (C = i); C && C.length > 0 ? c.push({ st: l, ed: m + 1, ts: { cl: { rgb: C }, fs: 11 } }) : c.push({ st: l, ed: m + 1, ts: { cl: { rgb: s }, fs: 11 } }); } return { textRuns: c, refSelections: a }; } function ai(e) { var r, i; const n = e.get(pe).getCurrentUniverDocInstance(); return n != null && n.getBody() ? { dataStream: (i = (r = n.getBody()) == null ? void 0 : r.dataStream) != null ? i : "", offset: 0 } : void 0; } var Mt = /* @__PURE__ */ ((e) => (e[e.NOT_SELECT = 0] = "NOT_SELECT", e[e.NEED_ADD = 1] = "NEED_ADD", e[e.CAN_EDIT = 2] = "CAN_EDIT", e))(Mt || {}); function li(e, t, n) { var g; const r = y(ve).getRenderById(e), i = r == null ? void 0 : r.with(mr), s = y(Tr), c = y(_t), [a, d] = H( 0 /* NOT_SELECT */ ), u = y(Be), h = q(!0), f = q(a); return f.current = a, D(() => { const l = s.textSelection$.pipe( sn((m) => m.unitId === e), Ht(() => { const m = i == null ? void 0 : i.getActiveTextRange(); return m != null && m.collapsed ? m.startOffset : -1; }) ).subscribe((m) => { var P, A; const S = ai(c); if (!S) return; const R = (P = S == null ? void 0 : S.dataStream) == null ? void 0 : P.slice(0, -2), C = (A = u.sequenceNodesBuilder(R)) != null ? A : [], _ = R[m - 1], E = R[m], x = C.findIndex((N) => typeof N == "object" && N.nodeType === G.REFERENCE && m === N.endIndex + 2), M = _ && Uo(_) && (!E || Vo(E) && E !== ge.OPEN_BRACKET), T = x > -1; if ((R == null ? void 0 : R.substring(0, 1)) === "=" && (M || T)) if (T) { if (h.current) return; d( 2 /* CAN_EDIT */ ); } else h.current = !1, d( 1 /* NEED_ADD */ ); else d( 0 /* NOT_SELECT */ ); }); return () => l.unsubscribe(); }, [s.textSelection$, i, e, c, u]), D(() => { t || (d( 0 /* NOT_SELECT */ ), h.current = !0); }, [t]), D(() => { var m; if (!n) return; const l = (m = r == null ? void 0 : r.mainComponent) == null ? void 0 : m.onPointerDown$.subscribeEvent(() => { d( 0 /* NOT_SELECT */ ), h.current = !0; }); return () => l == null ? void 0 : l.unsubscribe(); }, [n, (g = r == null ? void 0 : r.mainComponent) == null ? void 0 : g.onPointerDown$]), { isSelecting: a }; } const qr = (e, t, n, o) => { const r = y(ye), i = y(Vt), s = q(t); s.current = t; const c = q(o); c.current = o, D(() => { if (!n || !e) return; const d = `sheet.formula-embedding-editor.${n.getEditorId()}`, u = new st(), h = (l, m) => { if (c.current) { c.current(l, m); return; } let S = he.LEFT; l === $.ARROW_DOWN ? S = he.DOWN : l === $.ARROW_UP ? S = he.UP : l === $.ARROW_RIGHT && (S = he.RIGHT), m === Y.SHIFT ? r.executeCommand(es.id, { direction: S }) : r.executeCommand(ts.id, { direction: S }); }, f = (l, m) => { let S = he.DOWN; l === $.ARROW_DOWN ? S = he.DOWN : l === $.ARROW_UP ? S = he.UP : l === $.ARROW_LEFT ? S = he.LEFT : l === $.ARROW_RIGHT && (S = he.RIGHT), s.current ? m === Y.CTRL_COMMAND ? r.executeCommand(Pn.id, { direction: S, jumpOver: An.moveGap, extra: "formula-editor", fromCurrentSelection: s.current === Mt.NEED_ADD }) : m === Y.SHIFT ? r.executeCommand(Ln.id, { direction: S, extra: "formula-editor" }) : m === (Y.CTRL_COMMAND | Y.SHIFT) ? r.executeCommand(Ln.id, { direction: S, jumpOver: An.moveGap, extra: "formula-editor" }) : r.executeCommand(Pn.id, { direction: S, extra: "formula-editor", fromCurrentSelection: s.current === Mt.NEED_ADD }) : h(l, m); }; return u.add(r.registerCommand({ id: d, type: $e.OPERATION, handler(l, m) { const { keyCode: S, metaKey: R } = m; f(S, R); } })), [ { keyCode: $.ARROW_DOWN }, { keyCode: $.ARROW_LEFT }, { keyCode: $.ARROW_RIGHT }, { keyCode: $.ARROW_UP }, { keyCode: $.ARROW_DOWN, metaKey: Y.SHIFT }, { keyCode: $.ARROW_LEFT, metaKey: Y.SHIFT }, { keyCode: $.ARROW_RIGHT, metaKey: Y.SHIFT }, { keyCode: $.ARROW_UP, metaKey: Y.SHIFT }, { keyCode: $.ARROW_DOWN, metaKey: Y.CTRL_COMMAND }, { keyCode: $.ARROW_LEFT, metaKey: Y.CTRL_COMMAND }, { keyCode: $.ARROW_RIGHT, metaKey: Y.CTRL_COMMAND }, { keyCode: $.ARROW_UP, metaKey: Y.CTRL_COMMAND }, { keyCode: $.ARROW_DOWN, metaKey: Y.CTRL_COMMAND | Y.SHIFT }, { keyCode: $.ARROW_LEFT, metaKey: Y.CTRL_COMMAND | Y.SHIFT }, { keyCode: $.ARROW_RIGHT, metaKey: Y.CTRL_COMMAND | Y.SHIFT }, { keyCode: $.ARROW_UP, metaKey: Y.CTRL_COMMAND | Y.SHIFT } ].map(({ keyCode: l, metaKey: m }) => ({ id: d, binding: m ? l | m : l, preconditions: () => !0, priority: 900, staticParameters: { eventType: De.Keyboard, keyCode: l, metaKey: m } })).forEach((l) => { u.add(i.registerShortcut(l)); }), () => { u.dispose(); }; }, [r, n, e, i]); }, Kr = (e, t) => { const o = y(ve).getRenderById(e), r = o == null ? void 0 : o.with(Fe); D(() => { r && (t ? r == null || r.setRemainLastEnabled(!1) : r == null || r.setRemainLastEnabled(!0)); }, [t, r]); }, In = (e, t, n, o = !0) => { const r = y(ve), i = y(hn), s = y(ds), c = y(Wt), a = r.getRenderById(n), d = a == null ? void 0 : a.with(Fe); lt(() => { if (e) return i.setContextValue(Ft, !0), () => { i.setContextValue(Ft, !1), c.clear(); }; }, [i, e, c]), lt(() => { if (e && t) { const u = d == null ? void 0 : d.enableSelectionChanging(); return i.setContextValue(Wn, !0), () => { i.setContextValue(Wn, !1), u == null || u.dispose(); }; } }, [i, e, d, t]), D(() => { if (e) return i.setContextValue(Ft, !0), o && s.disable(), () => { i.setContextValue(Ft, !1), o && s.enable(); }; }, [s, i, e, o]), D(() => { e && (d == null || d.setSkipLastEnabled(!1)); }, [e, d]); }, ui = () => { D(() => () => { }, []); }, Yr = (e, t, n) => { const o = y(pe), r = y(Sr); return at(() => { if (e) { const s = [...r.getWorkbookSelections(t).getSelectionsOfWorksheet(n)], c = o.getCurrentUnitForType(Me.UNIVER_SHEET), a = c == null ? void 0 : c.getActiveSheet(); a && a.getSheetId() === n && r.setSelections(s); } }, [e, r, n, t, o]); }, un = (e) => typeof e == "string" ? e === ge.COMMA : !1, fi = (e) => { if (typeof e == "object") return e.nodeType === G.REFERENCE; }, hi = (e) => e.filter((t) => un(t) || fi(t)), En = (e) => { if (e.endColumn < e.startColumn) { const t = e.endColumn; e.endColumn = e.startColumn, e.startColumn = t; } if (e.endRow < e.startRow) { const t = e.endRow; e.endRow = e.startRow, e.startRow = t; } return e; }, Oe = (e) => e.map((t) => typeof t == "string" ? t : t.token).join(""); function Zn(e, t, n) { var o, r; return ((r = (o = e.getUnit(t)) == null ? void 0 : o.getSheetBySheetId(n)) == null ? void 0 : r.getName()) || ""; } const Ne = (e, t = !1, n = "") => t ? e.map((o) => o.sheetName !== "" && o.sheetName !== n ? Tt(o.sheetName, o.range) : Ve(o.range)) : e.map((o) => Ve(o.range)), zr = (e, t, n, o, r, i, s) => { const c = y(ve), a = y(pe), d = q(!1), u = c.getRenderById(t), h = u == null ? void 0 : u.with(Fe), f = q([]), g = Z(() => { const m = hi(o), S = f.current; return m.length === S.length ? (S.splice(0), S.push(...m), S) : m; }, [o]); f.current = g; const l = q(); D(() => { if (e && h) { let m = !0; const S = (_, E) => { var I; if (m || d.current) { m = !1; return; } const x = [..._], M = a.getUnit(t), T = ((I = M == null ? void 0 : M.getActiveSheet()) == null ? void 0 : I.getName()) || "", P = g.map((v, F) => { if (typeof v == "string") { if (!g[F - 1]) return null; const L = g[F + 1]; return un(v) && (un(L) || F === g.length - 1) ? null : v; } else if (v.nodeType === G.REFERENCE) { const O = we(v.token); O.unitId = O.unitId === "" ? t : O.unitId, O.sheetName = O.sheetName === "" ? T : O.sheetName; const { unitId: L, sheetName: B } = O; if (i && (L !== t || T !== B)) return null; if (L === t && T === B) { const K = x.shift(); if (K && Zn(a, t, K.rangeWithCoord.sheetId || "") === B) { const V = { ...v }; return En(K.rangeWithCoord), r ? V.token = Tt(T, K.rangeWithCoord) : V.token = Ve(K.rangeWithCoord), V; } } return v; } return null; }).filter((v) => !!v), A = Ne( x.map((v) => { var F, O, L; return { range: v.rangeWithCoord, unitId: (F = v.rangeWithCoord.unitId) != null ? F : "", sheetName: Zn(a, (O = v.rangeWithCoord.unitId) != null ? O : "", (L = v.rangeWithCoord.sheetId) != null ? L : "") }; }), r ).join(ge.COMMA), N = Oe(P), b = `${N}${N && A ? ge.COMMA : ""}${A}`, w = d.current; s(b, w ? -1 : b.length, E); }, R = h.selectionMoveEnd$.subscribe((_) => { if (S(_, !0), d.current = !1, l.current) { const { result: E, offset: x } = l.current; s(E, x, !0), l.current = void 0; } }), C = h.selectionMoving$.pipe(ys(50)).subscribe((_) => { S(_, !1); }); return () => { R.unsubscribe(), C.unsubscribe(); }; } }, [e, g, h, r, i, s, a, t]), D(() => { if (e && h) { const m = new st(), S = (_, E) => { var w; let x = 0, M = 0, T = !1; const P = a.getUnit(t), A = ((w = P == null ? void 0 : P.getActiveSheet()) == null ? void 0 : w.getName()) || "", N = g.map((I) => { if (typeof I == "string") return T || (M += I.length), I; if (I.nodeType === G.REFERENCE) { const v = we(_); if (v.unitId = v.unitId === "" ? t : v.unitId, v.sheetName = v.sheetName === "" ? A : v.sheetName, x === E) { T = !0; const F = { ...I, token: _ }; return r ? F.token = Tt(v.sheetName, v.range) : F.token = Ve(v.range), x++, M += F.token.length, F; } return x++, T || (M += I.token.length), I; } return I; }), b = Oe(N); l.current = { result: b, offset: M }, s(b, -1, !1); }; let R = 0; const C = h.selectionMoveEnd$.subscribe(() => { R = setTimeout(() => { m.dispose(), h.getSelectionControls().forEach((E, x) => { m.add(cn(E.selectionMoving$, E.selectionScaling$).pipe( Ht((M) => Ve(M)), dr() ).subscribe((M) => { d.current = !0, S(M, x); })); }); }, 30); }); return () => { C.unsubscribe(), m.dispose(), clearTimeout(R); }; } }, [e, h, g, s, a, t, r]); }, bn = (e, t, n, o, r, i) => { const s = y(ye), c = y(qe), d = y(ve).getRenderById(t), u = d == null ? void 0 : d.with(Fe); D(() => { if (e && u) if (n) { const h = s.onCommandExecuted((f) => { if (f.id === Un.id) { const g = u.getSelectionControls().length; for (let l = 1; l <= g; l++) u.clearLastSelection(); setTimeout(() => { i(); }, 30); } }); return () => { h.dispose(); }; } else { const h = s.beforeCommandExecuted((f) => { if (f.id === Un.id) { o(!1), r(), i(); const g = c.getEditor(dn); g == null || g.focus(); } }); return () => { h.dispose(); }; } }, [e, u]); }, Zr = (e) => !e.some((n) => { if (typeof n == "string") { if (n !== ge.COMMA) return !0; } else if (n.nodeType !== G.REFERENCE) return !0; return !1; }), di = (e, t, n) => { const o = q(!0); D(() => { if (e) { const r = setTimeout(() => { o.current = !1; }, 500); return () => { clearTimeout(r); }; } }, [e]), D(() => { if (!o.current && t) { const r = Zr(n); t(r, Oe(n)); } }, [n, t]); }, mi = "univer-sheet-range-selector-text-wrap", gi = "univer-sheet-range-selector-placeholder", pi = "univer-sheet-range-selector-error", Si = "univer-sheet-range-selector-error-wrap", vi = "univer-sheet-range-selector-text", Ci = "univer-sheet-range-selector-active", _i = "univer-sheet-range-selector-icon", Ri = "univer-sheet-range-selector-dialog-item", Ii = "univer-sheet-range-selector-dialog-item-delete", xe = { sheetRangeSelectorTextWrap: mi, sheetRangeSelectorPlaceholder: gi, sheetRangeSelectorError: pi, sheetRangeSelectorErrorWrap: Si, sheetRangeSelectorText: vi, sheetRangeSelectorActive: Ci, sheetRangeSelectorIcon: _i, sheetRangeSelectorDialogItem: Ri, sheetRangeSelectorDialogItemDelete: Ii }, dt = () => { }; function Ei(e) { const { initValue: t, unitId: n, subUnitId: o, errorText: r, placeholder: i, actions: s, onChange: c = dt, onVerify: a = dt, onRangeSelectorDialogVisibleChange: d = dt, onBlur: u = dt, onFocus: h = dt, isFocus: f = !0, isOnlyOneRange: g = !1, isSupportAcrossSheet: l = !1 } = e, m = Ee(c), S = y(qe), R = y(Xe), C = y(ye), _ = y(Be), E = q(null), [x, M] = H(!1), [T, P] = H(f), A = Z(() => sr(`${No}-${ir(4)}`), []), N = q(), b = N.current, w = q(null), I = y(pe), v = Z(() => !x && T, [x, T]), [F, O] = H(() => typeof t == "string" ? t : Ne(t, l).join(ge.COMMA)), L = Z(() => I.getCurrentTypeOfUnit$(Me.UNIVER_DOC), [I]), B = it(L), K = (B == null ? void 0 : B.getUnitId()) === A, V = q([]), U = Ee((j, k) => { E.current && !x && !E.current.contains(j.target) && k(); }); s && (s.handleOutClick = U); const ne = Z(() => F.split(ge.COMMA).filter((j) => !!j).map((j) => we(j)), [F]), ie = Z(() => r !== void 0, [r]), te = Yr(!x && T, n, o); Z(() => (j) => { const k = _.sequenceNodesBuilder(j); if (k) { if (Zr(k)) { const X = k.map((oe) => { if (typeof oe == "string") return oe; if (oe.nodeType === G.REFERENCE) { const Je = { ...oe }, Pe = we(oe.token); return Pe.range = En(Pe.range), l || (Pe.sheetName = "", Pe.unitId = ""), Je.token = Ne([Pe], l)[0], Je; } return oe; }), J = Oe(X); m(J); } } else O(""); }, [l]); const W = Hr(b), { checkScrollBar: Ce } = gr(b, !0, !0), de = qt(), fe = Z(() => de(F), [F]), re = Ur(), be = Rn(n, o), ce = Ee((j, k = !0, z = !0) => { if (!N.current) return; const X = de(j), J = re(N.current, X, k); V.current = J, z && be(J, N.current); }); D(() => { const j = C.onCommandExecuted((k) => { var z, X; if (k.id === Fs.id) { const J = k.params, { unitId: oe } = J; oe === A && m(cr.transform.getPlainText((X = (z = b == null ? void 0 : b.getDocumentData().body) == null ? void 0 : z.dataStream) != null ? X : "")); } }); return () => j.dispose(); }, [C, b, A, m]); const _e = Ee((j, k, z) => { ce(j), O(j), z && (W(), k !== -1 && setTimeout(() => { const X = { startOffset: k, endOffset: k }; b == null || b.setSelectionRanges([X]); const J = b == null ? void 0 : b.render.with(pr); J == null || J.scrollToRange({ ...X, collapsed: !0 }); }, 50), Ce()); }); zr(v, n, o, fe, l, g, _e), In(v, v && K, n), Kr(n, g), si(n, F, b), di(v, a, fe), qr(v, 0, b), ui(), bn(v, n, l, P, u, () => { v && ce(F); }), D(() => { if (b) { const j = b.input$.pipe(mn(100)).subscribe((k) => { var X, J; const z = ((J = (X = k.data.body) == null ? void 0 : X.dataStream) != null ? J : "").replaceAll(/\n|\r/g, "").replaceAll(/,{2,}/g, ",").replaceAll(/(^,)/g, ""); ce(z, !1), O(z); }); return () => { j.unsubscribe(); }; } }, [b]), D(() => { const j = C.onCommandExecuted((k) => { k.id === Fo.id && (M(!1), d(!1), P(!1), u()); }); return () => { j.dispose(); }; }, [l]), lt(() => { let j; if (w.current) { j = S.register({ autofocus: !0, editorUnitId: A, initialSnapshot: { id: A, body: { dataStream: `${F}\r `, textRuns: [] }, documentStyle: {} } }, w.current); const k = S.getEditor(A); N.current = k, ce(F, !1, !1); } return () => { j == null || j.dispose(); }; }, []), lt(() => { f ? (P(f), W()) : (b == null || b.blur(), te(), P(f)); }, [f, W]), ii(F, "", T, re, be, b); const me = () => { h(), W(), P(!0); }, Re = (j) => { const k = Ne(j, l).join(ge.COMMA); k || b == null || b.setDocumentData({ ...b.getDocumentData(), body: { dataStream: `\r `, textRuns: [] } }), ce(k), O(k), M(!1), d(!1), setTimeout(() => { P(!0), b == null || b.setSelectionRanges([{ startOffset: k.length, endOffset: k.length }]), W(), Ce(); }, 30); }, je = () => { M(!1), d(!1), setTimeout(() => { P(!0), W(); }, 30); }, He = () => { ie || (W(), setTimeout(() => { M(!0), d(!0), P(!1); }, 30)); }; return /* @__PURE__ */ p.jsxs("div", { className: xe.sheetRangeSelector, ref: E, children: [ /* @__PURE__ */ p.jsxs( "div", { className: ln(xe.sheetRangeSelectorTextWrap, { [xe.sheetRangeSelectorActive]: T && !ie, [xe.sheetRangeSelectorError]: ie }), children: [ /* @__PURE__ */ p.jsx("div", { className: xe.sheetRangeSelectorText, ref: w, onMouseUp: me }), /* @__PURE__ */ p.jsx(bs, { title: R.t("rangeSelector.buttonTooltip"), placement: "bottom", children: /* @__PURE__ */ p.jsx(kr, { className: xe.sheetRangeSelectorIcon, onClick: He }) }), r !== void 0 ? /* @__PURE__ */ p.jsx("div", { className: xe.sheetRangeSelectorErrorWrap, children: r }) : null, i !== void 0 && !F ? /* @__PURE__ */ p.jsx("div", { className: xe.sheetRangeSelectorPlaceholder, children: i }) : null ] } ), x && /* @__PURE__ */ p.jsx( bi, { editorId: A, handleConfirm: Re, handleClose: je, unitId: n, subUnitId: o, initValue: ne, visible: x, isOnlyOneRange: g, isSupportAcrossSheet: l } ) ] }); } function bi(e) { const { handleConfirm: t, handleClose: n, visible: o, initValue: r, unitId: i, subUnitId: s, isOnlyOneRange: c, isSupportAcrossSheet: a } = e, d = y(Xe), u = y(xt), h = y(Be), g = y(ve).getRenderById(i), l = g == null ? void 0 : g.with(Fe), [m, S] = H(() => { if (c) { const v = r[0]; return v ? Ne([v], a) : [""]; } return Ne(r, a); }), [R, C] = H(() => m.length - 1), _ = Vr(), E = Z(() => m.join(ge.COMMA), [m]), x = qt(), M = Z(() => x(E), [E]), T = Z(() => Br(u, _, M).refSelections, [M]), P = () => { S([]), setTimeout(() => { n(); }, 30); }, A = (v, F) => { F ? l == null || l.setSkipLastEnabled(!1) : l == null || l.setSkipLastEnabled(!0), S((O) => { const L = [...O]; return L[v] = F, L; }); }, N = (v) => { l == null || l.setSkipLastEnabled(!1), S((F) => { if (F.length === 1) return F; const O = []; return F.forEach((L, B) => { v !== B && O.push(L); }), O; }); }, b = () => { l == null || l.setSkipLastEnabled(!0), S((v) => (v.push(""), C(v.length - 1), [...v])); }, w = Ee((v) => { var O; l == null || l.setSkipLastEnabled(!1); const F = v.split(ge.COMMA).filter((L) => !!L); S(c ? [(O = F[0]) != null ? O : ""] : F); }), I = Rn(i, s); return zr(R >= 0, i, s, M, a, c, w), In(R >= 0, R >= 0, i), Kr(i, c), bn(R >= 0, i, a, $n, $n, () => I(T)), D(() => { I(T); }, [T]), D(() => { (m.length === 0 || m.length === 1 && !m[0]) && (l == null || l.setSkipLastEnabled(!0)); }, [m]), /* @__PURE__ */ p.jsx( xs, { width: "328px", visible: o, title: d.t("rangeSelector.title"), draggable: !0, closeIcon: /* @__PURE__ */ p.jsx(Bt, {}), footer: /* @__PURE__ */ p.jsxs("footer", { children: [ /* @__PURE__ */ p.jsx(ot, { onClick: P, children: d.t("rangeSelector.cancel") }), /* @__PURE__ */ p.jsx( ot, { style: { marginLeft: 10 }, onClick: () => t(m.filter((v) => { const F = h.sequenceNodesBuilder(v); return F && F.length === 1 && typeof F[0] != "string" && F[0].nodeType === G.REFERENCE; }).map((v) => we(v)).map((v) => ({ ...v, range: En(v.range) }))), type: "primary", children: d.t("rangeSelector.confirm") } ) ] }), onClose: P, children: /* @__PURE__ */ p.jsxs("div", { className: xe.sheetRangeSelectorDialog, children: [ m.map((v, F) => /* @__PURE__ */ p.jsxs("div", { className: xe.sheetRangeSelectorDialogItem, children: [ /* @__PURE__ */ p.jsx( Fr, { affixWrapperStyle: { width: "100%" }, placeholder: d.t("rangeSelector.placeHolder"), onFocus: () => C(F), value: v, onChange: (O) => A(F, O) }, `input_${F}` ), m.length > 1 && !c && /* @__PURE__ */ p.jsx(wr, { className: xe.sheetRangeSelectorDialogItemDelete, onClick: () => N(F) }) ] }, `${v}_${F}`)), !c && /* @__PURE__ */ p.jsx("div", { children: /* @__PURE__ */ p.jsxs(ot, { type: "link", size: "small", onClick: b, children: [ /* @__PURE__ */ p.jsx(Dr, {}), /* @__PURE__ */ p.jsx("span", { children: d.t("rangeSelector.addAnotherRange") }) ] }) }) ] }) } ); } function xi(e, t) { return Object.keys(e).filter((n) => isNaN(Number(n)) && n !== "DefinedName").map((n) => ({ label: t.t(`formula.functionType.${n.toLocaleLowerCase()}`), value: `${e[n]}` })); } function xn(e) { if (!e.require && !e.repeat) return `[${e.name}]`; if (e.require && !e.repeat) return e.name; if (!e.require && e.repeat) return `[${e.name},...]`; if (e.require && e.repeat) return `${e.name},...`; } const Ni = (e, t = 100) => { D(() => { let n = null; const o = () => { n === null && (n = window.setTimeout(() => { e(), n = null; }, t)); }; return window.addEventListener("scroll", o), window.addEventListener("resize", o), () => { n !== null && clearTimeout(n), window.removeEventListener("scroll", o), window.removeEventListener("resize", o); }; }, [e, t]); }; function Gr(e, t, n) { const o = y(qe), r = Z(() => new Go({ left: -999, top: -999, right: -999, bottom: -999 }), []), i = y(Ut), s = y(pe), c = Ee(() => { const a = o.getEditor(e); if (!a) return; const d = a.getBoundingClientRect(), { left: u, top: h, right: f, bottom: g } = d, l = r.getValue(); if (!(l.left === u && l.top === h && l.right === f && l.bottom === g)) return r.next({ left: u - 1, right: f + 1, top: h - 1, bottom: g + 1 }), d; }); return D(() => { t && c(); }, [e, o, s.unitAdded$, c, t, ...n != null ? n : []]), Ni(c), D(() => { const a = i.scrollEvent$.pipe(mn(100)).subscribe(c); return () => { a.unsubscribe(); }; }, []), [r, c]; } const Ct = (e) => { const t = q(e); return t.current = e, t; }, Fi = (e, t, n) => { const o = y(xt), r = y(Be), [i, s] = H(), [c, a] = H(-1), [d, u] = H(!0), h = Ct(d), f = q(t); f.current = t; const g = () => { s(void 0), a(-1), u(!1); }; return D(() => { if (n && e) { const l = n.selectionChange$.pipe(gn(50)).subscribe((S) => { if (S.textRanges.length === 1) { const [R] = S.textRanges; if (R.collapsed && h.current) { const C = r.getFunctionAndParameter(`${f.current}A`, R.startOffset - 1); if (C) { const { functionName: _, paramIndex: E } = C, x = o.getFunctionInfo(_); s(x), a(E); return; } } } s(void 0), a(-1); }), m = n.selectionChange$.pipe( sn((S) => S.isEditing), sn((S) => S.textRanges.length === 1), Ht((S) => S.textRanges[0].startOffset), dr() ).subscribe(() => { u(!0); }); return () => { l.unsubscribe(), m.unsubscribe(); }; } }, [n, e]), D(() => { e || g(); }, [e]), { functionInfo: i, paramIndex: c, reset: g }; }, yi = "univer-formula-help-function", Ti = "univer-formula-help-function-title", Oi = "univer-formula-help-function-title-icons", Mi = "univer-formula-help-function-title-icon", Pi = "univer-formula-help-function-content", Ai = "univer-formula-help-function-content-inner", Li = "univer-formula-help-function-content-params", wi = "univer-formula-help-function-content-params-title", $i = "univer-formula-help-function-content-params-detail", Di = "univer-formula-help-function-active", ki = "univer-formula-help-decorator", ji = "univer-formula-help-param", Hi = "univer-formula-help-param-prefix", Wi = "univer-formula-help-param-item", Ui = "univer-formula-help-param-active", ue = { formulaHelpFunction: yi, formulaHelpFunctionTitle: Ti, formulaHelpFunctionTitleIcons: Oi, formulaHelpFunctionTitleIcon: Mi, formulaHelpFunctionContent: Pi, formulaHelpFunctionContentInner: Ai, formulaHelpFunctionContentParams: Li, formulaHelpFunctionContentParamsTitle: wi, formulaHelpFunctionContentParamsDetail: $i, formulaHelpFunctionActive: Di, formulaHelpDecorator: ki, formulaHelpParam: ji, formulaHelpParamPrefix: Hi, formulaHelpParamItem: Wi, formulaHelpParamActive: Ui }, Jt = ({ className: e, title: t, value: n }) => /* @__PURE__ */ p.jsxs("div", { className: ue.formulaHelpFunctionContentParams, children: [ /* @__PURE__ */ p.jsx( "div", { className: ` ${ue.formulaHelpFunctionContentParamsTitle} ${e} `, children: t } ), /* @__PURE__ */ p.jsx("div", { className: ue.formulaHelpFunctionContentParamsDetail, children: n }) ] }), Vi = (e) => { const { prefix: t, value: n, active: o, onClick: r } = e; return /* @__PURE__ */ p.jsxs("div", { className: ue.formulaHelpParam, children: [ /* @__PURE__ */ p.jsxs("span", { className: ue.formulaHelpParamPrefix, children: [ t, "(" ] }), n && n.map((i, s) => /* @__PURE__ */ p.jsxs("span", { className: ue.formulaHelpParamItem, children: [ /* @__PURE__ */ p.jsx( "span", { className: o === s ? ue.formulaHelpFunctionActive : ue.formulaHelpParamActive, onClick: () => r(s), children: xn(i) } ), s === n.length - 1 ? "" : "," ] }, i.name)), ")" ] }); }, Gn = () => { }; function Bi(e) { const { onParamsSwitch: t = Gn, onClose: n = Gn, isFocus: o, editor: r, formulaText: i } = e, { functionInfo: s, paramIndex: c, reset: a } = Fi(o, i, r), d = Z(() => !!s && c >= 0, [s, c]), [u, h] = H(!0), f = y(Xe), g = f.t("formula.prompt.required"), l = f.t("formula.prompt.optional"), m = r.getEditorId(), [S] = Gr(m, d, [s, c]); function R(_) { t && t(_); } const C = () => { a(), n(); }; return d && s ? /* @__PURE__ */ p.jsx(xr, { portal: !0, onClickOutside: () => a(), anchorRect$: S, direction: "vertical", children: /* @__PURE__ */ p.jsxs("div", { className: ue.formulaHelpFunction, children: [ /* @__PURE__ */ p.jsxs("div", { className: ue.formulaHelpFunctionTitle, children: [ /* @__PURE__ */ p.jsx( Vi, { prefix: s.functionName, value: s.functionParameter, active: c, onClick: R } ), /* @__PURE__ */ p.jsxs("div", { className: ue.formulaHelpFunctionTitleIcons, children: [ /* @__PURE__ */ p.jsx( "div", { className: ue.formulaHelpFunctionTitleIcon, style: { transform: u ? "rotateZ(-90deg)" : "rotateZ(90deg)" }, onClick: () => h(!u), children: /* @__PURE__ */ p.jsx(_n, {}) } ), /* @__PURE__ */ p.jsx( "div", { className: ue.formulaHelpFunctionTitleIcon, onClick: C, children: /* @__PURE__ */ p.jsx(Bt, {}) } ) ] }) ] }), /* @__PURE__ */ p.jsx( "div", { className: ue.formulaHelpFunctionContent, style: { height: u ? "unset" : 0, padding: u ? "revert-layer" : 0 }, children: /* @__PURE__ */ p.jsxs("div", { className: ue.formulaHelpFunctionContentInner, children: [ /* @__PURE__ */ p.jsx( Jt, { title: f.t("formula.prompt.helpExample"), value: `${s.functionName}(${s.functionParameter.map((_) => _.example).join(",")})` } ), /* @__PURE__ */ p.jsx( Jt, { title: f.t("formula.prompt.helpAbstract"), value: s.description } ), s && s.functionParameter && s.functionParameter.map((_, E) => /* @__PURE__ */ p.jsx( Jt, { className: c === E ? ue.formulaHelpFunctionActive : "", title: _.name, value: `${_.require ? g : l} ${_.detail}` }, E )) ] }) } ) ] }) }) : null; } const Xr = (e, t, n = !0) => { let o = -1; return e.reduce((r, i, s) => { if (r.isFinish) return r; const c = r.currentIndex; if (typeof i != "string") r.currentIndex += i.token.length; else { const a = i.length; r.currentIndex += a; } return (n ? r.currentIndex === t : t > c && t <= r.currentIndex) && (o = s, r.isFinish = !0), r; }, { currentIndex: 0, isFinish: !1 }), o; }, yt = (e) => e.reduce((t, n) => typeof n == "string" ? t + n.length : t + n.token.length, 0), qi = () => { }, Ki = (e, t, n, o, r, i, s, c, a, d, u = qi) => { const h = y(ve), f = y(pe), g = y(ye), l = Ct(i), m = y(Tr), S = y(Rt), R = f.getUnit(o), C = Ee((I) => { var v, F; return (F = (v = R == null ? void 0 : R.getSheetBySheetId(I)) == null ? void 0 : v.getName()) != null ? F : ""; }), _ = Z(() => C(r), [C, r]), E = it(R == null ? void 0 : R.activeSheet$), x = Ct({ activeSheet: E, sheetName: _ }), M = h.getRenderById(o), T = M == null ? void 0 : M.with(Fe), P = M == null ? void 0 : M.with(kt), A = y(Wt), N = q(!1), b = q(n); b.current = n; const w = q(); D(() => { if (T && e) { let I = !0; const v = (O, L) => { var ie, te, W, Ce, de, fe; if (I) { I = !1; return; } const B = d == null ? void 0 : d.getSelectionRanges(); if ((B == null ? void 0 : B.length) !== 1) return; const V = B[0].startOffset - 1, U = [...l.current], ne = Xr(U, V, !1); if (b.current === Mt.NEED_ADD) if (V !== 0) { if (ne === -1 && U.length) return; const re = O[O.length - 1], be = U.splice(ne + 1), ce = (ie = re.rangeWithCoord.sheetId) != null ? ie : r, _e = { range: re.rangeWithCoord, unitId: (te = re.rangeWithCoord.unitId) != null ? te : o, sheetName: C(ce) }, Re = Ne([_e], c && ce !== r, _); U.push({ token: Re[0], nodeType: G.REFERENCE }); const je = [...U, ...be], He = Oe(je); u(He, yt(U), L); } else { const re = O[O.length - 1], be = (W = re.rangeWithCoord.sheetId) != null ? W : r, ce = { range: re.rangeWithCoord, unitId: (Ce = re.rangeWithCoord.unitId) != null ? Ce : o, sheetName: C(be) }, me = Ne([ce], c && be !== r); U.unshift({ token: me[0], nodeType: G.REFERENCE }); const Re = Oe(U); u(Re, me[0].length, L); } else { let re = 0; const be = U.map((j) => { var k, z, X; if (typeof j == "string") return j; if (j.nodeType === G.REFERENCE) { const J = we(j.token); if (J.sheetName || (J.sheetName = _), c && ((k = x.current.activeSheet) == null ? void 0 : k.getName()) !== J.sheetName) return j.token; const oe = O[re]; if (re++, !oe) return ""; const Je = (z = oe.rangeWithCoord.sheetId) != null ? z : r, Pe = { range: oe.rangeWithCoord, unitId: (X = oe.rangeWithCoord.unitId) != null ? X : o, sheetName: C(Je) }; return Ne([Pe], c, _)[0]; } return j.token; }); let ce = "", _e; be.forEach((j, k) => { ce += j, k === ne && (_e = ce.length); }); const me = []; for (let j = re; j <= O.length - 1; j++) { const k = O[j], z = (de = k.rangeWithCoord.sheetId) != null ? de : r, X = { range: k.rangeWithCoord, unitId: (fe = k.rangeWithCoord.unitId) != null ? fe : o, sheetName: C(z) }, oe = Ne([X], c && z !== r, _); me.push(oe[0]); } const Re = U[U.length - 1], je = Re && (typeof Re == "string" ? !1 : Re.nodeType === G.REFERENCE), He = `${ce}${me.length && je ? "," : ""}${me.join(",")}`; u(He, !me.length && _e ? _e : He.length, L); } }, F = new st(); return F.add(T.selectionMoving$.subscribe((O) => { N.current || v(O, !1); })), F.add(T.selectionMoveEnd$.subscribe((O) => { N.current || v(O, !0); })), () => { F.dispose(); }; } }, [T, d, c, e, l, r, o, C, _, u, x]), D(() => { if (t && T && d) { const I = new st(), v = (L, B) => { let K = 0, V = 0, U = !1; const { sheetName: ne } = x.current, ie = l.current.map((W) => { var Ce; if (typeof W == "string") return U || (V += W.length), W; if (W.nodeType === G.REFERENCE) { const de = we(W.token); if (de.unitId || (de.unitId = o), de.sheetName || (de.sheetName = ne), c && ((Ce = x.current.activeSheet) == null ? void 0 : Ce.getName()) !== de.sheetName) return U || (V += W.token.length), W; if (K === B) { U = !0; const fe = { ...W, token: L }; return c && de.sheetName !== ne ? fe.token = Tt(de.sheetName, we(L).range) : fe.token = L, V += fe.token.length, K++, fe; } return U || (V += W.token.length), K++, W; } return U || (V += W.token.length), W; }), te = Oe(ie); u(te, -1, !0), w.current = { result: te, offset: V }; }, F = () => { I.dispose(), T.getSelectionControls().forEach((B, K) => { I.add(cn(B.selectionMoving$, B.selectionScaling$).pipe( Ts((V) => Ve(V)), Os(), qn(100) ).subscribe((V) => { N.current = !0, v(V, K); })); }), I.add(T.selectionMoveEnd$.subscribe((B) => { if (N.current = !1, w.current) { const { result: K, offset: V } = w.current; u(K, V || -1, !0), w.current = void 0; } })); }, O = cn( d.input$, A.selectionSet$, T.selectionMoveEnd$ ).pipe( qn(50) ).subscribe(() => { F(); }); return () => { O.unsubscribe(), I.dispose(); }; } }, [t, T, d, A.selectionSet$, x, l, u, c, o]), D(() => { if (a) { const I = g.onCommandExecuted((v) => { if (v.id !== Cr.id) return; const F = v.params; if (F.extra !== "formula-editor") return; const { selections: O } = F; if (O.length) { const L = O[O.length - 1]; if (L) { const B = L.range, K = r, V = { range: B, unitId: F.unitId === o ? "" : F.unitId, sheetName: F.subUnitId === K ? "" : C(K) }, U = [...l.current], ie = Ne([V], c, _)[0]; let te = U[U.length - 1]; if (typeof te == "object" && te.nodeType === G.REFERENCE) { te = { ...te }, te.token = ie, te.endIndex = te.startIndex + ie.length, U[U.length - 1] = te; const W = Oe(U); u(W, yt(U), !0); } else { const W = yt(U); U.push({ nodeType: G.REFERENCE, token: ie, startIndex: W, endIndex: W + ie.length }); const Ce = Oe(U); u(Ce, yt(U), !0); } } } }); return () => { I.dispose(); }; } }, [g, C, u, c, a, l, _, r, o]), D(() => { if (!d) return; const I = m.textSelection$.subscribe((v) => { v.unitId === d.getEditorId() && Wr({ unitId: o, subUnitId: r, refSelections: s.current, editor: d, refSelectionsService: A, refSelectionsRenderService: T, sheetSkeletonManagerService: P, themeService: S, univerInstanceService: f }); }); return () => I.unsubscribe(); }, [m.textSelection$, d, s, T, A, l, P, r, S, o, f]); }, Yi = (e, t, n) => { const o = y(Be), r = q(!0); D(() => { if (e) { const i = setTimeout(() => { r.current = !1; }, 500); return () => { clearTimeout(i); }; } }, [e]), D(() => { if (!r.current && t) { const i = o.checkIfAddBracket(n); t(i === 0 && n.startsWith(hr.EQUALS), `${n}`); } }, [n, t]); }, zi = "univer-sheet-embedding-formula-editor-active", Zi = "univer-sheet-embedding-formula-editor-wrap", Gi = "univer-sheet-embedding-formula-editor-text", Xi = "univer-sheet-embedding-formula-editor-error", Ji = "univer-sheet-embedding-formula-editor", Qi = "univer-sheet-embedding-formula-editor-error-wrap", nt = { sheetEmbeddingFormulaEditorActive: zi, sheetEmbeddingFormulaEditorWrap: Zi, sheetEmbeddingFormulaEditorText: Gi, sheetEmbeddingFormulaEditorError: Xi, sheetEmbeddingFormulaEditor: Ji, sheetEmbeddingFormulaEditorErrorWrap: Qi }, ec = (e, t = [], n) => { const o = y(xt), [r, i] = H([]), [s, c] = H(""), a = q(-1), d = Ct({ nodes: t }), u = () => { i([]), c(""), a.current = -1; }; return D(() => { if (n && e) { const f = n.input$.pipe(gn(300)).subscribe(() => { const g = n.getSelectionRanges(); if (g.length === 1) { const l = d.current.nodes, m = g[0]; if (m.collapsed) { const S = Xr(l, m.startOffset - 1, !1); a.current = S; const R = l[S]; if (R && typeof R != "string" && R.nodeType === G.FUNCTION) { a.current = S; const C = R.token, _ = o.getSearchListByNameFirstLetter(C); i(_), c(C); return; } } } a.current = -1, c(""), i((l) => l != null && l.length ? [] : l); }); return () => { f.unsubscribe(); }; } }, [n, e]), D(() => { e || u(); }, [e]), { searchList: r, searchText: s, handlerFormulaReplace: (f) => { const g = [...d.current.nodes]; if (a.current !== -1) { const l = g.splice(a.current + 1), m = g.pop() || ""; let S = (typeof m == "string" ? m.length : m.token.length) - f.length; return g.push(f), l[0] !== ge.OPEN_BRACKET && (g.push(ge.OPEN_BRACKET), S--), { text: Oe([...g, ...l]), offset: S }; } }, reset: u }; }, tc = "univer-formula-search-function", nc = "univer-formula-search-function-item", rc = "univer-formula-search-function-item-name", oc = "univer-formula-search-function-item-name-light", sc = "univer-formula-search-function-item-desc", ic = "univer-formula-search-function-item-active", We = { formulaSearchFunction: tc, formulaSearchFunctionItem: nc, formulaSearchFunctionItemName: rc, formulaSearchFunctionItemNameLight: oc, formulaSearchFunctionItemDesc: sc, formulaSearchFunctionItemActive: ic }, cc = () => { }, ac = ke(lc); function lc(e, t) { const { isFocus: n, sequenceNodes: o, onSelect: r, editor: i, onClose: s = cc } = e, c = i.getEditorId(), a = y(Vt), d = y(ye), { searchList: u, searchText: h, handlerFormulaReplace: f, reset: g } = ec(n, o, i), l = Z(() => !!u.length, [u]), m = q(), [S, R] = H(0), C = q(!1), [_] = Gr(c, l, [h, u]), E = Ct({ searchList: u, active: S }), x = (N) => { const b = f(N); b && (g(), r(b)); }; function M(N) { C.current && R(N); } function T() { C.current && R(-1); } D(() => { if (!u.length) return; const N = `sheet.formula-embedding-editor.search_function.${c}`, b = new st(), w = (I) => { const { searchList: v, active: F } = E.current; switch (I) { case $.ARROW_UP: { R((O) => { const L = Math.max(0, O - 1); return P(L), L; }); break; } case $.ARROW_DOWN: { R((O) => { const L = Math.min(v.length - 1, O + 1); return P(L), L; }); break; } case $.TAB: case $.ENTER: { const O = v[F]; x(O.name); break; } case $.ESC: { g(), s(); break; } } }; return b.add(d.registerCommand({ id: N, type: $e.OPERATION, handler(I, v) { const { keyCode: F } = v; w(F); } })), [$.ARROW_UP, $.ARROW_DOWN, $.ENTER, $.ESC, $.TAB].map((I) => ({ id: N, binding: I, preconditions: () => !0, priority: 1e3, staticParameters: { eventType: De.Keyboard, keyCode: I } })).forEach((I) => { b.add(a.registerShortcut(I)); }), () => { b.dispose(); }; }, [u]); function P(N) { var V; const b = (V = m.current) == null ? void 0 : V.querySelectorAll(`.${We.formulaSearchFunctionItem}`)[N]; if (!b) return; const w = b.parentNode; if (!w) return; const v = w.getBoundingClientRect().top, F = w.offsetHeight, O = b.getBoundingClientRect(), L = O.top, B = O.height; if (L >= 0 && L > v && L - v + B <= F) return; const K = b.offsetTop - (F - B) / 2; w.scrollTo({ top: K, behavior: "smooth" }); } const A = Z(() => { let N = ""; return () => { clearTimeout(N), C.current = !0, N = setTimeout(() => { C.current = !1; }, 300); }; }, []); return u.length > 0 && l && /* @__PURE__ */ p.jsx(xr, { portal: !0, anchorRect$: _, direction: "vertical", children: /* @__PURE__ */ p.jsx( "ul", { className: We.formulaSearchFunction, ref: (N) => { m.current = N, t && (t.current = N); }, children: u.map((N, b) => /* @__PURE__ */ p.jsxs( "li", { className: S === b ? ` ${We.formulaSearchFunctionItem} ${We.formulaSearchFunctionItemActive} ` : We.formulaSearchFunctionItem, onMouseEnter: () => M(b), onMouseLeave: T, onMouseMove: A, onClick: () => { x(N.name), i && i.focus(); }, children: [ /* @__PURE__ */ p.jsxs("span", { className: We.formulaSearchFunctionItemName, children: [ /* @__PURE__ */ p.jsx("span", { className: We.formulaSearchFunctionItemNameLight, children: N.name.substring(0, h.length) }), /* @__PURE__ */ p.jsx("span", { children: N.name.slice(h.length) }) ] }), /* @__PURE__ */ p.jsx("span", { className: We.formulaSearchFunctionItemDesc, children: N.desc }) ] }, N.name )) } ) }); } const uc = (e) => e.startsWith(hr.EQUALS) ? e.slice(1) : "", Qt = () => { }; function fc(e) { var Yt, Nn; const { errorText: t, initValue: n, unitId: o, subUnitId: r, isFocus: i = !0, isSupportAcrossSheet: s = !1, onFocus: c = Qt, onBlur: a = Qt, onChange: d, onVerify: u, actions: h, className: f, editorId: g, moveCursor: l = !0, onFormulaSelectingChange: m, keyboradEventConfig: S, onMoveInEditor: R, resetSelectionOnBlur: C = !0, autoScrollbar: _ = !0, isSingle: E = !0, disableSelectionOnClick: x = !1, disableContextMenu: M } = e, T = y(qe), P = q(null), A = Ee(d); h && (h.handleOutClick = (ae, le) => { P.current && !P.current.contains(ae.target) && le(); }); const N = Ee(m), b = q(null), w = q(), I = w.current, [v, F] = H(i), O = q(null), L = Z(() => g != null ? g : sr(`${yo}-${ir(4)}`), []), B = Z(() => t !== void 0, [t]), K = y(pe), V = K.getUnit(L); it(V == null ? void 0 : V.change$); const U = qt(), ne = cr.transform.getPlainText((Nn = (Yt = V == null ? void 0 : V.getBody()) == null ? void 0 : Yt.dataStream) != null ? Nn : ""), ie = Z(() => uc(ne), [ne]), te = Z(() => U(ie), [ie, U]), { isSelecting: W } = li(L, v, x), Ce = q(""), fe = y(ve).getRenderById(L), re = fe == null ? void 0 : fe.with(mr), be = re == null ? void 0 : re.isFocusing, ce = Z(() => K.getCurrentTypeOfUnit$(Me.UNIVER_DOC), [K]), _e = it(ce), me = (_e == null ? void 0 : _e.getUnitId()) === L, Re = q([]), je = W; ms(() => { A(ne); }, [ne, A]); const He = Ur("="), j = Rn(o, r), k = Ee((ae, le = !0, Ae, Qe) => { if (!w.current) return; Ce.current = ae; const zt = U(ae[0] === "=" ? ae.slice(1) : ""), et = He( w.current, zt, le, Qe ); Re.current = et, Ae && j(v ? et : [], w.current); }); D(() => { v && k(ne, !1, !0); }, [ne, v, k]), Yi(v, u, ne); const z = Hr(I), X = Yr(v, o, r); D(() => { N(W); }, [N, W]), ns(v, S, I), lt(() => { let ae; if (O.current) { ae = T.register({ autofocus: !0, editorUnitId: L, initialSnapshot: { id: L, body: { dataStream: `${n}\r `, textRuns: [], customBlocks: [], customDecorations: [], customRanges: [] }, documentStyle: {} } }, O.current); const le = T.getEditor(L); w.current = le, k(n, !1, !0); } return () => { ae == null || ae.dispose(); }; }, []), lt(() => { i ? (F(i), z()) : (C && (I == null || I.blur(), X()), F(i)); }, [i, I, z, X, C]); const { checkScrollBar: J } = gr(I, E, _); In(v, !!(W && me), o, M), qr(v && l, je, I, R); const oe = Ee((ae, le, Ae) => { if (!be) return; const Qe = le !== -1 ? [{ startOffset: le + 1, endOffset: le + 1, collapsed: !0 }] : void 0; k(`=${ae}`, !0, Ae, Qe), Ae && (z(), le !== -1 && setTimeout(() => { const zt = { startOffset: le + 1, endOffset: le + 1 }, et = I == null ? void 0 : I.render.with(pr); et == null || et.scrollToRange({ ...zt, collapsed: !0 }); }, 50), J()); }); Ki( v && !!(W && me), v, W, o, r, te, Re, s, !!je, I, oe ), bn(v && !!(W && me), o, s, F, a, Qt); const Je = (ae) => { if (ae) { const le = I == null ? void 0 : I.getSelectionRanges(); if (le && le.length === 1) { const Ae = le[0]; if (Ae.collapsed) { const Qe = ae.offset; setTimeout(() => { I == null || I.setSelectionRanges([{ startOffset: Ae.startOffset - Qe, endOffset: Ae.endOffset - Qe }]); }, 30); } } z(), k(`=${ae.text}`); } }, Pe = () => { F(!0), c(), z(); }; return /* @__PURE__ */ p.jsxs("div", { className: ln(nt.sheetEmbeddingFormulaEditor, f), children: [ /* @__PURE__ */ p.jsx( "div", { className: ln(nt.sheetEmbeddingFormulaEditorWrap, { [nt.sheetEmbeddingFormulaEditorActive]: v, [nt.sheetEmbeddingFormulaEditorError]: B }), ref: P, children: /* @__PURE__ */ p.jsx( "div", { className: nt.sheetEmbeddingFormulaEditorText, ref: O, onMouseUp: Pe } ) } ), t !== void 0 ? /* @__PURE__ */ p.jsx("div", { className: nt.sheetEmbeddingFormulaEditorErrorWrap, children: t }) : null, I ? /* @__PURE__ */ p.jsx( Bi, { editor: I, isFocus: v, formulaText: ne, onClose: () => z() } ) : null, I ? /* @__PURE__ */ p.jsx( ac, { isFocus: v, sequenceNodes: te, onSelect: Je, ref: b, editor: I } ) : null ] }); } const hc = "sheets-formula-ui.base.config", Xn = {}; function dc(e) { return e.getContextValue(lo) && e.getContextValue(uo); } function Jr(e, t = !1) { return !t && !(Ge(e == null ? void 0 : e.f) || ct(e == null ? void 0 : e.si)) ? null : typeof (e == null ? void 0 : e.v) == "string" && Bo.has(e.v) ? e.v : null; } var mc = Object.defineProperty, gc = Object.getOwnPropertyDescriptor, pc = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? gc(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && mc(t, n, r), r; }, mt = (e, t) => (n, o) => t(n, o, e); const en = "SHEET_FORMULA_ALERT", Sc = { [Se.DIV_BY_ZERO]: "divByZero", [Se.NAME]: "name", [Se.VALUE]: "value", [Se.NUM]: "num", [Se.NA]: "na", [Se.CYCLE]: "cycle", [Se.REF]: "ref", [Se.SPILL]: "spill", [Se.CALC]: "calc", [Se.ERROR]: "error", [Se.CONNECT]: "connect", [Se.NULL]: "null" }; let fn = class extends It { constructor(e, t, n, o, r, i) { super(), this._context = e, this._hoverManagerService = t, this._cellAlertManagerService = n, this._localeService = o, this._formulaDataModel = r, this._zenZoneService = i, this._init(); } _init() { this._initCellAlertPopup(), this._initZenService(); } _initCellAlertPopup() { this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(gn(100)).subscribe((e) => { var t, n, o, r, i; if (e) { const c = this._context.unit.getActiveSheet(); if (!c) return; const a = c.getCell(e.location.row, e.location.col), d = (r = (o = (n = (t = this._formulaDataModel.getArrayFormulaCellData()) == null ? void 0 : t[e.location.unitId]) == null ? void 0 : n[e.location.subUnitId]) == null ? void 0 : o[e.location.row]) == null ? void 0 : r[e.location.col]; if (fo(a)) { const u = Jr(a, !!d); if (!u) { this._hideAlert(); return; } const h = this._cellAlertManagerService.currentAlert.get(en), f = (i = h == null ? void 0 : h.alert) == null ? void 0 : i.location; if (f && f.row === e.location.row && f.col === e.location.col && f.subUnitId === e.location.subUnitId && f.unitId === e.location.unitId) return; this._cellAlertManagerService.showAlert({ type: To.ERROR, title: this._localeService.t("formula.error.title"), message: this._localeService.t(`formula.error.${Sc[u]}`), location: e.location, width: 200, height: 74, key: en }); return; } } this._hideAlert(); })); } _initZenService() { this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => { e && this._hideAlert(); })); } _hideAlert() { this._cellAlertManagerService.removeAlert(en); } }; fn = pc([ mt(1, ee(Oo)), mt(2, ee(Mo)), mt(3, ee(Xe)), mt(4, ee(jt)), mt(5, gs) ], fn); var vc = Object.defineProperty, Cc = Object.getOwnPropertyDescriptor, _c = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? Cc(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && vc(t, n, r), r; }, Jn = (e, t) => (n, o) => t(n, o, e); let Pt = class extends It { constructor(e, t) { super(), this._autoFillService = e, this._lexerTreeBuilder = t, this._registerAutoFill(); } _registerAutoFill() { const e = { type: wn.FORMULA, priority: 1001, match: (t) => Ge(t == null ? void 0 : t.f) || ct(t == null ? void 0 : t.si), isContinue: (t, n) => t.type === wn.FORMULA, applyFunctions: { [Po.COPY]: (t, n, o, r) => { const { data: i, index: s } = t; return this._fillCopyFormula(i, n, o, s, r); } } }; this._autoFillService.registerRule(e); } _fillCopyFormula(e, t, n, o, r) { var a, d; const i = Ic(r), s = [], c = /* @__PURE__ */ new Map(); for (let u = 1; u <= t; u++) { const h = (u - 1) % e.length, f = vt.deepClone(e[h]); if (f) { const g = ((a = e[h]) == null ? void 0 : a.f) || "", l = ((d = e[h]) == null ? void 0 : d.si) || "", m = Ge(g); if (ct(l)) f.si = l, f.f = null, f.v = null, f.p = null, f.t = null, s.push(f); else if (m) { let R = c.get(h); if (R) f.si = R, f.f = null, f.v = null, f.p = null, f.t = null; else { R = vt.generateRandomId(6), c.set(h, R); const { offsetX: C, offsetY: _ } = Rc(i, t, n), E = this._lexerTreeBuilder.moveFormulaRefOffset( g, C, _ ); f.si = R, f.f = E, f.v = null, f.p = null, f.t = null; } s.push(f); } } } return s; } }; Pt = _c([ Jn(0, Ao), Jn(1, ee(Be)) ], Pt); function Rc(e, t, n) { let o = 0, r = 0; switch (n) { case he.UP: r = -e * t; break; case he.RIGHT: o = e; break; case he.DOWN: r = e; break; case he.LEFT: o = -e * t; break; } return { offsetX: o, offsetY: r }; } function Ic(e) { let t = 0; for (const n in e) e[n].forEach((o) => { t += o.data.length; }); return t; } var Ec = Object.defineProperty, bc = Object.getOwnPropertyDescriptor, xc = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? bc(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && Ec(t, n, r), r; }, gt = (e, t) => (n, o) => t(n, o, e); const Nc = "default-paste-formula"; let At = class extends It { constructor(e, t, n, o, r) { super(), this._currentUniverSheet = e, this._lexerTreeBuilder = t, this._sheetClipboardService = n, this._injector = o, this._formulaDataModel = r, this._initialize(); } _initialize() { this._registerClipboardHook(); } _registerClipboardHook() { this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteFormulaHook())), this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteWithFormulaHook())); } _pasteFormulaHook() { return { id: rt.SPECIAL_PASTE_FORMULA, priority: 10, specialPasteInfo: { label: "specialPaste.formula" }, onPasteCells: (e, t, n, o) => this._onPasteCells(e, t, n, o, !0) }; } _pasteWithFormulaHook() { return { id: Nc, priority: 10, onPasteCells: (e, t, n, o) => this._onPasteCells(e, t, n, o, !1) }; } _onPasteCells(e, t, n, o, r) { var f; if ([ rt.SPECIAL_PASTE_FORMAT, rt.SPECIAL_PASTE_COL_WIDTH ].includes(o.pasteType)) return { undos: [], redos: [] }; const s = this._currentUniverSheet.getCurrentUnitForType(Me.UNIVER_SHEET), c = t.unitId || s.getUnitId(), a = t.subUnitId || ((f = s.getActiveSheet()) == null ? void 0 : f.getSheetId()); if (!c || !a) return { undos: [], redos: [] }; const d = t.range, u = n, h = { copyType: o.copyType || Lo.COPY, copyRange: e == null ? void 0 : e.range, pasteType: o.pasteType }; return this._injector.invoke((g) => Fc( c, a, d, u, g, h, this._lexerTreeBuilder, this._formulaDataModel, r, e )); } }; At = xc([ gt(0, pe), gt(1, ee(Be)), gt(2, wo), gt(3, ee(_t)), gt(4, ee(jt)) ], At); function Fc(e, t, n, o, r, i, s, c, a = !1, d) { const u = [], h = [], f = yc(e, t, n, o, i, s, c, d), g = { unitId: e, subUnitId: t, cellValue: f.getData() }; u.push({ id: Vn.id, params: g }); const l = is( r, g ); return h.push({ id: Vn.id, params: l }), { undos: h, redos: u }; } function yc(e, t, n, o, r, i, s, c) { return c ? r.pasteType === rt.SPECIAL_PASTE_VALUE ? Oc(e, t, n, o, s, c) : r.pasteType === rt.SPECIAL_PASTE_FORMULA ? Mc(e, t, n, o, i, s, c) : Pc(e, t, n, o, i, s, c) : Tc(e, t, n, o, s); } function Tc(e, t, n, o, r) { const i = new Et(), s = r.getSheetFormulaData(e, t); return o.forValue((c, a, d) => { var g; const u = n.rows[c], h = n.cols[a], f = {}; Ge(d.v) ? (f.v = null, f.f = `${d.v}`, f.si = null, f.p = null, i.setValue(u, h, f)) : (g = s == null ? void 0 : s[u]) != null && g[h] && (f.v = d.v, f.f = null, f.si = null, f.p = null, i.setValue(u, h, f)); }), i; } function Oc(e, t, n, o, r, i) { var d, u; const s = new Et(), c = (u = (d = r.getArrayFormulaCellData()) == null ? void 0 : d[i.unitId]) == null ? void 0 : u[i.subUnitId], a = r.getSheetFormulaData(e, t); return o.forValue((h, f, g) => { var _, E; const l = i.range.rows[h % i.range.rows.length], m = i.range.cols[f % i.range.cols.length], S = n.rows[h], R = n.cols[f], C = {}; if (Ge(g.f) || ct(g.si)) C.v = g.v, C.f = null, C.si = null, C.p = null, s.setValue(S, R, C); else if ((_ = c == null ? void 0 : c[l]) != null && _[m]) { const x = c[l][m]; C.v = x.v, C.f = null, C.si = null, C.p = null, s.setValue(S, R, C); } else if ((E = a == null ? void 0 : a[S]) != null && E[R]) { if (C.v = g.v, C.f = null, C.si = null, C.p = null, g.p) { const x = Qr(g); x && (C.v = x); } s.setValue(S, R, C); } }), s; } function Mc(e, t, n, o, r, i, s) { const c = new Et(), a = /* @__PURE__ */ new Map(); return o.forValue((d, u, h) => { const f = n.rows[d], g = n.cols[u], l = {}; if (ct(h.si)) { if (s.unitId !== e || s.subUnitId !== t) { const m = i.getFormulaStringByCell( s.range.rows[d % s.range.rows.length], s.range.cols[u % s.range.cols.length], s.subUnitId, s.unitId ), S = n.cols[u] - s.range.cols[u % s.range.cols.length], R = n.rows[d] - s.range.rows[d % s.range.rows.length], C = r.moveFormulaRefOffset(m || "", S, R); l.si = null, l.f = C; } else l.si = h.si, l.f = null; l.v = null, l.p = null, c.setValue(f, g, l); } else if (Ge(h.f)) { const m = `${d % s.range.rows.length}_${u % s.range.cols.length}`; let S = a.get(m); if (S) l.si = S, l.f = null; else { S = vt.generateRandomId(6), a.set(m, S); const R = n.cols[u] - s.range.cols[u % s.range.cols.length], C = n.rows[d] - s.range.rows[d % s.range.rows.length], _ = r.moveFormulaRefOffset(h.f || "", R, C); l.si = S, l.f = _; } l.v = null, l.p = null, c.setValue(f, g, l); } else { if (l.v = h.v, l.f = null, l.si = null, l.p = null, h.p) { const m = Qr(h); m && (l.v = m); } c.setValue(f, g, l); } }), c; } function Pc(e, t, n, o, r, i, s) { const c = new Et(), a = /* @__PURE__ */ new Map(), d = i.getSheetFormulaData(e, t); return o.forValue((u, h, f) => { var S; const g = n.rows[u], l = n.cols[h], m = {}; if (ct(f.si)) { if (s.unitId !== e || s.subUnitId !== t) { const R = i.getFormulaStringByCell( s.range.rows[u % s.range.rows.length], s.range.cols[h % s.range.cols.length], s.subUnitId, s.unitId ), C = n.cols[h] - s.range.cols[h % s.range.cols.length], _ = n.rows[u] - s.range.rows[u % s.range.rows.length], E = r.moveFormulaRefOffset(R || "", C, _); m.si = null, m.f = E; } else m.si = f.si, m.f = null; m.v = null, m.p = null, c.setValue(g, l, m); } else if (Ge(f.f)) { const R = `${u % s.range.rows.length}_${h % s.range.cols.length}`; let C = a.get(R); if (C) m.si = C, m.f = null; else { C = vt.generateRandomId(6), a.set(R, C); const _ = n.cols[h] - s.range.cols[h % s.range.cols.length], E = n.rows[u] - s.range.rows[u % s.range.rows.length], x = r.moveFormulaRefOffset(f.f || "", _, E); m.si = C, m.f = x; } m.v = null, m.p = null, c.setValue(g, l, m); } else (S = d == null ? void 0 : d[g]) != null && S[l] && (m.v = f.v, m.f = null, m.si = null, m.p = f.p, c.setValue(g, l, m)); }), c; } function Qr(e) { if (e != null && e.p) { const t = e == null ? void 0 : e.p.body; if (t == null) return; const n = t.dataStream; return n.substring(n.length - 2, n.length) === nr ? n.substring(0, n.length - 2) : n; } } var Ac = Object.defineProperty, Lc = Object.getOwnPropertyDescriptor, wc = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? Lc(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && Ac(t, n, r), r; }, ze = (e, t) => (n, o) => t(n, o, e); let Lt = class extends It { constructor(t, n, o, r, i, s, c, a) { super(); Q(this, "_previousShape"); Q(this, "_skeleton"); this._context = t, this._sheetInterceptorService = n, this._formulaDataModel = o, this._themeService = r, this._renderManagerService = i, this._sheetSkeletonManagerService = s, this._commandService = c, this._logService = a, this._initSkeletonChangeListener(), this._initInterceptorEditorStart(), this._commandExecutedListener(); } _initSkeletonChangeListener() { this.disposeWithMe( this._sheetSkeletonManagerService.currentSkeleton$.subscribe((t) => { var n, o; if (t == null) this._logService.debug("[FormulaEditorShowController]: should not receive currentSkeleton$ as null!"); else { const { skeleton: r } = t, i = (o = (n = this._skeleton) == null ? void 0 : n.worksheet) == null ? void 0 : o.getSheetId(); if (this._changeRuntime(r), i !== r.worksheet.getSheetId()) this._removeArrayFormulaRangeShape(); else { const { unitId: s, sheetId: c } = t; this._updateArrayFormulaRangeShape(s, c); } } }) ); } _changeRuntime(t) { this._skeleton = t; } _initInterceptorEditorStart() { this.disposeWithMe( rr( this._sheetInterceptorService.writeCellInterceptor.intercept( cs, { handler: (t, n, o) => { var l, m, S, R; const { row: r, col: i, unitId: s, subUnitId: c, worksheet: a } = n, d = this._formulaDataModel.getArrayFormulaRange(), u = this._formulaDataModel.getArrayFormulaCellData(); if (this._removeArrayFormulaRangeShape(), t == null) return o(t); let h = null; const f = this._formulaDataModel.getFormulaStringByCell(r, i, c, s); if (f !== null && (h = { f }), t.v != null && t.v !== "" && ((S = (m = (l = u[s]) == null ? void 0 : l[c]) == null ? void 0 : m[r]) == null ? void 0 : S[i]) == null) return h ? { ...t, ...h } : o(t); const g = (R = d == null ? void 0 : d[s]) == null ? void 0 : R[c]; return g != null && (h = this._displayArrayFormulaRangeShape(g, r, i, s, c, a, h)), h ? { ...t, ...h } : o(t); } } ) ) ); } _commandExecutedListener() { this.disposeWithMe(this._commandService.onCommandExecuted((t, n) => { (t.id === qo.id || t.id === Ko.id && n && n.remove) && this._removeArrayFormulaRangeShape(); })), this.disposeWithMe( this._commandService.beforeCommandExecuted((t) => { as.id === t.id && requestIdleCallback(() => { const n = t.params, { unitId: o, subUnitId: r, rowsAutoHeightInfo: i } = n; this._refreshArrayFormulaRangeShapeByRow(o, r, i); }); }) ); } _displayArrayFormulaRangeShape(t, n, o, r, i, s, c) { const a = this._formulaDataModel.getSheetFormulaData(r, i); return new Et(t).forValue((d, u, h) => { var S; if (h == null) return !0; const { startRow: f, startColumn: g, endRow: l, endColumn: m } = h; if (d === n && u === o) return this._createArrayFormulaRangeShape(h, r), !1; if (n >= f && n <= l && o >= g && o <= m) { const R = s.getCell(f, g); if ((R == null ? void 0 : R.v) === Se.SPILL) return; const C = (S = a == null ? void 0 : a[d]) == null ? void 0 : S[u]; return C == null || C.f == null ? !0 : (c == null && (c = { f: C.f, isInArrayFormulaRange: !0 }), this._createArrayFormulaRangeShape(h, r), !1); } }), c; } _createArrayFormulaRangeShape(t, n) { const o = this._renderManagerService.getRenderById(n), r = this._sheetSkeletonManagerService.getCurrentSkeleton(); if (!o || !r) return; const { scene: i } = o; if (!i) return; const s = this._themeService.getCurrentTheme(), c = { range: t, primary: null, style: { strokeWidth: 1, stroke: s.hyacinth700, fill: new or(s.colorWhite).setAlpha(0).toString(), widgets: {} } }, a = on(c, r), { rowHeaderWidth: d, columnHeaderHeight: u } = r, h = new ur(i, $o.FORMULA_EDITOR_SHOW, this._themeService, { highlightHeader: !1, rowHeaderWidth: d, columnHeaderHeight: u }); h.updateRangeBySelectionWithCoord(a), h.setEvent(!1), this._previousShape = h; } _removeArrayFormulaRangeShape() { this._previousShape != null && (this._previousShape.dispose(), this._previousShape = null); } _refreshArrayFormulaRangeShape(t, n) { if (this._previousShape) { const { startRow: o, endRow: r, startColumn: i, endColumn: s } = this._previousShape.getRange(), c = { startRow: o, endRow: r, startColumn: i, endColumn: s }; this._removeArrayFormulaRangeShape(), this._createArrayFormulaRangeShape(c, t); } } _checkCurrentSheet(t, n) { const o = this._sheetSkeletonManagerService.getCurrentSkeleton(); if (!o) return !1; const r = o.worksheet; return r ? r.unitId === t && r.getSheetId() === n : !1; } _updateArrayFormulaRangeShape(t, n) { this._checkCurrentSheet(t, n) && this._previousShape && this._refreshArrayFormulaRangeShape(t); } _refreshArrayFormulaRangeShapeByRow(t, n, o) { if (!this._checkCurrentSheet(t, n) || !this._previousShape) return; const { startRow: r, endRow: i, startColumn: s, endColumn: c } = this._previousShape.getRange(); for (let a = 0; a < o.length; a++) { const { row: d } = o[a]; if (r >= d) { const u = { startRow: r, endRow: i, startColumn: s, endColumn: c }; this._refreshArrayFormulaRangeShape(t, u); break; } } } }; Lt = wc([ ze(1, ee(_r)), ze(2, ee(jt)), ze(3, ee(Rt)), ze(4, ve), ze(5, ee(kt)), ze(6, ye), ze(7, ho) ], Lt); var $c = Object.defineProperty, Dc = Object.getOwnPropertyDescriptor, kc = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? Dc(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && $c(t, n, r), r; }, Qn = (e, t) => (n, o) => t(n, o, e); const jc = { tl: { size: 6, color: "#409f11" } }; let wt = class extends mo { constructor(e, t) { super(), this._sheetInterceptorService = e, this._formulaDataModel = t, this.disposeWithMe(this._sheetInterceptorService.intercept( ls.CELL_CONTENT, { effect: go.Style, handler: (n, o, r) => { var c, a, d, u; const i = (u = (d = (a = (c = this._formulaDataModel.getArrayFormulaCellData()) == null ? void 0 : c[o.unitId]) == null ? void 0 : a[o.subUnitId]) == null ? void 0 : d[o.row]) == null ? void 0 : u[o.col]; return Jr(n, !!i) ? r({ ...n, markers: { ...n == null ? void 0 : n.markers, ...jc } }) : r(n); }, priority: 10 } )); } }; wt = kc([ Qn(0, ee(_r)), Qn(1, ee(jt)) ], wt); function Hc() { const e = y(fs), t = y(ye), n = it(e.progress$), o = at(() => { t.executeCommand(Yo.id); }, [t]), r = at(() => { e.clearProgress(); }, [e]); return /* @__PURE__ */ p.jsx(ps, { progress: n, onTerminate: o, onClearProgress: r }); } const Wc = (e, t = 100) => { D(() => { let n = null; const o = () => { n === null && (n = window.setTimeout(() => { e(), n = null; }, t)); }; return window.addEventListener("scroll", o), window.addEventListener("resize", o), () => { n !== null && clearTimeout(n), window.removeEventListener("scroll", o), window.removeEventListener("resize", o); }; }, [e, t]); }, Uc = "univer-formula-help-function", Vc = "univer-formula-help-function-title", Bc = "univer-formula-help-function-title-icons", qc = "univer-formula-help-function-title-icon", Kc = "univer-formula-help-function-content", Yc = "univer-formula-help-function-content-inner", zc = "univer-formula-help-function-content-params", Zc = "univer-formula-help-function-content-params-title", Gc = "univer-formula-help-function-content-params-detail", Xc = "univer-formula-help-function-active", Jc = "univer-formula-help-decorator", Qc = "univer-formula-help-param", ea = "univer-formula-help-param-prefix", ta = "univer-formula-help-param-item", na = "univer-formula-help-param-active", se = { formulaHelpFunction: Uc, formulaHelpFunctionTitle: Vc, formulaHelpFunctionTitleIcons: Bc, formulaHelpFunctionTitleIcon: qc, formulaHelpFunctionContent: Kc, formulaHelpFunctionContentInner: Yc, formulaHelpFunctionContentParams: zc, formulaHelpFunctionContentParamsTitle: Zc, formulaHelpFunctionContentParamsDetail: Gc, formulaHelpFunctionActive: Xc, formulaHelpDecorator: Jc, formulaHelpParam: Qc, formulaHelpParamPrefix: ea, formulaHelpParamItem: ta, formulaHelpParamActive: na }; function ra() { const [e, t] = H(!1), [n, o] = H(!0), [r, i] = H(!0), [s, c] = H(0), [a, d] = H([0, 0]), [u, h] = H({ left: 0, top: 0 }), [f, g] = H(null), l = y(Nt), m = y(Xe), S = m.t("formula.prompt.required"), R = m.t("formula.prompt.optional"), C = y(pe), _ = y(qe), E = y(Ut), x = po(); Wc(M), D(() => { const N = l.help$.subscribe((w) => { const { visible: I, paramIndex: v, functionInfo: F } = w; if (!I) { t(I); return; } const O = T(); if (O == null) return; const { left: L, top: B, height: K } = O; F.description === "" && F.functionParameter.length === 0 || (d([L, B + K]), c(v), g(F), h({ left: L, top: B }), t(I)); }), b = E.scrollEvent$.pipe(mn(100)).subscribe(M); return () => { N == null || N.unsubscribe(), b.unsubscribe(); }; }, []); function M() { if (!r) return; const N = T(); if (N == null) return; const { left: b, top: w, height: I } = N; d([b, w + I]); } function T() { const N = C.getCurrentUniverDocInstance(); if (!N) return; const b = N.getUnitId(); if (!_.isEditor(b)) return; const w = _.getEditor(b); return w == null ? void 0 : w.getBoundingClientRect(); } function P(N) { c(N); } function A() { i(!r), x.get(Ss).focus(); } return /* @__PURE__ */ p.jsx(p.Fragment, { children: r ? /* @__PURE__ */ p.jsx(yr, { visible: e, offset: a, children: f ? /* @__PURE__ */ p.jsxs("div", { className: se.formulaHelpFunction, children: [ /* @__PURE__ */ p.jsxs("div", { className: se.formulaHelpFunctionTitle, children: [ /* @__PURE__ */ p.jsx( oa, { prefix: f.functionName, value: f.functionParameter, active: s, onClick: P } ), /* @__PURE__ */ p.jsxs("div", { className: se.formulaHelpFunctionTitleIcons, children: [ /* @__PURE__ */ p.jsx( "div", { className: se.formulaHelpFunctionTitleIcon, style: { transform: n ? "rotateZ(-90deg)" : "rotateZ(90deg)" }, onClick: () => o(!n), children: /* @__PURE__ */ p.jsx(_n, {}) } ), /* @__PURE__ */ p.jsx( "div", { className: se.formulaHelpFunctionTitleIcon, onClick: A, children: /* @__PURE__ */ p.jsx(Bt, {}) } ) ] }) ] }), /* @__PURE__ */ p.jsx( "div", { className: se.formulaHelpFunctionContent, style: { height: n ? "unset" : 0, padding: n ? "revert-layer" : 0 }, children: /* @__PURE__ */ p.jsxs("div", { className: se.formulaHelpFunctionContentInner, children: [ /* @__PURE__ */ p.jsx( tn, { title: m.t("formula.prompt.helpExample"), value: `${f.functionName}(${f.functionParameter.map((N) => N.example).join(",")})` } ), /* @__PURE__ */ p.jsx( tn, { title: m.t("formula.prompt.helpAbstract"), value: f.description } ), f && f.functionParameter && f.functionParameter.map((N, b) => /* @__PURE__ */ p.jsx( tn, { className: s === b ? se.formulaHelpFunctionActive : "", title: N.name, value: `${N.require ? S : R} ${N.detail}` }, b )) ] }) } ) ] }) : /* @__PURE__ */ p.jsx(p.Fragment, {}) }) : e ? /* @__PURE__ */ p.jsx( "div", { className: se.formulaHelpDecorator, onClick: () => i(!r), style: { left: u.left - 24, top: u.top }, children: /* @__PURE__ */ p.jsx($r, {}) } ) : /* @__PURE__ */ p.jsx(p.Fragment, {}) }); } const tn = (e) => /* @__PURE__ */ p.jsxs("div", { className: se.formulaHelpFunctionContentParams, children: [ /* @__PURE__ */ p.jsx( "div", { className: ` ${se.formulaHelpFunctionContentParamsTitle} ${e.className} `, children: e.title } ), /* @__PURE__ */ p.jsx("div", { className: se.formulaHelpFunctionContentParamsDetail, children: e.value }) ] }), oa = (e) => { const { prefix: t, value: n, active: o, onClick: r } = e; return /* @__PURE__ */ p.jsxs("div", { className: se.formulaHelpParam, children: [ /* @__PURE__ */ p.jsxs("span", { className: se.formulaHelpParamPrefix, children: [ t, "(" ] }), n && n.map((i, s) => ( // TODO@Dushusir: more params needs to be active /* @__PURE__ */ p.jsxs("span", { className: se.formulaHelpParamItem, children: [ /* @__PURE__ */ p.jsx( "span", { className: o === s ? se.formulaHelpFunctionActive : se.formulaHelpParamActive, onClick: () => r(s), children: xn(i) } ), s === n.length - 1 ? "" : "," ] }, s) )), ")" ] }); }, sa = "univer-formula-search-function", ia = "univer-formula-search-function-item", ca = "univer-formula-search-function-item-name", aa = "univer-formula-search-function-item-name-light", la = "univer-formula-search-function-item-desc", ua = "univer-formula-search-function-item-active", Ue = { formulaSearchFunction: sa, formulaSearchFunctionItem: ia, formulaSearchFunctionItemName: ca, formulaSearchFunctionItemNameLight: aa, formulaSearchFunctionItemDesc: la, formulaSearchFunctionItemActive: ua }; function fa() { const [e, t] = H(!1), [n, o] = H(0), [r, i] = H([0, 0]), [s, c] = H([]), [a, d] = H(""), u = q(null), h = y(Nt), f = y(pe), g = y(qe); D(() => { let C = [], _ = 0; const E = h.search$.subscribe((T) => { const { visible: P, searchText: A, searchList: N } = T; if (!P) { t(P); return; } const b = l(); if (b == null) return; const { left: w, top: I, height: v } = b; d(A), c(N), C = N, i([w, I + v]), t(P), o(0), _ = 0; }), x = h.navigate$.subscribe((T) => { const { direction: P } = T; if (P === he.UP) { let A = _ - 1; A = A < 0 ? C.length - 1 : A, o(A), _ = A; } else if (P === he.DOWN) { let A = _ + 1; A = A >= C.length ? 0 : A, o(A), _ = A; } R(_); }), M = h.accept$.subscribe((T) => { const P = C[_].name; h.acceptFormulaName(P); }); return () => { E == null || E.unsubscribe(), x == null || x.unsubscribe(), M == null || M.unsubscribe(); }; }, []); function l() { const _ = f.getCurrentUniverDocInstance().getUnitId(); if (!g.isEditor(_)) return; const E = g.getEditor(_); return E == null ? void 0 : E.getBoundingClientRect(); } function m(C) { o(C); } function S() { o(-1); } function R(C) { var w; const _ = (w = u.current) == null ? void 0 : w.querySelectorAll(`.${Ue.formulaSearchFunctionItem}`)[C]; if (!_) return; const E = _.parentNode; if (!E) return; const M = E.getBoundingClientRect().top, T = E.offsetHeight, P = _.getBoundingClientRect(), A = P.top, N = P.height; if (A >= 0 && A > M && A - M + N <= T) return; const b = _.offsetTop - (T - N) / 2; E.scrollTo({ top: b, behavior: "smooth" }); } return s.length > 0 && /* @__PURE__ */ p.jsx(yr, { visible: e, offset: r, children: /* @__PURE__ */ p.jsx("ul", { className: Ue.formulaSearchFunction, ref: u, children: s.map((C, _) => /* @__PURE__ */ p.jsxs( "li", { className: n === _ ? ` ${Ue.formulaSearchFunctionItem} ${Ue.formulaSearchFunctionItemActive} ` : Ue.formulaSearchFunctionItem, onMouseEnter: () => m(_), onMouseLeave: S, onClick: () => h.acceptFormulaName(C.name), children: [ /* @__PURE__ */ p.jsxs("span", { className: Ue.formulaSearchFunctionItemName, children: [ /* @__PURE__ */ p.jsx("span", { className: Ue.formulaSearchFunctionItemNameLight, children: C.name.substring(0, a.length) }), /* @__PURE__ */ p.jsx("span", { children: C.name.slice(a.length) }) ] }), /* @__PURE__ */ p.jsx("span", { className: Ue.formulaSearchFunctionItemDesc, children: C.desc }) ] }, _ )) }) }); } function ha() { return /* @__PURE__ */ p.jsxs(p.Fragment, { children: [ /* @__PURE__ */ p.jsx(fa, {}), /* @__PURE__ */ p.jsx(ra, {}) ] }); } const da = "univer-formula-more-functions", ma = "univer-formula-more-functions-operation", er = { formulaMoreFunctions: da, formulaMoreFunctionsOperation: ma }; function eo(e) { const { prefix: t, value: n } = e; return /* @__PURE__ */ p.jsxs("div", { children: [ /* @__PURE__ */ p.jsxs("span", { children: [ t, "(" ] }), n && n.map((o, r) => /* @__PURE__ */ p.jsxs("span", { children: [ /* @__PURE__ */ p.jsx("span", { children: xn(o) }), r === n.length - 1 ? "" : "," ] }, r)), ")" ] }); } const ga = "univer-formula-function-params", pa = "univer-formula-function-params-title", Sa = "univer-formula-function-params-detail", nn = { formulaFunctionParams: ga, formulaFunctionParamsTitle: pa, formulaFunctionParamsDetail: Sa }; function St(e) { const { className: t, value: n, title: o } = e; return /* @__PURE__ */ p.jsxs("div", { className: nn.formulaFunctionParams, children: [ /* @__PURE__ */ p.jsx( "div", { className: ` ${nn.formulaFunctionParamsTitle} ${t} `, children: o } ), /* @__PURE__ */ p.jsx("div", { className: nn.formulaFunctionParamsDetail, children: n }) ] }); } const va = "univer-formula-input-params-list", Ca = "univer-formula-input-params-list-item-name", _a = "univer-formula-input-params-list-item-selector", pt = { formulaInputParamsList: va, formulaInputParamsListItemName: Ca, formulaInputParamsListItemSelector: _a }; function Ra(e) { const { functionInfo: t, onChange: n } = e; if (!t) return null; H([]); const [o, r] = H(t.functionParameter), [i, s] = H(-1); return /* @__PURE__ */ p.jsxs("div", { className: pt.formulaInputParams, children: [ /* @__PURE__ */ p.jsx("div", { className: pt.formulaInputParamsList, children: o.map((c, a) => /* @__PURE__ */ p.jsxs("div", { children: [ /* @__PURE__ */ p.jsx("div", { className: pt.formulaInputParamsListItemName, children: c.name }), /* @__PURE__ */ p.jsx("div", { className: pt.formulaInputParamsListItemSelector }) ] }, a)) }), /* @__PURE__ */ p.jsx("div", { className: pt.formulaInputParamsInfo, children: /* @__PURE__ */ p.jsx( St, { title: i === -1 ? /* @__PURE__ */ p.jsx(eo, { prefix: t.functionName, value: o }) : o[i].name, value: i === -1 ? t.description : o[i].detail } ) }) ] }); } const Ia = "univer-formula-select-function-select", Ea = "univer-formula-select-function-result", ba = "univer-formula-select-function-result-item", xa = "univer-formula-select-function-result-item-name-light", Na = "univer-formula-select-function-result-item-selected", Fa = "univer-formula-select-function-result-item-active", ya = "univer-formula-select-function-content", Le = { formulaSelectFunctionSelect: Ia, formulaSelectFunctionResult: Ea, formulaSelectFunctionResultItem: ba, formulaSelectFunctionResultItemNameLight: xa, formulaSelectFunctionResultItemSelected: Na, formulaSelectFunctionResultItemActive: Fa, formulaSelectFunctionContent: ya }; function Ta(e) { const { onChange: t } = e, n = "-1", [o, r] = H(""), [i, s] = H([]), [c, a] = H(0), [d, u] = H(n), [h, f] = H(0), [g, l] = H(null), m = y(xt), S = y(Xe), R = y(Ut), C = it(R.sidebarOptions$), _ = xi(zo, S); _.unshift({ label: S.t("formula.moreFunctions.allFunctions"), value: n }); const E = S.t("formula.prompt.required"), x = S.t("formula.prompt.optional"); D(() => { P(n); }, []), D(() => { T(0); }, [i]), D(() => { C != null && C.visible && (r(""), s([]), a(0), u(n), f(0), l(null), P(n)); }, [C]); const M = (I) => { if (o.trim() === "") return I; const v = new RegExp(`(${o.toLocaleUpperCase()})`); return I.split(v).filter(Boolean).map((O, L) => O.match(v) ? /* @__PURE__ */ p.jsx("span", { className: Le.formulaSelectFunctionResultItemNameLight, children: O }, L) : O); }, T = (I) => { if (i.length === 0) { l(null); return; } f(I); const v = m.getFunctionInfo(i[I].name); if (!v) { l(null); return; } l(v), t(v); }; function P(I) { u(I); const v = m.getSearchListByType(+I); s(v); } function A(I) { r(I); const v = m.getSearchListByName(I); s(v); } function N(I) { if (I.stopPropagation(), I.key === "ArrowDown") { const v = c + 1; a(v === i.length ? 0 : v); } else if (I.key === "ArrowUp") { const v = c - 1; a(v === -1 ? i.length - 1 : v); } else I.key === "Enter" && T(c); } const b = (I) => { a(I); }, w = () => { a(-1); }; return /* @__PURE__ */ p.jsxs("div", { children: [ /* @__PURE__ */ p.jsxs("div", { className: Le.formulaSelectFunctionSelect, children: [ /* @__PURE__ */ p.jsx(Ns, { value: d, options: _, onChange: P }), /* @__PURE__ */ p.jsx( Fr, { placeholder: S.t("formula.moreFunctions.searchFunctionPlaceholder"), onKeyDown: N, value: o, onChange: A, size: "large", allowClear: !0 } ) ] }), /* @__PURE__ */ p.jsx("ul", { className: Le.formulaSelectFunctionResult, onKeyDown: N, tabIndex: -1, children: i.map(({ name: I }, v) => /* @__PURE__ */ p.jsxs( "li", { className: c === v ? ` ${Le.formulaSelectFunctionResultItem} ${Le.formulaSelectFunctionResultItemActive} ` : Le.formulaSelectFunctionResultItem, onMouseEnter: () => b(v), onMouseLeave: w, onClick: () => T(v), children: [ h === v && /* @__PURE__ */ p.jsx(Lr, { className: Le.formulaSelectFunctionResultItemSelected }), /* @__PURE__ */ p.jsx("span", { className: Le.formulaSelectFunctionResultItemName, children: M(I) }) ] }, v )) }), g && /* @__PURE__ */ p.jsxs("div", { className: Le.formulaSelectFunctionContent, children: [ /* @__PURE__ */ p.jsx(St, { title: g.functionName, value: g.description }), /* @__PURE__ */ p.jsx( St, { title: S.t("formula.moreFunctions.syntax"), value: /* @__PURE__ */ p.jsx(eo, { prefix: g.functionName, value: g.functionParameter }) } ), /* @__PURE__ */ p.jsx( St, { title: S.t("formula.prompt.helpExample"), value: `${g.functionName}(${g.functionParameter.map((I) => I.example).join(",")})` } ), g.functionParameter && g.functionParameter.map((I, v) => /* @__PURE__ */ p.jsx( St, { title: I.name, value: `${I.require ? E : x} ${I.detail}` }, v )) ] }) ] }); } function Oa() { const e = Do(), [t, n] = H(!0), [o, r] = H(!1), [i, s] = H(null), c = y(ar), a = y(Xe), d = y(qe), u = y(pe); function h() { n(!t), r(!o); } function f() { const g = vr(u); if (!g) return; c.changeVisible({ visible: !0, unitId: g.unitId, eventType: De.Dblclick }); const l = d.getEditor(dn), m = d.getEditor(tr), S = `=${i == null ? void 0 : i.functionName}(`; l == null || l.replaceText(S), m == null || m.replaceText(S, !1); } return /* @__PURE__ */ p.jsxs("div", { className: er.formulaMoreFunctions, children: [ t && /* @__PURE__ */ p.jsx(Ta, { onChange: s }), o && /* @__PURE__ */ p.jsx(Ra, { functionInfo: i, onChange: () => { } }), /* @__PURE__ */ p.jsxs("div", { className: er.formulaMoreFunctionsOperation, children: [ o && /* @__PURE__ */ p.jsx(ot, { type: "primary", size: "small", onClick: h, children: a.t("formula.moreFunctions.next") }), o && /* @__PURE__ */ p.jsx(ot, { size: "small", onClick: h, children: a.t("formula.moreFunctions.prev") }), t && !!e && /* @__PURE__ */ p.jsx(ot, { type: "primary", size: "small", onClick: f, children: a.t("formula.moreFunctions.confirm") }) ] }) ] }); } function Ma(e) { return { id: vn.id, icon: "FunctionSingle", tooltip: "formula.insert.tooltip", type: pn.SELECTOR, selections: [ { label: "SUM", value: "SUM", icon: "SumSingle" }, { label: "AVERAGE", value: "AVERAGE", icon: "AvgSingle" }, { label: "COUNT", value: "COUNT", icon: "CntSingle" }, { label: "MAX", value: "MAX", icon: "MaxSingle" }, { label: "MIN", value: "MIN", icon: "MinSingle" } ], hidden$: vs(e, Me.UNIVER_SHEET), disabled$: fr(e, { workbookTypes: [Rr], worksheetTypes: [Ir, Er], rangeTypes: [br] }) }; } function Pa(e) { return { id: Cn.id, title: "formula.insert.more", type: pn.BUTTON }; } function Aa(e) { return e.get(pe).getCurrentTypeOfUnit$(Me.UNIVER_SHEET).pipe( Jo((o) => o ? e.get(Bn) ? new Qo((i) => i.next(!e.get(Bn).supportClipboard)) : Dn(!0) : Dn(!0)) ); } function La(e) { return { id: Sn.id, type: pn.BUTTON, title: "formula.operation.pasteFormula", disabled$: Aa(e).pipe( Xo(fr(e, { workbookTypes: [Rr], rangeTypes: [br], worksheetTypes: [Er, Ir] })), Ht(([t, n]) => t || n) ) }; } const wa = { [Cs.FORMULAS_INSERT]: { [vn.id]: { order: 1, menuItemFactory: Ma, [Cn.id]: { order: 1, menuItemFactory: Pa } } }, [ko]: { [Sn.id]: { order: 4, menuItemFactory: La } } }, $a = "meta_key_ctrl_And_Shift", Kt = [ $.ARROW_DOWN, $.ARROW_UP, $.ARROW_LEFT, $.ARROW_RIGHT ], Da = [...Kt, $.ENTER, $.TAB, $.ESC]; function ka() { const e = []; for (const t of Da) e.push({ id: ut.id, binding: t, preconditions: (n) => bt(n), staticParameters: { eventType: De.Keyboard, keycode: t } }); return e; } function ja() { const e = []; for (const t of Kt) e.push({ id: ut.id, binding: t | Y.SHIFT, preconditions: (n) => bt(n), staticParameters: { eventType: De.Keyboard, keycode: t, metaKey: Y.SHIFT } }); return e; } function Ha() { const e = []; for (const t of Kt) e.push({ id: ut.id, binding: t | Y.CTRL_COMMAND, preconditions: (n) => bt(n), staticParameters: { eventType: De.Keyboard, keycode: t, metaKey: Y.CTRL_COMMAND } }); return e; } function Wa() { const e = []; for (const t of Kt) e.push({ id: ut.id, binding: t | Y.SHIFT | Y.CTRL_COMMAND, preconditions: (n) => bt(n), staticParameters: { eventType: De.Keyboard, keycode: t, metaKey: $a } }); return e; } const Ua = { id: Pr.id, binding: $.F4, preconditions: (e) => bt(e) }; function Va() { const e = []; for (const t of [$.ENTER, $.TAB, $.ARROW_DOWN, $.ARROW_UP]) e.push({ id: ut.id, binding: t, preconditions: (n) => dc(n), staticParameters: { eventType: De.Keyboard, keycode: t, isSingleEditor: !0 } }); return e; } var Ba = Object.defineProperty, qa = Object.getOwnPropertyDescriptor, Ka = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? qa(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && Ba(t, n, r), r; }, Ze = (e, t) => (n, o) => t(n, o, e); let $t = class extends It { constructor(e, t, n, o, r, i, s) { super(), this._injector = e, this._menuManagerService = t, this._commandService = n, this._shortcutService = o, this._uiPartsService = r, this._renderManagerService = i, this._componentManager = s, this._initialize(); } _initialize() { this._registerCommands(), this._registerMenus(), this._registerShortcuts(), this._registerComponents(), this._registerRenderModules(); } _registerMenus() { this._menuManagerService.mergeMenu(wa); } _registerCommands() { [ Sn, vn, Cn, Ws, $s, ut, Pr ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))); } _registerShortcuts() { [ ...ka(), ...ja(), ...Ha(), ...Wa(), ...Va(), Ua ].forEach((e) => { this.disposeWithMe(this._shortcutService.registerShortcut(e)); }); } _registerComponents() { this.disposeWithMe(this._uiPartsService.registerComponent(_s.CONTENT, () => Tn(ha, this._injector))), this.disposeWithMe(this._uiPartsService.registerComponent(jo.FORMULA_AUX, () => Tn(Hc, this._injector))), this._componentManager.register(Mr, Oa); } _registerRenderModules() { this.disposeWithMe(this._renderManagerService.registerRenderModule(Me.UNIVER_SHEET, [Lt])); } }; $t = Ka([ Ze(0, ee(_t)), Ze(1, Rs), Ze(2, ye), Ze(3, Vt), Ze(4, Is), Ze(5, ve), Ze(6, ee(Nr)) ], $t); var to = Object.defineProperty, Ya = Object.getOwnPropertyDescriptor, za = (e, t, n) => t in e ? to(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Za = (e, t, n, o) => { for (var r = o > 1 ? void 0 : o ? Ya(t, n) : t, i = e.length - 1, s; i >= 0; i--) (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r); return o && r && to(t, n, r), r; }, rn = (e, t) => (n, o) => t(n, o, e), no = (e, t, n) => za(e, typeof t != "symbol" ? t + "" : t, n); let Dt = class extends So { constructor(e = Xn, t, n, o) { super(), this._config = e, this._injector = t, this._renderManagerService = n, this._configService = o; const { menu: r, ...i } = vo( Xn, this._config ); r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(hc, i); } onStarting() { const e = this._injector; [ [Nt, { useClass: an }], [$t], [Pt], [At], [Lt], [wt] ].forEach((o) => e.add(o)); const n = this._injector.get(Nr); n.register(Ho, Ei), n.register(Wo, fc); } onRendered() { [ [Fe], [fn] ].forEach((e) => { this.disposeWithMe(this._renderManagerService.registerRenderModule(Me.UNIVER_SHEET, e)); }), Co(this._injector, [ [$t], // FormulaProgressBar relies on TriggerCalculationController, but it is necessary to ensure that the formula calculation is done after rendered. [At], [wt] ]); } onSteady() { this._injector.get(Pt); } }; no(Dt, "pluginName", Or); no(Dt, "type", Me.UNIVER_SHEET); Dt = Za([ _o(Zo, hs), rn(1, ee(_t)), rn(2, ve), rn(3, Ro) ], Dt); export { ws as FORMULA_PROMPT_ACTIVATED, fc as FormulaEditor, $s as HelpFunctionOperation, vn as InsertFunctionOperation, Cn as MoreFunctionsOperation, Ei as RangeSelector, Fe as RefSelectionsRenderService, Pr as ReferenceAbsoluteOperation, Ws as SearchFunctionOperation, ut as SelectEditorFormulaOperation, Sn as SheetOnlyPasteFormulaCommand, Dt as UniverSheetsFormulaUIPlugin };