@univerjs/preset-sheets-hyper-link 0.20.0 → 0.21.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.
Files changed (2) hide show
  1. package/lib/umd/index.js +2 -2
  2. package/package.json +5 -5
package/lib/umd/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // @univerjs/sheets-hyper-link/index
2
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/docs`),require(`@univerjs/sheets`),require(`rxjs`),require(`@univerjs/engine-formula`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/sheets`,`rxjs`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLink={},e.UniverCore,e.UniverDocs,e.UniverSheets,e.rxjs,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let f=class extends t.Disposable{constructor(e){super(),this._univerInstanceService=e,l(this,`_linkUpdate$`,new i.Subject),l(this,`linkUpdate$`,this._linkUpdate$.asObservable()),l(this,`_linkMap`,new Map),l(this,`_linkPositionMap`,new Map),this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let r=this._linkMap.get(e);r||(r=new Map,this._linkMap.set(e,r));let i=r.get(n);i||(i=new t.ObjectMatrix,r.set(n,i));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let o=a.get(n);return o||(o=new Map,a.set(n,o)),{matrix:i,positionMap:o}}addHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t);return r.setValue(n.row,n.column,n),i.set(n.id,{row:n.row,column:n.column,link:n}),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:n,type:`add`}),!0}updateHyperLink(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return c?(Object.assign(c,r),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:{display:c.display,payload:c.payload},id:n,type:`update`,silent:i}),!0):!0}updateHyperLinkRef(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return!c||c.id!==n?c=s.link:a.realDeleteValue(s.row,s.column),Object.assign(c,r),o.set(n,{...r,link:c}),a.setValue(r.row,r.column,c),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:r,id:n,type:`updateRef`,silent:i}),!0}removeHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(!a)return!1;i.delete(n);let o=r.getValue(a.row,a.column);return o&&o.id===n&&r.realDeleteValue(a.row,a.column),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:a.link,type:`remove`}),!0}getHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(a)return r.getValue(a.row,a.column)}getHyperLinkByLocation(e,t,n,r){let{matrix:i}=this._ensureMap(e,t);return i.getValue(n,r)}getHyperLinkByLocationSync(e,n,r,i){var a,o,s,c;let{matrix:l}=this._ensureMap(e,n),u=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),d=u==null||(a=u.getSheetBySheetId(n))==null?void 0:a.getCellRaw(r,i),f=((o=(s=d==null?void 0:d.v)==null?d==null||(c=d.p)==null||(c=c.body)==null?void 0:c.dataStream.slice(0,-2):s)==null?``:o).toString(),p=l.getValue(r,i);if(p)return{...p,display:f}}getSubUnit(e,t){let{matrix:n}=this._ensureMap(e,t),r=[];return n.forValue((e,t,n)=>{n&&r.push(n)}),r}getUnit(e){let t=this._linkMap.get(e);return t?Array.from(t.keys()).map(t=>({unitId:e,subUnitId:t,links:this.getSubUnit(e,t)})):[]}deleteUnit(e){let t=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:`unload`,unitId:e,unitLinks:t})}getAll(){return Array.from(this._linkMap.keys()).map(e=>this.getUnit(e))}};f=d([u(0,t.IUniverInstanceService)],f);let p={type:t.CommandType.MUTATION,id:`sheets.mutation.add-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,link:a}=t;return n.addHyperLink(r,i,a)}},m={type:t.CommandType.MUTATION,id:`sheets.mutation.remove-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a}=t;return n.removeHyperLink(r,i,a)}},h={type:t.CommandType.COMMAND,id:`sheets.command.add-hyper-link`,async handler(e,n){if(!n)return!1;let i=e.get(t.ICommandService),a=e.get(t.IUndoRedoService),o=e.get(t.IUniverInstanceService),s=e.get(f),c=e.get(r.SheetInterceptorService),l=(0,r.getSheetCommandTarget)(o,n);if(!l)return!1;let{unitId:u,subUnitId:d,workbook:h,worksheet:g}=l,{link:_}=n,{payload:v,display:y,row:b,column:x,id:S}=_,C=g.getCell(b,x),w=g.getBlankCellDocumentModel(C,b,x),T=w.documentModel.getSnapshot(),E=t.Tools.deepClone(T.body);if(!E)return!1;let D;if(D=y?t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:E.dataStream.length-2,collapsed:E.dataStream.length-2==0},body:{dataStream:`${y}`,customRanges:[{startIndex:0,endIndex:y.length-1,rangeType:t.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:v}}]},doc:w.documentModel}):t.BuildTextUtils.customRange.add({body:E,ranges:[{startOffset:0,endOffset:E.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:v,refId:S}}),!D)return!1;let O=t.TextX.apply(E,D.serialize()),k={p:{...T,body:O},t:t.CellValueType.STRING},A=c.onWriteCell(h,g,b,x,k),j={unitId:u,subUnitId:d,cellValue:{[_.row]:{[_.column]:A}}},M={id:r.SetRangeValuesMutation.id,params:j},N=(0,r.SetRangeValuesUndoMutationFactory)(e,j),P={id:r.SetRangeValuesMutation.id,params:N},F=[M],I=[P],L=s.getHyperLinkByLocation(u,d,b,x);return L&&(F.push({id:m.id,params:{unitId:u,subUnitId:d,id:L.id}}),I.push({id:p.id,params:{unitId:u,subUnitId:d,link:L}})),await(0,t.sequenceExecute)(F,i)?await c.onValidateCell(h,g,b,x)===!1?((0,t.sequenceExecute)(I,i),!1):(a.pushUndoRedo({redoMutations:F,undoMutations:I,unitID:u}),!0):!1}},g={id:`sheets.command.add-rich-hyper-link`,type:t.CommandType.COMMAND,handler:async(e,r)=>{if(!r)return!1;let{documentId:i,link:a}=r,o=e.get(t.ICommandService),s=(0,t.generateRandomId)(),{payload:c}=a,l=(0,n.addCustomRangeBySelectionFactory)(e,{unitId:i,rangeId:s,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c,refId:s}});return l?o.syncExecuteCommand(l.id,l.params):!1}},_={type:t.CommandType.COMMAND,id:`sheets.command.cancel-hyper-link`,handler(e,n){var i;if(!n)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(t.IUniverInstanceService),c=e.get(f),l=(0,r.getSheetCommandTarget)(s,n);if(!l)return!1;let{row:u,column:d,id:h}=n,{unitId:g,subUnitId:_,worksheet:v}=l,y=v.getCell(u,d);if(!y)return!1;let b=v.getCellDocumentModelWithFormula(y,u,d);if(!(b!=null&&b.documentModel))return!1;let x=t.Tools.deepClone(b.documentModel.getSnapshot()),S=(i=x.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>`${e.rangeId}`===h);if(!S)return!1;let C=t.BuildTextUtils.customRange.delete({documentDataModel:b.documentModel,rangeId:S.rangeId});if(!C)return!1;let w=t.TextX.apply(x.body,C.serialize()),T=[],E=[],D={unitId:g,subUnitId:_,cellValue:{[u]:{[d]:{p:{...x,body:w},t:t.CellValueType.STRING}}}};T.push({id:r.SetRangeValuesMutation.id,params:D});let O=(0,r.SetRangeValuesUndoMutationFactory)(e,D);E.push({id:r.SetRangeValuesMutation.id,params:O});let k=c.getHyperLinkByLocation(g,_,u,d);return k&&(T.push({id:m.id,params:{unitId:g,subUnitId:_,id:h}}),E.push({id:p.id,params:{unitId:g,subUnitId:_,link:{...k}}})),(0,t.sequenceExecute)(T,a).result?(o.pushUndoRedo({redoMutations:T,undoMutations:E,unitID:g}),!0):!1}},v={type:t.CommandType.COMMAND,id:`sheets.command.cancel-rich-hyper-link`,handler(e,r){var i;if(!r)return!1;let{id:a,documentId:o}=r,s=e.get(t.ICommandService),c=e.get(t.IUniverInstanceService).getUnit(o,t.UniverInstanceType.UNIVER_DOC),l=c==null||(i=c.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===a),u=null;l&&l.endIndex===c.getBody().dataStream.length-3&&(u={dataStream:` `});let d=(0,n.deleteCustomRangeFactory)(e,{unitId:o,rangeId:a,insert:u});return d?s.syncExecuteCommand(d.id,d.params):!1}},y={type:t.CommandType.COMMAND,id:`sheets.command.update-hyper-link`,async handler(e,i){var a,o;if(!i)return!1;let s=e.get(t.ICommandService),c=e.get(t.IUndoRedoService),l=e.get(t.IUniverInstanceService),u=e.get(f),d=e.get(r.SheetInterceptorService),h=(0,r.getSheetCommandTarget)(l,{unitId:i.unitId,subUnitId:i.subUnitId});if(!h)return!1;let{payload:g,row:_,column:v,id:y}=i,{workbook:b,worksheet:x,unitId:S,subUnitId:C}=h,{payload:w,display:T=``}=g,E=x.getCell(_,v);if(!E)return!1;let D=x.getCellDocumentModelWithFormula(E,_,v);if(!(D!=null&&D.documentModel))return!1;let O=D.documentModel.getSnapshot(),k=(a=O.body)==null||(a=a.customRanges)==null?void 0:a.find(e=>`${e.rangeId}`===y);if(!k)return!1;let A=(0,t.generateRandomId)(),j=(o=(0,t.getBodySlice)(D.documentModel.getBody(),k.startIndex,k.endIndex+1).textRuns)==null?void 0:o[0];j&&(j.ed=T.length+1);let M=(0,n.replaceSelectionFactory)(e,{unitId:S,body:{dataStream:`${T}`,customRanges:[{rangeId:A,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:T.length-1,properties:{url:w}}],textRuns:j?[j]:void 0},selection:{startOffset:k.startIndex,endOffset:k.endIndex+1,collapsed:!1},doc:D.documentModel});if(!M)return!1;let N=t.TextX.apply(t.Tools.deepClone(O.body),M.textX.serialize()),P={p:{...O,body:N},t:t.CellValueType.STRING},F=d.onWriteCell(b,x,_,v,P),I={id:r.SetRangeValuesMutation.id,params:{unitId:S,subUnitId:C,cellValue:{[_]:{[v]:F}}}},L=(0,r.SetRangeValuesUndoMutationFactory)(e,I.params),R={id:r.SetRangeValuesMutation.id,params:L},z=[I],B=[R],V=u.getHyperLinkByLocation(S,C,_,v);return V&&(z.push({id:m.id,params:{unitId:S,subUnitId:C,id:V.id}}),B.push({id:p.id,params:{unitId:S,subUnitId:C,link:V}})),(0,t.sequenceExecute)(z,s)?await d.onValidateCell(b,x,_,v)===!1?((0,t.sequenceExecute)(B,s),!1):(c.pushUndoRedo({redoMutations:z,undoMutations:B,unitID:S}),!0):!1}},b={type:t.CommandType.COMMAND,id:`sheets.command.update-rich-hyper-link`,handler:(e,r)=>{var i,a,o;if(!r)return!1;let{documentId:s,payload:c,id:l}=r,u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=u.getUnit(s,t.UniverInstanceType.UNIVER_DOC);if(!f)return!1;let p=(i=f.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===l);if(!p)return!1;let m=(a=r.payload.display)==null?``:a,h=(0,t.generateRandomId)(),g=(o=(0,t.getBodySlice)(f.getBody(),p.startIndex,p.endIndex+1).textRuns)==null?void 0:o[0];g&&(g.ed=m.length+1);let _=(0,n.replaceSelectionFactory)(e,{unitId:s,body:{dataStream:`${m}`,customRanges:[{rangeId:h,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:m.length-1,properties:{url:c.payload}}],textRuns:g?[g]:void 0},selection:{startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},doc:f});return _?d.syncExecuteCommand(_.id,_.params):!1}},x={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,payload:a,id:o}=t;return n.updateHyperLink(r,i,o,a,!1)}},S={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link-ref`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a,row:o,column:s,silent:c}=t;return n.updateHyperLinkRef(r,i,a,{row:o,column:s},c)}},C={type:t.CommandType.MUTATION,id:`sheets.mutation.update-rich-hyper-link`,handler(e,n){var i;if(!n)return!1;let{unitId:a,subUnitId:o,row:s,col:c,id:l,url:u}=n,d=(0,r.getSheetCommandTarget)(e.get(t.IUniverInstanceService),{unitId:a,subUnitId:o});if(!d)return!1;let{worksheet:f}=d,p=f.getCellRaw(s,c),m=p==null||(i=p.p)==null||(i=i.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeType===t.CustomRangeType.HYPERLINK&&e.rangeId===l);return m&&(m.properties.url=u),!0}};var w=`@univerjs/sheets-hyper-link`,T=`0.20.0`;let E=`sheets-hyper-link.config`;Symbol(E);let D={},O=`SHEET_HYPER_LINK_PLUGIN`,k=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._commandService=r,l(this,`_disposableMap`,new Map),l(this,`_watchDisposableMap`,new Map),l(this,`_rangeDisableMap`,new Map),l(this,`_rangeWatcherMap`,new Map),l(this,`_handlePositionChange`,(e,t,n,r,i)=>{let a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:r.startRow,column:r.startColumn,silent:i}}],undos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:a.startRow,column:a.startColumn,silent:i}}]}:{redos:[{id:m.id,params:{unitId:e,subUnitId:t,id:n.id}}],undos:[{id:p.id,params:{unitId:e,subUnitId:t,link:n}}]}}),this._initData(),this._initRefRange()}_registerPosition(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(i,this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,t,n,s,!1)},e,t))}_watchPosition(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handlePositionChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){let t=this._disposableMap.get(e);t==null||t.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){let t=this._watchDisposableMap.get(e);t==null||t.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,i,o=!1){if(i.startsWith(`#`)){var s,c,l;let u=new URLSearchParams(i.slice(1)),d={gid:(s=u.get(`gid`))==null?``:s,range:(c=u.get(`range`))==null?``:c,rangeid:(l=u.get(`rangeid`))==null?``:l};if(d.range&&d.gid){let s=d.gid,c=(0,a.deserializeRangeWithSheet)(d.range).range;(0,t.isValidRange)(c)&&d.range!==`err`&&(this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(c,t=>{let o=(0,r.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests)(c,t,{selectionManagerService:this._selectionManagerService});return o&&(0,a.serializeRange)(o)===(0,a.serializeRange)(c)?{redos:[],undos:[]}:{redos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:`#gid=${s}&range=${o?(0,a.serializeRange)(o):`err`}`}}}],undos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:i}}}]}},e,s)),o||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,s,c,(t,r)=>{this._hyperLinkModel.updateHyperLink(e,s,n,{payload:`#gid=${s}&range=${r?(0,a.serializeRange)(r):`err`}`},!0)},!0)))}}}_unregisterRange(e){let t=this._rangeDisableMap.get(e);t==null||t.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){let t=this._rangeWatcherMap.get(e);t==null||t.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,links:r}=e;r.forEach(e=>{this._registerPosition(t,n,e),this._watchPosition(t,n,e),this._registerRange(t,e.id,e.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case`add`:this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break;case`remove`:this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break;case`updateRef`:{let{unitId:t,subUnitId:n,id:r,silent:i}=e,a=this._hyperLinkModel.getHyperLink(t,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(t,n,a),i||(this._unwatchPosition(r),this._watchPosition(t,n,a));break}case`unload`:{let{unitLinks:t}=e;t.forEach(e=>{let{links:t}=e;t.forEach(e=>{this._unregisterPosition(e.id),this._unwatchPosition(e.id),this._unregisterRange(e.id),this._unwatchRange(e.id)})});break}case`update`:e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};k=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.ICommandService)],k);let A=class extends t.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,i=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return{redos:[],undos:[]};let a=i.getUnitId(),o=r.subUnitId||((n=i.getActiveSheet())==null?void 0:n.getSheetId());if(!o)return{redos:[],undos:[]};let s=this._hyperLinkModel.getSubUnit(a,o);return{redos:s.map(e=>({id:m.id,params:{unitId:a,subUnitId:o,id:e.id}})),undos:s.map(e=>({id:p.id,params:{unitId:a,subUnitId:o,link:e}}))}}return{redos:[],undos:[]}}}))}};A=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(f))],A);let j=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._refRangeService=n,l(this,`_refRangeMap`,new Map),this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(e,n){let r=this._refRangeMap.get(e);r||(r=new Map,this._refRangeMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_isLegalRangeUrl(e,n){let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!r)return null;if(n&&n.startsWith(`#`)){var i,o,s;let e=new URLSearchParams(n.slice(1)),c={gid:(i=e.get(`gid`))==null?``:i,range:(o=e.get(`range`))==null?``:o,rangeid:(s=e.get(`rangeid`))==null?``:s};if(c.range&&c.gid){let e=c.gid,n=r.getSheetBySheetId(e);if(!n)return null;let i=(0,a.deserializeRangeWithSheet)(c.range).range;if((0,t.isValidRange)(i,n)&&c.range!==`err`)return{range:i,worksheet:n}}}return null}_registerRange(e,n,i,o,s){var c;let l=this._enusreMap(e,n);if(!((c=s.body)==null||(c=c.customRanges)==null)&&c.some(n=>{var r;return n.rangeType===t.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(e,(r=n.properties)==null?void 0:r.url)})){var u;let c=new t.DisposableCollection,d=!1;(u=s.body)==null||(u=u.customRanges)==null||u.forEach(s=>{if(s.rangeType===t.CustomRangeType.HYPERLINK){var l;let u=(l=s.properties)==null?void 0:l.url,f=this._isLegalRangeUrl(e,u);if(f){let{range:l,worksheet:p}=f;d=!0,c.add(this._refRangeService.registerRefRange(l,c=>{let d=(0,r.handleDefaultRangeChangeWithEffectRefCommands)(l,c);return d&&t.Rectangle.equals(d,l)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:`#gid=${n}&range=${d?(0,a.serializeRange)(d):`err`}`}}],undos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:u}}],redos:[]}},p.getUnitId(),p.getSheetId()))}}}),d&&l.setValue(i,o,c)}}_initWorkbookLoad(){let e=e=>{let t=e.getUnitId();e.getSheets().forEach(e=>{let n=e.getSheetId(),r=this._enusreMap(t,n);e.getCellMatrix().forValue((e,i,a)=>{let o=r.getValue(e,i);o&&o.dispose(),a&&a.p&&this._registerRange(t,n,e,i,a.p)})})};this._univerInstanceService.getAllUnitsForType(t.UniverInstanceType.UNIVER_SHEET).forEach(t=>{e(t)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(n=>{n.type===t.UniverInstanceType.UNIVER_SHEET&&e(n)}))}_initWorkbookUnload(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{if(e.type===t.UniverInstanceType.UNIVER_SHEET){let t=e,n=t.getUnitId();t.getSheets().forEach(e=>{let t=e.getSheetId();this._enusreMap(n,t).forValue((e,t,n)=>{n&&n.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===r.SetRangeValuesMutation.id){let{unitId:n,subUnitId:r,cellValue:i}=e.params,a=this._enusreMap(n,r);i&&new t.ObjectMatrix(i).forValue((e,t,i)=>{let o=a.getValue(e,t);o&&o.dispose(),i&&i.p&&this._registerRange(n,r,e,t,i.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===C.id){let{unitId:t,subUnitId:n,row:i,col:a}=e.params,o=(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:t,subUnitId:n}),s=this._enusreMap(t,n).getValue(i,a);if(s&&s.dispose(),o){let{worksheet:e}=o,r=e.getCellRaw(i,a);r&&r.p&&this._registerRange(t,n,i,a,r.p)}}}))}};j=d([u(0,t.ICommandService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(r.RefRangeService))],j);let M=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._univerInstanceService=r,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.SetRangeValuesCommand.id){let n=e.params,{unitId:r,subUnitId:i}=n,a=[],o=[];return n.cellValue&&new t.ObjectMatrix(n.cellValue).forValue((e,t)=>{let n=this._hyperLinkModel.getHyperLinkByLocation(r,i,e,t);n&&(a.push({id:m.id,params:{unitId:r,subUnitId:i,id:n.id}}),o.push({id:p.id,params:{unitId:r,subUnitId:i,link:n}}))}),{undos:o,redos:a}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.ClearSelectionContentCommand.id||e.id===r.ClearSelectionAllCommand.id||e.id===r.ClearSelectionFormatCommand.id){let n=[],i=[],a=this._selectionManagerService.getCurrentLastSelection(),o=(0,r.getSheetCommandTarget)(this._univerInstanceService,e.params);if(a&&o){let{unitId:e,subUnitId:r}=o;t.Range.foreach(a.range,(t,a)=>{let o=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,a);o&&(n.push({id:m.id,params:{unitId:e,subUnitId:r,id:o.id}}),i.push({id:p.id,params:{unitId:e,subUnitId:r,link:o}}))})}return{redos:n,undos:i}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.AFTER_CELL_EDIT,{handler:(e,n,r)=>{if(!e||e.p)return r(e);if(typeof e.v==`string`&&t.Tools.isLegalUrl(e.v)&&e.v[e.v.length-1]!==` `){let{unitId:i,subUnitId:a,row:o,col:s}=n,c=t.Tools.normalizeUrl(e.v),l=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),u=l==null?void 0:l.getSheetBySheetId(a);if(!u)return r(e);let d=u.getBlankCellDocumentModel(e,o,s);if(!d.documentModel)return r(e);let f=t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:e.v.length,collapsed:!1},body:{dataStream:`${e.v}`,customRanges:[{startIndex:0,endIndex:e.v.length-1,rangeId:(0,t.generateRandomId)(),rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c}}]},doc:d.documentModel});if(!f)return r(e);let p=d.documentModel.getBody();return t.TextX.apply(p,f.serialize()),r({...e,p:{id:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:p,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return r(e)}}))}};M=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.IUniverInstanceService)],M);let N=class extends t.Disposable{constructor(e,t){super(),this._resourceManagerService=e,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._hyperLinkModel.getUnit(e),n={};return t?(t.forEach(e=>{n[e.subUnitId]=e.links.map(({display:e,...t})=>t)}),JSON.stringify(n)):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:O,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,t)=>{Object.keys(t).forEach(n=>{t[n].forEach(t=>{this._hyperLinkModel.addHyperLink(e,n,t)})})}}))}};N=d([u(0,t.IResourceManagerService),u(1,(0,t.Inject)(f))],N);let P=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._registerCommands()}_registerCommands(){[h,y,_,b,v,g,p,x,m,S,C].forEach(e=>{this._commandService.registerCommand(e)})}};P=d([u(0,t.ICommandService)],P);let F=function(e){return e.SHEET=`gid`,e.RANGE=`range`,e.DEFINE_NAME=`rangeid`,e.INVALID=`invalid`,e.URL=`url`,e}({}),I=class{constructor(e,t,n){this._univerInstanceService=e,this._localeService=t,this._definedNamesService=n}buildHyperLink(e,t,n){return`#${F.SHEET}=${t}${n?`&${typeof n==`string`?F.DEFINE_NAME:F.RANGE}=${typeof n==`string`?n:(0,a.serializeRange)(n)}`:``}`}parseHyperLink(e){if(e.startsWith(`#`)){var t,n,r,i;let a=new URLSearchParams(e.slice(1)),o={gid:(t=a.get(`gid`))==null?``:t,range:(n=a.get(`range`))==null?``:n,rangeid:(r=a.get(`rangeid`))==null?``:r,unitid:(i=a.get(`unitid`))==null?``:i},s=this._getURLName(o);return{type:s.type,name:s.name,url:e,searchObj:o}}else return{type:F.URL,name:e,url:e,searchObj:null}}_getURLName(e){var n;let{gid:r,range:i,rangeid:o,unitid:s}=e,c=s?this._univerInstanceService.getUnit(s,t.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),l={type:F.INVALID,name:this._localeService.t(`hyperLink.message.refError`)};if(!c)return l;let u=r?c.getSheetBySheetId(r):c.getActiveSheet(),d=(n=u==null?void 0:u.getName())==null?``:n;if(i){if(!u)return l;let e=(0,a.deserializeRangeWithSheet)(i).range;return(0,t.isValidRange)(e,u)&&i!==`err`?{type:F.RANGE,name:(0,a.serializeRangeWithSheet)(d,e)}:l}if(o){let e=this._definedNamesService.getValueById(c.getUnitId(),o);return e?{type:F.DEFINE_NAME,name:e.formulaOrRefString}:l}if(r){let e=c.getSheetBySheetId(r);return e?{type:F.SHEET,name:e.getName()}:l}return l}};I=d([u(0,t.IUniverInstanceService),u(1,(0,t.Inject)(t.LocaleService)),u(2,a.IDefinedNamesService)],I);let L=class extends t.Plugin{constructor(e=D,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},D,this._config);this._configService.setConfig(E,i)}onStarting(){(0,t.registerDependencies)(this._injector,[[f],[I],[N],[P],[k],[M],[A],[j]]),(0,t.touchDependencies)(this._injector,[[k],[N],[P],[M],[A],[j]])}};l(L,`pluginName`,O),l(L,`packageName`,w),l(L,`version`,T),l(L,`type`,t.UniverInstanceType.UNIVER_SHEET),L=d([(0,t.DependentOn)(r.UniverSheetsPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,t.IConfigService)],L),e.AddHyperLinkCommand=h,e.AddHyperLinkMutation=p,e.AddRichHyperLinkCommand=g,e.CancelHyperLinkCommand=_,e.CancelRichHyperLinkCommand=v,e.ERROR_RANGE=`err`,Object.defineProperty(e,`HyperLinkModel`,{enumerable:!0,get:function(){return f}}),e.RemoveHyperLinkMutation=m,e.SheetHyperLinkType=F,Object.defineProperty(e,`SheetsHyperLinkParserService`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,`UniverSheetsHyperLinkPlugin`,{enumerable:!0,get:function(){return L}}),e.UpdateHyperLinkCommand=y,e.UpdateHyperLinkMutation=x,e.UpdateHyperLinkRefMutation=S,e.UpdateRichHyperLinkCommand=b});
2
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/docs`),require(`@univerjs/sheets`),require(`rxjs`),require(`@univerjs/engine-formula`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/sheets`,`rxjs`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLink={},e.UniverCore,e.UniverDocs,e.UniverSheets,e.rxjs,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let f=class extends t.Disposable{constructor(e){super(),this._univerInstanceService=e,l(this,`_linkUpdate$`,new i.Subject),l(this,`linkUpdate$`,this._linkUpdate$.asObservable()),l(this,`_linkMap`,new Map),l(this,`_linkPositionMap`,new Map),this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let r=this._linkMap.get(e);r||(r=new Map,this._linkMap.set(e,r));let i=r.get(n);i||(i=new t.ObjectMatrix,r.set(n,i));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let o=a.get(n);return o||(o=new Map,a.set(n,o)),{matrix:i,positionMap:o}}addHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t);return r.setValue(n.row,n.column,n),i.set(n.id,{row:n.row,column:n.column,link:n}),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:n,type:`add`}),!0}updateHyperLink(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return c?(Object.assign(c,r),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:{display:c.display,payload:c.payload},id:n,type:`update`,silent:i}),!0):!0}updateHyperLinkRef(e,t,n,r,i=!1){let{matrix:a,positionMap:o}=this._ensureMap(e,t),s=o.get(n);if(!s)return!0;let c=a.getValue(s.row,s.column);return!c||c.id!==n?c=s.link:a.realDeleteValue(s.row,s.column),Object.assign(c,r),o.set(n,{...r,link:c}),a.setValue(r.row,r.column,c),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:r,id:n,type:`updateRef`,silent:i}),!0}removeHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(!a)return!1;i.delete(n);let o=r.getValue(a.row,a.column);return o&&o.id===n&&r.realDeleteValue(a.row,a.column),this._linkUpdate$.next({unitId:e,subUnitId:t,payload:a.link,type:`remove`}),!0}getHyperLink(e,t,n){let{matrix:r,positionMap:i}=this._ensureMap(e,t),a=i.get(n);if(a)return r.getValue(a.row,a.column)}getHyperLinkByLocation(e,t,n,r){let{matrix:i}=this._ensureMap(e,t);return i.getValue(n,r)}getHyperLinkByLocationSync(e,n,r,i){var a,o,s,c;let{matrix:l}=this._ensureMap(e,n),u=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),d=u==null||(a=u.getSheetBySheetId(n))==null?void 0:a.getCellRaw(r,i),f=((o=(s=d==null?void 0:d.v)==null?d==null||(c=d.p)==null||(c=c.body)==null?void 0:c.dataStream.slice(0,-2):s)==null?``:o).toString(),p=l.getValue(r,i);if(p)return{...p,display:f}}getSubUnit(e,t){let{matrix:n}=this._ensureMap(e,t),r=[];return n.forValue((e,t,n)=>{n&&r.push(n)}),r}getUnit(e){let t=this._linkMap.get(e);return t?Array.from(t.keys()).map(t=>({unitId:e,subUnitId:t,links:this.getSubUnit(e,t)})):[]}deleteUnit(e){let t=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:`unload`,unitId:e,unitLinks:t})}getAll(){return Array.from(this._linkMap.keys()).map(e=>this.getUnit(e))}};f=d([u(0,t.IUniverInstanceService)],f);let p={type:t.CommandType.MUTATION,id:`sheets.mutation.add-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,link:a}=t;return n.addHyperLink(r,i,a)}},m={type:t.CommandType.MUTATION,id:`sheets.mutation.remove-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a}=t;return n.removeHyperLink(r,i,a)}},h={type:t.CommandType.COMMAND,id:`sheets.command.add-hyper-link`,async handler(e,n){if(!n)return!1;let i=e.get(t.ICommandService),a=e.get(t.IUndoRedoService),o=e.get(t.IUniverInstanceService),s=e.get(f),c=e.get(r.SheetInterceptorService),l=(0,r.getSheetCommandTarget)(o,n);if(!l)return!1;let{unitId:u,subUnitId:d,workbook:h,worksheet:g}=l,{link:_}=n,{payload:v,display:y,row:b,column:x,id:S}=_,C=g.getCell(b,x),w=g.getBlankCellDocumentModel(C,b,x),T=w.documentModel.getSnapshot(),E=t.Tools.deepClone(T.body);if(!E)return!1;let D;if(D=y?t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:E.dataStream.length-2,collapsed:E.dataStream.length-2==0},body:{dataStream:`${y}`,customRanges:[{startIndex:0,endIndex:y.length-1,rangeType:t.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:v}}]},doc:w.documentModel}):t.BuildTextUtils.customRange.add({body:E,ranges:[{startOffset:0,endOffset:E.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:v,refId:S}}),!D)return!1;let O=t.TextX.apply(E,D.serialize()),k={p:{...T,body:O},t:t.CellValueType.STRING},A=c.onWriteCell(h,g,b,x,k),j={unitId:u,subUnitId:d,cellValue:{[_.row]:{[_.column]:A}}},M={id:r.SetRangeValuesMutation.id,params:j},N=(0,r.SetRangeValuesUndoMutationFactory)(e,j),P={id:r.SetRangeValuesMutation.id,params:N},F=[M],I=[P],L=s.getHyperLinkByLocation(u,d,b,x);return L&&(F.push({id:m.id,params:{unitId:u,subUnitId:d,id:L.id}}),I.push({id:p.id,params:{unitId:u,subUnitId:d,link:L}})),await(0,t.sequenceExecute)(F,i)?await c.onValidateCell(h,g,b,x)===!1?((0,t.sequenceExecute)(I,i),!1):(a.pushUndoRedo({redoMutations:F,undoMutations:I,unitID:u}),!0):!1}},g={id:`sheets.command.add-rich-hyper-link`,type:t.CommandType.COMMAND,handler:async(e,r)=>{if(!r)return!1;let{documentId:i,link:a}=r,o=e.get(t.ICommandService),s=(0,t.generateRandomId)(),{payload:c}=a,l=(0,n.addCustomRangeBySelectionFactory)(e,{unitId:i,rangeId:s,rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c,refId:s}});return l?o.syncExecuteCommand(l.id,l.params):!1}},_={type:t.CommandType.COMMAND,id:`sheets.command.cancel-hyper-link`,handler(e,n){var i;if(!n)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(t.IUniverInstanceService),c=e.get(f),l=(0,r.getSheetCommandTarget)(s,n);if(!l)return!1;let{row:u,column:d,id:h}=n,{unitId:g,subUnitId:_,worksheet:v}=l,y=v.getCell(u,d);if(!y)return!1;let b=v.getCellDocumentModelWithFormula(y,u,d);if(!(b!=null&&b.documentModel))return!1;let x=t.Tools.deepClone(b.documentModel.getSnapshot()),S=(i=x.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>`${e.rangeId}`===h);if(!S)return!1;let C=t.BuildTextUtils.customRange.delete({documentDataModel:b.documentModel,rangeId:S.rangeId});if(!C)return!1;let w=t.TextX.apply(x.body,C.serialize()),T=[],E=[],D={unitId:g,subUnitId:_,cellValue:{[u]:{[d]:{p:{...x,body:w},t:t.CellValueType.STRING}}}};T.push({id:r.SetRangeValuesMutation.id,params:D});let O=(0,r.SetRangeValuesUndoMutationFactory)(e,D);E.push({id:r.SetRangeValuesMutation.id,params:O});let k=c.getHyperLinkByLocation(g,_,u,d);return k&&(T.push({id:m.id,params:{unitId:g,subUnitId:_,id:k.id}}),E.push({id:p.id,params:{unitId:g,subUnitId:_,link:{...k}}})),(0,t.sequenceExecute)(T,a).result?(o.pushUndoRedo({redoMutations:T,undoMutations:E,unitID:g}),!0):!1}},v={type:t.CommandType.COMMAND,id:`sheets.command.cancel-rich-hyper-link`,handler(e,r){var i;if(!r)return!1;let{id:a,documentId:o}=r,s=e.get(t.ICommandService),c=e.get(t.IUniverInstanceService).getUnit(o,t.UniverInstanceType.UNIVER_DOC),l=c==null||(i=c.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===a),u=null;l&&l.endIndex===c.getBody().dataStream.length-3&&(u={dataStream:` `});let d=(0,n.deleteCustomRangeFactory)(e,{unitId:o,rangeId:a,insert:u});return d?s.syncExecuteCommand(d.id,d.params):!1}},y={type:t.CommandType.COMMAND,id:`sheets.command.update-hyper-link`,async handler(e,i){var a,o;if(!i)return!1;let s=e.get(t.ICommandService),c=e.get(t.IUndoRedoService),l=e.get(t.IUniverInstanceService),u=e.get(f),d=e.get(r.SheetInterceptorService),h=(0,r.getSheetCommandTarget)(l,{unitId:i.unitId,subUnitId:i.subUnitId});if(!h)return!1;let{payload:g,row:_,column:v,id:y}=i,{workbook:b,worksheet:x,unitId:S,subUnitId:C}=h,{payload:w,display:T=``}=g,E=x.getCell(_,v);if(!E)return!1;let D=x.getCellDocumentModelWithFormula(E,_,v);if(!(D!=null&&D.documentModel))return!1;let O=D.documentModel.getSnapshot(),k=(a=O.body)==null||(a=a.customRanges)==null?void 0:a.find(e=>`${e.rangeId}`===y);if(!k)return!1;let A=(0,t.generateRandomId)(),j=(o=(0,t.getBodySlice)(D.documentModel.getBody(),k.startIndex,k.endIndex+1).textRuns)==null?void 0:o[0];j&&(j.ed=T.length+1);let M=(0,n.replaceSelectionFactory)(e,{unitId:S,body:{dataStream:`${T}`,customRanges:[{rangeId:A,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:T.length-1,properties:{url:w}}],textRuns:j?[j]:void 0},selection:{startOffset:k.startIndex,endOffset:k.endIndex+1,collapsed:!1},doc:D.documentModel});if(!M)return!1;let N=t.TextX.apply(t.Tools.deepClone(O.body),M.textX.serialize()),P={p:{...O,body:N},t:t.CellValueType.STRING},F=d.onWriteCell(b,x,_,v,P),I={id:r.SetRangeValuesMutation.id,params:{unitId:S,subUnitId:C,cellValue:{[_]:{[v]:F}}}},L=(0,r.SetRangeValuesUndoMutationFactory)(e,I.params),R={id:r.SetRangeValuesMutation.id,params:L},z=[I],B=[R],V=u.getHyperLinkByLocation(S,C,_,v);return V&&(z.push({id:m.id,params:{unitId:S,subUnitId:C,id:V.id}}),B.push({id:p.id,params:{unitId:S,subUnitId:C,link:V}})),(0,t.sequenceExecute)(z,s)?await d.onValidateCell(b,x,_,v)===!1?((0,t.sequenceExecute)(B,s),!1):(c.pushUndoRedo({redoMutations:z,undoMutations:B,unitID:S}),!0):!1}},b={type:t.CommandType.COMMAND,id:`sheets.command.update-rich-hyper-link`,handler:(e,r)=>{var i,a,o;if(!r)return!1;let{documentId:s,payload:c,id:l}=r,u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=u.getUnit(s,t.UniverInstanceType.UNIVER_DOC);if(!f)return!1;let p=(i=f.getBody())==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeId===l);if(!p)return!1;let m=(a=r.payload.display)==null?``:a,h=(0,t.generateRandomId)(),g=(o=(0,t.getBodySlice)(f.getBody(),p.startIndex,p.endIndex+1).textRuns)==null?void 0:o[0];g&&(g.ed=m.length+1);let _=(0,n.replaceSelectionFactory)(e,{unitId:s,body:{dataStream:`${m}`,customRanges:[{rangeId:h,rangeType:t.CustomRangeType.HYPERLINK,startIndex:0,endIndex:m.length-1,properties:{url:c.payload}}],textRuns:g?[g]:void 0},selection:{startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},doc:f});return _?d.syncExecuteCommand(_.id,_.params):!1}},x={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,payload:a,id:o}=t;return n.updateHyperLink(r,i,o,a,!1)}},S={type:t.CommandType.MUTATION,id:`sheets.mutation.update-hyper-link-ref`,handler(e,t){if(!t)return!1;let n=e.get(f),{unitId:r,subUnitId:i,id:a,row:o,column:s,silent:c}=t;return n.updateHyperLinkRef(r,i,a,{row:o,column:s},c)}},C={type:t.CommandType.MUTATION,id:`sheets.mutation.update-rich-hyper-link`,handler(e,n){var i;if(!n)return!1;let{unitId:a,subUnitId:o,row:s,col:c,id:l,url:u}=n,d=(0,r.getSheetCommandTarget)(e.get(t.IUniverInstanceService),{unitId:a,subUnitId:o});if(!d)return!1;let{worksheet:f}=d,p=f.getCellRaw(s,c),m=p==null||(i=p.p)==null||(i=i.body)==null||(i=i.customRanges)==null?void 0:i.find(e=>e.rangeType===t.CustomRangeType.HYPERLINK&&e.rangeId===l);return m&&(m.properties.url=u),!0}};var w=`@univerjs/sheets-hyper-link`,T=`0.21.0`;let E=`sheets-hyper-link.config`;Symbol(E);let D={},O=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._commandService=r,l(this,`_disposableMap`,new Map),l(this,`_watchDisposableMap`,new Map),l(this,`_rangeDisableMap`,new Map),l(this,`_rangeWatcherMap`,new Map),l(this,`_handlePositionChange`,(e,t,n,r,i)=>{let a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:r.startRow,column:r.startColumn,silent:i}}],undos:[{id:S.id,params:{unitId:e,subUnitId:t,id:n.id,row:a.startRow,column:a.startColumn,silent:i}}]}:{redos:[{id:m.id,params:{unitId:e,subUnitId:t,id:n.id}}],undos:[{id:p.id,params:{unitId:e,subUnitId:t,link:n}}]}}),this._initData(),this._initRefRange()}_registerPosition(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(i,this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,t,n,s,!1)},e,t))}_watchPosition(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handlePositionChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){let t=this._disposableMap.get(e);t==null||t.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){let t=this._watchDisposableMap.get(e);t==null||t.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,i,o=!1){if(i.startsWith(`#`)){var s,c,l;let u=new URLSearchParams(i.slice(1)),d={gid:(s=u.get(`gid`))==null?``:s,range:(c=u.get(`range`))==null?``:c,rangeid:(l=u.get(`rangeid`))==null?``:l};if(d.range&&d.gid){let s=d.gid,c=(0,a.deserializeRangeWithSheet)(d.range).range;(0,t.isValidRange)(c)&&d.range!==`err`&&(this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(c,t=>{let o=(0,r.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests)(c,t,{selectionManagerService:this._selectionManagerService});return o&&(0,a.serializeRange)(o)===(0,a.serializeRange)(c)?{redos:[],undos:[]}:{redos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:`#gid=${s}&range=${o?(0,a.serializeRange)(o):`err`}`}}}],undos:[{id:x.id,params:{unitId:e,subUnitId:s,id:n,payload:{payload:i}}}]}},e,s)),o||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,s,c,(t,r)=>{this._hyperLinkModel.updateHyperLink(e,s,n,{payload:`#gid=${s}&range=${r?(0,a.serializeRange)(r):`err`}`},!0)},!0)))}}}_unregisterRange(e){let t=this._rangeDisableMap.get(e);t==null||t.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){let t=this._rangeWatcherMap.get(e);t==null||t.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(e=>{let{unitId:t,subUnitId:n,links:r}=e;r.forEach(e=>{this._registerPosition(t,n,e),this._watchPosition(t,n,e),this._registerRange(t,e.id,e.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case`add`:this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break;case`remove`:this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break;case`updateRef`:{let{unitId:t,subUnitId:n,id:r,silent:i}=e,a=this._hyperLinkModel.getHyperLink(t,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(t,n,a),i||(this._unwatchPosition(r),this._watchPosition(t,n,a));break}case`unload`:{let{unitLinks:t}=e;t.forEach(e=>{let{links:t}=e;t.forEach(e=>{this._unregisterPosition(e.id),this._unwatchPosition(e.id),this._unregisterRange(e.id),this._unwatchRange(e.id)})});break}case`update`:e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};O=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.ICommandService)],O);let k=class extends t.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,i=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return{redos:[],undos:[]};let a=i.getUnitId(),o=r.subUnitId||((n=i.getActiveSheet())==null?void 0:n.getSheetId());if(!o)return{redos:[],undos:[]};let s=this._hyperLinkModel.getSubUnit(a,o);return{redos:s.map(e=>({id:m.id,params:{unitId:a,subUnitId:o,id:e.id}})),undos:s.map(e=>({id:p.id,params:{unitId:a,subUnitId:o,link:e}}))}}return{redos:[],undos:[]}}}))}};k=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(f))],k);let A=class extends t.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._refRangeService=n,l(this,`_refRangeMap`,new Map),this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(e,n){let r=this._refRangeMap.get(e);r||(r=new Map,this._refRangeMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_isLegalRangeUrl(e,n){let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!r)return null;if(n&&n.startsWith(`#`)){var i,o,s;let e=new URLSearchParams(n.slice(1)),c={gid:(i=e.get(`gid`))==null?``:i,range:(o=e.get(`range`))==null?``:o,rangeid:(s=e.get(`rangeid`))==null?``:s};if(c.range&&c.gid){let e=c.gid,n=r.getSheetBySheetId(e);if(!n)return null;let i=(0,a.deserializeRangeWithSheet)(c.range).range;if((0,t.isValidRange)(i,n)&&c.range!==`err`)return{range:i,worksheet:n}}}return null}_registerRange(e,n,i,o,s){var c;let l=this._enusreMap(e,n);if(!((c=s.body)==null||(c=c.customRanges)==null)&&c.some(n=>{var r;return n.rangeType===t.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(e,(r=n.properties)==null?void 0:r.url)})){var u;let c=new t.DisposableCollection,d=!1;(u=s.body)==null||(u=u.customRanges)==null||u.forEach(s=>{if(s.rangeType===t.CustomRangeType.HYPERLINK){var l;let u=(l=s.properties)==null?void 0:l.url,f=this._isLegalRangeUrl(e,u);if(f){let{range:l,worksheet:p}=f;d=!0,c.add(this._refRangeService.registerRefRange(l,c=>{let d=(0,r.handleDefaultRangeChangeWithEffectRefCommands)(l,c);return d&&t.Rectangle.equals(d,l)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:`#gid=${n}&range=${d?(0,a.serializeRange)(d):`err`}`}}],undos:[{id:C.id,params:{unitId:e,subUnitId:n,row:i,col:o,id:s.rangeId,url:u}}],redos:[]}},p.getUnitId(),p.getSheetId()))}}}),d&&l.setValue(i,o,c)}}_initWorkbookLoad(){let e=e=>{let t=e.getUnitId();e.getSheets().forEach(e=>{let n=e.getSheetId(),r=this._enusreMap(t,n);e.getCellMatrix().forValue((e,i,a)=>{let o=r.getValue(e,i);o&&o.dispose(),a&&a.p&&this._registerRange(t,n,e,i,a.p)})})};this._univerInstanceService.getAllUnitsForType(t.UniverInstanceType.UNIVER_SHEET).forEach(t=>{e(t)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(n=>{n.type===t.UniverInstanceType.UNIVER_SHEET&&e(n)}))}_initWorkbookUnload(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{if(e.type===t.UniverInstanceType.UNIVER_SHEET){let t=e,n=t.getUnitId();t.getSheets().forEach(e=>{let t=e.getSheetId();this._enusreMap(n,t).forValue((e,t,n)=>{n&&n.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===r.SetRangeValuesMutation.id){let{unitId:n,subUnitId:r,cellValue:i}=e.params,a=this._enusreMap(n,r);i&&new t.ObjectMatrix(i).forValue((e,t,i)=>{let o=a.getValue(e,t);o&&o.dispose(),i&&i.p&&this._registerRange(n,r,e,t,i.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===C.id){let{unitId:t,subUnitId:n,row:i,col:a}=e.params,o=(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:t,subUnitId:n}),s=this._enusreMap(t,n).getValue(i,a);if(s&&s.dispose(),o){let{worksheet:e}=o,r=e.getCellRaw(i,a);r&&r.p&&this._registerRange(t,n,i,a,r.p)}}}))}};A=d([u(0,t.ICommandService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(r.RefRangeService))],A);let j=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._selectionManagerService=n,this._univerInstanceService=r,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.SetRangeValuesCommand.id){let n=e.params,{unitId:r,subUnitId:i}=n,a=[],o=[];return n.cellValue&&new t.ObjectMatrix(n.cellValue).forValue((e,t)=>{let n=this._hyperLinkModel.getHyperLinkByLocation(r,i,e,t);n&&(a.push({id:m.id,params:{unitId:r,subUnitId:i,id:n.id}}),o.push({id:p.id,params:{unitId:r,subUnitId:i,link:n}}))}),{undos:o,redos:a}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.ClearSelectionContentCommand.id||e.id===r.ClearSelectionAllCommand.id||e.id===r.ClearSelectionFormatCommand.id){let n=[],i=[],a=this._selectionManagerService.getCurrentLastSelection(),o=(0,r.getSheetCommandTarget)(this._univerInstanceService,e.params);if(a&&o){let{unitId:e,subUnitId:r}=o;t.Range.foreach(a.range,(t,a)=>{let o=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,a);o&&(n.push({id:m.id,params:{unitId:e,subUnitId:r,id:o.id}}),i.push({id:p.id,params:{unitId:e,subUnitId:r,link:o}}))})}return{redos:n,undos:i}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.AFTER_CELL_EDIT,{handler:(e,n,r)=>{if(!e||e.p)return r(e);if(typeof e.v==`string`&&t.Tools.isLegalUrl(e.v)&&e.v[e.v.length-1]!==` `){let{unitId:i,subUnitId:a,row:o,col:s}=n,c=t.Tools.normalizeUrl(e.v),l=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),u=l==null?void 0:l.getSheetBySheetId(a);if(!u)return r(e);let d=u.getBlankCellDocumentModel(e,o,s);if(!d.documentModel)return r(e);let f=t.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:e.v.length,collapsed:!1},body:{dataStream:`${e.v}`,customRanges:[{startIndex:0,endIndex:e.v.length-1,rangeId:(0,t.generateRandomId)(),rangeType:t.CustomRangeType.HYPERLINK,properties:{url:c}}]},doc:d.documentModel});if(!f)return r(e);let p=d.documentModel.getBody();return t.TextX.apply(p,f.serialize()),r({...e,p:{id:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:p,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return r(e)}}))}};j=d([u(0,(0,t.Inject)(r.SheetInterceptorService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(r.SheetsSelectionsService)),u(3,t.IUniverInstanceService)],j);let M=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._registerCommands()}_registerCommands(){[h,y,_,b,v,g,p,x,m,S,C].forEach(e=>{this._commandService.registerCommand(e)})}};M=d([u(0,t.ICommandService)],M);let N=function(e){return e.SHEET=`gid`,e.RANGE=`range`,e.DEFINE_NAME=`rangeid`,e.INVALID=`invalid`,e.URL=`url`,e}({}),P=class{constructor(e,t,n){this._univerInstanceService=e,this._localeService=t,this._definedNamesService=n}buildHyperLink(e,t,n){return`#${N.SHEET}=${t}${n?`&${typeof n==`string`?N.DEFINE_NAME:N.RANGE}=${typeof n==`string`?n:(0,a.serializeRange)(n)}`:``}`}parseHyperLink(e){if(e.startsWith(`#`)){var t,n,r,i;let a=new URLSearchParams(e.slice(1)),o={gid:(t=a.get(`gid`))==null?``:t,range:(n=a.get(`range`))==null?``:n,rangeid:(r=a.get(`rangeid`))==null?``:r,unitid:(i=a.get(`unitid`))==null?``:i},s=this._getURLName(o);return{type:s.type,name:s.name,url:e,searchObj:o}}else return{type:N.URL,name:e,url:e,searchObj:null}}_getURLName(e){var n;let{gid:r,range:i,rangeid:o,unitid:s}=e,c=s?this._univerInstanceService.getUnit(s,t.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),l={type:N.INVALID,name:this._localeService.t(`hyperLink.message.refError`)};if(!c)return l;let u=r?c.getSheetBySheetId(r):c.getActiveSheet(),d=(n=u==null?void 0:u.getName())==null?``:n;if(i){if(!u)return l;let e=(0,a.deserializeRangeWithSheet)(i).range;return(0,t.isValidRange)(e,u)&&i!==`err`?{type:N.RANGE,name:(0,a.serializeRangeWithSheet)(d,e)}:l}if(o){let e=this._definedNamesService.getValueById(c.getUnitId(),o);return e?{type:N.DEFINE_NAME,name:e.formulaOrRefString}:l}if(r){let e=c.getSheetBySheetId(r);return e?{type:N.SHEET,name:e.getName()}:l}return l}};P=d([u(0,t.IUniverInstanceService),u(1,(0,t.Inject)(t.LocaleService)),u(2,a.IDefinedNamesService)],P);let F=class extends t.Plugin{constructor(e=D,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},D,this._config);this._configService.setConfig(E,i)}onStarting(){(0,t.registerDependencies)(this._injector,[[f],[P],[M],[O],[j],[k],[A]]),(0,t.touchDependencies)(this._injector,[[O],[M],[j],[k],[A]])}};l(F,`pluginName`,`SHEET_HYPER_LINK_PLUGIN`),l(F,`packageName`,w),l(F,`version`,T),l(F,`type`,t.UniverInstanceType.UNIVER_SHEET),F=d([(0,t.DependentOn)(r.UniverSheetsPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,t.IConfigService)],F),e.AddHyperLinkCommand=h,e.AddHyperLinkMutation=p,e.AddRichHyperLinkCommand=g,e.CancelHyperLinkCommand=_,e.CancelRichHyperLinkCommand=v,e.ERROR_RANGE=`err`,Object.defineProperty(e,`HyperLinkModel`,{enumerable:!0,get:function(){return f}}),e.RemoveHyperLinkMutation=m,e.SheetHyperLinkType=N,Object.defineProperty(e,`SheetsHyperLinkParserService`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,`UniverSheetsHyperLinkPlugin`,{enumerable:!0,get:function(){return F}}),e.UpdateHyperLinkCommand=y,e.UpdateHyperLinkMutation=x,e.UpdateHyperLinkRefMutation=S,e.UpdateRichHyperLinkCommand=b});
3
3
 
