@univerjs/sheets-hyper-link-ui 0.5.0-alpha.0 → 0.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +586 -581
- package/lib/types/controllers/menu.d.ts +1 -5
- package/lib/types/services/popup.service.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +16 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IAccessor } from '@univerjs/core';
|
|
2
|
-
import { IMenuItem, IShortcutItem,
|
|
2
|
+
import { IMenuItem, IShortcutItem, MenuItemType } from '@univerjs/ui';
|
|
3
3
|
export declare const genZenEditorMenuId: (id: string) => string;
|
|
4
4
|
export declare const insertLinkMenuFactory: (accessor: IAccessor) => IMenuItem;
|
|
5
5
|
export declare const zenEditorInsertLinkMenuFactory: (accessor: IAccessor) => IMenuItem;
|
|
@@ -8,8 +8,6 @@ export declare const insertLinkMenuToolbarFactory: (accessor: IAccessor) => {
|
|
|
8
8
|
hidden$: import('rxjs').Observable<boolean>;
|
|
9
9
|
disabled$: import('rxjs').Observable<boolean>;
|
|
10
10
|
tooltip: string;
|
|
11
|
-
positions: MenuPosition;
|
|
12
|
-
group: MenuGroup;
|
|
13
11
|
commandId: string;
|
|
14
12
|
type: MenuItemType;
|
|
15
13
|
icon: string;
|
|
@@ -19,8 +17,6 @@ export declare const zenEditorInsertLinkMenuToolbarFactory: (accessor: IAccessor
|
|
|
19
17
|
hidden$: import('rxjs').Observable<boolean>;
|
|
20
18
|
disabled$: import('rxjs').Observable<boolean>;
|
|
21
19
|
tooltip: string;
|
|
22
|
-
positions: MenuPosition;
|
|
23
|
-
group: MenuGroup;
|
|
24
20
|
commandId: string;
|
|
25
21
|
type: MenuItemType;
|
|
26
22
|
icon: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ICustomRange, INeedCheckDisposable, Nullable, Disposable, Injector, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
-
import { IBoundRectNoAngle } from '@univerjs/engine-render';
|
|
3
2
|
import { ISheetLocationBase } from '@univerjs/sheets';
|
|
4
3
|
import { DocSelectionManagerService } from '@univerjs/docs';
|
|
5
4
|
import { DocCanvasPopManagerService } from '@univerjs/docs-ui';
|
|
5
|
+
import { IBoundRectNoAngle } from '@univerjs/engine-render';
|
|
6
6
|
import { IEditorBridgeService, SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
|
|
7
7
|
import { IZenZoneService } from '@univerjs/ui';
|
|
8
8
|
import { HyperLinkEditSourceType } from '../types/enums/edit-source';
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={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 zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==v.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(v.SheetHyperLinkType.URL),[d,h]=C.useState(""),_=s.useDependency(s.LocaleService),S=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),T=s.useDependency(s.IUniverInstanceService),k=s.useDependency(g.SheetsHyperLinkPopupService),c=O.useObservable(k.currentEditing$),b=s.useDependency(v.SheetsHyperLinkParserService),j=s.useDependency(g.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(O.IZenZoneService),oe=s.useDependency(ye.IRenderManagerService),ge=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(pe.DocSelectionManagerService),ae=s.useDependency(s.IContextService),Se=s.useDependency(s.ThemeService),me=s.useDependency(pe.DocSelectionManagerService),_e=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[fe,ze]=C.useState(!1),A=C.useRef(!1),$=T.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",q=C.useCallback(m=>{a(m.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var m,D,L,N,x,z,Et,Rt,Pt,Tt,Lt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(m=le==null?void 0:le.rangeId)!=null?m:"",display:Q!=null?Q:"",payload:(L=(D=le==null?void 0:le.properties)==null?void 0:D.url)!=null?L:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=T.getUnit(c.unitId),te=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=te==null?void 0:te.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),Ie=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(Ie))&&l(!1),X={id:"",display:"",payload:(Tt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Tt:"",row:qe,column:et}}else{const H=T.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),te=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=te&&B?te:null,Ie=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Lt=B==null?void 0:B.customRanges)!=null?Lt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=Ie==null?void 0:Ie.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),q(H.display);return}q(X.display);const ee=b.parseHyperLink(X.payload);switch(p(ee.type===v.SheetHyperLinkType.INVALID?v.SheetHyperLinkType.RANGE:ee.type),ee.type){case v.SheetHyperLinkType.URL:{h(ee.url),ee.url===X.display&&(A.current=!0);break}case v.SheetHyperLinkType.RANGE:{const H=ee.searchObj,te=H.gid&&(Nt=(wt=(Dt=T.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(te,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case v.SheetHyperLinkType.SHEET:{const H=ee.searchObj;h(H.gid);break}case v.SheetHyperLinkType.DEFINE_NAME:{const H=ee.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,T]),C.useEffect(()=>{let m=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const D=T.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),L=D==null?void 0:D.getSheetBySheetId(c.subUnitId),N=L==null?void 0:L.getMergedCell(c.row,c.col),x=new s.ColorKit(Se.getCurrentTheme().hyacinth500).toRgb();m=ge.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{hasAutoFill:!1,fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{m&&ge.removeShape(m)}},[c,ge,Se,T]),C.useEffect(()=>{ze(u===v.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const m=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),D=new s.DisposableCollection;if(m){const L=m.with(ne.DocSelectionRenderService);L.setReserveRangesStatus(!0),D.add(()=>{L.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),D.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(k.setIsKeepVisible(fe),()=>{k.setIsKeepVisible(!1)}),[fe,k]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(fe)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[fe,E]);const Wn=[{label:_.t("hyperLink.form.link"),value:v.SheetHyperLinkType.URL},{label:_.t("hyperLink.form.range"),value:v.SheetHyperLinkType.RANGE},{label:_.t("hyperLink.form.worksheet"),value:v.SheetHyperLinkType.SHEET},{label:_.t("hyperLink.form.definedName"),value:v.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Gn=$.getHiddenWorksheets(),Xe=$.getSheets().map(m=>({label:m.getName(),value:m.getSheetId()})).filter(m=>Gn.indexOf(m.value)===-1),Je=Object.values((Ct=S.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(m=>({label:m.name,value:m.id})),yt=(m,D)=>{if(m===v.SheetHyperLinkType.URL)return At(D);if(m===v.SheetHyperLinkType.RANGE){const L=J.deserializeRangeWithSheet(D),N=$.getSheetBySheetName(L.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(L.range)}`}return`#${m}=${D}`},Yn=O.useEvent(m=>{var x;const L=m.split(",").map(J.deserializeRangeWithSheet)[0];if(!L||!s.isValidRange(L.range))return;L.sheetName||(L.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(L);h(N),N&&(A.current||!r)&&(q(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===v.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const m=c.type===I.ZEN_EDITOR||c.type===I.EDITING?v.UpdateRichHyperLinkCommand.id:v.UpdateHyperLinkCommand.id;await U.executeCommand(m,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const m=c.type===I.ZEN_EDITOR||c.type===I.EDITING?v.AddRichHyperLinkCommand.id:v.AddHyperLinkCommand.id;await U.executeCommand(m,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const m=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-m,0),endRow:c.row+m,startColumn:Math.max(c.col-m,0),endColumn:c.col+m}})}U.executeCommand(he.id)},$n=m=>{var L;if(u!==v.SheetHyperLinkType.RANGE)return;const D=(L=_e.current)==null?void 0:L.handleOutClick;D&&D(m,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:_.t("hyperLink.form.label"),error:K&&!r?_.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:m=>{q(m),A.current=!1},placeholder:_.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:m=>{m.keyCode===O.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:_.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:m=>{p(m),h("")}})}),u===v.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":_.t("hyperLink.form.linkError"):_.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:m=>{h(m),m&&(A.current||!r||r===d)&&(q(m),A.current=!0)},placeholder:_.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:m=>{m.keyCode===O.KeyCode.ENTER&&Qe()}})}),u===v.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?_.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Yn,isFocus:fe,onFocus:()=>ze(!0),actions:_e.current,onRangeSelectorDialogVisibleChange:async m=>{var D,L;if(m)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(D=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:D.with(ne.DocBackScrollRenderController),x=(L=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:L[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===v.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?_.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:m=>{var N,x;h(m);const D=(N=Xe.find(z=>z.value===m))==null?void 0:N.label,L=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;D&&(A.current||!r||r===L)&&(q(D),A.current=!0)}})}),u===v.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?_.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:m=>{var N,x;h(m);const D=(N=Je.find(z=>z.value===m))==null?void 0:N.label,L=(x=Je.find(z=>z.value===d))==null?void 0:x.label;D&&(A.current||!r||r===L)&&(q(D),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:m=>{q(m),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(he.id)},children:_.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:_.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={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"}}]},Te=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Te.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={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"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={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"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={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"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const G={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"},pn={[v.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[v.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[v.SheetHyperLinkType.RANGE]:f.jsx(Te,{}),[v.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Te,{}),[v.SheetHyperLinkType.INVALID]:f.jsx(Te,{})},pt=t=>{var j,U;const i=s.useDependency(g.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(O.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(g.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(v.SheetsHyperLinkParserService),u=s.useDependency(O.IZenZoneService),{customRange:p,row:d,col:h,unitId:_,subUnitId:S,editPermission:E,copyPermission:T,type:k}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),b=c.type===v.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:G.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(G.cellLinkContent,{[G.cellLinkContentError]:b}),onClick:()=>{u.visible||b||a.navigate(c)},children:[f.jsx("div",{className:G.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:G.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:G.cellLinkOperations,children:[T&&f.jsx("div",{className:dt(G.cellLinkOperation,{[G.cellLinkOperationError]:b}),onClick:()=>{if(!b){if(c.type!==v.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:G.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:_,subUnitId:S,row:d,col:h,customRangeId:p.rangeId,type:k})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:G.cellLinkOperation,onClick:()=>{const M=k===I.EDITING||k===I.ZEN_EDITOR?v.CancelRichHyperLinkCommand.id:v.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:_,subUnitId:S,id:p.rangeId,row:d,column:h,documentId:k===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Le=()=>{var r,a;const t=s.useDependency(g.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Le.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};g.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Le.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(_=>_.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(_=>{d=Math.min(d,_.startIndex),h=Math.max(h,_.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const _=this._textSelectionManagerService.getActiveTextRange();if(!_)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(_,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const S=(o=h.getBody())==null?void 0:o.dataStream.slice(_.startOffset,_.endOffset);this._currentEditing$.next({...e,label:S})}else if(a===I.EDITING){const h=this._getEditingRange();h&&this._textSelectionManagerService.replaceTextRanges([{...h}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),_=h==null?void 0:h.getSheetBySheetId(r),S=_==null?void 0:_.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:S!=null&&S.p?s.BuildTextUtils.transform.getPlainText((p=(u=S.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=S==null?void 0:S.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,_;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const S=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=S==null?void 0:S.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=S==null?void 0:S.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const S=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!S||!((h=S.rects)!=null&&h.length))return;a=S.customRange,o=S.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.rects.pop(),this._editPopup,n,r)}else{const S=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=S==null?void 0:S.getSheetBySheetId(r),T=E==null?void 0:E.getCellRaw(e.row,e.col),k=S==null?void 0:S.getStyles().getStyleByCell(T),c=k==null?void 0:k.tr,b=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!b||!((_=b.rects)!=null&&_.length))return;a=b.customRange,o=b.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(b.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(pe.DocSelectionManagerService)),re(5,s.Inject(ne.DocCanvasPopManagerService)),re(6,O.IZenZoneService)],g.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},mn=t=>{var p,d;const i=t.get(pe.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,_=l.length;h<_;h++){const S=l[h];if(r.startOffset<=S.startIndex&&r.endOffset>S.startIndex)return!0;if(S.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(g.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},he={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(g.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(he.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(ye.IRenderManagerService).getRenderById(i))==null?void 0:r.with(ne.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:mn(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,_n=t=>({...be,id:be.commandId,hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,commandId:se.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:O.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:_}=p,S={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),T=[],k=[];return E.forEach(c=>{const b=c.repeatStartCell,j=c.relativeRange,U={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},M={startRow:b.row,startColumn:b.col,endColumn:b.col,endRow:b.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:ge,col:Be}=_(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,ge,Be),Se=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:_e}=_(Se.startRow,Se.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,_e);K&&T.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(T.push({id:v.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:_e}}}),k.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&k.push({id:v.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:k,redos:T}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(v.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Ln=(t,i,e,n)=>{for(var r=n>1?void 0:n?Tn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Ln([Ge(0,s.Inject(s.LocaleService)),Ge(1,s.ICommandService),Ge(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},Y=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let _=h,S=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(_=M,S=Z)});const{viewPermission:E,editPermission:T,copyPermission:k}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(_,S),b=o.getStyles().getStyleByCell(c),j=b==null?void 0:b.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:_,col:S,editPermission:T,copyPermission:k,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),_=u.with(ne.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=_.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(S=>{var b,j;const E=S.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const T=E.rects[E.rects.length-1];if(!((j=(b=this._renderManagerService.getRenderById(r))==null?void 0:b.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!T)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:T.left+c.left,top:T.top+c.top,bottom:T.bottom+c.top,right:T.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(ne.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([Y(0,s.Inject(y.HoverManagerService)),Y(1,s.Inject(g.SheetsHyperLinkPopupService)),Y(2,s.Inject(ye.IRenderManagerService)),Y(3,s.Inject(s.IPermissionService)),Y(4,s.Inject(y.SheetPermissionInterceptorBaseController)),Y(5,s.ICommandService),Y(6,y.IEditorBridgeService),Y(7,s.Inject(pe.DocSelectionManagerService)),Y(8,s.IUniverInstanceService),Y(9,O.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ye(1,s.Inject(v.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ye(0,s.Inject(R.SheetInterceptorService)),Ye(1,s.Inject(v.HyperLinkModel))],He);const Nn={[O.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[O.ContextMenuPosition.MAIN_AREA]:{[O.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:_n},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ve=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Le,Le.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,he,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ve(0,s.Inject(O.ComponentManager)),ve(1,s.ICommandService),ve(2,O.IMenuManagerService),ve(3,s.Inject(s.Injector)),ve(4,s.Inject(O.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},mt=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([mt(0,s.Inject(v.SheetsHyperLinkParserService)),mt(1,s.Inject(g.SheetsHyperLinkResolverService))],je);var _t=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?_t(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&_t(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);g.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[g.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(ye.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(g.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(g.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(v.UniverSheetsHyperLinkPlugin,ne.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=he,g.InsertHyperLinkOperation=ke,g.InsertLinkShortcut=We,g.OpenHyperLinkEditPanelOperation=Oe,g.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={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"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={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"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={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"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={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"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={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"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,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.5.0-
|
|
3
|
+
"version": "0.5.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -61,25 +61,25 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@univerjs/icons": "^0.2.5",
|
|
63
63
|
"clsx": "^2.1.1",
|
|
64
|
-
"@univerjs/core": "0.5.0-
|
|
65
|
-
"@univerjs/docs": "0.5.0-
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/docs-hyper-link": "0.5.0-
|
|
68
|
-
"@univerjs/
|
|
69
|
-
"@univerjs/
|
|
70
|
-
"@univerjs/
|
|
71
|
-
"@univerjs/sheets-hyper-link": "0.5.0-
|
|
72
|
-
"@univerjs/sheets
|
|
73
|
-
"@univerjs/sheets-ui": "0.5.0-
|
|
74
|
-
"@univerjs/ui": "0.5.0-
|
|
64
|
+
"@univerjs/core": "0.5.0-beta.0",
|
|
65
|
+
"@univerjs/docs": "0.5.0-beta.0",
|
|
66
|
+
"@univerjs/docs-ui": "0.5.0-beta.0",
|
|
67
|
+
"@univerjs/docs-hyper-link": "0.5.0-beta.0",
|
|
68
|
+
"@univerjs/sheets-formula-ui": "0.5.0-beta.0",
|
|
69
|
+
"@univerjs/engine-formula": "0.5.0-beta.0",
|
|
70
|
+
"@univerjs/engine-render": "0.5.0-beta.0",
|
|
71
|
+
"@univerjs/sheets-hyper-link": "0.5.0-beta.0",
|
|
72
|
+
"@univerjs/sheets": "0.5.0-beta.0",
|
|
73
|
+
"@univerjs/sheets-ui": "0.5.0-beta.0",
|
|
74
|
+
"@univerjs/ui": "0.5.0-beta.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"react": "18.3.1",
|
|
78
78
|
"rxjs": "^7.8.1",
|
|
79
79
|
"typescript": "^5.6.3",
|
|
80
|
-
"vite": "^5.4.
|
|
81
|
-
"vitest": "^2.1.
|
|
82
|
-
"@univerjs-infra/shared": "0.5.0-
|
|
80
|
+
"vite": "^5.4.11",
|
|
81
|
+
"vitest": "^2.1.5",
|
|
82
|
+
"@univerjs-infra/shared": "0.5.0-beta.0"
|
|
83
83
|
},
|
|
84
84
|
"space": {
|
|
85
85
|
".": {
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"test:watch": "vitest",
|
|
110
110
|
"coverage": "vitest run --coverage",
|
|
111
111
|
"lint:types": "tsc --noEmit",
|
|
112
|
-
"build": "
|
|
112
|
+
"build": "univer-cli build"
|
|
113
113
|
},
|
|
114
114
|
"module": "./lib/es/index.js"
|
|
115
115
|
}
|