var fe = Object.defineProperty; var ge = (h, e, t) => e in h ? fe(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t; var g = (h, e, t) => ge(h, typeof e != "symbol" ? e + "" : e, t); import { CommandType as B, IUndoRedoService as _e, ICommandService as H, Rectangle as Se, Inject as C, Injector as T, ThemeService as me, Disposable as J, EDITOR_ACTIVATED as pe, IContextService as Z, IUniverInstanceService as q, UniverInstanceType as ee, fromCallback as P, ColorKit as Ie, rotate as $, groupBy as ve, ObjectMatrix as Ce, Tools as Re, replaceInDocumentBody as we, DependentOn as be, Plugin as ke, merge as Me, IConfigService as xe } from "@univerjs/core"; import { FindReplaceController as ye, IFindReplaceService as Pe, FindModel as Ue, FindBy as b, FindScope as v, FindDirection as w, UniverFindReplacePlugin as Be } from "@univerjs/find-replace"; import { SetRangeValuesCommand as te, SheetsSelectionsService as We, SetWorksheetActiveOperation as Fe, SetSelectionsOperation as He, SetWorksheetActivateCommand as Te, UniverSheetsPlugin as L } from "@univerjs/sheets"; import { Shape as Ee, Rect as Oe, IRenderManagerService as ie, RENDER_RAW_FORMULA_KEY as Ae } from "@univerjs/engine-render"; import { SheetSkeletonManagerService as Ne, getCoordByCell as j, getSheetObject as De, ScrollToCellCommand as $e } from "@univerjs/sheets-ui"; import { filter as k, Subject as V, throttleTime as Le, merge as je, skip as Ve, debounceTime as Ge } from "rxjs"; const Ye = "sheets-find-replace.config", G = {}, ne = { id: "sheet.command.replace", type: B.COMMAND, handler: async (h, e) => { const t = h.get(_e), i = h.get(H), { unitId: n, replacements: r } = e, s = t.__tempBatchingUndoRedo(n), o = await Promise.all(r.map((c) => i.executeCommand(te.id, { unitId: n, subUnitId: c.subUnitId, value: c.value }))); return s.dispose(), Ke(o, r); } }; function Ke(h, e) { let t = 0, i = 0; return h.forEach((n, r) => { const s = e[r].count; n ? t += s : i += s; }), { success: t, failure: i }; } class Qe extends Ee { constructor(t, i) { super(t, i); g(this, "_activated", !1); g(this, "_inHiddenRange", !1); g(this, "_color"); i && this.setShapeProps(i); } setShapeProps(t) { this._activated = !!t.activated, typeof t.inHiddenRange < "u" && (this._inHiddenRange = t.inHiddenRange), typeof t.color < "u" && (this._color = t.color), this.transformByState({ width: t.width, height: t.height }); } _draw(t) { const i = this._activated, n = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`, r = `rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`; Oe.drawWith(t, { width: this.width, height: this.height, fill: n, stroke: i ? r : void 0, strokeWidth: i ? 2 : 0, evented: !1 }); } } function Y(h, e) { return h.startRow === e.startRow && h.startColumn === e.startColumn; } function K(h, e) { return h.startRow < e.startRow || h.startRow === e.startRow && h.startColumn <= e.startColumn; } function Q(h, e) { return h.startColumn < e.startColumn || h.startColumn === e.startColumn && h.startRow <= e.startRow; } function Xe(h, e) { return h.startRow > e.startRow || h.startRow === e.startRow && h.startColumn >= e.startColumn; } function ze(h, e) { return h.startColumn > e.startColumn || h.startColumn === e.startColumn && h.startRow >= e.startRow; } function Je(h, e) { const { range: t } = h, { startRow: i, startColumn: n } = t, r = e.getMergedCell(i, n); return r ? Se.equals(t, r) : t.endRow === t.startRow && t.endColumn === t.startColumn; } var Ze = Object.defineProperty, qe = Object.getOwnPropertyDescriptor, E = (h, e, t, i) => { for (var n = i > 1 ? void 0 : i ? qe(e, t) : e, r = h.length - 1, s; r >= 0; r--) (s = h[r]) && (n = (i ? s(e, t, n) : s(n)) || n); return i && n && Ze(e, t, n), n; }, m = (h, e) => (t, i) => e(t, i, h); let M = class extends J { constructor(e, t, i, n, r) { super(); g(this, "_provider"); this._injector = e, this._findReplaceController = t, this._contextService = i, this._findReplaceService = n, this._commandService = r, this._init(), this._initCommands(); } dispose() { super.dispose(), this._findReplaceController.closePanel(), this._provider.dispose(); } _init() { const e = this._injector.createInstance(F); this._provider = e, this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)), this.disposeWithMe(this._contextService.subscribeContextValue$(pe).pipe(k((t) => !!t)).subscribe(() => this._findReplaceController.closePanel())); } _initCommands() { [ne].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))); } }; M = E([ m(0, C(T)), m(1, C(ye)), m(2, Z), m(3, Pe), m(4, H) ], M); const et = "sheets-find-replace-provider", tt = 1e4; let W = class extends Ue { constructor(e, t, i, n, r, s, o, c) { super(); // We can directly inject the `FindReplaceService` here, and call its methods instead of using the observables. g(this, "_matchesUpdate$", new V()); g(this, "matchesUpdate$", this._matchesUpdate$.asObservable()); g(this, "_activelyChangingMatch$", new V()); g(this, "activelyChangingMatch$", this._activelyChangingMatch$.asObservable()); /** Hold matches by the worksheet they are in. Make it easier to track the next (or previous) match when searching in the whole workbook. */ g(this, "_matchesByWorksheet", /* @__PURE__ */ new Map()); /** Hold all matches in the currently searching scope. */ g(this, "_matches", []); /** Position of the current focused ISheetCellMatch, starting from 1. */ g(this, "_matchesPosition", 0); g(this, "_activeHighlightIndex", -1); g(this, "_highlightShapes", []); g(this, "_currentHighlightShape", null); /** This properties holds the query params during this searching session. */ g(this, "_query", null); g(this, "_workbookSelections"); this._workbook = e, this._sheetSkeletonManagerService = t, this._univerInstanceService = i, this._renderManagerService = n, this._commandService = r, this._contextService = s, this._themeService = o, this._workbookSelections = c.getWorkbookSelections(this.unitId); } get _matchesCount() { return this._matches.length; } get unitId() { return this._workbook.getUnitId(); } get matchesCount() { return this._matchesCount; } get matchesPosition() { return this._matchesPosition; } get currentMatch() { return this._matchesPosition > 0 ? this._matches[this._matchesPosition - 1] : null; } dispose() { super.dispose(), this._disposeHighlights(), this._toggleDisplayRawFormula(!1); } getMatches() { return this._matches; } start(e) { switch (this._query = e, e.findBy === b.FORMULA ? this._toggleDisplayRawFormula(!0) : this._toggleDisplayRawFormula(!1), e.findScope) { case v.UNIT: this.findInWorkbook(e); break; case v.SUBUNIT: default: this.findInActiveWorksheet(e); break; } } _toggleDisplayRawFormula(e) { this._contextService.setContextValue(Ae, e); } /** * Find all matches in the current workbook no matter which worksheet is activated. * @param query the query object * @returns the query complete event */ findInWorkbook(e) { const t = this._workbook.getUnitId(); let i, n = !0; const r = () => { const s = this._workbook.getSheets().filter((o) => !o.isSheetHidden()).map((o) => { const c = this._findInWorksheet(o, e, t), l = o.getSheetId(), { results: a } = c; return a.length ? this._matchesByWorksheet.set(l, c.results) : this._matchesByWorksheet.delete(l), c; }); this._matches = s.map((o) => o.results).flat(), this._updateFindHighlight(), n ? (i = { results: this._matches }, n = !1) : this._matchesUpdate$.next(this._matches); }; return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(() => { this._updateFindHighlight(), this._updateCurrentHighlightShape(this._activeHighlightIndex); })), this.disposeWithMe( P(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(k(([s, o]) => s.id === Fe.id && !(o != null && o.fromFindReplace))).subscribe(() => { const s = this._workbook.getActiveSheet(); if (!s) return; const o = s.getSheetId(); this._matchesByWorksheet.has(o) && this._findNextMatchOnActiveSheetChange(s); }) ), this.disposeWithMe( P(this._commandService.onCommandExecuted.bind(this._commandService)).pipe( k( ([s]) => s.type === B.MUTATION && s.params.unitId === this._workbook.getUnitId() ), Le(600, void 0, { leading: !1, trailing: !0 }) ).subscribe(() => r()) ), r(), i; } /** * This method is used in `findInWorkbook`. When the active sheet changes, this method helps to find the next match * in the new worksheet. */ _findNextMatchOnActiveSheetChange(e) { let t, i, n = 0; const r = this._matchesByWorksheet.get(e.getSheetId()), s = this._workbookSelections.getCurrentSelections(); s != null && s.length ? ([t, n] = this._findNextMatchByRange(r, s[0].range), i = r.findIndex((o) => o === t)) : (t = r[0], i = 0, n = this._matches.findIndex((o) => o === t)), this._matchesPosition = n + 1, this._activelyChangingMatch$.next(t), this._activeHighlightIndex = i, this._updateFindHighlight(), this._updateCurrentHighlightShape(i); } /** * Find all matches (only) in the currently activated worksheet. * @param query the query object * @returns the query complete event */ findInActiveWorksheet(e) { const t = this._workbook.getUnitId(), i = () => { var d; const c = this._workbook.getActiveSheet(); if (!c) return !1; const l = this._workbookSelections.getCurrentSelections(); return (d = l == null ? void 0 : l.some((u) => !Je(u, c))) != null ? d : !1; }; let n, r = !0, s = !1; const o = () => { const c = this._workbook.getActiveSheet(); if (!c) return { results: [] }; const l = this.currentMatch; s = i(); const a = this._workbookSelections.getCurrentSelections(), d = s ? this._findInSelections(c, a, e, t) : this._findInWorksheet(c, e, t); return this._matches = d.results, this._matchesPosition = this._tryRestoreLastMatchesPosition(l, this._matches), r ? (n = d, r = !1) : this._matchesUpdate$.next(this._matches), this._updateFindHighlight(), d; }; return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(() => this._updateFindHighlight())), this.disposeWithMe( je( P(this._commandService.onCommandExecuted.bind(this._commandService)).pipe( k(([c]) => { if (c.type === B.MUTATION && c.params.unitId === this._workbook.getUnitId()) return !0; if (c.id === He.id && c.params.unitId === t) { const l = i(); return l === !1 && s === !1 ? !1 : (s = l, !0); } return !1; }) ), // activeSheet$ is a BehaviorSubject, so we need to skip the first this._workbook.activeSheet$.pipe(Ve(1)) ).pipe(Ge(200)).subscribe(() => o()) ), o(), n; } _findInRange(e, t, i, n, r) { const s = [], o = e.getSheetId(), c = (t.findDirection === w.COLUMN ? e.iterateByColumn : e.iterateByRow).bind(e)(i); for (const l of c) { const { row: a, col: d, colSpan: u, rowSpan: _, value: S } = l; if (r != null && r(a, d) || !S || e.getRowFiltered(a)) continue; const { hit: p, replaceable: R, isFormula: I } = it(e, a, d, t, S); if (p) { const y = { provider: et, unitId: n, replaceable: R, isFormula: I, range: { subUnitId: o, range: { startRow: a, startColumn: d, endColumn: d + (u != null ? u : 1) - 1, endRow: a + (_ != null ? _ : 1) - 1 } } }; s.push(y); } } return { results: s }; } _findInSelections(e, t, i, n) { const { findDirection: r } = i, s = r === w.ROW ? K : Q, o = /* @__PURE__ */ new Set(); return { results: t.map((l) => this._findInRange( e, i, l.range, n, (a, d) => { const u = `${a}-${d}`; return o.has(u) ? !0 : (o.add(u), !1); } ).results).flat().sort((l, a) => s(l.range.range, a.range.range) ? -1 : 1) }; } /** Find matches in a given worksheet. */ _findInWorksheet(e, t, i) { const n = e.getRowCount(), r = e.getColumnCount(), s = { startRow: 0, startColumn: 0, endRow: n - 1, endColumn: r - 1 }; return this._findInRange(e, t, s, i); } _disposeHighlights() { var e; this._highlightShapes.forEach((t) => { var i; (i = t.getScene()) == null || i.makeDirty(), t.dispose(); }), this._highlightShapes = [], (e = this._currentHighlightShape) == null || e.dispose(), this._currentHighlightShape = null; } _updateFindHighlight() { var d; this._disposeHighlights(); const e = (d = this._sheetSkeletonManagerService.getCurrent()) == null ? void 0 : d.skeleton; if (!e) return; const t = this._workbook.getUnitId(), i = this._renderManagerService.getRenderById(t); if (i == null) return; const { scene: n } = i, r = this._matches, s = this._themeService.getCurrentTheme().gold400, o = new Ie(s).toRgb(), c = this._workbook.getActiveSheet(); if (!c) return; const l = c.getSheetId(), a = r.filter((u) => u.range.subUnitId === l).map((u, _) => { const { startColumn: S, startRow: p, endColumn: R, endRow: I } = u.range.range, y = j(p, S, n, e), oe = j(I, R, n, e), { startX: O, startY: A } = y, { endX: he, endY: ce } = oe, N = !c.getRowRawVisible(p), D = !c.getColVisible(S), ae = N || D, le = D ? 2 : he - O, de = N ? 2 : ce - A, ue = { left: O, top: A, color: o, width: le, height: de, evented: !1, inHiddenRange: ae, zIndex: tt }; return new Qe(`find-highlight-${_}`, ue); }); n.addObjects(a), this._highlightShapes = a, n.makeDirty(); } _updateCurrentHighlightShape(e) { var t; if ((t = this._currentHighlightShape) == null || t.setShapeProps({ activated: !1 }), this._currentHighlightShape = null, e !== void 0) { const i = this._highlightShapes[e]; if (!i) return; this._currentHighlightShape = i, i.setShapeProps({ activated: !0 }); } } _getSheetObject() { return De(this._univerInstanceService, this._renderManagerService); } _focusMatch(e) { var i; const t = e.range.subUnitId; t !== ((i = this._workbook.getActiveSheet()) == null ? void 0 : i.getSheetId()) && this._commandService.executeCommand( Te.id, { unitId: this._workbook.getUnitId(), subUnitId: t }, { fromFindReplace: !0 } ), this._commandService.executeCommand( $e.id, { range: e.range.range }, { fromFindReplace: !0 } ); } _tryRestoreLastMatchesPosition(e, t) { if (!e) return 0; const { subUnitId: i } = e.range, { startColumn: n, startRow: r } = e.range.range, s = t.findIndex((o) => { if (i !== o.range.subUnitId) return !1; const { startColumn: c, startRow: l } = o.range.range; return c === n && l === r; }); return s > -1 ? s + 1 : 0; } moveToNextMatch(e) { var o, c, l, a, d; if (!this._matches.length) return null; const t = (o = e == null ? void 0 : e.loop) != null ? o : !1, i = (c = e == null ? void 0 : e.stayIfOnMatch) != null ? c : !1, n = (l = e == null ? void 0 : e.noFocus) != null ? l : !1, r = (a = e == null ? void 0 : e.ignoreSelection) != null ? a : !1, s = this._findNextMatch(t, i, r); if (s) { const [u, _] = s; return this._matchesPosition = _ + 1, this._query.findScope === v.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(u.range.subUnitId).findIndex((S) => S === u) : this._activeHighlightIndex = _, n || this._focusMatch(u), ((d = this._workbook.getActiveSheet()) == null ? void 0 : d.getSheetId()) === u.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), u; } return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null; } moveToPreviousMatch(e) { var o, c, l, a, d; if (!this._matches.length) return null; const t = (o = e == null ? void 0 : e.loop) != null ? o : !1, i = (c = e == null ? void 0 : e.stayIfOnMatch) != null ? c : !1, n = (l = e == null ? void 0 : e.noFocus) != null ? l : !1, r = (a = e == null ? void 0 : e.ignoreSelection) != null ? a : !1, s = this._findPreviousMatch(t, i, r); if (s) { const [u, _] = s; return this._matchesPosition = _ + 1, this._query.findScope === v.UNIT ? this._activeHighlightIndex = this._matchesByWorksheet.get(u.range.subUnitId).findIndex((S) => S === u) : this._activeHighlightIndex = _, n || this._focusMatch(u), ((d = this._workbook.getActiveSheet()) == null ? void 0 : d.getSheetId()) === u.range.subUnitId && this._updateCurrentHighlightShape(this._activeHighlightIndex), u; } return this._matchesPosition = 0, this._updateCurrentHighlightShape(), null; } _findPreviousMatch(e = !1, t = !1, i = !1) { var o; if (this.currentMatch) { const c = this._matches.findIndex((u) => u === this.currentMatch); if (t) return [this.currentMatch, c]; const l = c - 1; if (!e && l < 0) return null; const a = this._matches.length, d = (l + a) % a; return [this._matches[d], d]; } const n = this._workbookSelections.getCurrentLastSelection(); if (i || !n) { const c = this._matches.length - 1; return [this._matches[c], c]; } if (this._query.findScope !== v.UNIT) return this._findPreviousMatchByRange(this._matches, n.range); const r = (o = this._workbook.getActiveSheet()) == null ? void 0 : o.getSheetId(); if (!r) return null; const s = this._findPreviousWorksheetThatHasAMatch(r, e); return s ? this._findPreviousMatchByRange(this._matchesByWorksheet.get(s), n.range) : null; } _findNextMatch(e = !1, t = !1, i = !1) { var o; if (this.currentMatch) { const c = this._matches.findIndex((u) => u === this.currentMatch); if (t) return [this.currentMatch, c]; const l = c + 1, a = this._matches.length; if (!e && l >= a) return null; const d = l % a; return [this._matches[d], d]; } const n = this._workbookSelections.getCurrentLastSelection(); if (i || !n) return [this._matches[0], 0]; if (this._query.findScope !== v.UNIT) return this._findNextMatchByRange(this._matches, n.range, t); const r = (o = this._workbook.getActiveSheet()) == null ? void 0 : o.getSheetId(); if (!r) return null; const s = this._findNextWorksheetThatHasAMatch(r, e); return s ? this._findNextMatchByRange(this._matchesByWorksheet.get(s), n.range) : null; } _findPreviousWorksheetThatHasAMatch(e, t = !1) { const i = this._workbook.getSheetOrders(), n = i.findIndex((o) => o === e), s = (t ? $(i, n + 1) : i.slice(0, n + 1)).findLast((o) => this._matchesByWorksheet.has(o)); return s != null ? s : null; } _findNextWorksheetThatHasAMatch(e, t = !1) { const i = this._workbook.getSheetOrders(), n = i.findIndex((o) => o === e), s = (t ? $(i, n) : i.slice(n)).find((o) => this._matchesByWorksheet.has(o)); return s != null ? s : null; } _findNextMatchByRange(e, t, i = !1) { const n = this._query.findDirection === w.ROW; let r = e.findIndex((o) => { const c = o.range.range; if (!(n ? K(t, c) : Q(t, c))) return !1; const a = Y(t, c); return i ? a : !a; }); r === -1 && (r = e.length - 1); const s = e[r]; return [s, this._matches.findIndex((o) => o === s)]; } _findPreviousMatchByRange(e, t, i = !1) { const n = this._query.findDirection === w.ROW; let r = this._matches.findLastIndex((o) => { const c = o.range.range; if (!(n ? Xe(t, c) : ze(t, c))) return !1; const a = Y(t, c); return i ? a : !a; }); r === -1 && (r = 0); const s = e[r]; return [s, this._matches.findIndex((o) => o === s)]; } async replace(e) { if (this._matchesCount === 0 || !this.currentMatch || !this._query || !this.currentMatch.replaceable) return !1; const t = this.currentMatch.range, i = this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId), n = this._getReplacedCellData( this.currentMatch, i, this._query.findBy === b.FORMULA, this._query.findString, e, this._query.caseSensitive ? "g" : "ig" ), r = { unitId: this.currentMatch.unitId, subUnitId: t.subUnitId, value: { [t.range.startRow]: { [t.range.startColumn]: n } } }; return this._commandService.executeCommand(te.id, r); } async replaceAll(e) { if (this._matchesCount === 0 || !this._query) return { success: 0, failure: 0 }; const t = this._workbook.getUnitId(), { findString: i, caseSensitive: n, findBy: r } = this._query, s = r === b.FORMULA, o = n ? "g" : "ig", c = []; return ve(this._matches.filter((a) => a.replaceable), (a) => a.range.subUnitId).forEach((a, d) => { const u = new Ce(), _ = this._workbook.getSheetBySheetId(d); a.forEach((S) => { const { startColumn: p, startRow: R } = S.range.range, I = this._getReplacedCellData(S, _, s, i, e, o); I && u.setValue(R, p, I); }), c.push({ count: a.length, subUnitId: d, value: u.getMatrix() }); }), c ? this._commandService.executeCommand(ne.id, { unitId: t, replacements: c }) : { success: 0, failure: 0 }; } _getReplacedCellData(e, t, i, n, r, s) { var _; const o = e.range.range, { startRow: c, startColumn: l } = o, a = t.getCellRaw(c, l); if (e.isFormula) return i ? { f: a.f.replace(new RegExp(X(n), s), r), v: null } : null; if (!!((_ = a.p) != null && _.body)) { const S = Re.deepClone(a.p); return we(S.body, n, r, this._query.caseSensitive), { p: S }; } return { v: a.v.toString().replace(new RegExp(X(n), s), r) }; } }; W = E([ m(2, q), m(3, ie), m(4, H), m(5, Z), m(6, C(me)), m(7, C(We)) ], W); function X(h) { return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); } let F = class extends J { constructor(e, t, i) { super(); /** * Hold all find results in this kind of univer business instances (Workbooks). */ g(this, "_findModelsByUnitId", /* @__PURE__ */ new Map()); this._univerInstanceService = e, this._renderManagerService = t, this._injector = i; } async find(e) { this._terminate(); const t = this._univerInstanceService.getAllUnitsForType(ee.UNIVER_SHEET), i = this._preprocessQuery(e); return t.map((r) => { const s = this._renderManagerService.getRenderById(r.getUnitId()).with(Ne), o = this._injector.createInstance(W, r, s); return this._findModelsByUnitId.set(r.getUnitId(), o), o.start(i), o; }); } terminate() { this._terminate(); } _terminate() { this._findModelsByUnitId.forEach((e) => e.dispose()), this._findModelsByUnitId.clear(); } /** * Parsed the query object before do actual searching in favor of performance. * @param query the raw query object * @returns the parsed query object */ _preprocessQuery(e) { let t = e.caseSensitive ? e.findString : e.findString.toLowerCase(); return t = t.trim(), { ...e, findString: t }; } }; F = E([ m(0, q), m(1, ie), m(2, C(T)) ], F); const f = { hit: !1, replaceable: !1, isFormula: !1, rawData: null }; function it(h, e, t, i, n) { const { findBy: r } = i, s = r === b.FORMULA, o = h.getCellRaw(e, t); return f.rawData = o, !(o != null && o.f) ? (f.isFormula = !1, U(n, i) ? o ? (f.hit = !0, f.replaceable = !0) : (f.hit = !0, f.replaceable = !1) : (f.hit = !1, f.replaceable = !1), f) : (f.isFormula = !0, s ? U({ v: o.f }, i) ? (f.hit = !0, f.replaceable = !0, f) : (f.hit = !1, f.replaceable = !1, f) : (f.replaceable = !1, U(n, i) ? f.hit = !0 : f.hit = !1, f)); } function U(h, e) { let t = nt(h); return t ? e.matchesTheWholeCell ? (t = st(t), e.caseSensitive ? t === e.findString : t.toLowerCase() === e.findString) : e.caseSensitive ? t.indexOf(e.findString) > -1 : t.toLowerCase().indexOf(e.findString) > -1 : !1; } function nt(h) { var t, i, n; const e = (n = (i = (t = h == null ? void 0 : h.p) == null ? void 0 : t.body) == null ? void 0 : i.dataStream) != null ? n : h == null ? void 0 : h.v; return typeof e == "number" ? `${e}` : typeof e == "boolean" ? e ? "1" : "0" : e; } function st(h) { return h.replace(/^ +/g, "").replace(/ +$/g, ""); } var se = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, ot = (h, e, t) => e in h ? se(h, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[e] = t, ht = (h, e, t, i) => { for (var n = i > 1 ? void 0 : i ? rt(e, t) : e, r = h.length - 1, s; r >= 0; r--) (s = h[r]) && (n = (i ? s(e, t, n) : s(n)) || n); return i && n && se(e, t, n), n; }, z = (h, e) => (t, i) => e(t, i, h), re = (h, e, t) => ot(h, typeof e != "symbol" ? e + "" : e, t); const ct = "SHEET_FIND_REPLACE_PLUGIN"; let x = class extends ke { constructor(h = G, e, t) { super(), this._config = h, this._injector = e, this._configService = t; const { ...i } = Me( {}, G, this._config ); this._configService.setConfig(Ye, i); } onStarting() { [[M]].forEach((h) => this._injector.add(h)); } onSteady() { this._injector.get(M); } }; re(x, "pluginName", ct); re(x, "type", ee.UNIVER_SHEET); x = ht([ be(L, L, Be), z(1, C(T)), z(2, xe) ], x); export { ne as SheetReplaceCommand, M as SheetsFindReplaceController, x as UniverSheetsFindReplacePlugin };