4
4
  // @univerjs/sheets-hyper-link/facade
5
5
  (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets-hyper-link`),require(`@univerjs/sheets/facade`),require(`@univerjs/core/facade`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-hyper-link`,`@univerjs/sheets/facade`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLinkFacade={},e.UniverCore,e.UniverSheetsHyperLink,e.UniverSheetsFacade,e.UniverCoreFacade))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=class{constructor(e,t){this._workbook=e,this._parserService=t}getRangeUrl(e){return this._parserService.buildHyperLink(this._workbook.getId(),e.getSheetId(),e.getRange()),this}};s=o([a(1,(0,t.Inject)(n.SheetsHyperLinkParserService))],s);var c=class extends r.FWorkbook{parseSheetHyperlink(e){return this._injector.get(n.SheetsHyperLinkParserService).parseHyperLink(e)}};r.FWorkbook.extend(c);var l=class extends r.FWorksheet{getUrl(){return this._injector.get(n.SheetsHyperLinkParserService).buildHyperLink(this._workbook.getUnitId(),this._worksheet.getSheetId())}};r.FWorksheet.extend(l);var u=class extends r.FRange{setHyperLink(e,r){let i={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:r,id:(0,t.generateRandomId)()}};return this._commandService.executeCommand(n.AddHyperLinkCommand.id,i)}getHyperLinks(){var e,n;let r=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return r!=null&&r.p?(e=(n=r.p.body)==null||(n=n.customRanges)==null?void 0:n.filter(e=>e.rangeType===t.CustomRangeType.HYPERLINK).map(e=>{var n,i,a,o;return{id:`${e.rangeId}`,startIndex:e.startIndex,endIndex:e.endIndex,url:(n=(i=e.properties)==null?void 0:i.url)==null?``:n,label:(a=(o=r.p)==null||(o=o.body)==null?void 0:o.dataStream.slice(e.startIndex,e.endIndex+1).replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_START,``).replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_END,``))==null?``:a}}))==null?[]:e:[]}updateHyperLink(e,t,r){let i={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:r}};return this._commandService.executeCommand(n.UpdateHyperLinkCommand.id,i)}cancelHyperLink(e){let t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.syncExecuteCommand(n.CancelHyperLinkCommand.id,t)}getUrl(){return this._injector.get(n.SheetsHyperLinkParserService).buildHyperLink(this.getUnitId(),this.getSheetId(),this.getRange())}};r.FRange.extend(u);var d=class extends i.FEventName{get BeforeSheetLinkAdd(){return`BeforeSheetLinkAdd`}get BeforeSheetLinkCancel(){return`BeforeSheetLinkCancel`}get BeforeSheetLinkUpdate(){return`BeforeSheetLinkUpdate`}};i.FEventName.extend(d);var f=class extends i.FUniver{_initialize(e){let r=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetLinkAdd,()=>r.beforeCommandExecuted(e=>{if(e.id!==n.AddHyperLinkCommand.id)return;let r=this.getCommandSheetTarget(e);if(!r)return;let i=e.params,a={workbook:r.workbook,worksheet:r.worksheet,row:i.link.row,col:i.link.column,link:i.link};if(this.fireEvent(this.Event.BeforeSheetLinkAdd,a),a.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetLinkUpdate,()=>r.beforeCommandExecuted(e=>{if(e.id!==n.UpdateHyperLinkCommand.id)return;let r=this.getCommandSheetTarget(e);if(!r)return;let i=e.params,a={workbook:r.workbook,worksheet:r.worksheet,row:i.row,column:i.column,id:i.id,payload:i.payload};if(this.fireEvent(this.Event.BeforeSheetLinkUpdate,a),a.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetLinkCancel,()=>r.beforeCommandExecuted(e=>{if(e.id!==n.CancelHyperLinkCommand.id)return;let r=this.getCommandSheetTarget(e);if(!r)return;let i=e.params,a={workbook:r.workbook,worksheet:r.worksheet,row:i.row,column:i.column,id:i.id};if(this.fireEvent(this.Event.BeforeSheetLinkCancel,a),a.cancel)throw new t.CanceledError})))}};i.FUniver.extend(f),e.FWorkbookHyperlinkMixin=c});
6
6
 
7
7
  // @univerjs/sheets-hyper-link-ui/index
8
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets`),require(`@univerjs/sheets-ui`),require(`@univerjs/docs`),require(`@univerjs/docs-ui`),require(`@univerjs/engine-render`),require(`@univerjs/ui`),require(`rxjs`),require(`@univerjs/design`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula-ui`),require(`@univerjs/sheets-hyper-link`),require(`react`),require(`react/jsx-runtime`),require(`@univerjs/sheets-data-validation`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`@univerjs/docs`,`@univerjs/docs-ui`,`@univerjs/engine-render`,`@univerjs/ui`,`rxjs`,`@univerjs/design`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`@univerjs/sheets-hyper-link`,`react`,`react/jsx-runtime`,`@univerjs/sheets-data-validation`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLinkUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsUi,e.UniverDocs,e.UniverDocsUi,e.UniverEngineRender,e.UniverUi,e.rxjs,e.UniverDesign,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.UniverSheetsHyperLink,e.React,e.React,e.UniverSheetsDataValidation))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let g=function(e){return e.EDITING=`editing`,e.VIEWING=`viewing`,e.ZEN_EDITOR=`zen_mode`,e}({});function _(e){return t.Tools.isLegalUrl(e)}function v(e){return/^[a-zA-Z]+:\/\//.test(e)}function y(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function b(e){if(_(e)){let t=v(e)?e:y(e)?`mailto://${e}`:`http://${e}`,n;try{n=new URL(t)}catch{return e}return n.hostname===location.hostname&&n.port===location.port&&n.protocol===location.protocol&&n.pathname===location.pathname&&n.hash&&!n.search?n.hash:t}return e}let x=`sheets-hyper-link-ui.config`;Symbol(x);let S={};function C(e,t){return function(n,r){t(n,r,e)}}function w(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function T(e,n){let r=n.getMergeData(),i=n.getMaxColumns()-1,a=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),a<e.endRow&&(e.endRow=a),e.rangeType===t.RANGE_TYPE.COLUMN||t.RANGE_TYPE.ROW)return e;let o=[];return r.forEach(n=>{t.Rectangle.intersects(e,n)&&o.push(n)}),t.Rectangle.realUnion(e,...o)}let E=class{constructor(e,t,n,r,i,a){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=i,this._configService=a}navigate(e){switch(e.type){case f.SheetHyperLinkType.URL:this.navigateToOtherWebsite(e.url);break;default:this._navigateToUniver(e.searchObj)}}_navigateToUniver(e){let{gid:n,range:r,rangeid:i}=e,a=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=a.getUnitId();if(i){let e=this._definedNamesService.getValueById(o,i);if(!e)return;let{formulaOrRefString:t}=e,n=this._definedNamesService.getWorksheetByRef(o,t);if(!n){this._messageService.show({content:this._localeService.t(`hyperLink.message.refError`),type:l.MessageType.Error});return}if(n.isSheetHidden()){this._messageService.show({content:this._localeService.t(`hyperLink.message.hiddenSheet`),type:l.MessageType.Error});return}this.navigateToDefineName(o,i)}if(n){if(r){let e=(0,u.deserializeRangeWithSheet)(r);(0,t.isValidRange)(e.range)&&r!==f.ERROR_RANGE&&this.navigateToRange(o,n,e.range);return}this.navigateToSheetById(o,n)}}async navigateToRange(e,t,i,a){let o=await this.navigateToSheetById(e,t);if(o){let s=T(i,o);await this._commandService.executeCommand(n.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:s,primary:null}]}),await this._commandService.executeCommand(r.ScrollToRangeOperation.id,{range:s,forceTop:a})}}async navigateToSheetById(e,r){let i=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;let a=i.getActiveSheet();if(!a)return!1;if(a.getSheetId()===r)return a;let o=i.getSheetBySheetId(r);return o?i.getHiddenWorksheets().indexOf(r)>-1?(this._messageService.show({content:this._localeService.t(`hyperLink.message.hiddenSheet`),type:l.MessageType.Error}),!1):await this._commandService.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r})?o:!1:(this._messageService.show({content:this._localeService.t(`hyperLink.message.noSheet`),type:l.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){var t;let n=this._configService.getConfig(x);if(!(n==null||(t=n.urlHandler)==null)&&t.navigateToOtherWebsite)return n.urlHandler.navigateToOtherWebsite(e);window.open(e,`_blank`,`noopener noreferrer`)}};E=w([C(0,t.IUniverInstanceService),C(1,t.ICommandService),C(2,u.IDefinedNamesService),C(3,s.IMessageService),C(4,(0,t.Inject)(t.LocaleService)),C(5,t.IConfigService)],E);function D(e){"@babel/helpers - typeof";return D=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},D(e)}function O(e,t){if(D(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(D(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function k(e){var t=O(e,`string`);return D(t)==`symbol`?t:t+``}function A(e,t,n){return(t=k(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ee=class extends t.Disposable{constructor(...e){super(...e),A(this,`_customHyperLinks`,new Map)}isBuiltInLinkType(e){return e!==f.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(t=>t.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){let{_customHyperLinks:t}=this;t.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}};function te(e){return e.trim().length===0}function ne(e,n){let[r]=e.split(`,`).map(u.deserializeRangeWithSheet);return!r||!(0,t.isValidRange)(r.range)?``:(r.sheetName||(r.sheetName=n),(0,u.serializeRangeToRefString)(r))}let re=()=>{var e;let[c,h]=(0,p.useState)(``),[v,y]=(0,p.useState)(!1),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)(!0),[T,D]=(0,p.useState)(f.SheetHyperLinkType.URL),[O,k]=(0,p.useState)(``),A=(0,s.useDependency)(t.LocaleService),re=(0,s.useDependency)(u.IDefinedNamesService),j=(0,s.useDependency)(r.IEditorBridgeService),M=(0,s.useDependency)(t.IUniverInstanceService),N=(0,s.useDependency)(H),P=(0,s.useObservable)(N.currentEditing$),ie=(0,s.useDependency)(f.SheetsHyperLinkParserService),ae=(0,s.useDependency)(E),F=(0,s.useDependency)(t.ICommandService),I=(0,s.useDependency)(ee),oe=(0,p.useMemo)(()=>I.getOptions(),[I]),L=(0,s.useDependency)(s.IZenZoneService),R=(0,s.useDependency)(o.IRenderManagerService),se=(0,s.useDependency)(r.IMarkSelectionService),ce=(0,s.useDependency)(i.DocSelectionManagerService),z=(0,s.useDependency)(t.IContextService),le=(0,s.useDependency)(t.ThemeService),ue=(0,s.useDependency)(i.DocSelectionManagerService),[de,fe]=(0,p.useState)(!1),pe=(0,s.useDependency)(n.SheetsSelectionsService),B=(0,p.useMemo)(()=>pe.getCurrentSelections(),[]),V=(0,p.useMemo)(()=>{if(!I.isBuiltInLinkType(T))return I.getCustomHyperLink(T)},[I,T]),[U,me]=(0,p.useState)(!1),[W,he]=(0,p.useState)(!1),G=(0,p.useRef)(!1),K=M.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),J=(K==null?void 0:K.getActiveSheet().getSheetId())||``,Y=(0,p.useCallback)(e=>{S(e.replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_START,``).replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_END,``))},[S]);(0,p.useEffect)(()=>{if((P==null?void 0:P.row)!==void 0&&P.col!==void 0){let{customRange:b,row:x,col:S}=P,{label:C}=P;typeof C==`number`&&(C=`${C}`);let T;if(b){var e,n,r,i;T={id:(e=b==null?void 0:b.rangeId)==null?``:e,display:(n=C)==null?``:n,payload:(r=b==null||(i=b.properties)==null?void 0:i.url)==null?``:r,row:x,column:S}}else if(P.type===g.VIEWING){var a,o,s,c;let e=M.getUnit(P.unitId),n=e==null?void 0:e.getSheetBySheetId(P.subUnitId),r=n==null?void 0:n.getCellRaw(P.row,P.col),i=r==null||(a=r.p)==null||(a=a.body)==null||(a=a.customRanges)==null?void 0:a.find(e=>{var n;return e.rangeType===t.CustomRangeType.HYPERLINK&&((n=e.properties)==null?void 0:n.url)}),l=r==null?void 0:r.v;r&&(!t.BuildTextUtils.transform.isEmptyDocument((o=r.p)==null||(o=o.body)==null?void 0:o.dataStream)||t.Tools.isDefine(l))&&w(!1),T={id:``,display:``,payload:(s=i==null||(c=i.properties)==null?void 0:c.url)==null?``:s,row:x,column:S}}else{var l,d,p,m,_;let e=M.getCurrentUnitForType(t.UniverInstanceType.UNIVER_DOC),n=ce.getActiveTextRange(),r=e==null?void 0:e.getBody(),i=n&&r?n:null,a=i&&((l=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(i,(d=r==null?void 0:r.customRanges)==null?[]:d))==null?void 0:l[0]);w(!1),T={id:``,display:(p=C)==null?``:p,payload:(m=a==null||(_=a.properties)==null?void 0:_.url)==null?``:m,row:x,column:S}}h(T.id);let E=I.findCustomHyperLink(T);if(E){let e=E.convert(T);D(e.type),k(e.payload),Y(e.display);return}Y(T.display);let O=ie.parseHyperLink(T.payload);switch(D(O.type===f.SheetHyperLinkType.INVALID?f.SheetHyperLinkType.RANGE:O.type),O.type){case f.SheetHyperLinkType.URL:k(O.url),O.url===T.display&&(G.current=!0);break;case f.SheetHyperLinkType.RANGE:{var v,y;let e=O.searchObj,t=(0,u.serializeRangeWithSheet)(e.gid?(v=(y=M.getUnit(P.unitId))==null||(y=y.getSheetBySheetId(e.gid))==null?void 0:y.getName())==null?``:v:``,(0,u.deserializeRangeWithSheet)(e.range).range);k(t),t===T.display&&(G.current=!0);break}case f.SheetHyperLinkType.SHEET:{let e=O.searchObj;k(e.gid);break}case f.SheetHyperLinkType.DEFINE_NAME:{let e=O.searchObj;k(e.rangeid);break}default:k(``);break}}},[P,ae,I,ce,M]),(0,p.useEffect)(()=>{let e=null;if(P&&!P.customRangeId&&P.type===g.VIEWING&&t.Tools.isDefine(P.row)&&t.Tools.isDefine(P.col)){let n=M.getUnit(P.unitId,t.UniverInstanceType.UNIVER_SHEET),r=n==null?void 0:n.getSheetBySheetId(P.subUnitId),i=r==null?void 0:r.getMergedCell(P.row,P.col),a=new t.ColorKit(le.getColorFromTheme(`primary.600`)).toRgb();e=se.addShape({range:i==null?{startColumn:P.col,endColumn:P.col,startRow:P.row,endRow:P.row}:i,style:{fill:`rgb(${a.r}, ${a.g}, ${a.b}, 0.12)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1)}return()=>{e&&se.removeShape(e)}},[P,se,le,M]),(0,p.useEffect)(()=>{he(T===f.SheetHyperLinkType.RANGE)},[T]),(0,p.useEffect)(()=>{let e=(P==null?void 0:P.type)===g.ZEN_EDITOR?R.getRenderById(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY):R.getRenderById(j.getCurrentEditorId()),n=new t.DisposableCollection;if(e){let t=e.with(a.DocSelectionRenderService);t.setReserveRangesStatus(!0),n.add(()=>{t.setReserveRangesStatus(!1)})}return()=>{j.disableForceKeepVisible(),n.dispose()}},[P==null?void 0:P.type,j,R]),(0,p.useEffect)(()=>(W&&N.setIsKeepVisible(W),N.setIsKeepVisible(de),()=>{N.setIsKeepVisible(!1)}),[W,de,N]),(0,p.useEffect)(()=>()=>{L.temporaryHidden&&(L.show(),z.setContextValue(t.FOCUSING_SHEET,!1))},[z,L]),(0,p.useEffect)(()=>{if(W)return j.enableForceKeepVisible(),()=>{j.disableForceKeepVisible()}},[W,j]);let ge=[{label:A.t(`hyperLink.form.link`),value:f.SheetHyperLinkType.URL},{label:A.t(`hyperLink.form.range`),value:f.SheetHyperLinkType.RANGE},{label:A.t(`hyperLink.form.worksheet`),value:f.SheetHyperLinkType.SHEET},{label:A.t(`hyperLink.form.definedName`),value:f.SheetHyperLinkType.DEFINE_NAME},...oe];if(!K)return;let X=K.getHiddenWorksheets(),Z=K.getSheets().map(e=>({label:e.getName(),value:e.getSheetId()})).filter(e=>X.indexOf(e.value)===-1),_e=Object.values((e=re.getDefinedNameMap(K.getUnitId()))==null?{}:e).map(e=>({label:e.name,value:e.id})),Q=(e,t)=>{if(e===f.SheetHyperLinkType.URL)return b(t);if(e===f.SheetHyperLinkType.RANGE){let e=(0,u.deserializeRangeWithSheet)(t),n=K.getSheetBySheetName(e.sheetName);if(n)return`#gid=${n.getSheetId()}&range=${(0,u.serializeRange)(e.range)}`}return`#${e}=${t}`},ve=(0,s.useEvent)(e=>{var t;let n=ne(e,((t=K.getActiveSheet())==null?void 0:t.getName())||``);if(!n){k(``);return}k(n),n&&(G.current||!x)&&(Y(n),G.current=!0)}),ye=async()=>{if(C&&te(x)||!O||T===f.SheetHyperLinkType.URL&&!_(O)){me(!0);return}if(P)if(c){let e=P.type===g.ZEN_EDITOR||P.type===g.EDITING?f.UpdateRichHyperLinkCommand.id:f.UpdateHyperLinkCommand.id;await F.executeCommand(e,{id:c,unitId:P.unitId,subUnitId:P.subUnitId,payload:{display:C?x:``,payload:Q(T,O)},row:P.row,column:P.col,documentId:P.type===g.ZEN_EDITOR?t.DOCS_ZEN_EDITOR_UNIT_ID_KEY:j.getCurrentEditorId()})}else{let e=P.type===g.ZEN_EDITOR||P.type===g.EDITING?f.AddRichHyperLinkCommand.id:f.AddHyperLinkCommand.id;await F.executeCommand(e,{unitId:P.unitId,subUnitId:P.subUnitId,link:{id:(0,t.generateRandomId)(),row:P.row,column:P.col,payload:Q(T,O),display:C?x:``},documentId:P.type===g.ZEN_EDITOR?t.DOCS_ZEN_EDITOR_UNIT_ID_KEY:j.getCurrentEditorId()})}(P==null?void 0:P.type)===g.VIEWING&&(await F.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:P.unitId,subUnitId:P.subUnitId}),await F.executeCommand(r.ScrollToRangeOperation.id,{range:{startRow:Math.max(P.row-1,0),endRow:P.row+1,startColumn:Math.max(P.col-1,0),endColumn:P.col+1}})),F.executeCommand(q.id)};return P?(0,m.jsxs)(`div`,{className:(0,l.clsx)(`univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900`,l.borderClassName),children:[C?(0,m.jsx)(l.FormLayout,{label:A.t(`hyperLink.form.label`),error:U&&te(x)?A.t(`hyperLink.form.inputError`):``,children:(0,m.jsx)(l.Input,{value:x,onChange:e=>{Y(e),G.current=!1},placeholder:A.t(`hyperLink.form.labelPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===s.KeyCode.ENTER&&ye()}})}):null,(0,m.jsx)(l.FormLayout,{label:A.t(`hyperLink.form.type`),children:(0,m.jsx)(l.Select,{className:`univer-w-full`,options:ge,value:T,onChange:e=>{D(e),k(``)}})}),T===f.SheetHyperLinkType.URL&&(0,m.jsx)(l.FormLayout,{error:U?O?_(O)?``:A.t(`hyperLink.form.linkError`):A.t(`hyperLink.form.inputError`):``,children:(0,m.jsx)(l.Input,{value:O,onChange:e=>{k(e),e&&(G.current||!x||x===e)&&(Y(e),G.current=!0)},placeholder:A.t(`hyperLink.form.linkPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===s.KeyCode.ENTER&&ye()}})}),T===f.SheetHyperLinkType.RANGE&&(0,m.jsx)(l.FormLayout,{error:U&&!O?A.t(`hyperLink.form.inputError`):``,children:(0,m.jsx)(d.RangeSelector,{unitId:K.getUnitId(),subUnitId:J,maxRangeCount:1,supportAcrossSheet:!0,initialValue:O,resetRange:B,onChange:(e,t)=>ve(t),onRangeSelectorDialogVisibleChange:async e=>{if(fe(e),e)P.type===g.ZEN_EDITOR&&(L.hide(),z.setContextValue(t.FOCUSING_SHEET,!0)),P.type!==g.VIEWING&&j.enableForceKeepVisible(),y(!0);else{if(await ae.navigateToRange(P.unitId,P.subUnitId,{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col},!0),P.type===g.ZEN_EDITOR){var r,i;await F.executeCommand(n.SetSelectionsOperation.id,{unitId:P.unitId,subUnitId:P.subUnitId,selections:[{range:{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col}}]}),L.show(),z.setContextValue(t.FOCUSING_SHEET,!1);let e=(r=R.getRenderById(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(a.DocBackScrollRenderController),o=(i=ue.getTextRanges({unitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:i[0];e&&o&&(e.scrollToRange(o),ue.refreshSelection({unitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}j.disableForceKeepVisible(),y(!1)}},onFocusChange:e=>he(e)})}),T===f.SheetHyperLinkType.SHEET&&(0,m.jsx)(l.FormLayout,{error:U&&!O?A.t(`hyperLink.form.selectError`):``,children:(0,m.jsx)(l.Select,{className:`univer-w-full`,options:Z,value:O,onChange:e=>{var t,n;k(e);let r=(t=Z.find(t=>t.value===e))==null?void 0:t.label,i=(n=Z.find(e=>e.value===O))==null?void 0:n.label;r&&(G.current||!x||x===i)&&(Y(r),G.current=!0)}})}),T===f.SheetHyperLinkType.DEFINE_NAME&&(0,m.jsx)(l.FormLayout,{error:U&&!O?A.t(`hyperLink.form.selectError`):``,children:(0,m.jsx)(l.Select,{className:`univer-w-full`,options:_e,value:O,onChange:e=>{var t,n;k(e);let r=(t=_e.find(t=>t.value===e))==null?void 0:t.label,i=(n=_e.find(e=>e.value===O))==null?void 0:n.label;r&&(G.current||!x||x===i)&&(Y(r),G.current=!0)}})}),(V==null?void 0:V.Form)&&(0,m.jsx)(V.Form,{linkId:c,payload:O,display:x,showError:U,setByPayload:G,setDisplay:e=>{Y(e),G.current=!0},setPayload:k}),(0,m.jsxs)(`div`,{className:`univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[(0,m.jsx)(l.Button,{onClick:()=>{P&&ae.navigateToRange(P.unitId,P.subUnitId,{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col},!0),F.executeCommand(q.id)},children:A.t(`hyperLink.form.cancel`)}),(0,m.jsx)(l.Button,{variant:`primary`,onClick:async()=>{ye()},children:A.t(`hyperLink.form.ok`)})]})]}):null};re.componentKey=`univer.sheet.cell-link-edit`;function j({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,p.useRef)(`_${ie()}`);return M(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function M(e,t,n,r,i){return(0,p.createElement)(e.tag,{key:t,...N(e,n,i),...r},(P(e,n).children||[]).map((r,a)=>M(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function N(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function P(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function ie(){return Math.random().toString(36).substring(2,8)}j.displayName=`UniverIcon`;let ae={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{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`}}]},F=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`all-border-icon`,ref:t,icon:ae}))});F.displayName=`AllBorderIcon`;let I={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{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`}}]},oe=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`copy-icon`,ref:t,icon:I}))});oe.displayName=`CopyIcon`;let L={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z`}}]},R=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`link-icon`,ref:t,icon:L}))});R.displayName=`LinkIcon`;let se={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.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.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},ce=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:se}))});ce.displayName=`UnlinkIcon`;let z={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},le=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`write-icon`,ref:t,icon:z}))});le.displayName=`WriteIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{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:`white`,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`}}]},de=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`xlsx-multi-icon`,ref:t,icon:ue}))});de.displayName=`XlsxMultiIcon`;let fe={[f.SheetHyperLinkType.URL]:(0,m.jsx)(R,{}),[f.SheetHyperLinkType.SHEET]:(0,m.jsx)(de,{className:`univer-text-green-500`}),[f.SheetHyperLinkType.RANGE]:(0,m.jsx)(F,{}),[f.SheetHyperLinkType.DEFINE_NAME]:(0,m.jsx)(F,{}),[f.SheetHyperLinkType.INVALID]:(0,m.jsx)(F,{})},pe=e=>{var n,i;let a=(0,s.useDependency)(H),o=(0,s.useDependency)(t.ICommandService),c=(0,s.useDependency)(s.IMessageService),u=(0,s.useDependency)(t.LocaleService),d=(0,s.useDependency)(E),p=(0,s.useDependency)(r.IEditorBridgeService),h=(0,s.useDependency)(f.SheetsHyperLinkParserService),_=(0,s.useDependency)(s.IZenZoneService),{customRange:v,row:y,col:b,unitId:x,subUnitId:S,editPermission:C,copyPermission:w,type:T}=e;if(!(!(v==null||(n=v.properties)==null)&&n.url))return null;let D=h.parseHyperLink((i=v.properties.url)==null?``:i),O=D.type===f.SheetHyperLinkType.INVALID;return(0,m.jsxs)(`div`,{className:(0,l.clsx)(`univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md dark:!univer-bg-gray-900`,l.borderClassName),onClick:()=>a.hideCurrentPopup(),children:[(0,m.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600`,{"univer-text-red-500":O}),onClick:()=>{_.visible||O||d.navigate(D)},children:[(0,m.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white`,children:fe[D.type]}),(0,m.jsx)(l.Tooltip,{showIfEllipsis:!0,title:D.name,asChild:!0,children:(0,m.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:D.name})})]}),(0,m.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center`,children:[w&&(0,m.jsx)(`div`,{className:(0,l.clsx)(`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-text-red-500":O}),onClick:()=>{if(!O){if(D.type!==f.SheetHyperLinkType.URL){let e=new URL(window.location.href);e.hash=D.url.slice(1),navigator.clipboard.writeText(e.href)}else navigator.clipboard.writeText(D.url);c.show({content:u.t(`hyperLink.message.coped`),type:l.MessageType.Info})}},children:(0,m.jsx)(l.Tooltip,{placement:`bottom`,title:u.t(`hyperLink.popup.copy`),children:(0,m.jsx)(oe,{className:`dark:!univer-text-white`})})}),C&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>{o.executeCommand(K.id,{unitId:x,subUnitId:S,row:y,col:b,customRangeId:v.rangeId,type:T})},children:(0,m.jsx)(l.Tooltip,{placement:`bottom`,title:u.t(`hyperLink.popup.edit`),children:(0,m.jsx)(le,{className:`dark:!univer-text-white`})})}),(0,m.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>{let e=T===g.EDITING||T===g.ZEN_EDITOR?f.CancelRichHyperLinkCommand.id:f.CancelHyperLinkCommand.id;o.syncExecuteCommand(e,{unitId:x,subUnitId:S,id:v.rangeId,row:y,column:b,documentId:T===g.ZEN_EDITOR?t.DOCS_ZEN_EDITOR_UNIT_ID_KEY:p.getCurrentEditorId()})&&a.hideCurrentPopup(void 0,!0)},children:(0,m.jsx)(l.Tooltip,{placement:`bottom`,title:u.t(`hyperLink.popup.cancel`),children:(0,m.jsx)(ce,{className:`dark:!univer-text-white`})})})]})]})]})},B=()=>{let e=(0,s.useDependency)(H),[n,r]=(0,p.useState)(null),i=(0,s.useDependency)(t.IUniverInstanceService);if((0,p.useEffect)(()=>{r(e.currentPopup);let t=e.currentPopup$.subscribe(e=>{r(e)});return()=>{t.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){var a;let e=i.getUnit(n.unitId,t.UniverInstanceType.UNIVER_SHEET),r=e==null?void 0:e.getSheetBySheetId(n.subUnitId),o=r==null?void 0:r.getCell(n.row,n.col),s=o==null||(a=o.p)==null||(a=a.body)==null?void 0:a.customRanges;return s!=null&&s.length?(0,m.jsx)(`div`,{children:s.map(e=>(0,m.jsx)(pe,{...n,customRange:e},e.rangeId))}):null}return(0,m.jsx)(pe,{...n})};B.componentKey=`univer.sheet.cell-link-popup`;let V=(e,t)=>{var n,r;return e.unitId===t.unitId&&e.subUnitId===t.subUnitId&&e.row===t.row&&e.col===t.col&&((n=e.customRange)==null?void 0:n.rangeId)===((r=t.customRange)==null?void 0:r.rangeId)&&e.type===t.type},H=class extends t.Disposable{get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}constructor(e,t,n,r,i,a,o){super(),this._sheetCanvasPopManagerService=e,this._injector=t,this._univerInstanceService=n,this._editorBridgeService=r,this._textSelectionManagerService=i,this._docCanvasPopManagerService=a,this._zenZoneService=o,A(this,`_currentPopup`,null),A(this,`_currentPopup$`,new c.Subject),A(this,`currentPopup$`,this._currentPopup$.asObservable()),A(this,`_currentEditingPopup`,null),A(this,`_currentEditing$`,new c.BehaviorSubject(null)),A(this,`currentEditing$`,this._currentEditing$.asObservable()),A(this,`_isKeepVisible`,!1),this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&V(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==g.ZEN_EDITOR&&this._zenZoneService.visible))return;let n=this._currentEditing$.getValue();if(n&&V(e,n))return;let{unitId:r,subUnitId:i,row:a,col:o,customRangeRect:s,customRange:c}=e,l,u={componentKey:B.componentKey,direction:`bottom`,onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===g.EDITING){if(!c)return;l=s&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(s,u)}else if(e.type===g.ZEN_EDITOR){if(!c)return;l=this._docCanvasPopManagerService.attachPopupToRange({startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},u,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)l=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,u,r,i);else{if(!c)return;l=s&&this._sheetCanvasPopManagerService.attachPopupByPosition(s,u,e)}if(l){if(this._currentPopup){var d;(d=this._currentPopup.disposable)==null||d.dispose()}this._currentPopup={unitId:r,subUnitId:i,disposable:l,row:a,col:o,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:c,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup)}}hideCurrentPopup(e,t){if(this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||t)){var n;(n=this._currentPopup)==null||(n=n.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null)}}dispose(){super.dispose(),this.hideCurrentPopup(),this.endEditing(),this._currentPopup$.complete(),this._currentEditing$.complete()}_getEditingRange(){let e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){var r,i,a;let e=this._textSelectionManagerService.getActiveTextRange(),o=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!o)return null;if(!e||e.collapsed)return{startOffset:0,endOffset:o.dataStream.length-2,collapsed:o.dataStream.length-2==0,label:t.BuildTextUtils.transform.getPlainText(o.dataStream)};let s=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(e,(i=(a=o.customRanges)==null?void 0:a.filter(e=>e.rangeType===t.CustomRangeType.HYPERLINK))==null?[]:i),c=e.startOffset,l=e.endOffset;return s.forEach(e=>{c=Math.min(c,e.startIndex),l=Math.max(l,e.endIndex+1)}),{startOffset:c,endOffset:l,collapsed:c===l,label:t.BuildTextUtils.transform.getPlainText(o.dataStream.slice(c,l))}}return null}get _editPopup(){return{componentKey:re.componentKey,direction:`vertical`,onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:`hide`}}startAddEditing(e){let{unitId:n,subUnitId:r,type:i}=e;if(i===g.ZEN_EDITOR){var s;let n=this._univerInstanceService.getUnit(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,t.UniverInstanceType.UNIVER_DOC);if(!n)return;let r=this._textSelectionManagerService.getActiveTextRange();if(!r)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(r,this._editPopup,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY);let i=(s=n.getBody())==null?void 0:s.dataStream.slice(r.startOffset,r.endOffset);this._currentEditing$.next({...e,label:i})}else if(i===g.EDITING){var c;let i=this._getEditingRange();if(!i)return;this._textSelectionManagerService.replaceDocRanges([{...i}],{unitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});let s=this._injector.get(o.IRenderManagerService).getRenderById(t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!s)return;let l=(0,a.calcDocRangePositions)(i,s);if(!(l!=null&&l.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(c=i==null?void 0:i.label)==null?``:c})}else{var l,u,d;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);let i=this._univerInstanceService.getUnit(n,t.UniverInstanceType.UNIVER_SHEET),a=i==null?void 0:i.getSheetBySheetId(r),o=a==null?void 0:a.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:o!=null&&o.p?t.BuildTextUtils.transform.getPlainText((l=(u=o.p.body)==null?void 0:u.dataStream)==null?``:l):((d=o==null?void 0:o.v)==null?``:d).toString()})}}startEditing(e){var n;(n=this._currentEditingPopup)==null||n.dispose(),this.hideCurrentPopup(void 0,!0);let{unitId:i,subUnitId:a}=e,o,s;if(e.type===g.ZEN_EDITOR){var c,l;let n=this._univerInstanceService.getUnit(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,t.UniverInstanceType.UNIVER_DOC);if(o=n==null||(c=n.getBody())==null||(c=c.customRanges)==null?void 0:c.find(t=>t.rangeId===e.customRangeId),s=o?n==null||(l=n.getBody())==null?void 0:l.dataStream.slice(o.startIndex,o.endIndex+1):``,!o||!s)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1},this._editPopup,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===g.EDITING){var u;let t=(0,r.getEditingCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!t||!((u=t.rects)!=null&&u.length))return;o=t.customRange,s=t.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(t.rects.pop(),this._editPopup,i,a)}else{var d;let n=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),c=n==null?void 0:n.getSheetBySheetId(a),l=c==null?void 0:c.getCellRaw(e.row,e.col),u=n==null?void 0:n.getStyles().getStyleByCell(l),f=u==null?void 0:u.tr,p=(0,r.getCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!p||!((d=p.rects)!=null&&d.length))return;o=p.customRange,s=p.label,f?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,a):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(p.rects.pop(),this._editPopup,{unitId:i,subUnitId:a,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:o,label:s})}endEditing(e){if(this.getIsKeepVisible())return;let t=this._currentEditing$.getValue();if(t&&(!e||e===t.type)){var n;(n=this._currentEditingPopup)==null||n.dispose(),this._currentEditing$.next(null)}}};H=w([C(0,(0,t.Inject)(r.SheetCanvasPopManagerService)),C(1,(0,t.Inject)(t.Injector)),C(2,t.IUniverInstanceService),C(3,r.IEditorBridgeService),C(4,(0,t.Inject)(i.DocSelectionManagerService)),C(5,(0,t.Inject)(a.DocCanvasPopManagerService)),C(6,s.IZenZoneService)],H);let U=function(e){return e[e.ALLOWED=0]=`ALLOWED`,e[e.DISABLED_BY_CELL=1]=`DISABLED_BY_CELL`,e[e.ALLOW_ON_EDITING=2]=`ALLOW_ON_EDITING`,e}({}),me=new Set([t.DataValidationType.CHECKBOX,t.DataValidationType.LIST,t.DataValidationType.LIST_MULTIPLE]),W=(e,t,n,r)=>{var i,a;let o=t.getCell(n,r);if(o!=null&&o.f||o!=null&&o.si||!(o==null||(i=o.p)==null||(i=i.body)==null||(i=i.customBlocks)==null)&&i.length)return U.DISABLED_BY_CELL;let s=e.has(h.SheetDataValidationModel)?e.get(h.SheetDataValidationModel):null,c=s==null?void 0:s.getRuleByLocation(t.getUnitId(),t.getSheetId(),n,r);return c&&me.has(c.type)?!0:!(o==null||(a=o.p)==null||(a=a.drawingsOrder)==null)&&a.length?U.ALLOW_ON_EDITING:U.ALLOWED},he=e=>{let r=e.get(t.IUniverInstanceService).getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!r)return!0;let i=r.getActiveSheet(),a=e.get(n.SheetsSelectionsService).getCurrentSelections();if(!a.length)return!0;let o=a[0].range.startRow,s=a[0].range.startColumn;return W(e,i,o,s)===U.DISABLED_BY_CELL},G=e=>{let n=e.get(i.DocSelectionManagerService),r=e.get(t.IUniverInstanceService),a=n.getTextRanges();if(!(a!=null&&a.length))return!0;let o=r.getCurrentUnitForType(t.UniverInstanceType.UNIVER_DOC);return!!(!o||a.every(e=>e.collapsed)||!o.getSelfOrHeaderFooterModel(a[0].segmentId).getBody())},K={type:t.CommandType.OPERATION,id:`sheet.operation.open-hyper-link-edit-panel`,handler(e,t){if(!t)return!1;let n=e.get(H);return t.customRangeId?n.startEditing(t):n.startAddEditing(t),!0}},q={type:t.CommandType.OPERATION,id:`sheet.operation.close-hyper-link-popup`,handler(e){return e.get(H).endEditing(),!0}},J={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link`,handler(e){var i;let a=e.get(t.IUniverInstanceService),o=(0,n.getSheetCommandTarget)(a),s=e.get(r.IEditorBridgeService);if(!o)return!1;let c=e.get(t.ICommandService),l=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!l)return!1;let u=l.range.startRow,d=l.range.startColumn,f=s.isVisible(),p=((i=a.getFocusedUnit())==null?void 0:i.getUnitId())===t.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return c.executeCommand(K.id,{unitId:o.unitId,subUnitId:o.subUnitId,row:u,col:d,type:p?g.ZEN_EDITOR:f.visible?g.EDITING:g.VIEWING})}},Y={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link-toolbar`,handler(e){if(he(e))return!1;let n=e.get(t.ICommandService);return e.get(H).currentEditing?n.executeCommand(q.id):n.executeCommand(J.id)}},ge=`SHEET_HYPER_LINK_UI_PLUGIN`,X=class extends t.Disposable{registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(t=>t(e))}constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._hyperLinkModel=t,this._injector=n,this._resolverService=r,A(this,`_plainTextFilter`,new Set),A(this,`_copyInfo`,void 0),this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ge,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,i)=>{let{copyType:a=r.COPY_TYPE.COPY,pasteType:o}=i,{range:s}=e||{},{range:c,unitId:l,subUnitId:u}=t;return this._generateMutations(c,{copyType:a,pasteType:o,copyRange:s,unitId:l,subUnitId:u})},onPastePlainText:(e,n)=>{let i=this._filterPlainText(n);if(_(n)&&i){let{range:n,unitId:i,subUnitId:a}=e,{ranges:[o],mapFunc:s}=(0,r.virtualizeDiscreteRanges)([n]),c=[],l=[];return t.Range.foreach(o,(e,t)=>{let{row:n,col:r}=s(e,t),o=this._hyperLinkModel.getHyperLinkByLocation(i,a,n,r);o&&c.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:i,subUnitId:a,id:o.id}}),o&&l.push({id:f.AddHyperLinkMutation.id,params:{unitId:i,subUnitId:a,link:o}})}),{redos:c,undos:l}}return{undos:[],redos:[]}},priority:99})}_collect(e,r,i){let a=new t.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:r,matrix:a};let o=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!o)return;let{rows:s,cols:c}=o;s.forEach((t,n)=>{c.forEach((i,o)=>{var s;let c=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,i);a.setValue(n,o,(s=c==null?void 0:c.id)==null?``:s)})})}_generateMutations(e,n){if(!this._copyInfo||!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange||[r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};let{unitId:i,subUnitId:a}=this._copyInfo,o=[],s=[],{ranges:[c,l],mapFunc:u}=(0,r.virtualizeDiscreteRanges)([n.copyRange,e]);return(0,r.getRepeatRange)(c,l,!0).forEach(({startRange:e})=>{var r;(r=this._copyInfo)==null||r.matrix.forValue((r,c,l)=>{let d=t.Rectangle.getPositionRange({startRow:r,endRow:r,startColumn:c,endColumn:c},e),p=this._hyperLinkModel.getHyperLink(i,a,l),{row:m,col:h}=u(d.startRow,d.startColumn),g=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,m,h),_=(0,t.generateRandomId)();g&&o.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:g.id}}),p&&(o.push({id:f.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...p,id:_,row:m,column:h}}}),s.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:_}})),g&&s.push({id:f.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:g}})})}),{redos:o,undos:s}}};X=w([C(0,r.ISheetClipboardService),C(1,(0,t.Inject)(f.HyperLinkModel)),C(2,(0,t.Inject)(t.Injector)),C(3,(0,t.Inject)(E))],X);let Z=(e,i=t.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var s;let l=e.get(t.IUniverInstanceService),u=(s=e.get(o.IRenderManagerService).getRenderById(i))==null?void 0:s.with(a.DocSelectionRenderService);return u?u.textSelectionInner$.pipe((0,c.map)(()=>{let t=e.get(r.IEditorBridgeService).getEditCellState();if(!t)return!0;let i=(0,n.getSheetCommandTarget)(l,{unitId:t.unitId,subUnitId:t.sheetId});return!(i!=null&&i.worksheet)||W(e,i.worksheet,t.row,t.column)===1?!0:G(e)})):(0,c.of)(!0)},_e=e=>{var i;let a=e.get(t.IUniverInstanceService),o=e.has(r.IEditorBridgeService)?e.get(r.IEditorBridgeService):null;return((i=o==null?void 0:o.currentEditCellState$.pipe((0,c.map)(t=>{if(!t)return U.DISABLED_BY_CELL;let r=(0,n.getSheetCommandTarget)(a,{unitId:t.unitId,subUnitId:t.sheetId});return r?W(e,r.worksheet,t.row,t.column):U.DISABLED_BY_CELL}),(0,c.switchMap)(n=>n===U.DISABLED_BY_CELL?(0,c.of)(!0):(0,c.combineLatest)([o?o.visible$:(0,c.of)(null),a.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC)]).pipe((0,c.switchMap)(([r,i])=>r!=null&&r.visible?(i==null?void 0:i.getUnitId())===t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?(0,c.of)(!0):Z(e,t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):(0,c.of)(n!==U.ALLOWED))))))==null?(0,c.of)(!0):i).pipe((0,c.switchMap)(t=>t?(0,c.of)(!0):(0,r.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},!0)))},Q={commandId:J.id,type:s.MenuItemType.BUTTON,title:`hyperLink.menu.add`,icon:`LinkIcon`},ve=e=>`${e}-zen-editor`,ye=e=>({...Q,id:Q.commandId,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:_e(e)}),be=e=>({...Q,id:ve(Q.commandId),hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Z(e)}),xe={tooltip:`hyperLink.form.addTitle`,commandId:Y.id,type:s.MenuItemType.BUTTON,icon:`LinkIcon`},Se=e=>({...xe,id:xe.commandId,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:_e(e)}),Ce=e=>({...xe,id:ve(xe.commandId),hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Z(e)}),we={id:Y.id,binding:s.KeyCode.K|s.MetaKeys.CTRL_COMMAND,preconditions:r.whenSheetEditorFocused};var Te=`@univerjs/sheets-hyper-link-ui`,Ee=`0.20.0`;let De=class extends t.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,i)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,l=(0,r.virtualizeDiscreteRanges)([a,o]),[u,d]=l.ranges,{mapFunc:p}=l,m={row:u.startRow,col:u.startColumn},h=n.AutoFillTools.getAutoFillRepeatRange(u,d),g=[],_=[];return h.forEach(e=>{let r=e.repeatStartCell,a=e.relativeRange,o={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},l={startRow:r.row,startColumn:r.col,endColumn:r.col,endRow:r.row};t.Range.foreach(a,(e,r)=>{let a=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},o),{row:u,col:d}=p(a.startRow,a.startColumn),m=this._hyperLinkModel.getHyperLinkByLocation(s,c,u,d),h=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},l),{row:v,col:y}=p(h.startRow,h.startColumn),b=(0,t.generateRandomId)(),x=this._hyperLinkModel.getHyperLinkByLocation(s,c,v,y);x&&g.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:x.id}}),(n.AUTO_FILL_APPLY_TYPE.COPY===i||n.AUTO_FILL_APPLY_TYPE.SERIES===i)&&m&&(g.push({id:f.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{...m,id:b,row:v,column:y}}}),_.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:b}})),x&&_.push({id:f.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:x}})})}),{undos:_,redos:g}},a={id:ge,onFillData:(t,r,a)=>a===n.AUTO_FILL_APPLY_TYPE.COPY||a===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===n.AUTO_FILL_APPLY_TYPE.SERIES?i(t,a):e()};this.disposeWithMe(this._autoFillService.addHook(a))}};De=w([C(0,n.IAutoFillService),C(1,(0,t.Inject)(f.HyperLinkModel))],De);let Oe=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===we.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.hyperLinkErr`)))}))}};Oe=w([C(0,(0,t.Inject)(t.LocaleService)),C(1,t.ICommandService),C(2,(0,t.Inject)(n.SheetPermissionCheckController))],Oe);let ke=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionCheckController=i,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=s,this._univerInstanceService=c,this._zenZoneService=l,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){let{unitId:r,subUnitId:i,row:a,col:o}=e,s=this._univerInstanceService.getUnit(r,t.UniverInstanceType.UNIVER_SHEET),c=s==null?void 0:s.getSheetBySheetId(i);if(!c)return{viewPermission:!1,editPermission:!1,copyPermission:!1};let l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookViewPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),d=c.getCellRaw(a,o);d!=null&&d.f&&d.f.startsWith(`=HYPERLINK(`)&&(u=!1);let f=this._permissionService.composePermission([new n.WorkbookCopyPermission(r).id,new n.WorksheetCopyPermission(r,i).id]).every(e=>e.value);return{viewPermission:l,editPermission:u,copyPermission:f}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe((0,c.debounceTime)(200)).subscribe(e=>{var n,i,a;if(!e||((n=e.customRange)==null?void 0:n.rangeType)!==t.CustomRangeType.HYPERLINK){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let{unitId:o,subUnitId:s,row:c,col:l}=e,u=this._renderManagerService.getRenderById(o);if(!u)return;let d=this._univerInstanceService.getUnit(o,t.UniverInstanceType.UNIVER_SHEET),f=d==null?void 0:d.getSheetBySheetId(s);if(!f)return;if(!u.with(r.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(g.VIEWING);return}let p=u==null||(i=u.with(r.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:i.skeleton,m=l,h=c,_=h,v=m;p&&p.overflowCache.forValue((e,n,r)=>{t.Rectangle.contains(r,{startColumn:m,endColumn:m,startRow:h,endRow:h})&&(_=e,v=n)});let{viewPermission:y,editPermission:b,copyPermission:x}=this._getLinkPermission(e);if(!y){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let S=f.getCellStyleOnly(_,v),C=d.getStyles().getStyleByCell(S),w=C==null||(a=C.tr)==null?void 0:a.a;if(!w&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:_,col:v,editPermission:b,copyPermission:x,customRange:e.customRange,customRangeRect:e.rect,type:g.VIEWING,unitId:o,subUnitId:s,showAll:!!w})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe((0,c.switchMap)(e=>this._editorBridgeService.visible$.pipe((0,c.map)(t=>({visible:t,state:e}))))).subscribe(({visible:n,state:i})=>{if(!i||i.editorUnitId!==t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(g.EDITING),this._sheetsHyperLinkPopupService.endEditing(g.EDITING);return}let{editorUnitId:o,unitId:s,sheetId:l,row:u,column:d}=i,f=this._renderManagerService.getRenderById(o);if(!f)return;let{editPermission:p,viewPermission:m,copyPermission:h}=this._getLinkPermission({unitId:s,subUnitId:l,row:u,col:d}),_=f.with(a.DocEventManagerService);m&&(e==null||e.unsubscribe(),e=_.hoverCustomRanges$.pipe((0,c.debounceTime)(200)).subscribe(e=>{var n;let i=e.find(e=>e.range.rangeType===t.CustomRangeType.HYPERLINK);if(!i){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let a=i.rects[i.rects.length-1];if(!(!((n=this._renderManagerService.getRenderById(s))==null||(n=n.with(r.SheetSkeletonManagerService).getSkeletonParam(l))==null)&&n.skeleton)||!a)return;let o=f.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:s,subUnitId:l,row:u,col:d,customRange:i.range,customRangeRect:{left:a.left+o.left,top:a.top+o.top,bottom:a.bottom+o.top,right:a.right+o.left},editPermission:p,copyPermission:h,type:g.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(g.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(g.EDITING),this._sheetsHyperLinkPopupService.endEditing(g.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(g.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(g.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(g.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe((0,c.switchMap)(e=>{let n=e===t.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(a.DocEventManagerService).hoverCustomRanges$.pipe((0,c.debounceTime)(200)):new c.Observable(e=>{e.next(null)})})).subscribe(e=>{let n=e==null?void 0:e.find(e=>e.range.rangeType===t.CustomRangeType.HYPERLINK),r=this._editorBridgeService.getEditCellState();if(n&&r){let{unitId:e,sheetId:t,row:i,column:a}=r,{editPermission:o,viewPermission:s,copyPermission:c}=this._getLinkPermission({unitId:e,subUnitId:t,row:i,col:a});s&&this._sheetsHyperLinkPopupService.showPopup({type:g.ZEN_EDITOR,unitId:e,subUnitId:t,row:i,col:a,customRange:n.range,editPermission:o,copyPermission:c})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(g.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(g.EDITING)}))}_initCommandListener(){let e=[n.ClearSelectionContentCommand.id,n.ClearSelectionAllCommand.id,n.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};ke=w([C(0,(0,t.Inject)(r.HoverManagerService)),C(1,(0,t.Inject)(H)),C(2,(0,t.Inject)(o.IRenderManagerService)),C(3,(0,t.Inject)(t.IPermissionService)),C(4,(0,t.Inject)(n.SheetPermissionCheckController)),C(5,t.ICommandService),C(6,r.IEditorBridgeService),C(7,(0,t.Inject)(i.DocSelectionManagerService)),C(8,t.IUniverInstanceService),C(9,s.IZenZoneService)],ke);let Ae=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._hyperLinkModel=t,this._initSkeletonChange()}_initSkeletonChange(){let e=()=>{var e;(e=this._context.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe((0,c.debounceTime)(16)).subscribe(()=>{e()}))}};Ae=w([C(1,(0,t.Inject)(f.HyperLinkModel))],Ae);let je=class extends t.Disposable{constructor(e,t){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Value,priority:100,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t,s=this._hyperLinkModel.getHyperLinkByLocation(a,o,r,i);return s&&e?(e===t.rawData&&(e={...t.rawData}),e.linkUrl=s.payload,e.linkId=s.id,n(e)):n(e)}}))}};je=w([C(0,(0,t.Inject)(n.SheetInterceptorService)),C(1,(0,t.Inject)(f.HyperLinkModel))],je);let Me={[s.RibbonInsertGroup.MEDIA]:{[Y.id]:{order:1,menuItemFactory:Se},[ve(Y.id)]:{order:1,menuItemFactory:Ce}},[s.ContextMenuPosition.MAIN_AREA]:{[s.ContextMenuGroup.OTHERS]:{order:1,[Y.id]:{order:0,menuItemFactory:ye},[ve(Y.id)]:{order:0,menuItemFactory:be}}}},Ne=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[B.componentKey,B],[re.componentKey,re],[`LinkIcon`,R]].forEach(([e,t])=>{this._componentManager.register(e,t)})}_initCommands(){[K,q,J,Y].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(Me)}_initShortCut(){this._shortcutService.registerShortcut(we)}};Ne=w([C(0,(0,t.Inject)(s.ComponentManager)),C(1,t.ICommandService),C(2,s.IMenuManagerService),C(3,(0,t.Inject)(t.Injector)),C(4,(0,t.Inject)(s.IShortcutService))],Ne);let Pe=class extends t.Disposable{constructor(e,t){super(),this._parserService=e,this._resolverService=t,this._handleInitUrl()}_handleInitUrl(){let e=location.hash;if(e){let t=this._parserService.parseHyperLink(e);this._resolverService.navigate(t)}}};Pe=w([C(0,(0,t.Inject)(f.SheetsHyperLinkParserService)),C(1,(0,t.Inject)(E))],Pe);let $=class extends t.Plugin{constructor(e=S,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},S,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(x,a)}onStarting(){[[E],[H],[ee],[je],[ke],[Ne],[De],[X],[Oe],[Pe]].forEach(e=>this._injector.add(e)),this._injector.get(je)}onReady(){this._injector.get(o.IRenderManagerService).registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[Ae]),this._injector.get(De),this._injector.get(X),this._injector.get(Ne)}onRendered(){this._injector.get(Oe),this._injector.get(Pe),this._injector.get(ke)}};A($,`pluginName`,ge),A($,`packageName`,Te),A($,`version`,Ee),A($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=w([(0,t.DependentOn)(f.UniverSheetsHyperLinkPlugin,a.UniverDocsUIPlugin),C(1,(0,t.Inject)(t.Injector)),C(2,t.IConfigService)],$),e.CloseHyperLinkPopupOperation=q,e.InsertHyperLinkOperation=J,e.InsertLinkShortcut=we,e.OpenHyperLinkEditPanelOperation=K,Object.defineProperty(e,`SheetsHyperLinkCopyPasteController`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,`SheetsHyperLinkPopupService`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,`SheetsHyperLinkResolverService`,{enumerable:!0,get:function(){return E}}),e.SheetsHyperLinkSidePanelService=ee,Object.defineProperty(e,`UniverSheetsHyperLinkUIPlugin`,{enumerable:!0,get:function(){return $}})});
8
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets`),require(`@univerjs/sheets-ui`),require(`@univerjs/docs`),require(`@univerjs/docs-ui`),require(`@univerjs/engine-render`),require(`@univerjs/ui`),require(`rxjs`),require(`@univerjs/design`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula-ui`),require(`@univerjs/sheets-hyper-link`),require(`react`),require(`react/jsx-runtime`),require(`@univerjs/sheets-data-validation`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`@univerjs/docs`,`@univerjs/docs-ui`,`@univerjs/engine-render`,`@univerjs/ui`,`rxjs`,`@univerjs/design`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`@univerjs/sheets-hyper-link`,`react`,`react/jsx-runtime`,`@univerjs/sheets-data-validation`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLinkUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsUi,e.UniverDocs,e.UniverDocsUi,e.UniverEngineRender,e.UniverUi,e.rxjs,e.UniverDesign,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.UniverSheetsHyperLink,e.React,e.React,e.UniverSheetsDataValidation))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let g=function(e){return e.EDITING=`editing`,e.VIEWING=`viewing`,e.ZEN_EDITOR=`zen_mode`,e}({});function _(e){return t.Tools.isLegalUrl(e)}function v(e){return/^[a-zA-Z]+:\/\//.test(e)}function y(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function b(e){if(_(e)){let t=v(e)?e:y(e)?`mailto://${e}`:`http://${e}`,n;try{n=new URL(t)}catch{return e}return n.hostname===location.hostname&&n.port===location.port&&n.protocol===location.protocol&&n.pathname===location.pathname&&n.hash&&!n.search?n.hash:t}return e}let x=`sheets-hyper-link-ui.config`;Symbol(x);let S={};function C(e,t){return function(n,r){t(n,r,e)}}function w(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function T(e,n){let r=n.getMergeData(),i=n.getMaxColumns()-1,a=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),a<e.endRow&&(e.endRow=a),e.rangeType===t.RANGE_TYPE.COLUMN||t.RANGE_TYPE.ROW)return e;let o=[];return r.forEach(n=>{t.Rectangle.intersects(e,n)&&o.push(n)}),t.Rectangle.realUnion(e,...o)}let E=class{constructor(e,t,n,r,i,a){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=i,this._configService=a}navigate(e){switch(e.type){case f.SheetHyperLinkType.URL:this.navigateToOtherWebsite(e.url);break;default:this._navigateToUniver(e.searchObj)}}_navigateToUniver(e){let{gid:n,range:r,rangeid:i}=e,a=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=a.getUnitId();if(i){let e=this._definedNamesService.getValueById(o,i);if(!e)return;let{formulaOrRefString:t}=e,n=this._definedNamesService.getWorksheetByRef(o,t);if(!n){this._messageService.show({content:this._localeService.t(`hyperLink.message.refError`),type:l.MessageType.Error});return}if(n.isSheetHidden()){this._messageService.show({content:this._localeService.t(`hyperLink.message.hiddenSheet`),type:l.MessageType.Error});return}this.navigateToDefineName(o,i)}if(n){if(r){let e=(0,u.deserializeRangeWithSheet)(r);(0,t.isValidRange)(e.range)&&r!==f.ERROR_RANGE&&this.navigateToRange(o,n,e.range);return}this.navigateToSheetById(o,n)}}async navigateToRange(e,t,i,a){let o=await this.navigateToSheetById(e,t);if(o){let s=T(i,o);await this._commandService.executeCommand(n.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:s,primary:null}]}),await this._commandService.executeCommand(r.ScrollToRangeOperation.id,{range:s,forceTop:a})}}async navigateToSheetById(e,r){let i=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;let a=i.getActiveSheet();if(!a)return!1;if(a.getSheetId()===r)return a;let o=i.getSheetBySheetId(r);return o?i.getHiddenWorksheets().indexOf(r)>-1?(this._messageService.show({content:this._localeService.t(`hyperLink.message.hiddenSheet`),type:l.MessageType.Error}),!1):await this._commandService.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:r})?o:!1:(this._messageService.show({content:this._localeService.t(`hyperLink.message.noSheet`),type:l.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){var t;let n=this._configService.getConfig(x);if(!(n==null||(t=n.urlHandler)==null)&&t.navigateToOtherWebsite)return n.urlHandler.navigateToOtherWebsite(e);window.open(e,`_blank`,`noopener noreferrer`)}};E=w([C(0,t.IUniverInstanceService),C(1,t.ICommandService),C(2,u.IDefinedNamesService),C(3,s.IMessageService),C(4,(0,t.Inject)(t.LocaleService)),C(5,t.IConfigService)],E);function D(e){"@babel/helpers - typeof";return D=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},D(e)}function O(e,t){if(D(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(D(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function k(e){var t=O(e,`string`);return D(t)==`symbol`?t:t+``}function A(e,t,n){return(t=k(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ee=class extends t.Disposable{constructor(...e){super(...e),A(this,`_customHyperLinks`,new Map)}isBuiltInLinkType(e){return e!==f.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(t=>t.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){let{_customHyperLinks:t}=this;t.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}};function te(e){return e.trim().length===0}function ne(e,n){let[r]=e.split(`,`).map(u.deserializeRangeWithSheet);return!r||!(0,t.isValidRange)(r.range)?``:(r.sheetName||(r.sheetName=n),(0,u.serializeRangeToRefString)(r))}let re=()=>{var e;let[c,h]=(0,p.useState)(``),[v,y]=(0,p.useState)(!1),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)(!0),[T,D]=(0,p.useState)(f.SheetHyperLinkType.URL),[O,k]=(0,p.useState)(``),A=(0,s.useDependency)(t.LocaleService),re=(0,s.useDependency)(u.IDefinedNamesService),j=(0,s.useDependency)(r.IEditorBridgeService),M=(0,s.useDependency)(t.IUniverInstanceService),N=(0,s.useDependency)(H),P=(0,s.useObservable)(N.currentEditing$),ie=(0,s.useDependency)(f.SheetsHyperLinkParserService),ae=(0,s.useDependency)(E),F=(0,s.useDependency)(t.ICommandService),I=(0,s.useDependency)(ee),oe=(0,p.useMemo)(()=>I.getOptions(),[I]),L=(0,s.useDependency)(s.IZenZoneService),R=(0,s.useDependency)(o.IRenderManagerService),se=(0,s.useDependency)(r.IMarkSelectionService),ce=(0,s.useDependency)(i.DocSelectionManagerService),z=(0,s.useDependency)(t.IContextService),le=(0,s.useDependency)(t.ThemeService),ue=(0,s.useDependency)(i.DocSelectionManagerService),[de,fe]=(0,p.useState)(!1),pe=(0,s.useDependency)(n.SheetsSelectionsService),B=(0,p.useMemo)(()=>pe.getCurrentSelections(),[]),V=(0,p.useMemo)(()=>{if(!I.isBuiltInLinkType(T))return I.getCustomHyperLink(T)},[I,T]),[U,me]=(0,p.useState)(!1),[W,he]=(0,p.useState)(!1),G=(0,p.useRef)(!1),K=M.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),J=(K==null?void 0:K.getActiveSheet().getSheetId())||``,Y=(0,p.useCallback)(e=>{S(e.replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_START,``).replaceAll(t.DataStreamTreeTokenType.CUSTOM_RANGE_END,``))},[S]);(0,p.useEffect)(()=>{if((P==null?void 0:P.row)!==void 0&&P.col!==void 0){let{customRange:b,row:x,col:S}=P,{label:C}=P;typeof C==`number`&&(C=`${C}`);let T;if(b){var e,n,r,i;T={id:(e=b==null?void 0:b.rangeId)==null?``:e,display:(n=C)==null?``:n,payload:(r=b==null||(i=b.properties)==null?void 0:i.url)==null?``:r,row:x,column:S}}else if(P.type===g.VIEWING){var a,o,s,c;let e=M.getUnit(P.unitId),n=e==null?void 0:e.getSheetBySheetId(P.subUnitId),r=n==null?void 0:n.getCellRaw(P.row,P.col),i=r==null||(a=r.p)==null||(a=a.body)==null||(a=a.customRanges)==null?void 0:a.find(e=>{var n;return e.rangeType===t.CustomRangeType.HYPERLINK&&((n=e.properties)==null?void 0:n.url)}),l=r==null?void 0:r.v;r&&(!t.BuildTextUtils.transform.isEmptyDocument((o=r.p)==null||(o=o.body)==null?void 0:o.dataStream)||t.Tools.isDefine(l))&&w(!1),T={id:``,display:``,payload:(s=i==null||(c=i.properties)==null?void 0:c.url)==null?``:s,row:x,column:S}}else{var l,d,p,m,_;let e=M.getCurrentUnitForType(t.UniverInstanceType.UNIVER_DOC),n=ce.getActiveTextRange(),r=e==null?void 0:e.getBody(),i=n&&r?n:null,a=i&&((l=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(i,(d=r==null?void 0:r.customRanges)==null?[]:d))==null?void 0:l[0]);w(!1),T={id:``,display:(p=C)==null?``:p,payload:(m=a==null||(_=a.properties)==null?void 0:_.url)==null?``:m,row:x,column:S}}h(T.id);let E=I.findCustomHyperLink(T);if(E){let e=E.convert(T);D(e.type),k(e.payload),Y(e.display);return}Y(T.display);let O=ie.parseHyperLink(T.payload);switch(D(O.type===f.SheetHyperLinkType.INVALID?f.SheetHyperLinkType.RANGE:O.type),O.type){case f.SheetHyperLinkType.URL:k(O.url),O.url===T.display&&(G.current=!0);break;case f.SheetHyperLinkType.RANGE:{var v,y;let e=O.searchObj,t=(0,u.serializeRangeWithSheet)(e.gid?(v=(y=M.getUnit(P.unitId))==null||(y=y.getSheetBySheetId(e.gid))==null?void 0:y.getName())==null?``:v:``,(0,u.deserializeRangeWithSheet)(e.range).range);k(t),t===T.display&&(G.current=!0);break}case f.SheetHyperLinkType.SHEET:{let e=O.searchObj;k(e.gid);break}case f.SheetHyperLinkType.DEFINE_NAME:{let e=O.searchObj;k(e.rangeid);break}default:k(``);break}}},[P,ae,I,ce,M]),(0,p.useEffect)(()=>{let e=null;if(P&&!P.customRangeId&&P.type===g.VIEWING&&t.Tools.isDefine(P.row)&&t.Tools.isDefine(P.col)){let n=M.getUnit(P.unitId,t.UniverInstanceType.UNIVER_SHEET),r=n==null?void 0:n.getSheetBySheetId(P.subUnitId),i=r==null?void 0:r.getMergedCell(P.row,P.col),a=new t.ColorKit(le.getColorFromTheme(`primary.600`)).toRgb();e=se.addShape({range:i==null?{startColumn:P.col,endColumn:P.col,startRow:P.row,endRow:P.row}:i,style:{fill:`rgb(${a.r}, ${a.g}, ${a.b}, 0.12)`,strokeWidth:1,stroke:`#FFBD37`,widgets:{}},primary:null},[],-1)}return()=>{e&&se.removeShape(e)}},[P,se,le,M]),(0,p.useEffect)(()=>{he(T===f.SheetHyperLinkType.RANGE)},[T]),(0,p.useEffect)(()=>{let e=(P==null?void 0:P.type)===g.ZEN_EDITOR?R.getRenderById(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY):R.getRenderById(j.getCurrentEditorId()),n=new t.DisposableCollection;if(e){let t=e.with(a.DocSelectionRenderService);t.setReserveRangesStatus(!0),n.add(()=>{t.setReserveRangesStatus(!1)})}return()=>{j.disableForceKeepVisible(),n.dispose()}},[P==null?void 0:P.type,j,R]),(0,p.useEffect)(()=>(W&&N.setIsKeepVisible(W),N.setIsKeepVisible(de),()=>{N.setIsKeepVisible(!1)}),[W,de,N]),(0,p.useEffect)(()=>()=>{L.temporaryHidden&&(L.show(),z.setContextValue(t.FOCUSING_SHEET,!1))},[z,L]),(0,p.useEffect)(()=>{if(W)return j.enableForceKeepVisible(),()=>{j.disableForceKeepVisible()}},[W,j]);let ge=[{label:A.t(`hyperLink.form.link`),value:f.SheetHyperLinkType.URL},{label:A.t(`hyperLink.form.range`),value:f.SheetHyperLinkType.RANGE},{label:A.t(`hyperLink.form.worksheet`),value:f.SheetHyperLinkType.SHEET},{label:A.t(`hyperLink.form.definedName`),value:f.SheetHyperLinkType.DEFINE_NAME},...oe];if(!K)return;let X=K.getHiddenWorksheets(),Z=K.getSheets().map(e=>({label:e.getName(),value:e.getSheetId()})).filter(e=>X.indexOf(e.value)===-1),_e=Object.values((e=re.getDefinedNameMap(K.getUnitId()))==null?{}:e).map(e=>({label:e.name,value:e.id})),Q=(e,t)=>{if(e===f.SheetHyperLinkType.URL)return b(t);if(e===f.SheetHyperLinkType.RANGE){let e=(0,u.deserializeRangeWithSheet)(t),n=K.getSheetBySheetName(e.sheetName);if(n)return`#gid=${n.getSheetId()}&range=${(0,u.serializeRange)(e.range)}`}return`#${e}=${t}`},ve=(0,s.useEvent)(e=>{var t;let n=ne(e,((t=K.getActiveSheet())==null?void 0:t.getName())||``);if(!n){k(``);return}k(n),n&&(G.current||!x)&&(Y(n),G.current=!0)}),ye=async()=>{if(C&&te(x)||!O||T===f.SheetHyperLinkType.URL&&!_(O)){me(!0);return}if(P)if(c){let e=P.type===g.ZEN_EDITOR||P.type===g.EDITING?f.UpdateRichHyperLinkCommand.id:f.UpdateHyperLinkCommand.id;await F.executeCommand(e,{id:c,unitId:P.unitId,subUnitId:P.subUnitId,payload:{display:C?x:``,payload:Q(T,O)},row:P.row,column:P.col,documentId:P.type===g.ZEN_EDITOR?t.DOCS_ZEN_EDITOR_UNIT_ID_KEY:j.getCurrentEditorId()})}else{let e=P.type===g.ZEN_EDITOR||P.type===g.EDITING?f.AddRichHyperLinkCommand.id:f.AddHyperLinkCommand.id;await F.executeCommand(e,{unitId:P.unitId,subUnitId:P.subUnitId,link:{id:(0,t.generateRandomId)(),row:P.row,column:P.col,payload:Q(T,O),display:C?x:``},documentId:P.type===g.ZEN_EDITOR?t.DOCS_ZEN_EDITOR_UNIT_ID_KEY:j.getCurrentEditorId()})}(P==null?void 0:P.type)===g.VIEWING&&(await F.executeCommand(n.SetWorksheetActiveOperation.id,{unitId:P.unitId,subUnitId:P.subUnitId}),await F.executeCommand(r.ScrollToRangeOperation.id,{range:{startRow:Math.max(P.row-1,0),endRow:P.row+1,startColumn:Math.max(P.col-1,0),endColumn:P.col+1}})),F.executeCommand(q.id)};return P?(0,m.jsxs)(`div`,{className:(0,l.clsx)(`univer-box-border univer-w-[296px] univer-rounded-xl univer-bg-white univer-p-4 univer-shadow-md dark:!univer-bg-gray-900`,l.borderClassName),children:[C?(0,m.jsx)(l.FormLayout,{label:A.t(`hyperLink.form.label`),error:U&&te(x)?A.t(`hyperLink.form.inputError`):``,children:(0,m.jsx)(l.Input,{value:x,onChange:e=>{Y(e),G.current=!1},placeholder:A.t(`hyperLink.form.labelPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===s.KeyCode.ENTER&&ye()}})}):null,(0,m.jsx)(l.FormLayout,{label:A.t(`hyperLink.form.type`),children:(0,m.jsx)(l.Select,{className:`univer-w-full`,options:ge,value:T,onChange:e=>{D(e),k(``)}})}),T===f.SheetHyperLinkType.URL&&(0,m.jsx)(l.FormLayout,{error:U?O?_(O)?``:A.t(`hyperLink.form.linkError`):A.t(`hyperLink.form.inputError`):``,children:(0,m.jsx)(l.Input,{value:O,onChange:e=>{k(e),e&&(G.current||!x||x===e)&&(Y(e),G.current=!0)},placeholder:A.t(`hyperLink.form.linkPlaceholder`),autoFocus:!0,onKeyDown:e=>{e.keyCode===s.KeyCode.ENTER&&ye()}})}),T===f.SheetHyperLinkType.RANGE&&(0,m.jsx)(l.FormLayout,{error:U&&!O?A.t(`hyperLink.form.inputError`):``,children:(0,m.jsx)(d.RangeSelector,{unitId:K.getUnitId(),subUnitId:J,maxRangeCount:1,supportAcrossSheet:!0,initialValue:O,resetRange:B,onChange:(e,t)=>ve(t),onRangeSelectorDialogVisibleChange:async e=>{if(fe(e),e)P.type===g.ZEN_EDITOR&&(L.hide(),z.setContextValue(t.FOCUSING_SHEET,!0)),P.type!==g.VIEWING&&j.enableForceKeepVisible(),y(!0);else{if(await ae.navigateToRange(P.unitId,P.subUnitId,{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col},!0),P.type===g.ZEN_EDITOR){var r,i;await F.executeCommand(n.SetSelectionsOperation.id,{unitId:P.unitId,subUnitId:P.subUnitId,selections:[{range:{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col}}]}),L.show(),z.setContextValue(t.FOCUSING_SHEET,!1);let e=(r=R.getRenderById(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(a.DocBackScrollRenderController),o=(i=ue.getTextRanges({unitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:i[0];e&&o&&(e.scrollToRange(o),ue.refreshSelection({unitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}j.disableForceKeepVisible(),y(!1)}},onFocusChange:e=>he(e)})}),T===f.SheetHyperLinkType.SHEET&&(0,m.jsx)(l.FormLayout,{error:U&&!O?A.t(`hyperLink.form.selectError`):``,children:(0,m.jsx)(l.Select,{className:`univer-w-full`,options:Z,value:O,onChange:e=>{var t,n;k(e);let r=(t=Z.find(t=>t.value===e))==null?void 0:t.label,i=(n=Z.find(e=>e.value===O))==null?void 0:n.label;r&&(G.current||!x||x===i)&&(Y(r),G.current=!0)}})}),T===f.SheetHyperLinkType.DEFINE_NAME&&(0,m.jsx)(l.FormLayout,{error:U&&!O?A.t(`hyperLink.form.selectError`):``,children:(0,m.jsx)(l.Select,{className:`univer-w-full`,options:_e,value:O,onChange:e=>{var t,n;k(e);let r=(t=_e.find(t=>t.value===e))==null?void 0:t.label,i=(n=_e.find(e=>e.value===O))==null?void 0:n.label;r&&(G.current||!x||x===i)&&(Y(r),G.current=!0)}})}),(V==null?void 0:V.Form)&&(0,m.jsx)(V.Form,{linkId:c,payload:O,display:x,showError:U,setByPayload:G,setDisplay:e=>{Y(e),G.current=!0},setPayload:k}),(0,m.jsxs)(`div`,{className:`univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[(0,m.jsx)(l.Button,{onClick:()=>{P&&ae.navigateToRange(P.unitId,P.subUnitId,{startRow:P.row,endRow:P.row,startColumn:P.col,endColumn:P.col},!0),F.executeCommand(q.id)},children:A.t(`hyperLink.form.cancel`)}),(0,m.jsx)(l.Button,{variant:`primary`,onClick:async()=>{ye()},children:A.t(`hyperLink.form.ok`)})]})]}):null};re.componentKey=`univer.sheet.cell-link-edit`;function j({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,p.useRef)(`_${ie()}`);return M(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function M(e,t,n,r,i){return(0,p.createElement)(e.tag,{key:t,...N(e,n,i),...r},(P(e,n).children||[]).map((r,a)=>M(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function N(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function P(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function ie(){return Math.random().toString(36).substring(2,8)}j.displayName=`UniverIcon`;let ae={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{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`}}]},F=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`all-border-icon`,ref:t,icon:ae}))});F.displayName=`AllBorderIcon`;let I={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{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`}}]},oe=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`copy-icon`,ref:t,icon:I}))});oe.displayName=`CopyIcon`;let L={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z`}}]},R=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`link-icon`,ref:t,icon:L}))});R.displayName=`LinkIcon`;let se={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.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.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},ce=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:se}))});ce.displayName=`UnlinkIcon`;let z={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},le=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`write-icon`,ref:t,icon:z}))});le.displayName=`WriteIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{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:`white`,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`}}]},de=(0,p.forwardRef)(function(e,t){return(0,p.createElement)(j,Object.assign({},e,{id:`xlsx-multi-icon`,ref:t,icon:ue}))});de.displayName=`XlsxMultiIcon`;let fe={[f.SheetHyperLinkType.URL]:(0,m.jsx)(R,{}),[f.SheetHyperLinkType.SHEET]:(0,m.jsx)(de,{className:`univer-text-green-500`}),[f.SheetHyperLinkType.RANGE]:(0,m.jsx)(F,{}),[f.SheetHyperLinkType.DEFINE_NAME]:(0,m.jsx)(F,{}),[f.SheetHyperLinkType.INVALID]:(0,m.jsx)(F,{})},pe=e=>{var n,i;let a=(0,s.useDependency)(H),o=(0,s.useDependency)(t.ICommandService),c=(0,s.useDependency)(s.IMessageService),u=(0,s.useDependency)(t.LocaleService),d=(0,s.useDependency)(E),p=(0,s.useDependency)(r.IEditorBridgeService),h=(0,s.useDependency)(f.SheetsHyperLinkParserService),_=(0,s.useDependency)(s.IZenZoneService),{customRange:v,row:y,col:b,unitId:x,subUnitId:S,editPermission:C,copyPermission:w,type:T}=e;if(!(!(v==null||(n=v.properties)==null)&&n.url))return null;let D=h.parseHyperLink((i=v.properties.url)==null?``:i),O=D.type===f.SheetHyperLinkType.INVALID;return(0,m.jsxs)(`div`,{className:(0,l.clsx)(`univer-mb-1 univer-flex univer-max-w-80 univer-flex-row univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow-md dark:!univer-bg-gray-900`,l.borderClassName),onClick:()=>a.hideCurrentPopup(),children:[(0,m.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-flex-row univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-600`,{"univer-text-red-500":O}),onClick:()=>{_.visible||O||d.navigate(D)},children:[(0,m.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white`,children:fe[D.type]}),(0,m.jsx)(l.Tooltip,{showIfEllipsis:!0,title:D.name,asChild:!0,children:(0,m.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:D.name})})]}),(0,m.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center`,children:[w&&(0,m.jsx)(`div`,{className:(0,l.clsx)(`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-text-red-500":O}),onClick:()=>{if(!O){if(D.type!==f.SheetHyperLinkType.URL){let e=new URL(window.location.href);e.hash=D.url.slice(1),navigator.clipboard.writeText(e.href)}else navigator.clipboard.writeText(D.url);c.show({content:u.t(`hyperLink.message.coped`),type:l.MessageType.Info})}},children:(0,m.jsx)(l.Tooltip,{placement:`bottom`,title:u.t(`hyperLink.popup.copy`),children:(0,m.jsx)(oe,{className:`dark:!univer-text-white`})})}),C&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>{o.executeCommand(K.id,{unitId:x,subUnitId:S,row:y,col:b,customRangeId:v.rangeId,type:T})},children:(0,m.jsx)(l.Tooltip,{placement:`bottom`,title:u.t(`hyperLink.popup.edit`),children:(0,m.jsx)(le,{className:`dark:!univer-text-white`})})}),(0,m.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-flex-row univer-items-center univer-justify-center univer-rounded univer-text-base hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>{let e=T===g.EDITING||T===g.ZEN_EDITOR?f.CancelRichHyperLinkCommand.id:f.CancelHyperLinkCommand.id;o.syncExecuteCommand(e,{unitId:x,subUnitId:S,id:v.rangeId,row:y,column:b,documentId:T===g.ZEN_EDITOR?t.DOCS_ZEN_EDITOR_UNIT_ID_KEY:p.getCurrentEditorId()})&&a.hideCurrentPopup(void 0,!0)},children:(0,m.jsx)(l.Tooltip,{placement:`bottom`,title:u.t(`hyperLink.popup.cancel`),children:(0,m.jsx)(ce,{className:`dark:!univer-text-white`})})})]})]})]})},B=()=>{let e=(0,s.useDependency)(H),[n,r]=(0,p.useState)(null),i=(0,s.useDependency)(t.IUniverInstanceService);if((0,p.useEffect)(()=>{r(e.currentPopup);let t=e.currentPopup$.subscribe(e=>{r(e)});return()=>{t.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){var a;let e=i.getUnit(n.unitId,t.UniverInstanceType.UNIVER_SHEET),r=e==null?void 0:e.getSheetBySheetId(n.subUnitId),o=r==null?void 0:r.getCell(n.row,n.col),s=o==null||(a=o.p)==null||(a=a.body)==null?void 0:a.customRanges;return s!=null&&s.length?(0,m.jsx)(`div`,{children:s.map(e=>(0,m.jsx)(pe,{...n,customRange:e},e.rangeId))}):null}return(0,m.jsx)(pe,{...n})};B.componentKey=`univer.sheet.cell-link-popup`;let V=(e,t)=>{var n,r;return e.unitId===t.unitId&&e.subUnitId===t.subUnitId&&e.row===t.row&&e.col===t.col&&((n=e.customRange)==null?void 0:n.rangeId)===((r=t.customRange)==null?void 0:r.rangeId)&&e.type===t.type},H=class extends t.Disposable{get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}constructor(e,t,n,r,i,a,o){super(),this._sheetCanvasPopManagerService=e,this._injector=t,this._univerInstanceService=n,this._editorBridgeService=r,this._textSelectionManagerService=i,this._docCanvasPopManagerService=a,this._zenZoneService=o,A(this,`_currentPopup`,null),A(this,`_currentPopup$`,new c.Subject),A(this,`currentPopup$`,this._currentPopup$.asObservable()),A(this,`_currentEditingPopup`,null),A(this,`_currentEditing$`,new c.BehaviorSubject(null)),A(this,`currentEditing$`,this._currentEditing$.asObservable()),A(this,`_isKeepVisible`,!1),this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&V(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==g.ZEN_EDITOR&&this._zenZoneService.visible))return;let n=this._currentEditing$.getValue();if(n&&V(e,n))return;let{unitId:r,subUnitId:i,row:a,col:o,customRangeRect:s,customRange:c}=e,l,u={componentKey:B.componentKey,direction:`bottom`,onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===g.EDITING){if(!c)return;l=s&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(s,u)}else if(e.type===g.ZEN_EDITOR){if(!c)return;l=this._docCanvasPopManagerService.attachPopupToRange({startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},u,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)l=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,u,r,i);else{if(!c)return;l=s&&this._sheetCanvasPopManagerService.attachPopupByPosition(s,u,e)}if(l){if(this._currentPopup){var d;(d=this._currentPopup.disposable)==null||d.dispose()}this._currentPopup={unitId:r,subUnitId:i,disposable:l,row:a,col:o,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:c,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup)}}hideCurrentPopup(e,t){if(this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||t)){var n;(n=this._currentPopup)==null||(n=n.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null)}}dispose(){super.dispose(),this.hideCurrentPopup(),this.endEditing(),this._currentPopup$.complete(),this._currentEditing$.complete()}_getEditingRange(){let e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){var r,i,a;let e=this._textSelectionManagerService.getActiveTextRange(),o=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!o)return null;if(!e||e.collapsed)return{startOffset:0,endOffset:o.dataStream.length-2,collapsed:o.dataStream.length-2==0,label:t.BuildTextUtils.transform.getPlainText(o.dataStream)};let s=t.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(e,(i=(a=o.customRanges)==null?void 0:a.filter(e=>e.rangeType===t.CustomRangeType.HYPERLINK))==null?[]:i),c=e.startOffset,l=e.endOffset;return s.forEach(e=>{c=Math.min(c,e.startIndex),l=Math.max(l,e.endIndex+1)}),{startOffset:c,endOffset:l,collapsed:c===l,label:t.BuildTextUtils.transform.getPlainText(o.dataStream.slice(c,l))}}return null}get _editPopup(){return{componentKey:re.componentKey,direction:`vertical`,onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:`hide`}}startAddEditing(e){let{unitId:n,subUnitId:r,type:i}=e;if(i===g.ZEN_EDITOR){var s;let n=this._univerInstanceService.getUnit(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,t.UniverInstanceType.UNIVER_DOC);if(!n)return;let r=this._textSelectionManagerService.getActiveTextRange();if(!r)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(r,this._editPopup,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY);let i=(s=n.getBody())==null?void 0:s.dataStream.slice(r.startOffset,r.endOffset);this._currentEditing$.next({...e,label:i})}else if(i===g.EDITING){var c;let i=this._getEditingRange();if(!i)return;this._textSelectionManagerService.replaceDocRanges([{...i}],{unitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});let s=this._injector.get(o.IRenderManagerService).getRenderById(t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!s)return;let l=(0,a.calcDocRangePositions)(i,s);if(!(l!=null&&l.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(c=i==null?void 0:i.label)==null?``:c})}else{var l,u,d;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);let i=this._univerInstanceService.getUnit(n,t.UniverInstanceType.UNIVER_SHEET),a=i==null?void 0:i.getSheetBySheetId(r),o=a==null?void 0:a.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:o!=null&&o.p?t.BuildTextUtils.transform.getPlainText((l=(u=o.p.body)==null?void 0:u.dataStream)==null?``:l):((d=o==null?void 0:o.v)==null?``:d).toString()})}}startEditing(e){var n;(n=this._currentEditingPopup)==null||n.dispose(),this.hideCurrentPopup(void 0,!0);let{unitId:i,subUnitId:a}=e,o,s;if(e.type===g.ZEN_EDITOR){var c,l;let n=this._univerInstanceService.getUnit(t.DOCS_ZEN_EDITOR_UNIT_ID_KEY,t.UniverInstanceType.UNIVER_DOC);if(o=n==null||(c=n.getBody())==null||(c=c.customRanges)==null?void 0:c.find(t=>t.rangeId===e.customRangeId),s=o?n==null||(l=n.getBody())==null?void 0:l.dataStream.slice(o.startIndex,o.endIndex+1):``,!o||!s)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1},this._editPopup,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===g.EDITING){var u;let t=(0,r.getEditingCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!t||!((u=t.rects)!=null&&u.length))return;o=t.customRange,s=t.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(t.rects.pop(),this._editPopup,i,a)}else{var d;let n=this._univerInstanceService.getUnit(i,t.UniverInstanceType.UNIVER_SHEET),c=n==null?void 0:n.getSheetBySheetId(a),l=c==null?void 0:c.getCellRaw(e.row,e.col),u=n==null?void 0:n.getStyles().getStyleByCell(l),f=u==null?void 0:u.tr,p=(0,r.getCustomRangePosition)(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!p||!((d=p.rects)!=null&&d.length))return;o=p.customRange,s=p.label,f?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,a):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(p.rects.pop(),this._editPopup,{unitId:i,subUnitId:a,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:o,label:s})}endEditing(e){if(this.getIsKeepVisible())return;let t=this._currentEditing$.getValue();if(t&&(!e||e===t.type)){var n;(n=this._currentEditingPopup)==null||n.dispose(),this._currentEditing$.next(null)}}};H=w([C(0,(0,t.Inject)(r.SheetCanvasPopManagerService)),C(1,(0,t.Inject)(t.Injector)),C(2,t.IUniverInstanceService),C(3,r.IEditorBridgeService),C(4,(0,t.Inject)(i.DocSelectionManagerService)),C(5,(0,t.Inject)(a.DocCanvasPopManagerService)),C(6,s.IZenZoneService)],H);let U=function(e){return e[e.ALLOWED=0]=`ALLOWED`,e[e.DISABLED_BY_CELL=1]=`DISABLED_BY_CELL`,e[e.ALLOW_ON_EDITING=2]=`ALLOW_ON_EDITING`,e}({}),me=new Set([t.DataValidationType.CHECKBOX,t.DataValidationType.LIST,t.DataValidationType.LIST_MULTIPLE]),W=(e,t,n,r)=>{var i,a;let o=t.getCell(n,r);if(o!=null&&o.f||o!=null&&o.si||!(o==null||(i=o.p)==null||(i=i.body)==null||(i=i.customBlocks)==null)&&i.length)return U.DISABLED_BY_CELL;let s=e.has(h.SheetDataValidationModel)?e.get(h.SheetDataValidationModel):null,c=s==null?void 0:s.getRuleByLocation(t.getUnitId(),t.getSheetId(),n,r);return c&&me.has(c.type)?!0:!(o==null||(a=o.p)==null||(a=a.drawingsOrder)==null)&&a.length?U.ALLOW_ON_EDITING:U.ALLOWED},he=e=>{let r=e.get(t.IUniverInstanceService).getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!r)return!0;let i=r.getActiveSheet(),a=e.get(n.SheetsSelectionsService).getCurrentSelections();if(!a.length)return!0;let o=a[0].range.startRow,s=a[0].range.startColumn;return W(e,i,o,s)===U.DISABLED_BY_CELL},G=e=>{let n=e.get(i.DocSelectionManagerService),r=e.get(t.IUniverInstanceService),a=n.getTextRanges();if(!(a!=null&&a.length))return!0;let o=r.getCurrentUnitForType(t.UniverInstanceType.UNIVER_DOC);return!!(!o||a.every(e=>e.collapsed)||!o.getSelfOrHeaderFooterModel(a[0].segmentId).getBody())},K={type:t.CommandType.OPERATION,id:`sheet.operation.open-hyper-link-edit-panel`,handler(e,t){if(!t)return!1;let n=e.get(H);return t.customRangeId?n.startEditing(t):n.startAddEditing(t),!0}},q={type:t.CommandType.OPERATION,id:`sheet.operation.close-hyper-link-popup`,handler(e){return e.get(H).endEditing(),!0}},J={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link`,handler(e){var i;let a=e.get(t.IUniverInstanceService),o=(0,n.getSheetCommandTarget)(a),s=e.get(r.IEditorBridgeService);if(!o)return!1;let c=e.get(t.ICommandService),l=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!l)return!1;let u=l.range.startRow,d=l.range.startColumn,f=s.isVisible(),p=((i=a.getFocusedUnit())==null?void 0:i.getUnitId())===t.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return c.executeCommand(K.id,{unitId:o.unitId,subUnitId:o.subUnitId,row:u,col:d,type:p?g.ZEN_EDITOR:f.visible?g.EDITING:g.VIEWING})}},Y={type:t.CommandType.OPERATION,id:`sheet.operation.insert-hyper-link-toolbar`,handler(e){if(he(e))return!1;let n=e.get(t.ICommandService);return e.get(H).currentEditing?n.executeCommand(q.id):n.executeCommand(J.id)}},ge=`SHEET_HYPER_LINK_UI_PLUGIN`,X=class extends t.Disposable{registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(t=>t(e))}constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._hyperLinkModel=t,this._injector=n,this._resolverService=r,A(this,`_plainTextFilter`,new Set),A(this,`_copyInfo`,void 0),this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ge,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,i)=>{let{copyType:a=r.COPY_TYPE.COPY,pasteType:o}=i,{range:s}=e||{},{range:c,unitId:l,subUnitId:u}=t;return this._generateMutations(c,{copyType:a,pasteType:o,copyRange:s,unitId:l,subUnitId:u})},onPastePlainText:(e,n)=>{let i=this._filterPlainText(n);if(_(n)&&i){let{range:n,unitId:i,subUnitId:a}=e,{ranges:[o],mapFunc:s}=(0,r.virtualizeDiscreteRanges)([n]),c=[],l=[];return t.Range.foreach(o,(e,t)=>{let{row:n,col:r}=s(e,t),o=this._hyperLinkModel.getHyperLinkByLocation(i,a,n,r);o&&c.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:i,subUnitId:a,id:o.id}}),o&&l.push({id:f.AddHyperLinkMutation.id,params:{unitId:i,subUnitId:a,link:o}})}),{redos:c,undos:l}}return{undos:[],redos:[]}},priority:99})}_collect(e,r,i){let a=new t.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:r,matrix:a};let o=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!o)return;let{rows:s,cols:c}=o;s.forEach((t,n)=>{c.forEach((i,o)=>{var s;let c=this._hyperLinkModel.getHyperLinkByLocation(e,r,t,i);a.setValue(n,o,(s=c==null?void 0:c.id)==null?``:s)})})}_generateMutations(e,n){if(!this._copyInfo||!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange||[r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,r.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};let{unitId:i,subUnitId:a}=this._copyInfo,o=[],s=[],{ranges:[c,l],mapFunc:u}=(0,r.virtualizeDiscreteRanges)([n.copyRange,e]);return(0,r.getRepeatRange)(c,l,!0).forEach(({startRange:e})=>{var r;(r=this._copyInfo)==null||r.matrix.forValue((r,c,l)=>{let d=t.Rectangle.getPositionRange({startRow:r,endRow:r,startColumn:c,endColumn:c},e),p=this._hyperLinkModel.getHyperLink(i,a,l),{row:m,col:h}=u(d.startRow,d.startColumn),g=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,m,h),_=(0,t.generateRandomId)();g&&o.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:g.id}}),p&&(o.push({id:f.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...p,id:_,row:m,column:h}}}),s.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:_}})),g&&s.push({id:f.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:g}})})}),{redos:o,undos:s}}};X=w([C(0,r.ISheetClipboardService),C(1,(0,t.Inject)(f.HyperLinkModel)),C(2,(0,t.Inject)(t.Injector)),C(3,(0,t.Inject)(E))],X);let Z=(e,i=t.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var s;let l=e.get(t.IUniverInstanceService),u=(s=e.get(o.IRenderManagerService).getRenderById(i))==null?void 0:s.with(a.DocSelectionRenderService);return u?u.textSelectionInner$.pipe((0,c.map)(()=>{let t=e.get(r.IEditorBridgeService).getEditCellState();if(!t)return!0;let i=(0,n.getSheetCommandTarget)(l,{unitId:t.unitId,subUnitId:t.sheetId});return!(i!=null&&i.worksheet)||W(e,i.worksheet,t.row,t.column)===1?!0:G(e)})):(0,c.of)(!0)},_e=e=>{var i;let a=e.get(t.IUniverInstanceService),o=e.has(r.IEditorBridgeService)?e.get(r.IEditorBridgeService):null;return((i=o==null?void 0:o.currentEditCellState$.pipe((0,c.map)(t=>{if(!t)return U.DISABLED_BY_CELL;let r=(0,n.getSheetCommandTarget)(a,{unitId:t.unitId,subUnitId:t.sheetId});return r?W(e,r.worksheet,t.row,t.column):U.DISABLED_BY_CELL}),(0,c.switchMap)(n=>n===U.DISABLED_BY_CELL?(0,c.of)(!0):(0,c.combineLatest)([o?o.visible$:(0,c.of)(null),a.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC)]).pipe((0,c.switchMap)(([r,i])=>r!=null&&r.visible?(i==null?void 0:i.getUnitId())===t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?(0,c.of)(!0):Z(e,t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):(0,c.of)(n!==U.ALLOWED))))))==null?(0,c.of)(!0):i).pipe((0,c.switchMap)(t=>t?(0,c.of)(!0):(0,r.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},!0)))},Q={commandId:J.id,type:s.MenuItemType.BUTTON,title:`hyperLink.menu.add`,icon:`LinkIcon`},ve=e=>`${e}-zen-editor`,ye=e=>({...Q,id:Q.commandId,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:_e(e)}),be=e=>({...Q,id:ve(Q.commandId),hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Z(e)}),xe={tooltip:`hyperLink.form.addTitle`,commandId:Y.id,type:s.MenuItemType.BUTTON,icon:`LinkIcon`},Se=e=>({...xe,id:xe.commandId,hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:_e(e)}),Ce=e=>({...xe,id:ve(xe.commandId),hidden$:(0,s.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,t.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Z(e)}),we={id:Y.id,binding:s.KeyCode.K|s.MetaKeys.CTRL_COMMAND,preconditions:r.whenSheetEditorFocused};var Te=`@univerjs/sheets-hyper-link-ui`,Ee=`0.21.0`;let De=class extends t.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,i)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,l=(0,r.virtualizeDiscreteRanges)([a,o]),[u,d]=l.ranges,{mapFunc:p}=l,m={row:u.startRow,col:u.startColumn},h=n.AutoFillTools.getAutoFillRepeatRange(u,d),g=[],_=[];return h.forEach(e=>{let r=e.repeatStartCell,a=e.relativeRange,o={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},l={startRow:r.row,startColumn:r.col,endColumn:r.col,endRow:r.row};t.Range.foreach(a,(e,r)=>{let a=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},o),{row:u,col:d}=p(a.startRow,a.startColumn),m=this._hyperLinkModel.getHyperLinkByLocation(s,c,u,d),h=t.Rectangle.getPositionRange({startRow:e,startColumn:r,endColumn:r,endRow:e},l),{row:v,col:y}=p(h.startRow,h.startColumn),b=(0,t.generateRandomId)(),x=this._hyperLinkModel.getHyperLinkByLocation(s,c,v,y);x&&g.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:x.id}}),(n.AUTO_FILL_APPLY_TYPE.COPY===i||n.AUTO_FILL_APPLY_TYPE.SERIES===i)&&m&&(g.push({id:f.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{...m,id:b,row:v,column:y}}}),_.push({id:f.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:b}})),x&&_.push({id:f.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:x}})})}),{undos:_,redos:g}},a={id:ge,onFillData:(t,r,a)=>a===n.AUTO_FILL_APPLY_TYPE.COPY||a===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===n.AUTO_FILL_APPLY_TYPE.SERIES?i(t,a):e()};this.disposeWithMe(this._autoFillService.addHook(a))}};De=w([C(0,n.IAutoFillService),C(1,(0,t.Inject)(f.HyperLinkModel))],De);let Oe=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===we.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellValuePermission,n.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.hyperLinkErr`)))}))}};Oe=w([C(0,(0,t.Inject)(t.LocaleService)),C(1,t.ICommandService),C(2,(0,t.Inject)(n.SheetPermissionCheckController))],Oe);let ke=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionCheckController=i,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=s,this._univerInstanceService=c,this._zenZoneService=l,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){let{unitId:r,subUnitId:i,row:a,col:o}=e,s=this._univerInstanceService.getUnit(r,t.UniverInstanceType.UNIVER_SHEET),c=s==null?void 0:s.getSheetBySheetId(i);if(!c)return{viewPermission:!1,editPermission:!1,copyPermission:!1};let l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookViewPermission],worksheetTypes:[n.WorksheetViewPermission],rangeTypes:[n.RangeProtectionPermissionViewPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetInsertHyperlinkPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]},[{startRow:a,startColumn:o,endRow:a,endColumn:o}],r,i),d=c.getCellRaw(a,o);d!=null&&d.f&&d.f.startsWith(`=HYPERLINK(`)&&(u=!1);let f=this._permissionService.composePermission([new n.WorkbookCopyPermission(r).id,new n.WorksheetCopyPermission(r,i).id]).every(e=>e.value);return{viewPermission:l,editPermission:u,copyPermission:f}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe((0,c.debounceTime)(200)).subscribe(e=>{var n,i,a;if(!e||((n=e.customRange)==null?void 0:n.rangeType)!==t.CustomRangeType.HYPERLINK){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let{unitId:o,subUnitId:s,row:c,col:l}=e,u=this._renderManagerService.getRenderById(o);if(!u)return;let d=this._univerInstanceService.getUnit(o,t.UniverInstanceType.UNIVER_SHEET),f=d==null?void 0:d.getSheetBySheetId(s);if(!f)return;if(!u.with(r.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(g.VIEWING);return}let p=u==null||(i=u.with(r.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:i.skeleton,m=l,h=c,_=h,v=m;p&&p.overflowCache.forValue((e,n,r)=>{t.Rectangle.contains(r,{startColumn:m,endColumn:m,startRow:h,endRow:h})&&(_=e,v=n)});let{viewPermission:y,editPermission:b,copyPermission:x}=this._getLinkPermission(e);if(!y){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let S=f.getCellStyleOnly(_,v),C=d.getStyles().getStyleByCell(S),w=C==null||(a=C.tr)==null?void 0:a.a;if(!w&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:_,col:v,editPermission:b,copyPermission:x,customRange:e.customRange,customRangeRect:e.rect,type:g.VIEWING,unitId:o,subUnitId:s,showAll:!!w})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe((0,c.switchMap)(e=>this._editorBridgeService.visible$.pipe((0,c.map)(t=>({visible:t,state:e}))))).subscribe(({visible:n,state:i})=>{if(!i||i.editorUnitId!==t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(g.EDITING),this._sheetsHyperLinkPopupService.endEditing(g.EDITING);return}let{editorUnitId:o,unitId:s,sheetId:l,row:u,column:d}=i,f=this._renderManagerService.getRenderById(o);if(!f)return;let{editPermission:p,viewPermission:m,copyPermission:h}=this._getLinkPermission({unitId:s,subUnitId:l,row:u,col:d}),_=f.with(a.DocEventManagerService);m&&(e==null||e.unsubscribe(),e=_.hoverCustomRanges$.pipe((0,c.debounceTime)(200)).subscribe(e=>{var n;let i=e.find(e=>e.range.rangeType===t.CustomRangeType.HYPERLINK);if(!i){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}let a=i.rects[i.rects.length-1];if(!(!((n=this._renderManagerService.getRenderById(s))==null||(n=n.with(r.SheetSkeletonManagerService).getSkeletonParam(l))==null)&&n.skeleton)||!a)return;let o=f.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:s,subUnitId:l,row:u,col:d,customRange:i.range,customRangeRect:{left:a.left+o.left,top:a.top+o.top,bottom:a.bottom+o.top,right:a.right+o.left},editPermission:p,copyPermission:h,type:g.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(g.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(g.EDITING),this._sheetsHyperLinkPopupService.endEditing(g.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(g.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(g.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(g.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe((0,c.switchMap)(e=>{let n=e===t.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(a.DocEventManagerService).hoverCustomRanges$.pipe((0,c.debounceTime)(200)):new c.Observable(e=>{e.next(null)})})).subscribe(e=>{let n=e==null?void 0:e.find(e=>e.range.rangeType===t.CustomRangeType.HYPERLINK),r=this._editorBridgeService.getEditCellState();if(n&&r){let{unitId:e,sheetId:t,row:i,column:a}=r,{editPermission:o,viewPermission:s,copyPermission:c}=this._getLinkPermission({unitId:e,subUnitId:t,row:i,col:a});s&&this._sheetsHyperLinkPopupService.showPopup({type:g.ZEN_EDITOR,unitId:e,subUnitId:t,row:i,col:a,customRange:n.range,editPermission:o,copyPermission:c})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(g.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(g.EDITING)}))}_initCommandListener(){let e=[n.ClearSelectionContentCommand.id,n.ClearSelectionAllCommand.id,n.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};ke=w([C(0,(0,t.Inject)(r.HoverManagerService)),C(1,(0,t.Inject)(H)),C(2,(0,t.Inject)(o.IRenderManagerService)),C(3,(0,t.Inject)(t.IPermissionService)),C(4,(0,t.Inject)(n.SheetPermissionCheckController)),C(5,t.ICommandService),C(6,r.IEditorBridgeService),C(7,(0,t.Inject)(i.DocSelectionManagerService)),C(8,t.IUniverInstanceService),C(9,s.IZenZoneService)],ke);let Ae=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._hyperLinkModel=t,this._initSkeletonChange()}_initSkeletonChange(){let e=()=>{var e;(e=this._context.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe((0,c.debounceTime)(16)).subscribe(()=>{e()}))}};Ae=w([C(1,(0,t.Inject)(f.HyperLinkModel))],Ae);let je={[s.RibbonInsertGroup.MEDIA]:{[Y.id]:{order:1,menuItemFactory:Se},[ve(Y.id)]:{order:1,menuItemFactory:Ce}},[s.ContextMenuPosition.MAIN_AREA]:{[s.ContextMenuGroup.OTHERS]:{order:1,[Y.id]:{order:0,menuItemFactory:ye},[ve(Y.id)]:{order:0,menuItemFactory:be}}}},Me=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._componentManager=e,this._commandService=t,this._menuManagerService=n,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[B.componentKey,B],[re.componentKey,re],[`LinkIcon`,R]].forEach(([e,t])=>{this._componentManager.register(e,t)})}_initCommands(){[K,q,J,Y].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(je)}_initShortCut(){this._shortcutService.registerShortcut(we)}};Me=w([C(0,(0,t.Inject)(s.ComponentManager)),C(1,t.ICommandService),C(2,s.IMenuManagerService),C(3,(0,t.Inject)(t.Injector)),C(4,(0,t.Inject)(s.IShortcutService))],Me);let Ne=class extends t.Disposable{constructor(e,t){super(),this._parserService=e,this._resolverService=t,this._handleInitUrl()}_handleInitUrl(){let e=location.hash;if(e){let t=this._parserService.parseHyperLink(e);this._resolverService.navigate(t)}}};Ne=w([C(0,(0,t.Inject)(f.SheetsHyperLinkParserService)),C(1,(0,t.Inject)(E))],Ne);let $=class extends t.Plugin{constructor(e=S,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},S,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(x,a)}onStarting(){[[E],[H],[ee],[ke],[Me],[De],[X],[Oe],[Ne]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(o.IRenderManagerService).registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[Ae]),this._injector.get(De),this._injector.get(X),this._injector.get(Me)}onRendered(){this._injector.get(Oe),this._injector.get(Ne),this._injector.get(ke)}};A($,`pluginName`,ge),A($,`packageName`,Te),A($,`version`,Ee),A($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=w([(0,t.DependentOn)(f.UniverSheetsHyperLinkPlugin,a.UniverDocsUIPlugin),C(1,(0,t.Inject)(t.Injector)),C(2,t.IConfigService)],$),e.CloseHyperLinkPopupOperation=q,e.InsertHyperLinkOperation=J,e.InsertLinkShortcut=we,e.OpenHyperLinkEditPanelOperation=K,Object.defineProperty(e,`SheetsHyperLinkCopyPasteController`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,`SheetsHyperLinkPopupService`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,`SheetsHyperLinkResolverService`,{enumerable:!0,get:function(){return E}}),e.SheetsHyperLinkSidePanelService=ee,Object.defineProperty(e,`UniverSheetsHyperLinkUIPlugin`,{enumerable:!0,get:function(){return $}})});
9
9
 
10
10
  // @univerjs/sheets-hyper-link-ui/facade
11
11
  (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require(`@univerjs/sheets-hyper-link`),require(`@univerjs/sheets-hyper-link-ui`),require(`@univerjs/sheets/facade`)):typeof define==`function`&&define.amd?define([`@univerjs/sheets-hyper-link`,`@univerjs/sheets-hyper-link-ui`,`@univerjs/sheets/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsHyperLink,e.UniverSheetsHyperLinkUi,e.UniverSheetsFacade))})(this,function(e,t,n){var r=class extends n.FWorkbook{navigateToSheetHyperlink(n){let r=this._injector.get(e.SheetsHyperLinkParserService),i=this._injector.get(t.SheetsHyperLinkResolverService),a=r.parseHyperLink(n);i.navigate(a)}};n.FWorkbook.extend(r)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-hyper-link",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,16 +58,16 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/sheets-hyper-link": "0.20.0",
62
- "@univerjs/sheets-hyper-link-ui": "0.20.0"
61
+ "@univerjs/sheets-hyper-link": "0.21.0",
62
+ "@univerjs/sheets-hyper-link-ui": "0.21.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@univerjs/core": "0.20.0",
65
+ "@univerjs/core": "0.21.0",
66
66
  "react": "18.3.1",
67
67
  "react-dom": "18.3.1",
68
68
  "rxjs": "7.8.2",
69
69
  "typescript": "^5.9.3",
70
- "@univerjs-infra/shared": "0.20.0"
70
+ "@univerjs-infra/shared": "0.21.0"
71
71
  },
72
72
  "scripts": {
73
73
  "prebuild:preset": "tsx prepare.ts",