@univerjs/find-replace 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,90 +1,99 @@
1
- var at = Object.defineProperty;
2
- var ot = (t, e, n) => e in t ? at(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var o = (t, e, n) => ot(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { Disposable as X, createIdentifier as ct, Inject as b, Injector as ee, IUniverInstanceService as pe, toDisposable as H, IContextService as te, DisposableCollection as lt, CommandType as y, LocaleService as O, useDependency as v, ICommandService as ie, FOCUSING_SHEET as _e, EDITOR_ACTIVATED as ge, UniverInstanceType as dt, RxDisposable as ht, OnLifecycle as ut, LifecycleStages as ft, Plugin as pt, Tools as _t } from "@univerjs/core";
5
- import { IConfirmService as gt, IMessageService as me, useObservable as I, ILayoutService as ve, KeyCode as M, MetaKeys as x, MenuGroup as mt, MenuItemType as vt, MenuPosition as St, getMenuHiddenObservable as Ct, ComponentManager as Rt, IMenuService as Mt, IShortcutService as bt, IDialogService as xt } from "@univerjs/ui";
6
- import { BehaviorSubject as D, Subject as Se, throttleTime as yt, combineLatest as Ce, debounceTime as It, fromEvent as Ft, map as Dt, takeUntil as ce } from "rxjs";
7
- import { RENDER_RAW_FORMULA_KEY as Ot } from "@univerjs/engine-render";
8
- import Pt, { forwardRef as w, useRef as q, createElement as Re, useCallback as u, Fragment as N, useEffect as j, useMemo as ne, useImperativeHandle as Tt } from "react";
9
- import { MessageType as $, InputWithSlot as Et, Pager as Nt, Button as A, FormLayout as R, Input as $t, Select as G, FormDualColumnLayout as le, Checkbox as de } from "@univerjs/design";
10
- var _ = function() {
11
- return _ = Object.assign || function(t) {
12
- for (var e, n = 1, i = arguments.length; n < i; n++) {
13
- e = arguments[n];
14
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { Disposable, createIdentifier, Inject, Injector, IUniverInstanceService, toDisposable, IContextService, DisposableCollection, CommandType, LocaleService, useDependency, ICommandService, FOCUSING_SHEET, EDITOR_ACTIVATED, UniverInstanceType, RxDisposable, OnLifecycle, LifecycleStages, Plugin, Tools } from "@univerjs/core";
6
+ import { IConfirmService, IMessageService, useObservable, ILayoutService, KeyCode, MetaKeys, MenuGroup, MenuItemType, MenuPosition, getMenuHiddenObservable, ComponentManager, IMenuService, IShortcutService, IDialogService } from "@univerjs/ui";
7
+ import { BehaviorSubject, Subject, throttleTime, combineLatest, debounceTime, fromEvent, map, takeUntil } from "rxjs";
8
+ import { RENDER_RAW_FORMULA_KEY } from "@univerjs/engine-render";
9
+ import require$$0, { forwardRef, useRef, createElement, useCallback, Fragment, useEffect, useMemo, useImperativeHandle } from "react";
10
+ import { MessageType, InputWithSlot, Pager, Button, FormLayout, Input, Select, FormDualColumnLayout, Checkbox } from "@univerjs/design";
11
+ var __assign = function() {
12
+ return __assign = Object.assign || function(t) {
13
+ for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
14
+ s = arguments[i];
15
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
15
16
  }
16
17
  return t;
17
- }, _.apply(this, arguments);
18
- }, At = function(t, e) {
19
- var n = {};
20
- for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
21
- if (t != null && typeof Object.getOwnPropertySymbols == "function")
22
- for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
23
- e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
24
- return n;
25
- }, Me = w(function(t, e) {
26
- var n = t.icon, i = t.id, r = t.className, s = t.extend, a = At(t, ["icon", "id", "className", "extend"]), l = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = q("_".concat(wt()));
27
- return be(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, _({ ref: e, className: l }, a), s);
18
+ }, __assign.apply(this, arguments);
19
+ }, __rest = function(s, e) {
20
+ var t = {};
21
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
22
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
23
+ for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
24
+ e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
25
+ return t;
26
+ }, IconBase = forwardRef(function(props, ref) {
27
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
28
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
28
29
  });
29
- function be(t, e, n, i, r) {
30
- return Re(t.tag, _(_({ key: e }, jt(t, n, r)), i), (Lt(t, n).children || []).map(function(s, a) {
31
- return be(s, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
30
+ function render(node, id, runtimeProps, rootProps, extend) {
31
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
32
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
32
33
  }));
33
34
  }
34
- function jt(t, e, n) {
35
- var i = _({}, t.attrs);
36
- n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
37
- var r = e.defIds;
38
- return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(s) {
39
- var a = s[0], l = s[1];
40
- typeof l == "string" && (i[a] = l.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
41
- })), i;
35
+ __name(render, "render");
36
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
37
+ var attrs = __assign({}, node.attrs);
38
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
39
+ var defIds = runtimeProps.defIds;
40
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a5) {
41
+ var key = _a5[0], value = _a5[1];
42
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
43
+ })), attrs;
42
44
  }
43
- function Lt(t, e) {
44
- var n, i = e.defIds;
45
- return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? _(_({}, t), { children: t.children.map(function(r) {
46
- return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
47
- }) }) : t;
45
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
46
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
47
+ var _a5, defIds = runtimeProps.defIds;
48
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a5 = node.children) === null || _a5 === void 0) && _a5.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
49
+ return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
50
+ }) }) : node;
48
51
  }
