@univerjs/find-replace 0.4.2 → 0.5.0-beta.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.
@@ -1,17 +1,17 @@
1
- {
1
+ const e = {
2
2
  "find-replace": {
3
- "toolbar": "Find & Replace",
4
- "shortcut": {
3
+ toolbar: "Find & Replace",
4
+ shortcut: {
5
5
  "open-find-dialog": "Open Find Dialog",
6
6
  "open-replace-dialog": "Open Replace Dialog",
7
7
  "close-dialog": "Close Find & Replace Dialog",
8
8
  "go-to-next-match": "Go to Next Match",
9
9
  "go-to-previous-match": "Go to Previous Match"
10
10
  },
11
- "dialog": {
12
- "title": "Find",
13
- "find": "Find",
14
- "replace": "Replace",
11
+ dialog: {
12
+ title: "Find",
13
+ find: "Find",
14
+ replace: "Replace",
15
15
  "replace-all": "Replace All",
16
16
  "case-sensitive": "Case Sensitive",
17
17
  "find-placeholder": "Find in this Sheet",
@@ -19,30 +19,33 @@
19
19
  "replace-placeholder": "Input Replace String",
20
20
  "match-the-whole-cell": "Match the Whole Cell",
21
21
  "find-direction": {
22
- "title": "Find Direction",
23
- "row": "Search by Row",
24
- "column": "Search by Column"
22
+ title: "Find Direction",
23
+ row: "Search by Row",
24
+ column: "Search by Column"
25
25
  },
26
26
  "find-scope": {
27
- "title": "Find Range",
27
+ title: "Find Range",
28
28
  "current-sheet": "Current Sheet",
29
- "workbook": "Workbook"
29
+ workbook: "Workbook"
30
30
  },
31
31
  "find-by": {
32
- "title": "Find By",
33
- "value": "Find by Value",
34
- "formula": "Find Formula"
32
+ title: "Find By",
33
+ value: "Find by Value",
34
+ formula: "Find Formula"
35
35
  },
36
36
  "no-match": "Finding completed but no match found.",
37
37
  "no-result": "No Result"
38
38
  },
39
- "replace": {
39
+ replace: {
40
40
  "all-success": "Replaced all {0} matches",
41
41
  "all-failure": "Replace failed",
42
- "confirm": {
43
- "title": "Are you sure to replace all matches?"
42
+ confirm: {
43
+ title: "Are you sure to replace all matches?"
44
44
  }
45
45
  }
46
46
  },
47
47
  "find-replace-shortcuts": "Find & Replace"
48
- }
48
+ };
49
+ export {
50
+ e as default
51
+ };
@@ -1,17 +1,17 @@
1
- {
1
+ const e = {
2
2
  "find-replace": {
3
- "toolbar": "یافتن و جایگزینی",
4
- "shortcut": {
3
+ toolbar: "یافتن و جایگزینی",
4
+ shortcut: {
5
5
  "open-find-dialog": "باز کردن پنجره گفتگوی یافتن",
6
6
  "open-replace-dialog": "باز کردن پنجره گفتگوی جایگزینی",
7
7
  "close-dialog": "بستن پنجره گفتگوی یافتن و جایگزینی",
8
8
  "go-to-next-match": "رفتن به تطابق بعدی",
9
9
  "go-to-previous-match": "رفتن به تطابق قبلی"
10
10
  },
11
- "dialog": {
12
- "title": "یافتن",
13
- "find": "یافتن",
14
- "replace": "جایگزینی",
11
+ dialog: {
12
+ title: "یافتن",
13
+ find: "یافتن",
14
+ replace: "جایگزینی",
15
15
  "replace-all": "جایگزینی همه",
16
16
  "case-sensitive": "حساس به حروف کوچک و بزرگ",
17
17
  "find-placeholder": "یافتن در این برگ",
@@ -19,30 +19,33 @@
19
19
  "replace-placeholder": "ورود رشته جایگزین",
20
20
  "match-the-whole-cell": "مطابقت با کل سلول",
21
21
  "find-direction": {
22
- "title": "جهت یافتن",
23
- "row": "جستجو بر اساس سطر",
24
- "column": "جستجو بر اساس ستون"
22
+ title: "جهت یافتن",
23
+ row: "جستجو بر اساس سطر",
24
+ column: "جستجو بر اساس ستون"
25
25
  },
26
26
  "find-scope": {
27
- "title": "محدوده یافتن",
27
+ title: "محدوده یافتن",
28
28
  "current-sheet": "برگ فعلی",
29
- "workbook": "کتاب کار"
29
+ workbook: "کتاب کار"
30
30
  },
31
31
  "find-by": {
32
- "title": "یافتن بر اساس",
33
- "value": "یافتن بر اساس مقدار",
34
- "formula": "یافتن فرمول"
32
+ title: "یافتن بر اساس",
33
+ value: "یافتن بر اساس مقدار",
34
+ formula: "یافتن فرمول"
35
35
  },
36
36
  "no-match": "یافتن تکمیل شد اما هیچ تطابقی یافت نشد.",
37
37
  "no-result": "نتیجه‌ای وجود ندارد"
38
38
  },
39
- "replace": {
39
+ replace: {
40
40
  "all-success": "همه {0} تطابق جایگزین شد",
41
41
  "all-failure": "جایگزینی ناموفق بود",
42
- "confirm": {
43
- "title": "آیا مطمئن هستید که همه تطابق‌ها را جایگزین کنید؟"
42
+ confirm: {
43
+ title: "آیا مطمئن هستید که همه تطابق‌ها را جایگزین کنید؟"
44
44
  }
45
45
  }
46
46
  },
47
47
  "find-replace-shortcuts": "یافتن و جایگزینی"
48
- }
48
+ };
49
+ export {
50
+ e as default
51
+ };
@@ -1,17 +1,17 @@
1
- {
1
+ const e = {
2
2
  "find-replace": {
3
- "toolbar": "Найти и заменить",
4
- "shortcut": {
3
+ toolbar: "Найти и заменить",
4
+ shortcut: {
5
5
  "open-find-dialog": "Открыть диалог поиска",
6
6
  "open-replace-dialog": "Открыть диалог замены",
7
7
  "close-dialog": "Закрыть диалог поиска и замены",
8
8
  "go-to-next-match": "Перейти к следующему совпадению",
9
9
  "go-to-previous-match": "Перейти к предыдущему совпадению"
10
10
  },
11
- "dialog": {
12
- "title": "Найти",
13
- "find": "Найти",
14
- "replace": "Заменить",
11
+ dialog: {
12
+ title: "Найти",
13
+ find: "Найти",
14
+ replace: "Заменить",
15
15
  "replace-all": "Заменить все",
16
16
  "case-sensitive": "С учетом регистра",
17
17
  "find-placeholder": "Найти в этом листе",
@@ -19,30 +19,33 @@
19
19
  "replace-placeholder": "Введите строку для замены",
20
20
  "match-the-whole-cell": "Точное совпадение",
21
21
  "find-direction": {
22
- "title": "Направление поиска",
23
- "row": "Поиск по строкам",
24
- "column": "Поиск по столбцам"
22
+ title: "Направление поиска",
23
+ row: "Поиск по строкам",
24
+ column: "Поиск по столбцам"
25
25
  },
26
26
  "find-scope": {
27
- "title": "Область поиска",
27
+ title: "Область поиска",
28
28
  "current-sheet": "Текущий лист",
29
- "workbook": "Книга"
29
+ workbook: "Книга"
30
30
  },
31
31
  "find-by": {
32
- "title": "Поиск по",
33
- "value": "Поиск по значению",
34
- "formula": "Поиск по формуле"
32
+ title: "Поиск по",
33
+ value: "Поиск по значению",
34
+ formula: "Поиск по формуле"
35
35
  },
36
36
  "no-match": "Поиск завершен, совпадений не найдено.",
37
37
  "no-result": "Нет результатов"
38
38
  },
39
- "replace": {
39
+ replace: {
40
40
  "all-success": "Заменены все {0} совпадений",
41
41
  "all-failure": "Не удалось заменить",
42
- "confirm": {
43
- "title": "Вы уверены, что хотите заменить все совпадения?"
42
+ confirm: {
43
+ title: "Вы уверены, что хотите заменить все совпадения?"
44
44
  }
45
45
  }
46
46
  },
47
47
  "find-replace-shortcuts": "Найти и заменить"
48
- }
48
+ };
49
+ export {
50
+ e as default
51
+ };
@@ -1,17 +1,17 @@
1
- {
1
+ const t = {
2
2
  "find-replace": {
3
- "toolbar": "Tìm kiếm và Thay thế",
4
- "shortcut": {
3
+ toolbar: "Tìm kiếm và Thay thế",
4
+ shortcut: {
5
5
  "open-find-dialog": "Mở hộp thoại tìm kiếm",
6
6
  "open-replace-dialog": "Mở hộp thoại thay thế",
7
7
  "close-dialog": "Đóng hộp thoại tìm kiếm và thay thế",
8
8
  "go-to-next-match": "Đến mục khớp tiếp theo",
9
9
  "go-to-previous-match": "Đến mục khớp trước đó"
10
10
  },
11
- "dialog": {
12
- "title": "Tìm kiếm",
13
- "find": "Tìm kiếm",
14
- "replace": "Thay thế",
11
+ dialog: {
12
+ title: "Tìm kiếm",
13
+ find: "Tìm kiếm",
14
+ replace: "Thay thế",
15
15
  "replace-all": "Thay thế tất cả",
16
16
  "find-placeholder": "Nhập nội dung tìm kiếm",
17
17
  "advanced-finding": "Thay thế / Tìm kiếm nâng cao",
@@ -19,30 +19,33 @@
19
19
  "case-sensitive": "Phân biệt chữ hoa chữ thường",
20
20
  "match-the-whole-cell": "Khớp toàn bộ ô",
21
21
  "find-scope": {
22
- "title": "Phạm vi tìm kiếm",
22
+ title: "Phạm vi tìm kiếm",
23
23
  "current-sheet": "Bảng hiện tại",
24
- "workbook": "Toàn bộ sổ làm việc"
24
+ workbook: "Toàn bộ sổ làm việc"
25
25
  },
26
26
  "find-direction": {
27
- "title": "Thứ tự tìm kiếm",
28
- "column": "Tìm theo cột",
29
- "row": "Tìm theo hàng"
27
+ title: "Thứ tự tìm kiếm",
28
+ column: "Tìm theo cột",
29
+ row: "Tìm theo hàng"
30
30
  },
31
31
  "find-by": {
32
- "title": "Phương thức tìm kiếm",
33
- "formula": "Tìm công thức",
34
- "value": "Tìm giá trị"
32
+ title: "Phương thức tìm kiếm",
33
+ formula: "Tìm công thức",
34
+ value: "Tìm giá trị"
35
35
  },
36
36
  "no-match": "Đã hoàn thành tìm kiếm nhưng không tìm thấy mục nào khớp",
37
37
  "no-result": "Không có kết quả"
38
38
  },
39
- "replace": {
39
+ replace: {
40
40
  "all-success": "Đã thay thế tất cả {0} mục khớp",
41
41
  "all-failure": "Thay thế thất bại",
42
- "confirm": {
43
- "title": "Bạn có chắc muốn thay thế tất cả các mục khớp không?"
42
+ confirm: {
43
+ title: "Bạn có chắc muốn thay thế tất cả các mục khớp không?"
44
44
  }
45
45
  }
46
46
  },
47
47
  "find-replace-shortcuts": "Tìm kiếm và Thay thế"
48
- }
48
+ };
49
+ export {
50
+ t as default
51
+ };
@@ -1,17 +1,17 @@
1
- {
1
+ const e = {
2
2
  "find-replace": {
3
- "toolbar": "查找替换",
4
- "shortcut": {
3
+ toolbar: "查找替换",
4
+ shortcut: {
5
5
  "open-find-dialog": "打开查找对话框",
6
6
  "open-replace-dialog": "打开替换对话框",
7
7
  "close-dialog": "关闭查找替换对话框",
8
8
  "go-to-next-match": "下一个匹配项",
9
9
  "go-to-previous-match": "下一个匹配项"
10
10
  },
11
- "dialog": {
12
- "title": "查找",
13
- "find": "查找",
14
- "replace": "替换",
11
+ dialog: {
12
+ title: "查找",
13
+ find: "查找",
14
+ replace: "替换",
15
15
  "replace-all": "替换全部",
16
16
  "find-placeholder": "输入查找内容",
17
17
  "advanced-finding": "替换 / 高级查找",
@@ -19,30 +19,33 @@
19
19
  "case-sensitive": "匹配大小写",
20
20
  "match-the-whole-cell": "匹配整个单元格",
21
21
  "find-scope": {
22
- "title": "查找范围",
22
+ title: "查找范围",
23
23
  "current-sheet": "当前子表",
24
- "workbook": "整个工作簿"
24
+ workbook: "整个工作簿"
25
25
  },
26
26
  "find-direction": {
27
- "title": "查找顺序",
28
- "column": "按列查找",
29
- "row": "按行查找"
27
+ title: "查找顺序",
28
+ column: "按列查找",
29
+ row: "按行查找"
30
30
  },
31
31
  "find-by": {
32
- "title": "查找方式",
33
- "formula": "查找公式",
34
- "value": "查找值"
32
+ title: "查找方式",
33
+ formula: "查找公式",
34
+ value: "查找值"
35
35
  },
36
36
  "no-match": "已完成搜索,但是未找到任何匹配项",
37
37
  "no-result": "无结果"
38
38
  },
39
- "replace": {
39
+ replace: {
40
40
  "all-success": "已全部替换 {0} 个匹配项",
41
41
  "all-failure": "替换失败",
42
- "confirm": {
43
- "title": "确定要替换所有的匹配项吗?"
42
+ confirm: {
43
+ title: "确定要替换所有的匹配项吗?"
44
44
  }
45
45
  }
46
46
  },
47
47
  "find-replace-shortcuts": "查找替换"
48
- }
48
+ };
49
+ export {
50
+ e as default
51
+ };
@@ -1,17 +1,17 @@
1
- {
1
+ const e = {
2
2
  "find-replace": {
3
- "toolbar": "尋找替換",
4
- "shortcut": {
3
+ toolbar: "尋找替換",
4
+ shortcut: {
5
5
  "open-find-dialog": "開啟尋找對話框",
6
6
  "open-replace-dialog": "開啟替換對話框",
7
7
  "close-dialog": "關閉查找替換對話框",
8
8
  "go-to-next-match": "下一個匹配項",
9
9
  "go-to-previous-match": "下一個匹配項"
10
10
  },
11
- "dialog": {
12
- "title": "找",
13
- "find": "找",
14
- "replace": "替換",
11
+ dialog: {
12
+ title: "找",
13
+ find: "找",
14
+ replace: "替換",
15
15
  "replace-all": "替換全部",
16
16
  "find-placeholder": "輸入查找內容",
17
17
  "advanced-finding": "取代 / 進階查找",
@@ -19,30 +19,33 @@
19
19
  "case-sensitive": "匹配大小寫",
20
20
  "match-the-whole-cell": "符合整個儲存格",
21
21
  "find-scope": {
22
- "title": "找出範圍",
22
+ title: "找出範圍",
23
23
  "current-sheet": "目前子表",
24
- "workbook": "整個工作簿"
24
+ workbook: "整個工作簿"
25
25
  },
26
26
  "find-direction": {
27
- "title": "找出順序",
28
- "column": "按列查找",
29
- "row": "按行查找"
27
+ title: "找出順序",
28
+ column: "按列查找",
29
+ row: "按行查找"
30
30
  },
31
31
  "find-by": {
32
- "title": "找出方式",
33
- "formula": "找出公式",
34
- "value": "查找值"
32
+ title: "找出方式",
33
+ formula: "找出公式",
34
+ value: "查找值"
35
35
  },
36
36
  "no-match": "已完成搜索,但是未找到任何匹配項",
37
37
  "no-result": "無結果"
38
38
  },
39
- "replace": {
39
+ replace: {
40
40
  "all-success": "已全部替換 {0} 個匹配項",
41
41
  "all-failure": "替換失敗",
42
- "confirm": {
43
- "title": "確定要取代所有的符合項目嗎? "
42
+ confirm: {
43
+ title: "確定要取代所有的符合項目嗎? "
44
44
  }
45
45
  }
46
46
  },
47
47
  "find-replace-shortcuts": "尋找替換"
48
- }
48
+ };
49
+ export {
50
+ e as default
51
+ };
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverFindReplace={},global.UniverCore,global.UniverUi,global.rxjs,global.UniverDesign,global.UniverEngineRender,global.React))})(this,function(exports2,core,ui,rxjs,design,engineRender,require$$0){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d;const PLUGIN_CONFIG_KEY="find-replace.config",defaultPluginConfig={};var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n2=arguments.length;i<n2;i++){s=arguments[i];for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&(t[p2]=s[p2])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&e.indexOf(p2)<0&&(t[p2]=s[p2]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p2=Object.getOwnPropertySymbols(s);i<p2.length;i++)e.indexOf(p2[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p2[i])&&(t[p2[i]]=s[p2[i]]);return t},IconBase=require$$0.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=require$$0.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return require$$0.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},SearchSingle16=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"search-single-16",ref,icon:element}))});SearchSingle16.displayName="SearchSingle16";const FIND_REPLACE_INPUT_FOCUS="FIND_REPLACE_INPUT_FOCUS",FIND_REPLACE_DIALOG_FOCUS="FIND_REPLACE_DIALOG_FOCUS",FIND_REPLACE_REPLACE_REVEALED="FIND_REPLACE_REPLACE_REVEALED";var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");const _FindModel=class _FindModel extends core.Disposable{};__name(_FindModel,"FindModel");let FindModel=_FindModel;const IFindReplaceService=core.createIdentifier("find-replace.service");function shouldStateUpdateTriggerResearch(statusUpdate){return typeof statusUpdate.findString<"u"||typeof statusUpdate.inputtingFindString<"u"||typeof statusUpdate.findDirection<"u"||typeof statusUpdate.matchesTheWholeCell<"u"||typeof statusUpdate.caseSensitive<"u"||typeof statusUpdate.findScope<"u"||typeof statusUpdate.findBy<"u"}__name(shouldStateUpdateTriggerResearch,"shouldStateUpdateTriggerResearch");let FindReplaceModel=(_a=class extends core.Disposable{constructor(_state,_providers,_univerInstanceService){super();__publicField(this,"currentMatch$",new rxjs.BehaviorSubject(null));__publicField(this,"replaceables$",new rxjs.BehaviorSubject([]));__publicField(this,"_findModels",[]);__publicField(this,"_matchingModel",null);__publicField(this,"_matches",[]);__publicField(this,"_currentSearchingDisposables",null);this._state=_state,this._providers=_providers,this._univerInstanceService=_univerInstanceService,this.disposeWithMe(this._state.stateUpdates$.pipe(rxjs.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async stateUpdate=>{const state=this._state.state;shouldStateUpdateTriggerResearch(stateUpdate)&&(state.findString!==""&&!state.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):stateUpdate.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...createInitFindReplaceState(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const complete=await this._startSearching();return this._state.changeState({findCompleted:!0}),complete}async _startSearching(){if(!this._state.findString)return{results:[]};const providers=Array.from(this._providers),findModels=this._findModels=(await Promise.all(providers.map(provider=>provider.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})))).flat();this._subscribeToModelsChanges(findModels);const newMatches=this._matches=findModels.map(c=>c.getMatches()).flat();return this.replaceables$.next(newMatches.filter(m2=>m2.replaceable)),newMatches.length?(this._moveToInitialMatch(findModels),this._state.changeState({matchesCount:newMatches.length}),{results:newMatches}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var _a2;this._providers.forEach(provider=>provider.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(_a2=this._currentSearchingDisposables)==null||_a2.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(models){const disposables=this._currentSearchingDisposables=new core.DisposableCollection,matchesUpdateSubscription=rxjs.combineLatest(models.map(model=>model.matchesUpdate$)).pipe(rxjs.debounceTime(220)).subscribe(([...allMatches])=>{const newMatches=this._matches=allMatches.flat();newMatches.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:newMatches.length}),this.replaceables$.next(newMatches.filter(m2=>m2.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});models.forEach(model=>disposables.add(core.toDisposable(model.activelyChangingMatch$.subscribe(match=>{const index=this._matches.findIndex(m2=>m2===match);this._state.changeState({matchesPosition:index+1})})))),disposables.add(core.toDisposable(matchesUpdateSubscription))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const result=await Promise.all(this._findModels.map(m2=>m2.replaceAll(this._state.replaceString))).then(results=>results.reduce((acc,cur)=>(acc.success+=cur.success,acc.failure+=cur.failure,acc),{success:0,failure:0}));return result.failure===0&&this._stopSearching(),result}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(match){const index=this._matches.findIndex(value=>value===match);this.currentMatch$.next(match),this._state.changeState({matchesPosition:index+1})}moveToNextMatch(){if(!this._matchingModel)return;const loopInCurrentUnit=this._findModels.length===1,nextMatch=this._matchingModel.moveToNextMatch({loop:loopInCurrentUnit});if(nextMatch)this._markMatch(nextMatch);else{const currentModelIndex=this._findModels.findIndex(m2=>m2===this._matchingModel);this._moveToNextUnitMatch(currentModelIndex)}}_moveToNextUnitMatch(startingIndex){const l2=this._findModels.length;for(let i=(startingIndex+1)%l2;i!==startingIndex;){const nextPositionModel=this._findModels[i],nextMatch=nextPositionModel.moveToNextMatch({ignoreSelection:!0});if(nextMatch){this._matchingModel=nextPositionModel,this._markMatch(nextMatch);return}i=(i+1)%l2}if(this._matchingModel){const nextMatch=this._matchingModel.moveToNextMatch({ignoreSelection:!0});nextMatch&&this._markMatch(nextMatch)}}moveToPreviousMatch(){if(!this._matchingModel)return;const loopInCurrentUnit=this._findModels.length===1,nextMatch=this._matchingModel.moveToPreviousMatch({loop:loopInCurrentUnit});if(nextMatch){const index=this._matches.findIndex(value=>value===nextMatch);this.currentMatch$.next(nextMatch),this._state.changeState({matchesPosition:index+1})}else{const l2=this._findModels.length,currentModelIndex=this._findModels.findIndex(m2=>m2===this._matchingModel);for(let i=(currentModelIndex-1+l2)%l2;i!==currentModelIndex;){const nextPositionModel=this._findModels[i],nextMatch3=nextPositionModel.moveToPreviousMatch({ignoreSelection:!0});if(nextMatch3){this._matchingModel=nextPositionModel,this._markMatch(nextMatch3);return}i=(i-1)%l2}const nextMatch2=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});nextMatch2&&this._markMatch(nextMatch2)}}_moveToInitialMatch(findModels,noFocus=!1){var _a2;const focusedUnitId=(_a2=this._univerInstanceService.getFocusedUnit())==null?void 0:_a2.getUnitId();if(!focusedUnitId)return-1;const i=findModels.findIndex(model=>model.unitId===focusedUnitId);if(i!==-1){this._matchingModel=findModels[i];const nextMatch=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus});if(nextMatch)return this._markMatch(nextMatch),i}return this._moveToNextUnitMatch(i),0}},__name(_a,"FindReplaceModel"),_a);FindReplaceModel=__decorateClass$2([__decorateParam$2(2,core.IUniverInstanceService)],FindReplaceModel);var FindDirection=(FindDirection2=>(FindDirection2.ROW="row",FindDirection2.COLUMN="column",FindDirection2))(FindDirection||{}),FindBy=(FindBy2=>(FindBy2.VALUE="value",FindBy2.FORMULA="formula",FindBy2))(FindBy||{}),FindScope=(FindScope2=>(FindScope2.SUBUNIT="subunit",FindScope2.UNIT="unit",FindScope2))(FindScope||{});function createInitFindReplaceState(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}__name(createInitFindReplaceState,"createInitFindReplaceState");const _FindReplaceState=class _FindReplaceState{constructor(){__publicField(this,"_stateUpdates$",new rxjs.Subject);__publicField(this,"stateUpdates$",this._stateUpdates$.asObservable());__publicField(this,"_state$",new rxjs.BehaviorSubject(createInitFindReplaceState()));__publicField(this,"state$",this._state$.asObservable());__publicField(this,"_findString","");__publicField(this,"_inputtingFindString","");__publicField(this,"_replaceString","");__publicField(this,"_revealed",!1);__publicField(this,"_replaceRevealed",!1);__publicField(this,"_matchesPosition",0);__publicField(this,"_matchesCount",0);__publicField(this,"_caseSensitive",!0);__publicField(this,"_matchesTheWholeCell",!1);__publicField(this,"_findDirection","row");__publicField(this,"_findScope","subunit");__publicField(this,"_findBy","value");__publicField(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 findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(changes){let changed=!1;const changedState={};typeof changes.findString<"u"&&changes.findString!==this._findString&&(this._findString=changes.findString,changedState.findString=this._findString,changed=!0),typeof changes.revealed<"u"&&changes.revealed!==this._revealed&&(this._revealed=changes.revealed,changedState.revealed=changes.revealed,changed=!0),typeof changes.replaceRevealed<"u"&&changes.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=changes.replaceRevealed,changedState.replaceRevealed=changes.replaceRevealed,changed=!0),typeof changes.replaceString<"u"&&changes.replaceString!==this._replaceString&&(this._replaceString=changes.replaceString,changedState.replaceString=changes.replaceString,changed=!0),typeof changes.matchesCount<"u"&&changes.matchesCount!==this._matchesCount&&(this._matchesCount=changes.matchesCount,changedState.matchesCount=changes.matchesCount,changed=!0),typeof changes.matchesPosition<"u"&&changes.matchesPosition!==this._matchesPosition&&(this._matchesPosition=changes.matchesPosition,changedState.matchesPosition=changes.matchesPosition,changed=!0),typeof changes.findBy<"u"&&changes.findBy!==this._findBy&&(this._findBy=changes.findBy,changedState.findBy=changes.findBy,changed=!0),typeof changes.findScope<"u"&&changes.findScope!==this._findScope&&(this._findScope=changes.findScope,changedState.findScope=changes.findScope,changed=!0),typeof changes.findDirection<"u"&&changes.findDirection!==this._findDirection&&(this._findDirection=changes.findDirection,changedState.findDirection=changes.findDirection,changed=!0),typeof changes.caseSensitive<"u"&&changes.caseSensitive!==this._caseSensitive&&(this._caseSensitive=changes.caseSensitive,changedState.caseSensitive=changes.caseSensitive,changed=!0),typeof changes.matchesTheWholeCell<"u"&&changes.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=changes.matchesTheWholeCell,changedState.matchesTheWholeCell=changes.matchesTheWholeCell,changed=!0),typeof changes.inputtingFindString<"u"&&changes.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=changes.inputtingFindString,changedState.inputtingFindString=changes.inputtingFindString,changed=!0),typeof changes.findCompleted<"u"&&changes.findCompleted!==this._findCompleted&&(this._findCompleted=changes.findCompleted,changedState.findCompleted=changes.findCompleted,changed=!0),changed&&(this._state$.next({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,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(changedState))}};__name(_FindReplaceState,"FindReplaceState");let FindReplaceState=_FindReplaceState,FindReplaceService=(_b=class extends core.Disposable{constructor(_injector,_contextService){super();__publicField(this,"_providers",new Set);__publicField(this,"_state",new FindReplaceState);__publicField(this,"_model");__publicField(this,"_currentMatch$",new rxjs.BehaviorSubject(null));__publicField(this,"currentMatch$",this._currentMatch$.asObservable());__publicField(this,"_replaceables$",new rxjs.BehaviorSubject([]));__publicField(this,"replaceables$",this._replaceables$.asObservable());__publicField(this,"_focusSignal$",new rxjs.Subject);__publicField(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=_injector,this._contextService=_contextService}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var _a2;return(_a2=this._model)==null?void 0:_a2.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(findString){this._state.changeState({findString})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(value){value?this._state.changeState({inputtingFindString:value}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(replaceString){this._state.changeState({replaceString})}changeMatchesTheWholeCell(matchesTheWholeCell){this._state.changeState({matchesTheWholeCell})}changeCaseSensitive(caseSensitive){this._state.changeState({caseSensitive})}changeFindBy(findBy){this._state.changeState({findBy}),this._toggleDisplayRawFormula(findBy==="formula")}changeFindScope(scope){this._state.changeState({findScope:scope})}changeFindDirection(direction){this._state.changeState({findDirection:direction})}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 new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(revealReplace=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(FindReplaceModel,this._state,this._providers),this._model.currentMatch$.subscribe(match=>this._currentMatch$.next(match)),this._model.replaceables$.subscribe(replaceables=>this._replaceables$.next(replaceables));const newState=createInitFindReplaceState();return revealReplace&&(newState.replaceRevealed=!0),this._state.changeState(newState),this._toggleRevealReplace(revealReplace),!0}find(){var _a2;(_a2=this._model)==null||_a2.start()}terminate(){var _a2;(_a2=this._model)==null||_a2.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(provider){return this._providers.add(provider),core.toDisposable(()=>this._providers.delete(provider))}_toggleRevealReplace(revealReplace){this._contextService.setContextValue(FIND_REPLACE_REPLACE_REVEALED,revealReplace)}_toggleDisplayRawFormula(force){this._contextService.setContextValue(engineRender.RENDER_RAW_FORMULA_KEY,force)}},__name(_b,"FindReplaceService"),_b);FindReplaceService=__decorateClass$2([__decorateParam$2(0,core.Inject(core.Injector)),__decorateParam$2(1,core.IContextService)],FindReplaceService);const ReplaceCurrentMatchCommand={id:"ui.command.replace-current-match",type:core.CommandType.COMMAND,handler:__name(accessor=>accessor.get(IFindReplaceService).replace(),"handler")},CONFIRM_REPLACE_ALL_ID="CONFIRM_REPLACE_ALL",ReplaceAllMatchesCommand={id:"ui.command.replace-all-matches",type:core.CommandType.COMMAND,handler:__name(async accessor=>{const confirmService=accessor.get(ui.IConfirmService),localeService=accessor.get(core.LocaleService),messageService=accessor.get(ui.IMessageService);if(!await confirmService.confirm({id:CONFIRM_REPLACE_ALL_ID,title:{title:localeService.t("find-replace.replace.confirm.title")},cancelText:localeService.t("button.cancel"),confirmText:localeService.t("button.confirm")}))return!1;const result=await accessor.get(IFindReplaceService).replaceAll(),{success,failure}=result;return failure>0?(success===0?messageService.show({type:design.MessageType.Error,content:localeService.t("find-replace.replace.all-failure")}):messageService.show({type:design.MessageType.Warning,content:localeService.t("find-replace.replace.partial-success",`${success}`,`${failure}`)}),!1):(messageService.show({type:design.MessageType.Success,content:localeService.t("find-replace.replace.all-success",`${success}`)}),!0)},"handler")},OpenFindDialogOperation={id:"ui.operation.open-find-dialog",type:core.CommandType.OPERATION,handler:__name(accessor=>{const findReplaceService=accessor.get(IFindReplaceService);return findReplaceService.revealed?findReplaceService.focusFindInput():findReplaceService.start(),!0},"handler")},OpenReplaceDialogOperation={id:"ui.operation.open-replace-dialog",type:core.CommandType.OPERATION,handler:__name(accessor=>{const findReplaceService=accessor.get(IFindReplaceService);return findReplaceService.revealed?findReplaceService.replaceRevealed?findReplaceService.focusFindInput():findReplaceService.revealReplace():findReplaceService.start(!0),!0},"handler")},GoToNextMatchOperation={type:core.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:__name(accessor=>(accessor.get(IFindReplaceService).moveToNextMatch(),!0),"handler")},GoToPreviousMatchOperation={type:core.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:__name(accessor=>(accessor.get(IFindReplaceService).moveToPreviousMatch(),!0),"handler")};var jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
1
+ (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverFindReplace={},c.UniverCore,c.UniverUi,c.rxjs,c.UniverDesign,c.UniverEngineRender,c.React))})(this,function(c,a,d,m,p,le,l){"use strict";var Ct=Object.defineProperty;var Rt=(c,a,d)=>a in c?Ct(c,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[a]=d;var h=(c,a,d)=>Rt(c,typeof a!="symbol"?a+"":a,d);var $;const de="find-replace.config",he={};var C=function(){return C=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},C.apply(this,arguments)},ue=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(n);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(n,t[s])&&(i[t[s]]=n[t[s]]);return i},Y=l.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,r=n.extend,o=ue(n,["icon","id","className","extend"]),f="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),_=l.useRef("_".concat(_e()));return Z(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},C({ref:e,className:f},o),r)});function Z(n,e,i,t,s){return l.createElement(n.tag,C(C({key:e},fe(n,i,s)),t),(pe(n,i).children||[]).map(function(r,o){return Z(r,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,s)}))}function fe(n,e,i){var t=C({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(r){var o=r[0],f=r[1];typeof f=="string"&&(t[o]=f.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function pe(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?C(C({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?C(C({},s),{attrs:C(C({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function _e(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var ge={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},J=l.forwardRef(function(n,e){return l.createElement(Y,Object.assign({},n,{id:"search-single-16",ref:e,icon:ge}))});J.displayName="SearchSingle16";const Q="FIND_REPLACE_INPUT_FOCUS",X="FIND_REPLACE_DIALOG_FOCUS",q="FIND_REPLACE_REPLACE_REVEALED";var me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,ee=(n,e,i,t)=>{for(var s=t>1?void 0:t?ve(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&me(e,i,s),s},A=(n,e)=>(i,t)=>e(i,t,n);class Se extends a.Disposable{}const R=a.createIdentifier("find-replace.service");function Ce(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let U=class extends a.Disposable{constructor(e,i,t){super();h(this,"currentMatch$",new m.BehaviorSubject(null));h(this,"replaceables$",new m.BehaviorSubject([]));h(this,"_findModels",[]);h(this,"_matchingModel",null);h(this,"_matches",[]);h(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this.disposeWithMe(this._state.stateUpdates$.pipe(m.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const r=this._state.state;Ce(s)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...w(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(s=>s.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})))).flat();this._subscribeToModelsChanges(i);const t=this._matches=i.map(s=>s.getMatches()).flat();return this.replaceables$.next(t.filter(s=>s.replaceable)),t.length?(this._moveToInitialMatch(i),this._state.changeState({matchesCount:t.length}),{results:t}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var e;this._providers.forEach(i=>i.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){const i=this._currentSearchingDisposables=new a.DisposableCollection,t=m.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(m.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(o=>o.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(s=>i.add(a.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const o=this._matches.findIndex(f=>f===r);this._state.changeState({matchesPosition:o+1})})))),i.add(a.toDisposable(t))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((t,s)=>(t.success+=s.success,t.failure+=s.failure,t),{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){const i=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:i+1})}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i)this._markMatch(i);else{const t=this._findModels.findIndex(s=>s===this._matchingModel);this._moveToNextUnitMatch(t)}}_moveToNextUnitMatch(e){const i=this._findModels.length;for(let t=(e+1)%i;t!==e;){const s=this._findModels[t],r=s.moveToNextMatch({ignoreSelection:!0});if(r){this._matchingModel=s,this._markMatch(r);return}t=(t+1)%i}if(this._matchingModel){const t=this._matchingModel.moveToNextMatch({ignoreSelection:!0});t&&this._markMatch(t)}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.length,s=this._findModels.findIndex(o=>o===this._matchingModel);for(let o=(s-1+t)%t;o!==s;){const f=this._findModels[o],_=f.moveToPreviousMatch({ignoreSelection:!0});if(_){this._matchingModel=f,this._markMatch(_);return}o=(o-1)%t}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});r&&this._markMatch(r)}}_moveToInitialMatch(e,i=!1){var r;const t=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!t)return-1;const s=e.findIndex(o=>o.unitId===t);if(s!==-1){this._matchingModel=e[s];const o=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:i});if(o)return this._markMatch(o),s}return this._moveToNextUnitMatch(s),0}};U=ee([A(2,a.IUniverInstanceService)],U);var D=(n=>(n.ROW="row",n.COLUMN="column",n))(D||{}),x=(n=>(n.VALUE="value",n.FORMULA="formula",n))(x||{}),T=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(T||{});function w(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Re{constructor(){h(this,"_stateUpdates$",new m.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new m.BehaviorSubject(w()));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,"_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 findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(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,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let B=class extends a.Disposable{constructor(e,i){super();h(this,"_providers",new Set);h(this,"_state",new Re);h(this,"_model");h(this,"_currentMatch$",new m.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new m.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new m.Subject);h(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}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})}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 new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=w();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),a.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(q,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(le.RENDER_RAW_FORMULA_KEY,e)}};B=ee([A(0,a.Inject(a.Injector)),A(1,a.IContextService)],B);const k={id:"ui.command.replace-current-match",type:a.CommandType.COMMAND,handler:n=>n.get(R).replace()},be="CONFIRM_REPLACE_ALL",W={id:"ui.command.replace-all-matches",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(d.IConfirmService),i=n.get(a.LocaleService),t=n.get(d.IMessageService);if(!await e.confirm({id:be,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const r=await n.get(R).replaceAll(),{success:o,failure:f}=r;return f>0?(o===0?t.show({type:p.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:p.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${f}`)}),!1):(t.show({type:p.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}},I={id:"ui.operation.open-find-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.focusFindInput():e.start(),!0}},O={id:"ui.operation.open-replace-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},G={type:a.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(R).moveToNextMatch(),!0)},V={type:a.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(R).moveToPreviousMatch(),!0)};var te={exports:{}},P={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q"),reactJsxRuntime_production_min.Fragment=l,reactJsxRuntime_production_min.jsx=q,reactJsxRuntime_production_min.jsxs=q,jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports;function SearchInput(props){const{findCompleted:findComplete,localeService,matchesCount,matchesPosition,findString,findReplaceService,onChange,...rest}=props,text=findComplete&&matchesCount===0?localeService.t("find-replace.dialog.no-result"):matchesCount===0?" ":void 0;return jsxRuntimeExports.jsx(design.InputWithSlot,{autoFocus:!0,placeholder:localeService.t("find-replace.dialog.find-placeholder"),slot:jsxRuntimeExports.jsx(design.Pager,{loop:!0,text,value:matchesPosition,total:matchesCount,onChange:__name(newIndex=>{matchesPosition===matchesCount&&newIndex===1?findReplaceService.moveToNextMatch():matchesPosition===1&&newIndex===matchesCount||newIndex<matchesPosition?findReplaceService.moveToPreviousMatch():findReplaceService.moveToNextMatch()},"onChange")}),value:findString,onChange:__name(value=>onChange==null?void 0:onChange(value),"onChange"),...rest})}__name(SearchInput,"SearchInput");const styles={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function useFindInputFocus(findReplaceService,ref){const focus=require$$0.useCallback(()=>{var _a2;(_a2=document.querySelector(".univer-find-input input"))==null||_a2.focus()},[]),selectHasFocus=require$$0.useCallback(()=>{const allInputs=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(allInputs).some(input=>input===document.activeElement)},[]);return require$$0.useImperativeHandle(ref,()=>({focus,selectHasFocus})),require$$0.useEffect(()=>{const subscription=findReplaceService.focusSignal$.subscribe(()=>focus());return()=>subscription.unsubscribe()},[findReplaceService,focus]),{focus,selectHasFocus}}__name(useFindInputFocus,"useFindInputFocus");const FindDialog=require$$0.forwardRef(__name(function(_props,ref){const localeService=core.useDependency(core.LocaleService),findReplaceService=core.useDependency(IFindReplaceService),commandService=core.useDependency(core.ICommandService),state=ui.useObservable(findReplaceService.state$,void 0,!0),{findCompleted,findString,matchesCount,matchesPosition}=state,revealReplace=require$$0.useCallback(()=>{commandService.executeCommand(OpenReplaceDialogOperation.id)},[commandService]),onFindStringChange=require$$0.useCallback(findString2=>findReplaceService.changeFindString(findString2),[findReplaceService]);return useFindInputFocus(findReplaceService,ref),jsxRuntimeExports.jsxs(require$$0.Fragment,{children:[jsxRuntimeExports.jsx(SearchInput,{findCompleted,className:"univer-find-input",matchesCount,matchesPosition,findReplaceService,localeService,findString,onChange:onFindStringChange}),jsxRuntimeExports.jsx("div",{className:styles.findReplaceExpandContainer,children:jsxRuntimeExports.jsx(design.Button,{type:"text",size:"small",onClick:revealReplace,children:localeService.t("find-replace.dialog.advanced-finding")})})]})},"FindDialogImpl")),ReplaceDialog=require$$0.forwardRef(__name(function(_props,ref){const findReplaceService=core.useDependency(IFindReplaceService),localeService=core.useDependency(core.LocaleService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),currentMatch=ui.useObservable(findReplaceService.currentMatch$,void 0,!0),replaceables=ui.useObservable(findReplaceService.replaceables$,void 0,!0),state=ui.useObservable(findReplaceService.state$,void 0,!0),{matchesCount,matchesPosition,findString,inputtingFindString,replaceString,caseSensitive,matchesTheWholeCell,findDirection,findScope,findBy,findCompleted}=state,findDisabled=inputtingFindString.length===0,replaceDisabled=matchesCount===0||!(currentMatch!=null&&currentMatch.replaceable),replaceAllDisabled=replaceables.length===0,onFindStringChange=require$$0.useCallback(newValue=>findReplaceService.changeInputtingFindString(newValue),[findReplaceService]),onReplaceStringChange=require$$0.useCallback(replaceString2=>findReplaceService.changeReplaceString(replaceString2),[findReplaceService]),{focus}=useFindInputFocus(findReplaceService,ref),onClickFindButton=require$$0.useCallback(()=>{findString===inputtingFindString?findReplaceService.moveToNextMatch():(findReplaceService.changeFindString(inputtingFindString),findReplaceService.find())},[findString,inputtingFindString,findReplaceService]),onClickReplaceButton=require$$0.useCallback(()=>commandService.executeCommand(ReplaceCurrentMatchCommand.id),[commandService]),onClickReplaceAllButton=require$$0.useCallback(async()=>{await commandService.executeCommand(ReplaceAllMatchesCommand.id),focus()},[commandService]),onChangeFindDirection=require$$0.useCallback(findDirection2=>{findReplaceService.changeFindDirection(findDirection2)},[findReplaceService]),onChangeFindScope=require$$0.useCallback(findScope2=>{findReplaceService.changeFindScope(findScope2)},[findReplaceService]),onChangeFindBy=require$$0.useCallback(findBy2=>{findReplaceService.changeFindBy(findBy2)},[findReplaceService]),findScopeOptions=useFindScopeOptions(localeService),findDirectionOptions=useFindDirectionOptions(localeService),findByOptions=useFindByOptions(localeService);return require$$0.useEffect(()=>{const shouldDisplayNoMatchInfo=findCompleted&&matchesCount===0;let messageDisposable=null;return shouldDisplayNoMatchInfo&&(messageDisposable=messageService.show({content:localeService.t("find-replace.dialog.no-match"),type:design.MessageType.Warning,duration:5e3})),()=>messageDisposable==null?void 0:messageDisposable.dispose()},[findCompleted,matchesCount,messageService,localeService]),jsxRuntimeExports.jsxs(require$$0.Fragment,{children:[jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("find-replace.dialog.find"),children:jsxRuntimeExports.jsx(SearchInput,{findCompleted,className:"univer-find-input",matchesCount,matchesPosition,findReplaceService,localeService,findString:inputtingFindString,onChange:onFindStringChange})}),jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("find-replace.dialog.replace"),children:jsxRuntimeExports.jsx(design.Input,{placeholder:localeService.t("find-replace.dialog.replace-placeholder"),value:replaceString,onChange:__name(value=>onReplaceStringChange(value),"onChange")})}),jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("find-replace.dialog.find-direction.title"),children:jsxRuntimeExports.jsx(design.Select,{value:findDirection,options:findDirectionOptions,onChange:onChangeFindDirection})}),jsxRuntimeExports.jsx(design.FormDualColumnLayout,{children:jsxRuntimeExports.jsxs(require$$0.Fragment,{children:[jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("find-replace.dialog.find-scope.title"),children:jsxRuntimeExports.jsx(design.Select,{value:findScope,options:findScopeOptions,onChange:onChangeFindScope})}),jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("find-replace.dialog.find-by.title"),children:jsxRuntimeExports.jsx(design.Select,{value:findBy,options:findByOptions,onChange:onChangeFindBy})})]})}),jsxRuntimeExports.jsx(design.FormDualColumnLayout,{children:jsxRuntimeExports.jsxs(require$$0.Fragment,{children:[jsxRuntimeExports.jsx(design.FormLayout,{children:jsxRuntimeExports.jsx(design.Checkbox,{checked:caseSensitive,onChange:__name(checked=>{findReplaceService.changeCaseSensitive(checked)},"onChange"),children:localeService.t("find-replace.dialog.case-sensitive")})}),jsxRuntimeExports.jsx(design.FormLayout,{children:jsxRuntimeExports.jsx(design.Checkbox,{checked:matchesTheWholeCell,onChange:__name(checked=>{findReplaceService.changeMatchesTheWholeCell(checked)},"onChange"),children:localeService.t("find-replace.dialog.match-the-whole-cell")})})]})}),jsxRuntimeExports.jsxs("div",{className:styles.findReplaceButtonsGroup,children:[jsxRuntimeExports.jsx(design.Button,{type:"primary",onClick:onClickFindButton,disabled:findDisabled,children:localeService.t("find-replace.dialog.find")}),jsxRuntimeExports.jsxs("span",{className:styles.findReplaceButtonsGroupRight,children:[jsxRuntimeExports.jsx(design.Button,{disabled:replaceDisabled,onClick:onClickReplaceButton,children:localeService.t("find-replace.dialog.replace")}),jsxRuntimeExports.jsx(design.Button,{disabled:replaceAllDisabled,onClick:onClickReplaceAllButton,children:localeService.t("find-replace.dialog.replace-all")})]})]})]})},"ReplaceDIalogImpl"));function FindReplaceDialog(){const findReplaceService=core.useDependency(IFindReplaceService),layoutService=core.useDependency(ui.ILayoutService),contextService=core.useDependency(core.IContextService),state=ui.useObservable(findReplaceService.state$,void 0,!0),dialogContainerRef=require$$0.useRef(null);require$$0.useEffect(()=>{let disposable;return dialogContainerRef.current&&(disposable=layoutService.registerContainerElement(dialogContainerRef.current)),()=>disposable==null?void 0:disposable.dispose()},[layoutService]);const focusRef=require$$0.useRef(null),setDialogContainerFocus=require$$0.useCallback(focused=>contextService.setContextValue(FIND_REPLACE_DIALOG_FOCUS,focused),[contextService]),setDialogInputFocus=require$$0.useCallback(focused=>contextService.setContextValue(FIND_REPLACE_INPUT_FOCUS,focused),[contextService]);return require$$0.useEffect(()=>{var _a2;const focusSubscription=rxjs.fromEvent(document,"focusin").subscribe(event=>{var _a3;event.target&&((_a3=dialogContainerRef.current)!=null&&_a3.contains(event.target))?setDialogContainerFocus(!0):setDialogContainerFocus(!1),!focusRef.current||!focusRef.current.selectHasFocus()?setDialogInputFocus(!0):setDialogInputFocus(!1)});return(_a2=focusRef.current)==null||_a2.focus(),setDialogContainerFocus(!0),setDialogInputFocus(!0),()=>{focusSubscription.unsubscribe(),setDialogContainerFocus(!1)}},[setDialogContainerFocus,setDialogInputFocus]),jsxRuntimeExports.jsx("div",{className:styles.findReplaceDialogContainer,ref:dialogContainerRef,children:state.replaceRevealed?jsxRuntimeExports.jsx(ReplaceDialog,{ref:focusRef}):jsxRuntimeExports.jsx(FindDialog,{ref:focusRef})})}__name(FindReplaceDialog,"FindReplaceDialog");function useFindScopeOptions(localeService){const locale=localeService.getCurrentLocale();return require$$0.useMemo(()=>[{label:localeService.t("find-replace.dialog.find-scope.current-sheet"),value:FindScope.SUBUNIT},{label:localeService.t("find-replace.dialog.find-scope.workbook"),value:FindScope.UNIT}],[locale])}__name(useFindScopeOptions,"useFindScopeOptions");function useFindDirectionOptions(localeService){const locale=localeService.getCurrentLocale();return require$$0.useMemo(()=>[{label:localeService.t("find-replace.dialog.find-direction.row"),value:FindDirection.ROW},{label:localeService.t("find-replace.dialog.find-direction.column"),value:FindDirection.COLUMN}],[locale])}__name(useFindDirectionOptions,"useFindDirectionOptions");function useFindByOptions(localeService){const locale=localeService.getCurrentLocale();return require$$0.useMemo(()=>[{label:localeService.t("find-replace.dialog.find-by.value"),value:FindBy.VALUE},{label:localeService.t("find-replace.dialog.find-by.formula"),value:FindBy.FORMULA}],[locale])}__name(useFindByOptions,"useFindByOptions");function whenFindReplaceDialogFocused(contextService){return contextService.getContextValue(FIND_REPLACE_DIALOG_FOCUS)}__name(whenFindReplaceDialogFocused,"whenFindReplaceDialogFocused");function whenReplaceRevealed(contextService){return contextService.getContextValue(FIND_REPLACE_REPLACE_REVEALED)}__name(whenReplaceRevealed,"whenReplaceRevealed");function whenFindReplaceInputFocused(contextService){return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS)}__name(whenFindReplaceInputFocused,"whenFindReplaceInputFocused");const FIND_REPLACE_SHORTCUT_GROUP="7_find-replace-shortcuts";function whenSheetFocused(contextService){return contextService.getContextValue(core.FOCUSING_SHEET)}__name(whenSheetFocused,"whenSheetFocused");function whenEditorNotActivated(contextService){return!contextService.getContextValue(core.EDITOR_ACTIVATED)}__name(whenEditorNotActivated,"whenEditorNotActivated");const OpenFindDialogShortcutItem={id:OpenFindDialogOperation.id,description:"find-replace.shortcut.open-find-dialog",binding:ui.KeyCode.F|ui.MetaKeys.CTRL_COMMAND,group:FIND_REPLACE_SHORTCUT_GROUP,preconditions(contextService){return!whenFindReplaceDialogFocused(contextService)&&whenSheetFocused(contextService)&&whenEditorNotActivated(contextService)}},MacOpenFindDialogShortcutItem={id:OpenFindDialogOperation.id,description:"find-replace.shortcut.open-find-dialog",binding:ui.KeyCode.F|ui.MetaKeys.CTRL_COMMAND,mac:ui.KeyCode.F|ui.MetaKeys.MAC_CTRL,preconditions(contextService){return!whenFindReplaceDialogFocused(contextService)&&whenSheetFocused(contextService)&&whenEditorNotActivated(contextService)}},OpenReplaceDialogShortcutItem={id:OpenReplaceDialogOperation.id,description:"find-replace.shortcut.open-replace-dialog",binding:ui.KeyCode.H|ui.MetaKeys.CTRL_COMMAND,mac:ui.KeyCode.H|ui.MetaKeys.MAC_CTRL,group:FIND_REPLACE_SHORTCUT_GROUP,preconditions(contextService){return whenSheetFocused(contextService)&&whenEditorNotActivated(contextService)&&(!whenFindReplaceDialogFocused(contextService)||!whenReplaceRevealed(contextService))}},GoToNextFindMatchShortcutItem={id:GoToNextMatchOperation.id,description:"find-replace.shortcut.go-to-next-match",binding:ui.KeyCode.ENTER,group:FIND_REPLACE_SHORTCUT_GROUP,priority:1e3,preconditions(contextService){return whenFindReplaceInputFocused(contextService)&&whenFindReplaceDialogFocused(contextService)}},GoToPreviousFindMatchShortcutItem={id:GoToPreviousMatchOperation.id,description:"find-replace.shortcut.go-to-previous-match",binding:ui.KeyCode.ENTER|ui.MetaKeys.SHIFT,group:FIND_REPLACE_SHORTCUT_GROUP,priority:1e3,preconditions(contextService){return whenFindReplaceInputFocused(contextService)&&whenFindReplaceDialogFocused(contextService)}};function FindReplaceMenuItemFactory(accessor){const contextService=accessor.get(core.IContextService);return{id:OpenFindDialogOperation.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:ui.MenuItemType.BUTTON,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:rxjs.combineLatest([contextService.subscribeContextValue$(core.EDITOR_ACTIVATED),contextService.subscribeContextValue$(core.FOCUSING_SHEET)]).pipe(rxjs.map(([editorActivated,focusingSheet])=>editorActivated||!focusingSheet))}}__name(FindReplaceMenuItemFactory,"FindReplaceMenuItemFactory");const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[OpenFindDialogOperation.id]:{order:2,menuItemFactory:FindReplaceMenuItemFactory}}};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const FIND_REPLACE_DIALOG_ID="DESKTOP_FIND_REPLACE_DIALOG",FIND_REPLACE_PANEL_WIDTH=350,FIND_REPLACE_PANEL_RIGHT_PADDING=20,FIND_REPLACE_PANEL_TOP_PADDING=-90;exports2.FindReplaceController=(_c=class extends core.RxDisposable{constructor(_univerInstanceService,_menuManagerService,_shortcutService,_commandService,_findReplaceService,_dialogService,_layoutService,_localeService,_componentManager,_injector){super();__publicField(this,"_closingListenerDisposable");this._univerInstanceService=_univerInstanceService,this._menuManagerService=_menuManagerService,this._shortcutService=_shortcutService,this._commandService=_commandService,this._findReplaceService=_findReplaceService,this._dialogService=_dialogService,this._layoutService=_layoutService,this._localeService=_localeService,this._componentManager=_componentManager,this._injector=_injector,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var _a2;super.dispose(),(_a2=this._closingListenerDisposable)==null||_a2.dispose(),this._closingListenerDisposable=null}_initCommands(){[OpenFindDialogOperation,OpenReplaceDialogOperation,GoToNextMatchOperation,GoToPreviousMatchOperation,ReplaceAllMatchesCommand,ReplaceCurrentMatchCommand].forEach(c=>{this.disposeWithMe(this._commandService.registerCommand(c))})}_initShortcuts(){[OpenReplaceDialogShortcutItem,OpenFindDialogShortcutItem,MacOpenFindDialogShortcutItem,GoToPreviousFindMatchShortcutItem,GoToNextFindMatchShortcutItem].forEach(s=>this.disposeWithMe(this._shortcutService.registerShortcut(s)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",FindReplaceDialog)),this.disposeWithMe(this._componentManager.register("SearchIcon",SearchSingle16)),this._menuManagerService.mergeMenu(menuSchema),this._findReplaceService.stateUpdates$.pipe(rxjs.takeUntil(this.dispose$)).subscribe(newState=>{newState.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:FIND_REPLACE_DIALOG_ID,draggable:!0,width:FIND_REPLACE_PANEL_WIDTH,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:getFindReplaceDialogDefaultPosition(),preservePositionOnDestroy:!0,onClose:__name(()=>this.closePanel(),"onClose")}),this._closingListenerDisposable=core.toDisposable(this._univerInstanceService.focused$.pipe(rxjs.takeUntil(this.dispose$)).subscribe(focused=>{(!focused||!this._univerInstanceService.getUniverSheetInstance(focused))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(FIND_REPLACE_DIALOG_ID),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},__name(_c,"FindReplaceController"),_c),exports2.FindReplaceController=__decorateClass$1([__decorateParam$1(0,core.IUniverInstanceService),__decorateParam$1(1,ui.IMenuManagerService),__decorateParam$1(2,ui.IShortcutService),__decorateParam$1(3,core.ICommandService),__decorateParam$1(4,IFindReplaceService),__decorateParam$1(5,ui.IDialogService),__decorateParam$1(6,ui.ILayoutService),__decorateParam$1(7,core.Inject(core.LocaleService)),__decorateParam$1(8,core.Inject(ui.ComponentManager)),__decorateParam$1(9,core.Inject(core.Injector))],exports2.FindReplaceController);function getFindReplaceDialogDefaultPosition(){const{innerWidth}=window;return{x:(innerWidth-FIND_REPLACE_PANEL_WIDTH)/2-FIND_REPLACE_PANEL_RIGHT_PADDING,y:FIND_REPLACE_PANEL_TOP_PADDING}}__name(getFindReplaceDialogDefaultPosition,"getFindReplaceDialogDefaultPosition");var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");const PLUGIN_NAME="UNIVER_FIND_REPLACE_PLUGIN";exports2.UniverFindReplacePlugin=(_d=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[exports2.FindReplaceController],[IFindReplaceService,{useClass:FindReplaceService}]].forEach(d=>this._injector.add(d))}onRendered(){this._injector.get(exports2.FindReplaceController)}},__name(_d,"UniverFindReplacePlugin"),__publicField(_d,"pluginName",PLUGIN_NAME),_d),exports2.UniverFindReplacePlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverFindReplacePlugin),exports2.FindBy=FindBy,exports2.FindDirection=FindDirection,exports2.FindModel=FindModel,exports2.FindScope=FindScope,exports2.GoToNextMatchOperation=GoToNextMatchOperation,exports2.GoToPreviousMatchOperation=GoToPreviousMatchOperation,exports2.IFindReplaceService=IFindReplaceService,exports2.OpenFindDialogOperation=OpenFindDialogOperation,exports2.OpenReplaceDialogOperation=OpenReplaceDialogOperation,exports2.ReplaceAllMatchesCommand=ReplaceAllMatchesCommand,exports2.ReplaceCurrentMatchCommand=ReplaceCurrentMatchCommand,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
9
+ */var Me=l,ye=Symbol.for("react.element"),Ie=Symbol.for("react.fragment"),Fe=Object.prototype.hasOwnProperty,De=Me.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xe={key:!0,ref:!0,__self:!0,__source:!0};function ne(n,e,i){var t,s={},r=null,o=null;i!==void 0&&(r=""+i),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)Fe.call(e,t)&&!xe.hasOwnProperty(t)&&(s[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)s[t]===void 0&&(s[t]=e[t]);return{$$typeof:ye,type:n,key:r,ref:o,props:s,_owner:De.current}}P.Fragment=Ie,P.jsx=ne,P.jsxs=ne,te.exports=P;var u=te.exports;function ie(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:s,findString:r,findReplaceService:o,onChange:f,..._}=n,S=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:S,value:s,total:t,onChange:v=>{s===t&&v===1?o.moveToNextMatch():s===1&&v===t||v<s?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:r,onChange:v=>f==null?void 0:f(v),..._})}const E={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function se(n,e){const i=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),l.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Te=l.forwardRef(function(e,i){const t=a.useDependency(a.LocaleService),s=a.useDependency(R),r=a.useDependency(a.ICommandService),o=d.useObservable(s.state$,void 0,!0),{findCompleted:f,findString:_,matchesCount:M,matchesPosition:S}=o,v=l.useCallback(()=>{r.executeCommand(O.id)},[r]),L=l.useCallback(y=>s.changeFindString(y),[s]);return se(s,i),u.jsxs(l.Fragment,{children:[u.jsx(ie,{findCompleted:f,className:"univer-find-input",matchesCount:M,matchesPosition:S,findReplaceService:s,localeService:t,findString:_,onChange:L}),u.jsx("div",{className:E.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:v,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Oe=l.forwardRef(function(e,i){const t=a.useDependency(R),s=a.useDependency(a.LocaleService),r=a.useDependency(a.ICommandService),o=a.useDependency(d.IMessageService),f=d.useObservable(t.currentMatch$,void 0,!0),_=d.useObservable(t.replaceables$,void 0,!0),M=d.useObservable(t.state$,void 0,!0),{matchesCount:S,matchesPosition:v,findString:L,inputtingFindString:y,replaceString:qe,caseSensitive:et,matchesTheWholeCell:tt,findDirection:nt,findScope:it,findBy:st,findCompleted:z}=M,at=y.length===0,rt=S===0||!(f!=null&&f.replaceable),ot=_.length===0,ct=l.useCallback(g=>t.changeInputtingFindString(g),[t]),lt=l.useCallback(g=>t.changeReplaceString(g),[t]),{focus:dt}=se(t,i),ht=l.useCallback(()=>{L===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[L,y,t]),ut=l.useCallback(()=>r.executeCommand(k.id),[r]),ft=l.useCallback(async()=>{await r.executeCommand(W.id),dt()},[r]),pt=l.useCallback(g=>{t.changeFindDirection(g)},[t]),_t=l.useCallback(g=>{t.changeFindScope(g)},[t]),gt=l.useCallback(g=>{t.changeFindBy(g)},[t]),mt=Ee(s),vt=Ne(s),St=Le(s);return l.useEffect(()=>{const g=z&&S===0;let j=null;return g&&(j=o.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,duration:5e3})),()=>j==null?void 0:j.dispose()},[z,S,o,s]),u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:u.jsx(ie,{findCompleted:z,className:"univer-find-input",matchesCount:S,matchesPosition:v,findReplaceService:t,localeService:s,findString:y,onChange:ct})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.replace"),children:u.jsx(p.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:qe,onChange:g=>lt(g)})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:nt,options:vt,onChange:pt})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:u.jsx(p.Select,{value:it,options:mt,onChange:_t})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:st,options:St,onChange:gt})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:et,onChange:g=>{t.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:tt,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:E.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:ht,disabled:at,children:s.t("find-replace.dialog.find")}),u.jsxs("span",{className:E.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:rt,onClick:ut,children:s.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:ot,onClick:ft,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Pe(){const n=a.useDependency(R),e=a.useDependency(d.ILayoutService),i=a.useDependency(a.IContextService),t=d.useObservable(n.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let _;return s.current&&(_=e.registerContainerElement(s.current)),()=>_==null?void 0:_.dispose()},[e]);const r=l.useRef(null),o=l.useCallback(_=>i.setContextValue(X,_),[i]),f=l.useCallback(_=>i.setContextValue(Q,_),[i]);return l.useEffect(()=>{var M;const _=m.fromEvent(document,"focusin").subscribe(S=>{var v;S.target&&((v=s.current)!=null&&v.contains(S.target))?o(!0):o(!1),!r.current||!r.current.selectHasFocus()?f(!0):f(!1)});return(M=r.current)==null||M.focus(),o(!0),f(!0),()=>{_.unsubscribe(),o(!1)}},[o,f]),u.jsx("div",{className:E.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?u.jsx(Oe,{ref:r}):u.jsx(Te,{ref:r})})}function Ee(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:T.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:T.UNIT}],[e])}function Ne(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:D.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:D.COLUMN}],[e])}function Le(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:x.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:x.FORMULA}],[e])}function F(n){return n.getContextValue(X)}function je(n){return n.getContextValue(q)}function ae(n){return n.getContextValue(Q)}const N="7_find-replace-shortcuts";function H(n){return n.getContextValue(a.FOCUSING_SHEET)}function K(n){return!n.getContextValue(a.EDITOR_ACTIVATED)}const Ae={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:N,preconditions(n){return!F(n)&&H(n)&&K(n)}},Ue={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.F|d.MetaKeys.MAC_CTRL,preconditions(n){return!F(n)&&H(n)&&K(n)}},we={id:O.id,description:"find-replace.shortcut.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.H|d.MetaKeys.MAC_CTRL,group:N,preconditions(n){return H(n)&&K(n)&&(!F(n)||!je(n))}},Be={id:G.id,description:"find-replace.shortcut.go-to-next-match",binding:d.KeyCode.ENTER,group:N,priority:1e3,preconditions(n){return ae(n)&&F(n)}},ke={id:V.id,description:"find-replace.shortcut.go-to-previous-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:N,priority:1e3,preconditions(n){return ae(n)&&F(n)}};function We(n){const e=n.get(a.IContextService);return{id:I.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:d.MenuItemType.BUTTON,hidden$:d.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:m.combineLatest([e.subscribeContextValue$(a.EDITOR_ACTIVATED),e.subscribeContextValue$(a.FOCUSING_SHEET)]).pipe(m.map(([i,t])=>i||!t))}}const Ge={[d.RibbonStartGroup.OTHERS]:{[I.id]:{order:2,menuItemFactory:We}}};var Ve=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Ke=(n,e,i,t)=>{for(var s=t>1?void 0:t?He(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&Ve(e,i,s),s},b=(n,e)=>(i,t)=>e(i,t,n);const re="DESKTOP_FIND_REPLACE_DIALOG",oe=350,$e=20,ze=-90;c.FindReplaceController=class extends a.RxDisposable{constructor(i,t,s,r,o,f,_,M,S,v){super();h(this,"_closingListenerDisposable");this._univerInstanceService=i,this._menuManagerService=t,this._shortcutService=s,this._commandService=r,this._findReplaceService=o,this._dialogService=f,this._layoutService=_,this._localeService=M,this._componentManager=S,this._injector=v,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var i;super.dispose(),(i=this._closingListenerDisposable)==null||i.dispose(),this._closingListenerDisposable=null}_initCommands(){[I,O,G,V,W,k].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initShortcuts(){[we,Ae,Ue,ke,Be].forEach(i=>this.disposeWithMe(this._shortcutService.registerShortcut(i)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Pe)),this.disposeWithMe(this._componentManager.register("SearchIcon",J)),this._menuManagerService.mergeMenu(Ge),this._findReplaceService.stateUpdates$.pipe(m.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:re,draggable:!0,width:oe,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:Ye(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=a.toDisposable(this._univerInstanceService.focused$.pipe(m.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(re),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},c.FindReplaceController=Ke([b(0,a.IUniverInstanceService),b(1,d.IMenuManagerService),b(2,d.IShortcutService),b(3,a.ICommandService),b(4,R),b(5,d.IDialogService),b(6,d.ILayoutService),b(7,a.Inject(a.LocaleService)),b(8,a.Inject(d.ComponentManager)),b(9,a.Inject(a.Injector))],c.FindReplaceController);function Ye(){const{innerWidth:n}=window;return{x:(n-oe)/2-$e,y:ze}}var Ze=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(n,e,i,t)=>{for(var s=t>1?void 0:t?Je(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&Ze(e,i,s),s},ce=(n,e)=>(i,t)=>e(i,t,n);const Xe="UNIVER_FIND_REPLACE_PLUGIN";c.UniverFindReplacePlugin=($=class extends a.Plugin{constructor(e=he,i,t){super(),this._config=e,this._injector=i,this._configService=t;const{...s}=this._config;this._configService.setConfig(de,s)}onStarting(){[[c.FindReplaceController],[R,{useClass:B}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(c.FindReplaceController)}},h($,"pluginName",Xe),$),c.UniverFindReplacePlugin=Qe([ce(1,a.Inject(a.Injector)),ce(2,a.IConfigService)],c.UniverFindReplacePlugin),c.FindBy=x,c.FindDirection=D,c.FindModel=Se,c.FindScope=T,c.GoToNextMatchOperation=G,c.GoToPreviousMatchOperation=V,c.IFindReplaceService=R,c.OpenFindDialogOperation=I,c.OpenReplaceDialogOperation=O,c.ReplaceAllMatchesCommand=W,c.ReplaceCurrentMatchCommand=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1 @@
1
+ (function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l():typeof define=="function"&&define.amd?define(l):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverFindReplaceEnUS=l())})(this,function(){"use strict";return{"find-replace":{toolbar:"Find & Replace",shortcut:{"open-find-dialog":"Open Find Dialog","open-replace-dialog":"Open Replace Dialog","close-dialog":"Close Find & Replace Dialog","go-to-next-match":"Go to Next Match","go-to-previous-match":"Go to Previous Match"},dialog:{title:"Find",find:"Find",replace:"Replace","replace-all":"Replace All","case-sensitive":"Case Sensitive","find-placeholder":"Find in this Sheet","advanced-finding":"Advanced Searching & Replace","replace-placeholder":"Input Replace String","match-the-whole-cell":"Match the Whole Cell","find-direction":{title:"Find Direction",row:"Search by Row",column:"Search by Column"},"find-scope":{title:"Find Range","current-sheet":"Current Sheet",workbook:"Workbook"},"find-by":{title:"Find By",value:"Find by Value",formula:"Find Formula"},"no-match":"Finding completed but no match found.","no-result":"No Result"},replace:{"all-success":"Replaced all {0} matches","all-failure":"Replace failed",confirm:{title:"Are you sure to replace all matches?"}}},"find-replace-shortcuts":"Find & Replace"}});