@univerjs/sheets-hyper-link-ui 0.4.2 → 0.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/facade.js +1 -0
- package/lib/es/index.js +1349 -2024
- package/lib/es/locale/en-US.js +38 -0
- package/lib/es/locale/fa-IR.js +38 -0
- package/lib/es/locale/ru-RU.js +38 -0
- package/lib/es/locale/vi-VN.js +38 -0
- package/lib/es/locale/zh-CN.js +38 -0
- package/lib/es/locale/zh-TW.js +38 -0
- package/lib/index.css +1 -1
- package/lib/types/controllers/menu.d.ts +1 -5
- package/lib/types/controllers/url.controller.d.ts +3 -1
- package/lib/types/facade/f-workbook.d.ts +13 -0
- package/lib/types/{types/interfaces/i-sheet-url-params.d.ts → facade/index.d.ts} +0 -6
- package/lib/types/index.d.ts +0 -4
- package/lib/types/services/popup.service.d.ts +6 -6
- package/lib/types/services/resolver.service.d.ts +5 -9
- package/lib/types/views/CellLinkPopup/index.d.ts +14 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +44 -25
- package/lib/locale/en-US.json +0 -35
- package/lib/locale/fa-IR.json +0 -35
- package/lib/locale/ru-RU.json +0 -35
- package/lib/locale/vi-VN.json +0 -35
- package/lib/locale/zh-CN.json +0 -35
- package/lib/locale/zh-TW.json +0 -35
- package/lib/types/commands/commands/add-hyper-link.command.d.ts +0 -19
- package/lib/types/commands/commands/remove-hyper-link.command.d.ts +0 -19
- package/lib/types/commands/commands/update-hyper-link.command.d.ts +0 -17
- package/lib/types/controllers/remove-sheet.controller.d.ts +0 -10
- package/lib/types/controllers/rich-text-ref-range.controller.d.ts +0 -15
- package/lib/types/controllers/set-range.controller.d.ts +0 -18
- package/lib/types/types/interfaces/i-sheet-hyper-link-info.d.ts +0 -10
- package/lib/types/types/interfaces/index.d.ts +0 -17
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/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"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsHyperLinkUi={},global.UniverCore,global.UniverSheetsHyperLink,global.UniverSheetsUi,global.UniverDesign,global.UniverEngineFormula,global.UniverSheets,global.UniverUi,global.UniverDocsUi,global.UniverEngineRender,global.rxjs,global.UniverDocs,global.React,global.UniverSheetsFormulaUi))})(this,function(exports2,core,sheetsHyperLink,sheetsUi,design,engineFormula,sheets,ui,docsUi,engineRender,rxjs,docs,require$$0,sheetsFormulaUi){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n;function isLegalLink(link){return core.Tools.isLegalUrl(link)}__name(isLegalLink,"isLegalLink");function hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function serializeUrl(urlStr){if(isLegalLink(urlStr)){const transformedUrl=hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`http://${urlStr}`;let url;try{url=new URL(transformedUrl)}catch{return urlStr}return url.hostname===location.hostname&&url.port===location.port&&url.protocol===location.protocol&&url.pathname===location.pathname&&url.hash&&!url.search?url.hash:transformedUrl}return urlStr}__name(serializeUrl,"serializeUrl");const PLUGIN_CONFIG_KEY="sheets-hyper-link-ui.config",defaultPluginConfig={};var __defProp$c=Object.defineProperty,__getOwnPropDesc$c=Object.getOwnPropertyDescriptor,__decorateClass$c=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$c(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$c(target,key,result),result},"__decorateClass$c"),__decorateParam$c=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$c");function getContainRange(range,worksheet){const mergedCells=worksheet.getMergeData(),maxCol=worksheet.getMaxColumns()-1,maxRow=worksheet.getMaxRows()-1;if(maxCol<range.endColumn&&(range.endColumn=maxCol),maxRow<range.endRow&&(range.endRow=maxRow),range.rangeType===core.RANGE_TYPE.COLUMN||core.RANGE_TYPE.ROW)return range;const relativeCells=[];return mergedCells.forEach(cell=>{core.Rectangle.intersects(range,cell)&&relativeCells.push(cell)}),core.Rectangle.realUnion(range,...relativeCells)}__name(getContainRange,"getContainRange"),exports2.SheetsHyperLinkResolverService=(_a=class{constructor(_univerInstanceService,_commandService,_definedNamesService,_messageService,_localeService,_configService){this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._definedNamesService=_definedNamesService,this._messageService=_messageService,this._localeService=_localeService,this._configService=_configService}_getURLName(params){var _a2;const{gid,range,rangeid,unitid}=params,workbook=unitid?this._univerInstanceService.getUnit(unitid,core.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),invalidLink={type:sheetsHyperLink.SheetHyperLinkType.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!workbook)return invalidLink;const sheet=gid?workbook.getSheetBySheetId(gid):workbook.getActiveSheet(),sheetName=(_a2=sheet==null?void 0:sheet.getName())!=null?_a2:"";if(range){if(!sheet)return invalidLink;const rangeObj=engineFormula.deserializeRangeWithSheet(range).range;return core.isValidRange(rangeObj,sheet)&&range!==sheetsHyperLink.ERROR_RANGE?{type:sheetsHyperLink.SheetHyperLinkType.RANGE,name:engineFormula.serializeRangeWithSheet(sheetName,rangeObj)}:invalidLink}if(rangeid){const range2=this._definedNamesService.getValueById(workbook.getUnitId(),rangeid);return range2?{type:sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME,name:range2.formulaOrRefString}:invalidLink}if(gid){const worksheet=workbook.getSheetBySheetId(gid);return worksheet?{type:sheetsHyperLink.SheetHyperLinkType.SHEET,name:worksheet.getName()}:invalidLink}return invalidLink}navigateTo(params){const{gid,range,rangeid}=params,workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const unitId=workbook.getUnitId();if(rangeid){const item=this._definedNamesService.getValueById(unitId,rangeid);if(!item)return;const{formulaOrRefString}=item,worksheet=this._definedNamesService.getWorksheetByRef(unitId,formulaOrRefString);if(!worksheet){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:design.MessageType.Error});return}if(worksheet.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error});return}this.navigateToDefineName(unitId,rangeid)}if(gid){if(range){const rangeInfo=engineFormula.deserializeRangeWithSheet(range);core.isValidRange(rangeInfo.range)&&range!==sheetsHyperLink.ERROR_RANGE&&this.navigateToRange(unitId,gid,rangeInfo.range);return}this.navigateToSheetById(unitId,gid)}}buildHyperLink(unitId,sheetId,range){return`#${sheetsHyperLink.SheetHyperLinkType.SHEET}=${sheetId}${range?`&${typeof range=="string"?sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME:sheetsHyperLink.SheetHyperLinkType.RANGE}=${typeof range=="string"?range:engineFormula.serializeRange(range)}`:""}`}parseHyperLink(urlStr){var _a2,_b2,_c2,_d2;if(urlStr.startsWith("#")){const search=new URLSearchParams(urlStr.slice(1)),searchObj={gid:(_a2=search.get("gid"))!=null?_a2:"",range:(_b2=search.get("range"))!=null?_b2:"",rangeid:(_c2=search.get("rangeid"))!=null?_c2:"",unitid:(_d2=search.get("unitid"))!=null?_d2:""},urlInfo=this._getURLName(searchObj);return{type:urlInfo.type,name:urlInfo.name,url:urlStr,searchObj,handler:__name(()=>{this.navigateTo(searchObj)},"handler")}}else return{type:sheetsHyperLink.SheetHyperLinkType.URL,name:urlStr,url:urlStr,handler:__name(()=>{this.navigateToOtherWebsite(urlStr)},"handler"),searchObj:null}}async navigateToRange(unitId,subUnitId,range){const worksheet=await this.navigateToSheetById(unitId,subUnitId);if(worksheet){const realRange=getContainRange(range,worksheet);await this._commandService.executeCommand(sheets.SetSelectionsOperation.id,{unitId,subUnitId,selections:[{range:realRange}]}),await this._commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:realRange})}}async navigateToSheet(unitId,sheetName){const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return!1;const worksheet=workbook.getActiveSheet();if((worksheet==null?void 0:worksheet.getName())===sheetName)return!0;const targetSheet=workbook.getSheetBySheetName(sheetName);if(!targetSheet){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:design.MessageType.Error});return}const sheetId=targetSheet.getSheetId();return workbook.getHiddenWorksheets().indexOf(sheetId)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error}),await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId:sheetId})}async navigateToSheetById(unitId,subUnitId){const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return!1;const worksheet=workbook.getActiveSheet();if(!worksheet)return!1;if(worksheet.getSheetId()===subUnitId)return worksheet;const targetSheet=workbook.getSheetBySheetId(subUnitId);return targetSheet?workbook.getHiddenWorksheets().indexOf(subUnitId)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error}),!1):await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId})?targetSheet:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:design.MessageType.Error}),!1)}async navigateToDefineName(unitId,rangeid){return this._definedNamesService.focusRange(unitId,rangeid),!0}async navigateToOtherWebsite(url){var _a2;const config=this._configService.getConfig(PLUGIN_CONFIG_KEY);if((_a2=config==null?void 0:config.urlHandler)!=null&&_a2.navigateToOtherWebsite)return config.urlHandler.navigateToOtherWebsite(url);window.open(url,"_blank","noopener noreferrer")}},__name(_a,"SheetsHyperLinkResolverService"),_a),exports2.SheetsHyperLinkResolverService=__decorateClass$c([__decorateParam$c(0,core.IUniverInstanceService),__decorateParam$c(1,core.ICommandService),__decorateParam$c(2,engineFormula.IDefinedNamesService),__decorateParam$c(3,ui.IMessageService),__decorateParam$c(4,core.Inject(core.LocaleService)),__decorateParam$c(5,core.IConfigService)],exports2.SheetsHyperLinkResolverService);const SHEET_HYPER_LINK_UI_PLUGIN="SHEET_HYPER_LINK_UI_PLUGIN";var __defProp$b=Object.defineProperty,__getOwnPropDesc$b=Object.getOwnPropertyDescriptor,__decorateClass$b=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$b(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$b(target,key,result),result},"__decorateClass$b"),__decorateParam$b=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$b");exports2.SheetsHyperLinkCopyPasteController=(_b=class extends core.Disposable{constructor(_sheetClipboardService,_hyperLinkModel,_injector,_resolverService){super();__publicField(this,"_plainTextFilter",new Set);__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._hyperLinkModel=_hyperLinkModel,this._injector=_injector,this._resolverService=_resolverService,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(filter){this._plainTextFilter.add(filter)}removePlainTextFilter(filter){this._plainTextFilter.delete(filter)}_filterPlainText(text){return Array.from(this._plainTextFilter).every(filter=>filter(text))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:SHEET_HYPER_LINK_UI_PLUGIN,onBeforeCopy:__name((unitId,subUnitId,range)=>this._collect(unitId,subUnitId,range),"onBeforeCopy"),onPasteCells:__name((pasteFrom,pasteTo,data,payload)=>{const{copyType=sheetsUi.COPY_TYPE.COPY,pasteType}=payload,{range:copyRange}=pasteFrom||{},{range:pastedRange,unitId,subUnitId}=pasteTo;return this._generateMutations(pastedRange,{copyType,pasteType,copyRange,unitId,subUnitId})},"onPasteCells"),onPastePlainText:__name((pasteTo,clipText)=>{const filterResult=this._filterPlainText(clipText);if(isLegalLink(clipText)&&filterResult){const{range,unitId,subUnitId}=pasteTo,{ranges:[pasteToRange],mapFunc}=sheetsUi.virtualizeDiscreteRanges([range]),redos=[],undos=[];return core.Range.foreach(pasteToRange,(originRow,originCol)=>{const{row,col:column}=mapFunc(originRow,originCol),link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);link&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),link&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}})}),{redos,undos}}return{undos:[],redos:[]}},"onPastePlainText"),priority:99})}_collect(unitId,subUnitId,range){const matrix=new core.ObjectMatrix;this._copyInfo={unitId,subUnitId,matrix};const discreteRange=this._injector.invoke(accessor=>sheetsUi.rangeToDiscreteRange(range,accessor,unitId,subUnitId));if(!discreteRange)return;const{rows,cols}=discreteRange;rows.forEach((row,rowIndex)=>{cols.forEach((col,colIndex)=>{var _a2;const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);matrix.setValue(rowIndex,colIndex,(_a2=link==null?void 0:link.id)!=null?_a2:"")})})}_generateMutations(pastedRange,copyInfo){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!copyInfo.copyRange)return{redos:[],undos:[]};if([sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(copyInfo.pasteType))return{redos:[],undos:[]};const{unitId,subUnitId}=this._copyInfo,redos=[],undos=[],{ranges:[vCopyRange,vPastedRange],mapFunc}=sheetsUi.virtualizeDiscreteRanges([copyInfo.copyRange,pastedRange]);return sheetsUi.getRepeatRange(vCopyRange,vPastedRange,!0).forEach(({startRange})=>{var _a2;(_a2=this._copyInfo)==null||_a2.matrix.forValue((row,col,ruleId)=>{const range=core.Rectangle.getPositionRange({startRow:row,endRow:row,startColumn:col,endColumn:col},startRange),oldLink=this._hyperLinkModel.getHyperLink(unitId,subUnitId,ruleId),{row:startRow,col:startColumn}=mapFunc(range.startRow,range.startColumn),currentLink=this._hyperLinkModel.getHyperLinkByLocation(copyInfo.unitId,copyInfo.subUnitId,startRow,startColumn),id=core.Tools.generateRandomId();currentLink&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,id:currentLink.id}}),oldLink&&(redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,link:{...oldLink,id,row:startRow,column:startColumn}}}),undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,id}})),currentLink&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,link:currentLink}})})}),{redos,undos}}},__name(_b,"SheetsHyperLinkCopyPasteController"),_b),exports2.SheetsHyperLinkCopyPasteController=__decorateClass$b([__decorateParam$b(0,sheetsUi.ISheetClipboardService),__decorateParam$b(1,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$b(2,core.Inject(core.Injector)),__decorateParam$b(3,core.Inject(exports2.SheetsHyperLinkResolverService))],exports2.SheetsHyperLinkCopyPasteController);var HyperLinkEditSourceType=(HyperLinkEditSourceType2=>(HyperLinkEditSourceType2.EDITING="editing",HyperLinkEditSourceType2.VIEWING="viewing",HyperLinkEditSourceType2.ZEN_EDITOR="zen_mode",HyperLinkEditSourceType2))(HyperLinkEditSourceType||{}),jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
|
|
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 f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q"),reactJsxRuntime_production_min.Fragment=l,reactJsxRuntime_production_min.jsx=q,reactJsxRuntime_production_min.jsxs=q,jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports;const AddHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(accessor,params){var _a2;if(!params)return!1;const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),renderManagerService=accessor.get(engineRender.IRenderManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),hyperLinkModel=accessor.get(sheetsHyperLink.HyperLinkModel),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),{unitId,subUnitId,link}=params,workbook=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),currentRender=renderManagerService.getRenderById(unitId);if(!currentRender||!workbook)return!1;const worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),skeleton=(_a2=currentRender.with(sheetsUi.SheetSkeletonManagerService).getCurrent())==null?void 0:_a2.skeleton;if(!worksheet||!skeleton)return!1;const{payload,display,row,column,id}=link,cellData=worksheet.getCell(row,column),doc=skeleton.getBlankCellDocumentModel(cellData),snapshot=doc.documentModel.getSnapshot(),body=core.Tools.deepClone(snapshot.body);if(!body)return!1;let textX;if(display?textX=core.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:body.dataStream.length-2,collapsed:!0},body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{startIndex:0,endIndex:display.length+1,rangeType:core.CustomRangeType.HYPERLINK,rangeId:id,properties:{url:payload}}]},doc:doc.documentModel}):textX=core.BuildTextUtils.customRange.add({body,range:{startOffset:0,endOffset:body.dataStream.length-2,collapsed:!1},rangeId:id,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload,refId:id}}),!textX)return!1;const newBody=core.TextX.apply(body,textX.serialize()),newCellData={p:{...snapshot,body:newBody},t:core.CellValueType.STRING},finalCellData=await editorBridgeService.beforeSetRangeValue(workbook,worksheet,row,column,newCellData),redoParams={unitId,subUnitId,cellValue:{[link.row]:{[link.column]:finalCellData}}},redo={id:sheets.SetRangeValuesMutation.id,params:redoParams},undoParams=sheets.SetRangeValuesUndoMutationFactory(accessor,redoParams),undo={id:sheets.SetRangeValuesMutation.id,params:undoParams},redos=[redo],undos=[undo],modelLink=hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);return modelLink&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:modelLink.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:modelLink}})),await core.sequenceExecuteAsync(redos,commandService)?(undoRedoService.pushUndoRedo({redoMutations:redos,undoMutations:undos,unitID:unitId}),!0):!1}},AddRichHyperLinkCommand={id:"sheets.command.add-rich-hyper-link",type:core.CommandType.COMMAND,handler:__name(async(accessor,params)=>{if(!params)return!1;const{documentId,link}=params,commandService=accessor.get(core.ICommandService),newId=core.generateRandomId(),{payload}=link,replaceSelection=docsUi.addCustomRangeBySelectionFactory(accessor,{unitId:documentId,rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload,refId:newId}});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1},"handler")},UpdateHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(accessor,params){var _a2,_b2,_c2,_d2;if(!params)return!1;const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),renderManagerService=accessor.get(engineRender.IRenderManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),hyperLinkModel=accessor.get(sheetsHyperLink.HyperLinkModel),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),{unitId,subUnitId,payload:link,row,column,id}=params,workbook=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),currentRender=renderManagerService.getRenderById(unitId);if(!currentRender||!workbook)return!1;const worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),skeleton=(_a2=currentRender.with(sheetsUi.SheetSkeletonManagerService).getCurrent())==null?void 0:_a2.skeleton;if(!worksheet||!skeleton)return!1;const{payload,display=""}=link,cellData=worksheet.getCell(row,column);if(!cellData)return!1;const doc=skeleton.getCellDocumentModelWithFormula(cellData);if(!(doc!=null&&doc.documentModel))return!1;const snapshot=doc.documentModel.getSnapshot(),range=(_c2=(_b2=snapshot.body)==null?void 0:_b2.customRanges)==null?void 0:_c2.find(range2=>range2.rangeId===id);if(!range)return!1;const newId=core.generateRandomId(),textRun=(_d2=core.getBodySlice(doc.documentModel.getBody(),range.startIndex,range.endIndex+1).textRuns)==null?void 0:_d2[0];textRun&&(textRun.ed=display.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:display.length+1,properties:{url:payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:range.startIndex,endOffset:range.endIndex+1,collapsed:!1},doc:doc.documentModel});if(!replaceSelection)return!1;const newBody=core.TextX.apply(core.Tools.deepClone(snapshot.body),replaceSelection.textX.serialize()),newCellData={p:{...snapshot,body:newBody},t:core.CellValueType.STRING},finalCellData=await editorBridgeService.beforeSetRangeValue(workbook,worksheet,row,column,newCellData),redo={id:sheets.SetRangeValuesMutation.id,params:{unitId,subUnitId,cellValue:{[row]:{[column]:finalCellData}}}},undoParams=sheets.SetRangeValuesUndoMutationFactory(accessor,redo.params),undo={id:sheets.SetRangeValuesMutation.id,params:undoParams},redos=[redo],undos=[undo],modelLink=hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);return modelLink&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:modelLink.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:modelLink}})),await core.sequenceExecuteAsync(redos,commandService)?(undoRedoService.pushUndoRedo({redoMutations:redos,undoMutations:undos,unitID:unitId}),!0):!1}},UpdateRichHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:__name((accessor,params)=>{var _a2,_b2,_c2,_d2;if(!params)return!1;const{documentId:unitId,payload,id:rangeId}=params,univerInstanceService=accessor.get(core.IUniverInstanceService),commandService=accessor.get(core.ICommandService),doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!doc)return!1;const range=(_b2=(_a2=doc.getBody())==null?void 0:_a2.customRanges)==null?void 0:_b2.find(range2=>range2.rangeId===rangeId);if(!range)return!1;const display=(_c2=params.payload.display)!=null?_c2:"",newId=core.generateRandomId(),textRun=(_d2=core.getBodySlice(doc.getBody(),range.startIndex,range.endIndex+1).textRuns)==null?void 0:_d2[0];textRun&&(textRun.ed=display.length+1);const replaceSelection=docsUi.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${display}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{rangeId:newId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:display.length+1,properties:{url:payload.payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:range.startIndex,endOffset:range.endIndex+1,collapsed:!1},doc});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1},"handler")},_SheetsHyperLinkSidePanelService=class _SheetsHyperLinkSidePanelService extends core.Disposable{constructor(){super(...arguments);__publicField(this,"_customHyperLinks",new Map)}isBuiltInLinkType(type){return type!==sheetsHyperLink.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option})=>option)}findCustomHyperLink(link){return Array.from(this._customHyperLinks.values()).find(item=>item.match(link))}registerCustomHyperLink(customHyperLink){this._customHyperLinks.set(customHyperLink.type,customHyperLink)}getCustomHyperLink(type){return this._customHyperLinks.get(type)}removeCustomHyperLink(type){const{_customHyperLinks}=this;_customHyperLinks.delete(type)}dispose(){super.dispose(),this._customHyperLinks.clear()}};__name(_SheetsHyperLinkSidePanelService,"SheetsHyperLinkSidePanelService");let SheetsHyperLinkSidePanelService=_SheetsHyperLinkSidePanelService;const styles$1={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},CellLinkEdit=__name(()=>{var _a2;const[id,setId]=require$$0.useState(""),[hide,setHide]=require$$0.useState(!1),[display,setDisplay]=require$$0.useState(""),[showLabel,setShowLabel]=require$$0.useState(!0),[type,setType]=require$$0.useState(sheetsHyperLink.SheetHyperLinkType.URL),[payload,setPayload]=require$$0.useState(""),localeService=core.useDependency(core.LocaleService),definedNameService=core.useDependency(engineFormula.IDefinedNamesService),editorBridgeService=core.useDependency(sheetsUi.IEditorBridgeService),univerInstanceService=core.useDependency(core.IUniverInstanceService),popupService=core.useDependency(exports2.SheetsHyperLinkPopupService),editing=ui.useObservable(popupService.currentEditing$),resolverService=core.useDependency(exports2.SheetsHyperLinkResolverService),commandService=core.useDependency(core.ICommandService),sidePanelService=core.useDependency(SheetsHyperLinkSidePanelService),sidePanelOptions=require$$0.useMemo(()=>sidePanelService.getOptions(),[sidePanelService]),zenZoneService=core.useDependency(ui.IZenZoneService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),markSelectionService=core.useDependency(sheetsUi.IMarkSelectionService),textSelectionService=core.useDependency(docs.DocSelectionManagerService),contextService=core.useDependency(core.IContextService),themeService=core.useDependency(core.ThemeService),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),rangeSelectorActionsRef=require$$0.useRef({}),customHyperLinkSidePanel=require$$0.useMemo(()=>{if(!sidePanelService.isBuiltInLinkType(type))return sidePanelService.getCustomHyperLink(type)},[sidePanelService,type]),[showError,setShowError]=require$$0.useState(!1),[isFocusRangeSelector,isFocusRangeSelectorSet]=require$$0.useState(!1),setByPayload=require$$0.useRef(!1),workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),subUnitId=(workbook==null?void 0:workbook.getActiveSheet().getSheetId())||"";require$$0.useEffect(()=>{isFocusRangeSelectorSet(!1)},[subUnitId]),require$$0.useEffect(()=>{var _a3,_b2,_c2,_d2,_e2,_f2,_g2,_h2,_i2,_j2,_k2,_l2,_m2,_n2,_o,_p,_q;if((editing==null?void 0:editing.row)!==void 0&&editing.col!==void 0){const{label,customRange,row,col}=editing;let link;if(customRange)link={id:(_a3=customRange==null?void 0:customRange.rangeId)!=null?_a3:"",display:label!=null?label:"",payload:(_c2=(_b2=customRange==null?void 0:customRange.properties)==null?void 0:_b2.url)!=null?_c2:"",row,column:col};else if(editing.type===HyperLinkEditSourceType.VIEWING){const workbook2=univerInstanceService.getUnit(editing.unitId),worksheet=workbook2==null?void 0:workbook2.getSheetBySheetId(editing.subUnitId),cell=worksheet==null?void 0:worksheet.getCellRaw(editing.row,editing.col),range=(_f2=(_e2=(_d2=cell==null?void 0:cell.p)==null?void 0:_d2.body)==null?void 0:_e2.customRanges)==null?void 0:_f2.find(range2=>{var _a4;return range2.rangeType===core.CustomRangeType.HYPERLINK&&((_a4=range2.properties)==null?void 0:_a4.url)}),cellValue=cell==null?void 0:cell.v;cell&&(!core.BuildTextUtils.transform.isEmptyDocument((_h2=(_g2=cell.p)==null?void 0:_g2.body)==null?void 0:_h2.dataStream)||cellValue)&&setShowLabel(!1),link={id:"",display:"",payload:(_j2=(_i2=range==null?void 0:range.properties)==null?void 0:_i2.url)!=null?_j2:"",row,column:col}}else{const doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC),currentSelection=textSelectionService.getActiveTextRange(),body=doc==null?void 0:doc.getBody(),selection=currentSelection&&body?core.BuildTextUtils.selection.getInsertSelection(currentSelection,body):null,customRange2=selection&&((_l2=core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection,(_k2=body==null?void 0:body.customRanges)!=null?_k2:[]))==null?void 0:_l2[0]);setShowLabel(!1),link={id:"",display:label!=null?label:"",payload:(_n2=(_m2=customRange2==null?void 0:customRange2.properties)==null?void 0:_m2.url)!=null?_n2:"",row,column:col}}setId(link.id);const customLink=sidePanelService.findCustomHyperLink(link);if(customLink){const customLinkInfo=customLink.convert(link);setType(customLinkInfo.type),setPayload(customLinkInfo.payload),setDisplay(customLinkInfo.display);return}setDisplay(link.display);const linkInfo=resolverService.parseHyperLink(link.payload);switch(setType(linkInfo.type===sheetsHyperLink.SheetHyperLinkType.INVALID?sheetsHyperLink.SheetHyperLinkType.RANGE:linkInfo.type),linkInfo.type){case sheetsHyperLink.SheetHyperLinkType.URL:{setPayload(linkInfo.url),linkInfo.url===link.display&&(setByPayload.current=!0);break}case sheetsHyperLink.SheetHyperLinkType.RANGE:{const params=linkInfo.searchObj,sheetName=params.gid&&(_q=(_p=(_o=univerInstanceService.getUnit(editing.unitId))==null?void 0:_o.getSheetBySheetId(params.gid))==null?void 0:_p.getName())!=null?_q:"",payload2=engineFormula.serializeRangeWithSheet(sheetName,engineFormula.deserializeRangeWithSheet(params.range).range);setPayload(payload2),payload2===link.display&&(setByPayload.current=!0);break}case sheetsHyperLink.SheetHyperLinkType.SHEET:{const params=linkInfo.searchObj;setPayload(params.gid);break}case sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME:{const params=linkInfo.searchObj;setPayload(params.rangeid);break}default:setPayload("");break}}},[editing,resolverService,sidePanelService,textSelectionService,univerInstanceService]),require$$0.useEffect(()=>{let id2=null;if(editing&&!editing.customRangeId&&editing.type===HyperLinkEditSourceType.VIEWING&&core.Tools.isDefine(editing.row)&&core.Tools.isDefine(editing.col)){const workbook2=univerInstanceService.getUnit(editing.unitId,core.UniverInstanceType.UNIVER_SHEET),worksheet=workbook2==null?void 0:workbook2.getSheetBySheetId(editing.subUnitId),mergeInfo=worksheet==null?void 0:worksheet.getMergedCell(editing.row,editing.col),color=new core.ColorKit(themeService.getCurrentTheme().hyacinth500).toRgb();id2=markSelectionService.addShape({range:mergeInfo!=null?mergeInfo:{startColumn:editing.col,endColumn:editing.col,startRow:editing.row,endRow:editing.row},style:{hasAutoFill:!1,fill:`rgb(${color.r}, ${color.g}, ${color.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{id2&&markSelectionService.removeShape(id2)}},[editing,markSelectionService,themeService,univerInstanceService]),require$$0.useEffect(()=>{type===sheetsHyperLink.SheetHyperLinkType.RANGE&&!showLabel&&!isFocusRangeSelector&&isFocusRangeSelectorSet(!0)},[type,isFocusRangeSelector,showLabel,editorBridgeService]),require$$0.useEffect(()=>{const render2=(editing==null?void 0:editing.type)===HyperLinkEditSourceType.ZEN_EDITOR?renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY):renderManagerService.getRenderById(editorBridgeService.getCurrentEditorId()),disposeCollection=new core.DisposableCollection;if(render2){const selectionRenderService=render2.with(docsUi.DocSelectionRenderService);selectionRenderService.setReserveRangesStatus(!0),disposeCollection.add(()=>{selectionRenderService.setReserveRangesStatus(!1)})}return()=>{editorBridgeService.disableForceKeepVisible(),disposeCollection.dispose()}},[editing==null?void 0:editing.type,editorBridgeService,renderManagerService]),require$$0.useEffect(()=>(popupService.setIsKeepVisible(isFocusRangeSelector),()=>{popupService.setIsKeepVisible(!1)}),[isFocusRangeSelector,popupService]),require$$0.useEffect(()=>()=>{zenZoneService.temporaryHidden&&(zenZoneService.show(),contextService.setContextValue(core.FOCUSING_SHEET,!1))},[contextService,zenZoneService]);const linkTypeOptions=[{label:localeService.t("hyperLink.form.link"),value:sheetsHyperLink.SheetHyperLinkType.URL},{label:localeService.t("hyperLink.form.range"),value:sheetsHyperLink.SheetHyperLinkType.RANGE},{label:localeService.t("hyperLink.form.worksheet"),value:sheetsHyperLink.SheetHyperLinkType.SHEET},{label:localeService.t("hyperLink.form.definedName"),value:sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME},...sidePanelOptions];if(!workbook)return;const hiddens=workbook.getHiddenWorksheets(),sheetsOption=workbook.getSheets().map(sheet=>({label:sheet.getName(),value:sheet.getSheetId()})).filter(opt=>hiddens.indexOf(opt.value)===-1),definedNames=Object.values((_a2=definedNameService.getDefinedNameMap(workbook.getUnitId()))!=null?_a2:{}).map(value=>({label:value.name,value:value.id})),formatUrl=__name((type2,payload2)=>{if(type2===sheetsHyperLink.SheetHyperLinkType.URL)return serializeUrl(payload2);if(type2===sheetsHyperLink.SheetHyperLinkType.RANGE){const info=engineFormula.deserializeRangeWithSheet(payload2),worksheet=workbook.getSheetBySheetName(info.sheetName);if(worksheet)return`#gid=${worksheet.getSheetId()}&range=${engineFormula.serializeRange(info.range)}`}return`#${type2}=${payload2}`},"formatUrl"),handleRangeChange=ui.useEvent(rangeText=>{var _a3;const range=rangeText.split(",").map(engineFormula.deserializeRangeWithSheet)[0];if(!range||!core.isValidRange(range.range))return;range.sheetName||(range.sheetName=((_a3=workbook.getActiveSheet())==null?void 0:_a3.getName())||"");const newPayload=engineFormula.serializeRangeToRefString(range);setPayload(newPayload),newPayload&&(setByPayload.current||!display)&&(setDisplay(newPayload),setByPayload.current=!0)}),handleSubmit=__name(async()=>{if(showLabel&&!display||!payload||type===sheetsHyperLink.SheetHyperLinkType.URL&&!isLegalLink(payload)){setShowError(!0);return}if(editing)if(id){const commandId=editing.type===HyperLinkEditSourceType.ZEN_EDITOR||editing.type===HyperLinkEditSourceType.EDITING?UpdateRichHyperLinkCommand.id:UpdateHyperLinkCommand.id;await commandService.executeCommand(commandId,{id,unitId:editing.unitId,subUnitId:editing.subUnitId,payload:{display:showLabel?display:"",payload:formatUrl(type,payload)},row:editing.row,column:editing.col,documentId:editing.type===HyperLinkEditSourceType.ZEN_EDITOR?core.DOCS_ZEN_EDITOR_UNIT_ID_KEY:editorBridgeService.getCurrentEditorId()})}else{const commandId=editing.type===HyperLinkEditSourceType.ZEN_EDITOR||editing.type===HyperLinkEditSourceType.EDITING?AddRichHyperLinkCommand.id:AddHyperLinkCommand.id;await commandService.executeCommand(commandId,{unitId:editing.unitId,subUnitId:editing.subUnitId,link:{id:core.generateRandomId(),row:editing.row,column:editing.col,payload:formatUrl(type,payload),display:showLabel?display:""},documentId:editing.type===HyperLinkEditSourceType.ZEN_EDITOR?core.DOCS_ZEN_EDITOR_UNIT_ID_KEY:editorBridgeService.getCurrentEditorId()})}if((editing==null?void 0:editing.type)===HyperLinkEditSourceType.VIEWING){await commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId:editing.unitId,subUnitId:editing.subUnitId});const GAP=1;await commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:{startRow:Math.max(editing.row-GAP,0),endRow:editing.row+GAP,startColumn:Math.max(editing.col-GAP,0),endColumn:editing.col+GAP}})}commandService.executeCommand(CloseHyperLinkPopupOperation.id)},"handleSubmit"),handlePanelClick=__name(e=>{var _a3;if(type!==sheetsHyperLink.SheetHyperLinkType.RANGE)return;const handleOutClick=(_a3=rangeSelectorActionsRef.current)==null?void 0:_a3.handleOutClick;handleOutClick&&handleOutClick(e,isFocusRangeSelectorSet)},"handlePanelClick");return editing?jsxRuntimeExports.jsxs("div",{className:styles$1.cellLinkEdit,style:{display:hide?"none":"block"},onClick:handlePanelClick,children:[showLabel?jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("hyperLink.form.label"),error:showError&&!display?localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(design.Input,{value:display,onChange:__name(v=>{setDisplay(v),setByPayload.current=!1},"onChange"),placeholder:localeService.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:__name(e=>{e.keyCode===ui.KeyCode.ENTER&&handleSubmit()},"onKeyDown")})}):null,jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("hyperLink.form.type"),children:jsxRuntimeExports.jsx(design.Select,{options:linkTypeOptions,value:type,onChange:__name(newType=>{setType(newType),setPayload("")},"onChange")})}),type===sheetsHyperLink.SheetHyperLinkType.URL&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError?payload?isLegalLink(payload)?"":localeService.t("hyperLink.form.linkError"):localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(design.Input,{value:payload,onChange:__name(newLink=>{setPayload(newLink),newLink&&(setByPayload.current||!display||display===payload)&&(setDisplay(newLink),setByPayload.current=!0)},"onChange"),placeholder:localeService.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:__name(e=>{e.keyCode===ui.KeyCode.ENTER&&handleSubmit()},"onKeyDown")})}),type===sheetsHyperLink.SheetHyperLinkType.RANGE&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(sheetsFormulaUi.RangeSelector,{unitId:workbook.getUnitId(),subUnitId,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:payload,onChange:handleRangeChange,isFocus:isFocusRangeSelector,onBlur:__name(()=>{isFocusRangeSelectorSet(!1)},"onBlur"),actions:rangeSelectorActionsRef.current,onRangeSelectorDialogVisibleChange:__name(async visible=>{var _a3,_b2;if(visible)editing.type===HyperLinkEditSourceType.ZEN_EDITOR&&(zenZoneService.hide(),contextService.setContextValue(core.FOCUSING_SHEET,!0)),editing.type!==HyperLinkEditSourceType.VIEWING&&editorBridgeService.enableForceKeepVisible(),setHide(!0);else{if(await resolverService.navigateToRange(editing.unitId,editing.subUnitId,{startRow:editing.row,endRow:editing.row,startColumn:editing.col,endColumn:editing.col}),editing.type===HyperLinkEditSourceType.ZEN_EDITOR){await commandService.executeCommand(sheets.SetSelectionsOperation.id,{unitId:editing.unitId,subUnitId:editing.subUnitId,selections:[{range:{startRow:editing.row,endRow:editing.row,startColumn:editing.col,endColumn:editing.col}}]}),zenZoneService.show(),contextService.setContextValue(core.FOCUSING_SHEET,!1);const docBackScrollRenderController=(_a3=renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a3.with(docsUi.DocBackScrollRenderController),range=(_b2=docSelectionManagerService.getTextRanges({unitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:_b2[0];docBackScrollRenderController&&range&&(docBackScrollRenderController.scrollToRange(range),docSelectionManagerService.refreshSelection({unitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}editorBridgeService.disableForceKeepVisible(),setHide(!1)}},"onRangeSelectorDialogVisibleChange")})}),type===sheetsHyperLink.SheetHyperLinkType.SHEET&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.selectError"):"",children:jsxRuntimeExports.jsx(design.Select,{options:sheetsOption,value:payload,onChange:__name(newPayload=>{var _a3,_b2;setPayload(newPayload);const label=(_a3=sheetsOption.find(i=>i.value===newPayload))==null?void 0:_a3.label,oldLabel=(_b2=sheetsOption.find(i=>i.value===payload))==null?void 0:_b2.label;label&&(setByPayload.current||!display||display===oldLabel)&&(setDisplay(label),setByPayload.current=!0)},"onChange")})}),type===sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.selectError"):"",children:jsxRuntimeExports.jsx(design.Select,{options:definedNames,value:payload,onChange:__name(newValue=>{var _a3,_b2;setPayload(newValue);const label=(_a3=definedNames.find(i=>i.value===newValue))==null?void 0:_a3.label,oldLabel=(_b2=definedNames.find(i=>i.value===payload))==null?void 0:_b2.label;label&&(setByPayload.current||!display||display===oldLabel)&&(setDisplay(label),setByPayload.current=!0)},"onChange")})}),(customHyperLinkSidePanel==null?void 0:customHyperLinkSidePanel.Form)&&jsxRuntimeExports.jsx(customHyperLinkSidePanel.Form,{linkId:id,payload,display,showError,setByPayload,setDisplay:__name(newLink=>{setDisplay(newLink),setByPayload.current=!0},"setDisplay"),setPayload}),jsxRuntimeExports.jsxs("div",{className:styles$1.cellLinkEditButtons,children:[jsxRuntimeExports.jsx(design.Button,{onClick:__name(()=>{editing&&resolverService.navigateToRange(editing.unitId,editing.subUnitId,{startRow:editing.row,endRow:editing.row,startColumn:editing.col,endColumn:editing.col}),commandService.executeCommand(CloseHyperLinkPopupOperation.id)},"onClick"),children:localeService.t("hyperLink.form.cancel")}),jsxRuntimeExports.jsx(design.Button,{type:"primary",style:{marginLeft:8},onClick:__name(async()=>{handleSubmit()},"onClick"),children:localeService.t("hyperLink.form.ok")})]})]}):null},"CellLinkEdit");CellLinkEdit.componentKey="univer.sheet.cell-link-edit";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n2=arguments.length;i<n2;i++){s=arguments[i];for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&(t[p2]=s[p2])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&e.indexOf(p2)<0&&(t[p2]=s[p2]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p2=Object.getOwnPropertySymbols(s);i<p2.length;i++)e.indexOf(p2[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p2[i])&&(t[p2[i]]=s[p2[i]]);return t},IconBase=require$$0.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=require$$0.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return require$$0.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$5={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"}}]},AllBorderSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"all-border-single",ref,icon:element$5}))});AllBorderSingle.displayName="AllBorderSingle";var element$4={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"}}]},CopySingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$4}))});CopySingle.displayName="CopySingle";var element$3={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"}}]},LinkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$3}))});LinkSingle.displayName="LinkSingle";var element$2={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"}}]},UnlinkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$2}))});UnlinkSingle.displayName="UnlinkSingle";var element$1={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"}}]},WriteSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element$1}))});WriteSingle.displayName="WriteSingle";var element={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"}}]},Xlsx=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"xlsx",ref,icon:element}))});Xlsx.displayName="Xlsx";function r(e){var t,f2,n2="";if(typeof e=="string"||typeof e=="number")n2+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f2=r(e[t]))&&(n2&&(n2+=" "),n2+=f2)}else for(f2 in e)e[f2]&&(n2&&(n2+=" "),n2+=f2);return n2}__name(r,"r");function clsx(){for(var e,t,f2=0,n2="",o=arguments.length;f2<o;f2++)(e=arguments[f2])&&(t=r(e))&&(n2&&(n2+=" "),n2+=t);return n2}__name(clsx,"clsx");const CancelHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(accessor,params){var _a2,_b2,_c2;if(!params)return!1;const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),renderManagerService=accessor.get(engineRender.IRenderManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),hyperLinkModel=accessor.get(sheetsHyperLink.HyperLinkModel),{unitId,subUnitId,row,column,id}=params,workbook=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),currentRender=renderManagerService.getRenderById(unitId);if(!currentRender||!workbook)return!1;const worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),skeleton=(_a2=currentRender.with(sheetsUi.SheetSkeletonManagerService).getCurrent())==null?void 0:_a2.skeleton;if(!worksheet||!skeleton)return!1;const cellData=worksheet.getCell(row,column);if(!cellData)return!1;const doc=skeleton.getCellDocumentModelWithFormula(cellData);if(!(doc!=null&&doc.documentModel))return!1;const snapshot=core.Tools.deepClone(doc.documentModel.getSnapshot());if(!((_c2=(_b2=snapshot.body)==null?void 0:_b2.customRanges)==null?void 0:_c2.find(range2=>range2.rangeId===id)))return!1;const textX=core.BuildTextUtils.customRange.delete(accessor,{documentDataModel:doc.documentModel,rangeId:id});if(!textX)return!1;const newBody=core.TextX.apply(snapshot.body,textX.serialize()),redos=[],undos=[],setRangeParams={unitId,subUnitId,cellValue:{[row]:{[column]:{p:{...snapshot,body:newBody},t:core.CellValueType.STRING}}}};redos.push({id:sheets.SetRangeValuesMutation.id,params:setRangeParams});const undoParams=sheets.SetRangeValuesUndoMutationFactory(accessor,setRangeParams);undos.push({id:sheets.SetRangeValuesMutation.id,params:undoParams});const link=hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);return link&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:{...link}}})),core.sequenceExecute(redos,commandService).result?(undoRedoService.pushUndoRedo({redoMutations:redos,undoMutations:undos,unitID:unitId}),!0):!1}},CancelRichHyperLinkCommand={type:core.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(accessor,params){var _a2,_b2;if(!params)return!1;const{id:linkId,documentId}=params,commandService=accessor.get(core.ICommandService),doc=accessor.get(core.IUniverInstanceService).getUnit(documentId,core.UniverInstanceType.UNIVER_DOC),link=(_b2=(_a2=doc==null?void 0:doc.getBody())==null?void 0:_a2.customRanges)==null?void 0:_b2.find(i=>i.rangeId===linkId);let insert=null;link&&link.endIndex===doc.getBody().dataStream.length-3&&(insert={dataStream:" "});const doMutation=docsUi.deleteCustomRangeFactory(accessor,{unitId:documentId,rangeId:linkId,insert});return doMutation?commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},styles={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"},iconsMap={[sheetsHyperLink.SheetHyperLinkType.URL]:jsxRuntimeExports.jsx(LinkSingle,{}),[sheetsHyperLink.SheetHyperLinkType.SHEET]:jsxRuntimeExports.jsx(Xlsx,{}),[sheetsHyperLink.SheetHyperLinkType.RANGE]:jsxRuntimeExports.jsx(AllBorderSingle,{}),[sheetsHyperLink.SheetHyperLinkType.DEFINE_NAME]:jsxRuntimeExports.jsx(AllBorderSingle,{}),[sheetsHyperLink.SheetHyperLinkType.INVALID]:jsxRuntimeExports.jsx(AllBorderSingle,{})},CellLinkPopup=__name(()=>{var _a2,_b2;const popupService=core.useDependency(exports2.SheetsHyperLinkPopupService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),[currentPopup,setCurrentPopup]=require$$0.useState(null),resolverService=core.useDependency(exports2.SheetsHyperLinkResolverService),editorBridgeService=core.useDependency(sheetsUi.IEditorBridgeService),zenZoneService=core.useDependency(ui.IZenZoneService);if(core.useObservable(zenZoneService.visible$),require$$0.useEffect(()=>{setCurrentPopup(popupService.currentPopup);const ob=popupService.currentPopup$.subscribe(popup=>{setCurrentPopup(popup)});return()=>{ob.unsubscribe()}},[popupService.currentPopup,popupService.currentPopup$]),!currentPopup)return null;const{unitId,subUnitId,customRange,row,col}=currentPopup;if(!((_a2=customRange==null?void 0:customRange.properties)!=null&&_a2.url))return null;const linkObj=resolverService.parseHyperLink((_b2=customRange.properties.url)!=null?_b2:""),isError=linkObj.type===sheetsHyperLink.SheetHyperLinkType.INVALID;return jsxRuntimeExports.jsxs("div",{className:styles.cellLink,onClick:__name(()=>popupService.hideCurrentPopup(),"onClick"),children:[jsxRuntimeExports.jsxs("div",{className:clsx(styles.cellLinkContent,{[styles.cellLinkContentError]:isError}),onClick:__name(()=>{zenZoneService.visible||linkObj.handler()},"onClick"),children:[jsxRuntimeExports.jsx("div",{className:styles.cellLinkType,children:iconsMap[linkObj.type]}),jsxRuntimeExports.jsx(design.Tooltip,{showIfEllipsis:!0,title:linkObj.name,children:jsxRuntimeExports.jsx("span",{className:styles.cellLinkUrl,children:linkObj.name})})]}),jsxRuntimeExports.jsxs("div",{className:styles.cellLinkOperations,children:[currentPopup.copyPermission&&jsxRuntimeExports.jsx("div",{className:clsx(styles.cellLinkOperation,{[styles.cellLinkOperationError]:isError}),onClick:__name(()=>{if(!isError){if(linkObj.type!==sheetsHyperLink.SheetHyperLinkType.URL){const url=new URL(window.location.href);url.hash=linkObj.url.slice(1),navigator.clipboard.writeText(url.href)}else navigator.clipboard.writeText(linkObj.url);messageService.show({content:localeService.t("hyperLink.message.coped"),type:design.MessageType.Info})}},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.copy"),children:jsxRuntimeExports.jsx(CopySingle,{})})}),currentPopup.editPermission&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:styles.cellLinkOperation,onClick:__name(()=>{commandService.executeCommand(OpenHyperLinkEditPanelOperation.id,{unitId,subUnitId,row,col,customRangeId:customRange.rangeId,type:currentPopup.type})},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.edit"),children:jsxRuntimeExports.jsx(WriteSingle,{})})}),jsxRuntimeExports.jsx("div",{className:styles.cellLinkOperation,onClick:__name(()=>{const commandId=currentPopup.type===HyperLinkEditSourceType.EDITING||currentPopup.type===HyperLinkEditSourceType.ZEN_EDITOR?CancelRichHyperLinkCommand.id:CancelHyperLinkCommand.id;commandService.syncExecuteCommand(commandId,{unitId,subUnitId,id:customRange.rangeId,row,column:col,documentId:currentPopup.type===HyperLinkEditSourceType.ZEN_EDITOR?core.DOCS_ZEN_EDITOR_UNIT_ID_KEY:editorBridgeService.getCurrentEditorId()})&&popupService.hideCurrentPopup(void 0,!0)},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.cancel"),children:jsxRuntimeExports.jsx(UnlinkSingle,{})})})]})]})]})},"CellLinkPopup");CellLinkPopup.componentKey="univer.sheet.cell-link-popup";var __defProp$a=Object.defineProperty,__getOwnPropDesc$a=Object.getOwnPropertyDescriptor,__decorateClass$a=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$a(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$a(target,key,result),result},"__decorateClass$a"),__decorateParam$a=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$a");const isEqualLink=__name((a,b)=>{var _a2,_b2;return a.unitId===b.unitId&&a.subUnitId===b.subUnitId&&a.row===b.row&&a.col===b.col&&((_a2=a.customRange)==null?void 0:_a2.rangeId)===((_b2=b.customRange)==null?void 0:_b2.rangeId)&&a.type===b.type},"isEqualLink");exports2.SheetsHyperLinkPopupService=(_c=class extends core.Disposable{constructor(_sheetCanvasPopManagerService,_injector,_univerInstanceService,_editorBridgeService,_textSelectionManagerService,_docCanvasPopManagerService,_editorService,_rangeSelectorService,_zenZoneService){super();__publicField(this,"_currentPopup",null);__publicField(this,"_currentPopup$",new rxjs.Subject);__publicField(this,"currentPopup$",this._currentPopup$.asObservable());__publicField(this,"_currentEditingPopup",null);__publicField(this,"_currentEditing$",new rxjs.BehaviorSubject(null));__publicField(this,"currentEditing$",this._currentEditing$.asObservable());__publicField(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=_sheetCanvasPopManagerService,this._injector=_injector,this._univerInstanceService=_univerInstanceService,this._editorBridgeService=_editorBridgeService,this._textSelectionManagerService=_textSelectionManagerService,this._docCanvasPopManagerService=_docCanvasPopManagerService,this._editorService=_editorService,this._rangeSelectorService=_rangeSelectorService,this._zenZoneService=_zenZoneService,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(v){this._isKeepVisible=v}getIsKeepVisible(){return this._isKeepVisible}showPopup(location2){if(this._currentPopup&&isEqualLink(location2,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),location2.type!==HyperLinkEditSourceType.ZEN_EDITOR&&this._zenZoneService.visible))return;const currentEditing=this._currentEditing$.getValue();if(currentEditing&&isEqualLink(location2,currentEditing))return;const{unitId,subUnitId,row,col,customRangeRect,customRange}=location2;if(!customRange)return;let disposable;const popup={componentKey:CellLinkPopup.componentKey,direction:"bottom",onClickOutside:__name(()=>{this.hideCurrentPopup()},"onClickOutside"),onClick:__name(()=>{this.hideCurrentPopup(location2.type,!0)},"onClick")};location2.type===HyperLinkEditSourceType.EDITING?disposable=customRangeRect&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(customRangeRect,popup):location2.type===HyperLinkEditSourceType.ZEN_EDITOR?disposable=this._docCanvasPopManagerService.attachPopupToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex+1,collapsed:!1},popup,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY):disposable=customRangeRect&&this._sheetCanvasPopManagerService.attachPopupByPosition(customRangeRect,popup),disposable&&(this._currentPopup={unitId,subUnitId,disposable,row,col,editPermission:!!location2.editPermission,copyPermission:!!location2.copyPermission,customRange,type:location2.type},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(type,force){var _a2,_b2;this._currentPopup&&((!type||type===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||force)&&((_b2=(_a2=this._currentPopup)==null?void 0:_a2.disposable)==null||_b2.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var _a2,_b2,_c2;const visible=this._editorBridgeService.isVisible().visible,state=this._editorBridgeService.getEditCellState();if(visible&&state){const textRange=this._textSelectionManagerService.getActiveTextRange(),body=(_a2=state.documentLayoutObject.documentModel)==null?void 0:_a2.getBody();if(!body)return null;if(!textRange||textRange.collapsed)return{startOffset:0,endOffset:body.dataStream.length-2,collapsed:body.dataStream.length-2===0,label:core.BuildTextUtils.transform.getPlainText(body.dataStream)};const links=core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(textRange,(_c2=(_b2=body.customRanges)==null?void 0:_b2.filter(i=>i.rangeType===core.CustomRangeType.HYPERLINK))!=null?_c2:[]);let start=textRange.startOffset,end=textRange.endOffset;return links.forEach(link=>{start=Math.min(start,link.startIndex),end=Math.max(end,link.endIndex+1)}),{startOffset:start,endOffset:end,collapsed:start===end,label:core.BuildTextUtils.transform.getPlainText(body.dataStream.slice(start,end))}}return null}get _editPopup(){return{componentKey:CellLinkEdit.componentKey,direction:"bottom",onClickOutside:__name(()=>{this.getIsKeepVisible()||this.endEditing()},"onClickOutside"),onContextMenu:__name(()=>{this.getIsKeepVisible()||this.endEditing()},"onContextMenu"),hiddenType:"hide"}}startAddEditing(link){var _a2,_b2,_c2,_d2,_e2;const{unitId,subUnitId,type}=link;if(type===HyperLinkEditSourceType.ZEN_EDITOR){const document=this._univerInstanceService.getUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,core.UniverInstanceType.UNIVER_DOC);if(!document)return;const range=this._textSelectionManagerService.getActiveTextRange();if(!range)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(range,this._editPopup,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const label=(_a2=document.getBody())==null?void 0:_a2.dataStream.slice(range.startOffset,range.endOffset-1);this._currentEditing$.next({...link,label})}else if(type===HyperLinkEditSourceType.EDITING){const range=this._getEditingRange();range&&this._textSelectionManagerService.replaceTextRanges([{...range}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(link.row,link.col,this._editPopup,unitId,subUnitId),this._currentEditing$.next({...link,label:(_b2=range==null?void 0:range.label)!=null?_b2:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(link.row,link.col,this._editPopup,unitId,subUnitId);const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),worksheet=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId),cell=worksheet==null?void 0:worksheet.getCellRaw(link.row,link.col);this._currentEditing$.next({...link,label:cell!=null&&cell.p?core.BuildTextUtils.transform.getPlainText((_d2=(_c2=cell.p.body)==null?void 0:_c2.dataStream)!=null?_d2:""):((_e2=cell==null?void 0:cell.v)!=null?_e2:"").toString()})}}startEditing(link){var _a2,_b2,_c2,_d2,_e2,_f2;(_a2=this._currentEditingPopup)==null||_a2.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId,subUnitId}=link;let customRange,label;if(link.type===HyperLinkEditSourceType.ZEN_EDITOR){const document=this._univerInstanceService.getUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,core.UniverInstanceType.UNIVER_DOC);if(customRange=(_c2=(_b2=document==null?void 0:document.getBody())==null?void 0:_b2.customRanges)==null?void 0:_c2.find(range=>range.rangeId===link.customRangeId),label=customRange?(_d2=document==null?void 0:document.getBody())==null?void 0:_d2.dataStream.slice(customRange.startIndex+1,customRange.endIndex):"",!customRange||!label)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:customRange.startIndex,endOffset:customRange.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:customRange.startIndex,endOffset:customRange.endIndex,collapsed:!1},this._editPopup,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(link.type===HyperLinkEditSourceType.EDITING){const customRangeInfo=sheetsUi.getEditingCustomRangePosition(this._injector,link.unitId,link.subUnitId,link.row,link.col,link.customRangeId);if(!customRangeInfo||!((_e2=customRangeInfo.rects)!=null&&_e2.length))return;customRange=customRangeInfo.customRange,label=customRangeInfo.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:customRange.startIndex,endOffset:customRange.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(customRangeInfo.rects.pop(),this._editPopup,unitId,subUnitId)}else{const customRangeInfo=sheetsUi.getCustomRangePosition(this._injector,link.unitId,link.subUnitId,link.row,link.col,link.customRangeId);if(!customRangeInfo||!((_f2=customRangeInfo.rects)!=null&&_f2.length))return;customRange=customRangeInfo.customRange,label=customRangeInfo.label,this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(customRangeInfo.rects.pop(),this._editPopup,unitId,subUnitId)}this._currentEditing$.next({...link,customRange,label})}endEditing(type){var _a2;const current=this._currentEditing$.getValue();current&&(!type||type===current.type)&&((_a2=this._currentEditingPopup)==null||_a2.dispose(),this._currentEditing$.next(null))}},__name(_c,"SheetsHyperLinkPopupService"),_c),exports2.SheetsHyperLinkPopupService=__decorateClass$a([__decorateParam$a(0,core.Inject(sheetsUi.SheetCanvasPopManagerService)),__decorateParam$a(1,core.Inject(core.Injector)),__decorateParam$a(2,core.IUniverInstanceService),__decorateParam$a(3,sheetsUi.IEditorBridgeService),__decorateParam$a(4,core.Inject(docs.DocSelectionManagerService)),__decorateParam$a(5,core.Inject(docsUi.DocCanvasPopManagerService)),__decorateParam$a(6,docsUi.IEditorService),__decorateParam$a(7,docsUi.IRangeSelectorService),__decorateParam$a(8,ui.IZenZoneService)],exports2.SheetsHyperLinkPopupService);const getShouldDisableCellLink=__name((worksheet,row,col)=>{const cell=worksheet.getCell(row,col);if(cell!=null&&cell.f||cell!=null&&cell.si)return!0;const disables=[core.DataValidationType.CHECKBOX,core.DataValidationType.LIST,core.DataValidationType.LIST_MULTIPLE];return!!(cell!=null&&cell.dataValidation&&disables.includes(cell.dataValidation.rule.type))},"getShouldDisableCellLink"),getShouldDisableCurrentCellLink=__name(accessor=>{const unit=accessor.get(core.IUniverInstanceService).getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!unit)return!0;const worksheet=unit.getActiveSheet(),selections=accessor.get(sheets.SheetsSelectionsService).getCurrentSelections();if(!selections.length)return!0;const row=selections[0].range.startRow,col=selections[0].range.startColumn;return getShouldDisableCellLink(worksheet,row,col)},"getShouldDisableCurrentCellLink"),shouldDisableAddLink=__name(accessor=>{var _a2,_b2;const textSelectionService=accessor.get(docs.DocSelectionManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),textRanges=textSelectionService.getDocRanges();if(!textRanges.length||textRanges.length>1)return!0;const activeRange=textRanges[0],doc=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC);if(!doc||!activeRange||activeRange.collapsed)return!0;const body=doc.getSelfOrHeaderFooterModel(activeRange.segmentId).getBody();if(!body)return!0;const paragraphs=(_a2=body==null?void 0:body.paragraphs)!=null?_a2:[];for(let i=0,len=paragraphs.length;i<len;i++){const p2=paragraphs[i];if(activeRange.startOffset<=p2.startIndex&&activeRange.endOffset>p2.startIndex)return!0;if(p2.startIndex>activeRange.endOffset)break}return!core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(activeRange,(_b2=body.customRanges)!=null?_b2:[]).every(range=>range.rangeType===core.CustomRangeType.HYPERLINK)},"shouldDisableAddLink"),OpenHyperLinkEditPanelOperation={type:core.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(accessor,params){if(!params)return!1;const popupService=accessor.get(exports2.SheetsHyperLinkPopupService);return params.customRangeId?popupService.startEditing(params):popupService.startAddEditing(params),!0}},CloseHyperLinkPopupOperation={type:core.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(accessor){return accessor.get(exports2.SheetsHyperLinkPopupService).endEditing(),!0}},InsertHyperLinkOperation={type:core.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(accessor){var _a2;const univerInstanceService=accessor.get(core.IUniverInstanceService),target=sheets.getSheetCommandTarget(univerInstanceService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService);if(!target)return!1;const commandService=accessor.get(core.ICommandService),selection=accessor.get(sheets.SheetsSelectionsService).getCurrentLastSelection();if(!selection)return!1;const row=selection.range.startRow,col=selection.range.startColumn,visible=editorBridgeService.isVisible(),isZenEditor=((_a2=univerInstanceService.getFocusedUnit())==null?void 0:_a2.getUnitId())===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return commandService.executeCommand(OpenHyperLinkEditPanelOperation.id,{unitId:target.unitId,subUnitId:target.subUnitId,row,col,type:isZenEditor?HyperLinkEditSourceType.ZEN_EDITOR:visible.visible?HyperLinkEditSourceType.EDITING:HyperLinkEditSourceType.VIEWING})}},InsertHyperLinkToolbarOperation={type:core.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(accessor){if(getShouldDisableCurrentCellLink(accessor))return!1;const commandService=accessor.get(core.ICommandService);return accessor.get(exports2.SheetsHyperLinkPopupService).currentEditing?commandService.executeCommand(CloseHyperLinkPopupOperation.id):commandService.executeCommand(InsertHyperLinkOperation.id)}},getEditingLinkDisable$=__name((accessor,unitId=core.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var _a2;const univerInstanceService=accessor.get(core.IUniverInstanceService),docSelctionService=(_a2=accessor.get(engineRender.IRenderManagerService).getRenderById(unitId))==null?void 0:_a2.with(docsUi.DocSelectionRenderService);return docSelctionService?docSelctionService.textSelectionInner$.pipe(rxjs.map(()=>{const state=accessor.get(sheetsUi.IEditorBridgeService).getEditCellState();if(!state)return!0;const target=sheets.getSheetCommandTarget(univerInstanceService,{unitId:state.unitId,subUnitId:state.sheetId});return!(target!=null&&target.worksheet)||getShouldDisableCellLink(target.worksheet,state.row,state.column)?!0:shouldDisableAddLink(accessor)})):rxjs.of(!0)},"getEditingLinkDisable$"),getLinkDisable$=__name(accessor=>{const disableRange$=sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetInsertHyperlinkPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]},!0),univerInstanceService=accessor.get(core.IUniverInstanceService),sheetSelectionService=accessor.get(sheets.SheetsSelectionsService),editorBridgeService=accessor.has(sheetsUi.IEditorBridgeService)?accessor.get(sheetsUi.IEditorBridgeService):null,disableCell$=univerInstanceService.focused$.pipe(rxjs.filter(focused=>!!focused),rxjs.map(focused=>univerInstanceService.getUnit(focused,core.UniverInstanceType.UNIVER_SHEET)),rxjs.filter(unit=>!!unit),rxjs.switchMap(unit=>unit.activeSheet$),rxjs.switchMap(sheet=>sheetSelectionService.selectionMoveEnd$.pipe(rxjs.map(selections=>sheet&&{selections,sheet}))),rxjs.map(sheetWithSelection=>{if(!sheetWithSelection)return!0;const{selections,sheet}=sheetWithSelection;if(!selections.length)return!0;const row=selections[0].range.startRow,col=selections[0].range.startColumn;if(getShouldDisableCellLink(sheet,row,col))return!0}),rxjs.switchMap(disableCell=>disableCell?rxjs.of(!0):(editorBridgeService?editorBridgeService.visible$:rxjs.of(null)).pipe(rxjs.map(visible=>visible!=null&&visible.visible?core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)).pipe(rxjs.switchMap(editing=>editing?getEditingLinkDisable$(accessor,editing):rxjs.of(!1)))));return disableRange$.pipe(rxjs.distinctUntilChanged(),rxjs.switchMap(disableRange=>disableCell$.pipe(rxjs.map(disableCell=>disableRange||disableCell))))},"getLinkDisable$"),linkMenu={commandId:InsertHyperLinkOperation.id,type:ui.MenuItemType.BUTTON,positions:[ui.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",icon:"LinkSingle"},genZenEditorMenuId=__name(id=>`${id}-zen-editor`,"genZenEditorMenuId"),insertLinkMenuFactory=__name(accessor=>({...linkMenu,id:linkMenu.commandId,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:getLinkDisable$(accessor)}),"insertLinkMenuFactory"),zenEditorInsertLinkMenuFactory=__name(accessor=>({...linkMenu,id:genZenEditorMenuId(linkMenu.commandId),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:getEditingLinkDisable$(accessor)}),"zenEditorInsertLinkMenuFactory"),linkToolbarMenu={tooltip:"hyperLink.form.addTitle",positions:ui.MenuPosition.TOOLBAR_START,group:ui.MenuGroup.TOOLBAR_OTHERS,commandId:InsertHyperLinkToolbarOperation.id,type:ui.MenuItemType.BUTTON,icon:"LinkSingle"},insertLinkMenuToolbarFactory=__name(accessor=>({...linkToolbarMenu,id:linkToolbarMenu.commandId,hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:getLinkDisable$(accessor)}),"insertLinkMenuToolbarFactory"),zenEditorInsertLinkMenuToolbarFactory=__name(accessor=>({...linkToolbarMenu,id:genZenEditorMenuId(linkToolbarMenu.commandId),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC,core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:getEditingLinkDisable$(accessor)}),"zenEditorInsertLinkMenuToolbarFactory"),InsertLinkShortcut={id:InsertHyperLinkToolbarOperation.id,binding:ui.KeyCode.K|ui.MetaKeys.CTRL_COMMAND,preconditions:sheetsUi.whenSheetEditorFocused};var __defProp$9=Object.defineProperty,__getOwnPropDesc$9=Object.getOwnPropertyDescriptor,__decorateClass$9=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$9(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$9(target,key,result),result},"__decorateClass$9"),__decorateParam$9=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$9");let SheetsHyperLinkAutoFillController=(_d=class extends core.Disposable{constructor(_autoFillService,_hyperLinkModel){super(),this._autoFillService=_autoFillService,this._hyperLinkModel=_hyperLinkModel,this._initAutoFill()}_initAutoFill(){const noopReturnFunc=__name(()=>({redos:[],undos:[]}),"noopReturnFunc"),generalApplyFunc=__name((location2,applyType)=>{const{source:sourceRange,target:targetRange,unitId,subUnitId}=location2,virtualRange=sheetsUi.virtualizeDiscreteRanges([sourceRange,targetRange]),[vSourceRange,vTargetRange]=virtualRange.ranges,{mapFunc}=virtualRange,sourceStartCell={row:vSourceRange.startRow,col:vSourceRange.startColumn},repeats=sheetsUi.getAutoFillRepeatRange(vSourceRange,vTargetRange),redos=[],undos=[];return repeats.forEach(repeat=>{const targetStartCell=repeat.repeatStartCell,relativeRange=repeat.relativeRange,sourceRange2={startRow:sourceStartCell.row,startColumn:sourceStartCell.col,endColumn:sourceStartCell.col,endRow:sourceStartCell.row},targetRange2={startRow:targetStartCell.row,startColumn:targetStartCell.col,endColumn:targetStartCell.col,endRow:targetStartCell.row};core.Range.foreach(relativeRange,(row,col)=>{const sourcePositionRange=core.Rectangle.getPositionRange({startRow:row,startColumn:col,endColumn:col,endRow:row},sourceRange2),{row:sourceRow,col:sourceCol}=mapFunc(sourcePositionRange.startRow,sourcePositionRange.startColumn),link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,sourceRow,sourceCol),targetPositionRange=core.Rectangle.getPositionRange({startRow:row,startColumn:col,endColumn:col,endRow:row},targetRange2),{row:targetRow,col:targetCol}=mapFunc(targetPositionRange.startRow,targetPositionRange.startColumn),id=core.Tools.generateRandomId(),currentLink=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,targetRow,targetCol);currentLink&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:currentLink.id}}),(sheetsUi.APPLY_TYPE.COPY===applyType||sheetsUi.APPLY_TYPE.SERIES===applyType)&&link&&(redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:{...link,id,row:targetRow,column:targetCol}}}),undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id}})),currentLink&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:currentLink}})})}),{undos,redos}},"generalApplyFunc"),hook={id:SHEET_HYPER_LINK_UI_PLUGIN,onFillData:__name((location2,direction,applyType)=>applyType===sheetsUi.APPLY_TYPE.COPY||applyType===sheetsUi.APPLY_TYPE.ONLY_FORMAT||applyType===sheetsUi.APPLY_TYPE.SERIES?generalApplyFunc(location2,applyType):noopReturnFunc(),"onFillData")};this.disposeWithMe(this._autoFillService.addHook(hook))}},__name(_d,"SheetsHyperLinkAutoFillController"),_d);SheetsHyperLinkAutoFillController=__decorateClass$9([__decorateParam$9(0,sheetsUi.IAutoFillService),__decorateParam$9(1,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkAutoFillController);var __defProp$8=Object.defineProperty,__getOwnPropDesc$8=Object.getOwnPropertyDescriptor,__decorateClass$8=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$8(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$8(target,key,result),result},"__decorateClass$8"),__decorateParam$8=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$8");let SheetsHyperLinkPermissionController=(_e=class extends core.Disposable{constructor(_localeService,_commandService,_sheetPermissionInterceptorBaseController){super(),this._localeService=_localeService,this._commandService=_commandService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(command=>{command.id===InsertLinkShortcut.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookEditablePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}},__name(_e,"SheetsHyperLinkPermissionController"),_e);SheetsHyperLinkPermissionController=__decorateClass$8([__decorateParam$8(0,core.Inject(core.LocaleService)),__decorateParam$8(1,core.ICommandService),__decorateParam$8(2,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController))],SheetsHyperLinkPermissionController);var __defProp$7=Object.defineProperty,__getOwnPropDesc$7=Object.getOwnPropertyDescriptor,__decorateClass$7=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$7(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$7(target,key,result),result},"__decorateClass$7"),__decorateParam$7=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$7");let SheetsHyperLinkPopupController=(_f=class extends core.Disposable{constructor(_hoverManagerService,_sheetsHyperLinkPopupService,_renderManagerService,_permissionService,_sheetPermissionInterceptorBaseController,_commandService,_editorBridgeService,_textSelectionManagerService,_univerInstanceService,_zenZoneService){super(),this._hoverManagerService=_hoverManagerService,this._sheetsHyperLinkPopupService=_sheetsHyperLinkPopupService,this._renderManagerService=_renderManagerService,this._permissionService=_permissionService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._commandService=_commandService,this._editorBridgeService=_editorBridgeService,this._textSelectionManagerService=_textSelectionManagerService,this._univerInstanceService=_univerInstanceService,this._zenZoneService=_zenZoneService,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(location2){const{unitId,subUnitId,row:currentRow,col:currentCol}=location2,workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!(workbook==null?void 0:workbook.getSheetBySheetId(subUnitId)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const viewPermission=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookViewPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:currentRow,startColumn:currentCol,endRow:currentRow,endColumn:currentCol}]),editPermission=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetInsertHyperlinkPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]},[{startRow:currentRow,startColumn:currentCol,endRow:currentRow,endColumn:currentCol}]),copyPermission=this._permissionService.composePermission([new sheets.WorkbookCopyPermission(unitId).id,new sheets.WorksheetCopyPermission(unitId,subUnitId).id]).every(permission=>permission.value);return{viewPermission,editPermission,copyPermission}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(rxjs.debounceTime(200)).subscribe(currentCell=>{var _a2;if(!currentCell){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId,subUnitId,row,col}=currentCell,renderer=this._renderManagerService.getRenderById(unitId);if(!renderer)return;if(!renderer.with(sheetsUi.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING);return}const skeleton=(_a2=renderer==null?void 0:renderer.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId))==null?void 0:_a2.skeleton,currentCol=col,currentRow=row;let targetRow=currentRow,targetCol=currentCol;skeleton&&skeleton.overflowCache.forValue((row2,col2,value)=>{core.Rectangle.contains(value,{startColumn:currentCol,endColumn:currentCol,startRow:currentRow,endRow:currentRow})&&(targetRow=row2,targetCol=col2)});const{viewPermission,editPermission,copyPermission}=this._getLinkPermission(currentCell);if(!viewPermission||!currentCell.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:targetRow,col:targetCol,editPermission,copyPermission,customRange:currentCell.customRange,customRangeRect:currentCell.rect,type:HyperLinkEditSourceType.VIEWING,unitId,subUnitId})}))}_initHoverEditingListener(){let subscribe=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(rxjs.switchMap(state=>this._editorBridgeService.visible$.pipe(rxjs.map(visible=>({visible,state}))))).subscribe(({visible,state})=>{if(!state||state.editorUnitId!==core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!visible.visible){subscribe==null||subscribe.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING),this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING);return}const{editorUnitId,unitId,sheetId,row,column}=state,renderer=this._renderManagerService.getRenderById(editorUnitId);if(!renderer)return;const{editPermission,viewPermission,copyPermission}=this._getLinkPermission({unitId,subUnitId:sheetId,row,col:column}),docEventService=renderer.with(docsUi.DocEventManagerService);viewPermission&&(subscribe==null||subscribe.unsubscribe(),subscribe=docEventService.hoverCustomRanges$.pipe(rxjs.debounceTime(200)).subscribe(customRanges=>{var _a2,_b2;const customRange=customRanges.find(customRange2=>customRange2.range.rangeType===core.CustomRangeType.HYPERLINK);if(!customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const rect=customRange.rects[customRange.rects.length-1];if(!((_b2=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(sheetId))==null?void 0:_b2.skeleton)||!rect)return;const canvasClientRect=renderer.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId,subUnitId:sheetId,row,col:column,customRange:customRange.range,customRangeRect:{left:rect.left+canvasClientRect.left,top:rect.top+canvasClientRect.top,bottom:rect.bottom+canvasClientRect.top,right:rect.right+canvasClientRect.left},editPermission,copyPermission,type:HyperLinkEditSourceType.EDITING})}))})),this.disposeWithMe(()=>{subscribe==null||subscribe.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(visible=>{visible?(this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.EDITING),this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(rxjs.switchMap(id=>{const render2=id===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(id):null;return render2?render2.with(docsUi.DocEventManagerService).hoverCustomRanges$.pipe(rxjs.debounceTime(200)):new rxjs.Observable(sub=>{sub.next(null)})})).subscribe(value=>{const range=value==null?void 0:value.find(range2=>range2.range.rangeType===core.CustomRangeType.HYPERLINK),state=this._editorBridgeService.getEditCellState();if(range&&state){const{unitId,sheetId,row,column}=state,{editPermission,viewPermission,copyPermission}=this._getLinkPermission({unitId,subUnitId:sheetId,row,col:column});viewPermission&&this._sheetsHyperLinkPopupService.showPopup({type:HyperLinkEditSourceType.ZEN_EDITOR,unitId,subUnitId:sheetId,row,col:column,customRange:range.range,editPermission,copyPermission})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(HyperLinkEditSourceType.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(selection=>{selection&&selection.unitId===core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(HyperLinkEditSourceType.EDITING)}))}_initCommandListener(){const HIDE_COMMAND_LIST=[sheets.ClearSelectionContentCommand.id,sheets.ClearSelectionAllCommand.id,sheets.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(command=>{HIDE_COMMAND_LIST.includes(command.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}},__name(_f,"SheetsHyperLinkPopupController"),_f);SheetsHyperLinkPopupController=__decorateClass$7([__decorateParam$7(0,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$7(1,core.Inject(exports2.SheetsHyperLinkPopupService)),__decorateParam$7(2,core.Inject(engineRender.IRenderManagerService)),__decorateParam$7(3,core.Inject(core.IPermissionService)),__decorateParam$7(4,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController)),__decorateParam$7(5,core.ICommandService),__decorateParam$7(6,sheetsUi.IEditorBridgeService),__decorateParam$7(7,core.Inject(docs.DocSelectionManagerService)),__decorateParam$7(8,core.IUniverInstanceService),__decorateParam$7(9,ui.IZenZoneService)],SheetsHyperLinkPopupController);var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6");let SheetsHyperLinkRemoveSheetController=(_g=class extends core.Disposable{constructor(_sheetInterceptorService,_univerInstanceService,_hyperLinkModel){super(),this._sheetInterceptorService=_sheetInterceptorService,this._univerInstanceService=_univerInstanceService,this._hyperLinkModel=_hyperLinkModel,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{var _a2;if(commandInfo.id===sheets.RemoveSheetCommand.id){const params=commandInfo.params,workbook=params.unitId?this._univerInstanceService.getUnit(params.unitId):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return{redos:[],undos:[]};const unitId=workbook.getUnitId(),subUnitId=params.subUnitId||((_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId());if(!subUnitId)return{redos:[],undos:[]};const links=this._hyperLinkModel.getSubUnit(unitId,subUnitId),redos=links.map(link=>({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}})),undos=links.map(link=>({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}));return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}},__name(_g,"SheetsHyperLinkRemoveSheetController"),_g);SheetsHyperLinkRemoveSheetController=__decorateClass$6([__decorateParam$6(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$6(1,core.IUniverInstanceService),__decorateParam$6(2,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkRemoveSheetController);var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");let SheetsHyperLinkRenderController=(_h=class extends core.Disposable{constructor(_context,_hyperLinkModel){super(),this._context=_context,this._hyperLinkModel=_hyperLinkModel,this._initSkeletonChange()}_initSkeletonChange(){const markSkeletonDirty=__name(()=>{var _a2;(_a2=this._context.mainComponent)==null||_a2.makeForceDirty()},"markSkeletonDirty");this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(rxjs.debounceTime(16)).subscribe(()=>{markSkeletonDirty()}))}},__name(_h,"SheetsHyperLinkRenderController"),_h);SheetsHyperLinkRenderController=__decorateClass$5([__decorateParam$5(1,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkRenderController);let SheetsHyperLinkRenderManagerController=(_i=class extends core.Disposable{constructor(_sheetInterceptorService,_hyperLinkModel){super(),this._sheetInterceptorService=_sheetInterceptorService,this._hyperLinkModel=_hyperLinkModel,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{effect:core.InterceptorEffectEnum.Value,priority:100,handler:__name((cell,pos,next)=>{const{row,col,unitId,subUnitId}=pos,link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);return next(link?{...cell,linkUrl:link.payload,linkId:link.id}:cell)},"handler")}))}},__name(_i,"SheetsHyperLinkRenderManagerController"),_i);SheetsHyperLinkRenderManagerController=__decorateClass$5([__decorateParam$5(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$5(1,core.Inject(sheetsHyperLink.HyperLinkModel))],SheetsHyperLinkRenderManagerController);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let SheetsHyperLinkRichTextRefRangeController=(_j=class extends core.Disposable{constructor(_commandService,_univerInstanceService,_refRangeService){super();__publicField(this,"_refRangeMap",new Map);this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._refRangeService=_refRangeService,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(unitId,subUnitId){let unitMap=this._refRangeMap.get(unitId);unitMap||(unitMap=new Map,this._refRangeMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new core.ObjectMatrix,unitMap.set(subUnitId,subUnitMap)),subUnitMap}_isLegalRangeUrl(unitId,payload){var _a2,_b2,_c2;const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return null;if(payload&&payload.startsWith("#")){const search=new URLSearchParams(payload.slice(1)),searchObj={gid:(_a2=search.get("gid"))!=null?_a2:"",range:(_b2=search.get("range"))!=null?_b2:"",rangeid:(_c2=search.get("rangeid"))!=null?_c2:""};if(searchObj.range&&searchObj.gid){const subUnitId=searchObj.gid,worksheet=workbook.getSheetBySheetId(subUnitId);if(!worksheet)return null;const range=engineFormula.deserializeRangeWithSheet(searchObj.range).range;if(core.isValidRange(range,worksheet)&&searchObj.range!==sheetsHyperLink.ERROR_RANGE)return range}}return null}_registerRange(unitId,subUnitId,row,col,p2){var _a2,_b2,_c2,_d2;const map=this._enusreMap(unitId,subUnitId);if((_b2=(_a2=p2.body)==null?void 0:_a2.customRanges)!=null&&_b2.some(customRange=>{var _a3;return customRange.rangeType===core.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(unitId,(_a3=customRange.properties)==null?void 0:_a3.url)})){const disposableCollection=new core.DisposableCollection;(_d2=(_c2=p2.body)==null?void 0:_c2.customRanges)==null||_d2.forEach(customRange=>{var _a3;if(customRange.rangeType===core.CustomRangeType.HYPERLINK){const payload=(_a3=customRange.properties)==null?void 0:_a3.url,range=this._isLegalRangeUrl(unitId,payload);range&&disposableCollection.add(this._refRangeService.watchRange(unitId,subUnitId,range,(before,after)=>{customRange.properties.url=`#gid=${subUnitId}&range=${after?engineFormula.serializeRange(after):sheetsHyperLink.ERROR_RANGE}`}))}}),map.setValue(row,col,disposableCollection)}}_initWorkbookLoad(){const handleWorkbook=__name(workbook=>{const unitId=workbook.getUnitId();workbook.getSheets().forEach(sheet=>{const subUnitId=sheet.getSheetId(),map=this._enusreMap(unitId,subUnitId);sheet.getCellMatrix().forValue((row,col,cell)=>{const dispose=map.getValue(row,col);dispose&&dispose.dispose(),cell&&cell.p&&this._registerRange(unitId,subUnitId,row,col,cell.p)})})},"handleWorkbook");this._univerInstanceService.getAllUnitsForType(core.UniverInstanceType.UNIVER_SHEET).forEach(workbook=>{handleWorkbook(workbook)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(unit=>{unit.type===core.UniverInstanceType.UNIVER_SHEET&&handleWorkbook(unit)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(unit=>{if(unit.type===core.UniverInstanceType.UNIVER_SHEET){const workbook=unit,unitId=workbook.getUnitId();workbook.getSheets().forEach(sheet=>{const subUnitId=sheet.getSheetId();this._enusreMap(unitId,subUnitId).forValue((row,col,dispose)=>{dispose&&dispose.dispose()})}),this._refRangeMap.delete(unitId)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{if(commandInfo.id===sheets.SetRangeValuesMutation.id){const params=commandInfo.params,{unitId,subUnitId,cellValue}=params,map=this._enusreMap(unitId,subUnitId);cellValue&&new core.ObjectMatrix(cellValue).forValue((row,col,cell)=>{const dispose=map.getValue(row,col);dispose&&dispose.dispose(),cell&&cell.p&&this._registerRange(unitId,subUnitId,row,col,cell.p)})}}))}},__name(_j,"SheetsHyperLinkRichTextRefRangeController"),_j);SheetsHyperLinkRichTextRefRangeController=__decorateClass$4([__decorateParam$4(0,core.ICommandService),__decorateParam$4(1,core.IUniverInstanceService),__decorateParam$4(2,core.Inject(sheets.RefRangeService))],SheetsHyperLinkRichTextRefRangeController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let SheetHyperLinkSetRangeController=(_k=class extends core.Disposable{constructor(_sheetInterceptorService,_hyperLinkModel,_selectionManagerService,_univerInstanceService,_editorBridgeService,_renderManagerService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._hyperLinkModel=_hyperLinkModel,this._selectionManagerService=_selectionManagerService,this._univerInstanceService=_univerInstanceService,this._editorBridgeService=_editorBridgeService,this._renderManagerService=_renderManagerService,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{if(command.id===sheets.SetRangeValuesCommand.id){const params=command.params,{unitId,subUnitId}=params,redos=[],undos=[];return params.cellValue&&new core.ObjectMatrix(params.cellValue).forValue((row,col)=>{const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);link&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}))}),{undos,redos}}return{redos:[],undos:[]}},"getMutations")}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{if(command.id===sheets.ClearSelectionContentCommand.id||command.id===sheets.ClearSelectionAllCommand.id||command.id===sheets.ClearSelectionFormatCommand.id){const redos=[],undos=[],selection=this._selectionManagerService.getCurrentLastSelection(),target=sheets.getSheetCommandTarget(this._univerInstanceService);if(selection&&target){const{unitId,subUnitId}=target;core.Range.foreach(selection.range,(row,col)=>{const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);link&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}))})}return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}_initAfterEditor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:__name((cell,context,next)=>{if(!cell||cell.p)return next(cell);if(typeof cell.v=="string"&&core.Tools.isLegalUrl(cell.v)&&cell.v[cell.v.length-1]!==" "){const{unitId,subUnitId}=context,renderer=this._renderManagerService.getRenderById(unitId),skeleton=renderer==null?void 0:renderer.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);if(!skeleton)return next(cell);const doc=skeleton.skeleton.getBlankCellDocumentModel(cell);if(!doc.documentModel)return next(cell);const textX=core.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:cell.v.length,collapsed:!1},body:{dataStream:`${core.DataStreamTreeTokenType.CUSTOM_RANGE_START}${cell.v}${core.DataStreamTreeTokenType.CUSTOM_RANGE_END}`,customRanges:[{startIndex:0,endIndex:cell.v.length+1,rangeId:core.generateRandomId(),rangeType:core.CustomRangeType.HYPERLINK,properties:{url:cell.v}}]},doc:doc.documentModel});if(!textX)return next(cell);const body=doc.documentModel.getBody();return core.TextX.apply(body,textX.serialize()),next({...cell,p:{id:core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return next(cell)},"handler")}))}},__name(_k,"SheetHyperLinkSetRangeController"),_k);SheetHyperLinkSetRangeController=__decorateClass$3([__decorateParam$3(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$3(1,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$3(2,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$3(3,core.IUniverInstanceService),__decorateParam$3(4,sheetsUi.IEditorBridgeService),__decorateParam$3(5,engineRender.IRenderManagerService)],SheetHyperLinkSetRangeController);const menuSchema={[ui.RibbonStartGroup.OTHERS]:{[InsertHyperLinkToolbarOperation.id]:{order:2,menuItemFactory:insertLinkMenuToolbarFactory},[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]:{order:2,menuItemFactory:zenEditorInsertLinkMenuToolbarFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{order:1,[InsertHyperLinkToolbarOperation.id]:{order:0,menuItemFactory:insertLinkMenuFactory},[genZenEditorMenuId(InsertHyperLinkToolbarOperation.id)]:{order:0,menuItemFactory:zenEditorInsertLinkMenuFactory}}}};var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let SheetsHyperLinkUIController=(_l=class extends core.Disposable{constructor(_componentManager,_commandService,_menuManagerService,_injector,_shortcutService){super(),this._componentManager=_componentManager,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._injector=_injector,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[CellLinkPopup,CellLinkPopup.componentKey],[CellLinkEdit,CellLinkEdit.componentKey],[LinkSingle,"LinkSingle"]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[OpenHyperLinkEditPanelOperation,CloseHyperLinkPopupOperation,InsertHyperLinkOperation,InsertHyperLinkToolbarOperation,AddHyperLinkCommand,UpdateHyperLinkCommand,CancelHyperLinkCommand,UpdateRichHyperLinkCommand,CancelRichHyperLinkCommand,AddRichHyperLinkCommand].forEach(command=>{this._commandService.registerCommand(command)})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initShortCut(){this._shortcutService.registerShortcut(InsertLinkShortcut)}},__name(_l,"SheetsHyperLinkUIController"),_l);SheetsHyperLinkUIController=__decorateClass$2([__decorateParam$2(0,core.Inject(ui.ComponentManager)),__decorateParam$2(1,core.ICommandService),__decorateParam$2(2,ui.IMenuManagerService),__decorateParam$2(3,core.Inject(core.Injector)),__decorateParam$2(4,core.Inject(ui.IShortcutService))],SheetsHyperLinkUIController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let SheetHyperLinkUrlController=(_m=class extends core.Disposable{constructor(_resolverService){super(),this._resolverService=_resolverService,this._handleInitUrl()}_handleInitUrl(){const hash=location.hash;hash&&this._resolverService.parseHyperLink(hash).handler()}},__name(_m,"SheetHyperLinkUrlController"),_m);SheetHyperLinkUrlController=__decorateClass$1([__decorateParam$1(0,core.Inject(exports2.SheetsHyperLinkResolverService))],SheetHyperLinkUrlController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsHyperLinkUIPlugin=(_n=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[exports2.SheetsHyperLinkResolverService],[exports2.SheetsHyperLinkPopupService],[SheetsHyperLinkSidePanelService],[SheetsHyperLinkRemoveSheetController],[SheetsHyperLinkRenderManagerController],[SheetHyperLinkSetRangeController],[SheetsHyperLinkPopupController],[SheetsHyperLinkUIController],[SheetsHyperLinkAutoFillController],[exports2.SheetsHyperLinkCopyPasteController],[SheetsHyperLinkPermissionController],[SheetHyperLinkUrlController],[SheetsHyperLinkRichTextRefRangeController]].forEach(dep=>this._injector.add(dep)),this._injector.get(SheetsHyperLinkRenderManagerController),this._injector.get(SheetsHyperLinkRichTextRefRangeController),this._injector.get(SheetHyperLinkSetRangeController)}onReady(){this._injector.get(engineRender.IRenderManagerService).registerRenderModule(core.UniverInstanceType.UNIVER_SHEET,[SheetsHyperLinkRenderController]),this._injector.get(SheetsHyperLinkAutoFillController),this._injector.get(exports2.SheetsHyperLinkCopyPasteController),this._injector.get(SheetsHyperLinkRemoveSheetController),this._injector.get(SheetsHyperLinkUIController)}onRendered(){this._injector.get(SheetsHyperLinkPermissionController),this._injector.get(SheetHyperLinkUrlController),this._injector.get(SheetsHyperLinkPopupController)}},__name(_n,"UniverSheetsHyperLinkUIPlugin"),_n),__publicField2(exports2.UniverSheetsHyperLinkUIPlugin,"pluginName",SHEET_HYPER_LINK_UI_PLUGIN),__publicField2(exports2.UniverSheetsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsHyperLinkUIPlugin=__decorateClass([core.DependentOn(sheetsHyperLink.UniverSheetsHyperLinkPlugin,docsUi.UniverDocsUIPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverSheetsHyperLinkUIPlugin),exports2.AddHyperLinkCommand=AddHyperLinkCommand,exports2.CancelHyperLinkCommand=CancelHyperLinkCommand,exports2.CloseHyperLinkPopupOperation=CloseHyperLinkPopupOperation,exports2.InsertHyperLinkOperation=InsertHyperLinkOperation,exports2.InsertLinkShortcut=InsertLinkShortcut,exports2.OpenHyperLinkEditPanelOperation=OpenHyperLinkEditPanelOperation,exports2.SheetsHyperLinkSidePanelService=SheetsHyperLinkSidePanelService,exports2.UpdateHyperLinkCommand=UpdateHyperLinkCommand,Object.defineProperty(exports2,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"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiEnUS=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"Edit Link",addTitle:"Insert Link",label:"Label",type:"Type",link:"Link",linkPlaceholder:"Enter link",range:"Range",worksheet:"Worksheet",definedName:"Defined Name",ok:"Confirm",cancel:"Cancel",labelPlaceholder:"Enter label",inputError:"Please enter",selectError:"Please select",linkError:"Please enter a legal link"},menu:{add:"Insert Link"},message:{noSheet:"Target sheet has been delete",refError:"Invalid Range",hiddenSheet:"Cannot open the link because the linked sheet is hidden",coped:"Link copied to clipboard"},popup:{copy:"Copy Link",edit:"Edit Link",cancel:"Cancel Link"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiFaIR=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"ویرایش لینک",addTitle:"درج لینک",label:"برچسب",type:"نوع",link:"لینک",linkPlaceholder:"لینک را وارد کنید",range:"محدوده",worksheet:"برگ کار",definedName:"نام تعریف شده",ok:"تایید",cancel:"انصراف",labelPlaceholder:"برچسب را وارد کنید",inputError:"لطفا وارد کنید",selectError:"لطفا انتخاب کنید",linkError:"لطفا یک لینک معتبر وارد کنید"},menu:{add:"درج لینک"},message:{noSheet:"برگ هدف حذف شده است",refError:"محدوده نامعتبر",hiddenSheet:"نمیتوان لینک را باز کرد زیرا برگ مرتبط پنهان است",coped:"لینک به کلیپ بورد کپی شد"},popup:{copy:"کپی لینک",edit:"ویرایش لینک",cancel:"لینک را لغو کنید"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiRuRU=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"Редактировать ссылку",addTitle:"Вставить ссылку",label:"Метка",type:"Тип",link:"Ссылка",linkPlaceholder:"Введите ссылку",range:"Диапазон",worksheet:"Лист",definedName:"Определенное имя",ok:"ОК",cancel:"Отмена",labelPlaceholder:"Введите метку",inputError:"Пожалуйста, введите",selectError:"Пожалуйста, выберите",linkError:"Пожалуйста, введите корректную ссылку"},menu:{add:"Вставить ссылку"},message:{noSheet:"Целевой лист был удален",refError:"Недопустимый диапазон",hiddenSheet:"Невозможно открыть ссылку, так как связанный лист скрыт",coped:"Ссылка скопирована в буфер обмена"},popup:{copy:"Копировать ссылку",edit:"Редактировать ссылку",cancel:"Отменить ссылку"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(n,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(n=typeof globalThis<"u"?globalThis:n||self,n.UniverSheetsHyperLinkUiViVN=e())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"Chỉnh sửa liên kết",addTitle:"Chèn liên kết",label:"Văn bản",labelPlaceholder:"Nhập văn bản",type:"Loại",link:"Liên kết",linkPlaceholder:"Nhập địa chỉ liên kết",range:"Ô",worksheet:"Bảng tính",definedName:"Tên đã xác định",ok:"Xác nhận",cancel:"Hủy",inputError:"Vui lòng nhập",selectError:"Vui lòng chọn",linkError:"Vui lòng nhập liên kết hợp lệ"},menu:{add:"Thêm liên kết"},message:{noSheet:"Bảng con này đã bị xóa",refError:"Tham chiếu lỗi",hiddenSheet:"Không thể mở bảng con bị ẩn",coped:"Liên kết đã được sao chép vào clipboard"},popup:{copy:"Sao chép",edit:"Chỉnh sửa",cancel:"Hủy liên kết"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiZhCN=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"编辑链接",addTitle:"插入链接",label:"文本",labelPlaceholder:"输入文本",type:"类型",link:"链接",linkPlaceholder:"输入链接地址",range:"单元格",worksheet:"工作表",definedName:"定义的名称",ok:"确认",cancel:"取消",inputError:"请输入",selectError:"请选择",linkError:"请输入合法的链接"},menu:{add:"添加链接"},message:{noSheet:"该子表已被删除",refError:"错误的引用",hiddenSheet:"无法打开被隐藏的子表",coped:"链接已被复制到剪贴板"},popup:{copy:"复制",edit:"编辑",cancel:"取消链接"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsHyperLinkUiZhTW=n())})(this,function(){"use strict";return{hyperLink:{form:{editTitle:"編輯連結",addTitle:"插入連結",label:"文本",labelPlaceholder:"輸入文字",type:"類型",link:"連結",linkPlaceholder:"輸入連結位址",range:"單元格",worksheet:"工作表",definedName:"定義的名稱",ok:"確認",cancel:"取消",inputError:"請輸入",selectError:"請選擇",linkError:"請輸入合法的連結"},menu:{add:"新增連結"},message:{noSheet:"該子表已被刪除",refError:"錯誤的引用",hiddenSheet:"無法開啟被隱藏的子表",coped:"連結已複製到剪貼簿"},popup:{copy:"複製",edit:"編輯",cancel:"取消連結"}}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-hyper-link-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -31,11 +31,19 @@
|
|
|
31
31
|
"require": "./lib/cjs/*",
|
|
32
32
|
"types": "./lib/types/index.d.ts"
|
|
33
33
|
},
|
|
34
|
-
"./
|
|
35
|
-
|
|
34
|
+
"./facade": {
|
|
35
|
+
"import": "./lib/es/facade.js",
|
|
36
|
+
"require": "./lib/cjs/facade.js",
|
|
37
|
+
"types": "./lib/types/facade/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./locale/*": {
|
|
40
|
+
"import": "./lib/es/locale/*.js",
|
|
41
|
+
"require": "./lib/cjs/locale/*.js",
|
|
42
|
+
"types": "./lib/types/locale/*.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./lib/*": "./lib/*"
|
|
36
45
|
},
|
|
37
|
-
"main": "./lib/
|
|
38
|
-
"module": "./lib/es/index.js",
|
|
46
|
+
"main": "./lib/es/index.js",
|
|
39
47
|
"types": "./lib/types/index.d.ts",
|
|
40
48
|
"publishConfig": {
|
|
41
49
|
"access": "public"
|
|
@@ -51,28 +59,29 @@
|
|
|
51
59
|
"rxjs": ">=7.0.0"
|
|
52
60
|
},
|
|
53
61
|
"dependencies": {
|
|
54
|
-
"@univerjs/icons": "^0.
|
|
62
|
+
"@univerjs/icons": "^0.2.5",
|
|
55
63
|
"clsx": "^2.1.1",
|
|
56
|
-
"@univerjs/core": "0.
|
|
57
|
-
"@univerjs/docs": "0.
|
|
58
|
-
"@univerjs/docs-
|
|
59
|
-
"@univerjs/docs-
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/engine-
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/sheets-hyper-link": "0.
|
|
64
|
-
"@univerjs/sheets
|
|
65
|
-
"@univerjs/sheets-ui": "0.
|
|
66
|
-
"@univerjs/ui": "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"
|
|
67
75
|
},
|
|
68
76
|
"devDependencies": {
|
|
77
|
+
"react": "18.3.1",
|
|
69
78
|
"rxjs": "^7.8.1",
|
|
70
79
|
"typescript": "^5.6.3",
|
|
71
|
-
"vite": "^5.4.
|
|
72
|
-
"vitest": "^2.1.
|
|
73
|
-
"@univerjs-infra/shared": "0.
|
|
80
|
+
"vite": "^5.4.11",
|
|
81
|
+
"vitest": "^2.1.5",
|
|
82
|
+
"@univerjs-infra/shared": "0.5.0-beta.0"
|
|
74
83
|
},
|
|
75
|
-
"
|
|
84
|
+
"space": {
|
|
76
85
|
".": {
|
|
77
86
|
"import": "./lib/es/index.js",
|
|
78
87
|
"require": "./lib/cjs/index.js",
|
|
@@ -83,14 +92,24 @@
|
|
|
83
92
|
"require": "./lib/cjs/*",
|
|
84
93
|
"types": "./lib/types/index.d.ts"
|
|
85
94
|
},
|
|
86
|
-
"./
|
|
87
|
-
|
|
95
|
+
"./facade": {
|
|
96
|
+
"import": "./lib/es/facade.js",
|
|
97
|
+
"require": "./lib/cjs/facade.js",
|
|
98
|
+
"types": "./lib/types/facade/index.d.ts"
|
|
99
|
+
},
|
|
100
|
+
"./locale/*": {
|
|
101
|
+
"import": "./lib/es/locale/*.js",
|
|
102
|
+
"require": "./lib/cjs/locale/*.js",
|
|
103
|
+
"types": "./lib/types/locale/*.d.ts"
|
|
104
|
+
},
|
|
105
|
+
"./lib/*": "./lib/*"
|
|
88
106
|
},
|
|
89
107
|
"scripts": {
|
|
90
108
|
"test": "vitest run",
|
|
91
109
|
"test:watch": "vitest",
|
|
92
110
|
"coverage": "vitest run --coverage",
|
|
93
111
|
"lint:types": "tsc --noEmit",
|
|
94
|
-
"build": "
|
|
95
|
-
}
|
|
112
|
+
"build": "univer-cli build"
|
|
113
|
+
},
|
|
114
|
+
"module": "./lib/es/index.js"
|
|
96
115
|
}
|