@univerjs/find-replace 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  ## Package Overview
10
10
 
11
- | Package | UMD global | CSS | Locales | Facade entry |
12
- | --- | --- | :---: | :---: | :---: |
13
- | `@univerjs/find-replace` | `UniverFindReplace` | Yes | Yes | No |
11
+ | Package | UMD global | CSS | Locales | Facade entry | Worker entry |
12
+ | --- | --- | :---: | :---: | :---: | :---: |
13
+ | `@univerjs/find-replace` | `UniverFindReplace` | Yes | Yes | No | No |
14
14
 
15
15
  ## Installation
16
16
 
@@ -20,10 +20,10 @@ pnpm add @univerjs/find-replace
20
20
  npm install @univerjs/find-replace
21
21
  ```
22
22
 
23
- Keep all `@univerjs/*` packages on the same version.
24
-
25
23
  ## Usage
26
24
 
25
+ Start with the [integration setup](https://docs.univer.ai/) for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
26
+
27
27
  ```ts
28
28
  import '@univerjs/find-replace/lib/index.css';
29
29
  import EnUS from '@univerjs/find-replace/locale/en-US';
package/lib/cjs/index.js CHANGED
@@ -36,7 +36,7 @@ const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
36
36
  /** If the focused unit has a find-replace provider. */
37
37
  const FIND_REPLACE_AVAILABLE = "FIND_REPLACE_AVAILABLE";
38
38
 
39
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
39
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
40
40
  function _typeof(o) {
41
41
  "@babel/helpers - typeof";
42
42
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -46,25 +46,25 @@ function _typeof(o) {
46
46
  }, _typeof(o);
47
47
  }
48
48
 
49
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
50
- function toPrimitive(t, r) {
49
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
50
+ function toPrimitive(t, e) {
51
51
  if ("object" != _typeof(t) || !t) return t;
52
- var e = t[Symbol.toPrimitive];
53
- if (void 0 !== e) {
54
- var i = e.call(t, r || "default");
52
+ var r;
53
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
54
+ var i = r.call(t, e || "default");
55
55
  if ("object" != _typeof(i)) return i;
56
56
  throw new TypeError("@@toPrimitive must return a primitive value.");
57
57
  }
58
- return ("string" === r ? String : Number)(t);
58
+ return ("string" === e ? String : Number)(t);
59
59
  }
60
60
 
61
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
61
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
62
62
  function toPropertyKey(t) {
63
63
  var i = toPrimitive(t, "string");
64
64
  return "symbol" == _typeof(i) ? i : i + "";
65
65
  }
66
66
 
67
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
67
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
68
68
  function _defineProperty(e, r, t) {
69
69
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
70
70
  value: t,
@@ -74,14 +74,14 @@ function _defineProperty(e, r, t) {
74
74
  }) : e[r] = t, e;
75
75
  }
76
76
 
77
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
77
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
78
78
  function __decorateParam(paramIndex, decorator) {
79
79
  return function(target, key) {
80
80
  decorator(target, key, paramIndex);
81
81
  };
82
82
  }
83
83
 
84
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
84
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
85
85
  function __decorate(decorators, target, key, desc) {
86
86
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
87
87
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1026,7 +1026,7 @@ function getFindReplaceDialogDefaultPosition(direction) {
1026
1026
 
1027
1027
  // package.json
1028
1028
  var name = "@univerjs/find-replace";
1029
- var version = "1.4.0";
1029
+ var version = "1.5.0";
1030
1030
 
1031
1031
  // src/config/config.ts
1032
1032
  const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
@@ -1053,6 +1053,21 @@ const MOBILE_FIND_REPLACE_SETTINGS_COMPONENT = "MobileFindReplaceSettings";
1053
1053
  const MOBILE_FIND_REPLACE_SETTINGS_DIALOG_ID = "MOBILE_FIND_REPLACE_SETTINGS_DIALOG";
1054
1054
 
1055
1055
  // src/views/mobile/MobileFindReplaceSettings.tsx
1056
+ /**
1057
+ * Copyright 2023-present DreamNum Co., Ltd.
1058
+ *
1059
+ * Licensed under the Apache License, Version 2.0 (the "License");
1060
+ * you may not use this file except in compliance with the License.
1061
+ * You may obtain a copy of the License at
1062
+ *
1063
+ * http://www.apache.org/licenses/LICENSE-2.0
1064
+ *
1065
+ * Unless required by applicable law or agreed to in writing, software
1066
+ * distributed under the License is distributed on an "AS IS" BASIS,
1067
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1068
+ * See the License for the specific language governing permissions and
1069
+ * limitations under the License.
1070
+ */
1056
1071
  const FIND_SCOPE_OPTIONS$1 = [{
1057
1072
  label: "find-replace.dialog.find-scope.current-sheet",
1058
1073
  value: "subunit"
@@ -1167,7 +1182,8 @@ function SettingSelect(props) {
1167
1182
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: props.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileSelect, {
1168
1183
  value: props.value,
1169
1184
  options: props.options,
1170
- onChange: props.onChange
1185
+ onChange: props.onChange,
1186
+ size: "small"
1171
1187
  })]
1172
1188
  });
1173
1189
  }
