@univerjs/sheets-hyper-link-ui 0.2.1 → 0.2.3
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 +20 -5
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +317 -305
- package/lib/locale/vi-VN.json +35 -0
- package/lib/locale/zh-TW.json +35 -0
- package/lib/types/controllers/set-range.controller.d.ts +2 -2
- package/lib/types/locale/vi-VN.d.ts +4 -0
- package/lib/types/locale/zh-TW.d.ts +4 -0
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/services/popup.service.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +17 -17
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hyperLink": {
|
|
3
|
+
"form": {
|
|
4
|
+
"editTitle": "Chỉnh sửa liên kết",
|
|
5
|
+
"addTitle": "Chèn liên kết",
|
|
6
|
+
"label": "Văn bản",
|
|
7
|
+
"labelPlaceholder": "Nhập văn bản",
|
|
8
|
+
"type": "Loại",
|
|
9
|
+
"link": "Liên kết",
|
|
10
|
+
"linkPlaceholder": "Nhập địa chỉ liên kết",
|
|
11
|
+
"range": "Ô",
|
|
12
|
+
"worksheet": "Bảng tính",
|
|
13
|
+
"definedName": "Tên đã xác định",
|
|
14
|
+
"ok": "Xác nhận",
|
|
15
|
+
"cancel": "Hủy",
|
|
16
|
+
"inputError": "Vui lòng nhập",
|
|
17
|
+
"selectError": "Vui lòng chọn",
|
|
18
|
+
"linkError": "Vui lòng nhập liên kết hợp lệ"
|
|
19
|
+
},
|
|
20
|
+
"menu": {
|
|
21
|
+
"add": "Thêm liên kết"
|
|
22
|
+
},
|
|
23
|
+
"message": {
|
|
24
|
+
"noSheet": "Bảng con này đã bị xóa",
|
|
25
|
+
"refError": "Tham chiếu lỗi",
|
|
26
|
+
"hiddenSheet": "Không thể mở bảng con bị ẩn",
|
|
27
|
+
"coped": "Liên kết đã được sao chép vào clipboard"
|
|
28
|
+
},
|
|
29
|
+
"popup": {
|
|
30
|
+
"copy": "Sao chép",
|
|
31
|
+
"edit": "Chỉnh sửa",
|
|
32
|
+
"cancel": "Hủy liên kết"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hyperLink": {
|
|
3
|
+
"form": {
|
|
4
|
+
"editTitle": "編輯連結",
|
|
5
|
+
"addTitle": "插入連結",
|
|
6
|
+
"label": "文本",
|
|
7
|
+
"labelPlaceholder": "輸入文字",
|
|
8
|
+
"type": "類型",
|
|
9
|
+
"link": "連結",
|
|
10
|
+
"linkPlaceholder": "輸入連結位址",
|
|
11
|
+
"range": "單元格",
|
|
12
|
+
"worksheet": "工作表",
|
|
13
|
+
"definedName": "定義的名稱",
|
|
14
|
+
"ok": "確認",
|
|
15
|
+
"cancel": "取消",
|
|
16
|
+
"inputError": "請輸入",
|
|
17
|
+
"selectError": "請選擇",
|
|
18
|
+
"linkError": "請輸入合法的連結"
|
|
19
|
+
},
|
|
20
|
+
"menu": {
|
|
21
|
+
"add": "新增連結"
|
|
22
|
+
},
|
|
23
|
+
"message": {
|
|
24
|
+
"noSheet": "該子表已被刪除",
|
|
25
|
+
"refError": "錯誤的引用",
|
|
26
|
+
"hiddenSheet": "無法開啟被隱藏的子表",
|
|
27
|
+
"coped": "連結已複製到剪貼簿"
|
|
28
|
+
},
|
|
29
|
+
"popup": {
|
|
30
|
+
"copy": "複製",
|
|
31
|
+
"edit": "編輯",
|
|
32
|
+
"cancel": "取消連結"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { Injector } from '@wendellhu/redi';
|
|
3
|
-
import {
|
|
3
|
+
import { SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
|
|
4
4
|
import { HyperLinkModel } from '@univerjs/sheets-hyper-link';
|
|
5
5
|
|
|
6
6
|
export declare class SheetHyperLinkSetRangeController extends Disposable {
|
|
@@ -9,7 +9,7 @@ export declare class SheetHyperLinkSetRangeController extends Disposable {
|
|
|
9
9
|
private readonly _hyperLinkModel;
|
|
10
10
|
private readonly _selectionManagerService;
|
|
11
11
|
private readonly _univerInstanceService;
|
|
12
|
-
constructor(_sheetInterceptorService: SheetInterceptorService, _injector: Injector, _hyperLinkModel: HyperLinkModel, _selectionManagerService:
|
|
12
|
+
constructor(_sheetInterceptorService: SheetInterceptorService, _injector: Injector, _hyperLinkModel: HyperLinkModel, _selectionManagerService: SheetsSelectionsService, _univerInstanceService: IUniverInstanceService);
|
|
13
13
|
private _initCommandInterceptor;
|
|
14
14
|
private _initAddHyperLinkCommandInterceptor;
|
|
15
15
|
private _initUpdateHyperLinkCommandInterceptor;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export declare class UniverSheetsHyperLinkUIPlugin extends Plugin {
|
|
|
11
11
|
static type: UniverInstanceType;
|
|
12
12
|
constructor(_config: IUniverSheetsHyperLinkUIConfig, _injector: Injector, _renderManagerService: IRenderManagerService);
|
|
13
13
|
onStarting(injector: Injector): void;
|
|
14
|
+
onReady(): void;
|
|
14
15
|
}
|
|
@@ -4,7 +4,7 @@ import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
|
|
|
4
4
|
import { IDisposable } from '@wendellhu/redi';
|
|
5
5
|
import { Disposable } from '@univerjs/core';
|
|
6
6
|
|
|
7
|
-
interface IHyperLinkPopup {
|
|
7
|
+
export interface IHyperLinkPopup {
|
|
8
8
|
unitId: string;
|
|
9
9
|
subUnitId: string;
|
|
10
10
|
id: string;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/engine-render","rxjs","react","@wendellhu/redi/react-bindings","clsx","@univerjs/design","@univerjs/ui","@univerjs/engine-formula"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l.UniverSheetsHyperLinkUi={},l.UniverCore,l.UniverSheets,l["@wendellhu/redi"],l.UniverSheetsHyperLink,l.UniverSheetsUi,l.UniverEngineRender,l.rxjs,l.React,l["@wendellhu/redi/react-bindings"],l.clsx,l.UniverDesign,l.UniverUi,l.UniverEngineFormula))})(this,function(l,a,
|
|
1
|
+
(function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/engine-render","rxjs","react","@wendellhu/redi/react-bindings","clsx","@univerjs/design","@univerjs/ui","@univerjs/engine-formula"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l.UniverSheetsHyperLinkUi={},l.UniverCore,l.UniverSheets,l["@wendellhu/redi"],l.UniverSheetsHyperLink,l.UniverSheetsUi,l.UniverEngineRender,l.rxjs,l.React,l["@wendellhu/redi/react-bindings"],l.clsx,l.UniverDesign,l.UniverUi,l.UniverEngineFormula))})(this,function(l,a,p,g,v,f,he,me,C,T,Re,I,O,A){"use strict";var Gn=Object.defineProperty;var Xn=(l,a,p)=>a in l?Gn(l,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[a]=p;var Y=(l,a,p)=>Xn(l,typeof a!="symbol"?a+"":a,p);var Ve=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,We=(i,e,t,n)=>{for(var r=n>1?void 0:n?xe(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ve(e,t,r),r},ve=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRemoveSheetController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===p.RemoveSheetCommand.id){const n=e.params,r=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return{redos:[],undos:[]};const o=r.getUnitId(),s=n.subUnitId||((t=r.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const c=this._hyperLinkModel.getSubUnit(o,s),d=c.map(y=>({id:v.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:y.id}})),h=c.map(y=>({id:v.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:y}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=We([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),ve(0,g.Inject(p.SheetInterceptorService)),ve(1,a.IUniverInstanceService),ve(2,g.Inject(v.HyperLinkModel))],l.SheetsHyperLinkRemoveSheetController);var Be=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Pe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Fe(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Be(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRenderController=class extends a.Disposable{constructor(e,t,n,r){super(),this._context=e,this._hyperLinkModel=t,this._sheetSkeletonManagerService=n,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var c;const t=this._context.unit,n=t.getUnitId(),r=(c=t.getActiveSheet())==null?void 0:c.getSheetId();if(!r){console.warn("No active sheet found");return}const o=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:r}),s=this._renderManagerService.getRenderById(n);o==null||o.makeDirty(!0),o==null||o.calculate(),s&&s.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(()=>{e()}))}},l.SheetsHyperLinkRenderController=Pe([z(1,g.Inject(v.HyperLinkModel)),z(2,g.Inject(f.SheetSkeletonManagerService)),z(3,he.IRenderManagerService)],l.SheetsHyperLinkRenderController),l.SheetsHyperLinkRenderManagerController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._themeService=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,t,n)=>{const{row:r,col:o,unitId:s,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(s,c,r,o),h=this._themeService.getCurrentTheme();return n(d?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:h.blue500}}}:e)},priority:100}))}},l.SheetsHyperLinkRenderManagerController=Pe([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRenderManagerController),z(0,g.Inject(p.SheetInterceptorService)),z(1,g.Inject(v.HyperLinkModel)),z(2,g.Inject(a.ThemeService))],l.SheetsHyperLinkRenderManagerController);var be={exports:{}},re={};/**
|
|
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 $e=C,Ye=Symbol.for("react.element"),ze=Symbol.for("react.fragment"),Ke=Object.prototype.hasOwnProperty,Ze=$e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0};function Ee(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Ke.call(e,n)&&!Ge.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Ye,type:i,key:o,ref:s,props:r,_owner:Ze.current}}re.Fragment=ze,re.jsx=Ee,re.jsxs=Ee,be.exports=re;var m=be.exports,U=function(){return U=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},U.apply(this,arguments)},Xe=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},$=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=Xe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=C.useRef("_".concat(qe()));return Oe(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},U({ref:e,className:c},s),o)});function Oe(i,e,t,n,r){return C.createElement(i.tag,U(U({key:e},Je(i,t,r)),n),(Qe(i,t).children||[]).map(function(o,s){return Oe(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function Je(i,e,t){var n=U({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Qe(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?U(U({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?U(U({},r),{attrs:U(U({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function qe(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"all-border-single",ref:e,icon:en}))});ie.displayName="AllBorderSingle";var nn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},we=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"copy-single",ref:e,icon:nn}))});we.displayName="CopySingle";var tn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},oe=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"link-single",ref:e,icon:tn}))});oe.displayName="LinkSingle";var rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Me=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"unlink-single",ref:e,icon:rn}))});Me.displayName="UnlinkSingle";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},He=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"write-single",ref:e,icon:on}))});He.displayName="WriteSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"xlsx",ref:e,icon:sn}))});ge.displayName="Xlsx";var an=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,cn=(i,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&an(e,t,r),r},X=(i,e)=>(t,n)=>e(t,n,i);function dn(i,e){const t=e.getMergeData(),n=e.getMaxColumns()-1,r=e.getMaxRows()-1;if(n<i.endColumn&&(i.endColumn=n),r<i.endRow&&(i.endRow=r),i.rangeType===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return t.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}l.SheetsHyperLinkResolverService=class{constructor(e,t,n,r,o){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=o}_getURLName(e){var d;const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=s==null?void 0:s.getName())!=null?d:"";if(n){const h=A.deserializeRangeWithSheet(n).range;return a.isValidRange(h)&&n!==v.ERROR_RANGE?{type:"range",name:A.serializeRangeWithSheet(c,h)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const h=this._definedNamesService.getValueById(o.getUnitId(),r);return h?{type:"defineName",name:h.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const h=o.getSheetBySheetId(t);return h?{type:"sheet",name:h.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!t){if(n){const c=A.deserializeRangeWithSheet(n);a.isValidRange(c.range)&&n!==v.ERROR_RANGE&&this.navigateToRange(s,t,c.range);return}this.navigateToSheetById(s,t)}}parseHyperLink(e){var t,n,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),s={gid:(t=o.get("gid"))!=null?t:"",range:(n=o.get("range"))!=null?n:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(s);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:s,handler:()=>{this.navigateTo(s)}}}else return{type:"outer",name:e,url:e,handler:()=>{this.navigateToOtherWebsite(e)}}}async navigateToRange(e,t,n){const r=await this.navigateToSheetById(e,t);if(r){const o=dn(n,r);await this._commandService.executeCommand(u.SetSelectionsOperation.id,{unitId:e,subUnitId:t,pluginName:u.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}),await this._commandService.executeCommand(f.ScrollToRangeOperation.id,{range:o})}}async navigateToSheet(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if((r==null?void 0:r.getName())===t)return!0;const o=n.getSheetBySheetName(t);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error});return}const s=o.getSheetId();return n.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const o=n.getSheetBySheetId(t);return o?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){window.open(e,"_blank","noopener noreferrer")}},l.SheetsHyperLinkResolverService=cn([X(0,a.IUniverInstanceService),X(1,a.ICommandService),X(2,A.IDefinedNamesService),X(3,O.IMessageService),X(4,y.Inject(a.LocaleService))],l.SheetsHyperLinkResolverService);function J(i){return a.Tools.isLegalUrl(i)}function un(i){return/^[a-zA-Z]+:\/\//.test(i)}function pn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function Se(i){if(J(i)){const e=un(i)?i:pn(i)?`mailto://${i}`:`http://${i}`,t=new URL(e);return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:e}return i}function hn(i){if(i===null)return"";if(i!=null&&i.p){const e=i==null?void 0:i.p.body;if(e==null)return"";const t=e.dataStream;return t.substring(t.length-2,t.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?t.substring(0,t.length-2):t}return i==null?void 0:i.v}const mn={cellLinkEditButtons:"univer-cell-link-edit-buttons"},se=()=>{var te;const[i,e]=C.useState(""),[t,n]=C.useState(""),[r,o]=C.useState("link"),[s,c]=C.useState(""),d=T.useDependency(a.LocaleService),h=T.useDependency(A.IDefinedNamesService),g=T.useDependency(a.IUniverInstanceService),_=T.useDependency(l.SheetsHyperLinkPopupService),p=O.useObservable(_.currentEditing$),R=T.useDependency(v.HyperLinkModel),L=T.useDependency(l.SheetsHyperLinkResolverService),k=T.useDependency(a.ICommandService),[P,N]=C.useState(!1),w=C.useRef(!1);C.useEffect(()=>{var S,b,M;if((p==null?void 0:p.row)!==void 0&&p.column!==void 0){const E=R.getHyperLinkByLocationSync(p.unitId,p.subUnitId,p.row,p.column);if(E){const pe=L.parseHyperLink(E.payload);if(e(E.id),n(E.display),pe.type==="outer"){o("link"),c(pe.url),pe.url===E.display&&(w.current=!0);return}else{const W=pe.searchObj;if(W.rangeid){o("rangeid"),c(W.rangeid);return}if(W.range){const Zn=W.gid&&(M=(b=(S=g.getUnit(p.unitId))==null?void 0:S.getSheetBySheetId(W.gid))==null?void 0:b.getName())!=null?M:"";if(o("range"),W.range===v.ERROR_RANGE)c("");else{const Ae=A.serializeRangeWithSheet(Zn,A.deserializeRangeWithSheet(W.range).range);c(Ae),Ae===E.display&&(w.current=!0)}return}if(W.gid){o("gid"),c(W.gid);return}}}const j=g.getUnit(p.unitId),D=j==null?void 0:j.getSheetBySheetId(p.subUnitId),Kn=D==null?void 0:D.getCellRaw(p.row,p.column),Ie=hn(Kn);o("link"),c(""),n((Ie!=null?Ie:"").toString()),e("");return}o("link"),c(""),n(""),e("")},[p,R,L,g]);const x=C.useMemo(()=>s,[r]),Z=[{label:d.t("hyperLink.form.link"),value:"link"},{label:d.t("hyperLink.form.range"),value:"range"},{label:d.t("hyperLink.form.worksheet"),value:"gid"},{label:d.t("hyperLink.form.definedName"),value:"rangeid"}],H=g.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!H)return;const G=H.getHiddenWorksheets(),B=H.getSheets().map(S=>({label:S.getName(),value:S.getSheetId()})).filter(S=>G.indexOf(S.value)===-1),F=Object.values((te=h.getDefinedNameMap(H.getUnitId()))!=null?te:{}).map(S=>({label:S.name,value:S.id})),ne=(S,b)=>{if(S==="link")return Se(b);if(S==="range"){const M=A.deserializeRangeWithSheet(b),E=H.getSheetBySheetName(M.sheetName);if(E)return`#gid=${E.getSheetId()}&range=${A.serializeRange(M.range)}`}return`#${S}=${b}`},Le=O.useEvent(S=>{var E;const b=S[0];if(!b||!a.isValidRange(b.range))return;b.sheetName||(b.sheetName=((E=H.getActiveSheet())==null?void 0:E.getName())||"");const M=A.serializeRangeToRefString(b);c(M),M&&(w.current||!t)&&(n(M),w.current=!0)}),ke=async()=>{if(p&&(i?await k.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:p.unitId,subUnitId:p.subUnitId,id:i,payload:{display:t,payload:ne(r,s)}}):await k.executeCommand(v.AddHyperLinkCommand.id,{unitId:p.unitId,subUnitId:p.subUnitId,link:{id:a.Tools.generateRandomId(),row:p.row,column:p.column,payload:ne(r,s),display:t}})),p){await k.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:p.unitId,subUnitId:p.subUnitId});const S=1;await k.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(p.row-S,0),endRow:p.row+S,startColumn:Math.max(p.column-S,0),endColumn:p.column+S}})}k.executeCommand(Q.id)};return m.jsxs("div",{children:[m.jsx(I.FormLayout,{label:d.t("hyperLink.form.label"),error:P&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:t,onChange:S=>{n(S),w.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(I.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(I.Select,{options:Z,value:r,onChange:S=>{o(S),c("")}})}),r==="link"&&m.jsx(I.FormLayout,{error:P?s?J(s)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:s,onChange:S=>{c(S),S&&(w.current||!t||t===s)&&(n(S),w.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(I.FormLayout,{error:P&&!s?d.t("hyperLink.form.inputError"):"",children:m.jsx(O.RangeSelector,{openForSheetUnitId:H.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:x,onChange:Le})}),r==="gid"&&m.jsx(I.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:B,value:s,onChange:S=>{var E,j;c(S);const b=(E=B.find(D=>D.value===S))==null?void 0:E.label,M=(j=B.find(D=>D.value===s))==null?void 0:j.label;b&&(w.current||!t||t===M)&&(n(b),w.current=!0)}})}),r==="rangeid"&&m.jsx(I.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:F,value:s,onChange:S=>{var E,j;c(S);const b=(E=F.find(D=>D.value===S))==null?void 0:E.label,M=(j=F.find(D=>D.value===s))==null?void 0:j.label;b&&(w.current||!t||t===M)&&(n(b),w.current=!0)}})}),m.jsxs("div",{className:mn.cellLinkEditButtons,children:[m.jsx(I.Button,{onClick:()=>{p&&k.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:p.unitId,subUnitId:p.subUnitId}),k.executeCommand(Q.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!s||r==="link"&&!J(s)){N(!0);return}ke()},children:d.t("hyperLink.form.ok")})]})]})};se.componentKey="univer.sheet.cell-link-edit";const ae={type:a.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,e){if(!e)return!1;const{unitId:t,subUnitId:n,row:r,column:o}=e,s=i.get(v.HyperLinkModel),c=i.get(O.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),h=s.getHyperLinkByLocation(t,n,r,o);return d.startEditing(e),c.open({header:{title:h?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:se.componentKey}}),!0}},Q={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(O.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return e.close(),t.endEditing(),!0}},le={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),t=u.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(a.ICommandService),o=i.get(u.SelectionManagerService).getFirst();if(!(o!=null&&o.primary))return!1;const s=o.primary.startRow,c=o.primary.startColumn;return n.executeCommand(ae.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:s,column:c})}},ye={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(a.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(Q.id):e.executeCommand(le.id)}},V={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},vn={outer:m.jsx(oe,{}),link:m.jsx(oe,{}),sheet:m.jsx(ge,{}),range:m.jsx(ie,{}),defineName:m.jsx(ie,{}),"range-error":m.jsx(ie,{}),"sheet-error":m.jsx(ge,{})},ce=()=>{const i=T.useDependency(l.SheetsHyperLinkPopupService),e=T.useDependency(v.HyperLinkModel),t=T.useDependency(a.ICommandService),n=T.useDependency(O.IMessageService),r=T.useDependency(a.LocaleService),o=O.useObservable(i.currentPopup$,i.currentPopup),s=T.useDependency(l.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:d,id:h}=o,g=e.getHyperLink(c,d,h);if(!g)return null;const _=s.parseHyperLink(g.payload),p=_.type.indexOf("error")>-1;return m.jsxs("div",{className:V.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:Re(V.cellLinkContent,{[V.cellLinkContentError]:p}),onClick:_.handler,children:[m.jsx("div",{className:V.cellLinkType,children:vn[_.type]}),m.jsx(I.Tooltip,{showIfEllipsis:!0,title:_.name,children:m.jsx("span",{className:V.cellLinkUrl,children:_.name})})]}),m.jsxs("div",{className:V.cellLinkOperations,children:[o.copyPermission&&m.jsx("div",{className:Re(V.cellLinkOperation,{[V.cellLinkOperationError]:p}),onClick:()=>{if(!p){if(_.type!=="outer"){const R=new URL(window.location.href);R.hash=_.url.slice(1),navigator.clipboard.writeText(R.href)}else navigator.clipboard.writeText(_.url);n.show({content:r.t("hyperLink.message.coped"),type:I.MessageType.Info})}},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(we,{})})}),o.editPermission&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(ae.id,{unitId:c,subUnitId:d,row:g.row,column:g.column})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(He,{})})}),m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:c,subUnitId:d,id:g.id})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(Me,{})})})]})]})]})};ce.componentKey="univer.sheet.cell-link-popup";var gn=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,yn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Sn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&gn(e,t,r),r},je=(i,e)=>(t,n)=>e(t,n,i);const fn=(i,e)=>i.unitId===e.unitId&&i.subUnitId===e.subUnitId&&i.row===e.row&&i.col===e.col;l.SheetsHyperLinkPopupService=class extends a.Disposable{constructor(t,n){super();Y(this,"_currentPopup",null);Y(this,"_currentPopup$",new me.Subject);Y(this,"currentPopup$",this._currentPopup$.asObservable());Y(this,"_currentEditing$",new me.BehaviorSubject(null));Y(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=t,this._sheetCanvasPopManagerService=n,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(t){if(this._currentPopup&&fn(t,this._currentPopup))return;this.hideCurrentPopup();const{unitId:n,subUnitId:r,row:o,col:s}=t,c=this._hyperLinkModel.getHyperLinkByLocation(n,r,o,s);if(!c)return;const d=this._sheetCanvasPopManagerService.attachPopupToCell(o,s,{componentKey:ce.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideCurrentPopup()}});d&&(this._currentPopup={unitId:n,subUnitId:r,id:c.id,disposable:d,row:o,col:s,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var t;this._currentPopup&&((t=this._currentPopup.disposable)==null||t.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(t){this._currentEditing$.next(t)}endEditing(){this._currentEditing$.next(null)}},l.SheetsHyperLinkPopupService=yn([je(0,y.Inject(v.HyperLinkModel)),je(1,y.Inject(f.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Ln=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&_n(e,t,r),r},q=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,t,n,r,o){super(),this._sheetInterceptorService=e,this._injector=t,this._hyperLinkModel=n,this._selectionManagerService=r,this._univerInstanceService=o,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===v.AddHyperLinkCommand.id){const n=e.params,{unitId:r,subUnitId:o,link:s}=n,c=this._getCurrentCell(r,o,s.row,s.column),d={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(t=c==null?void 0:c.t)!=null?t:void 0}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:d}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===v.UpdateHyperLinkCommand.id){const t=e.params,{unitId:n,subUnitId:r,id:o,payload:s}=t,c=this._hyperLinkModel.getHyperLink(n,r,o);if(c&&c.display!==s.display){const d={unitId:n,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:d}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.SetRangeValuesCommand.id){const t=e.params,{unitId:n,subUnitId:r}=t,o=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((c,d,h)=>{var R,L,k;const g=(k=h==null?void 0:h.v)!=null?k:(L=(R=h==null?void 0:h.p)==null?void 0:R.body)==null?void 0:L.dataStream.slice(0,-2),_=(g!=null?g:"").toString(),p=this._hyperLinkModel.getHyperLinkByLocation(n,r,c,d);if(!p){if(J(_)){const P=a.Tools.generateRandomId();s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:P}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:{id:P,row:c,column:d,display:_,payload:Se(_)}}})}return}g===""&&(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:p.id}}),s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:p}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.ClearSelectionContentCommand.id||e.id===u.ClearSelectionAllCommand.id||e.id===u.ClearSelectionFormatCommand.id){const t=[],n=[],r=this._selectionManagerService.getFirst(),o=u.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(d,h)=>{const g=this._hyperLinkModel.getHyperLinkByLocation(s,c,d,h);g&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:g.id}}),n.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:g}}))})}return{redos:t,undos:n}}return{redos:[],undos:[]}}}))}_getCurrentCell(e,t,n,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(t))==null?void 0:s.getCell(n,r)}},l.SheetHyperLinkSetRangeController=Ln([a.OnLifecycle(a.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),q(0,y.Inject(u.SheetInterceptorService)),q(1,y.Inject(y.Injector)),q(2,y.Inject(v.HyperLinkModel)),q(3,y.Inject(u.SelectionManagerService)),q(4,a.IUniverInstanceService)],l.SheetHyperLinkSetRangeController);var kn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var r=n>1?void 0:n?In(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kn(e,t,r),r},ee=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkPopupController=class extends a.Disposable{constructor(e,t,n,r,o){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionInterceptorBaseController=o,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(me.debounceTime(100)).subscribe(e=>{var p,R;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const t=(R=(p=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:p.with(f.SheetSkeletonManagerService).getUnitSkeleton(e.location.unitId,e.location.subUnitId))==null?void 0:R.skeleton,n=e.location.col,r=e.location.row;let o=r,s=n;if(t&&t.overflowCache.forValue((L,k,P)=>{a.Rectangle.contains(P,{startColumn:n,endColumn:n,startRow:r,endRow:r})&&(o=L,s=k)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookViewPermission],worksheetTypes:[u.WorksheetViewPermission],rangeTypes:[u.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const d=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}]),h=e.location.unitId,g=e.location.subUnitId,_=this._permissionService.composePermission([new u.WorkbookCopyPermission(h).id,new u.WorksheetCopyPermission(h,g).id]).every(L=>L.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:d,copyPermission:_})}))}},l.SheetsHyperLinkPopupController=Rn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),ee(0,y.Inject(f.HoverManagerService)),ee(1,y.Inject(l.SheetsHyperLinkPopupService)),ee(2,y.Inject(he.IRenderManagerService)),ee(3,y.Inject(a.IPermissionService)),ee(4,y.Inject(f.SheetPermissionInterceptorBaseController))],l.SheetsHyperLinkPopupController);const Pn=i=>({id:le.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),bn=i=>({tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,id:ye.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),fe={id:ye.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var En=Object.defineProperty,On=Object.getOwnPropertyDescriptor,wn=(i,e,t,n)=>{for(var r=n>1?void 0:n?On(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&En(e,t,r),r},K=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkUIController=class extends a.Disposable{constructor(e,t,n,r,o,s,c){super(),this._config=e,this._componentManager=t,this._commandService=n,this._localeService=r,this._menuService=o,this._injector=s,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[ce,ce.componentKey],[se,se.componentKey],[oe,"LinkSingle"]].forEach(([e,t])=>{this._componentManager.register(t,e)})}_initCommands(){[ae,Q,le,ye].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,t,n,r;this._menuService.addMenuItem(Pn(this._injector),(t=(e=this._config)==null?void 0:e.menu)!=null?t:{}),this._menuService.addMenuItem(bn(this._injector),(r=(n=this._config)==null?void 0:n.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(fe)}},l.SheetsHyperLinkUIController=wn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkUIController),K(1,y.Inject(O.ComponentManager)),K(2,a.ICommandService),K(3,y.Inject(a.LocaleService)),K(4,O.IMenuService),K(5,y.Inject(y.Injector)),K(6,y.Inject(O.IShortcutService))],l.SheetsHyperLinkUIController);const _e="SHEET_HYPER_LINK_UI_PLUGIN";var Mn=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,jn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Mn(e,t,r),r},Te=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:s,target:c,unitId:d,subUnitId:h}=r,g=f.virtualizeDiscreteRanges([s,c]),[_,p]=g.ranges,{mapFunc:R}=g,L={row:_.startRow,col:_.startColumn},k=f.getAutoFillRepeatRange(_,p),P=[],N=[];return k.forEach(w=>{const x=w.repeatStartCell,Z=w.relativeRange,H={startRow:L.row,startColumn:L.col,endColumn:L.col,endRow:L.row},G={startRow:x.row,startColumn:x.col,endColumn:x.col,endRow:x.row};a.Range.foreach(Z,(B,F)=>{const ne=a.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},H),{row:Le,col:ke}=R(ne.startRow,ne.startColumn),te=this._hyperLinkModel.getHyperLinkByLocation(d,h,Le,ke);if(te){const S=a.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},G),{row:b,col:M}=R(S.startRow,S.startColumn),E=a.Tools.generateRandomId(),j=this._hyperLinkModel.getHyperLinkByLocation(d,h,b,M);j&&P.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:h,id:j.id}}),(f.APPLY_TYPE.COPY===o||f.APPLY_TYPE.SERIES===o)&&(P.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:h,link:{...te,id:E,row:b,column:M}}}),N.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:h,id:E}})),j&&N.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:h,link:j}})}})}),{undos:N,redos:P}},n={id:_e,onFillData:(r,o,s)=>s===f.APPLY_TYPE.COPY||s===f.APPLY_TYPE.ONLY_FORMAT||s===f.APPLY_TYPE.SERIES?t(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(n))}},l.SheetsHyperLinkAutoFillController=jn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),Te(0,f.IAutoFillService),Te(1,y.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);var Tn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Nn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Un(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Tn(e,t,r),r},de=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkCopyPasteController=class extends a.Disposable{constructor(t,n,r,o){super();Y(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=n,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_e,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,o)=>{const{copyType:s=f.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:h,unitId:g,subUnitId:_}=n;return this._generateMutations(h,{copyType:s,pasteType:c,copyRange:d,unitId:g,subUnitId:_})},onPastePlainText:(t,n)=>{if(J(n)){const r=Se(n),{range:o,unitId:s,subUnitId:c}=t,{ranges:[d],mapFunc:h}=f.virtualizeDiscreteRanges([o]),g=[],_=[];return a.Range.foreach(d,(p,R)=>{const{row:L,col:k}=h(p,R),P=this._hyperLinkModel.getHyperLinkByLocation(s,c,L,k);P&&g.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:P.id}});const N=a.Tools.generateRandomId();g.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:N,row:L,column:k,payload:r}}}),_.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:N}}),P&&_.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:P}})}),{redos:g,undos:_}}return{undos:[],redos:[]}}})}_collect(t,n,r){const o=new a.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:o};const s={get:this._injector.get.bind(this._injector)},c=f.rangeToDiscreteRange(r,s,t,n);if(!c)return;const{rows:d,cols:h}=c;d.forEach((g,_)=>{h.forEach((p,R)=>{var k;const L=this._hyperLinkModel.getHyperLinkByLocation(t,n,g,p);o.setValue(_,R,(k=L==null?void 0:L.id)!=null?k:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===f.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,s=[],c=[],{ranges:[d,h],mapFunc:g}=f.virtualizeDiscreteRanges([n.copyRange,t]);return f.getRepeatRange(d,h,!0).forEach(({startRange:p})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((L,k,P)=>{const N=a.Rectangle.getPositionRange({startRow:L,endRow:L,startColumn:k,endColumn:k},p),w=this._hyperLinkModel.getHyperLink(r,o,P),{row:x,col:Z}=g(N.startRow,N.startColumn),H=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,x,Z),G=a.Tools.generateRandomId();H&&s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:H.id}}),w&&(s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...w,id:G,row:x,column:Z}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:G}})),H&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:H}})})}),{redos:s,undos:c}}},l.SheetsHyperLinkCopyPasteController=Nn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),de(0,f.ISheetClipboardService),de(1,y.Inject(v.HyperLinkModel)),de(2,y.Inject(y.Injector)),de(3,y.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var Dn=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(i,e,t,n)=>{for(var r=n>1?void 0:n?An(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Dn(e,t,r),r},xn=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}},l.SheetHyperLinkUrlController=Vn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),xn(0,y.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var Wn=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,Fn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Bn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Wn(e,t,r),r},Ce=(i,e)=>(t,n)=>e(t,n,i);let ue=class extends a.Disposable{constructor(i,e,t){super(),this._localeService=i,this._commandService=e,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===fe.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],rangeTypes:[u.RangeProtectionPermissionEditPoint],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};ue=Fn([a.OnLifecycle(a.LifecycleStages.Rendered,ue),Ce(0,y.Inject(a.LocaleService)),Ce(1,a.ICommandService),Ce(2,y.Inject(f.SheetPermissionInterceptorBaseController))],ue);var Ue=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Yn=(i,e,t)=>e in i?Ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,zn=(i,e,t,n)=>{for(var r=n>1?void 0:n?$n(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ue(e,t,r),r},Ne=(i,e)=>(t,n)=>e(t,n,i),De=(i,e,t)=>Yn(i,typeof e!="symbol"?e+"":e,t);l.UniverSheetsHyperLinkUIPlugin=class extends a.Plugin{constructor(e,t,n){super(),this._config=e,this._injector=t,this._renderManagerService=n}onStarting(e){[[l.SheetsHyperLinkResolverService],[l.SheetsHyperLinkPopupService],[l.SheetsHyperLinkRemoveSheetController],[l.SheetsHyperLinkRenderManagerController],[l.SheetHyperLinkSetRangeController],[l.SheetsHyperLinkPopupController],[l.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(l.SheetsHyperLinkUIController,this._config)}],[l.SheetsHyperLinkAutoFillController],[l.SheetsHyperLinkCopyPasteController],[ue],[l.SheetHyperLinkUrlController]].forEach(n=>e.add(n)),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,l.SheetsHyperLinkRenderController)}},De(l.UniverSheetsHyperLinkUIPlugin,"pluginName",_e),De(l.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),l.UniverSheetsHyperLinkUIPlugin=zn([a.DependentOn(v.UniverSheetsHyperLinkPlugin),Ne(1,y.Inject(y.Injector)),Ne(2,he.IRenderManagerService)],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=Q,l.InsertHyperLinkOperation=le,l.InsertLinkShortcut=fe,l.OpenHyperLinkSidebarOperation=ae,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var $e=C,Ye=Symbol.for("react.element"),ze=Symbol.for("react.fragment"),Ke=Object.prototype.hasOwnProperty,Ze=$e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0};function Ee(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)Ke.call(e,n)&&!Ge.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Ye,type:i,key:o,ref:s,props:r,_owner:Ze.current}}re.Fragment=ze,re.jsx=Ee,re.jsxs=Ee,be.exports=re;var m=be.exports,U=function(){return U=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},U.apply(this,arguments)},Xe=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},$=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=Xe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=C.useRef("_".concat(qe()));return Oe(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},U({ref:e,className:c},s),o)});function Oe(i,e,t,n,r){return C.createElement(i.tag,U(U({key:e},Je(i,t,r)),n),(Qe(i,t).children||[]).map(function(o,s){return Oe(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function Je(i,e,t){var n=U({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Qe(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?U(U({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?U(U({},r),{attrs:U(U({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function qe(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"all-border-single",ref:e,icon:en}))});ie.displayName="AllBorderSingle";var nn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},we=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"copy-single",ref:e,icon:nn}))});we.displayName="CopySingle";var tn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},oe=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"link-single",ref:e,icon:tn}))});oe.displayName="LinkSingle";var rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Me=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"unlink-single",ref:e,icon:rn}))});Me.displayName="UnlinkSingle";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},He=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"write-single",ref:e,icon:on}))});He.displayName="WriteSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Se=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"xlsx",ref:e,icon:sn}))});Se.displayName="Xlsx";var an=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,cn=(i,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&an(e,t,r),r},X=(i,e)=>(t,n)=>e(t,n,i);function dn(i,e){const t=e.getMergeData(),n=e.getMaxColumns()-1,r=e.getMaxRows()-1;if(n<i.endColumn&&(i.endColumn=n),r<i.endRow&&(i.endRow=r),i.rangeType===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return t.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}l.SheetsHyperLinkResolverService=class{constructor(e,t,n,r,o){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=o}_getURLName(e){var d;const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=s==null?void 0:s.getName())!=null?d:"";if(n){const h=A.deserializeRangeWithSheet(n).range;return a.isValidRange(h)&&n!==v.ERROR_RANGE?{type:"range",name:A.serializeRangeWithSheet(c,h)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const h=this._definedNamesService.getValueById(o.getUnitId(),r);return h?{type:"defineName",name:h.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const h=o.getSheetBySheetId(t);return h?{type:"sheet",name:h.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!t){if(n){const c=A.deserializeRangeWithSheet(n);a.isValidRange(c.range)&&n!==v.ERROR_RANGE&&this.navigateToRange(s,t,c.range);return}this.navigateToSheetById(s,t)}}parseHyperLink(e){var t,n,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),s={gid:(t=o.get("gid"))!=null?t:"",range:(n=o.get("range"))!=null?n:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(s);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:s,handler:()=>{this.navigateTo(s)}}}else return{type:"outer",name:e,url:e,handler:()=>{this.navigateToOtherWebsite(e)}}}async navigateToRange(e,t,n){const r=await this.navigateToSheetById(e,t);if(r){const o=dn(n,r);await this._commandService.executeCommand(p.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:o}]}),await this._commandService.executeCommand(f.ScrollToRangeOperation.id,{range:o})}}async navigateToSheet(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if((r==null?void 0:r.getName())===t)return!0;const o=n.getSheetBySheetName(t);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error});return}const s=o.getSheetId();return n.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const o=n.getSheetBySheetId(t);return o?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){window.open(e,"_blank","noopener noreferrer")}},l.SheetsHyperLinkResolverService=cn([X(0,a.IUniverInstanceService),X(1,a.ICommandService),X(2,A.IDefinedNamesService),X(3,O.IMessageService),X(4,g.Inject(a.LocaleService))],l.SheetsHyperLinkResolverService);function J(i){return a.Tools.isLegalUrl(i)}function un(i){return/^[a-zA-Z]+:\/\//.test(i)}function pn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function ge(i){if(J(i)){const e=un(i)?i:pn(i)?`mailto://${i}`:`http://${i}`,t=new URL(e);return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:e}return i}function hn(i){if(i===null)return"";if(i!=null&&i.p){const e=i==null?void 0:i.p.body;if(e==null)return"";const t=e.dataStream;return t.substring(t.length-2,t.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?t.substring(0,t.length-2):t}return i==null?void 0:i.v}const mn={cellLinkEditButtons:"univer-cell-link-edit-buttons"},se=()=>{var te;const[i,e]=C.useState(""),[t,n]=C.useState(""),[r,o]=C.useState("link"),[s,c]=C.useState(""),d=T.useDependency(a.LocaleService),h=T.useDependency(A.IDefinedNamesService),y=T.useDependency(a.IUniverInstanceService),L=T.useDependency(l.SheetsHyperLinkPopupService),u=O.useObservable(L.currentEditing$),R=T.useDependency(v.HyperLinkModel),_=T.useDependency(l.SheetsHyperLinkResolverService),k=T.useDependency(a.ICommandService),[P,N]=C.useState(!1),w=C.useRef(!1);C.useEffect(()=>{var S,b,M;if((u==null?void 0:u.row)!==void 0&&u.column!==void 0){const E=R.getHyperLinkByLocationSync(u.unitId,u.subUnitId,u.row,u.column);if(E){const pe=_.parseHyperLink(E.payload);if(e(E.id),n(E.display),pe.type==="outer"){o("link"),c(pe.url),pe.url===E.display&&(w.current=!0);return}else{const W=pe.searchObj;if(W.rangeid){o("rangeid"),c(W.rangeid);return}if(W.range){const Zn=W.gid&&(M=(b=(S=y.getUnit(u.unitId))==null?void 0:S.getSheetBySheetId(W.gid))==null?void 0:b.getName())!=null?M:"";if(o("range"),W.range===v.ERROR_RANGE)c("");else{const Ae=A.serializeRangeWithSheet(Zn,A.deserializeRangeWithSheet(W.range).range);c(Ae),Ae===E.display&&(w.current=!0)}return}if(W.gid){o("gid"),c(W.gid);return}}}const j=y.getUnit(u.unitId),D=j==null?void 0:j.getSheetBySheetId(u.subUnitId),Kn=D==null?void 0:D.getCellRaw(u.row,u.column),Ie=hn(Kn);o("link"),c(""),n((Ie!=null?Ie:"").toString()),e("");return}o("link"),c(""),n(""),e("")},[u,R,_,y]);const x=C.useMemo(()=>s,[r]),Z=[{label:d.t("hyperLink.form.link"),value:"link"},{label:d.t("hyperLink.form.range"),value:"range"},{label:d.t("hyperLink.form.worksheet"),value:"gid"},{label:d.t("hyperLink.form.definedName"),value:"rangeid"}],H=y.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!H)return;const G=H.getHiddenWorksheets(),B=H.getSheets().map(S=>({label:S.getName(),value:S.getSheetId()})).filter(S=>G.indexOf(S.value)===-1),F=Object.values((te=h.getDefinedNameMap(H.getUnitId()))!=null?te:{}).map(S=>({label:S.name,value:S.id})),ne=(S,b)=>{if(S==="link")return ge(b);if(S==="range"){const M=A.deserializeRangeWithSheet(b),E=H.getSheetBySheetName(M.sheetName);if(E)return`#gid=${E.getSheetId()}&range=${A.serializeRange(M.range)}`}return`#${S}=${b}`},Le=O.useEvent(S=>{var E;const b=S[0];if(!b||!a.isValidRange(b.range))return;b.sheetName||(b.sheetName=((E=H.getActiveSheet())==null?void 0:E.getName())||"");const M=A.serializeRangeToRefString(b);c(M),M&&(w.current||!t)&&(n(M),w.current=!0)}),ke=async()=>{if(u&&(i?await k.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,id:i,payload:{display:t,payload:ne(r,s)}}):await k.executeCommand(v.AddHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,link:{id:a.Tools.generateRandomId(),row:u.row,column:u.column,payload:ne(r,s),display:t}})),u){await k.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId});const S=1;await k.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-S,0),endRow:u.row+S,startColumn:Math.max(u.column-S,0),endColumn:u.column+S}})}k.executeCommand(Q.id)};return m.jsxs("div",{children:[m.jsx(I.FormLayout,{label:d.t("hyperLink.form.label"),error:P&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:t,onChange:S=>{n(S),w.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(I.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(I.Select,{options:Z,value:r,onChange:S=>{o(S),c("")}})}),r==="link"&&m.jsx(I.FormLayout,{error:P?s?J(s)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:s,onChange:S=>{c(S),S&&(w.current||!t||t===s)&&(n(S),w.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(I.FormLayout,{error:P&&!s?d.t("hyperLink.form.inputError"):"",children:m.jsx(O.RangeSelector,{openForSheetUnitId:H.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:x,onChange:Le})}),r==="gid"&&m.jsx(I.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:B,value:s,onChange:S=>{var E,j;c(S);const b=(E=B.find(D=>D.value===S))==null?void 0:E.label,M=(j=B.find(D=>D.value===s))==null?void 0:j.label;b&&(w.current||!t||t===M)&&(n(b),w.current=!0)}})}),r==="rangeid"&&m.jsx(I.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:F,value:s,onChange:S=>{var E,j;c(S);const b=(E=F.find(D=>D.value===S))==null?void 0:E.label,M=(j=F.find(D=>D.value===s))==null?void 0:j.label;b&&(w.current||!t||t===M)&&(n(b),w.current=!0)}})}),m.jsxs("div",{className:mn.cellLinkEditButtons,children:[m.jsx(I.Button,{onClick:()=>{u&&k.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId}),k.executeCommand(Q.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!s||r==="link"&&!J(s)){N(!0);return}ke()},children:d.t("hyperLink.form.ok")})]})]})};se.componentKey="univer.sheet.cell-link-edit";const ae={type:a.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,e){if(!e)return!1;const{unitId:t,subUnitId:n,row:r,column:o}=e,s=i.get(v.HyperLinkModel),c=i.get(O.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),h=s.getHyperLinkByLocation(t,n,r,o);return d.startEditing(e),c.open({header:{title:h?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:se.componentKey}}),!0}},Q={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(O.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return e.close(),t.endEditing(),!0}},le={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(a.ICommandService),o=i.get(p.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const s=o.primary.startRow,c=o.primary.startColumn;return n.executeCommand(ae.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:s,column:c})}},ye={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(a.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(Q.id):e.executeCommand(le.id)}},V={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},vn={outer:m.jsx(oe,{}),link:m.jsx(oe,{}),sheet:m.jsx(Se,{}),range:m.jsx(ie,{}),defineName:m.jsx(ie,{}),"range-error":m.jsx(ie,{}),"sheet-error":m.jsx(Se,{})},ce=()=>{const i=T.useDependency(l.SheetsHyperLinkPopupService),e=T.useDependency(v.HyperLinkModel),t=T.useDependency(a.ICommandService),n=T.useDependency(O.IMessageService),r=T.useDependency(a.LocaleService),[o,s]=C.useState(null),c=T.useDependency(l.SheetsHyperLinkResolverService);if(C.useEffect(()=>{s(i.currentPopup);const _=i.currentPopup$.subscribe(k=>{s(k)});return()=>{_.unsubscribe()}},[i.currentPopup,i.currentPopup$]),!o)return null;const{unitId:d,subUnitId:h,id:y}=o,L=e.getHyperLink(d,h,y);if(!L)return null;const u=c.parseHyperLink(L.payload),R=u.type.indexOf("error")>-1;return m.jsxs("div",{className:V.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:Re(V.cellLinkContent,{[V.cellLinkContentError]:R}),onClick:u.handler,children:[m.jsx("div",{className:V.cellLinkType,children:vn[u.type]}),m.jsx(I.Tooltip,{showIfEllipsis:!0,title:u.name,children:m.jsx("span",{className:V.cellLinkUrl,children:u.name})})]}),m.jsxs("div",{className:V.cellLinkOperations,children:[o.copyPermission&&m.jsx("div",{className:Re(V.cellLinkOperation,{[V.cellLinkOperationError]:R}),onClick:()=>{if(!R){if(u.type!=="outer"){const _=new URL(window.location.href);_.hash=u.url.slice(1),navigator.clipboard.writeText(_.href)}else navigator.clipboard.writeText(u.url);n.show({content:r.t("hyperLink.message.coped"),type:I.MessageType.Info})}},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(we,{})})}),o.editPermission&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(ae.id,{unitId:d,subUnitId:h,row:L.row,column:L.column})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(He,{})})}),m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:d,subUnitId:h,id:L.id})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(Me,{})})})]})]})]})};ce.componentKey="univer.sheet.cell-link-popup";var Sn=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,yn=(i,e,t,n)=>{for(var r=n>1?void 0:n?gn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Sn(e,t,r),r},je=(i,e)=>(t,n)=>e(t,n,i);const fn=(i,e)=>i.unitId===e.unitId&&i.subUnitId===e.subUnitId&&i.row===e.row&&i.col===e.col;l.SheetsHyperLinkPopupService=class extends a.Disposable{constructor(t,n){super();Y(this,"_currentPopup",null);Y(this,"_currentPopup$",new me.Subject);Y(this,"currentPopup$",this._currentPopup$.asObservable());Y(this,"_currentEditing$",new me.BehaviorSubject(null));Y(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=t,this._sheetCanvasPopManagerService=n,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(t){if(this._currentPopup&&fn(t,this._currentPopup))return;this.hideCurrentPopup();const{unitId:n,subUnitId:r,row:o,col:s}=t,c=this._hyperLinkModel.getHyperLinkByLocation(n,r,o,s);if(!c)return;const d=this._sheetCanvasPopManagerService.attachPopupToCell(o,s,{componentKey:ce.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideCurrentPopup()}});d&&(this._currentPopup={unitId:n,subUnitId:r,id:c.id,disposable:d,row:o,col:s,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var t;this._currentPopup&&((t=this._currentPopup.disposable)==null||t.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(t){this._currentEditing$.next(t)}endEditing(){this._currentEditing$.next(null)}},l.SheetsHyperLinkPopupService=yn([je(0,g.Inject(v.HyperLinkModel)),je(1,g.Inject(f.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Ln=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&_n(e,t,r),r},q=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,t,n,r,o){super(),this._sheetInterceptorService=e,this._injector=t,this._hyperLinkModel=n,this._selectionManagerService=r,this._univerInstanceService=o,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===v.AddHyperLinkCommand.id){const n=e.params,{unitId:r,subUnitId:o,link:s}=n,c=this._getCurrentCell(r,o,s.row,s.column),d={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(t=c==null?void 0:c.t)!=null?t:void 0}}}};return{redos:[{id:p.SetRangeValuesMutation.id,params:d}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===v.UpdateHyperLinkCommand.id){const t=e.params,{unitId:n,subUnitId:r,id:o,payload:s}=t,c=this._hyperLinkModel.getHyperLink(n,r,o);if(c&&c.display!==s.display){const d={unitId:n,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:p.SetRangeValuesMutation.id,params:d}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===p.SetRangeValuesCommand.id){const t=e.params,{unitId:n,subUnitId:r}=t,o=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((c,d,h)=>{var R,_,k;const y=(k=h==null?void 0:h.v)!=null?k:(_=(R=h==null?void 0:h.p)==null?void 0:R.body)==null?void 0:_.dataStream.slice(0,-2),L=(y!=null?y:"").toString(),u=this._hyperLinkModel.getHyperLinkByLocation(n,r,c,d);if(!u){if(J(L)){const P=a.Tools.generateRandomId();s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:P}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:{id:P,row:c,column:d,display:L,payload:ge(L)}}})}return}y===""&&(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:u.id}}),s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:u}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===p.ClearSelectionContentCommand.id||e.id===p.ClearSelectionAllCommand.id||e.id===p.ClearSelectionFormatCommand.id){const t=[],n=[],r=this._selectionManagerService.getCurrentLastSelection(),o=p.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(d,h)=>{const y=this._hyperLinkModel.getHyperLinkByLocation(s,c,d,h);y&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:y.id}}),n.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:y}}))})}return{redos:t,undos:n}}return{redos:[],undos:[]}}}))}_getCurrentCell(e,t,n,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(t))==null?void 0:s.getCell(n,r)}},l.SheetHyperLinkSetRangeController=Ln([a.OnLifecycle(a.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),q(0,g.Inject(p.SheetInterceptorService)),q(1,g.Inject(g.Injector)),q(2,g.Inject(v.HyperLinkModel)),q(3,g.Inject(p.SheetsSelectionsService)),q(4,a.IUniverInstanceService)],l.SheetHyperLinkSetRangeController);var kn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var r=n>1?void 0:n?In(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kn(e,t,r),r},ee=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkPopupController=class extends a.Disposable{constructor(e,t,n,r,o){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionInterceptorBaseController=o,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(me.debounceTime(100)).subscribe(e=>{var u,R;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const t=(R=(u=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:u.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(e.location.subUnitId))==null?void 0:R.skeleton,n=e.location.col,r=e.location.row;let o=r,s=n;if(t&&t.overflowCache.forValue((_,k,P)=>{a.Rectangle.contains(P,{startColumn:n,endColumn:n,startRow:r,endRow:r})&&(o=_,s=k)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookViewPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const d=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}]),h=e.location.unitId,y=e.location.subUnitId,L=this._permissionService.composePermission([new p.WorkbookCopyPermission(h).id,new p.WorksheetCopyPermission(h,y).id]).every(_=>_.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:d,copyPermission:L})}))}},l.SheetsHyperLinkPopupController=Rn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),ee(0,g.Inject(f.HoverManagerService)),ee(1,g.Inject(l.SheetsHyperLinkPopupService)),ee(2,g.Inject(he.IRenderManagerService)),ee(3,g.Inject(a.IPermissionService)),ee(4,g.Inject(f.SheetPermissionInterceptorBaseController))],l.SheetsHyperLinkPopupController);const Pn=i=>({id:le.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),bn=i=>({tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,id:ye.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),fe={id:ye.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var En=Object.defineProperty,On=Object.getOwnPropertyDescriptor,wn=(i,e,t,n)=>{for(var r=n>1?void 0:n?On(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&En(e,t,r),r},K=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkUIController=class extends a.Disposable{constructor(e,t,n,r,o,s,c){super(),this._config=e,this._componentManager=t,this._commandService=n,this._localeService=r,this._menuService=o,this._injector=s,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[ce,ce.componentKey],[se,se.componentKey],[oe,"LinkSingle"]].forEach(([e,t])=>{this._componentManager.register(t,e)})}_initCommands(){[ae,Q,le,ye].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,t,n,r;this._menuService.addMenuItem(Pn(this._injector),(t=(e=this._config)==null?void 0:e.menu)!=null?t:{}),this._menuService.addMenuItem(bn(this._injector),(r=(n=this._config)==null?void 0:n.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(fe)}},l.SheetsHyperLinkUIController=wn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkUIController),K(1,g.Inject(O.ComponentManager)),K(2,a.ICommandService),K(3,g.Inject(a.LocaleService)),K(4,O.IMenuService),K(5,g.Inject(g.Injector)),K(6,g.Inject(O.IShortcutService))],l.SheetsHyperLinkUIController);const _e="SHEET_HYPER_LINK_UI_PLUGIN";var Mn=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,jn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Mn(e,t,r),r},Te=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:s,target:c,unitId:d,subUnitId:h}=r,y=f.virtualizeDiscreteRanges([s,c]),[L,u]=y.ranges,{mapFunc:R}=y,_={row:L.startRow,col:L.startColumn},k=f.getAutoFillRepeatRange(L,u),P=[],N=[];return k.forEach(w=>{const x=w.repeatStartCell,Z=w.relativeRange,H={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row},G={startRow:x.row,startColumn:x.col,endColumn:x.col,endRow:x.row};a.Range.foreach(Z,(B,F)=>{const ne=a.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},H),{row:Le,col:ke}=R(ne.startRow,ne.startColumn),te=this._hyperLinkModel.getHyperLinkByLocation(d,h,Le,ke);if(te){const S=a.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},G),{row:b,col:M}=R(S.startRow,S.startColumn),E=a.Tools.generateRandomId(),j=this._hyperLinkModel.getHyperLinkByLocation(d,h,b,M);j&&P.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:h,id:j.id}}),(f.APPLY_TYPE.COPY===o||f.APPLY_TYPE.SERIES===o)&&(P.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:h,link:{...te,id:E,row:b,column:M}}}),N.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:h,id:E}})),j&&N.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:h,link:j}})}})}),{undos:N,redos:P}},n={id:_e,onFillData:(r,o,s)=>s===f.APPLY_TYPE.COPY||s===f.APPLY_TYPE.ONLY_FORMAT||s===f.APPLY_TYPE.SERIES?t(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(n))}},l.SheetsHyperLinkAutoFillController=jn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),Te(0,f.IAutoFillService),Te(1,g.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);var Tn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Nn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Un(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Tn(e,t,r),r},de=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkCopyPasteController=class extends a.Disposable{constructor(t,n,r,o){super();Y(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=n,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_e,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,o)=>{const{copyType:s=f.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:h,unitId:y,subUnitId:L}=n;return this._generateMutations(h,{copyType:s,pasteType:c,copyRange:d,unitId:y,subUnitId:L})},onPastePlainText:(t,n)=>{if(J(n)){const r=ge(n),{range:o,unitId:s,subUnitId:c}=t,{ranges:[d],mapFunc:h}=f.virtualizeDiscreteRanges([o]),y=[],L=[];return a.Range.foreach(d,(u,R)=>{const{row:_,col:k}=h(u,R),P=this._hyperLinkModel.getHyperLinkByLocation(s,c,_,k);P&&y.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:P.id}});const N=a.Tools.generateRandomId();y.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:N,row:_,column:k,payload:r}}}),L.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:N}}),P&&L.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:P}})}),{redos:y,undos:L}}return{undos:[],redos:[]}}})}_collect(t,n,r){const o=new a.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:o};const s={get:this._injector.get.bind(this._injector)},c=f.rangeToDiscreteRange(r,s,t,n);if(!c)return;const{rows:d,cols:h}=c;d.forEach((y,L)=>{h.forEach((u,R)=>{var k;const _=this._hyperLinkModel.getHyperLinkByLocation(t,n,y,u);o.setValue(L,R,(k=_==null?void 0:_.id)!=null?k:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===f.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,s=[],c=[],{ranges:[d,h],mapFunc:y}=f.virtualizeDiscreteRanges([n.copyRange,t]);return f.getRepeatRange(d,h,!0).forEach(({startRange:u})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((_,k,P)=>{const N=a.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:k,endColumn:k},u),w=this._hyperLinkModel.getHyperLink(r,o,P),{row:x,col:Z}=y(N.startRow,N.startColumn),H=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,x,Z),G=a.Tools.generateRandomId();H&&s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:H.id}}),w&&(s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...w,id:G,row:x,column:Z}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:G}})),H&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:H}})})}),{redos:s,undos:c}}},l.SheetsHyperLinkCopyPasteController=Nn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),de(0,f.ISheetClipboardService),de(1,g.Inject(v.HyperLinkModel)),de(2,g.Inject(g.Injector)),de(3,g.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var Dn=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(i,e,t,n)=>{for(var r=n>1?void 0:n?An(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Dn(e,t,r),r},xn=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}},l.SheetHyperLinkUrlController=Vn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),xn(0,g.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var Wn=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,Fn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Bn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Wn(e,t,r),r},Ce=(i,e)=>(t,n)=>e(t,n,i);let ue=class extends a.Disposable{constructor(i,e,t){super(),this._localeService=i,this._commandService=e,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===fe.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookEditablePermission],rangeTypes:[p.RangeProtectionPermissionEditPoint],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};ue=Fn([a.OnLifecycle(a.LifecycleStages.Rendered,ue),Ce(0,g.Inject(a.LocaleService)),Ce(1,a.ICommandService),Ce(2,g.Inject(f.SheetPermissionInterceptorBaseController))],ue);var Ue=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Yn=(i,e,t)=>e in i?Ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,zn=(i,e,t,n)=>{for(var r=n>1?void 0:n?$n(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ue(e,t,r),r},Ne=(i,e)=>(t,n)=>e(t,n,i),De=(i,e,t)=>Yn(i,typeof e!="symbol"?e+"":e,t);l.UniverSheetsHyperLinkUIPlugin=class extends a.Plugin{constructor(e,t,n){super(),this._config=e,this._injector=t,this._renderManagerService=n}onStarting(e){[[l.SheetsHyperLinkResolverService],[l.SheetsHyperLinkPopupService],[l.SheetsHyperLinkRemoveSheetController],[l.SheetsHyperLinkRenderManagerController],[l.SheetHyperLinkSetRangeController],[l.SheetsHyperLinkPopupController],[l.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(l.SheetsHyperLinkUIController,this._config)}],[l.SheetsHyperLinkAutoFillController],[l.SheetsHyperLinkCopyPasteController],[ue],[l.SheetHyperLinkUrlController]].forEach(n=>e.add(n))}onReady(){[[l.SheetsHyperLinkRenderController]].forEach(t=>this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,t))}},De(l.UniverSheetsHyperLinkUIPlugin,"pluginName",_e),De(l.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),l.UniverSheetsHyperLinkUIPlugin=zn([a.DependentOn(v.UniverSheetsHyperLinkPlugin),Ne(1,g.Inject(g.Injector)),Ne(2,he.IRenderManagerService)],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=Q,l.InsertHyperLinkOperation=le,l.InsertLinkShortcut=fe,l.OpenHyperLinkSidebarOperation=ae,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-hyper-link-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"clsx": ">=2.0.0",
|
|
55
55
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
56
56
|
"rxjs": ">=7.0.0",
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/engine-
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/sheets": "0.2.
|
|
62
|
-
"@univerjs/sheets
|
|
63
|
-
"@univerjs/sheets-
|
|
64
|
-
"@univerjs/ui": "0.2.
|
|
57
|
+
"@univerjs/design": "0.2.3",
|
|
58
|
+
"@univerjs/core": "0.2.3",
|
|
59
|
+
"@univerjs/engine-formula": "0.2.3",
|
|
60
|
+
"@univerjs/engine-render": "0.2.3",
|
|
61
|
+
"@univerjs/sheets-hyper-link": "0.2.3",
|
|
62
|
+
"@univerjs/sheets": "0.2.3",
|
|
63
|
+
"@univerjs/sheets-ui": "0.2.3",
|
|
64
|
+
"@univerjs/ui": "0.2.3"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@univerjs/icons": "^0.1.58",
|
|
68
|
-
"@univerjs/sheets-hyper-link": "0.2.
|
|
68
|
+
"@univerjs/sheets-hyper-link": "0.2.3"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@wendellhu/redi": "0.15.5",
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"typescript": "^5.5.3",
|
|
75
75
|
"vite": "^5.3.3",
|
|
76
76
|
"vitest": "^1.6.0",
|
|
77
|
-
"@univerjs/core": "0.2.
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/engine-render": "0.2.
|
|
80
|
-
"@univerjs/
|
|
81
|
-
"@univerjs/sheets": "0.2.
|
|
82
|
-
"@univerjs/sheets-ui": "0.2.
|
|
83
|
-
"@univerjs/ui": "0.2.
|
|
77
|
+
"@univerjs/core": "0.2.3",
|
|
78
|
+
"@univerjs/shared": "0.2.3",
|
|
79
|
+
"@univerjs/engine-render": "0.2.3",
|
|
80
|
+
"@univerjs/engine-formula": "0.2.3",
|
|
81
|
+
"@univerjs/sheets": "0.2.3",
|
|
82
|
+
"@univerjs/sheets-ui": "0.2.3",
|
|
83
|
+
"@univerjs/ui": "0.2.3"
|
|
84
84
|
},
|
|
85
85
|
"univerSpace": {
|
|
86
86
|
".": {
|