49
- function wt() {
52
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
53
+ function generateShortUuid() {
50
54
  return Math.random().toString(36).substring(2, 8);
51
55
  }
52
- Me.displayName = "UniverIcon";
53
- var Ut = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_217_40", style: { maskType: "alpha" }, width: 17, height: 17, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#D9D9D9", d: "M0.9 0.09H16.9V16.09H0.9z" } }] }, { tag: "g", attrs: { mask: "url(#mask0_217_40)" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z", fillRule: "evenodd", clipRule: "evenodd" } }] }] }, xe = w(function(t, e) {
54
- return Re(Me, Object.assign({}, t, {
56
+ __name(generateShortUuid, "generateShortUuid");
57
+ IconBase.displayName = "UniverIcon";
58
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "mask", attrs: { id: "mask0_217_40", style: { maskType: "alpha" }, width: 17, height: 17, x: 0, y: 0, maskUnits: "userSpaceOnUse" }, children: [{ tag: "path", attrs: { fill: "#D9D9D9", d: "M0.9 0.09H16.9V16.09H0.9z" } }] }, { tag: "g", attrs: { mask: "url(#mask0_217_40)" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z", fillRule: "evenodd", clipRule: "evenodd" } }] }] }, SearchSingle16 = forwardRef(function(props, ref) {
59
+ return createElement(IconBase, Object.assign({}, props, {
55
60
  id: "search-single-16",
56
- ref: e,
57
- icon: Ut
61
+ ref,
62
+ icon: element
58
63
  }));
59
64
  });
60
- xe.displayName = "SearchSingle16";
61
- const ye = "FIND_REPLACE_INPUT_FOCUS", Ie = "FIND_REPLACE_DIALOG_FOCUS", Fe = "FIND_REPLACE_REPLACE_REVEALED";
62
- var Bt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, De = (t, e, n, i) => {
63
- for (var r = i > 1 ? void 0 : i ? Wt(e, n) : e, s = t.length - 1, a; s >= 0; s--)
64
- (a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
65
- return i && r && Bt(e, n, r), r;
66
- }, z = (t, e) => (n, i) => e(n, i, t);
67
- class Ni extends X {
68
- }
69
- const g = ct("find-replace.service");
70
- function kt(t) {
71
- return typeof t.findString < "u" || typeof t.inputtingFindString < "u" || typeof t.findDirection < "u" || typeof t.matchesTheWholeCell < "u" || typeof t.caseSensitive < "u" || typeof t.findScope < "u" || typeof t.findBy < "u";
65
+ SearchSingle16.displayName = "SearchSingle16";
66
+ const FIND_REPLACE_INPUT_FOCUS = "FIND_REPLACE_INPUT_FOCUS", FIND_REPLACE_DIALOG_FOCUS = "FIND_REPLACE_DIALOG_FOCUS", FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
67
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
68
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
69
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
70
+ return kind && result && __defProp$2(target, key, result), result;
71
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
72
+ const _FindModel = class _FindModel extends Disposable {
73
+ };
74
+ __name(_FindModel, "FindModel");
75
+ let FindModel = _FindModel;
76
+ const IFindReplaceService = createIdentifier("find-replace.service");
77
+ function shouldStateUpdateTriggerResearch(statusUpdate) {
78
+ return typeof statusUpdate.findString < "u" || typeof statusUpdate.inputtingFindString < "u" || typeof statusUpdate.findDirection < "u" || typeof statusUpdate.matchesTheWholeCell < "u" || typeof statusUpdate.caseSensitive < "u" || typeof statusUpdate.findScope < "u" || typeof statusUpdate.findBy < "u";
72
79
  }
73
- let K = class extends X {
74
- constructor(e, n, i) {
80
+ __name(shouldStateUpdateTriggerResearch, "shouldStateUpdateTriggerResearch");
81
+ var _a;
82
+ let FindReplaceModel = (_a = class extends Disposable {
83
+ constructor(_state, _providers, _univerInstanceService) {
75
84
  super();
76
- o(this, "currentMatch$", new D(null));
77
- o(this, "replaceables$", new D([]));
85
+ __publicField(this, "currentMatch$", new BehaviorSubject(null));
86
+ __publicField(this, "replaceables$", new BehaviorSubject([]));
78
87
  /** All find models returned by providers. */
79
- o(this, "_findModels", []);
88
+ __publicField(this, "_findModels", []);
80
89
  /** The find model that the current match is from. */
81
- o(this, "_matchingModel", null);
82
- o(this, "_matches", []);
83
- o(this, "_currentSearchingDisposables", null);
84
- this._state = e, this._providers = n, this._univerInstanceService = i, this.disposeWithMe(
85
- this._state.stateUpdates$.pipe(yt(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (r) => {
86
- const s = this._state.state;
87
- kt(r) && (s.findString !== "" && !s.replaceRevealed ? (await this._startSearching(), this._state.changeState({ findCompleted: !0 })) : r.replaceRevealed !== !0 && this._stopSearching());
90
+ __publicField(this, "_matchingModel", null);
91
+ __publicField(this, "_matches", []);
92
+ __publicField(this, "_currentSearchingDisposables", null);
93
+ this._state = _state, this._providers = _providers, this._univerInstanceService = _univerInstanceService, this.disposeWithMe(
94
+ this._state.stateUpdates$.pipe(throttleTime(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (stateUpdate) => {
95
+ const state = this._state.state;
96
+ shouldStateUpdateTriggerResearch(stateUpdate) && (state.findString !== "" && !state.replaceRevealed ? (await this._startSearching(), this._state.changeState({ findCompleted: !0 })) : stateUpdate.replaceRevealed !== !0 && this._stopSearching());
88
97
  })
89
98
  );
90
99
  }
@@ -92,19 +101,19 @@ let K = class extends X {
92
101
  return this._findModels.length > 0;
93
102
  }
94
103
  dispose() {
95
- super.dispose(), this._stopSearching(), this.currentMatch$.complete(), this.replaceables$.complete(), this._state.changeState({ ...re(), revealed: !1 });
104
+ super.dispose(), this._stopSearching(), this.currentMatch$.complete(), this.replaceables$.complete(), this._state.changeState({ ...createInitFindReplaceState(), revealed: !1 });
96
105
  }
97
106
  async start() {
98
107
  if (!this._state.findString)
99
108
  return { results: [] };
100
- const e = await this._startSearching();
101
- return this._state.changeState({ findCompleted: !0 }), e;
109
+ const complete = await this._startSearching();
110
+ return this._state.changeState({ findCompleted: !0 }), complete;
102
111
  }
103
112
  /** Call this method to start a `searching`. */
104
113
  async _startSearching() {
105
114
  if (!this._state.findString)
106
115
  return { results: [] };
107
- const e = Array.from(this._providers), n = this._findModels = (await Promise.all(e.map((r) => r.find({
116
+ const providers = Array.from(this._providers), findModels = this._findModels = (await Promise.all(providers.map((provider) => provider.find({
108
117
  findString: this._state.findString,
109
118
  findDirection: this._state.findDirection,
110
119
  findScope: this._state.findScope,
@@ -113,111 +122,111 @@ let K = class extends X {
113
122
  caseSensitive: this._state.caseSensitive,
114
123
  matchesTheWholeCell: this._state.matchesTheWholeCell
115
124
  })))).flat();
116
- this._subscribeToModelsChanges(n);
117
- const i = this._matches = n.map((r) => r.getMatches()).flat();
118
- return this.replaceables$.next(i.filter((r) => r.replaceable)), i.length ? (this._moveToInitialMatch(n), this._state.changeState({ matchesCount: i.length }), { results: i }) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), { results: [] });
125
+ this._subscribeToModelsChanges(findModels);
126
+ const newMatches = this._matches = findModels.map((c) => c.getMatches()).flat();
127
+ return this.replaceables$.next(newMatches.filter((m2) => m2.replaceable)), newMatches.length ? (this._moveToInitialMatch(findModels), this._state.changeState({ matchesCount: newMatches.length }), { results: newMatches }) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), { results: [] });
119
128
  }
120
129
  /** Terminate the current searching session, when searching string is empty. */
121
130
  _stopSearching() {
122
- var e;
123
- this._providers.forEach((n) => n.terminate()), this._findModels = [], this._matches = [], this._matchingModel = null, (e = this._currentSearchingDisposables) == null || e.dispose(), this._currentSearchingDisposables = null, this.currentMatch$.next(null), this.replaceables$.next([]), this._state.changeState({
131
+ var _a5;
132
+ this._providers.forEach((provider) => provider.terminate()), this._findModels = [], this._matches = [], this._matchingModel = null, (_a5 = this._currentSearchingDisposables) == null || _a5.dispose(), this._currentSearchingDisposables = null, this.currentMatch$.next(null), this.replaceables$.next([]), this._state.changeState({
124
133
  findCompleted: !1,
125
134
  matchesCount: 0,
126
135
  matchesPosition: 0
127
136
  });
128
137
  }
129
138
  // When a document's content changes, we should reset all matches and try to move to the next match.
130
- _subscribeToModelsChanges(e) {
131
- const n = this._currentSearchingDisposables = new lt(), i = Ce(e.map((r) => r.matchesUpdate$)).pipe(It(220)).subscribe(([...r]) => {
132
- const s = this._matches = r.flat();
133
- s.length ? (this._moveToInitialMatch(this._findModels, !0), this._state.changeState({ matchesCount: s.length }), this.replaceables$.next(s.filter((a) => a.replaceable))) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]));
139
+ _subscribeToModelsChanges(models) {
140
+ const disposables = this._currentSearchingDisposables = new DisposableCollection(), matchesUpdateSubscription = combineLatest(models.map((model) => model.matchesUpdate$)).pipe(debounceTime(220)).subscribe(([...allMatches]) => {
141
+ const newMatches = this._matches = allMatches.flat();
142
+ newMatches.length ? (this._moveToInitialMatch(this._findModels, !0), this._state.changeState({ matchesCount: newMatches.length }), this.replaceables$.next(newMatches.filter((m2) => m2.replaceable))) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]));
134
143
  });
135
- e.forEach((r) => n.add(H(r.activelyChangingMatch$.subscribe((s) => {
136
- const a = this._matches.findIndex((l) => l === s);
137
- this._state.changeState({ matchesPosition: a + 1 });
138
- })))), n.add(H(i));
144
+ models.forEach((model) => disposables.add(toDisposable(model.activelyChangingMatch$.subscribe((match) => {
145
+ const index = this._matches.findIndex((m2) => m2 === match);
146
+ this._state.changeState({ matchesPosition: index + 1 });
147
+ })))), disposables.add(toDisposable(matchesUpdateSubscription));
139
148
  }
140
149
  async replace() {
141
150
  return this._matchingModel ? this._matchingModel.replace(this._state.replaceString) : !1;
142
151
  }
143
152
  async replaceAll() {
144
- const e = await Promise.all(this._findModels.map((n) => n.replaceAll(this._state.replaceString))).then((n) => n.reduce((i, r) => (i.success += r.success, i.failure += r.failure, i), { success: 0, failure: 0 }));
145
- return e.failure === 0 && this._stopSearching(), e;
153
+ const result = await Promise.all(this._findModels.map((m2) => m2.replaceAll(this._state.replaceString))).then((results) => results.reduce((acc, cur) => (acc.success += cur.success, acc.failure += cur.failure, acc), { success: 0, failure: 0 }));
154
+ return result.failure === 0 && this._stopSearching(), result;
146
155
  }
147
156
  getCurrentMatch() {
148
157
  return this._state.matchesPosition > 0 ? this._matches[this._state.matchesPosition - 1] : null;
149
158
  }
150
- _markMatch(e) {
151
- const n = this._matches.findIndex((i) => i === e);
152
- this.currentMatch$.next(e), this._state.changeState({ matchesPosition: n + 1 });
159
+ _markMatch(match) {
160
+ const index = this._matches.findIndex((value) => value === match);
161
+ this.currentMatch$.next(match), this._state.changeState({ matchesPosition: index + 1 });
153
162
  }
154
163
  moveToNextMatch() {
155
164
  if (!this._matchingModel)
156
165
  return;
157
- const e = this._findModels.length === 1, n = this._matchingModel.moveToNextMatch({ loop: e });
158
- if (n)
159
- this._markMatch(n);
166
+ const loopInCurrentUnit = this._findModels.length === 1, nextMatch = this._matchingModel.moveToNextMatch({ loop: loopInCurrentUnit });
167
+ if (nextMatch)
168
+ this._markMatch(nextMatch);
160
169
  else {
161
- const i = this._findModels.findIndex((r) => r === this._matchingModel);
162
- this._moveToNextUnitMatch(i);
170
+ const currentModelIndex = this._findModels.findIndex((m2) => m2 === this._matchingModel);
171
+ this._moveToNextUnitMatch(currentModelIndex);
163
172
  }
164
173
  }
165
- _moveToNextUnitMatch(e) {
166
- const n = this._findModels.length;
167
- for (let i = (e + 1) % n; i !== e; ) {
168
- const r = this._findModels[i], s = r.moveToNextMatch({ ignoreSelection: !0 });
169
- if (s) {
170
- this._matchingModel = r, this._markMatch(s);
174
+ _moveToNextUnitMatch(startingIndex) {
175
+ const l2 = this._findModels.length;
176
+ for (let i = (startingIndex + 1) % l2; i !== startingIndex; ) {
177
+ const nextPositionModel = this._findModels[i], nextMatch = nextPositionModel.moveToNextMatch({ ignoreSelection: !0 });
178
+ if (nextMatch) {
179
+ this._matchingModel = nextPositionModel, this._markMatch(nextMatch);
171
180
  return;
172
181
  }
173
- i = (i + 1) % n;
182
+ i = (i + 1) % l2;
174
183
  }
175
184
  if (this._matchingModel) {
176
- const i = this._matchingModel.moveToNextMatch({ ignoreSelection: !0 });
177
- i && this._markMatch(i);
185
+ const nextMatch = this._matchingModel.moveToNextMatch({ ignoreSelection: !0 });
186
+ nextMatch && this._markMatch(nextMatch);
178
187
  }
179
188
  }
180
189
  moveToPreviousMatch() {
181
190
  if (!this._matchingModel)
182
191
  return;
183
- const e = this._findModels.length === 1, n = this._matchingModel.moveToPreviousMatch({ loop: e });
184
- if (n) {
185
- const i = this._matches.findIndex((r) => r === n);
186
- this.currentMatch$.next(n), this._state.changeState({ matchesPosition: i + 1 });
192
+ const loopInCurrentUnit = this._findModels.length === 1, nextMatch = this._matchingModel.moveToPreviousMatch({ loop: loopInCurrentUnit });
193
+ if (nextMatch) {
194
+ const index = this._matches.findIndex((value) => value === nextMatch);
195
+ this.currentMatch$.next(nextMatch), this._state.changeState({ matchesPosition: index + 1 });
187
196
  } else {
188
- const i = this._findModels.length, r = this._findModels.findIndex((a) => a === this._matchingModel);
189
- for (let a = (r - 1 + i) % i; a !== r; ) {
190
- const l = this._findModels[a], d = l.moveToPreviousMatch({ ignoreSelection: !0 });
191
- if (d) {
192
- this._matchingModel = l, this._markMatch(d);
197
+ const l2 = this._findModels.length, currentModelIndex = this._findModels.findIndex((m2) => m2 === this._matchingModel);
198
+ for (let i = (currentModelIndex - 1 + l2) % l2; i !== currentModelIndex; ) {
199
+ const nextPositionModel = this._findModels[i], nextMatch3 = nextPositionModel.moveToPreviousMatch({ ignoreSelection: !0 });
200
+ if (nextMatch3) {
201
+ this._matchingModel = nextPositionModel, this._markMatch(nextMatch3);
193
202
  return;
194
203
  }
195
- a = (a - 1) % i;
204
+ i = (i - 1) % l2;
196
205
  }
197
- const s = this._matchingModel.moveToPreviousMatch({ ignoreSelection: !0 });
198
- s && this._markMatch(s);
206
+ const nextMatch2 = this._matchingModel.moveToPreviousMatch({ ignoreSelection: !0 });
207
+ nextMatch2 && this._markMatch(nextMatch2);
199
208
  }
200
209
  }
201
- _moveToInitialMatch(e, n = !1) {
202
- var s;
203
- const i = (s = this._univerInstanceService.getFocusedUnit()) == null ? void 0 : s.getUnitId();
204
- if (!i)
210
+ _moveToInitialMatch(findModels, noFocus = !1) {
211
+ var _a5;
212
+ const focusedUnitId = (_a5 = this._univerInstanceService.getFocusedUnit()) == null ? void 0 : _a5.getUnitId();
213
+ if (!focusedUnitId)
205
214
  return -1;
206
- const r = e.findIndex((a) => a.unitId === i);
207
- if (r !== -1) {
208
- this._matchingModel = e[r];
209
- const a = this._matchingModel.moveToNextMatch({ stayIfOnMatch: !0, noFocus: n });
210
- if (a)
211
- return this._markMatch(a), r;
215
+ const i = findModels.findIndex((model) => model.unitId === focusedUnitId);
216
+ if (i !== -1) {
217
+ this._matchingModel = findModels[i];
218
+ const nextMatch = this._matchingModel.moveToNextMatch({ stayIfOnMatch: !0, noFocus });
219
+ if (nextMatch)
220
+ return this._markMatch(nextMatch), i;
212
221
  }
213
- return this._moveToNextUnitMatch(r), 0;
214
- }
215
- };
216
- K = De([
217
- z(2, pe)
218
- ], K);
219
- var Y = /* @__PURE__ */ ((t) => (t.ROW = "row", t.COLUMN = "column", t))(Y || {}), Z = /* @__PURE__ */ ((t) => (t.VALUE = "value", t.FORMULA = "formula", t))(Z || {}), J = /* @__PURE__ */ ((t) => (t.SUBUNIT = "subunit", t.UNIT = "unit", t))(J || {});
220
- function re() {
222
+ return this._moveToNextUnitMatch(i), 0;
223
+ }
224
+ }, __name(_a, "FindReplaceModel"), _a);
225
+ FindReplaceModel = __decorateClass$2([
226
+ __decorateParam$2(2, IUniverInstanceService)
227
+ ], FindReplaceModel);
228
+ var FindDirection = /* @__PURE__ */ ((FindDirection2) => (FindDirection2.ROW = "row", FindDirection2.COLUMN = "column", FindDirection2))(FindDirection || {}), FindBy = /* @__PURE__ */ ((FindBy2) => (FindBy2.VALUE = "value", FindBy2.FORMULA = "formula", FindBy2))(FindBy || {}), FindScope = /* @__PURE__ */ ((FindScope2) => (FindScope2.SUBUNIT = "subunit", FindScope2.UNIT = "unit", FindScope2))(FindScope || {});
229
+ function createInitFindReplaceState() {
221
230
  return {
222
231
  caseSensitive: !1,
223
232
  findBy: "value",
@@ -234,25 +243,26 @@ function re() {
234
243
  revealed: !0
235
244
  };
236
245
  }
237
- class Gt {
246
+ __name(createInitFindReplaceState, "createInitFindReplaceState");
247
+ const _FindReplaceState = class _FindReplaceState {
238
248
  constructor() {
239
- o(this, "_stateUpdates$", new Se());
240
- o(this, "stateUpdates$", this._stateUpdates$.asObservable());
241
- o(this, "_state$", new D(re()));
242
- o(this, "state$", this._state$.asObservable());
243
- o(this, "_findString", "");
244
- o(this, "_inputtingFindString", "");
245
- o(this, "_replaceString", "");
246
- o(this, "_revealed", !1);
247
- o(this, "_replaceRevealed", !1);
248
- o(this, "_matchesPosition", 0);
249
- o(this, "_matchesCount", 0);
250
- o(this, "_caseSensitive", !0);
251
- o(this, "_matchesTheWholeCell", !1);
252
- o(this, "_findDirection", "row");
253
- o(this, "_findScope", "subunit");
254
- o(this, "_findBy", "value");
255
- o(this, "_findCompleted", !1);
249
+ __publicField(this, "_stateUpdates$", new Subject());
250
+ __publicField(this, "stateUpdates$", this._stateUpdates$.asObservable());
251
+ __publicField(this, "_state$", new BehaviorSubject(createInitFindReplaceState()));
252
+ __publicField(this, "state$", this._state$.asObservable());
253
+ __publicField(this, "_findString", "");
254
+ __publicField(this, "_inputtingFindString", "");
255
+ __publicField(this, "_replaceString", "");
256
+ __publicField(this, "_revealed", !1);
257
+ __publicField(this, "_replaceRevealed", !1);
258
+ __publicField(this, "_matchesPosition", 0);
259
+ __publicField(this, "_matchesCount", 0);
260
+ __publicField(this, "_caseSensitive", !0);
261
+ __publicField(this, "_matchesTheWholeCell", !1);
262
+ __publicField(this, "_findDirection", "row");
263
+ __publicField(this, "_findScope", "subunit");
264
+ __publicField(this, "_findBy", "value");
265
+ __publicField(this, "_findCompleted", !1);
256
266
  }
257
267
  get state() {
258
268
  return this._state$.getValue();
@@ -297,10 +307,10 @@ class Gt {
297
307
  return this._findCompleted;
298
308
  }
299
309
  // eslint-disable-next-line max-lines-per-function, complexity
300
- changeState(e) {
301
- let n = !1;
302
- const i = {};
303
- typeof e.findString < "u" && e.findString !== this._findString && (this._findString = e.findString, i.findString = this._findString, n = !0), typeof e.revealed < "u" && e.revealed !== this._revealed && (this._revealed = e.revealed, i.revealed = e.revealed, n = !0), typeof e.replaceRevealed < "u" && e.replaceRevealed !== this._replaceRevealed && (this._replaceRevealed = e.replaceRevealed, i.replaceRevealed = e.replaceRevealed, n = !0), typeof e.replaceString < "u" && e.replaceString !== this._replaceString && (this._replaceString = e.replaceString, i.replaceString = e.replaceString, n = !0), typeof e.matchesCount < "u" && e.matchesCount !== this._matchesCount && (this._matchesCount = e.matchesCount, i.matchesCount = e.matchesCount, n = !0), typeof e.matchesPosition < "u" && e.matchesPosition !== this._matchesPosition && (this._matchesPosition = e.matchesPosition, i.matchesPosition = e.matchesPosition, n = !0), typeof e.findBy < "u" && e.findBy !== this._findBy && (this._findBy = e.findBy, i.findBy = e.findBy, n = !0), typeof e.findScope < "u" && e.findScope !== this._findScope && (this._findScope = e.findScope, i.findScope = e.findScope, n = !0), typeof e.findDirection < "u" && e.findDirection !== this._findDirection && (this._findDirection = e.findDirection, i.findDirection = e.findDirection, n = !0), typeof e.caseSensitive < "u" && e.caseSensitive !== this._caseSensitive && (this._caseSensitive = e.caseSensitive, i.caseSensitive = e.caseSensitive, n = !0), typeof e.matchesTheWholeCell < "u" && e.matchesTheWholeCell !== this._matchesTheWholeCell && (this._matchesTheWholeCell = e.matchesTheWholeCell, i.matchesTheWholeCell = e.matchesTheWholeCell, n = !0), typeof e.inputtingFindString < "u" && e.inputtingFindString !== this._inputtingFindString && (this._inputtingFindString = e.inputtingFindString, i.inputtingFindString = e.inputtingFindString, n = !0), typeof e.findCompleted < "u" && e.findCompleted !== this._findCompleted && (this._findCompleted = e.findCompleted, i.findCompleted = e.findCompleted, n = !0), n && (this._state$.next({
310
+ changeState(changes) {
311
+ let changed = !1;
312
+ const changedState = {};
313
+ typeof changes.findString < "u" && changes.findString !== this._findString && (this._findString = changes.findString, changedState.findString = this._findString, changed = !0), typeof changes.revealed < "u" && changes.revealed !== this._revealed && (this._revealed = changes.revealed, changedState.revealed = changes.revealed, changed = !0), typeof changes.replaceRevealed < "u" && changes.replaceRevealed !== this._replaceRevealed && (this._replaceRevealed = changes.replaceRevealed, changedState.replaceRevealed = changes.replaceRevealed, changed = !0), typeof changes.replaceString < "u" && changes.replaceString !== this._replaceString && (this._replaceString = changes.replaceString, changedState.replaceString = changes.replaceString, changed = !0), typeof changes.matchesCount < "u" && changes.matchesCount !== this._matchesCount && (this._matchesCount = changes.matchesCount, changedState.matchesCount = changes.matchesCount, changed = !0), typeof changes.matchesPosition < "u" && changes.matchesPosition !== this._matchesPosition && (this._matchesPosition = changes.matchesPosition, changedState.matchesPosition = changes.matchesPosition, changed = !0), typeof changes.findBy < "u" && changes.findBy !== this._findBy && (this._findBy = changes.findBy, changedState.findBy = changes.findBy, changed = !0), typeof changes.findScope < "u" && changes.findScope !== this._findScope && (this._findScope = changes.findScope, changedState.findScope = changes.findScope, changed = !0), typeof changes.findDirection < "u" && changes.findDirection !== this._findDirection && (this._findDirection = changes.findDirection, changedState.findDirection = changes.findDirection, changed = !0), typeof changes.caseSensitive < "u" && changes.caseSensitive !== this._caseSensitive && (this._caseSensitive = changes.caseSensitive, changedState.caseSensitive = changes.caseSensitive, changed = !0), typeof changes.matchesTheWholeCell < "u" && changes.matchesTheWholeCell !== this._matchesTheWholeCell && (this._matchesTheWholeCell = changes.matchesTheWholeCell, changedState.matchesTheWholeCell = changes.matchesTheWholeCell, changed = !0), typeof changes.inputtingFindString < "u" && changes.inputtingFindString !== this._inputtingFindString && (this._inputtingFindString = changes.inputtingFindString, changedState.inputtingFindString = changes.inputtingFindString, changed = !0), typeof changes.findCompleted < "u" && changes.findCompleted !== this._findCompleted && (this._findCompleted = changes.findCompleted, changedState.findCompleted = changes.findCompleted, changed = !0), changed && (this._state$.next({
304
314
  caseSensitive: this._caseSensitive,
305
315
  findBy: this._findBy,
306
316
  findCompleted: this._findCompleted,
@@ -313,22 +323,25 @@ class Gt {
313
323
  matchesTheWholeCell: this._matchesTheWholeCell,
314
324
  replaceRevealed: this._replaceRevealed,
315
325
  revealed: this._revealed
316
- }), this._stateUpdates$.next(i));
326
+ }), this._stateUpdates$.next(changedState));
317
327
  }
318
- }
319
- let Q = class extends X {
320
- constructor(e, n) {
328
+ };
329
+ __name(_FindReplaceState, "FindReplaceState");
330
+ let FindReplaceState = _FindReplaceState;
331
+ var _a2;
332
+ let FindReplaceService = (_a2 = class extends Disposable {
333
+ constructor(_injector, _contextService) {
321
334
  super();
322
- o(this, "_providers", /* @__PURE__ */ new Set());
323
- o(this, "_state", new Gt());
324
- o(this, "_model");
325
- o(this, "_currentMatch$", new D(null));
326
- o(this, "currentMatch$", this._currentMatch$.asObservable());
327
- o(this, "_replaceables$", new D([]));
328
- o(this, "replaceables$", this._replaceables$.asObservable());
329
- o(this, "_focusSignal$", new Se());
330
- o(this, "focusSignal$", this._focusSignal$.asObservable());
331
- this._injector = e, this._contextService = n;
335
+ __publicField(this, "_providers", /* @__PURE__ */ new Set());
336
+ __publicField(this, "_state", new FindReplaceState());
337
+ __publicField(this, "_model");
338
+ __publicField(this, "_currentMatch$", new BehaviorSubject(null));
339
+ __publicField(this, "currentMatch$", this._currentMatch$.asObservable());
340
+ __publicField(this, "_replaceables$", new BehaviorSubject([]));
341
+ __publicField(this, "replaceables$", this._replaceables$.asObservable());
342
+ __publicField(this, "_focusSignal$", new Subject());
343
+ __publicField(this, "focusSignal$", this._focusSignal$.asObservable());
344
+ this._injector = _injector, this._contextService = _contextService;
332
345
  }
333
346
  get stateUpdates$() {
334
347
  return this._state.stateUpdates$;
@@ -346,41 +359,41 @@ let Q = class extends X {
346
359
  super.dispose(), this._currentMatch$.next(null), this._currentMatch$.complete(), this._replaceables$.next([]), this._replaceables$.complete(), this._focusSignal$.complete();
347
360
  }
348
361
  getCurrentMatch() {
349
- var e;
350
- return (e = this._model) == null ? void 0 : e.getCurrentMatch();
362
+ var _a5;
363
+ return (_a5 = this._model) == null ? void 0 : _a5.getCurrentMatch();
351
364
  }
352
365
  getFindString() {
353
366
  return this._state.findString;
354
367
  }
355
- changeFindString(e) {
356
- this._state.changeState({ findString: e });
368
+ changeFindString(findString) {
369
+ this._state.changeState({ findString });
357
370
  }
358
371
  focusFindInput() {
359
372
  this._focusSignal$.next();
360
373
  }
361
- changeInputtingFindString(e) {
362
- e ? this._state.changeState({ inputtingFindString: e }) : this._state.changeState({ inputtingFindString: "", findString: "" });
374
+ changeInputtingFindString(value) {
375
+ value ? this._state.changeState({ inputtingFindString: value }) : this._state.changeState({ inputtingFindString: "", findString: "" });
363
376
  }
364
- changeReplaceString(e) {
365
- this._state.changeState({ replaceString: e });
377
+ changeReplaceString(replaceString) {
378
+ this._state.changeState({ replaceString });
366
379
  }
367
- changeMatchesTheWholeCell(e) {
368
- this._state.changeState({ matchesTheWholeCell: e });
380
+ changeMatchesTheWholeCell(matchesTheWholeCell) {
381
+ this._state.changeState({ matchesTheWholeCell });
369
382
  }
370
- changeCaseSensitive(e) {
371
- this._state.changeState({ caseSensitive: e });
383
+ changeCaseSensitive(caseSensitive) {
384
+ this._state.changeState({ caseSensitive });
372
385
  }
373
- changeFindBy(e) {
374
- this._state.changeState({ findBy: e }), this._toggleDisplayRawFormula(
375
- e === "formula"
386
+ changeFindBy(findBy) {
387
+ this._state.changeState({ findBy }), this._toggleDisplayRawFormula(
388
+ findBy === "formula"
376
389
  /* FORMULA */
377
390
  );
378
391
  }
379
- changeFindScope(e) {
380
- this._state.changeState({ findScope: e });
392
+ changeFindScope(scope) {
393
+ this._state.changeState({ findScope: scope });
381
394
  }
382
- changeFindDirection(e) {
383
- this._state.changeState({ findDirection: e });
395
+ changeFindDirection(direction) {
396
+ this._state.changeState({ findDirection: direction });
384
397
  }
385
398
  moveToNextMatch() {
386
399
  this._model && (this._state.replaceRevealed && !this._model.searched ? (this._state.changeState({ findString: this._state.inputtingFindString }), this._model.start()) : this._model.moveToNextMatch(), this._focusSignal$.next());
@@ -399,59 +412,59 @@ let Q = class extends X {
399
412
  revealReplace() {
400
413
  this._state.changeState({ replaceRevealed: !0, inputtingFindString: this._state.findString }), this._toggleRevealReplace(!0);
401
414
  }
402
- start(e = !1) {
415
+ start(revealReplace = !1) {
403
416
  if (this._providers.size === 0)
404
417
  return !1;
405
- this._model = this._injector.createInstance(K, this._state, this._providers), this._model.currentMatch$.subscribe((i) => this._currentMatch$.next(i)), this._model.replaceables$.subscribe((i) => this._replaceables$.next(i));
406
- const n = re();
407
- return e && (n.replaceRevealed = !0), this._state.changeState(n), this._toggleRevealReplace(e), !0;
418
+ this._model = this._injector.createInstance(FindReplaceModel, this._state, this._providers), this._model.currentMatch$.subscribe((match) => this._currentMatch$.next(match)), this._model.replaceables$.subscribe((replaceables) => this._replaceables$.next(replaceables));
419
+ const newState = createInitFindReplaceState();
420
+ return revealReplace && (newState.replaceRevealed = !0), this._state.changeState(newState), this._toggleRevealReplace(revealReplace), !0;
408
421
  }
409
422
  find() {
410
- var e;
411
- (e = this._model) == null || e.start();
423
+ var _a5;
424
+ (_a5 = this._model) == null || _a5.start();
412
425
  }
413
426
  terminate() {
414
- var e;
415
- (e = this._model) == null || e.dispose(), this._model = null, this._toggleDisplayRawFormula(!1), this._toggleRevealReplace(!1);
427
+ var _a5;
428
+ (_a5 = this._model) == null || _a5.dispose(), this._model = null, this._toggleDisplayRawFormula(!1), this._toggleRevealReplace(!1);
416
429
  }
417
- registerFindReplaceProvider(e) {
418
- return this._providers.add(e), H(() => this._providers.delete(e));
430
+ registerFindReplaceProvider(provider) {
431
+ return this._providers.add(provider), toDisposable(() => this._providers.delete(provider));
419
432
  }
420
- _toggleRevealReplace(e) {
421
- this._contextService.setContextValue(Fe, e);
433
+ _toggleRevealReplace(revealReplace) {
434
+ this._contextService.setContextValue(FIND_REPLACE_REPLACE_REVEALED, revealReplace);
422
435
  }
423
- _toggleDisplayRawFormula(e) {
424
- this._contextService.setContextValue(Ot, e);
436
+ _toggleDisplayRawFormula(force) {
437
+ this._contextService.setContextValue(RENDER_RAW_FORMULA_KEY, force);
425
438
  }
426
- };
427
- Q = De([
428
- z(0, b(ee)),
429
- z(1, te)
430
- ], Q);
431
- const U = {
439
+ }, __name(_a2, "FindReplaceService"), _a2);
440
+ FindReplaceService = __decorateClass$2([
441
+ __decorateParam$2(0, Inject(Injector)),
442
+ __decorateParam$2(1, IContextService)
443
+ ], FindReplaceService);
444
+ const OpenFindDialogOperation = {
432
445
  id: "ui.operation.open-find-dialog",
433
- type: y.OPERATION,
434
- handler: (t) => {
435
- const e = t.get(g);
436
- return e.revealed ? e.focusFindInput() : e.start(), !0;
437
- }
438
- }, se = {
446
+ type: CommandType.OPERATION,
447
+ handler: /* @__PURE__ */ __name((accessor) => {
448
+ const findReplaceService = accessor.get(IFindReplaceService);
449
+ return findReplaceService.revealed ? findReplaceService.focusFindInput() : findReplaceService.start(), !0;
450
+ }, "handler")
451
+ }, OpenReplaceDialogOperation = {
439
452
  id: "ui.operation.open-replace-dialog",
440
- type: y.OPERATION,
441
- handler: (t) => {
442
- const e = t.get(g);
443
- return e.revealed ? e.replaceRevealed ? e.focusFindInput() : e.revealReplace() : e.start(!0), !0;
444
- }
445
- }, Oe = {
446
- type: y.OPERATION,
453
+ type: CommandType.OPERATION,
454
+ handler: /* @__PURE__ */ __name((accessor) => {
455
+ const findReplaceService = accessor.get(IFindReplaceService);
456
+ return findReplaceService.revealed ? findReplaceService.replaceRevealed ? findReplaceService.focusFindInput() : findReplaceService.revealReplace() : findReplaceService.start(!0), !0;
457
+ }, "handler")
458
+ }, GoToNextMatchOperation = {
459
+ type: CommandType.OPERATION,
447
460
  id: "ui.operation.go-to-next-match",
448
- handler: (t) => (t.get(g).moveToNextMatch(), !0)
449
- }, Pe = {
450
- type: y.OPERATION,
461
+ handler: /* @__PURE__ */ __name((accessor) => (accessor.get(IFindReplaceService).moveToNextMatch(), !0), "handler")
462
+ }, GoToPreviousMatchOperation = {
463
+ type: CommandType.OPERATION,
451
464
  id: "ui.operation.go-to-previous-match",
452
- handler: (t) => (t.get(g).moveToPreviousMatch(), !0)
465
+ handler: /* @__PURE__ */ __name((accessor) => (accessor.get(IFindReplaceService).moveToPreviousMatch(), !0), "handler")
453
466
  };
454
- var Te = { exports: {} }, B = {};
467
+ var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
455
468
  /**
456
469
  * @license React
457
470
  * react-jsx-runtime.production.min.js
@@ -461,448 +474,467 @@ var Te = { exports: {} }, B = {};
461
474
  * This source code is licensed under the MIT license found in the
462
475
  * LICENSE file in the root directory of this source tree.
463
476
  */
464
- var Vt = Pt, Ht = Symbol.for("react.element"), qt = Symbol.for("react.fragment"), zt = Object.prototype.hasOwnProperty, Kt = Vt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Yt = { key: !0, ref: !0, __self: !0, __source: !0 };
465
- function Ee(t, e, n) {
466
- var i, r = {}, s = null, a = null;
467
- n !== void 0 && (s = "" + n), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (a = e.ref);
468
- for (i in e) zt.call(e, i) && !Yt.hasOwnProperty(i) && (r[i] = e[i]);
469
- if (t && t.defaultProps) for (i in e = t.defaultProps, e) r[i] === void 0 && (r[i] = e[i]);
470
- return { $$typeof: Ht, type: t, key: s, ref: a, props: r, _owner: Kt.current };
477
+ var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
478
+ function q(c, a, g) {
479
+ var b, d = {}, e = null, h = null;
480
+ g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
481
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
482
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
483
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
471
484
  }
472
- B.Fragment = qt;
473
- B.jsx = Ee;
474
- B.jsxs = Ee;
475
- Te.exports = B;
476
- var c = Te.exports;
477
- const Ne = {
485
+ __name(q, "q");
486
+ reactJsxRuntime_production_min.Fragment = l;
487
+ reactJsxRuntime_production_min.jsx = q;
488
+ reactJsxRuntime_production_min.jsxs = q;
489
+ jsxRuntime.exports = reactJsxRuntime_production_min;
490
+ var jsxRuntimeExports = jsxRuntime.exports;
491
+ const ReplaceCurrentMatchCommand = {
478
492
  id: "ui.command.replace-current-match",
479
- type: y.COMMAND,
480
- handler: (t) => t.get(g).replace()
481
- }, Zt = "CONFIRM_REPLACE_ALL", $e = {
493
+ type: CommandType.COMMAND,
494
+ handler: /* @__PURE__ */ __name((accessor) => accessor.get(IFindReplaceService).replace(), "handler")
495
+ }, CONFIRM_REPLACE_ALL_ID = "CONFIRM_REPLACE_ALL", ReplaceAllMatchesCommand = {
482
496
  id: "ui.command.replace-all-matches",
483
- type: y.COMMAND,
484
- handler: async (t) => {
485
- const e = t.get(gt), n = t.get(O), i = t.get(me);
486
- if (!await e.confirm({
487
- id: Zt,
488
- title: { title: n.t("find-replace.replace.confirm.title") },
489
- cancelText: n.t("button.cancel"),
490
- confirmText: n.t("button.confirm")
497
+ type: CommandType.COMMAND,
498
+ handler: /* @__PURE__ */ __name(async (accessor) => {
499
+ const confirmService = accessor.get(IConfirmService), localeService = accessor.get(LocaleService), messageService = accessor.get(IMessageService);
500
+ if (!await confirmService.confirm({
501
+ id: CONFIRM_REPLACE_ALL_ID,
502
+ title: { title: localeService.t("find-replace.replace.confirm.title") },
503
+ cancelText: localeService.t("button.cancel"),
504
+ confirmText: localeService.t("button.confirm")
491
505
  }))
492
506
  return !1;
493
- const s = await t.get(g).replaceAll(), { success: a, failure: l } = s;
494
- return l > 0 ? (a === 0 ? i.show({
495
- type: $.Error,
496
- content: n.t("find-replace.replace.all-failure")
497
- }) : i.show({
498
- type: $.Warning,
499
- content: n.t("find-replace.replace.partial-success", `${a}`, `${l}`)
500
- }), !1) : (i.show({
501
- type: $.Success,
502
- content: n.t("find-replace.replace.all-success", `${a}`)
507
+ const result = await accessor.get(IFindReplaceService).replaceAll(), { success, failure } = result;
508
+ return failure > 0 ? (success === 0 ? messageService.show({
509
+ type: MessageType.Error,
510
+ content: localeService.t("find-replace.replace.all-failure")
511
+ }) : messageService.show({
512
+ type: MessageType.Warning,
513
+ content: localeService.t("find-replace.replace.partial-success", `${success}`, `${failure}`)
514
+ }), !1) : (messageService.show({
515
+ type: MessageType.Success,
516
+ content: localeService.t("find-replace.replace.all-success", `${success}`)
503
517
  }), !0);
504
- }
518
+ }, "handler")
505
519
  };
506
- function Ae(t) {
507
- const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition: r, findString: s, findReplaceService: a, onChange: l, ...d } = t, f = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
508
- return /* @__PURE__ */ c.jsx(
509
- Et,
520
+ function SearchInput(props) {
521
+ const { findCompleted: findComplete, localeService, matchesCount, matchesPosition, findString, findReplaceService, onChange, ...rest } = props, text = findComplete && matchesCount === 0 ? localeService.t("find-replace.dialog.no-result") : matchesCount === 0 ? " " : void 0;
522
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
523
+ InputWithSlot,
510
524
  {
511
525
  autoFocus: !0,
512
- placeholder: n.t("find-replace.dialog.find-placeholder"),
513
- slot: /* @__PURE__ */ c.jsx(
514
- Nt,
526
+ placeholder: localeService.t("find-replace.dialog.find-placeholder"),
527
+ slot: /* @__PURE__ */ jsxRuntimeExports.jsx(
528
+ Pager,
515
529
  {
516
530
  loop: !0,
517
- text: f,
518
- value: r,
519
- total: i,
520
- onChange: (p) => {
521
- r === i && p === 1 ? a.moveToNextMatch() : r === 1 && p === i || p < r ? a.moveToPreviousMatch() : a.moveToNextMatch();
522
- }
531
+ text,
532
+ value: matchesPosition,
533
+ total: matchesCount,
534
+ onChange: /* @__PURE__ */ __name((newIndex) => {
535
+ matchesPosition === matchesCount && newIndex === 1 ? findReplaceService.moveToNextMatch() : matchesPosition === 1 && newIndex === matchesCount || newIndex < matchesPosition ? findReplaceService.moveToPreviousMatch() : findReplaceService.moveToNextMatch();
536
+ }, "onChange")
523
537
  }
524
538
  ),
525
- value: s,
526
- onChange: (p) => l == null ? void 0 : l(p),
527
- ...d
539
+ value: findString,
540
+ onChange: /* @__PURE__ */ __name((value) => onChange == null ? void 0 : onChange(value), "onChange"),
541
+ ...rest
528
542
  }
529
543
  );
530
544
  }
531
- const Jt = "univer-find-replace-dialog-container", Qt = "univer-find-replace-expand-container", Xt = "univer-button-text", ei = "univer-find-replace-buttons-group", ti = "univer-find-replace-buttons-group-right", L = {
532
- findReplaceDialogContainer: Jt,
533
- findReplaceExpandContainer: Qt,
534
- buttonText: Xt,
535
- findReplaceButtonsGroup: ei,
536
- findReplaceButtonsGroupRight: ti
545
+ __name(SearchInput, "SearchInput");
546
+ const findReplaceDialogContainer = "univer-find-replace-dialog-container", findReplaceExpandContainer = "univer-find-replace-expand-container", buttonText = "univer-button-text", findReplaceButtonsGroup = "univer-find-replace-buttons-group", findReplaceButtonsGroupRight = "univer-find-replace-buttons-group-right", styles = {
547
+ findReplaceDialogContainer,
548
+ findReplaceExpandContainer,
549
+ buttonText,
550
+ findReplaceButtonsGroup,
551
+ findReplaceButtonsGroupRight
537
552
  };
538
- function je(t, e) {
539
- const n = u(() => {
540
- var r;
541
- (r = document.querySelector(".univer-find-input input")) == null || r.focus();
542
- }, []), i = u(() => {
543
- const r = document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");
544
- return Array.from(r).some((s) => s === document.activeElement);
553
+ function useFindInputFocus(findReplaceService, ref) {
554
+ const focus = useCallback(() => {
555
+ var _a5;
556
+ (_a5 = document.querySelector(".univer-find-input input")) == null || _a5.focus();
557
+ }, []), selectHasFocus = useCallback(() => {
558
+ const allInputs = document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");
559
+ return Array.from(allInputs).some((input) => input === document.activeElement);
545
560
  }, []);
546
- return Tt(e, () => ({ focus: n, selectHasFocus: i })), j(() => {
547
- const r = t.focusSignal$.subscribe(() => n());
548
- return () => r.unsubscribe();
549
- }, [t, n]), { focus: n, selectHasFocus: i };
561
+ return useImperativeHandle(ref, () => ({ focus, selectHasFocus })), useEffect(() => {
562
+ const subscription = findReplaceService.focusSignal$.subscribe(() => focus());
563
+ return () => subscription.unsubscribe();
564
+ }, [findReplaceService, focus]), { focus, selectHasFocus };
550
565
  }
551
- const ii = w(function(e, n) {
552
- const i = v(O), r = v(g), s = v(ie), a = I(r.state$, void 0, !0), { findCompleted: l, findString: d, matchesCount: S, matchesPosition: f } = a, p = u(() => {
553
- s.executeCommand(se.id);
554
- }, [s]), T = u((C) => r.changeFindString(C), [r]);
555
- return je(r, n), /* @__PURE__ */ c.jsxs(N, { children: [
556
- /* @__PURE__ */ c.jsx(
557
- Ae,
566
+ __name(useFindInputFocus, "useFindInputFocus");
567
+ const FindDialog = forwardRef(/* @__PURE__ */ __name(function(_props, ref) {
568
+ const localeService = useDependency(LocaleService), findReplaceService = useDependency(IFindReplaceService), commandService = useDependency(ICommandService), state = useObservable(findReplaceService.state$, void 0, !0), { findCompleted, findString, matchesCount, matchesPosition } = state, revealReplace = useCallback(() => {
569
+ commandService.executeCommand(OpenReplaceDialogOperation.id);
570
+ }, [commandService]), onFindStringChange = useCallback((findString2) => findReplaceService.changeFindString(findString2), [findReplaceService]);
571
+ return useFindInputFocus(findReplaceService, ref), /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
572
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
573
+ SearchInput,
558
574
  {
559
- findCompleted: l,
575
+ findCompleted,
560
576
  className: "univer-find-input",
561
- matchesCount: S,
562
- matchesPosition: f,
563
- findReplaceService: r,
564
- localeService: i,
565
- findString: d,
566
- onChange: T
577
+ matchesCount,
578
+ matchesPosition,
579
+ findReplaceService,
580
+ localeService,
581
+ findString,
582
+ onChange: onFindStringChange
567
583
  }
568
584
  ),
569
- /* @__PURE__ */ c.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ c.jsx(A, { type: "text", size: "small", onClick: p, children: i.t("find-replace.dialog.advanced-finding") }) })
585
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.findReplaceExpandContainer, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: revealReplace, children: localeService.t("find-replace.dialog.advanced-finding") }) })
570
586
  ] });
571
- }), ni = w(function(e, n) {
572
- const i = v(g), r = v(O), s = v(ie), a = v(me), l = I(i.currentMatch$, void 0, !0), d = I(i.replaceables$, void 0, !0), S = I(i.state$, void 0, !0), {
573
- matchesCount: f,
574
- matchesPosition: p,
575
- findString: T,
576
- inputtingFindString: C,
577
- replaceString: Ue,
578
- caseSensitive: Be,
579
- matchesTheWholeCell: We,
580
- findDirection: ke,
581
- findScope: Ge,
582
- findBy: Ve,
583
- findCompleted: k
584
- } = S, He = C.length === 0, qe = f === 0 || !(l != null && l.replaceable), ze = d.length === 0, Ke = u(
585
- (h) => i.changeInputtingFindString(h),
586
- [i]
587
- ), Ye = u(
588
- (h) => i.changeReplaceString(h),
589
- [i]
590
- ), { focus: Ze } = je(i, n), Je = u(() => {
591
- T === C ? i.moveToNextMatch() : (i.changeFindString(C), i.find());
592
- }, [T, C, i]), Qe = u(() => s.executeCommand(Ne.id), [s]), Xe = u(async () => {
593
- await s.executeCommand($e.id), Ze();
594
- }, [s]), et = u((h) => {
595
- i.changeFindDirection(h);
596
- }, [i]), tt = u((h) => {
597
- i.changeFindScope(h);
598
- }, [i]), it = u((h) => {
599
- i.changeFindBy(h);
600
- }, [i]), nt = si(r), rt = ai(r), st = oi(r);
601
- return j(() => {
602
- const h = k && f === 0;
603
- let E = null;
604
- return h && (E = a.show({
605
- content: r.t("find-replace.dialog.no-match"),
606
- type: $.Warning,
587
+ }, "FindDialogImpl")), ReplaceDialog = forwardRef(/* @__PURE__ */ __name(function(_props, ref) {
588
+ const findReplaceService = useDependency(IFindReplaceService), localeService = useDependency(LocaleService), commandService = useDependency(ICommandService), messageService = useDependency(IMessageService), currentMatch = useObservable(findReplaceService.currentMatch$, void 0, !0), replaceables = useObservable(findReplaceService.replaceables$, void 0, !0), state = useObservable(findReplaceService.state$, void 0, !0), {
589
+ matchesCount,
590
+ matchesPosition,
591
+ findString,
592
+ inputtingFindString,
593
+ replaceString,
594
+ caseSensitive,
595
+ matchesTheWholeCell,
596
+ findDirection,
597
+ findScope,
598
+ findBy,
599
+ findCompleted
600
+ } = state, findDisabled = inputtingFindString.length === 0, replaceDisabled = matchesCount === 0 || !(currentMatch != null && currentMatch.replaceable), replaceAllDisabled = replaceables.length === 0, onFindStringChange = useCallback(
601
+ (newValue) => findReplaceService.changeInputtingFindString(newValue),
602
+ [findReplaceService]
603
+ ), onReplaceStringChange = useCallback(
604
+ (replaceString2) => findReplaceService.changeReplaceString(replaceString2),
605
+ [findReplaceService]
606
+ ), { focus } = useFindInputFocus(findReplaceService, ref), onClickFindButton = useCallback(() => {
607
+ findString === inputtingFindString ? findReplaceService.moveToNextMatch() : (findReplaceService.changeFindString(inputtingFindString), findReplaceService.find());
608
+ }, [findString, inputtingFindString, findReplaceService]), onClickReplaceButton = useCallback(() => commandService.executeCommand(ReplaceCurrentMatchCommand.id), [commandService]), onClickReplaceAllButton = useCallback(async () => {
609
+ await commandService.executeCommand(ReplaceAllMatchesCommand.id), focus();
610
+ }, [commandService]), onChangeFindDirection = useCallback((findDirection2) => {
611
+ findReplaceService.changeFindDirection(findDirection2);
612
+ }, [findReplaceService]), onChangeFindScope = useCallback((findScope2) => {
613
+ findReplaceService.changeFindScope(findScope2);
614
+ }, [findReplaceService]), onChangeFindBy = useCallback((findBy2) => {
615
+ findReplaceService.changeFindBy(findBy2);
616
+ }, [findReplaceService]), findScopeOptions = useFindScopeOptions(localeService), findDirectionOptions = useFindDirectionOptions(localeService), findByOptions = useFindByOptions(localeService);
617
+ return useEffect(() => {
618
+ const shouldDisplayNoMatchInfo = findCompleted && matchesCount === 0;
619
+ let messageDisposable = null;
620
+ return shouldDisplayNoMatchInfo && (messageDisposable = messageService.show({
621
+ content: localeService.t("find-replace.dialog.no-match"),
622
+ type: MessageType.Warning,
607
623
  duration: 5e3
608
- })), () => E == null ? void 0 : E.dispose();
609
- }, [k, f, a, r]), /* @__PURE__ */ c.jsxs(N, { children: [
610
- /* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find"), children: /* @__PURE__ */ c.jsx(
611
- Ae,
624
+ })), () => messageDisposable == null ? void 0 : messageDisposable.dispose();
625
+ }, [findCompleted, matchesCount, messageService, localeService]), /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
626
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("find-replace.dialog.find"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
627
+ SearchInput,
612
628
  {
613
- findCompleted: k,
629
+ findCompleted,
614
630
  className: "univer-find-input",
615
- matchesCount: f,
616
- matchesPosition: p,
617
- findReplaceService: i,
618
- localeService: r,
619
- findString: C,
620
- onChange: Ke
631
+ matchesCount,
632
+ matchesPosition,
633
+ findReplaceService,
634
+ localeService,
635
+ findString: inputtingFindString,
636
+ onChange: onFindStringChange
621
637
  }
622
638
  ) }),
623
- /* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.replace"), children: /* @__PURE__ */ c.jsx(
624
- $t,
639
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("find-replace.dialog.replace"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
640
+ Input,
625
641
  {
626
- placeholder: r.t("find-replace.dialog.replace-placeholder"),
627
- value: Ue,
628
- onChange: (h) => Ye(h)
642
+ placeholder: localeService.t("find-replace.dialog.replace-placeholder"),
643
+ value: replaceString,
644
+ onChange: /* @__PURE__ */ __name((value) => onReplaceStringChange(value), "onChange")
629
645
  }
630
646
  ) }),
631
- /* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ c.jsx(G, { value: ke, options: rt, onChange: et }) }),
632
- /* @__PURE__ */ c.jsx(le, { children: /* @__PURE__ */ c.jsxs(N, { children: [
633
- /* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ c.jsx(G, { value: Ge, options: nt, onChange: tt }) }),
634
- /* @__PURE__ */ c.jsx(R, { label: r.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ c.jsx(G, { value: Ve, options: st, onChange: it }) })
647
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { value: findDirection, options: findDirectionOptions, onChange: onChangeFindDirection }) }),
648
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormDualColumnLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
649
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { value: findScope, options: findScopeOptions, onChange: onChangeFindScope }) }),
650
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { value: findBy, options: findByOptions, onChange: onChangeFindBy }) })
635
651
  ] }) }),
636
- /* @__PURE__ */ c.jsx(le, { children: /* @__PURE__ */ c.jsxs(N, { children: [
637
- /* @__PURE__ */ c.jsx(R, { children: /* @__PURE__ */ c.jsx(
638
- de,
652
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormDualColumnLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
653
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
654
+ Checkbox,
639
655
  {
640
- checked: Be,
641
- onChange: (h) => {
642
- i.changeCaseSensitive(h);
643
- },
644
- children: r.t("find-replace.dialog.case-sensitive")
656
+ checked: caseSensitive,
657
+ onChange: /* @__PURE__ */ __name((checked) => {
658
+ findReplaceService.changeCaseSensitive(checked);
659
+ }, "onChange"),
660
+ children: localeService.t("find-replace.dialog.case-sensitive")
645
661
  }
646
662
  ) }),
647
- /* @__PURE__ */ c.jsx(R, { children: /* @__PURE__ */ c.jsx(
648
- de,
663
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
664
+ Checkbox,
649
665
  {
650
- checked: We,
651
- onChange: (h) => {
652
- i.changeMatchesTheWholeCell(h);
653
- },
654
- children: r.t("find-replace.dialog.match-the-whole-cell")
666
+ checked: matchesTheWholeCell,
667
+ onChange: /* @__PURE__ */ __name((checked) => {
668
+ findReplaceService.changeMatchesTheWholeCell(checked);
669
+ }, "onChange"),
670
+ children: localeService.t("find-replace.dialog.match-the-whole-cell")
655
671
  }
656
672
  ) })
657
673
  ] }) }),
658
- /* @__PURE__ */ c.jsxs("div", { className: L.findReplaceButtonsGroup, children: [
659
- /* @__PURE__ */ c.jsx(A, { type: "primary", onClick: Je, disabled: He, children: r.t("find-replace.dialog.find") }),
660
- /* @__PURE__ */ c.jsxs("span", { className: L.findReplaceButtonsGroupRight, children: [
661
- /* @__PURE__ */ c.jsx(A, { disabled: qe, onClick: Qe, children: r.t("find-replace.dialog.replace") }),
662
- /* @__PURE__ */ c.jsx(A, { disabled: ze, onClick: Xe, children: r.t("find-replace.dialog.replace-all") })
674
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.findReplaceButtonsGroup, children: [
675
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "primary", onClick: onClickFindButton, disabled: findDisabled, children: localeService.t("find-replace.dialog.find") }),
676
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: styles.findReplaceButtonsGroupRight, children: [
677
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: replaceDisabled, onClick: onClickReplaceButton, children: localeService.t("find-replace.dialog.replace") }),
678
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: replaceAllDisabled, onClick: onClickReplaceAllButton, children: localeService.t("find-replace.dialog.replace-all") })
663
679
  ] })
664
680
  ] })
665
681
  ] });
666
- });
667
- function ri() {
668
- const t = v(g), e = v(ve), n = v(te), i = I(t.state$, void 0, !0), r = q(null);
669
- j(() => {
670
- let d;
671
- return r.current && (d = e.registerContainerElement(r.current)), () => d == null ? void 0 : d.dispose();
672
- }, [e]);
673
- const s = q(null), a = u(
674
- (d) => n.setContextValue(Ie, d),
675
- [n]
676
- ), l = u(
677
- (d) => n.setContextValue(ye, d),
678
- [n]
682
+ }, "ReplaceDIalogImpl"));
683
+ function FindReplaceDialog() {
684
+ const findReplaceService = useDependency(IFindReplaceService), layoutService = useDependency(ILayoutService), contextService = useDependency(IContextService), state = useObservable(findReplaceService.state$, void 0, !0), dialogContainerRef = useRef(null);
685
+ useEffect(() => {
686
+ let disposable;
687
+ return dialogContainerRef.current && (disposable = layoutService.registerContainerElement(dialogContainerRef.current)), () => disposable == null ? void 0 : disposable.dispose();
688
+ }, [layoutService]);
689
+ const focusRef = useRef(null), setDialogContainerFocus = useCallback(
690
+ (focused) => contextService.setContextValue(FIND_REPLACE_DIALOG_FOCUS, focused),
691
+ [contextService]
692
+ ), setDialogInputFocus = useCallback(
693
+ (focused) => contextService.setContextValue(FIND_REPLACE_INPUT_FOCUS, focused),
694
+ [contextService]
679
695
  );
680
- return j(() => {
681
- var S;
682
- const d = Ft(document, "focusin").subscribe((f) => {
683
- var p;
684
- f.target && ((p = r.current) != null && p.contains(f.target)) ? a(!0) : a(!1), !s.current || !s.current.selectHasFocus() ? l(!0) : l(!1);
696
+ return useEffect(() => {
697
+ var _a5;
698
+ const focusSubscription = fromEvent(document, "focusin").subscribe((event) => {
699
+ var _a6;
700
+ event.target && ((_a6 = dialogContainerRef.current) != null && _a6.contains(event.target)) ? setDialogContainerFocus(!0) : setDialogContainerFocus(!1), !focusRef.current || !focusRef.current.selectHasFocus() ? setDialogInputFocus(!0) : setDialogInputFocus(!1);
685
701
  });
686
- return (S = s.current) == null || S.focus(), a(!0), l(!0), () => {
687
- d.unsubscribe(), a(!1);
702
+ return (_a5 = focusRef.current) == null || _a5.focus(), setDialogContainerFocus(!0), setDialogInputFocus(!0), () => {
703
+ focusSubscription.unsubscribe(), setDialogContainerFocus(!1);
688
704
  };
689
- }, [a, l]), /* @__PURE__ */ c.jsx("div", { className: L.findReplaceDialogContainer, ref: r, children: i.replaceRevealed ? /* @__PURE__ */ c.jsx(ni, { ref: s }) : /* @__PURE__ */ c.jsx(ii, { ref: s }) });
705
+ }, [setDialogContainerFocus, setDialogInputFocus]), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.findReplaceDialogContainer, ref: dialogContainerRef, children: state.replaceRevealed ? /* @__PURE__ */ jsxRuntimeExports.jsx(ReplaceDialog, { ref: focusRef }) : /* @__PURE__ */ jsxRuntimeExports.jsx(FindDialog, { ref: focusRef }) });
690
706
  }
691
- function si(t) {
692
- const e = t.getCurrentLocale();
693
- return ne(() => [
694
- { label: t.t("find-replace.dialog.find-scope.current-sheet"), value: J.SUBUNIT },
695
- { label: t.t("find-replace.dialog.find-scope.workbook"), value: J.UNIT }
696
- ], [e]);
707
+ __name(FindReplaceDialog, "FindReplaceDialog");
708
+ function useFindScopeOptions(localeService) {
709
+ const locale = localeService.getCurrentLocale();
710
+ return useMemo(() => [
711
+ { label: localeService.t("find-replace.dialog.find-scope.current-sheet"), value: FindScope.SUBUNIT },
712
+ { label: localeService.t("find-replace.dialog.find-scope.workbook"), value: FindScope.UNIT }
713
+ ], [locale]);
697
714
  }
698
- function ai(t) {
699
- const e = t.getCurrentLocale();
700
- return ne(() => [
701
- { label: t.t("find-replace.dialog.find-direction.row"), value: Y.ROW },
702
- { label: t.t("find-replace.dialog.find-direction.column"), value: Y.COLUMN }
703
- ], [e]);
715
+ __name(useFindScopeOptions, "useFindScopeOptions");
716
+ function useFindDirectionOptions(localeService) {
717
+ const locale = localeService.getCurrentLocale();
718
+ return useMemo(() => [
719
+ { label: localeService.t("find-replace.dialog.find-direction.row"), value: FindDirection.ROW },
720
+ { label: localeService.t("find-replace.dialog.find-direction.column"), value: FindDirection.COLUMN }
721
+ ], [locale]);
704
722
  }
705
- function oi(t) {
706
- const e = t.getCurrentLocale();
707
- return ne(() => [
708
- { label: t.t("find-replace.dialog.find-by.value"), value: Z.VALUE },
709
- { label: t.t("find-replace.dialog.find-by.formula"), value: Z.FORMULA }
710
- ], [e]);
723
+ __name(useFindDirectionOptions, "useFindDirectionOptions");
724
+ function useFindByOptions(localeService) {
725
+ const locale = localeService.getCurrentLocale();
726
+ return useMemo(() => [
727
+ { label: localeService.t("find-replace.dialog.find-by.value"), value: FindBy.VALUE },
728
+ { label: localeService.t("find-replace.dialog.find-by.formula"), value: FindBy.FORMULA }
729
+ ], [locale]);
711
730
  }
712
- function P(t) {
713
- return t.getContextValue(Ie);
731
+ __name(useFindByOptions, "useFindByOptions");
732
+ function whenFindReplaceDialogFocused(contextService) {
733
+ return contextService.getContextValue(FIND_REPLACE_DIALOG_FOCUS);
714
734
  }
715
- function ci(t) {
716
- return t.getContextValue(Fe);
735
+ __name(whenFindReplaceDialogFocused, "whenFindReplaceDialogFocused");
736
+ function whenReplaceRevealed(contextService) {
737
+ return contextService.getContextValue(FIND_REPLACE_REPLACE_REVEALED);
717
738
  }
718
- function Le(t) {
719
- return t.getContextValue(ye);
739
+ __name(whenReplaceRevealed, "whenReplaceRevealed");
740
+ function whenFindReplaceInputFocused(contextService) {
741
+ return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS);
720
742
  }
721
- const W = "7_find-replace-shortcuts";
722
- function ae(t) {
723
- return t.getContextValue(_e);
743
+ __name(whenFindReplaceInputFocused, "whenFindReplaceInputFocused");
744
+ const FIND_REPLACE_SHORTCUT_GROUP = "7_find-replace-shortcuts";
745
+ function whenSheetFocused(contextService) {
746
+ return contextService.getContextValue(FOCUSING_SHEET);
724
747
  }
725
- function oe(t) {
726
- return !t.getContextValue(ge);
748
+ __name(whenSheetFocused, "whenSheetFocused");
749
+ function whenEditorNotActivated(contextService) {
750
+ return !contextService.getContextValue(EDITOR_ACTIVATED);
727
751
  }
728
- const li = {
729
- id: U.id,
752
+ __name(whenEditorNotActivated, "whenEditorNotActivated");
753
+ const OpenFindDialogShortcutItem = {
754
+ id: OpenFindDialogOperation.id,
730
755
  description: "find-replace.shortcut.open-find-dialog",
731
- binding: M.F | x.CTRL_COMMAND,
732
- group: W,
733
- preconditions(t) {
734
- return !P(t) && ae(t) && oe(t);
756
+ binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
757
+ group: FIND_REPLACE_SHORTCUT_GROUP,
758
+ preconditions(contextService) {
759
+ return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
735
760
  }
736
- }, di = {
737
- id: U.id,
761
+ }, MacOpenFindDialogShortcutItem = {
762
+ id: OpenFindDialogOperation.id,
738
763
  description: "find-replace.shortcut.open-find-dialog",
739
- binding: M.F | x.CTRL_COMMAND,
740
- mac: M.F | x.MAC_CTRL,
741
- preconditions(t) {
742
- return !P(t) && ae(t) && oe(t);
764
+ binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
765
+ mac: KeyCode.F | MetaKeys.MAC_CTRL,
766
+ preconditions(contextService) {
767
+ return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
743
768
  }
744
- }, hi = {
745
- id: se.id,
769
+ }, OpenReplaceDialogShortcutItem = {
770
+ id: OpenReplaceDialogOperation.id,
746
771
  description: "find-replace.shortcut.open-replace-dialog",
747
- binding: M.H | x.CTRL_COMMAND,
748
- mac: M.H | x.MAC_CTRL,
749
- group: W,
750
- preconditions(t) {
751
- return ae(t) && oe(t) && (!P(t) || !ci(t));
752
- }
753
- }, ui = {
754
- id: Oe.id,
772
+ binding: KeyCode.H | MetaKeys.CTRL_COMMAND,
773
+ mac: KeyCode.H | MetaKeys.MAC_CTRL,
774
+ group: FIND_REPLACE_SHORTCUT_GROUP,
775
+ preconditions(contextService) {
776
+ return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
777
+ }
778
+ }, GoToNextFindMatchShortcutItem = {
779
+ id: GoToNextMatchOperation.id,
755
780
  description: "find-replace.shortcut.go-to-next-match",
756
- binding: M.ENTER,
757
- group: W,
781
+ binding: KeyCode.ENTER,
782
+ group: FIND_REPLACE_SHORTCUT_GROUP,
758
783
  priority: 1e3,
759
- preconditions(t) {
760
- return Le(t) && P(t);
784
+ preconditions(contextService) {
785
+ return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
761
786
  }
762
- }, fi = {
763
- id: Pe.id,
787
+ }, GoToPreviousFindMatchShortcutItem = {
788
+ id: GoToPreviousMatchOperation.id,
764
789
  description: "find-replace.shortcut.go-to-previous-match",
765
- binding: M.ENTER | x.SHIFT,
766
- group: W,
790
+ binding: KeyCode.ENTER | MetaKeys.SHIFT,
791
+ group: FIND_REPLACE_SHORTCUT_GROUP,
767
792
  priority: 1e3,
768
- preconditions(t) {
769
- return Le(t) && P(t);
793
+ preconditions(contextService) {
794
+ return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
770
795
  }
771
796
  };
772
- function pi(t) {
773
- const e = t.get(te);
797
+ function FindReplaceMenuItemFactory(accessor) {
798
+ const contextService = accessor.get(IContextService);
774
799
  return {
775
- id: U.id,
800
+ id: OpenFindDialogOperation.id,
776
801
  icon: "SearchIcon",
777
802
  tooltip: "find-replace.toolbar",
778
- group: mt.TOOLBAR_OTHERS,
779
- type: vt.BUTTON,
780
- positions: [St.TOOLBAR_START],
781
- hidden$: Ct(t, dt.UNIVER_SHEET),
782
- disabled$: Ce([
783
- e.subscribeContextValue$(ge),
784
- e.subscribeContextValue$(_e)
785
- ]).pipe(Dt(([n, i]) => n || !i))
803
+ group: MenuGroup.TOOLBAR_OTHERS,
804
+ type: MenuItemType.BUTTON,
805
+ positions: [MenuPosition.TOOLBAR_START],
806
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
807
+ disabled$: combineLatest([
808
+ contextService.subscribeContextValue$(EDITOR_ACTIVATED),
809
+ contextService.subscribeContextValue$(FOCUSING_SHEET)
810
+ ]).pipe(map(([editorActivated, focusingSheet]) => editorActivated || !focusingSheet))
786
811
  };
787
812
  }
788
- var _i = Object.defineProperty, gi = Object.getOwnPropertyDescriptor, mi = (t, e, n, i) => {
789
- for (var r = i > 1 ? void 0 : i ? gi(e, n) : e, s = t.length - 1, a; s >= 0; s--)
790
- (a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
791
- return i && r && _i(e, n, r), r;
792
- }, m = (t, e) => (n, i) => e(n, i, t);
793
- const vi = {}, he = "DESKTOP_FIND_REPLACE_DIALOG", we = 350, Si = 20, Ci = -90;
794
- let F = class extends ht {
795
- constructor(t, e, n, i, r, s, a, l, d, S, f) {
796
- super(), this._config = t, this._univerInstanceService = e, this._menuService = n, this._shortcutService = i, this._commandService = r, this._findReplaceService = s, this._dialogService = a, this._layoutService = l, this._localeService = d, this._componentManager = S, this._injector = f, this._initCommands(), this._initUI(), this._initShortcuts();
813
+ __name(FindReplaceMenuItemFactory, "FindReplaceMenuItemFactory");
814
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
815
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
816
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
817
+ return kind && result && __defProp$1(target, key, result), result;
818
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
819
+ const DefaultFindReplaceConfig = {}, FIND_REPLACE_DIALOG_ID = "DESKTOP_FIND_REPLACE_DIALOG", FIND_REPLACE_PANEL_WIDTH = 350, FIND_REPLACE_PANEL_RIGHT_PADDING = 20, FIND_REPLACE_PANEL_TOP_PADDING = -90;
820
+ var _a3;
821
+ let FindReplaceController = (_a3 = class extends RxDisposable {
822
+ constructor(_config, _univerInstanceService, _menuService, _shortcutService, _commandService, _findReplaceService, _dialogService, _layoutService, _localeService, _componentManager, _injector) {
823
+ super();
824
+ __publicField(this, "_closingListenerDisposable");
825
+ this._config = _config, this._univerInstanceService = _univerInstanceService, this._menuService = _menuService, this._shortcutService = _shortcutService, this._commandService = _commandService, this._findReplaceService = _findReplaceService, this._dialogService = _dialogService, this._layoutService = _layoutService, this._localeService = _localeService, this._componentManager = _componentManager, this._injector = _injector, this._initCommands(), this._initUI(), this._initShortcuts();
826
+ }
827
+ dispose() {
828
+ var _a5;
829
+ super.dispose(), (_a5 = this._closingListenerDisposable) == null || _a5.dispose(), this._closingListenerDisposable = null;
797
830
  }
798
831
  _initCommands() {
799
832
  [
800
- U,
801
- se,
802
- Oe,
803
- Pe,
804
- $e,
805
- Ne
806
- ].forEach((t) => {
807
- this.disposeWithMe(this._commandService.registerCommand(t));
833
+ OpenFindDialogOperation,
834
+ OpenReplaceDialogOperation,
835
+ GoToNextMatchOperation,
836
+ GoToPreviousMatchOperation,
837
+ ReplaceAllMatchesCommand,
838
+ ReplaceCurrentMatchCommand
839
+ ].forEach((c) => {
840
+ this.disposeWithMe(this._commandService.registerCommand(c));
808
841
  });
809
842
  }
810
843
  _initShortcuts() {
811
844
  [
812
- hi,
813
- li,
814
- di,
815
- fi,
816
- ui
817
- ].forEach((t) => this.disposeWithMe(this._shortcutService.registerShortcut(t)));
845
+ OpenReplaceDialogShortcutItem,
846
+ OpenFindDialogShortcutItem,
847
+ MacOpenFindDialogShortcutItem,
848
+ GoToPreviousFindMatchShortcutItem,
849
+ GoToNextFindMatchShortcutItem
850
+ ].forEach((s) => this.disposeWithMe(this._shortcutService.registerShortcut(s)));
818
851
  }
819
852
  _initUI() {
820
- const { menu: t = {} } = this._config;
821
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(pi), t)), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", ri)), this.disposeWithMe(this._componentManager.register("SearchIcon", xe)), this._findReplaceService.stateUpdates$.pipe(ce(this.dispose$)).subscribe((e) => {
822
- e.revealed === !0 && this._openPanel();
823
- }), this.disposeWithMe(
824
- this._univerInstanceService.focused$.pipe(ce(this.dispose$)).subscribe((e) => {
825
- (!e || !this._univerInstanceService.getUniverSheetInstance(e)) && this.closePanel();
826
- })
827
- );
853
+ const { menu = {} } = this._config;
854
+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(FindReplaceMenuItemFactory), menu)), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", FindReplaceDialog)), this.disposeWithMe(this._componentManager.register("SearchIcon", SearchSingle16)), this._findReplaceService.stateUpdates$.pipe(takeUntil(this.dispose$)).subscribe((newState) => {
855
+ newState.revealed === !0 && this._openPanel();
856
+ });
828
857
  }
829
858
  _openPanel() {
830
859
  this._dialogService.open({
831
- id: he,
860
+ id: FIND_REPLACE_DIALOG_ID,
832
861
  draggable: !0,
833
- width: we,
862
+ width: FIND_REPLACE_PANEL_WIDTH,
834
863
  title: { title: this._localeService.t("find-replace.dialog.title") },
835
864
  children: { label: "FindReplaceDialog" },
836
865
  destroyOnClose: !0,
837
- defaultPosition: Ri(),
866
+ defaultPosition: getFindReplaceDialogDefaultPosition(),
838
867
  preservePositionOnDestroy: !0,
839
- onClose: () => this.closePanel()
840
- });
868
+ onClose: /* @__PURE__ */ __name(() => this.closePanel(), "onClose")
869
+ }), this._closingListenerDisposable = toDisposable(this._univerInstanceService.focused$.pipe(takeUntil(this.dispose$)).subscribe((focused) => {
870
+ (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) && this.closePanel();
871
+ }));
841
872
  }
842
873
  closePanel() {
843
- this._dialogService.close(he), this._findReplaceService.terminate(), queueMicrotask(() => this._layoutService.focus());
844
- }
845
- };
846
- F = mi([
847
- ut(ft.Rendered, F),
848
- m(1, pe),
849
- m(2, Mt),
850
- m(3, bt),
851
- m(4, ie),
852
- m(5, g),
853
- m(6, xt),
854
- m(7, ve),
855
- m(8, b(O)),
856
- m(9, b(Rt)),
857
- m(10, b(ee))
858
- ], F);
859
- function Ri() {
860
- const { innerWidth: t } = window;
861
- return { x: (t - we) / 2 - Si, y: Ci };
874
+ this._closingListenerDisposable && (this._closingListenerDisposable.dispose(), this._closingListenerDisposable = null, this._dialogService.close(FIND_REPLACE_DIALOG_ID), this._findReplaceService.terminate(), queueMicrotask(() => this._layoutService.focus()));
875
+ }
876
+ }, __name(_a3, "FindReplaceController"), _a3);
877
+ FindReplaceController = __decorateClass$1([
878
+ OnLifecycle(LifecycleStages.Rendered, FindReplaceController),
879
+ __decorateParam$1(1, IUniverInstanceService),
880
+ __decorateParam$1(2, IMenuService),
881
+ __decorateParam$1(3, IShortcutService),
882
+ __decorateParam$1(4, ICommandService),
883
+ __decorateParam$1(5, IFindReplaceService),
884
+ __decorateParam$1(6, IDialogService),
885
+ __decorateParam$1(7, ILayoutService),
886
+ __decorateParam$1(8, Inject(LocaleService)),
887
+ __decorateParam$1(9, Inject(ComponentManager)),
888
+ __decorateParam$1(10, Inject(Injector))
889
+ ], FindReplaceController);
890
+ function getFindReplaceDialogDefaultPosition() {
891
+ const { innerWidth } = window;
892
+ return { x: (innerWidth - FIND_REPLACE_PANEL_WIDTH) / 2 - FIND_REPLACE_PANEL_RIGHT_PADDING, y: FIND_REPLACE_PANEL_TOP_PADDING };
862
893
  }
863
- var Mi = Object.defineProperty, bi = Object.getOwnPropertyDescriptor, xi = (t, e, n, i) => {
864
- for (var r = i > 1 ? void 0 : i ? bi(e, n) : e, s = t.length - 1, a; s >= 0; s--)
865
- (a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
866
- return i && r && Mi(e, n, r), r;
867
- }, ue = (t, e) => (n, i) => e(n, i, t);
868
- const yi = "FIND_REPLACE_PLUGIN";
869
- var V;
870
- let fe = (V = class extends pt {
871
- constructor(t = {}, e, n) {
872
- super(), this._config = t, this._injector = e, this._localeService = n, this._config = _t.deepMerge({}, vi, this._config);
873
- }
874
- onStarting(t) {
894
+ __name(getFindReplaceDialogDefaultPosition, "getFindReplaceDialogDefaultPosition");
895
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
896
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
897
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
898
+ return kind && result && __defProp2(target, key, result), result;
899
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
900
+ const PLUGIN_NAME = "FIND_REPLACE_PLUGIN";
901
+ var _a4;
902
+ let UniverFindReplacePlugin = (_a4 = class extends Plugin {
903
+ constructor(_config = {}, _injector, _localeService) {
904
+ super(), this._config = _config, this._injector = _injector, this._localeService = _localeService, this._config = Tools.deepMerge({}, DefaultFindReplaceConfig, this._config);
905
+ }
906
+ onStarting() {
875
907
  [
876
908
  [
877
- F,
909
+ FindReplaceController,
878
910
  {
879
- useFactory: () => this._injector.createInstance(F, this._config)
911
+ useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(FindReplaceController, this._config), "useFactory")
880
912
  }
881
913
  ],
882
- [g, { useClass: Q }]
914
+ [IFindReplaceService, { useClass: FindReplaceService }]
883
915
  ].forEach(
884
- (e) => {
885
- t.add(e);
916
+ (d) => {
917
+ this._injector.add(d);
886
918
  }
887
919
  );
888
920
  }
889
- }, o(V, "pluginName", yi), V);
890
- fe = xi([
891
- ue(1, b(ee)),
892
- ue(2, b(O))
893
- ], fe);
921
+ }, __name(_a4, "UniverFindReplacePlugin"), __publicField(_a4, "pluginName", PLUGIN_NAME), _a4);
922
+ UniverFindReplacePlugin = __decorateClass([
923
+ __decorateParam(1, Inject(Injector)),
924
+ __decorateParam(2, Inject(LocaleService))
925
+ ], UniverFindReplacePlugin);
894
926
  export {
895
- Z as FindBy,
896
- Y as FindDirection,
897
- Ni as FindModel,
898
- F as FindReplaceController,
899
- J as FindScope,
900
- Oe as GoToNextMatchOperation,
901
- Pe as GoToPreviousMatchOperation,
902
- g as IFindReplaceService,
903
- U as OpenFindDialogOperation,
904
- se as OpenReplaceDialogOperation,
905
- $e as ReplaceAllMatchesCommand,
906
- Ne as ReplaceCurrentMatchCommand,
907
- fe as UniverFindReplacePlugin
927
+ FindBy,
928
+ FindDirection,
929
+ FindModel,
930
+ FindReplaceController,
931
+ FindScope,
932
+ GoToNextMatchOperation,
933
+ GoToPreviousMatchOperation,
934
+ IFindReplaceService,
935
+ OpenFindDialogOperation,
936
+ OpenReplaceDialogOperation,
937
+ ReplaceAllMatchesCommand,
938
+ ReplaceCurrentMatchCommand,
939
+ UniverFindReplacePlugin
908
940
  };