@@ -1331,7 +1347,7 @@ function MobileFindReplaceBarContent() {
1331
1347
  className: "univer-relative univer-mr-2 univer-min-w-0 univer-flex-1",
1332
1348
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SearchIcon, { className: "univer-pointer-events-none univer-absolute univer-left-3 univer-top-1/2 univer-z-10 univer-size-5 -univer-translate-y-1/2 univer-text-gray-500" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
1333
1349
  ref: inputRef,
1334
- size: "middle",
1350
+ size: "small",
1335
1351
  allowClear: true,
1336
1352
  value: findValue,
1337
1353
  placeholder: localeService.t("find-replace.dialog.find-placeholder"),
@@ -1374,7 +1390,7 @@ function MobileFindReplaceBarContent() {
1374
1390
  className: "univer-flex univer-gap-1 univer-pl-9",
1375
1391
  children: [
1376
1392
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
1377
- size: "middle",
1393
+ size: "small",
1378
1394
  className: "univer-min-w-0 univer-flex-1",
1379
1395
  value: state.replaceString,
1380
1396
  placeholder: localeService.t("find-replace.dialog.replace-placeholder"),
@@ -1401,7 +1417,7 @@ function IconButton(props) {
1401
1417
  disabled: props.disabled,
1402
1418
  variant: "text",
1403
1419
  size: "icon",
1404
- className: "univer-size-9 univer-flex-none univer-rounded-full",
1420
+ className: "univer-flex-none univer-rounded-full",
1405
1421
  onClick: props.onClick,
1406
1422
  children: props.children
1407
1423
  });
@@ -1411,7 +1427,7 @@ function ActionButton(props) {
1411
1427
  type: "button",
1412
1428
  disabled: props.disabled,
1413
1429
  variant: "primary",
1414
- size: "large",
1430
+ size: "middle",
1415
1431
  className: "univer-flex-none",
1416
1432
  onClick: props.onClick,
1417
1433
  children: props.children
@@ -1615,7 +1631,7 @@ const FindDialog = (0, react.forwardRef)(function FindDialogImpl(_props, ref) {
1615
1631
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
1616
1632
  const { findCompleted, findString, matchesCount, matchesPosition } = (0, _univerjs_ui.useObservable)(findReplaceService.state$, void 0, true);
1617
1633
  const revealReplace = (0, react.useCallback)(() => {
1618
- commandService.executeCommand(OpenReplaceDialogOperation.id);
1634
+ return commandService.executeCommand(OpenReplaceDialogOperation.id);
1619
1635
  }, [commandService]);
1620
1636
  const onFindStringChange = (0, _univerjs_ui.useDebounceFn)((findString) => {
1621
1637
  return findReplaceService.changeFindString(findString);
@@ -1630,8 +1646,10 @@ const FindDialog = (0, react.forwardRef)(function FindDialogImpl(_props, ref) {
1630
1646
  onChange: onFindStringChange
1631
1647
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1632
1648
  className: "univer-mt-4 univer-text-center",
1633
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1634
- className: "univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors hover:univer-text-primary-500",
1649
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
1650
+ type: "button",
1651
+ variant: "link",
1652
+ size: "small",
1635
1653
  onClick: revealReplace,
1636
1654
  children: localeService.t("find-replace.dialog.advanced-finding")
1637
1655
  })
@@ -1821,7 +1839,11 @@ function FindReplaceDialog() {
1821
1839
  focusSubscription.unsubscribe();
1822
1840
  setDialogContainerFocus(false);
1823
1841
  };
1824
- }, [setDialogContainerFocus, setDialogInputFocus]);
1842
+ }, [
1843
+ setDialogContainerFocus,
1844
+ setDialogInputFocus,
1845
+ state.replaceRevealed
1846
+ ]);
1825
1847
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1826
1848
  ref: dialogContainerRef,
1827
1849
  "data-u-comp": "find-replace-dialog",
package/lib/es/index.js CHANGED
@@ -35,7 +35,7 @@ const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
35
35
  /** If the focused unit has a find-replace provider. */
36
36
  const FIND_REPLACE_AVAILABLE = "FIND_REPLACE_AVAILABLE";
37
37
 
38
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
38
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
39
39
  function _typeof(o) {
40
40
  "@babel/helpers - typeof";
41
41
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -45,25 +45,25 @@ function _typeof(o) {
45
45
  }, _typeof(o);
46
46
  }
47
47
 
48
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
49
- function toPrimitive(t, r) {
48
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
49
+ function toPrimitive(t, e) {
50
50
  if ("object" != _typeof(t) || !t) return t;
51
- var e = t[Symbol.toPrimitive];
52
- if (void 0 !== e) {
53
- var i = e.call(t, r || "default");
51
+ var r;
52
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
53
+ var i = r.call(t, e || "default");
54
54
  if ("object" != _typeof(i)) return i;
55
55
  throw new TypeError("@@toPrimitive must return a primitive value.");
56
56
  }
57
- return ("string" === r ? String : Number)(t);
57
+ return ("string" === e ? String : Number)(t);
58
58
  }
59
59
 
60
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
60
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
61
61
  function toPropertyKey(t) {
62
62
  var i = toPrimitive(t, "string");
63
63
  return "symbol" == _typeof(i) ? i : i + "";
64
64
  }
65
65
 
66
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
66
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
67
67
  function _defineProperty(e, r, t) {
68
68
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
69
69
  value: t,
@@ -73,14 +73,14 @@ function _defineProperty(e, r, t) {
73
73
  }) : e[r] = t, e;
74
74
  }
75
75
 
76
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
76
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
77
77
  function __decorateParam(paramIndex, decorator) {
78
78
  return function(target, key) {
79
79
  decorator(target, key, paramIndex);
80
80
  };
81
81
  }
82
82
 
83
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
83
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
84
84
  function __decorate(decorators, target, key, desc) {
85
85
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
86
86
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1025,7 +1025,7 @@ function getFindReplaceDialogDefaultPosition(direction) {
1025
1025
 
1026
1026
  // package.json
1027
1027
  var name = "@univerjs/find-replace";
1028
- var version = "1.4.0";
1028
+ var version = "1.5.0";
1029
1029
 
1030
1030
  // src/config/config.ts
1031
1031
  const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
@@ -1052,6 +1052,21 @@ const MOBILE_FIND_REPLACE_SETTINGS_COMPONENT = "MobileFindReplaceSettings";
1052
1052
  const MOBILE_FIND_REPLACE_SETTINGS_DIALOG_ID = "MOBILE_FIND_REPLACE_SETTINGS_DIALOG";
1053
1053
 
1054
1054
  // src/views/mobile/MobileFindReplaceSettings.tsx
1055
+ /**
1056
+ * Copyright 2023-present DreamNum Co., Ltd.
1057
+ *
1058
+ * Licensed under the Apache License, Version 2.0 (the "License");
1059
+ * you may not use this file except in compliance with the License.
1060
+ * You may obtain a copy of the License at
1061
+ *
1062
+ * http://www.apache.org/licenses/LICENSE-2.0
1063
+ *
1064
+ * Unless required by applicable law or agreed to in writing, software
1065
+ * distributed under the License is distributed on an "AS IS" BASIS,
1066
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1067
+ * See the License for the specific language governing permissions and
1068
+ * limitations under the License.
1069
+ */
1055
1070
  const FIND_SCOPE_OPTIONS$1 = [{
1056
1071
  label: "find-replace.dialog.find-scope.current-sheet",
1057
1072
  value: "subunit"
@@ -1166,7 +1181,8 @@ function SettingSelect(props) {
1166
1181
  children: [/* @__PURE__ */ jsx("span", { children: props.label }), /* @__PURE__ */ jsx(MobileSelect, {
1167
1182
  value: props.value,
1168
1183
  options: props.options,
1169
- onChange: props.onChange
1184
+ onChange: props.onChange,
1185
+ size: "small"
1170
1186
  })]
1171
1187
  });
1172
1188
  }
@@ -1330,7 +1346,7 @@ function MobileFindReplaceBarContent() {
1330
1346
  className: "univer-relative univer-mr-2 univer-min-w-0 univer-flex-1",
1331
1347
  children: [/* @__PURE__ */ jsx(SearchIcon, { className: "univer-pointer-events-none univer-absolute univer-left-3 univer-top-1/2 univer-z-10 univer-size-5 -univer-translate-y-1/2 univer-text-gray-500" }), /* @__PURE__ */ jsx(Input, {
1332
1348
  ref: inputRef,
1333
- size: "middle",
1349
+ size: "small",
1334
1350
  allowClear: true,
1335
1351
  value: findValue,
1336
1352
  placeholder: localeService.t("find-replace.dialog.find-placeholder"),
@@ -1373,7 +1389,7 @@ function MobileFindReplaceBarContent() {
1373
1389
  className: "univer-flex univer-gap-1 univer-pl-9",
1374
1390
  children: [
1375
1391
  /* @__PURE__ */ jsx(Input, {
1376
- size: "middle",
1392
+ size: "small",
1377
1393
  className: "univer-min-w-0 univer-flex-1",
1378
1394
  value: state.replaceString,
1379
1395
  placeholder: localeService.t("find-replace.dialog.replace-placeholder"),
@@ -1400,7 +1416,7 @@ function IconButton(props) {
1400
1416
  disabled: props.disabled,
1401
1417
  variant: "text",
1402
1418
  size: "icon",
1403
- className: "univer-size-9 univer-flex-none univer-rounded-full",
1419
+ className: "univer-flex-none univer-rounded-full",
1404
1420
  onClick: props.onClick,
1405
1421
  children: props.children
1406
1422
  });
@@ -1410,7 +1426,7 @@ function ActionButton(props) {
1410
1426
  type: "button",
1411
1427
  disabled: props.disabled,
1412
1428
  variant: "primary",
1413
- size: "large",
1429
+ size: "middle",
1414
1430
  className: "univer-flex-none",
1415
1431
  onClick: props.onClick,
1416
1432
  children: props.children
@@ -1614,7 +1630,7 @@ const FindDialog = forwardRef(function FindDialogImpl(_props, ref) {
1614
1630
  const commandService = useDependency(ICommandService);
1615
1631
  const { findCompleted, findString, matchesCount, matchesPosition } = useObservable(findReplaceService.state$, void 0, true);
1616
1632
  const revealReplace = useCallback(() => {
1617
- commandService.executeCommand(OpenReplaceDialogOperation.id);
1633
+ return commandService.executeCommand(OpenReplaceDialogOperation.id);
1618
1634
  }, [commandService]);
1619
1635
  const onFindStringChange = useDebounceFn((findString) => {
1620
1636
  return findReplaceService.changeFindString(findString);
@@ -1629,8 +1645,10 @@ const FindDialog = forwardRef(function FindDialogImpl(_props, ref) {
1629
1645
  onChange: onFindStringChange
1630
1646
  }), /* @__PURE__ */ jsx("div", {
1631
1647
  className: "univer-mt-4 univer-text-center",
1632
- children: /* @__PURE__ */ jsx("a", {
1633
- className: "univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors hover:univer-text-primary-500",
1648
+ children: /* @__PURE__ */ jsx(Button, {
1649
+ type: "button",
1650
+ variant: "link",
1651
+ size: "small",
1634
1652
  onClick: revealReplace,
1635
1653
  children: localeService.t("find-replace.dialog.advanced-finding")
1636
1654
  })
@@ -1820,7 +1838,11 @@ function FindReplaceDialog() {
1820
1838
  focusSubscription.unsubscribe();
1821
1839
  setDialogContainerFocus(false);
1822
1840
  };
1823
- }, [setDialogContainerFocus, setDialogInputFocus]);
1841
+ }, [
1842
+ setDialogContainerFocus,
1843
+ setDialogInputFocus,
1844
+ state.replaceRevealed
1845
+ ]);
1824
1846
  return /* @__PURE__ */ jsx("div", {
1825
1847
  ref: dialogContainerRef,
1826
1848
  "data-u-comp": "find-replace-dialog",
package/lib/index.css CHANGED
@@ -64,11 +64,6 @@
64
64
  height: 1.25rem;
65
65
  }
66
66
 
67
- .univer-size-9 {
68
- width: 2.25rem;
69
- height: 2.25rem;
70
- }
71
-
72
67
  .univer-min-h-9 {
73
68
  min-height: 2.25rem;
74
69
  }
@@ -91,10 +86,6 @@
91
86
  transform: translate(var(--univer-tw-translate-x), var(--univer-tw-translate-y)) rotate(var(--univer-tw-rotate)) skewX(var(--univer-tw-skew-x)) skewY(var(--univer-tw-skew-y)) scaleX(var(--univer-tw-scale-x)) scaleY(var(--univer-tw-scale-y));
92
87
  }
93
88
 
94
- .univer-cursor-pointer {
95
- cursor: pointer;
96
- }
97
-
98
89
  .univer-items-center {
99
90
  align-items: center;
100
91
  }
@@ -162,10 +153,6 @@
162
153
  color: var(--univer-gray-700);
163
154
  }
164
155
 
165
- .univer-text-primary-500 {
166
- color: var(--univer-primary-500);
167
- }
168
-
169
156
  .univer-shadow-\[0_-4px_16px_rgba\(0\,0\,0\,0\.08\)\] {
170
157
  --univer-tw-shadow: 0 -4px 16px #00000014;
171
158
  --univer-tw-shadow-colored: 0 -4px 16px var(--univer-tw-shadow-color);
@@ -173,18 +160,6 @@
173
160
  box-shadow: var(--univer-tw-ring-offset-shadow, 0 0 #0000), var(--univer-tw-ring-shadow, 0 0 #0000), var(--univer-tw-shadow);
174
161
  }
175
162
 
176
- .univer-transition-colors {
177
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
178
- transition-duration: .15s;
179
- transition-timing-function: cubic-bezier(.4, 0, .2, 1);
180
- }
181
-
182
- @media (hover: hover) and (pointer: fine) {
183
- .hover\:univer-text-primary-500:hover {
184
- color: var(--univer-primary-500);
185
- }
186
- }
187
-
188
163
  .dark\:\!univer-bg-gray-800:where(.univer-dark, .univer-dark *) {
189
164
  background-color: var(--univer-gray-800) !important;
190
165
  }
package/lib/index.js CHANGED
@@ -35,7 +35,7 @@ const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
35
35
  /** If the focused unit has a find-replace provider. */
36
36
  const FIND_REPLACE_AVAILABLE = "FIND_REPLACE_AVAILABLE";
37
37
 
38
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
38
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
39
39
  function _typeof(o) {
40
40
  "@babel/helpers - typeof";
41
41
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -45,25 +45,25 @@ function _typeof(o) {
45
45
  }, _typeof(o);
46
46
  }
47
47
 
48
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
49
- function toPrimitive(t, r) {
48
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
49
+ function toPrimitive(t, e) {
50
50
  if ("object" != _typeof(t) || !t) return t;
51
- var e = t[Symbol.toPrimitive];
52
- if (void 0 !== e) {
53
- var i = e.call(t, r || "default");
51
+ var r;
52
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
53
+ var i = r.call(t, e || "default");
54
54
  if ("object" != _typeof(i)) return i;
55
55
  throw new TypeError("@@toPrimitive must return a primitive value.");
56
56
  }
57
- return ("string" === r ? String : Number)(t);
57
+ return ("string" === e ? String : Number)(t);
58
58
  }
59
59
 
60
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
60
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
61
61
  function toPropertyKey(t) {
62
62
  var i = toPrimitive(t, "string");
63
63
  return "symbol" == _typeof(i) ? i : i + "";
64
64
  }
65
65
 
66
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
66
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
67
67
  function _defineProperty(e, r, t) {
68
68
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
69
69
  value: t,
@@ -73,14 +73,14 @@ function _defineProperty(e, r, t) {
73
73
  }) : e[r] = t, e;
74
74
  }
75
75
 
76
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
76
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
77
77
  function __decorateParam(paramIndex, decorator) {
78
78
  return function(target, key) {
79
79
  decorator(target, key, paramIndex);
80
80
  };
81
81
  }
82
82
 
83
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
83
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
84
84
  function __decorate(decorators, target, key, desc) {
85
85
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
86
86
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1025,7 +1025,7 @@ function getFindReplaceDialogDefaultPosition(direction) {
1025
1025
 
1026
1026
  // package.json
1027
1027
  var name = "@univerjs/find-replace";
1028
- var version = "1.4.0";
1028
+ var version = "1.5.0";
1029
1029
 
1030
1030
  // src/config/config.ts
1031
1031
  const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
@@ -1052,6 +1052,21 @@ const MOBILE_FIND_REPLACE_SETTINGS_COMPONENT = "MobileFindReplaceSettings";
1052
1052
  const MOBILE_FIND_REPLACE_SETTINGS_DIALOG_ID = "MOBILE_FIND_REPLACE_SETTINGS_DIALOG";
1053
1053
 
1054
1054
  // src/views/mobile/MobileFindReplaceSettings.tsx
1055
+ /**
1056
+ * Copyright 2023-present DreamNum Co., Ltd.
1057
+ *
1058
+ * Licensed under the Apache License, Version 2.0 (the "License");
1059
+ * you may not use this file except in compliance with the License.
1060
+ * You may obtain a copy of the License at
1061
+ *
1062
+ * http://www.apache.org/licenses/LICENSE-2.0
1063
+ *
1064
+ * Unless required by applicable law or agreed to in writing, software
1065
+ * distributed under the License is distributed on an "AS IS" BASIS,
1066
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1067
+ * See the License for the specific language governing permissions and
1068
+ * limitations under the License.
1069
+ */
1055
1070
  const FIND_SCOPE_OPTIONS$1 = [{
1056
1071
  label: "find-replace.dialog.find-scope.current-sheet",
1057
1072
  value: "subunit"
@@ -1166,7 +1181,8 @@ function SettingSelect(props) {
1166
1181
  children: [/* @__PURE__ */ jsx("span", { children: props.label }), /* @__PURE__ */ jsx(MobileSelect, {
1167
1182
  value: props.value,
1168
1183
  options: props.options,
1169
- onChange: props.onChange
1184
+ onChange: props.onChange,
1185
+ size: "small"
1170
1186
  })]
1171
1187
  });
1172
1188
  }
@@ -1330,7 +1346,7 @@ function MobileFindReplaceBarContent() {
1330
1346
  className: "univer-relative univer-mr-2 univer-min-w-0 univer-flex-1",
1331
1347
  children: [/* @__PURE__ */ jsx(SearchIcon, { className: "univer-pointer-events-none univer-absolute univer-left-3 univer-top-1/2 univer-z-10 univer-size-5 -univer-translate-y-1/2 univer-text-gray-500" }), /* @__PURE__ */ jsx(Input, {
1332
1348
  ref: inputRef,
1333
- size: "middle",
1349
+ size: "small",
1334
1350
  allowClear: true,
1335
1351
  value: findValue,
1336
1352
  placeholder: localeService.t("find-replace.dialog.find-placeholder"),
@@ -1373,7 +1389,7 @@ function MobileFindReplaceBarContent() {
1373
1389
  className: "univer-flex univer-gap-1 univer-pl-9",
1374
1390
  children: [
1375
1391
  /* @__PURE__ */ jsx(Input, {
1376
- size: "middle",
1392
+ size: "small",
1377
1393
  className: "univer-min-w-0 univer-flex-1",
1378
1394
  value: state.replaceString,
1379
1395
  placeholder: localeService.t("find-replace.dialog.replace-placeholder"),
@@ -1400,7 +1416,7 @@ function IconButton(props) {
1400
1416
  disabled: props.disabled,
1401
1417
  variant: "text",
1402
1418
  size: "icon",
1403
- className: "univer-size-9 univer-flex-none univer-rounded-full",
1419
+ className: "univer-flex-none univer-rounded-full",
1404
1420
  onClick: props.onClick,
1405
1421
  children: props.children
1406
1422
  });
@@ -1410,7 +1426,7 @@ function ActionButton(props) {
1410
1426
  type: "button",
1411
1427
  disabled: props.disabled,
1412
1428
  variant: "primary",
1413
- size: "large",
1429
+ size: "middle",
1414
1430
  className: "univer-flex-none",
1415
1431
  onClick: props.onClick,
1416
1432
  children: props.children
@@ -1614,7 +1630,7 @@ const FindDialog = forwardRef(function FindDialogImpl(_props, ref) {
1614
1630
  const commandService = useDependency(ICommandService);
1615
1631
  const { findCompleted, findString, matchesCount, matchesPosition } = useObservable(findReplaceService.state$, void 0, true);
1616
1632
  const revealReplace = useCallback(() => {
1617
- commandService.executeCommand(OpenReplaceDialogOperation.id);
1633
+ return commandService.executeCommand(OpenReplaceDialogOperation.id);
1618
1634
  }, [commandService]);
1619
1635
  const onFindStringChange = useDebounceFn((findString) => {
1620
1636
  return findReplaceService.changeFindString(findString);
@@ -1629,8 +1645,10 @@ const FindDialog = forwardRef(function FindDialogImpl(_props, ref) {
1629
1645
  onChange: onFindStringChange
1630
1646
  }), /* @__PURE__ */ jsx("div", {
1631
1647
  className: "univer-mt-4 univer-text-center",
1632
- children: /* @__PURE__ */ jsx("a", {
1633
- className: "univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors hover:univer-text-primary-500",
1648
+ children: /* @__PURE__ */ jsx(Button, {
1649
+ type: "button",
1650
+ variant: "link",
1651
+ size: "small",
1634
1652
  onClick: revealReplace,
1635
1653
  children: localeService.t("find-replace.dialog.advanced-finding")
1636
1654
  })
@@ -1820,7 +1838,11 @@ function FindReplaceDialog() {
1820
1838
  focusSubscription.unsubscribe();
1821
1839
  setDialogContainerFocus(false);
1822
1840
  };
1823
- }, [setDialogContainerFocus, setDialogInputFocus]);
1841
+ }, [
1842
+ setDialogContainerFocus,
1843
+ setDialogInputFocus,
1844
+ state.replaceRevealed
1845
+ ]);
1824
1846
  return /* @__PURE__ */ jsx("div", {
1825
1847
  ref: dialogContainerRef,
1826
1848
  "data-u-comp": "find-replace-dialog",
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/design`,`@univerjs/ui`,`@univerjs/engine-render`,`rxjs`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverFindReplace={},e.UniverCore,e.UniverDesign,e.UniverUi,e.UniverEngineRender,e.rxjs,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let c=`FIND_REPLACE_INPUT_FOCUS`,l=`FIND_REPLACE_DIALOG_FOCUS`,u=`FIND_REPLACE_REPLACE_REVEALED`,d=`FIND_REPLACE_AVAILABLE`;function f(e){"@babel/helpers - typeof";return f=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},f(e)}function p(e,t){if(f(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(f(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){var t=p(e,`string`);return f(t)==`symbol`?t:t+``}function h(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e,t){return function(n,r){t(n,r,e)}}function _(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var v=class extends t.Disposable{};let y=(0,t.createIdentifier)(`find-replace.service`);function b(e){return e.findString!==void 0||e.inputtingFindString!==void 0||e.findDirection!==void 0||e.matchesTheWholeCell!==void 0||e.matchesTheWholeWord!==void 0||e.caseSensitive!==void 0||e.findScope!==void 0||e.findBy!==void 0}let x=class extends t.Disposable{get searched(){return this._findModels.length>0}constructor(e,t,n,r){super(),this._state=e,this._providers=t,this._univerInstanceService=n,this._commandService=r,h(this,`currentMatch$`,new a.BehaviorSubject(null)),h(this,`replaceables$`,new a.BehaviorSubject([])),h(this,`_findModels`,[]),h(this,`_matchingModel`,null),h(this,`_matches`,[]),h(this,`_currentSearchingDisposables`,null),this.disposeWithMe(this._state.stateUpdates$.pipe((0,a.throttleTime)(200,void 0,{leading:!0,trailing:!0})).subscribe(async e=>{let t=this._state.state;b(e)&&(t.findString!==``&&!t.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):e.replaceRevealed!==!0&&this._stopSearching())}))}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...T(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};let e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}focusSelection(){var e;(e=this._matchingModel)==null||e.focusSelection()}async _startSearching(){if(!this._state.findString)return{results:[]};let e=Array.from(this._providers),t=this._findModels=(await Promise.all(e.map(e=>e.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell,matchesTheWholeWord:this._state.matchesTheWholeWord})))).flat();this._subscribeToModelsChanges(t);let n=this._matches=t.map(e=>e.getMatches()).flat();return this.replaceables$.next(n.filter(e=>e.replaceable)),n.length?(this._moveToInitialMatch(t),this._state.changeState({matchesCount:n.length}),{results:n}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var e;this._providers.forEach(e=>e.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({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){let n=this._currentSearchingDisposables=new t.DisposableCollection,r=(0,a.combineLatest)(e.map(e=>e.matchesUpdate$)).pipe((0,a.debounceTime)(220)).subscribe(([...e])=>{let t=this._matches=e.flat();t.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:t.length}),this.replaceables$.next(t.filter(e=>e.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(e=>n.add((0,t.toDisposable)(e.activelyChangingMatch$.subscribe(e=>{let t=this._matches.findIndex(t=>t===e);this._state.changeState({matchesPosition:t+1})})))),n.add((0,t.toDisposable)(r))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){let e=await Promise.all(this._findModels.map(e=>e.replaceAll(this._state.replaceString))).then(e=>e.reduce((e,t)=>(e.success+=t.success,e.failure+=t.failure,e),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(e){let t=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:t+1})}moveToNextMatch(){if(!this._matchingModel)return;let e=this._findModels.length===1,t=this._matchingModel.moveToNextMatch({loop:e});if(t)return this._markMatch(t),t;{let e=this._findModels.findIndex(e=>e===this._matchingModel);return this._moveToNextUnitMatch(e)}}_moveToNextUnitMatch(e){let t=this._findModels.length;for(let n=(e+1)%t;n!==e;){let e=this._findModels[n],r=e.moveToNextMatch({ignoreSelection:!0});if(r)return this._matchingModel=e,this._markMatch(r),r;n=(n+1)%t}if(this._matchingModel){let e=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return e&&this._markMatch(e),e}}moveToPreviousMatch(){if(!this._matchingModel)return;let e=this._findModels.length===1,t=this._matchingModel.moveToPreviousMatch({loop:e});if(t){let e=this._matches.findIndex(e=>e===t);return this.currentMatch$.next(t),this._state.changeState({matchesPosition:e+1}),t}{let e=this._findModels.length,t=this._findModels.findIndex(e=>e===this._matchingModel);for(let n=(t-1+e)%e;n!==t;){let t=this._findModels[n],r=t.moveToPreviousMatch({ignoreSelection:!0});if(r)return this._matchingModel=t,this._markMatch(r),r;n=(n-1)%e}let n=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return n&&this._markMatch(n),n}}_moveToInitialMatch(e,t=!1){var n;let r=(n=this._univerInstanceService.getFocusedUnit())==null?void 0:n.getUnitId();if(!r)return-1;let i=e.findIndex(e=>e.unitId===r);if(i!==-1){this._matchingModel=e[i];let n=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:t});if(n)return this._markMatch(n),i}return this._moveToNextUnitMatch(i),0}};x=_([g(2,t.IUniverInstanceService),g(3,t.ICommandService)],x);let S=/* @__PURE__ */ function(e){return e.ROW=`row`,e.COLUMN=`column`,e}({}),C=/* @__PURE__ */ function(e){return e.VALUE=`value`,e.FORMULA=`formula`,e}({}),w=/* @__PURE__ */ function(e){return e.SUBUNIT=`subunit`,e.UNIT=`unit`,e}({});function T(){return{caseSensitive:!1,findBy:`value`,findCompleted:!1,findDirection:`row`,findScope:`subunit`,findString:``,inputtingFindString:``,matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,matchesTheWholeWord:!1,replaceRevealed:!1,replaceString:``,revealed:!0}}var E=class{constructor(){h(this,`_stateUpdates$`,new a.Subject),h(this,`stateUpdates$`,this._stateUpdates$.asObservable()),h(this,`_state$`,new a.BehaviorSubject(T())),h(this,`state$`,this._state$.asObservable()),h(this,`_findString`,``),h(this,`_inputtingFindString`,``),h(this,`_replaceString`,``),h(this,`_revealed`,!1),h(this,`_replaceRevealed`,!1),h(this,`_matchesPosition`,0),h(this,`_matchesCount`,0),h(this,`_caseSensitive`,!0),h(this,`_matchesTheWholeCell`,!1),h(this,`_matchesTheWholeWord`,!1),h(this,`_findDirection`,`row`),h(this,`_findScope`,`subunit`),h(this,`_findBy`,`value`),h(this,`_findCompleted`,!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get matchesTheWholeWord(){return this._matchesTheWholeWord}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let t=!1,n={};e.findString!==void 0&&e.findString!==this._findString&&(this._findString=e.findString,n.findString=this._findString,t=!0),e.revealed!==void 0&&e.revealed!==this._revealed&&(this._revealed=e.revealed,n.revealed=e.revealed,t=!0),e.replaceRevealed!==void 0&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,n.replaceRevealed=e.replaceRevealed,t=!0),e.replaceString!==void 0&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,n.replaceString=e.replaceString,t=!0),e.matchesCount!==void 0&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,n.matchesCount=e.matchesCount,t=!0),e.matchesPosition!==void 0&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,n.matchesPosition=e.matchesPosition,t=!0),e.findBy!==void 0&&e.findBy!==this._findBy&&(this._findBy=e.findBy,n.findBy=e.findBy,t=!0),e.findScope!==void 0&&e.findScope!==this._findScope&&(this._findScope=e.findScope,n.findScope=e.findScope,t=!0),e.findDirection!==void 0&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,n.findDirection=e.findDirection,t=!0),e.caseSensitive!==void 0&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,n.caseSensitive=e.caseSensitive,t=!0),e.matchesTheWholeCell!==void 0&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,n.matchesTheWholeCell=e.matchesTheWholeCell,t=!0),e.matchesTheWholeWord!==void 0&&e.matchesTheWholeWord!==this._matchesTheWholeWord&&(this._matchesTheWholeWord=e.matchesTheWholeWord,n.matchesTheWholeWord=e.matchesTheWholeWord,t=!0),e.inputtingFindString!==void 0&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,n.inputtingFindString=e.inputtingFindString,t=!0),e.findCompleted!==void 0&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,n.findCompleted=e.findCompleted,t=!0),t&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,matchesTheWholeWord:this._matchesTheWholeWord,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(n))}};let D=class extends t.Disposable{get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}constructor(e,n,r){super(),this._injector=e,this._contextService=n,this._univerInstanceService=r,h(this,`_providers`,/* @__PURE__ */ new Set),h(this,`_state`,new E),h(this,`_model`,void 0),h(this,`_modelDisposables`,null),h(this,`_currentMatch$`,new a.BehaviorSubject(null)),h(this,`currentMatch$`,this._currentMatch$.asObservable()),h(this,`_replaceables$`,new a.BehaviorSubject([])),h(this,`replaceables$`,this._replaceables$.asObservable()),h(this,`_focusSignal$`,new a.Subject),h(this,`focusSignal$`,this._focusSignal$.asObservable()),h(this,`_providerCapabilities$`,new a.BehaviorSubject(null)),h(this,`providerCapabilities$`,this._providerCapabilities$.asObservable()),h(this,`_activeProvider`,null),this.disposeWithMe((0,t.toDisposable)(this._univerInstanceService.focused$.subscribe(()=>this._syncActiveProvider())))}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete(),this._providerCapabilities$.complete()}getProviders(){return this._providers}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:``,findString:``})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeMatchesTheWholeWord(e){this._state.changeState({matchesTheWholeWord:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e===`formula`)}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw Error(`[FindReplaceService] replaceAll: model is not initialized!`);return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}hideReplace(){this._state.changeState({replaceRevealed:!1,findString:this._state.inputtingFindString}),this._toggleRevealReplace(!1)}focusSelection(){var e;(e=this._model)==null||e.focusSelection()}start(e=!1){if(!this._activeProvider)return!1;this._model=this._injector.createInstance(x,this._state,/* @__PURE__ */ new Set([this._activeProvider])),this._modelDisposables=new t.DisposableCollection,this._modelDisposables.add((0,t.toDisposable)(this._model.currentMatch$.subscribe(e=>this._currentMatch$.next(e)))),this._modelDisposables.add((0,t.toDisposable)(this._model.replaceables$.subscribe(e=>this._replaceables$.next(e))));let n=T();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e,t;(e=this._model)==null||e.dispose(),this._model=null,(t=this._modelDisposables)==null||t.dispose(),this._modelDisposables=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),this._syncActiveProvider(),(0,t.toDisposable)(()=>{this._providers.delete(e),this._syncActiveProvider()})}_syncActiveProvider(){let e=this._univerInstanceService.getFocusedUnit(),t=e==null?null:Array.from(this._providers).find(t=>t.isSupported(e))??null;t!==this._activeProvider&&(this.revealed&&this.terminate(),this._activeProvider=t,this._providerCapabilities$.next((t==null?void 0:t.capabilities)??null),this._contextService.setContextValue(d,t!=null))}_toggleRevealReplace(e){this._contextService.setContextValue(u,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(i.RENDER_RAW_FORMULA_KEY,e)}};D=_([g(0,(0,t.Inject)(t.Injector)),g(1,t.IContextService),g(2,t.IUniverInstanceService)],D);let O={id:`ui.command.replace-current-match`,type:t.CommandType.COMMAND,handler:e=>e.get(y).replace()},k={id:`ui.command.replace-all-matches`,type:t.CommandType.COMMAND,handler:async e=>{let i=e.get(t.IConfirmService),a=e.get(t.LocaleService),o=e.get(r.IMessageService);if(!await i.confirm({id:`CONFIRM_REPLACE_ALL`,title:{title:a.t(`find-replace.replace.confirm.title`)},cancelText:a.t(`find-replace.button.cancel`),confirmText:a.t(`find-replace.button.confirm`)}))return!1;let{success:s,failure:c}=await e.get(y).replaceAll();return c>0?(s===0?o.show({type:n.MessageType.Error,content:a.t(`find-replace.replace.all-failure`)}):o.show({type:n.MessageType.Warning,content:a.t(`find-replace.replace.partial-success`,`${s}`,`${c}`)}),!1):(o.show({type:n.MessageType.Success,content:a.t(`find-replace.replace.all-success`,`${s}`)}),!0)}},A={id:`ui.operation.open-find-dialog`,type:t.CommandType.OPERATION,handler:e=>{let t=e.get(y);return t.revealed?t.focusFindInput():t.start(),!0}},j={id:`ui.operation.open-replace-dialog`,type:t.CommandType.OPERATION,handler:e=>{let t=e.get(y);return t.revealed?t.replaceRevealed?t.focusFindInput():t.revealReplace():t.start(!0),!0}},M={id:`ui.operation.close-find-dialog`,type:t.CommandType.OPERATION,handler:e=>(e.get(y).terminate(),!0)},N={type:t.CommandType.OPERATION,id:`ui.operation.go-to-next-match`,handler:e=>(e.get(y).moveToNextMatch(),!0)},P={type:t.CommandType.OPERATION,id:`ui.operation.go-to-previous-match`,handler:e=>(e.get(y).moveToPreviousMatch(),!0)},F={type:t.CommandType.OPERATION,id:`ui.operation.focus-selection`,handler:e=>(e.get(y).focusSelection(),!0)};function I(e){let n=e.get(t.IContextService);return{id:A.id,icon:`SearchIcon`,tooltip:`find-replace.toolbar`,type:r.MenuItemType.BUTTON,hidden$:(0,r.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,a.combineLatest)([n.subscribeContextValue$(t.EDITOR_ACTIVATED),n.subscribeContextValue$(t.FOCUSING_SHEET),n.subscribeContextValue$(d).pipe((0,a.startWith)(n.getContextValue(d)))]).pipe((0,a.map)(([e,t,n])=>e||!t||!n))}}let ee={[r.RibbonDataGroup.OTHERS]:{[A.id]:{order:0,gridLayout:{row:1,column:1,rowSpan:2,columnSpan:2,showLabel:!0},menuItemFactory:I}}};function L(e){return e.getContextValue(l)}function te(e){return e.getContextValue(u)}function R(e){return e.getContextValue(c)}let z=`7_find-replace-shortcuts`;function B(e){return e.getContextValue(d)}function V(e){return!e.getContextValue(t.EDITOR_ACTIVATED)}let ne={id:A.id,description:`find-replace.shortcut.open-find-dialog`,binding:r.KeyCode.F|r.MetaKeys.CTRL_COMMAND,group:z,groupTitle:`find-replace.shortcut.panel`,preconditions(e){return!L(e)&&B(e)&&V(e)}},re={id:A.id,description:`find-replace.shortcut.open-find-dialog`,binding:r.KeyCode.F|r.MetaKeys.CTRL_COMMAND,mac:r.KeyCode.F|r.MetaKeys.MAC_CTRL,preconditions(e){return!L(e)&&B(e)&&V(e)}},ie={id:j.id,description:`find-replace.shortcut.open-replace-dialog`,binding:r.KeyCode.H|r.MetaKeys.CTRL_COMMAND,mac:r.KeyCode.H|r.MetaKeys.MAC_CTRL,group:z,groupTitle:`find-replace.shortcut.panel`,preconditions(e){return B(e)&&V(e)&&(!L(e)||!te(e))}},ae={id:N.id,description:`find-replace.shortcut.go-to-next-match`,binding:r.KeyCode.ENTER,group:z,groupTitle:`find-replace.shortcut.panel`,priority:1e3,preconditions(e){return R(e)&&L(e)}},oe={id:P.id,description:`find-replace.shortcut.go-to-previous-match`,binding:r.KeyCode.ENTER|r.MetaKeys.SHIFT,group:z,groupTitle:`find-replace.shortcut.panel`,priority:1e3,preconditions(e){return R(e)&&L(e)}},se={id:F.id,description:`find-replace.shortcut.focus-selection`,binding:r.KeyCode.ESC,group:z,groupTitle:`find-replace.shortcut.panel`,priority:1e3,preconditions(e){return L(e)}},ce=`DESKTOP_FIND_REPLACE_DIALOG`,H=class extends t.RxDisposable{constructor(e,t,n,r,i,a,o,s){super(),this._univerInstanceService=e,this._menuManagerService=t,this._shortcutService=n,this._commandService=r,this._findReplaceService=i,this._dialogService=a,this._layoutService=o,this._localeService=s,h(this,`_closingListenerDisposable`,void 0),this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var e;super.dispose(),(e=this._closingListenerDisposable)==null||e.dispose(),this._closingListenerDisposable=null}_initCommands(){[A,j,M,N,P,k,O,F].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[ie,ne,re,oe,ae,se].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this._menuManagerService.mergeMenu(ee),this._findReplaceService.stateUpdates$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{e.revealed===!0?this._openPanel():e.revealed===!1&&this._closePanel(!1)})}_openPanel(){var e;let n=(e=this._univerInstanceService.getFocusedUnit())==null?void 0:e.getUnitId();this._dialogService.open({id:ce,draggable:!0,width:350,title:{title:this._localeService.t(`find-replace.dialog.title`)},children:{label:`FindReplaceDialog`},mask:!1,maskClosable:!1,defaultPosition:le(this._localeService.getDirection()),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=(0,t.toDisposable)(this._univerInstanceService.focused$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{e&&e===n||this.closePanel()}))}closePanel(){this._closePanel(!0)}_closePanel(e){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(ce),e&&this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}};H=_([g(0,t.IUniverInstanceService),g(1,r.IMenuManagerService),g(2,r.IShortcutService),g(3,t.ICommandService),g(4,y),g(5,r.IDialogService),g(6,r.ILayoutService),g(7,(0,t.Inject)(t.LocaleService))],H);function le(e){let{innerWidth:t}=window;return{x:e===`rtl`?20:t-350-20,y:64}}var ue=`@univerjs/find-replace`,de=`1.4.0`;let fe=`find-replace.config`,U={};function W({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:s,...c}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,o.useId)()}`,d=(0,o.useRef)(null);return(0,o.useImperativeHandle)(e,()=>d.current),(0,o.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return ge(d.current)},[n,r]),pe(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...c},s)}function pe(e,t,n,r,i){return(0,o.createElement)(e.tag,{key:t,...me(e,n,i),...r},(he(e,n).children||[]).map((r,a)=>pe(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function me(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function he(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function ge(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:_e(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(ve(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function _e(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function ve(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}W.displayName=`UniverIcon`;let ye={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 2.5V13.5M3 8.5L8 13.5L13 8.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},be=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`arrow-down-icon`,ref:t,icon:ye}))});be.displayName=`ArrowDownIcon`;let xe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 13.5V2.5M3 7.5L8 2.5L13 7.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},Se=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`arrow-up-icon`,ref:t,icon:xe}))});Se.displayName=`ArrowUpIcon`;let Ce={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.3 3.3L12.7 12.7M12.7 3.3L3.3 12.7`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},we=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`close-icon`,ref:t,icon:Ce}))});we.displayName=`CloseIcon`;let Te={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.7 3.2h2.6l.4 1.7 1.4.6 1.5-.9 1.8 1.8-.9 1.5.6 1.4 1.7.4v2.6l-1.7.4-.6 1.4.9 1.5-1.8 1.8-1.5-.9-1.4.6-.4 1.7H8.7l-.4-1.7-1.4-.6-1.5.9-1.8-1.8.9-1.5-.6-1.4-1.7-.4V9.7l1.7-.4.6-1.4-.9-1.5 1.8-1.8 1.5.9 1.4-.6.4-1.7Z`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.6}},{tag:`circle`,attrs:{cx:10,cy:11,r:2.2,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.6}}]},Ee=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`configure-tab-icon`,ref:t,icon:Te}))});Ee.displayName=`ConfigureTabIcon`;let De={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`g`,attrs:{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2},children:[{tag:`circle`,attrs:{cx:7,cy:7,r:5.2}},{tag:`path`,attrs:{d:`M10.8 10.8L14.2 14.2`}}]}]},G=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`search-icon`,ref:t,icon:De}))});G.displayName=`SearchIcon`;let Oe=`MobileFindReplaceSettings`,ke=`MOBILE_FIND_REPLACE_SETTINGS_DIALOG`,Ae=[{label:`find-replace.dialog.find-scope.current-sheet`,value:`subunit`},{label:`find-replace.dialog.find-scope.workbook`,value:`unit`}],je=[{label:`find-replace.dialog.find-direction.row`,value:`row`},{label:`find-replace.dialog.find-direction.column`,value:`column`}],Me=[{label:`find-replace.dialog.find-by.value`,value:`value`},{label:`find-replace.dialog.find-by.formula`,value:`formula`}];function Ne(){let e=(0,r.useDependency)(y),n=(0,r.useDependency)(t.LocaleService),i=(0,r.useObservable)(e.state$,void 0,!0),a=(0,r.useObservable)(e.providerCapabilities$,null,!0);function o(t=!1){i.findString&&(t||i.replaceRevealed)&&e.find()}let c=Ae.map(e=>({...e,label:n.t(e.label)})),l=je.map(e=>({...e,label:n.t(e.label)})),u=Me.map(e=>({...e,label:n.t(e.label)}));return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-grid univer-gap-2`,"data-u-comp":`mobile-find-replace-settings`,children:[/* @__PURE__ */ (0,s.jsx)(q,{checked:i.replaceRevealed,label:n.t(`find-replace.dialog.replace`),onChange:t=>{t?e.revealReplace():e.hideReplace(),o(!0)}}),(a==null?void 0:a.findDirection)&&/* @__PURE__ */ (0,s.jsx)(K,{label:n.t(`find-replace.dialog.find-direction.title`),value:i.findDirection,options:l,onChange:t=>{e.changeFindDirection(t),o()}}),(a==null?void 0:a.findScope)&&/* @__PURE__ */ (0,s.jsx)(K,{label:n.t(`find-replace.dialog.find-scope.title`),value:i.findScope,options:c,onChange:t=>{e.changeFindScope(t),o()}}),(a==null?void 0:a.findBy)&&/* @__PURE__ */ (0,s.jsx)(K,{label:n.t(`find-replace.dialog.find-by.title`),value:i.findBy,options:u,onChange:t=>{e.changeFindBy(t),o()}}),(a==null?void 0:a.caseSensitive)&&/* @__PURE__ */ (0,s.jsx)(q,{checked:i.caseSensitive,label:n.t(`find-replace.dialog.case-sensitive`),onChange:t=>{e.changeCaseSensitive(t),o()}}),(a==null?void 0:a.matchesTheWholeCell)&&/* @__PURE__ */ (0,s.jsx)(q,{checked:i.matchesTheWholeCell,label:n.t(`find-replace.dialog.match-the-whole-cell`),onChange:t=>{e.changeMatchesTheWholeCell(t),o()}}),(a==null?void 0:a.matchesTheWholeWord)&&/* @__PURE__ */ (0,s.jsx)(q,{checked:i.matchesTheWholeWord,label:n.t(`find-replace.dialog.match-the-whole-word`),onChange:t=>{e.changeMatchesTheWholeWord(t),o()}})]})}function K(e){return/* @__PURE__ */ (0,s.jsxs)(`label`,{className:`univer-grid univer-gap-1 univer-text-sm univer-text-gray-700 dark:!univer-text-gray-300`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{children:e.label}),/* @__PURE__ */ (0,s.jsx)(n.MobileSelect,{value:e.value,options:e.options,onChange:e.onChange})]})}function q(e){return/* @__PURE__ */ (0,s.jsx)(`div`,{className:`univer-flex univer-min-h-9 univer-items-center`,children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:e.checked,onChange:t=>e.onChange(!!t),children:e.label})})}let J=class extends t.Disposable{constructor(e,t){super(),this.disposeWithMe(t.register({SearchIcon:G})),this.disposeWithMe(e.register(Oe,Ne))}};J=_([g(0,(0,t.Inject)(r.ComponentManager)),g(1,(0,t.Inject)(r.IconManager))],J);let Pe={[r.RibbonDataGroup.ORGANIZATION]:{[A.id]:{order:2,menuItemFactory:I}}};function Fe(){let e=(0,r.useDependency)(y);return(0,r.useObservable)(e.state$,void 0,!0),e.revealed?/* @__PURE__ */ (0,s.jsx)(Ie,{}):null}function Ie(){let e=(0,r.useDependency)(t.ICommandService),i=(0,r.useDependency)(r.IDialogService),a=(0,r.useDependency)(y),c=(0,r.useDependency)(t.LocaleService),l=(0,r.useObservable)(a.state$,void 0,!0),u=(0,r.useObservable)(a.currentMatch$,null,!0),d=(0,r.useObservable)(a.replaceables$,[],!0),[f,p]=(0,o.useState)(()=>l.replaceRevealed?l.inputtingFindString:l.findString),m=(0,o.useRef)(null),h=(0,o.useRef)(null),g=(0,o.useRef)(null),_=(0,o.useRef)(!1),v=(0,n.useMobileKeyboardViewportLayout)(m);(0,o.useEffect)(()=>{let e=requestAnimationFrame(()=>{var e;return(e=h.current)==null?void 0:e.focus()});return()=>cancelAnimationFrame(e)},[]),(0,o.useEffect)(()=>{let e=a.focusSignal$.subscribe(()=>{var e;_.current?_.current=!1:(e=h.current)==null||e.focus()});return()=>e.unsubscribe()},[a]),(0,o.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]);function b(){g.current&&=(clearTimeout(g.current),null)}function x(e){b(),e?a.replaceRevealed?(a.changeInputtingFindString(e),a.changeFindString(e),a.find()):a.changeFindString(e):a.changeInputtingFindString(``)}function S(e){b(),e?g.current=setTimeout(()=>x(e),500):x(e)}function C(){document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function w(t,n=!1){if(C(),f!==l.findString&&(x(f),t===N.id||t===P.id))return;_.current=n;let r=e.executeCommand(t);_.current=!1,r.catch(()=>void 0)}function T(){x(f),C(),i.open({id:ke,title:{title:c.t(`find-replace.mobile.settings-title`)},children:{label:Oe}})}let E=l.findCompleted&&l.matchesCount===0?c.t(`find-replace.dialog.no-result`):l.matchesCount>0?`${l.matchesPosition}/${l.matchesCount}`:void 0,D=l.matchesCount===0,A=l.matchesCount===0||!(u!=null&&u.replaceable),j=d.length===0;return/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:m,"data-u-comp":`mobile-find-replace-bar`,className:`univer-fixed univer-inset-x-0 univer-z-40 univer-grid univer-gap-2 univer-bg-gray-0 univer-px-2 univer-pt-1.5 univer-shadow-[0_-4px_16px_rgba(0,0,0,0.08)] dark:!univer-bg-gray-800`,style:{bottom:(v==null?void 0:v.bottom)??0,paddingBottom:`calc(6px + env(safe-area-inset-bottom, 0px))`},children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-flex`,children:[/* @__PURE__ */ (0,s.jsx)(Y,{label:c.t(`find-replace.mobile.settings`),onClick:T,children:/* @__PURE__ */ (0,s.jsx)(Ee,{})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-relative univer-mr-2 univer-min-w-0 univer-flex-1`,children:[/* @__PURE__ */ (0,s.jsx)(G,{className:`univer-pointer-events-none univer-absolute univer-left-3 univer-top-1/2 univer-z-10 univer-size-5 -univer-translate-y-1/2 univer-text-gray-500`}),/* @__PURE__ */ (0,s.jsx)(n.Input,{ref:h,size:`middle`,allowClear:!0,value:f,placeholder:c.t(`find-replace.dialog.find-placeholder`),inputClass:`!univer-pl-10`,slot:E?/* @__PURE__ */ (0,s.jsx)(`span`,{className:`univer-text-xs univer-text-gray-400`,children:E}):void 0,onChange:e=>{p(e),S(e)},onKeyDown:e=>{e.key===`Enter`&&w(N.id)}})]}),/* @__PURE__ */ (0,s.jsx)(Y,{disabled:D,label:c.t(`find-replace.mobile.previous-match`),onClick:()=>w(P.id,!0),children:/* @__PURE__ */ (0,s.jsx)(Se,{})}),/* @__PURE__ */ (0,s.jsx)(Y,{disabled:D,label:c.t(`find-replace.mobile.next-match`),onClick:()=>w(N.id,!0),children:/* @__PURE__ */ (0,s.jsx)(be,{})}),/* @__PURE__ */ (0,s.jsx)(Y,{label:c.t(`find-replace.mobile.close`),onClick:()=>{C(),e.executeCommand(M.id).catch(()=>void 0)},children:/* @__PURE__ */ (0,s.jsx)(we,{})})]}),l.replaceRevealed&&/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-flex univer-gap-1 univer-pl-9`,children:[/* @__PURE__ */ (0,s.jsx)(n.Input,{size:`middle`,className:`univer-min-w-0 univer-flex-1`,value:l.replaceString,placeholder:c.t(`find-replace.dialog.replace-placeholder`),onChange:e=>a.changeReplaceString(e)}),/* @__PURE__ */ (0,s.jsx)(Le,{disabled:A,onClick:()=>w(O.id),children:c.t(`find-replace.dialog.replace`)}),/* @__PURE__ */ (0,s.jsx)(Le,{disabled:j,onClick:()=>w(k.id),children:c.t(`find-replace.dialog.replace-all`)})]})]})}function Y(e){return/* @__PURE__ */ (0,s.jsx)(n.Button,{type:`button`,"aria-label":e.label,disabled:e.disabled,variant:`text`,size:`icon`,className:`univer-size-9 univer-flex-none univer-rounded-full`,onClick:e.onClick,children:e.children})}function Le(e){return/* @__PURE__ */ (0,s.jsx)(n.Button,{type:`button`,disabled:e.disabled,variant:`primary`,size:`large`,className:`univer-flex-none`,onClick:e.onClick,children:e.children})}let X=class extends t.RxDisposable{constructor(e,t,n,i,o,s,c){super(),[A,j,M,N,P,k,O,F].forEach(e=>this.disposeWithMe(t.registerCommand(e))),o.mergeMenu(Pe),this.disposeWithMe(c.registerComponent(r.BuiltInUIPart.FOOTER,()=>(0,r.connectInjector)(Fe,e))),i.stateUpdates$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{e.revealed===!1&&n.close(ke)});let l=null;i.stateUpdates$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{if(e.revealed===!0){var t;l=((t=s.getFocusedUnit())==null?void 0:t.getUnitId())??null}else e.revealed===!1&&(l=null)}),s.focused$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{l&&e!==l&&i.terminate()})}};X=_([g(0,(0,t.Inject)(t.Injector)),g(1,t.ICommandService),g(2,r.IDialogService),g(3,y),g(4,r.IMenuManagerService),g(5,t.IUniverInstanceService),g(6,r.IUIPartsService)],X);let Z=class extends t.Plugin{constructor(e=U,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},U,this._config);this._configService.setConfig(fe,i)}onStarting(){this._injector.add([J]),this._injector.get(J),[[X],[y,{useClass:D}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(X)}};h(Z,`pluginName`,`UNIVER_FIND_REPLACE_PLUGIN`),h(Z,`packageName`,ue),h(Z,`version`,de),Z=_([(0,t.DependentOn)(r.UniverMobileUIPlugin),g(1,(0,t.Inject)(t.Injector)),g(2,t.IConfigService)],Z);function Re(e){let{findCompleted:i,matchesCount:a,matchesPosition:c,initialFindString:l,findReplaceService:u,onChange:d,...f}=e,p=(0,r.useDependency)(t.LocaleService),[m,h]=(0,o.useState)(l),g=i&&a===0?p.t(`find-replace.dialog.no-result`):a===0?` `:void 0;function _(e){c===a&&e===1?u.moveToNextMatch():c===1&&e===a||e<c?u.moveToPreviousMatch():u.moveToNextMatch()}return/* @__PURE__ */ (0,s.jsx)(`div`,{className:`univer-relative univer-flex univer-items-center univer-gap-2`,onDrag:e=>e.stopPropagation(),children:/* @__PURE__ */ (0,s.jsx)(n.Input,{"data-u-comp":`search-input`,autoFocus:!0,placeholder:p.t(`find-replace.dialog.find-placeholder`),value:m,onChange:e=>{h(e),d==null||d(e)},slot:/* @__PURE__ */ (0,s.jsx)(n.Pager,{loop:!0,text:g,value:c,total:a,onChange:_}),...f})})}let ze=[{label:`find-replace.dialog.find-scope.current-sheet`,value:`subunit`},{label:`find-replace.dialog.find-scope.workbook`,value:`unit`}],Be=[{label:`find-replace.dialog.find-direction.row`,value:`row`},{label:`find-replace.dialog.find-direction.column`,value:`column`}],Ve=[{label:`find-replace.dialog.find-by.value`,value:`value`},{label:`find-replace.dialog.find-by.formula`,value:`formula`}];function He(e,t){let n=(0,o.useRef)(null),r=(0,o.useCallback)(()=>{var e;(e=document.querySelector(`.univer-find-input input`))==null||e.focus()},[]),i=(0,o.useCallback)(()=>{r(),n.current=requestAnimationFrame(()=>{n.current=null,r()})},[r]),a=(0,o.useCallback)(()=>{let e=document.querySelectorAll(`[data-u-comp=find-replace-dialog] [data-u-comp=search-input]`);return Array.from(e).some(e=>e===document.activeElement)},[]);return(0,o.useImperativeHandle)(t,()=>({focus:r,selectHasFocus:a})),(0,o.useEffect)(()=>{let t=e.focusSignal$.subscribe(()=>r());return()=>{t.unsubscribe(),n.current!==null&&cancelAnimationFrame(n.current)}},[e,r]),{focus:r,focusAfterDialogClose:i,selectHasFocus:a}}let Ue=(0,o.forwardRef)(function(e,n){let i=(0,r.useDependency)(t.LocaleService),a=(0,r.useDependency)(y),c=(0,r.useDependency)(t.ICommandService),{findCompleted:l,findString:u,matchesCount:d,matchesPosition:f}=(0,r.useObservable)(a.state$,void 0,!0),p=(0,o.useCallback)(()=>{c.executeCommand(j.id)},[c]),m=(0,r.useDebounceFn)(e=>a.changeFindString(e),500);return He(a,n),/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(Re,{findCompleted:l,matchesCount:d,matchesPosition:f,findReplaceService:a,initialFindString:u,onChange:m}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:`univer-mt-4 univer-text-center`,children:/* @__PURE__ */ (0,s.jsx)(`a`,{className:`univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors hover:univer-text-primary-500`,onClick:p,children:i.t(`find-replace.dialog.advanced-finding`)})})]})}),We=(0,o.forwardRef)(function(e,i){let a=(0,r.useDependency)(y),c=(0,r.useDependency)(t.LocaleService),l=(0,r.useDependency)(t.ICommandService),u=(0,r.useDependency)(r.IMessageService),d=(0,r.useObservable)(a.currentMatch$,void 0,!0),f=(0,r.useObservable)(a.replaceables$,void 0,!0),p=(0,r.useObservable)(a.providerCapabilities$,null,!0),{matchesCount:m,matchesPosition:h,findString:g,inputtingFindString:_,replaceString:v,caseSensitive:b,matchesTheWholeCell:x,matchesTheWholeWord:S,findDirection:C,findScope:w,findBy:T,findCompleted:E}=(0,r.useObservable)(a.state$,void 0,!0),D=_.length===0,A=m===0||!(d!=null&&d.replaceable),j=f.length===0,M=(0,o.useCallback)(e=>a.changeInputtingFindString(e),[a]),N=(0,o.useCallback)(e=>a.changeReplaceString(e),[a]),{focusAfterDialogClose:P}=He(a,i),F=(0,o.useCallback)(()=>{g===_?a.moveToNextMatch():(a.changeFindString(_),a.find())},[g,_,a]),I=(0,o.useCallback)(()=>l.executeCommand(O.id),[l]),ee=(0,o.useCallback)(async()=>{await l.executeCommand(k.id),P()},[l,P]),L=(0,o.useCallback)(e=>{a.changeFindDirection(e)},[a]),te=(0,o.useCallback)(e=>{a.changeFindScope(e)},[a]),R=(0,o.useCallback)(e=>{a.changeFindBy(e)},[a]),z=ze.map(e=>({...e,label:c.t(e.label)})),B=Be.map(e=>({...e,label:c.t(e.label)})),V=Ve.map(e=>({...e,label:c.t(e.label)}));return(0,o.useEffect)(()=>{E&&m===0&&u.show({content:c.t(`find-replace.dialog.no-match`),type:n.MessageType.Warning,duration:5e3})},[E,m,u,c]),/* @__PURE__ */ (0,s.jsxs)(`div`,{children:[/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find`),children:/* @__PURE__ */ (0,s.jsx)(Re,{findCompleted:E,className:`univer-find-input`,matchesCount:m,matchesPosition:h,findReplaceService:a,initialFindString:_,onChange:M})}),/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.replace`),children:/* @__PURE__ */ (0,s.jsx)(n.Input,{placeholder:c.t(`find-replace.dialog.replace-placeholder`),value:v,onChange:e=>N(e)})}),(p==null?void 0:p.findDirection)&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find-direction.title`),children:/* @__PURE__ */ (0,s.jsx)(n.Select,{value:C,options:B,onChange:L})}),((p==null?void 0:p.findScope)||(p==null?void 0:p.findBy))&&/* @__PURE__ */ (0,s.jsx)(n.FormDualColumnLayout,{children:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[p.findScope&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find-scope.title`),children:/* @__PURE__ */ (0,s.jsx)(n.Select,{value:w,options:z,onChange:te})}),p.findBy&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find-by.title`),children:/* @__PURE__ */ (0,s.jsx)(n.Select,{value:T,options:V,onChange:R})})]})}),((p==null?void 0:p.caseSensitive)||(p==null?void 0:p.matchesTheWholeCell)||(p==null?void 0:p.matchesTheWholeWord))&&/* @__PURE__ */ (0,s.jsx)(n.FormDualColumnLayout,{children:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[p.caseSensitive&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:b,onChange:e=>{a.changeCaseSensitive(!!e),E&&a.find()},children:c.t(`find-replace.dialog.case-sensitive`)})}),p.matchesTheWholeCell&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:x,onChange:e=>a.changeMatchesTheWholeCell(!!e),children:c.t(`find-replace.dialog.match-the-whole-cell`)})}),p.matchesTheWholeWord&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:S,onChange:e=>{a.changeMatchesTheWholeWord(!!e),E&&a.find()},children:c.t(`find-replace.dialog.match-the-whole-word`)})})]})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-mt-6 univer-flex univer-justify-between`,children:[/* @__PURE__ */ (0,s.jsx)(n.Button,{variant:`primary`,onClick:F,disabled:D,children:c.t(`find-replace.dialog.find`)}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:`univer-inline-flex univer-gap-2`,children:[/* @__PURE__ */ (0,s.jsx)(n.Button,{disabled:A,onClick:I,children:c.t(`find-replace.dialog.replace`)}),/* @__PURE__ */ (0,s.jsx)(n.Button,{disabled:j,onClick:ee,children:c.t(`find-replace.dialog.replace-all`)})]})]})]})});function Ge(){let e=(0,r.useDependency)(y),n=(0,r.useDependency)(r.ILayoutService),i=(0,r.useDependency)(t.IContextService),u=(0,r.useObservable)(e.state$,void 0,!0),d=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=d.current;if(!e)return;let t=n.registerContainerElement(e);return()=>t.dispose()},[n]);let f=(0,o.useRef)(null),p=(0,o.useCallback)(e=>i.setContextValue(l,e),[i]),m=(0,o.useCallback)(e=>i.setContextValue(c,e),[i]);return(0,o.useEffect)(()=>{var e;let t=(0,a.fromEvent)(document,`focusin`).subscribe(e=>{var t;e.target&&(t=d.current)!=null&&t.contains(e.target)?p(!0):p(!1),!f.current||!f.current.selectHasFocus()?m(!1):m(!0)});return(e=f.current)==null||e.focus(),p(!0),m(!0),()=>{t.unsubscribe(),p(!1)}},[p,m]),/* @__PURE__ */ (0,s.jsx)(`div`,{ref:d,"data-u-comp":`find-replace-dialog`,children:u.replaceRevealed?/* @__PURE__ */ (0,s.jsx)(We,{ref:f}):/* @__PURE__ */ (0,s.jsx)(Ue,{ref:f})})}let Q=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({SearchIcon:G}))}_registerComponents(){[[`FindReplaceDialog`,Ge]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};Q=_([g(0,(0,t.Inject)(r.ComponentManager)),g(1,(0,t.Inject)(r.IconManager))],Q);let $=class extends t.Plugin{constructor(e=U,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},U,this._config);this._configService.setConfig(fe,i)}onStarting(){this._injector.add([Q]),this._injector.get(Q),[[H],[y,{useClass:D}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(H)}};h($,`pluginName`,`UNIVER_FIND_REPLACE_PLUGIN`),h($,`packageName`,ue),h($,`version`,de),$=_([g(1,(0,t.Inject)(t.Injector)),g(2,t.IConfigService)],$),e.CloseFindDialogOperation=M,e.FindBy=C,e.FindDirection=S,e.FindModel=v,Object.defineProperty(e,"FindReplaceController",{enumerable:!0,get:function(){return H}}),e.FindReplaceMenuSchema=ee,Object.defineProperty(e,"FindReplaceModel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"FindReplaceService",{enumerable:!0,get:function(){return D}}),e.FindReplaceState=E,e.FindScope=w,e.GoToNextMatchOperation=N,e.GoToPreviousMatchOperation=P,e.IFindReplaceService=y,e.OpenFindDialogOperation=A,e.OpenReplaceDialogOperation=j,e.ReplaceAllMatchesCommand=k,e.ReplaceCurrentMatchCommand=O,Object.defineProperty(e,"UniverFindReplaceMobileUIPlugin",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UniverFindReplacePlugin",{enumerable:!0,get:function(){return $}}),e.createInitFindReplaceState=T});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/design`,`@univerjs/ui`,`@univerjs/engine-render`,`rxjs`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverFindReplace={},e.UniverCore,e.UniverDesign,e.UniverUi,e.UniverEngineRender,e.rxjs,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let c=`FIND_REPLACE_INPUT_FOCUS`,l=`FIND_REPLACE_DIALOG_FOCUS`,u=`FIND_REPLACE_REPLACE_REVEALED`,d=`FIND_REPLACE_AVAILABLE`;function f(e){"@babel/helpers - typeof";return f=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},f(e)}function p(e,t){if(f(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(f(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){var t=p(e,`string`);return f(t)==`symbol`?t:t+``}function h(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e,t){return function(n,r){t(n,r,e)}}function _(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var v=class extends t.Disposable{};let y=(0,t.createIdentifier)(`find-replace.service`);function b(e){return e.findString!==void 0||e.inputtingFindString!==void 0||e.findDirection!==void 0||e.matchesTheWholeCell!==void 0||e.matchesTheWholeWord!==void 0||e.caseSensitive!==void 0||e.findScope!==void 0||e.findBy!==void 0}let x=class extends t.Disposable{get searched(){return this._findModels.length>0}constructor(e,t,n,r){super(),this._state=e,this._providers=t,this._univerInstanceService=n,this._commandService=r,h(this,`currentMatch$`,new a.BehaviorSubject(null)),h(this,`replaceables$`,new a.BehaviorSubject([])),h(this,`_findModels`,[]),h(this,`_matchingModel`,null),h(this,`_matches`,[]),h(this,`_currentSearchingDisposables`,null),this.disposeWithMe(this._state.stateUpdates$.pipe((0,a.throttleTime)(200,void 0,{leading:!0,trailing:!0})).subscribe(async e=>{let t=this._state.state;b(e)&&(t.findString!==``&&!t.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):e.replaceRevealed!==!0&&this._stopSearching())}))}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...T(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};let e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}focusSelection(){var e;(e=this._matchingModel)==null||e.focusSelection()}async _startSearching(){if(!this._state.findString)return{results:[]};let e=Array.from(this._providers),t=this._findModels=(await Promise.all(e.map(e=>e.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell,matchesTheWholeWord:this._state.matchesTheWholeWord})))).flat();this._subscribeToModelsChanges(t);let n=this._matches=t.map(e=>e.getMatches()).flat();return this.replaceables$.next(n.filter(e=>e.replaceable)),n.length?(this._moveToInitialMatch(t),this._state.changeState({matchesCount:n.length}),{results:n}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var e;this._providers.forEach(e=>e.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({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){let n=this._currentSearchingDisposables=new t.DisposableCollection,r=(0,a.combineLatest)(e.map(e=>e.matchesUpdate$)).pipe((0,a.debounceTime)(220)).subscribe(([...e])=>{let t=this._matches=e.flat();t.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:t.length}),this.replaceables$.next(t.filter(e=>e.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(e=>n.add((0,t.toDisposable)(e.activelyChangingMatch$.subscribe(e=>{let t=this._matches.findIndex(t=>t===e);this._state.changeState({matchesPosition:t+1})})))),n.add((0,t.toDisposable)(r))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){let e=await Promise.all(this._findModels.map(e=>e.replaceAll(this._state.replaceString))).then(e=>e.reduce((e,t)=>(e.success+=t.success,e.failure+=t.failure,e),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(e){let t=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:t+1})}moveToNextMatch(){if(!this._matchingModel)return;let e=this._findModels.length===1,t=this._matchingModel.moveToNextMatch({loop:e});if(t)return this._markMatch(t),t;{let e=this._findModels.findIndex(e=>e===this._matchingModel);return this._moveToNextUnitMatch(e)}}_moveToNextUnitMatch(e){let t=this._findModels.length;for(let n=(e+1)%t;n!==e;){let e=this._findModels[n],r=e.moveToNextMatch({ignoreSelection:!0});if(r)return this._matchingModel=e,this._markMatch(r),r;n=(n+1)%t}if(this._matchingModel){let e=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return e&&this._markMatch(e),e}}moveToPreviousMatch(){if(!this._matchingModel)return;let e=this._findModels.length===1,t=this._matchingModel.moveToPreviousMatch({loop:e});if(t){let e=this._matches.findIndex(e=>e===t);return this.currentMatch$.next(t),this._state.changeState({matchesPosition:e+1}),t}{let e=this._findModels.length,t=this._findModels.findIndex(e=>e===this._matchingModel);for(let n=(t-1+e)%e;n!==t;){let t=this._findModels[n],r=t.moveToPreviousMatch({ignoreSelection:!0});if(r)return this._matchingModel=t,this._markMatch(r),r;n=(n-1)%e}let n=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return n&&this._markMatch(n),n}}_moveToInitialMatch(e,t=!1){var n;let r=(n=this._univerInstanceService.getFocusedUnit())==null?void 0:n.getUnitId();if(!r)return-1;let i=e.findIndex(e=>e.unitId===r);if(i!==-1){this._matchingModel=e[i];let n=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:t});if(n)return this._markMatch(n),i}return this._moveToNextUnitMatch(i),0}};x=_([g(2,t.IUniverInstanceService),g(3,t.ICommandService)],x);let S=/* @__PURE__ */ function(e){return e.ROW=`row`,e.COLUMN=`column`,e}({}),C=/* @__PURE__ */ function(e){return e.VALUE=`value`,e.FORMULA=`formula`,e}({}),w=/* @__PURE__ */ function(e){return e.SUBUNIT=`subunit`,e.UNIT=`unit`,e}({});function T(){return{caseSensitive:!1,findBy:`value`,findCompleted:!1,findDirection:`row`,findScope:`subunit`,findString:``,inputtingFindString:``,matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,matchesTheWholeWord:!1,replaceRevealed:!1,replaceString:``,revealed:!0}}var E=class{constructor(){h(this,`_stateUpdates$`,new a.Subject),h(this,`stateUpdates$`,this._stateUpdates$.asObservable()),h(this,`_state$`,new a.BehaviorSubject(T())),h(this,`state$`,this._state$.asObservable()),h(this,`_findString`,``),h(this,`_inputtingFindString`,``),h(this,`_replaceString`,``),h(this,`_revealed`,!1),h(this,`_replaceRevealed`,!1),h(this,`_matchesPosition`,0),h(this,`_matchesCount`,0),h(this,`_caseSensitive`,!0),h(this,`_matchesTheWholeCell`,!1),h(this,`_matchesTheWholeWord`,!1),h(this,`_findDirection`,`row`),h(this,`_findScope`,`subunit`),h(this,`_findBy`,`value`),h(this,`_findCompleted`,!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get matchesTheWholeWord(){return this._matchesTheWholeWord}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let t=!1,n={};e.findString!==void 0&&e.findString!==this._findString&&(this._findString=e.findString,n.findString=this._findString,t=!0),e.revealed!==void 0&&e.revealed!==this._revealed&&(this._revealed=e.revealed,n.revealed=e.revealed,t=!0),e.replaceRevealed!==void 0&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,n.replaceRevealed=e.replaceRevealed,t=!0),e.replaceString!==void 0&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,n.replaceString=e.replaceString,t=!0),e.matchesCount!==void 0&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,n.matchesCount=e.matchesCount,t=!0),e.matchesPosition!==void 0&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,n.matchesPosition=e.matchesPosition,t=!0),e.findBy!==void 0&&e.findBy!==this._findBy&&(this._findBy=e.findBy,n.findBy=e.findBy,t=!0),e.findScope!==void 0&&e.findScope!==this._findScope&&(this._findScope=e.findScope,n.findScope=e.findScope,t=!0),e.findDirection!==void 0&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,n.findDirection=e.findDirection,t=!0),e.caseSensitive!==void 0&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,n.caseSensitive=e.caseSensitive,t=!0),e.matchesTheWholeCell!==void 0&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,n.matchesTheWholeCell=e.matchesTheWholeCell,t=!0),e.matchesTheWholeWord!==void 0&&e.matchesTheWholeWord!==this._matchesTheWholeWord&&(this._matchesTheWholeWord=e.matchesTheWholeWord,n.matchesTheWholeWord=e.matchesTheWholeWord,t=!0),e.inputtingFindString!==void 0&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,n.inputtingFindString=e.inputtingFindString,t=!0),e.findCompleted!==void 0&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,n.findCompleted=e.findCompleted,t=!0),t&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,matchesTheWholeWord:this._matchesTheWholeWord,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(n))}};let D=class extends t.Disposable{get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}constructor(e,n,r){super(),this._injector=e,this._contextService=n,this._univerInstanceService=r,h(this,`_providers`,/* @__PURE__ */ new Set),h(this,`_state`,new E),h(this,`_model`,void 0),h(this,`_modelDisposables`,null),h(this,`_currentMatch$`,new a.BehaviorSubject(null)),h(this,`currentMatch$`,this._currentMatch$.asObservable()),h(this,`_replaceables$`,new a.BehaviorSubject([])),h(this,`replaceables$`,this._replaceables$.asObservable()),h(this,`_focusSignal$`,new a.Subject),h(this,`focusSignal$`,this._focusSignal$.asObservable()),h(this,`_providerCapabilities$`,new a.BehaviorSubject(null)),h(this,`providerCapabilities$`,this._providerCapabilities$.asObservable()),h(this,`_activeProvider`,null),this.disposeWithMe((0,t.toDisposable)(this._univerInstanceService.focused$.subscribe(()=>this._syncActiveProvider())))}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete(),this._providerCapabilities$.complete()}getProviders(){return this._providers}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:``,findString:``})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeMatchesTheWholeWord(e){this._state.changeState({matchesTheWholeWord:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e===`formula`)}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw Error(`[FindReplaceService] replaceAll: model is not initialized!`);return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}hideReplace(){this._state.changeState({replaceRevealed:!1,findString:this._state.inputtingFindString}),this._toggleRevealReplace(!1)}focusSelection(){var e;(e=this._model)==null||e.focusSelection()}start(e=!1){if(!this._activeProvider)return!1;this._model=this._injector.createInstance(x,this._state,/* @__PURE__ */ new Set([this._activeProvider])),this._modelDisposables=new t.DisposableCollection,this._modelDisposables.add((0,t.toDisposable)(this._model.currentMatch$.subscribe(e=>this._currentMatch$.next(e)))),this._modelDisposables.add((0,t.toDisposable)(this._model.replaceables$.subscribe(e=>this._replaceables$.next(e))));let n=T();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e,t;(e=this._model)==null||e.dispose(),this._model=null,(t=this._modelDisposables)==null||t.dispose(),this._modelDisposables=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),this._syncActiveProvider(),(0,t.toDisposable)(()=>{this._providers.delete(e),this._syncActiveProvider()})}_syncActiveProvider(){let e=this._univerInstanceService.getFocusedUnit(),t=e==null?null:Array.from(this._providers).find(t=>t.isSupported(e))??null;t!==this._activeProvider&&(this.revealed&&this.terminate(),this._activeProvider=t,this._providerCapabilities$.next((t==null?void 0:t.capabilities)??null),this._contextService.setContextValue(d,t!=null))}_toggleRevealReplace(e){this._contextService.setContextValue(u,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(i.RENDER_RAW_FORMULA_KEY,e)}};D=_([g(0,(0,t.Inject)(t.Injector)),g(1,t.IContextService),g(2,t.IUniverInstanceService)],D);let O={id:`ui.command.replace-current-match`,type:t.CommandType.COMMAND,handler:e=>e.get(y).replace()},k={id:`ui.command.replace-all-matches`,type:t.CommandType.COMMAND,handler:async e=>{let i=e.get(t.IConfirmService),a=e.get(t.LocaleService),o=e.get(r.IMessageService);if(!await i.confirm({id:`CONFIRM_REPLACE_ALL`,title:{title:a.t(`find-replace.replace.confirm.title`)},cancelText:a.t(`find-replace.button.cancel`),confirmText:a.t(`find-replace.button.confirm`)}))return!1;let{success:s,failure:c}=await e.get(y).replaceAll();return c>0?(s===0?o.show({type:n.MessageType.Error,content:a.t(`find-replace.replace.all-failure`)}):o.show({type:n.MessageType.Warning,content:a.t(`find-replace.replace.partial-success`,`${s}`,`${c}`)}),!1):(o.show({type:n.MessageType.Success,content:a.t(`find-replace.replace.all-success`,`${s}`)}),!0)}},A={id:`ui.operation.open-find-dialog`,type:t.CommandType.OPERATION,handler:e=>{let t=e.get(y);return t.revealed?t.focusFindInput():t.start(),!0}},j={id:`ui.operation.open-replace-dialog`,type:t.CommandType.OPERATION,handler:e=>{let t=e.get(y);return t.revealed?t.replaceRevealed?t.focusFindInput():t.revealReplace():t.start(!0),!0}},M={id:`ui.operation.close-find-dialog`,type:t.CommandType.OPERATION,handler:e=>(e.get(y).terminate(),!0)},N={type:t.CommandType.OPERATION,id:`ui.operation.go-to-next-match`,handler:e=>(e.get(y).moveToNextMatch(),!0)},P={type:t.CommandType.OPERATION,id:`ui.operation.go-to-previous-match`,handler:e=>(e.get(y).moveToPreviousMatch(),!0)},F={type:t.CommandType.OPERATION,id:`ui.operation.focus-selection`,handler:e=>(e.get(y).focusSelection(),!0)};function I(e){let n=e.get(t.IContextService);return{id:A.id,icon:`SearchIcon`,tooltip:`find-replace.toolbar`,type:r.MenuItemType.BUTTON,hidden$:(0,r.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,a.combineLatest)([n.subscribeContextValue$(t.EDITOR_ACTIVATED),n.subscribeContextValue$(t.FOCUSING_SHEET),n.subscribeContextValue$(d).pipe((0,a.startWith)(n.getContextValue(d)))]).pipe((0,a.map)(([e,t,n])=>e||!t||!n))}}let ee={[r.RibbonDataGroup.OTHERS]:{[A.id]:{order:0,gridLayout:{row:1,column:1,rowSpan:2,columnSpan:2,showLabel:!0},menuItemFactory:I}}};function L(e){return e.getContextValue(l)}function te(e){return e.getContextValue(u)}function R(e){return e.getContextValue(c)}let z=`7_find-replace-shortcuts`;function B(e){return e.getContextValue(d)}function V(e){return!e.getContextValue(t.EDITOR_ACTIVATED)}let ne={id:A.id,description:`find-replace.shortcut.open-find-dialog`,binding:r.KeyCode.F|r.MetaKeys.CTRL_COMMAND,group:z,groupTitle:`find-replace.shortcut.panel`,preconditions(e){return!L(e)&&B(e)&&V(e)}},re={id:A.id,description:`find-replace.shortcut.open-find-dialog`,binding:r.KeyCode.F|r.MetaKeys.CTRL_COMMAND,mac:r.KeyCode.F|r.MetaKeys.MAC_CTRL,preconditions(e){return!L(e)&&B(e)&&V(e)}},ie={id:j.id,description:`find-replace.shortcut.open-replace-dialog`,binding:r.KeyCode.H|r.MetaKeys.CTRL_COMMAND,mac:r.KeyCode.H|r.MetaKeys.MAC_CTRL,group:z,groupTitle:`find-replace.shortcut.panel`,preconditions(e){return B(e)&&V(e)&&(!L(e)||!te(e))}},ae={id:N.id,description:`find-replace.shortcut.go-to-next-match`,binding:r.KeyCode.ENTER,group:z,groupTitle:`find-replace.shortcut.panel`,priority:1e3,preconditions(e){return R(e)&&L(e)}},oe={id:P.id,description:`find-replace.shortcut.go-to-previous-match`,binding:r.KeyCode.ENTER|r.MetaKeys.SHIFT,group:z,groupTitle:`find-replace.shortcut.panel`,priority:1e3,preconditions(e){return R(e)&&L(e)}},se={id:F.id,description:`find-replace.shortcut.focus-selection`,binding:r.KeyCode.ESC,group:z,groupTitle:`find-replace.shortcut.panel`,priority:1e3,preconditions(e){return L(e)}},ce=`DESKTOP_FIND_REPLACE_DIALOG`,H=class extends t.RxDisposable{constructor(e,t,n,r,i,a,o,s){super(),this._univerInstanceService=e,this._menuManagerService=t,this._shortcutService=n,this._commandService=r,this._findReplaceService=i,this._dialogService=a,this._layoutService=o,this._localeService=s,h(this,`_closingListenerDisposable`,void 0),this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var e;super.dispose(),(e=this._closingListenerDisposable)==null||e.dispose(),this._closingListenerDisposable=null}_initCommands(){[A,j,M,N,P,k,O,F].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[ie,ne,re,oe,ae,se].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this._menuManagerService.mergeMenu(ee),this._findReplaceService.stateUpdates$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{e.revealed===!0?this._openPanel():e.revealed===!1&&this._closePanel(!1)})}_openPanel(){var e;let n=(e=this._univerInstanceService.getFocusedUnit())==null?void 0:e.getUnitId();this._dialogService.open({id:ce,draggable:!0,width:350,title:{title:this._localeService.t(`find-replace.dialog.title`)},children:{label:`FindReplaceDialog`},mask:!1,maskClosable:!1,defaultPosition:le(this._localeService.getDirection()),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=(0,t.toDisposable)(this._univerInstanceService.focused$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{e&&e===n||this.closePanel()}))}closePanel(){this._closePanel(!0)}_closePanel(e){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(ce),e&&this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}};H=_([g(0,t.IUniverInstanceService),g(1,r.IMenuManagerService),g(2,r.IShortcutService),g(3,t.ICommandService),g(4,y),g(5,r.IDialogService),g(6,r.ILayoutService),g(7,(0,t.Inject)(t.LocaleService))],H);function le(e){let{innerWidth:t}=window;return{x:e===`rtl`?20:t-350-20,y:64}}var ue=`@univerjs/find-replace`,de=`1.5.0`;let fe=`find-replace.config`,U={};function W({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:s,...c}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,o.useId)()}`,d=(0,o.useRef)(null);return(0,o.useImperativeHandle)(e,()=>d.current),(0,o.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return ge(d.current)},[n,r]),pe(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...c},s)}function pe(e,t,n,r,i){return(0,o.createElement)(e.tag,{key:t,...me(e,n,i),...r},(he(e,n).children||[]).map((r,a)=>pe(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function me(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function he(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function ge(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:_e(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(ve(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function _e(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function ve(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}W.displayName=`UniverIcon`;let ye={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 2.5V13.5M3 8.5L8 13.5L13 8.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},be=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`arrow-down-icon`,ref:t,icon:ye}))});be.displayName=`ArrowDownIcon`;let xe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 13.5V2.5M3 7.5L8 2.5L13 7.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},Se=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`arrow-up-icon`,ref:t,icon:xe}))});Se.displayName=`ArrowUpIcon`;let Ce={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.3 3.3L12.7 12.7M12.7 3.3L3.3 12.7`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},we=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`close-icon`,ref:t,icon:Ce}))});we.displayName=`CloseIcon`;let Te={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.7 3.2h2.6l.4 1.7 1.4.6 1.5-.9 1.8 1.8-.9 1.5.6 1.4 1.7.4v2.6l-1.7.4-.6 1.4.9 1.5-1.8 1.8-1.5-.9-1.4.6-.4 1.7H8.7l-.4-1.7-1.4-.6-1.5.9-1.8-1.8.9-1.5-.6-1.4-1.7-.4V9.7l1.7-.4.6-1.4-.9-1.5 1.8-1.8 1.5.9 1.4-.6.4-1.7Z`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.6}},{tag:`circle`,attrs:{cx:10,cy:11,r:2.2,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.6}}]},Ee=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`configure-tab-icon`,ref:t,icon:Te}))});Ee.displayName=`ConfigureTabIcon`;let De={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`g`,attrs:{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2},children:[{tag:`circle`,attrs:{cx:7,cy:7,r:5.2}},{tag:`path`,attrs:{d:`M10.8 10.8L14.2 14.2`}}]}]},G=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(W,Object.assign({},e,{id:`search-icon`,ref:t,icon:De}))});G.displayName=`SearchIcon`;let Oe=`MobileFindReplaceSettings`,ke=`MOBILE_FIND_REPLACE_SETTINGS_DIALOG`,Ae=[{label:`find-replace.dialog.find-scope.current-sheet`,value:`subunit`},{label:`find-replace.dialog.find-scope.workbook`,value:`unit`}],je=[{label:`find-replace.dialog.find-direction.row`,value:`row`},{label:`find-replace.dialog.find-direction.column`,value:`column`}],Me=[{label:`find-replace.dialog.find-by.value`,value:`value`},{label:`find-replace.dialog.find-by.formula`,value:`formula`}];function Ne(){let e=(0,r.useDependency)(y),n=(0,r.useDependency)(t.LocaleService),i=(0,r.useObservable)(e.state$,void 0,!0),a=(0,r.useObservable)(e.providerCapabilities$,null,!0);function o(t=!1){i.findString&&(t||i.replaceRevealed)&&e.find()}let c=Ae.map(e=>({...e,label:n.t(e.label)})),l=je.map(e=>({...e,label:n.t(e.label)})),u=Me.map(e=>({...e,label:n.t(e.label)}));return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-grid univer-gap-2`,"data-u-comp":`mobile-find-replace-settings`,children:[/* @__PURE__ */ (0,s.jsx)(q,{checked:i.replaceRevealed,label:n.t(`find-replace.dialog.replace`),onChange:t=>{t?e.revealReplace():e.hideReplace(),o(!0)}}),(a==null?void 0:a.findDirection)&&/* @__PURE__ */ (0,s.jsx)(K,{label:n.t(`find-replace.dialog.find-direction.title`),value:i.findDirection,options:l,onChange:t=>{e.changeFindDirection(t),o()}}),(a==null?void 0:a.findScope)&&/* @__PURE__ */ (0,s.jsx)(K,{label:n.t(`find-replace.dialog.find-scope.title`),value:i.findScope,options:c,onChange:t=>{e.changeFindScope(t),o()}}),(a==null?void 0:a.findBy)&&/* @__PURE__ */ (0,s.jsx)(K,{label:n.t(`find-replace.dialog.find-by.title`),value:i.findBy,options:u,onChange:t=>{e.changeFindBy(t),o()}}),(a==null?void 0:a.caseSensitive)&&/* @__PURE__ */ (0,s.jsx)(q,{checked:i.caseSensitive,label:n.t(`find-replace.dialog.case-sensitive`),onChange:t=>{e.changeCaseSensitive(t),o()}}),(a==null?void 0:a.matchesTheWholeCell)&&/* @__PURE__ */ (0,s.jsx)(q,{checked:i.matchesTheWholeCell,label:n.t(`find-replace.dialog.match-the-whole-cell`),onChange:t=>{e.changeMatchesTheWholeCell(t),o()}}),(a==null?void 0:a.matchesTheWholeWord)&&/* @__PURE__ */ (0,s.jsx)(q,{checked:i.matchesTheWholeWord,label:n.t(`find-replace.dialog.match-the-whole-word`),onChange:t=>{e.changeMatchesTheWholeWord(t),o()}})]})}function K(e){return/* @__PURE__ */ (0,s.jsxs)(`label`,{className:`univer-grid univer-gap-1 univer-text-sm univer-text-gray-700 dark:!univer-text-gray-300`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{children:e.label}),/* @__PURE__ */ (0,s.jsx)(n.MobileSelect,{value:e.value,options:e.options,onChange:e.onChange,size:`small`})]})}function q(e){return/* @__PURE__ */ (0,s.jsx)(`div`,{className:`univer-flex univer-min-h-9 univer-items-center`,children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:e.checked,onChange:t=>e.onChange(!!t),children:e.label})})}let J=class extends t.Disposable{constructor(e,t){super(),this.disposeWithMe(t.register({SearchIcon:G})),this.disposeWithMe(e.register(Oe,Ne))}};J=_([g(0,(0,t.Inject)(r.ComponentManager)),g(1,(0,t.Inject)(r.IconManager))],J);let Pe={[r.RibbonDataGroup.ORGANIZATION]:{[A.id]:{order:2,menuItemFactory:I}}};function Fe(){let e=(0,r.useDependency)(y);return(0,r.useObservable)(e.state$,void 0,!0),e.revealed?/* @__PURE__ */ (0,s.jsx)(Ie,{}):null}function Ie(){let e=(0,r.useDependency)(t.ICommandService),i=(0,r.useDependency)(r.IDialogService),a=(0,r.useDependency)(y),c=(0,r.useDependency)(t.LocaleService),l=(0,r.useObservable)(a.state$,void 0,!0),u=(0,r.useObservable)(a.currentMatch$,null,!0),d=(0,r.useObservable)(a.replaceables$,[],!0),[f,p]=(0,o.useState)(()=>l.replaceRevealed?l.inputtingFindString:l.findString),m=(0,o.useRef)(null),h=(0,o.useRef)(null),g=(0,o.useRef)(null),_=(0,o.useRef)(!1),v=(0,n.useMobileKeyboardViewportLayout)(m);(0,o.useEffect)(()=>{let e=requestAnimationFrame(()=>{var e;return(e=h.current)==null?void 0:e.focus()});return()=>cancelAnimationFrame(e)},[]),(0,o.useEffect)(()=>{let e=a.focusSignal$.subscribe(()=>{var e;_.current?_.current=!1:(e=h.current)==null||e.focus()});return()=>e.unsubscribe()},[a]),(0,o.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]);function b(){g.current&&=(clearTimeout(g.current),null)}function x(e){b(),e?a.replaceRevealed?(a.changeInputtingFindString(e),a.changeFindString(e),a.find()):a.changeFindString(e):a.changeInputtingFindString(``)}function S(e){b(),e?g.current=setTimeout(()=>x(e),500):x(e)}function C(){document.activeElement instanceof HTMLElement&&document.activeElement.blur()}function w(t,n=!1){if(C(),f!==l.findString&&(x(f),t===N.id||t===P.id))return;_.current=n;let r=e.executeCommand(t);_.current=!1,r.catch(()=>void 0)}function T(){x(f),C(),i.open({id:ke,title:{title:c.t(`find-replace.mobile.settings-title`)},children:{label:Oe}})}let E=l.findCompleted&&l.matchesCount===0?c.t(`find-replace.dialog.no-result`):l.matchesCount>0?`${l.matchesPosition}/${l.matchesCount}`:void 0,D=l.matchesCount===0,A=l.matchesCount===0||!(u!=null&&u.replaceable),j=d.length===0;return/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:m,"data-u-comp":`mobile-find-replace-bar`,className:`univer-fixed univer-inset-x-0 univer-z-40 univer-grid univer-gap-2 univer-bg-gray-0 univer-px-2 univer-pt-1.5 univer-shadow-[0_-4px_16px_rgba(0,0,0,0.08)] dark:!univer-bg-gray-800`,style:{bottom:(v==null?void 0:v.bottom)??0,paddingBottom:`calc(6px + env(safe-area-inset-bottom, 0px))`},children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-flex`,children:[/* @__PURE__ */ (0,s.jsx)(Y,{label:c.t(`find-replace.mobile.settings`),onClick:T,children:/* @__PURE__ */ (0,s.jsx)(Ee,{})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-relative univer-mr-2 univer-min-w-0 univer-flex-1`,children:[/* @__PURE__ */ (0,s.jsx)(G,{className:`univer-pointer-events-none univer-absolute univer-left-3 univer-top-1/2 univer-z-10 univer-size-5 -univer-translate-y-1/2 univer-text-gray-500`}),/* @__PURE__ */ (0,s.jsx)(n.Input,{ref:h,size:`small`,allowClear:!0,value:f,placeholder:c.t(`find-replace.dialog.find-placeholder`),inputClass:`!univer-pl-10`,slot:E?/* @__PURE__ */ (0,s.jsx)(`span`,{className:`univer-text-xs univer-text-gray-400`,children:E}):void 0,onChange:e=>{p(e),S(e)},onKeyDown:e=>{e.key===`Enter`&&w(N.id)}})]}),/* @__PURE__ */ (0,s.jsx)(Y,{disabled:D,label:c.t(`find-replace.mobile.previous-match`),onClick:()=>w(P.id,!0),children:/* @__PURE__ */ (0,s.jsx)(Se,{})}),/* @__PURE__ */ (0,s.jsx)(Y,{disabled:D,label:c.t(`find-replace.mobile.next-match`),onClick:()=>w(N.id,!0),children:/* @__PURE__ */ (0,s.jsx)(be,{})}),/* @__PURE__ */ (0,s.jsx)(Y,{label:c.t(`find-replace.mobile.close`),onClick:()=>{C(),e.executeCommand(M.id).catch(()=>void 0)},children:/* @__PURE__ */ (0,s.jsx)(we,{})})]}),l.replaceRevealed&&/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-flex univer-gap-1 univer-pl-9`,children:[/* @__PURE__ */ (0,s.jsx)(n.Input,{size:`small`,className:`univer-min-w-0 univer-flex-1`,value:l.replaceString,placeholder:c.t(`find-replace.dialog.replace-placeholder`),onChange:e=>a.changeReplaceString(e)}),/* @__PURE__ */ (0,s.jsx)(Le,{disabled:A,onClick:()=>w(O.id),children:c.t(`find-replace.dialog.replace`)}),/* @__PURE__ */ (0,s.jsx)(Le,{disabled:j,onClick:()=>w(k.id),children:c.t(`find-replace.dialog.replace-all`)})]})]})}function Y(e){return/* @__PURE__ */ (0,s.jsx)(n.Button,{type:`button`,"aria-label":e.label,disabled:e.disabled,variant:`text`,size:`icon`,className:`univer-flex-none univer-rounded-full`,onClick:e.onClick,children:e.children})}function Le(e){return/* @__PURE__ */ (0,s.jsx)(n.Button,{type:`button`,disabled:e.disabled,variant:`primary`,size:`middle`,className:`univer-flex-none`,onClick:e.onClick,children:e.children})}let X=class extends t.RxDisposable{constructor(e,t,n,i,o,s,c){super(),[A,j,M,N,P,k,O,F].forEach(e=>this.disposeWithMe(t.registerCommand(e))),o.mergeMenu(Pe),this.disposeWithMe(c.registerComponent(r.BuiltInUIPart.FOOTER,()=>(0,r.connectInjector)(Fe,e))),i.stateUpdates$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{e.revealed===!1&&n.close(ke)});let l=null;i.stateUpdates$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{if(e.revealed===!0){var t;l=((t=s.getFocusedUnit())==null?void 0:t.getUnitId())??null}else e.revealed===!1&&(l=null)}),s.focused$.pipe((0,a.takeUntil)(this.dispose$)).subscribe(e=>{l&&e!==l&&i.terminate()})}};X=_([g(0,(0,t.Inject)(t.Injector)),g(1,t.ICommandService),g(2,r.IDialogService),g(3,y),g(4,r.IMenuManagerService),g(5,t.IUniverInstanceService),g(6,r.IUIPartsService)],X);let Z=class extends t.Plugin{constructor(e=U,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},U,this._config);this._configService.setConfig(fe,i)}onStarting(){this._injector.add([J]),this._injector.get(J),[[X],[y,{useClass:D}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(X)}};h(Z,`pluginName`,`UNIVER_FIND_REPLACE_PLUGIN`),h(Z,`packageName`,ue),h(Z,`version`,de),Z=_([(0,t.DependentOn)(r.UniverMobileUIPlugin),g(1,(0,t.Inject)(t.Injector)),g(2,t.IConfigService)],Z);function Re(e){let{findCompleted:i,matchesCount:a,matchesPosition:c,initialFindString:l,findReplaceService:u,onChange:d,...f}=e,p=(0,r.useDependency)(t.LocaleService),[m,h]=(0,o.useState)(l),g=i&&a===0?p.t(`find-replace.dialog.no-result`):a===0?` `:void 0;function _(e){c===a&&e===1?u.moveToNextMatch():c===1&&e===a||e<c?u.moveToPreviousMatch():u.moveToNextMatch()}return/* @__PURE__ */ (0,s.jsx)(`div`,{className:`univer-relative univer-flex univer-items-center univer-gap-2`,onDrag:e=>e.stopPropagation(),children:/* @__PURE__ */ (0,s.jsx)(n.Input,{"data-u-comp":`search-input`,autoFocus:!0,placeholder:p.t(`find-replace.dialog.find-placeholder`),value:m,onChange:e=>{h(e),d==null||d(e)},slot:/* @__PURE__ */ (0,s.jsx)(n.Pager,{loop:!0,text:g,value:c,total:a,onChange:_}),...f})})}let ze=[{label:`find-replace.dialog.find-scope.current-sheet`,value:`subunit`},{label:`find-replace.dialog.find-scope.workbook`,value:`unit`}],Be=[{label:`find-replace.dialog.find-direction.row`,value:`row`},{label:`find-replace.dialog.find-direction.column`,value:`column`}],Ve=[{label:`find-replace.dialog.find-by.value`,value:`value`},{label:`find-replace.dialog.find-by.formula`,value:`formula`}];function He(e,t){let n=(0,o.useRef)(null),r=(0,o.useCallback)(()=>{var e;(e=document.querySelector(`.univer-find-input input`))==null||e.focus()},[]),i=(0,o.useCallback)(()=>{r(),n.current=requestAnimationFrame(()=>{n.current=null,r()})},[r]),a=(0,o.useCallback)(()=>{let e=document.querySelectorAll(`[data-u-comp=find-replace-dialog] [data-u-comp=search-input]`);return Array.from(e).some(e=>e===document.activeElement)},[]);return(0,o.useImperativeHandle)(t,()=>({focus:r,selectHasFocus:a})),(0,o.useEffect)(()=>{let t=e.focusSignal$.subscribe(()=>r());return()=>{t.unsubscribe(),n.current!==null&&cancelAnimationFrame(n.current)}},[e,r]),{focus:r,focusAfterDialogClose:i,selectHasFocus:a}}let Ue=(0,o.forwardRef)(function(e,i){let a=(0,r.useDependency)(t.LocaleService),c=(0,r.useDependency)(y),l=(0,r.useDependency)(t.ICommandService),{findCompleted:u,findString:d,matchesCount:f,matchesPosition:p}=(0,r.useObservable)(c.state$,void 0,!0),m=(0,o.useCallback)(()=>l.executeCommand(j.id),[l]),h=(0,r.useDebounceFn)(e=>c.changeFindString(e),500);return He(c,i),/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(Re,{findCompleted:u,matchesCount:f,matchesPosition:p,findReplaceService:c,initialFindString:d,onChange:h}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:`univer-mt-4 univer-text-center`,children:/* @__PURE__ */ (0,s.jsx)(n.Button,{type:`button`,variant:`link`,size:`small`,onClick:m,children:a.t(`find-replace.dialog.advanced-finding`)})})]})}),We=(0,o.forwardRef)(function(e,i){let a=(0,r.useDependency)(y),c=(0,r.useDependency)(t.LocaleService),l=(0,r.useDependency)(t.ICommandService),u=(0,r.useDependency)(r.IMessageService),d=(0,r.useObservable)(a.currentMatch$,void 0,!0),f=(0,r.useObservable)(a.replaceables$,void 0,!0),p=(0,r.useObservable)(a.providerCapabilities$,null,!0),{matchesCount:m,matchesPosition:h,findString:g,inputtingFindString:_,replaceString:v,caseSensitive:b,matchesTheWholeCell:x,matchesTheWholeWord:S,findDirection:C,findScope:w,findBy:T,findCompleted:E}=(0,r.useObservable)(a.state$,void 0,!0),D=_.length===0,A=m===0||!(d!=null&&d.replaceable),j=f.length===0,M=(0,o.useCallback)(e=>a.changeInputtingFindString(e),[a]),N=(0,o.useCallback)(e=>a.changeReplaceString(e),[a]),{focusAfterDialogClose:P}=He(a,i),F=(0,o.useCallback)(()=>{g===_?a.moveToNextMatch():(a.changeFindString(_),a.find())},[g,_,a]),I=(0,o.useCallback)(()=>l.executeCommand(O.id),[l]),ee=(0,o.useCallback)(async()=>{await l.executeCommand(k.id),P()},[l,P]),L=(0,o.useCallback)(e=>{a.changeFindDirection(e)},[a]),te=(0,o.useCallback)(e=>{a.changeFindScope(e)},[a]),R=(0,o.useCallback)(e=>{a.changeFindBy(e)},[a]),z=ze.map(e=>({...e,label:c.t(e.label)})),B=Be.map(e=>({...e,label:c.t(e.label)})),V=Ve.map(e=>({...e,label:c.t(e.label)}));return(0,o.useEffect)(()=>{E&&m===0&&u.show({content:c.t(`find-replace.dialog.no-match`),type:n.MessageType.Warning,duration:5e3})},[E,m,u,c]),/* @__PURE__ */ (0,s.jsxs)(`div`,{children:[/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find`),children:/* @__PURE__ */ (0,s.jsx)(Re,{findCompleted:E,className:`univer-find-input`,matchesCount:m,matchesPosition:h,findReplaceService:a,initialFindString:_,onChange:M})}),/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.replace`),children:/* @__PURE__ */ (0,s.jsx)(n.Input,{placeholder:c.t(`find-replace.dialog.replace-placeholder`),value:v,onChange:e=>N(e)})}),(p==null?void 0:p.findDirection)&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find-direction.title`),children:/* @__PURE__ */ (0,s.jsx)(n.Select,{value:C,options:B,onChange:L})}),((p==null?void 0:p.findScope)||(p==null?void 0:p.findBy))&&/* @__PURE__ */ (0,s.jsx)(n.FormDualColumnLayout,{children:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[p.findScope&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find-scope.title`),children:/* @__PURE__ */ (0,s.jsx)(n.Select,{value:w,options:z,onChange:te})}),p.findBy&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{label:c.t(`find-replace.dialog.find-by.title`),children:/* @__PURE__ */ (0,s.jsx)(n.Select,{value:T,options:V,onChange:R})})]})}),((p==null?void 0:p.caseSensitive)||(p==null?void 0:p.matchesTheWholeCell)||(p==null?void 0:p.matchesTheWholeWord))&&/* @__PURE__ */ (0,s.jsx)(n.FormDualColumnLayout,{children:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[p.caseSensitive&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:b,onChange:e=>{a.changeCaseSensitive(!!e),E&&a.find()},children:c.t(`find-replace.dialog.case-sensitive`)})}),p.matchesTheWholeCell&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:x,onChange:e=>a.changeMatchesTheWholeCell(!!e),children:c.t(`find-replace.dialog.match-the-whole-cell`)})}),p.matchesTheWholeWord&&/* @__PURE__ */ (0,s.jsx)(n.FormLayout,{children:/* @__PURE__ */ (0,s.jsx)(n.Checkbox,{checked:S,onChange:e=>{a.changeMatchesTheWholeWord(!!e),E&&a.find()},children:c.t(`find-replace.dialog.match-the-whole-word`)})})]})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`univer-mt-6 univer-flex univer-justify-between`,children:[/* @__PURE__ */ (0,s.jsx)(n.Button,{variant:`primary`,onClick:F,disabled:D,children:c.t(`find-replace.dialog.find`)}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:`univer-inline-flex univer-gap-2`,children:[/* @__PURE__ */ (0,s.jsx)(n.Button,{disabled:A,onClick:I,children:c.t(`find-replace.dialog.replace`)}),/* @__PURE__ */ (0,s.jsx)(n.Button,{disabled:j,onClick:ee,children:c.t(`find-replace.dialog.replace-all`)})]})]})]})});function Ge(){let e=(0,r.useDependency)(y),n=(0,r.useDependency)(r.ILayoutService),i=(0,r.useDependency)(t.IContextService),u=(0,r.useObservable)(e.state$,void 0,!0),d=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=d.current;if(!e)return;let t=n.registerContainerElement(e);return()=>t.dispose()},[n]);let f=(0,o.useRef)(null),p=(0,o.useCallback)(e=>i.setContextValue(l,e),[i]),m=(0,o.useCallback)(e=>i.setContextValue(c,e),[i]);return(0,o.useEffect)(()=>{var e;let t=(0,a.fromEvent)(document,`focusin`).subscribe(e=>{var t;e.target&&(t=d.current)!=null&&t.contains(e.target)?p(!0):p(!1),!f.current||!f.current.selectHasFocus()?m(!1):m(!0)});return(e=f.current)==null||e.focus(),p(!0),m(!0),()=>{t.unsubscribe(),p(!1)}},[p,m,u.replaceRevealed]),/* @__PURE__ */ (0,s.jsx)(`div`,{ref:d,"data-u-comp":`find-replace-dialog`,children:u.replaceRevealed?/* @__PURE__ */ (0,s.jsx)(We,{ref:f}):/* @__PURE__ */ (0,s.jsx)(Ue,{ref:f})})}let Q=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({SearchIcon:G}))}_registerComponents(){[[`FindReplaceDialog`,Ge]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};Q=_([g(0,(0,t.Inject)(r.ComponentManager)),g(1,(0,t.Inject)(r.IconManager))],Q);let $=class extends t.Plugin{constructor(e=U,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},U,this._config);this._configService.setConfig(fe,i)}onStarting(){this._injector.add([Q]),this._injector.get(Q),[[H],[y,{useClass:D}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(H)}};h($,`pluginName`,`UNIVER_FIND_REPLACE_PLUGIN`),h($,`packageName`,ue),h($,`version`,de),$=_([g(1,(0,t.Inject)(t.Injector)),g(2,t.IConfigService)],$),e.CloseFindDialogOperation=M,e.FindBy=C,e.FindDirection=S,e.FindModel=v,Object.defineProperty(e,"FindReplaceController",{enumerable:!0,get:function(){return H}}),e.FindReplaceMenuSchema=ee,Object.defineProperty(e,"FindReplaceModel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"FindReplaceService",{enumerable:!0,get:function(){return D}}),e.FindReplaceState=E,e.FindScope=w,e.GoToNextMatchOperation=N,e.GoToPreviousMatchOperation=P,e.IFindReplaceService=y,e.OpenFindDialogOperation=A,e.OpenReplaceDialogOperation=j,e.ReplaceAllMatchesCommand=k,e.ReplaceCurrentMatchCommand=O,Object.defineProperty(e,"UniverFindReplaceMobileUIPlugin",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UniverFindReplacePlugin",{enumerable:!0,get:function(){return $}}),e.createInitFindReplaceState=T});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/find-replace",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "private": false,
5
5
  "description": "Shared find and replace services and UI infrastructure for Univer.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,20 +58,20 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/core": "1.4.0",
62
- "@univerjs/design": "1.4.0",
63
- "@univerjs/engine-render": "1.4.0",
61
+ "@univerjs/core": "1.5.0",
62
+ "@univerjs/design": "1.5.0",
63
+ "@univerjs/engine-render": "1.5.0",
64
64
  "@univerjs/icons": "1.47.0",
65
- "@univerjs/ui": "1.4.0"
65
+ "@univerjs/ui": "1.5.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@univerjs-infra/shared": "1.4.0",
68
+ "@univerjs-infra/shared": "1.5.0",
69
69
  "postcss": "^8.5.32",
70
70
  "react": "18.3.1",
71
71
  "rxjs": "7.8.2",
72
72
  "tailwindcss": "3.4.18",
73
- "tsrs": "0.20.1-ts7.1.0-beta",
74
- "vitest": "^5.0.5"
73
+ "tsrs": "0.23.0-ts7.1.0-beta",
74
+ "vitest": "^5.1.0"
75
75
  },
76
76
  "scripts": {
77
77
  "test": "vitest run",