@univerjs/preset-sheets-hyper-link 0.10.12 → 0.10.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/umd/index.js +2 -2
- package/package.json +5 -5
package/lib/umd/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @univerjs/sheets-hyper-link/index
|
|
2
|
-
(function(g,a){typeof exports=="object"&&typeof module<"u"?a(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"],a):(g=typeof globalThis<"u"?globalThis:g||self,a(g.UniverSheetsHyperLink={},g.UniverCore,g.UniverDocs,g.UniverSheets,g.rxjs,g.UniverEngineFormula))})(this,(function(g,a,w,m,Se,C){"use strict";var Ke=Object.defineProperty;var Ye=(g,a,w)=>a in g?Ke(g,a,{enumerable:!0,configurable:!0,writable:!0,value:w}):g[a]=w;var L=(g,a,w)=>Ye(g,typeof a!="symbol"?a+"":a,w);var Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},Me=(r,t)=>(e,n)=>t(e,n,r);g.HyperLinkModel=class extends a.Disposable{constructor(e){super();L(this,"_linkUpdate$",new Se.Subject);L(this,"linkUpdate$",this._linkUpdate$.asObservable());L(this,"_linkMap",new Map);L(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let i=this._linkMap.get(e);i||(i=new Map,this._linkMap.set(e,i));let s=i.get(n);s||(s=new a.ObjectMatrix,i.set(n,s));let o=this._linkPositionMap.get(e);o||(o=new Map,this._linkPositionMap.set(e,o));let d=o.get(n);return d||(d=new Map,o.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:o}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),o.set(i.id,{row:i.row,column:i.column,link:i}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,type:"add"}),!0}updateHyperLink(e,n,i,s,o=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;const u=d.getValue(l.row,l.column);return u&&(Object.assign(u,s),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:u.display,payload:u.payload},id:i,type:"update",silent:o})),!0}updateHyperLinkRef(e,n,i,s,o=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;let u=d.getValue(l.row,l.column);return!u||u.id!==i?u=l.link:d.realDeleteValue(l.row,l.column),Object.assign(u,s),c.set(i,{...s,link:u}),d.setValue(s.row,s.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:s,id:i,type:"updateRef",silent:o}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:o}=this._ensureMap(e,n),d=o.get(i);if(!d)return!1;o.delete(i);const c=s.getValue(d.row,d.column);return c&&c.id===i&&s.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,i){const{matrix:s,positionMap:o}=this._ensureMap(e,n),d=o.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:o}=this._ensureMap(e,n);return o.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var p,f,y,h,_;const{matrix:o}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET),c=(p=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:p.getCellRaw(i,s),l=((_=(h=c==null?void 0:c.v)!=null?h:(y=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:y.dataStream.slice(0,-2))!=null?_:"").toString(),u=o.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((o,d,c)=>{c&&s.push(c)}),s}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(i=>{const s=this.getSubUnit(e,i);return{unitId:e,subUnitId:i,links:s}}):[]}deleteUnit(e){const n=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:"unload",unitId:e,unitLinks:n})}getAll(){return Array.from(this._linkMap.keys()).map(n=>this.getUnit(n))}},g.HyperLinkModel=Re([Me(0,a.IUniverInstanceService)],g.HyperLinkModel);const E={type:a.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},T={type:a.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},re={type:a.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(a.ICommandService),n=r.get(a.IUndoRedoService),i=r.get(a.IUniverInstanceService),s=r.get(g.HyperLinkModel),o=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:p}=d,{link:f}=t,{payload:y,display:h,row:_,column:v,id:S}=f,k=p.getCell(_,v),I=p.getBlankCellDocumentModel(k,_,v),R=I.documentModel.getSnapshot(),M=a.Tools.deepClone(R.body);if(!M)return!1;let H;if(h?H=a.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:M.dataStream.length-2,collapsed:M.dataStream.length-2===0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:a.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:y}}]},doc:I.documentModel}):H=a.BuildTextUtils.customRange.add({body:M,ranges:[{startOffset:0,endOffset:M.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:a.CustomRangeType.HYPERLINK,properties:{url:y,refId:S}}),!H)return!1;const j=a.TextX.apply(M,H.serialize()),b={p:{...R,body:j},t:a.CellValueType.STRING},N=o.onWriteCell(u,p,_,v,b),V={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:V},Q=m.SetRangeValuesUndoMutationFactory(r,V),se={id:m.SetRangeValuesMutation.id,params:Q},A=[ie],P=[se],D=s.getHyperLinkByLocation(c,l,_,v);return D&&(A.push({id:T.id,params:{unitId:c,subUnitId:l,id:D.id}}),P.push({id:E.id,params:{unitId:c,subUnitId:l,link:D}})),await a.sequenceExecute(A,e)?await o.onValidateCell(u,p,_,v)===!1?(a.sequenceExecute(P,e),!1):(n.pushUndoRedo({redoMutations:A,undoMutations:P,unitID:c}),!0):!1}},ae={id:"sheets.command.add-rich-hyper-link",type:a.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(a.ICommandService),s=a.generateRandomId(),{payload:o}=n,d=w.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:a.CustomRangeType.HYPERLINK,properties:{url:o,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},oe={type:a.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var b,N;if(!t)return!1;const e=r.get(a.ICommandService),n=r.get(a.IUndoRedoService),i=r.get(a.IUniverInstanceService),s=r.get(g.HyperLinkModel),o=m.getSheetCommandTarget(i,t);if(!o)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:p,worksheet:f}=o,y=f.getCell(d,c);if(!y)return!1;const h=f.getCellDocumentModelWithFormula(y,d,c);if(!(h!=null&&h.documentModel))return!1;const _=a.Tools.deepClone(h.documentModel.getSnapshot()),v=(N=(b=_.body)==null?void 0:b.customRanges)==null?void 0:N.find(V=>`${V.rangeId}`===l);if(!v)return!1;const S=a.BuildTextUtils.customRange.delete({documentDataModel:h.documentModel,rangeId:v.rangeId});if(!S)return!1;const k=a.TextX.apply(_.body,S.serialize()),I=[],R=[],M={unitId:u,subUnitId:p,cellValue:{[d]:{[c]:{p:{..._,body:k},t:a.CellValueType.STRING}}}};I.push({id:m.SetRangeValuesMutation.id,params:M});const H=m.SetRangeValuesUndoMutationFactory(r,M);R.push({id:m.SetRangeValuesMutation.id,params:H});const j=s.getHyperLinkByLocation(u,p,d,c);return j&&(I.push({id:T.id,params:{unitId:u,subUnitId:p,id:l}}),R.push({id:E.id,params:{unitId:u,subUnitId:p,link:{...j}}})),a.sequenceExecute(I,e).result?(n.pushUndoRedo({redoMutations:I,undoMutations:R,unitID:u}),!0):!1}},de={type:a.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,p;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(a.ICommandService),o=r.get(a.IUniverInstanceService).getUnit(n,a.UniverInstanceType.UNIVER_DOC),d=(p=(u=o==null?void 0:o.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===o.getBody().dataStream.length-3&&(c={dataStream:" "});const l=w.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},ce={type:a.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var fe,ye,_e;if(!t)return!1;const e=r.get(a.ICommandService),n=r.get(a.IUndoRedoService),i=r.get(a.IUniverInstanceService),s=r.get(g.HyperLinkModel),o=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,{unitId:t.unitId,subUnitId:t.subUnitId});if(!d)return!1;const{payload:c,row:l,column:u,id:p}=t,{workbook:f,worksheet:y,unitId:h,subUnitId:_}=d,{payload:v,display:S=""}=c,k=y.getCell(l,u);if(!k)return!1;const I=y.getCellDocumentModelWithFormula(k,l,u);if(!(I!=null&&I.documentModel))return!1;const R=I.documentModel.getSnapshot(),M=(ye=(fe=R.body)==null?void 0:fe.customRanges)==null?void 0:ye.find(ve=>`${ve.rangeId}`===p);if(!M)return!1;const H=a.generateRandomId(),O=(_e=a.getBodySlice(I.documentModel.getBody(),M.startIndex,M.endIndex+1).textRuns)==null?void 0:_e[0];O&&(O.ed=S.length+1);const b=w.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${S}`,customRanges:[{rangeId:H,rangeType:a.CustomRangeType.HYPERLINK,startIndex:0,endIndex:S.length-1,properties:{url:v}}],textRuns:O?[O]:void 0},selection:{startOffset:M.startIndex,endOffset:M.endIndex+1,collapsed:!1},doc:I.documentModel});if(!b)return!1;const N=a.TextX.apply(a.Tools.deepClone(R.body),b.textX.serialize()),V={p:{...R,body:N},t:a.CellValueType.STRING},ie=o.onWriteCell(f,y,l,u,V),Q={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:_,cellValue:{[l]:{[u]:ie}}}},se=m.SetRangeValuesUndoMutationFactory(r,Q.params),A={id:m.SetRangeValuesMutation.id,params:se},P=[Q],D=[A],Z=s.getHyperLinkByLocation(h,_,l,u);return Z&&(P.push({id:T.id,params:{unitId:h,subUnitId:_,id:Z.id}}),D.push({id:E.id,params:{unitId:h,subUnitId:_,link:Z}})),a.sequenceExecute(P,e)?await o.onValidateCell(f,y,l,u)===!1?(a.sequenceExecute(D,e),!1):(n.pushUndoRedo({redoMutations:P,undoMutations:D,unitID:h}),!0):!1}},le={type:a.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,_,v,S;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(a.IUniverInstanceService),o=r.get(a.ICommandService),d=s.getUnit(e,a.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(_=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:_.find(k=>k.rangeId===i);if(!c)return!1;const l=(v=t.payload.display)!=null?v:"",u=a.generateRandomId(),f=(S=a.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:S[0];f&&(f.ed=l.length+1);const y=w.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:a.CustomRangeType.HYPERLINK,startIndex:0,endIndex:l.length-1,properties:{url:n.payload}}],textRuns:f?[f]:void 0},selection:{startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},doc:d});return y?o.syncExecuteCommand(y.id,y.params):!1}},x={type:a.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:o}=t;return e.updateHyperLink(n,i,o,s,!1)}},W={type:a.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:o,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:o,column:d},c)}},B={type:a.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(r,t){var y,h,_;if(!t)return!1;const{unitId:e,subUnitId:n,row:i,col:s,id:o,url:d}=t,c=r.get(a.IUniverInstanceService),l=m.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,p=u.getCellRaw(i,s),f=(_=(h=(y=p==null?void 0:p.p)==null?void 0:y.body)==null?void 0:h.customRanges)==null?void 0:_.find(v=>v.rangeType===a.CustomRangeType.HYPERLINK&&v.rangeId===o);return f&&(f.properties.url=d),!0}},Ce="sheets-hyper-link.config",ue={},pe="SHEET_HYPER_LINK_PLUGIN",$="err";var ke=Object.getOwnPropertyDescriptor,Le=(r,t,e,n)=>{for(var i=n>1?void 0:n?ke(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},z=(r,t)=>(e,n)=>t(e,n,r);let K=class extends a.Disposable{constructor(t,e,n,i){super();L(this,"_disposableMap",new Map);L(this,"_watchDisposableMap",new Map);L(this,"_rangeDisableMap",new Map);L(this,"_rangeWatcherMap",new Map);L(this,"_handlePositionChange",(t,e,n,i,s)=>{const o={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return i?{redos:[{id:W.id,params:{unitId:t,subUnitId:e,id:n.id,row:i.startRow,column:i.startColumn,silent:s}}],undos:[{id:W.id,params:{unitId:t,subUnitId:e,id:n.id,row:o.startRow,column:o.startColumn,silent:s}}]}:{redos:[{id:T.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:E.id,params:{unitId:t,subUnitId:e,link:n}}]}});this._refRangeService=t,this._hyperLinkModel=e,this._selectionManagerService=n,this._commandService=i,this._initData(),this._initRefRange()}_registerPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},o=d=>{const c=m.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===s.startColumn&&l.startRow===s.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(s,o,t,e))}_watchPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(t,e,s,(o,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);a.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_unwatchPosition(t){const e=this._watchDisposableMap.get(t);e==null||e.dispose(),this._watchDisposableMap.delete(t)}_registerRange(t,e,n,i=!1){var s,o,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(o=c.get("range"))!=null?o:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,p=C.deserializeRangeWithSheet(l.range).range;if(a.isValidRange(p)&&l.range!==$){const f=y=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(p,y,{selectionManagerService:this._selectionManagerService});return h&&C.serializeRange(h)===C.serializeRange(p)?{redos:[],undos:[]}:{redos:[{id:x.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`}}}],undos:[{id:x.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(p,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,p,(y,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`},!0)},!0))}}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_unwatchRange(t){const e=this._rangeWatcherMap.get(t);e==null||e.dispose(),this._rangeWatcherMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(n=>{const{unitId:i,subUnitId:s,links:o}=n;o.forEach(d=>{this._registerPosition(i,s,d),this._watchPosition(i,s,d),this._registerRange(i,d.id,d.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._registerPosition(t.unitId,t.subUnitId,t.payload),this._watchPosition(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregisterPosition(t.payload.id),this._unwatchPosition(t.payload.id),this._unregisterRange(t.payload.id),this._unwatchRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:n,id:i,silent:s}=t,o=this._hyperLinkModel.getHyperLink(e,n,i);if(!o)return;this._unregisterPosition(i),this._registerPosition(e,n,o),s||(this._unwatchPosition(i),this._watchPosition(e,n,o));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:i}=n;i.forEach(s=>{this._unregisterPosition(s.id),this._unwatchPosition(s.id),this._unregisterRange(s.id),this._unwatchRange(s.id)})});break}case"update":{t.silent||this._unwatchRange(t.id),this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload,t.silent);break}}})),this.disposeWithMe(a.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};K=Le([z(0,a.Inject(m.RefRangeService)),z(1,a.Inject(g.HyperLinkModel)),z(2,a.Inject(m.SheetsSelectionsService)),z(3,a.ICommandService)],K);var Ue=Object.getOwnPropertyDescriptor,we=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ue(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},ee=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends a.Disposable{constructor(r,t,e){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===m.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const o=this._hyperLinkModel.getSubUnit(i,s),d=o.map(l=>({id:T.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=o.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};Y=we([ee(0,a.Inject(m.SheetInterceptorService)),ee(1,a.IUniverInstanceService),ee(2,a.Inject(g.HyperLinkModel))],Y);var Ee=Object.getOwnPropertyDescriptor,Te=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ee(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},te=(r,t)=>(e,n)=>t(e,n,r);let q=class extends a.Disposable{constructor(t,e,n){super();L(this,"_refRangeMap",new Map);this._commandService=t,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(t,e){let n=this._refRangeMap.get(t);n||(n=new Map,this._refRangeMap.set(t,n));let i=n.get(e);return i||(i=new a.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,o;const n=this._univerInstanceService.getUnit(t,a.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const d=new URLSearchParams(e.slice(1)),c={gid:(i=d.get("gid"))!=null?i:"",range:(s=d.get("range"))!=null?s:"",rangeid:(o=d.get("rangeid"))!=null?o:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const p=C.deserializeRangeWithSheet(c.range).range;if(a.isValidRange(p,u)&&c.range!==$)return{range:p,worksheet:u}}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const o=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(p=>{var f;return p.rangeType===a.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=p.properties)==null?void 0:f.url)})){const p=new a.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(y=>{var h;if(y.rangeType===a.CustomRangeType.HYPERLINK){const _=(h=y.properties)==null?void 0:h.url,v=this._isLegalRangeUrl(t,_);if(v){const{range:S,worksheet:k}=v;f=!0,p.add(this._refRangeService.registerRefRange(S,I=>{const R=m.handleDefaultRangeChangeWithEffectRefCommands(S,I);return R&&a.Rectangle.equals(R,S)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:y.rangeId,url:`#gid=${e}&range=${R?C.serializeRange(R):$}`}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:y.rangeId,url:_}}],redos:[]}},k.getUnitId(),k.getSheetId()))}}}),f&&o.setValue(n,i,p)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),o=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=o.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===a.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===a.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId();this._enusreMap(n,s).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===m.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:i,cellValue:s}=e,o=this._enusreMap(n,i);s&&new a.ObjectMatrix(s).forValue((d,c,l)=>{const u=o.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===B.id){const e=t.params,{unitId:n,subUnitId:i,row:s,col:o}=e,d=m.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:i}),l=this._enusreMap(n,i).getValue(s,o);if(l&&l.dispose(),d){const{worksheet:u}=d,p=u.getCellRaw(s,o);p&&p.p&&this._registerRange(n,i,s,o,p.p)}}}))}};q=Te([te(0,a.ICommandService),te(1,a.IUniverInstanceService),te(2,a.Inject(m.RefRangeService))],q);var He=Object.getOwnPropertyDescriptor,be=(r,t,e,n)=>{for(var i=n>1?void 0:n?He(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},G=(r,t)=>(e,n)=>t(e,n,r);let F=class extends a.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._hyperLinkModel=t,this._selectionManagerService=e,this._univerInstanceService=n,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.SetRangeValuesCommand.id){const t=r.params,{unitId:e,subUnitId:n}=t,i=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((o,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,o,d);c&&(i.push({id:T.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:E.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:s,redos:i}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.ClearSelectionContentCommand.id||r.id===m.ClearSelectionAllCommand.id||r.id===m.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),i=m.getSheetCommandTarget(this._univerInstanceService);if(n&&i){const{unitId:s,subUnitId:o}=i;a.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,o,d,c);l&&(t.push({id:T.id,params:{unitId:s,subUnitId:o,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:o,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(m.AFTER_CELL_EDIT,{handler:(r,t,e)=>{if(!r||r.p)return e(r);if(typeof r.v=="string"&&a.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i,row:s,col:o}=t,d=this._univerInstanceService.getUnit(n,a.UniverInstanceType.UNIVER_SHEET),c=d==null?void 0:d.getSheetBySheetId(i);if(!c)return e(r);const l=c.getBlankCellDocumentModel(r,s,o);if(!l.documentModel)return e(r);const u=a.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:r.v.length,collapsed:!1},body:{dataStream:`${r.v}`,customRanges:[{startIndex:0,endIndex:r.v.length-1,rangeId:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:l.documentModel});if(!u)return e(r);const p=l.documentModel.getBody();return a.TextX.apply(p,u.serialize()),e({...r,p:{id:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:p,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};F=be([G(0,a.Inject(m.SheetInterceptorService)),G(1,a.Inject(g.HyperLinkModel)),G(2,a.Inject(m.SheetsSelectionsService)),G(3,a.IUniverInstanceService)],F);var Pe=Object.getOwnPropertyDescriptor,De=(r,t,e,n)=>{for(var i=n>1?void 0:n?Pe(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends a.Disposable{constructor(r,t){super(),this._resourceManagerService=r,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const r=e=>{const n=this._hyperLinkModel.getUnit(e),i={};return n?(n.forEach(s=>{i[s.subUnitId]=s.links.map(({display:o,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:pe,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(i=>{n[i].forEach(o=>{this._hyperLinkModel.addHyperLink(e,i,o)})})}}))}};X=De([ge(0,a.IResourceManagerService),ge(1,a.Inject(g.HyperLinkModel))],X);var Oe=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Oe(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},Ve=(r,t)=>(e,n)=>t(e,n,r);let J=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[re,ce,oe,le,de,ae,E,x,T,W,B].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ne([Ve(0,a.ICommandService)],J);var U=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(U||{}),$e=Object.getOwnPropertyDescriptor,je=(r,t,e,n)=>{for(var i=n>1?void 0:n?$e(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},ne=(r,t)=>(e,n)=>t(e,n,r);g.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${U.SHEET}=${e}${n?`&${typeof n=="string"?U.DEFINE_NAME:U.RANGE}=${typeof n=="string"?n:C.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const o=new URLSearchParams(t.slice(1)),d={gid:(e=o.get("gid"))!=null?e:"",range:(n=o.get("range"))!=null?n:"",rangeid:(i=o.get("rangeid"))!=null?i:"",unitid:(s=o.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:U.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,o=s?this._univerInstanceService.getUnit(s,a.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d={type:U.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!o)return d;const c=e?o.getSheetBySheetId(e):o.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const p=C.deserializeRangeWithSheet(n).range;return a.isValidRange(p,c)&&n!==$?{type:U.RANGE,name:C.serializeRangeWithSheet(l,p)}:d}if(i){const p=this._definedNamesService.getValueById(o.getUnitId(),i);return p?{type:U.DEFINE_NAME,name:p.formulaOrRefString}:d}if(e){const p=o.getSheetBySheetId(e);return p?{type:U.SHEET,name:p.getName()}:d}return d}},g.SheetsHyperLinkParserService=je([ne(0,a.IUniverInstanceService),ne(1,a.Inject(a.LocaleService)),ne(2,C.IDefinedNamesService)],g.SheetsHyperLinkParserService);var Ae=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,We=(r,t,e)=>t in r?Ae(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Be=(r,t,e,n)=>{for(var i=n>1?void 0:n?xe(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},he=(r,t)=>(e,n)=>t(e,n,r),me=(r,t,e)=>We(r,typeof t!="symbol"?t+"":t,e);g.UniverSheetsHyperLinkPlugin=class extends a.Plugin{constructor(t=ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=a.merge({},ue,this._config);this._configService.setConfig(Ce,i)}onStarting(){a.registerDependencies(this._injector,[[g.HyperLinkModel],[g.SheetsHyperLinkParserService],[X],[J],[K],[F],[Y],[q]]),a.touchDependencies(this._injector,[[K],[X],[J],[F],[Y],[q]])}},me(g.UniverSheetsHyperLinkPlugin,"pluginName",pe),me(g.UniverSheetsHyperLinkPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkPlugin=Be([a.DependentOn(m.UniverSheetsPlugin),he(1,a.Inject(a.Injector)),he(2,a.IConfigService)],g.UniverSheetsHyperLinkPlugin),g.AddHyperLinkCommand=re,g.AddHyperLinkMutation=E,g.AddRichHyperLinkCommand=ae,g.CancelHyperLinkCommand=oe,g.CancelRichHyperLinkCommand=de,g.ERROR_RANGE=$,g.RemoveHyperLinkMutation=T,g.SheetHyperLinkType=U,g.UpdateHyperLinkCommand=ce,g.UpdateHyperLinkMutation=x,g.UpdateHyperLinkRefMutation=W,g.UpdateRichHyperLinkCommand=le,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
+
(function(g,a){typeof exports=="object"&&typeof module<"u"?a(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"],a):(g=typeof globalThis<"u"?globalThis:g||self,a(g.UniverSheetsHyperLink={},g.UniverCore,g.UniverDocs,g.UniverSheets,g.rxjs,g.UniverEngineFormula))})(this,(function(g,a,w,m,Se,C){"use strict";var Ke=Object.defineProperty;var Ye=(g,a,w)=>a in g?Ke(g,a,{enumerable:!0,configurable:!0,writable:!0,value:w}):g[a]=w;var L=(g,a,w)=>Ye(g,typeof a!="symbol"?a+"":a,w);var Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},Me=(r,t)=>(e,n)=>t(e,n,r);g.HyperLinkModel=class extends a.Disposable{constructor(e){super();L(this,"_linkUpdate$",new Se.Subject);L(this,"linkUpdate$",this._linkUpdate$.asObservable());L(this,"_linkMap",new Map);L(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let i=this._linkMap.get(e);i||(i=new Map,this._linkMap.set(e,i));let s=i.get(n);s||(s=new a.ObjectMatrix,i.set(n,s));let o=this._linkPositionMap.get(e);o||(o=new Map,this._linkPositionMap.set(e,o));let d=o.get(n);return d||(d=new Map,o.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:o}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),o.set(i.id,{row:i.row,column:i.column,link:i}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,type:"add"}),!0}updateHyperLink(e,n,i,s,o=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;const u=d.getValue(l.row,l.column);return u&&(Object.assign(u,s),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:u.display,payload:u.payload},id:i,type:"update",silent:o})),!0}updateHyperLinkRef(e,n,i,s,o=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;let u=d.getValue(l.row,l.column);return!u||u.id!==i?u=l.link:d.realDeleteValue(l.row,l.column),Object.assign(u,s),c.set(i,{...s,link:u}),d.setValue(s.row,s.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:s,id:i,type:"updateRef",silent:o}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:o}=this._ensureMap(e,n),d=o.get(i);if(!d)return!1;o.delete(i);const c=s.getValue(d.row,d.column);return c&&c.id===i&&s.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,i){const{matrix:s,positionMap:o}=this._ensureMap(e,n),d=o.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:o}=this._ensureMap(e,n);return o.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var p,f,y,h,_;const{matrix:o}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET),c=(p=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:p.getCellRaw(i,s),l=((_=(h=c==null?void 0:c.v)!=null?h:(y=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:y.dataStream.slice(0,-2))!=null?_:"").toString(),u=o.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((o,d,c)=>{c&&s.push(c)}),s}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(i=>{const s=this.getSubUnit(e,i);return{unitId:e,subUnitId:i,links:s}}):[]}deleteUnit(e){const n=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:"unload",unitId:e,unitLinks:n})}getAll(){return Array.from(this._linkMap.keys()).map(n=>this.getUnit(n))}},g.HyperLinkModel=Re([Me(0,a.IUniverInstanceService)],g.HyperLinkModel);const E={type:a.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},T={type:a.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},re={type:a.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(a.ICommandService),n=r.get(a.IUndoRedoService),i=r.get(a.IUniverInstanceService),s=r.get(g.HyperLinkModel),o=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:p}=d,{link:f}=t,{payload:y,display:h,row:_,column:v,id:S}=f,k=p.getCell(_,v),I=p.getBlankCellDocumentModel(k,_,v),R=I.documentModel.getSnapshot(),M=a.Tools.deepClone(R.body);if(!M)return!1;let H;if(h?H=a.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:M.dataStream.length-2,collapsed:M.dataStream.length-2===0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:a.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:y}}]},doc:I.documentModel}):H=a.BuildTextUtils.customRange.add({body:M,ranges:[{startOffset:0,endOffset:M.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:a.CustomRangeType.HYPERLINK,properties:{url:y,refId:S}}),!H)return!1;const j=a.TextX.apply(M,H.serialize()),b={p:{...R,body:j},t:a.CellValueType.STRING},N=o.onWriteCell(u,p,_,v,b),V={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:V},Q=m.SetRangeValuesUndoMutationFactory(r,V),se={id:m.SetRangeValuesMutation.id,params:Q},A=[ie],P=[se],D=s.getHyperLinkByLocation(c,l,_,v);return D&&(A.push({id:T.id,params:{unitId:c,subUnitId:l,id:D.id}}),P.push({id:E.id,params:{unitId:c,subUnitId:l,link:D}})),await a.sequenceExecute(A,e)?await o.onValidateCell(u,p,_,v)===!1?(a.sequenceExecute(P,e),!1):(n.pushUndoRedo({redoMutations:A,undoMutations:P,unitID:c}),!0):!1}},ae={id:"sheets.command.add-rich-hyper-link",type:a.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(a.ICommandService),s=a.generateRandomId(),{payload:o}=n,d=w.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:a.CustomRangeType.HYPERLINK,properties:{url:o,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},oe={type:a.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var b,N;if(!t)return!1;const e=r.get(a.ICommandService),n=r.get(a.IUndoRedoService),i=r.get(a.IUniverInstanceService),s=r.get(g.HyperLinkModel),o=m.getSheetCommandTarget(i,t);if(!o)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:p,worksheet:f}=o,y=f.getCell(d,c);if(!y)return!1;const h=f.getCellDocumentModelWithFormula(y,d,c);if(!(h!=null&&h.documentModel))return!1;const _=a.Tools.deepClone(h.documentModel.getSnapshot()),v=(N=(b=_.body)==null?void 0:b.customRanges)==null?void 0:N.find(V=>`${V.rangeId}`===l);if(!v)return!1;const S=a.BuildTextUtils.customRange.delete({documentDataModel:h.documentModel,rangeId:v.rangeId});if(!S)return!1;const k=a.TextX.apply(_.body,S.serialize()),I=[],R=[],M={unitId:u,subUnitId:p,cellValue:{[d]:{[c]:{p:{..._,body:k},t:a.CellValueType.STRING}}}};I.push({id:m.SetRangeValuesMutation.id,params:M});const H=m.SetRangeValuesUndoMutationFactory(r,M);R.push({id:m.SetRangeValuesMutation.id,params:H});const j=s.getHyperLinkByLocation(u,p,d,c);return j&&(I.push({id:T.id,params:{unitId:u,subUnitId:p,id:l}}),R.push({id:E.id,params:{unitId:u,subUnitId:p,link:{...j}}})),a.sequenceExecute(I,e).result?(n.pushUndoRedo({redoMutations:I,undoMutations:R,unitID:u}),!0):!1}},de={type:a.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,p;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(a.ICommandService),o=r.get(a.IUniverInstanceService).getUnit(n,a.UniverInstanceType.UNIVER_DOC),d=(p=(u=o==null?void 0:o.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===o.getBody().dataStream.length-3&&(c={dataStream:" "});const l=w.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},ce={type:a.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var fe,ye,_e;if(!t)return!1;const e=r.get(a.ICommandService),n=r.get(a.IUndoRedoService),i=r.get(a.IUniverInstanceService),s=r.get(g.HyperLinkModel),o=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,{unitId:t.unitId,subUnitId:t.subUnitId});if(!d)return!1;const{payload:c,row:l,column:u,id:p}=t,{workbook:f,worksheet:y,unitId:h,subUnitId:_}=d,{payload:v,display:S=""}=c,k=y.getCell(l,u);if(!k)return!1;const I=y.getCellDocumentModelWithFormula(k,l,u);if(!(I!=null&&I.documentModel))return!1;const R=I.documentModel.getSnapshot(),M=(ye=(fe=R.body)==null?void 0:fe.customRanges)==null?void 0:ye.find(ve=>`${ve.rangeId}`===p);if(!M)return!1;const H=a.generateRandomId(),O=(_e=a.getBodySlice(I.documentModel.getBody(),M.startIndex,M.endIndex+1).textRuns)==null?void 0:_e[0];O&&(O.ed=S.length+1);const b=w.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${S}`,customRanges:[{rangeId:H,rangeType:a.CustomRangeType.HYPERLINK,startIndex:0,endIndex:S.length-1,properties:{url:v}}],textRuns:O?[O]:void 0},selection:{startOffset:M.startIndex,endOffset:M.endIndex+1,collapsed:!1},doc:I.documentModel});if(!b)return!1;const N=a.TextX.apply(a.Tools.deepClone(R.body),b.textX.serialize()),V={p:{...R,body:N},t:a.CellValueType.STRING},ie=o.onWriteCell(f,y,l,u,V),Q={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:_,cellValue:{[l]:{[u]:ie}}}},se=m.SetRangeValuesUndoMutationFactory(r,Q.params),A={id:m.SetRangeValuesMutation.id,params:se},P=[Q],D=[A],Z=s.getHyperLinkByLocation(h,_,l,u);return Z&&(P.push({id:T.id,params:{unitId:h,subUnitId:_,id:Z.id}}),D.push({id:E.id,params:{unitId:h,subUnitId:_,link:Z}})),a.sequenceExecute(P,e)?await o.onValidateCell(f,y,l,u)===!1?(a.sequenceExecute(D,e),!1):(n.pushUndoRedo({redoMutations:P,undoMutations:D,unitID:h}),!0):!1}},le={type:a.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,_,v,S;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(a.IUniverInstanceService),o=r.get(a.ICommandService),d=s.getUnit(e,a.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(_=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:_.find(k=>k.rangeId===i);if(!c)return!1;const l=(v=t.payload.display)!=null?v:"",u=a.generateRandomId(),f=(S=a.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:S[0];f&&(f.ed=l.length+1);const y=w.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:a.CustomRangeType.HYPERLINK,startIndex:0,endIndex:l.length-1,properties:{url:n.payload}}],textRuns:f?[f]:void 0},selection:{startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},doc:d});return y?o.syncExecuteCommand(y.id,y.params):!1}},x={type:a.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:o}=t;return e.updateHyperLink(n,i,o,s,!1)}},W={type:a.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(g.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:o,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:o,column:d},c)}},B={type:a.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(r,t){var y,h,_;if(!t)return!1;const{unitId:e,subUnitId:n,row:i,col:s,id:o,url:d}=t,c=r.get(a.IUniverInstanceService),l=m.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,p=u.getCellRaw(i,s),f=(_=(h=(y=p==null?void 0:p.p)==null?void 0:y.body)==null?void 0:h.customRanges)==null?void 0:_.find(v=>v.rangeType===a.CustomRangeType.HYPERLINK&&v.rangeId===o);return f&&(f.properties.url=d),!0}},Ce="sheets-hyper-link.config",ue={},pe="SHEET_HYPER_LINK_PLUGIN",$="err";var ke=Object.getOwnPropertyDescriptor,Le=(r,t,e,n)=>{for(var i=n>1?void 0:n?ke(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},z=(r,t)=>(e,n)=>t(e,n,r);let K=class extends a.Disposable{constructor(t,e,n,i){super();L(this,"_disposableMap",new Map);L(this,"_watchDisposableMap",new Map);L(this,"_rangeDisableMap",new Map);L(this,"_rangeWatcherMap",new Map);L(this,"_handlePositionChange",(t,e,n,i,s)=>{const o={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return i?{redos:[{id:W.id,params:{unitId:t,subUnitId:e,id:n.id,row:i.startRow,column:i.startColumn,silent:s}}],undos:[{id:W.id,params:{unitId:t,subUnitId:e,id:n.id,row:o.startRow,column:o.startColumn,silent:s}}]}:{redos:[{id:T.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:E.id,params:{unitId:t,subUnitId:e,link:n}}]}});this._refRangeService=t,this._hyperLinkModel=e,this._selectionManagerService=n,this._commandService=i,this._initData(),this._initRefRange()}_registerPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},o=d=>{const c=m.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===s.startColumn&&l.startRow===s.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(s,o,t,e))}_watchPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(t,e,s,(o,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);a.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_unwatchPosition(t){const e=this._watchDisposableMap.get(t);e==null||e.dispose(),this._watchDisposableMap.delete(t)}_registerRange(t,e,n,i=!1){var s,o,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(o=c.get("range"))!=null?o:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,p=C.deserializeRangeWithSheet(l.range).range;if(a.isValidRange(p)&&l.range!==$){const f=y=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(p,y,{selectionManagerService:this._selectionManagerService});return h&&C.serializeRange(h)===C.serializeRange(p)?{redos:[],undos:[]}:{redos:[{id:x.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`}}}],undos:[{id:x.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(p,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,p,(y,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`},!0)},!0))}}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_unwatchRange(t){const e=this._rangeWatcherMap.get(t);e==null||e.dispose(),this._rangeWatcherMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(n=>{const{unitId:i,subUnitId:s,links:o}=n;o.forEach(d=>{this._registerPosition(i,s,d),this._watchPosition(i,s,d),this._registerRange(i,d.id,d.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._registerPosition(t.unitId,t.subUnitId,t.payload),this._watchPosition(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregisterPosition(t.payload.id),this._unwatchPosition(t.payload.id),this._unregisterRange(t.payload.id),this._unwatchRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:n,id:i,silent:s}=t,o=this._hyperLinkModel.getHyperLink(e,n,i);if(!o)return;this._unregisterPosition(i),this._registerPosition(e,n,o),s||(this._unwatchPosition(i),this._watchPosition(e,n,o));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:i}=n;i.forEach(s=>{this._unregisterPosition(s.id),this._unwatchPosition(s.id),this._unregisterRange(s.id),this._unwatchRange(s.id)})});break}case"update":{t.silent||this._unwatchRange(t.id),this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload,t.silent);break}}})),this.disposeWithMe(a.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};K=Le([z(0,a.Inject(m.RefRangeService)),z(1,a.Inject(g.HyperLinkModel)),z(2,a.Inject(m.SheetsSelectionsService)),z(3,a.ICommandService)],K);var Ue=Object.getOwnPropertyDescriptor,we=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ue(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},ee=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends a.Disposable{constructor(r,t,e){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===m.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const o=this._hyperLinkModel.getSubUnit(i,s),d=o.map(l=>({id:T.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=o.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};Y=we([ee(0,a.Inject(m.SheetInterceptorService)),ee(1,a.IUniverInstanceService),ee(2,a.Inject(g.HyperLinkModel))],Y);var Ee=Object.getOwnPropertyDescriptor,Te=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ee(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},te=(r,t)=>(e,n)=>t(e,n,r);let q=class extends a.Disposable{constructor(t,e,n){super();L(this,"_refRangeMap",new Map);this._commandService=t,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(t,e){let n=this._refRangeMap.get(t);n||(n=new Map,this._refRangeMap.set(t,n));let i=n.get(e);return i||(i=new a.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,o;const n=this._univerInstanceService.getUnit(t,a.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const d=new URLSearchParams(e.slice(1)),c={gid:(i=d.get("gid"))!=null?i:"",range:(s=d.get("range"))!=null?s:"",rangeid:(o=d.get("rangeid"))!=null?o:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const p=C.deserializeRangeWithSheet(c.range).range;if(a.isValidRange(p,u)&&c.range!==$)return{range:p,worksheet:u}}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const o=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(p=>{var f;return p.rangeType===a.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=p.properties)==null?void 0:f.url)})){const p=new a.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(y=>{var h;if(y.rangeType===a.CustomRangeType.HYPERLINK){const _=(h=y.properties)==null?void 0:h.url,v=this._isLegalRangeUrl(t,_);if(v){const{range:S,worksheet:k}=v;f=!0,p.add(this._refRangeService.registerRefRange(S,I=>{const R=m.handleDefaultRangeChangeWithEffectRefCommands(S,I);return R&&a.Rectangle.equals(R,S)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:y.rangeId,url:`#gid=${e}&range=${R?C.serializeRange(R):$}`}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:y.rangeId,url:_}}],redos:[]}},k.getUnitId(),k.getSheetId()))}}}),f&&o.setValue(n,i,p)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),o=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=o.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===a.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===a.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId();this._enusreMap(n,s).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===m.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:i,cellValue:s}=e,o=this._enusreMap(n,i);s&&new a.ObjectMatrix(s).forValue((d,c,l)=>{const u=o.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===B.id){const e=t.params,{unitId:n,subUnitId:i,row:s,col:o}=e,d=m.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:i}),l=this._enusreMap(n,i).getValue(s,o);if(l&&l.dispose(),d){const{worksheet:u}=d,p=u.getCellRaw(s,o);p&&p.p&&this._registerRange(n,i,s,o,p.p)}}}))}};q=Te([te(0,a.ICommandService),te(1,a.IUniverInstanceService),te(2,a.Inject(m.RefRangeService))],q);var He=Object.getOwnPropertyDescriptor,be=(r,t,e,n)=>{for(var i=n>1?void 0:n?He(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},G=(r,t)=>(e,n)=>t(e,n,r);let F=class extends a.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._hyperLinkModel=t,this._selectionManagerService=e,this._univerInstanceService=n,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.SetRangeValuesCommand.id){const t=r.params,{unitId:e,subUnitId:n}=t,i=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((o,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,o,d);c&&(i.push({id:T.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:E.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:s,redos:i}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.ClearSelectionContentCommand.id||r.id===m.ClearSelectionAllCommand.id||r.id===m.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),i=m.getSheetCommandTarget(this._univerInstanceService);if(n&&i){const{unitId:s,subUnitId:o}=i;a.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,o,d,c);l&&(t.push({id:T.id,params:{unitId:s,subUnitId:o,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:o,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(m.AFTER_CELL_EDIT,{handler:(r,t,e)=>{if(!r||r.p)return e(r);if(typeof r.v=="string"&&a.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i,row:s,col:o}=t,d=a.Tools.normalizeUrl(r.v),c=this._univerInstanceService.getUnit(n,a.UniverInstanceType.UNIVER_SHEET),l=c==null?void 0:c.getSheetBySheetId(i);if(!l)return e(r);const u=l.getBlankCellDocumentModel(r,s,o);if(!u.documentModel)return e(r);const p=a.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:r.v.length,collapsed:!1},body:{dataStream:`${r.v}`,customRanges:[{startIndex:0,endIndex:r.v.length-1,rangeId:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:d}}]},doc:u.documentModel});if(!p)return e(r);const f=u.documentModel.getBody();return a.TextX.apply(f,p.serialize()),e({...r,p:{id:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:f,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};F=be([G(0,a.Inject(m.SheetInterceptorService)),G(1,a.Inject(g.HyperLinkModel)),G(2,a.Inject(m.SheetsSelectionsService)),G(3,a.IUniverInstanceService)],F);var Pe=Object.getOwnPropertyDescriptor,De=(r,t,e,n)=>{for(var i=n>1?void 0:n?Pe(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends a.Disposable{constructor(r,t){super(),this._resourceManagerService=r,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const r=e=>{const n=this._hyperLinkModel.getUnit(e),i={};return n?(n.forEach(s=>{i[s.subUnitId]=s.links.map(({display:o,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:pe,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(i=>{n[i].forEach(o=>{this._hyperLinkModel.addHyperLink(e,i,o)})})}}))}};X=De([ge(0,a.IResourceManagerService),ge(1,a.Inject(g.HyperLinkModel))],X);var Oe=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Oe(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},Ve=(r,t)=>(e,n)=>t(e,n,r);let J=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[re,ce,oe,le,de,ae,E,x,T,W,B].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ne([Ve(0,a.ICommandService)],J);var U=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(U||{}),$e=Object.getOwnPropertyDescriptor,je=(r,t,e,n)=>{for(var i=n>1?void 0:n?$e(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},ne=(r,t)=>(e,n)=>t(e,n,r);g.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${U.SHEET}=${e}${n?`&${typeof n=="string"?U.DEFINE_NAME:U.RANGE}=${typeof n=="string"?n:C.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const o=new URLSearchParams(t.slice(1)),d={gid:(e=o.get("gid"))!=null?e:"",range:(n=o.get("range"))!=null?n:"",rangeid:(i=o.get("rangeid"))!=null?i:"",unitid:(s=o.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:U.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,o=s?this._univerInstanceService.getUnit(s,a.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d={type:U.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!o)return d;const c=e?o.getSheetBySheetId(e):o.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const p=C.deserializeRangeWithSheet(n).range;return a.isValidRange(p,c)&&n!==$?{type:U.RANGE,name:C.serializeRangeWithSheet(l,p)}:d}if(i){const p=this._definedNamesService.getValueById(o.getUnitId(),i);return p?{type:U.DEFINE_NAME,name:p.formulaOrRefString}:d}if(e){const p=o.getSheetBySheetId(e);return p?{type:U.SHEET,name:p.getName()}:d}return d}},g.SheetsHyperLinkParserService=je([ne(0,a.IUniverInstanceService),ne(1,a.Inject(a.LocaleService)),ne(2,C.IDefinedNamesService)],g.SheetsHyperLinkParserService);var Ae=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,We=(r,t,e)=>t in r?Ae(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Be=(r,t,e,n)=>{for(var i=n>1?void 0:n?xe(t,e):t,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=o(i)||i);return i},he=(r,t)=>(e,n)=>t(e,n,r),me=(r,t,e)=>We(r,typeof t!="symbol"?t+"":t,e);g.UniverSheetsHyperLinkPlugin=class extends a.Plugin{constructor(t=ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=a.merge({},ue,this._config);this._configService.setConfig(Ce,i)}onStarting(){a.registerDependencies(this._injector,[[g.HyperLinkModel],[g.SheetsHyperLinkParserService],[X],[J],[K],[F],[Y],[q]]),a.touchDependencies(this._injector,[[K],[X],[J],[F],[Y],[q]])}},me(g.UniverSheetsHyperLinkPlugin,"pluginName",pe),me(g.UniverSheetsHyperLinkPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkPlugin=Be([a.DependentOn(m.UniverSheetsPlugin),he(1,a.Inject(a.Injector)),he(2,a.IConfigService)],g.UniverSheetsHyperLinkPlugin),g.AddHyperLinkCommand=re,g.AddHyperLinkMutation=E,g.AddRichHyperLinkCommand=ae,g.CancelHyperLinkCommand=oe,g.CancelRichHyperLinkCommand=de,g.ERROR_RANGE=$,g.RemoveHyperLinkMutation=T,g.SheetHyperLinkType=U,g.UpdateHyperLinkCommand=ce,g.UpdateHyperLinkMutation=x,g.UpdateHyperLinkRefMutation=W,g.UpdateRichHyperLinkCommand=le,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// @univerjs/sheets-hyper-link/facade
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// @univerjs/sheets-hyper-link-ui/index
|
|
10
|
-
(function(g,o){typeof exports=="object"&&typeof module<"u"?o(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("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-hyper-link"),require("react"),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","react/jsx-runtime","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-hyper-link","react","@univerjs/sheets-data-validation"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.UniverSheetsHyperLinkUi={},g.UniverCore,g.UniverSheets,g.UniverSheetsUi,g.UniverDocs,g.UniverDocsUi,g.UniverEngineRender,g.UniverUi,g.rxjs,g.React,g.UniverDesign,g.UniverEngineFormula,g.UniverSheetsFormulaUi,g.UniverSheetsHyperLink,g.React,g.UniverSheetsDataValidation))})(this,(function(g,o,f,P,pe,J,he,m,k,y,L,z,Mt,_,E,tt){"use strict";var kn=Object.defineProperty;var Nn=(g,o,f)=>o in g?kn(g,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):g[o]=f;var F=(g,o,f)=>Nn(g,typeof o!="symbol"?o+"":o,f);var C=(e=>(e.EDITING="editing",e.VIEWING="viewing",e.ZEN_EDITOR="zen_mode",e))(C||{});function Ce(e){return o.Tools.isLegalUrl(e)}function Ut(e){return/^[a-zA-Z]+:\/\//.test(e)}function Ht(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function xt(e){if(Ce(e)){const n=Ut(e)?e:Ht(e)?`mailto://${e}`:`http://${e}`;let t;try{t=new URL(n)}catch{return e}return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:n}return e}const nt="sheets-hyper-link-ui.config",it={};var At=Object.getOwnPropertyDescriptor,Bt=(e,n,t,i)=>{for(var r=i>1?void 0:i?At(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ce=(e,n)=>(t,i)=>n(t,i,e);function Vt(e,n){const t=n.getMergeData(),i=n.getMaxColumns()-1,r=n.getMaxRows()-1;if(i<e.endColumn&&(e.endColumn=i),r<e.endRow&&(e.endRow=r),e.rangeType===o.RANGE_TYPE.COLUMN||o.RANGE_TYPE.ROW)return e;const s=[];return t.forEach(a=>{o.Rectangle.intersects(e,a)&&s.push(a)}),o.Rectangle.realUnion(e,...s)}g.SheetsHyperLinkResolverService=class{constructor(n,t,i,r,s,a){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=i,this._messageService=r,this._localeService=s,this._configService=a}navigate(n){switch(n.type){case _.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:t,range:i,rangeid:r}=n,s=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const a=s.getUnitId();if(r){const u=this._definedNamesService.getValueById(a,r);if(!u)return;const{formulaOrRefString:l}=u,h=this._definedNamesService.getWorksheetByRef(a,l);if(!h){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:L.MessageType.Error});return}if(h.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error});return}this.navigateToDefineName(a,r)}if(t){if(i){const u=z.deserializeRangeWithSheet(i);o.isValidRange(u.range)&&i!==_.ERROR_RANGE&&this.navigateToRange(a,t,u.range);return}this.navigateToSheetById(a,t)}}async navigateToRange(n,t,i,r){const s=await this.navigateToSheetById(n,t);if(s){const a=Vt(i,s);await this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:t,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(P.ScrollToRangeOperation.id,{range:a,forceTop:r})}}async navigateToSheetById(n,t){const i=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const s=i.getSheetBySheetId(t);return s?i.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error}),!1):await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?s:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:L.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){var i;const t=this._configService.getConfig(nt);if((i=t==null?void 0:t.urlHandler)!=null&&i.navigateToOtherWebsite)return t.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}},g.SheetsHyperLinkResolverService=Bt([ce(0,o.IUniverInstanceService),ce(1,o.ICommandService),ce(2,z.IDefinedNamesService),ce(3,m.IMessageService),ce(4,o.Inject(o.LocaleService)),ce(5,o.IConfigService)],g.SheetsHyperLinkResolverService);class je extends o.Disposable{constructor(){super(...arguments);F(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==_.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(r=>r.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:i}=this;i.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const Ee=()=>{var mt;const[e,n]=E.useState(""),[t,i]=E.useState(!1),[r,s]=E.useState(""),[a,u]=E.useState(!0),[l,h]=E.useState(_.SheetHyperLinkType.URL),[d,p]=E.useState(""),I=m.useDependency(o.LocaleService),S=m.useDependency(z.IDefinedNamesService),R=m.useDependency(P.IEditorBridgeService),w=m.useDependency(o.IUniverInstanceService),T=m.useDependency(g.SheetsHyperLinkPopupService),c=m.useObservable(T.currentEditing$),D=m.useDependency(_.SheetsHyperLinkParserService),A=m.useDependency(g.SheetsHyperLinkResolverService),M=m.useDependency(o.ICommandService),U=m.useDependency(je),j=E.useMemo(()=>U.getOptions(),[U]),V=m.useDependency(m.IZenZoneService),q=m.useDependency(he.IRenderManagerService),oe=m.useDependency(P.IMarkSelectionService),Ae=m.useDependency(pe.DocSelectionManagerService),se=m.useDependency(o.IContextService),Ie=m.useDependency(o.ThemeService),_e=m.useDependency(pe.DocSelectionManagerService),[me,Be]=E.useState(!1),ue=m.useDependency(f.SheetsSelectionsService),Tn=E.useMemo(()=>ue.getCurrentSelections(),[]),Ve=E.useMemo(()=>{if(!U.isBuiltInLinkType(l))return U.getCustomHyperLink(l)},[U,l]),[le,Ln]=E.useState(!1),[fe,It]=E.useState(!1),$=E.useRef(!1),W=w.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),wn=(W==null?void 0:W.getActiveSheet().getSheetId())||"",Q=E.useCallback(v=>{s(v.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[s]);E.useEffect(()=>{var v,b,O,N,x,Y,ft,yt,Ct,Et,Pt,Rt,Tt,Lt,wt,Dt,bt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:ae,row:Qe,col:et}=c;let{label:X}=c;typeof X=="number"&&(X=`${X}`);let G;if(ae)G={id:(v=ae==null?void 0:ae.rangeId)!=null?v:"",display:X!=null?X:"",payload:(O=(b=ae==null?void 0:ae.properties)==null?void 0:b.url)!=null?O:"",row:Qe,column:et};else if(c.type===C.VIEWING){const H=w.getUnit(c.unitId),te=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=te==null?void 0:te.getCellRaw(c.row,c.col),de=(Y=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:Y.find(kt=>{var Nt;return kt.rangeType===o.CustomRangeType.HYPERLINK&&((Nt=kt.properties)==null?void 0:Nt.url)}),ye=B==null?void 0:B.v;B&&(!o.BuildTextUtils.transform.isEmptyDocument((yt=(ft=B.p)==null?void 0:ft.body)==null?void 0:yt.dataStream)||o.Tools.isDefine(ye))&&u(!1),G={id:"",display:"",payload:(Et=(Ct=de==null?void 0:de.properties)==null?void 0:Ct.url)!=null?Et:"",row:Qe,column:et}}else{const H=w.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),te=Ae.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=te&&B?te:null,ye=de&&((Rt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Pt=B==null?void 0:B.customRanges)!=null?Pt:[]))==null?void 0:Rt[0]);u(!1),G={id:"",display:X!=null?X:"",payload:(Lt=(Tt=ye==null?void 0:ye.properties)==null?void 0:Tt.url)!=null?Lt:"",row:Qe,column:et}}n(G.id);const Ot=U.findCustomHyperLink(G);if(Ot){const H=Ot.convert(G);h(H.type),p(H.payload),Q(H.display);return}Q(G.display);const ee=D.parseHyperLink(G.payload);switch(h(ee.type===_.SheetHyperLinkType.INVALID?_.SheetHyperLinkType.RANGE:ee.type),ee.type){case _.SheetHyperLinkType.URL:{p(ee.url),ee.url===G.display&&($.current=!0);break}case _.SheetHyperLinkType.RANGE:{const H=ee.searchObj,te=H.gid&&(bt=(Dt=(wt=w.getUnit(c.unitId))==null?void 0:wt.getSheetBySheetId(H.gid))==null?void 0:Dt.getName())!=null?bt:"",B=z.serializeRangeWithSheet(te,z.deserializeRangeWithSheet(H.range).range);p(B),B===G.display&&($.current=!0);break}case _.SheetHyperLinkType.SHEET:{const H=ee.searchObj;p(H.gid);break}case _.SheetHyperLinkType.DEFINE_NAME:{const H=ee.searchObj;p(H.rangeid);break}default:p("");break}}},[c,A,U,Ae,w]),E.useEffect(()=>{let v=null;if(c&&!c.customRangeId&&c.type===C.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const b=w.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),O=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=O==null?void 0:O.getMergedCell(c.row,c.col),x=new o.ColorKit(Ie.getColorFromTheme("primary.600")).toRgb();v=oe.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&oe.removeShape(v)}},[c,oe,Ie,w]),E.useEffect(()=>{It(l===_.SheetHyperLinkType.RANGE)},[l]),E.useEffect(()=>{const v=(c==null?void 0:c.type)===C.ZEN_EDITOR?q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):q.getRenderById(R.getCurrentEditorId()),b=new o.DisposableCollection;if(v){const O=v.with(J.DocSelectionRenderService);O.setReserveRangesStatus(!0),b.add(()=>{O.setReserveRangesStatus(!1)})}return()=>{R.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,R,q]),E.useEffect(()=>(fe&&T.setIsKeepVisible(fe),T.setIsKeepVisible(me),()=>{T.setIsKeepVisible(!1)}),[fe,me,T]),E.useEffect(()=>()=>{V.temporaryHidden&&(V.show(),se.setContextValue(o.FOCUSING_SHEET,!1))},[se,V]),E.useEffect(()=>{if(fe)return R.enableForceKeepVisible(),()=>{R.disableForceKeepVisible()}},[fe,R]);const Dn=[{label:I.t("hyperLink.form.link"),value:_.SheetHyperLinkType.URL},{label:I.t("hyperLink.form.range"),value:_.SheetHyperLinkType.RANGE},{label:I.t("hyperLink.form.worksheet"),value:_.SheetHyperLinkType.SHEET},{label:I.t("hyperLink.form.definedName"),value:_.SheetHyperLinkType.DEFINE_NAME},...j];if(!W)return;const bn=W.getHiddenWorksheets(),qe=W.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>bn.indexOf(v.value)===-1),Xe=Object.values((mt=S.getDefinedNameMap(W.getUnitId()))!=null?mt:{}).map(v=>({label:v.name,value:v.id})),_t=(v,b)=>{if(v===_.SheetHyperLinkType.URL)return xt(b);if(v===_.SheetHyperLinkType.RANGE){const O=z.deserializeRangeWithSheet(b),N=W.getSheetBySheetName(O.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${z.serializeRange(O.range)}`}return`#${v}=${b}`},On=m.useEvent(v=>{var x;const O=v.split(",").map(z.deserializeRangeWithSheet)[0];if(!O||!o.isValidRange(O.range))return;O.sheetName||(O.sheetName=((x=W.getActiveSheet())==null?void 0:x.getName())||"");const N=z.serializeRangeToRefString(O);p(N),N&&($.current||!r)&&(Q(N),$.current=!0)}),Je=async()=>{if(a&&!r||!d||l===_.SheetHyperLinkType.URL&&!Ce(d)){Ln(!0);return}if(c)if(e){const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.UpdateRichHyperLinkCommand.id:_.UpdateHyperLinkCommand.id;await M.executeCommand(v,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?r:"",payload:_t(l,d)},row:c.row,column:c.col,documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}else{const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.AddRichHyperLinkCommand.id:_.AddHyperLinkCommand.id;await M.executeCommand(v,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:_t(l,d),display:a?r:""},documentId:c.type===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:R.getCurrentEditorId()})}if((c==null?void 0:c.type)===C.VIEWING){await M.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const v=1;await M.executeCommand(P.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-v,0),endRow:c.row+v,startColumn:Math.max(c.col-v,0),endColumn:c.col+v}})}M.executeCommand(ge.id)};return c?y.jsxs("div",{className: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:[a?y.jsx(L.FormLayout,{label:I.t("hyperLink.form.label"),error:le&&!r?I.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:r,onChange:v=>{Q(v),$.current=!1},placeholder:I.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Je()}})}):null,y.jsx(L.FormLayout,{label:I.t("hyperLink.form.type"),children:y.jsx(L.Select,{className:"univer-w-full",options:Dn,value:l,onChange:v=>{h(v),p("")}})}),l===_.SheetHyperLinkType.URL&&y.jsx(L.FormLayout,{error:le?d?Ce(d)?"":I.t("hyperLink.form.linkError"):I.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:d,onChange:v=>{p(v),v&&($.current||!r||r===v)&&(Q(v),$.current=!0)},placeholder:I.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Je()}})}),l===_.SheetHyperLinkType.RANGE&&y.jsx(L.FormLayout,{error:le&&!d?I.t("hyperLink.form.inputError"):"",children:y.jsx(Mt.RangeSelector,{unitId:W.getUnitId(),subUnitId:wn,maxRangeCount:1,supportAcrossSheet:!0,initialValue:d,resetRange:Tn,onChange:(v,b)=>On(b),onRangeSelectorDialogVisibleChange:async v=>{var b,O;if(Be(v),v)c.type===C.ZEN_EDITOR&&(V.hide(),se.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==C.VIEWING&&R.enableForceKeepVisible(),i(!0);else{if(await A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===C.ZEN_EDITOR){await M.executeCommand(f.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),V.show(),se.setContextValue(o.FOCUSING_SHEET,!1);const N=(b=q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(J.DocBackScrollRenderController),x=(O=_e.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:O[0];N&&x&&(N.scrollToRange(x),_e.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}R.disableForceKeepVisible(),i(!1)}},onFocusChange:v=>It(v)})}),l===_.SheetHyperLinkType.SHEET&&y.jsx(L.FormLayout,{error:le&&!d?I.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:qe,value:d,onChange:v=>{var N,x;p(v);const b=(N=qe.find(Y=>Y.value===v))==null?void 0:N.label,O=(x=qe.find(Y=>Y.value===d))==null?void 0:x.label;b&&($.current||!r||r===O)&&(Q(b),$.current=!0)}})}),l===_.SheetHyperLinkType.DEFINE_NAME&&y.jsx(L.FormLayout,{error:le&&!d?I.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:Xe,value:d,onChange:v=>{var N,x;p(v);const b=(N=Xe.find(Y=>Y.value===v))==null?void 0:N.label,O=(x=Xe.find(Y=>Y.value===d))==null?void 0:x.label;b&&($.current||!r||r===O)&&(Q(b),$.current=!0)}})}),(Ve==null?void 0:Ve.Form)&&y.jsx(Ve.Form,{linkId:e,payload:d,display:r,showError:le,setByPayload:$,setDisplay:v=>{Q(v),$.current=!0},setPayload:p}),y.jsxs("div",{className:"univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[y.jsx(L.Button,{onClick:()=>{c&&A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),M.executeCommand(ge.id)},children:I.t("hyperLink.form.cancel")}),y.jsx(L.Button,{variant:"primary",onClick:async()=>{Je()},children:I.t("hyperLink.form.ok")})]})]}):null};Ee.componentKey="univer.sheet.cell-link-edit";var Z=function(){return Z=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Z.apply(this,arguments)},jt=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},ne=E.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,s=e.extend,a=jt(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),l=E.useRef("_".concat(Ft()));return rt(t,"".concat(i),{defIds:t.defIds,idSuffix:l.current},Z({ref:n,className:u},a),s)});function rt(e,n,t,i,r){return E.createElement(e.tag,Z(Z({key:n},$t(e,t,r)),i),(Zt(e,t).children||[]).map(function(s,a){return rt(s,"".concat(n,"-").concat(e.tag,"-").concat(a),t,void 0,r)}))}function $t(e,n,t){var i=Z({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),e.tag==="mask"&&i.id&&(i.id=i.id+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],u=s[1];a==="mask"&&typeof u=="string"&&(i[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],u=s[1];typeof u=="string"&&(i[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function Zt(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?Z(Z({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.includes(r.attrs.id)?Z(Z({},r),{attrs:Z(Z({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function Ft(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";var Kt={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"}}]},Pe=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"all-border-icon",ref:n,icon:Kt}))});Pe.displayName="AllBorderIcon";var Wt={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"}}]},ot=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"copy-icon",ref:n,icon:Wt}))});ot.displayName="CopyIcon";var Yt={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"}}]},$e=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"link-icon",ref:n,icon:Yt}))});$e.displayName="LinkIcon";var Gt={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"}}]},st=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"unlink-icon",ref:n,icon:Gt}))});st.displayName="UnlinkIcon";var zt={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"}}]},at=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"write-icon",ref:n,icon:zt}))});at.displayName="WriteIcon";var qt={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"}}]},ct=E.forwardRef(function(e,n){return E.createElement(ne,Object.assign({},e,{id:"xlsx-multi-icon",ref:n,icon:qt}))});ct.displayName="XlsxMultiIcon";const Xt={[_.SheetHyperLinkType.URL]:y.jsx($e,{}),[_.SheetHyperLinkType.SHEET]:y.jsx(ct,{className:"univer-text-green-500"}),[_.SheetHyperLinkType.RANGE]:y.jsx(Pe,{}),[_.SheetHyperLinkType.DEFINE_NAME]:y.jsx(Pe,{}),[_.SheetHyperLinkType.INVALID]:y.jsx(Pe,{})},ut=e=>{var A,M;const n=m.useDependency(g.SheetsHyperLinkPopupService),t=m.useDependency(o.ICommandService),i=m.useDependency(m.IMessageService),r=m.useDependency(o.LocaleService),s=m.useDependency(g.SheetsHyperLinkResolverService),a=m.useDependency(P.IEditorBridgeService),u=m.useDependency(_.SheetsHyperLinkParserService),l=m.useDependency(m.IZenZoneService),{customRange:h,row:d,col:p,unitId:I,subUnitId:S,editPermission:R,copyPermission:w,type:T}=e;if(!((A=h==null?void 0:h.properties)!=null&&A.url))return null;const c=u.parseHyperLink((M=h.properties.url)!=null?M:""),D=c.type===_.SheetHyperLinkType.INVALID;return y.jsxs("div",{className: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:()=>n.hideCurrentPopup(),children:[y.jsxs("div",{className: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":D}),onClick:()=>{l.visible||D||s.navigate(c)},children:[y.jsx("div",{className:"univer-mr-2 univer-flex univer-h-5 univer-w-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",children:Xt[c.type]}),y.jsx(L.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:y.jsx("span",{className:"univer-flex-1 univer-overflow-hidden univer-text-ellipsis",children:c.name})})]}),y.jsxs("div",{className:"univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center",children:[w&&y.jsx("div",{className: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":D}),onClick:()=>{if(!D){if(c.type!==_.SheetHyperLinkType.URL){const U=new URL(window.location.href);U.hash=c.url.slice(1),navigator.clipboard.writeText(U.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:L.MessageType.Info})}},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:y.jsx(ot,{className:"dark:!univer-text-white"})})}),R&&y.jsxs(y.Fragment,{children:[y.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:()=>{t.executeCommand(Te.id,{unitId:I,subUnitId:S,row:d,col:p,customRangeId:h.rangeId,type:T})},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:y.jsx(at,{className:"dark:!univer-text-white"})})}),y.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:()=>{const U=T===C.EDITING||T===C.ZEN_EDITOR?_.CancelRichHyperLinkCommand.id:_.CancelHyperLinkCommand.id;t.syncExecuteCommand(U,{unitId:I,subUnitId:S,id:h.rangeId,row:d,column:p,documentId:T===C.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:y.jsx(st,{className:"dark:!univer-text-white"})})})]})]})]})},Re=()=>{var r,s;const e=m.useDependency(g.SheetsHyperLinkPopupService),[n,t]=E.useState(null),i=m.useDependency(o.IUniverInstanceService);if(E.useEffect(()=>{t(e.currentPopup);const a=e.currentPopup$.subscribe(u=>{t(u)});return()=>{a.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const a=i.getUnit(n.unitId,o.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(n.subUnitId),l=u==null?void 0:u.getCell(n.row,n.col),h=(s=(r=l==null?void 0:l.p)==null?void 0:r.body)==null?void 0:s.customRanges;return h!=null&&h.length?y.jsx("div",{children:h.map(d=>y.jsx(ut,{...n,customRange:d},d.rangeId))}):null}return y.jsx(ut,{...n})};Re.componentKey="univer.sheet.cell-link-popup";var Jt=Object.getOwnPropertyDescriptor,Qt=(e,n,t,i)=>{for(var r=i>1?void 0:i?Jt(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},ie=(e,n)=>(t,i)=>n(t,i,e);const lt=(e,n)=>{var t,i;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((i=n.customRange)==null?void 0:i.rangeId)&&e.type===n.type};g.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(t,i,r,s,a,u,l){super();F(this,"_currentPopup",null);F(this,"_currentPopup$",new k.Subject);F(this,"currentPopup$",this._currentPopup$.asObservable());F(this,"_currentEditingPopup",null);F(this,"_currentEditing$",new k.BehaviorSubject(null));F(this,"currentEditing$",this._currentEditing$.asObservable());F(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=s,this._textSelectionManagerService=a,this._docCanvasPopManagerService=u,this._zenZoneService=l,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){var I;if(this._currentPopup&<(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==C.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&<(t,i))return;const{unitId:r,subUnitId:s,row:a,col:u,customRangeRect:l,customRange:h}=t;let d;const p={componentKey:Re.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===C.EDITING){if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l,p)}else if(t.type===C.ZEN_EDITOR){if(!h)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:h.startIndex,endOffset:h.endIndex+1,collapsed:!1},p,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,p,r,s);else{if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupByPosition(l,p,t)}d&&(this._currentPopup&&((I=this._currentPopup.disposable)==null||I.dispose()),this._currentPopup={unitId:r,subUnitId:s,disposable:d,row:a,col:u,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:h,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,i){var r,s;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((s=(r=this._currentPopup)==null?void 0:r.disposable)==null||s.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}dispose(){super.dispose(),this.hideCurrentPopup(),this.endEditing(),this._currentPopup$.complete(),this._currentEditing$.complete()}_getEditingRange(){var r,s,a;const t=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(t&&i){const u=this._textSelectionManagerService.getActiveTextRange(),l=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!l)return null;if(!u||u.collapsed)return{startOffset:0,endOffset:l.dataStream.length-2,collapsed:l.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(l.dataStream)};const h=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(u,(a=(s=l.customRanges)==null?void 0:s.filter(I=>I.rangeType===o.CustomRangeType.HYPERLINK))!=null?a:[]);let d=u.startOffset,p=u.endOffset;return h.forEach(I=>{d=Math.min(d,I.startIndex),p=Math.max(p,I.endIndex+1)}),{startOffset:d,endOffset:p,collapsed:d===p,label:o.BuildTextUtils.transform.getPlainText(l.dataStream.slice(d,p))}}return null}get _editPopup(){return{componentKey:Ee.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var a,u,l,h,d;const{unitId:i,subUnitId:r,type:s}=t;if(s===C.ZEN_EDITOR){const p=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!p)return;const I=this._textSelectionManagerService.getActiveTextRange();if(!I)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(I,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const S=(a=p.getBody())==null?void 0:a.dataStream.slice(I.startOffset,I.endOffset);this._currentEditing$.next({...t,label:S})}else if(s===C.EDITING){const p=this._getEditingRange();if(!p)return;this._textSelectionManagerService.replaceDocRanges([{...p}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const I=this._injector.get(he.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!I)return;const S=J.calcDocRangePositions(p,I);if(!(S!=null&&S.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.pop(),this._editPopup,i,r),this._currentEditing$.next({...t,label:(u=p==null?void 0:p.label)!=null?u:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r);const p=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),I=p==null?void 0:p.getSheetBySheetId(r),S=I==null?void 0:I.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:S!=null&&S.p?o.BuildTextUtils.transform.getPlainText((h=(l=S.p.body)==null?void 0:l.dataStream)!=null?h:""):((d=S==null?void 0:S.v)!=null?d:"").toString()})}}startEditing(t){var u,l,h,d,p,I;(u=this._currentEditingPopup)==null||u.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=t;let s,a;if(t.type===C.ZEN_EDITOR){const S=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(s=(h=(l=S==null?void 0:S.getBody())==null?void 0:l.customRanges)==null?void 0:h.find(R=>R.rangeId===t.customRangeId),a=s?(d=S==null?void 0:S.getBody())==null?void 0:d.dataStream.slice(s.startIndex,s.endIndex+1):"",!s||!a)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:s.startIndex,endOffset:s.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===C.EDITING){const S=P.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!S||!((p=S.rects)!=null&&p.length))return;s=S.customRange,a=S.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:s.startIndex,endOffset:s.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.rects.pop(),this._editPopup,i,r)}else{const S=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),R=S==null?void 0:S.getSheetBySheetId(r),w=R==null?void 0:R.getCellRaw(t.row,t.col),T=S==null?void 0:S.getStyles().getStyleByCell(w),c=T==null?void 0:T.tr,D=P.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!D||!((I=D.rects)!=null&&I.length))return;s=D.customRange,a=D.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(D.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:s,label:a})}endEditing(t){var r;if(this.getIsKeepVisible())return;const i=this._currentEditing$.getValue();i&&(!t||t===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=Qt([ie(0,o.Inject(P.SheetCanvasPopManagerService)),ie(1,o.Inject(o.Injector)),ie(2,o.IUniverInstanceService),ie(3,P.IEditorBridgeService),ie(4,o.Inject(pe.DocSelectionManagerService)),ie(5,o.Inject(J.DocCanvasPopManagerService)),ie(6,m.IZenZoneService)],g.SheetsHyperLinkPopupService);var ve=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(ve||{});const en=new Set([o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE]),Ze=(e,n,t,i)=>{var u,l,h,d,p;const r=n.getCell(t,i);if(r!=null&&r.f||r!=null&&r.si||(h=(l=(u=r==null?void 0:r.p)==null?void 0:u.body)==null?void 0:l.customBlocks)!=null&&h.length)return 1;const s=e.has(tt.SheetDataValidationModel)?e.get(tt.SheetDataValidationModel):null,a=s==null?void 0:s.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,i);return a&&en.has(a.type)?!0:(p=(d=r==null?void 0:r.p)==null?void 0:d.drawingsOrder)!=null&&p.length?2:0},tn=e=>{const n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),i=e.get(f.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,s=i[0].range.startColumn;return Ze(e,t,r,s)===1},nn=e=>{const n=e.get(pe.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(a=>a.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},Te={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(g.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},ge={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},Le={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var p;const n=e.get(o.IUniverInstanceService),t=f.getSheetCommandTarget(n),i=e.get(P.IEditorBridgeService);if(!t)return!1;const r=e.get(o.ICommandService),a=e.get(f.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const u=a.range.startRow,l=a.range.startColumn,h=i.isVisible(),d=((p=n.getFocusedUnit())==null?void 0:p.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Te.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:u,col:l,type:d?C.ZEN_EDITOR:h.visible?C.EDITING:C.VIEWING})}},re={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(tn(e))return!1;const n=e.get(o.ICommandService);return e.get(g.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ge.id):n.executeCommand(Le.id)}},Fe="SHEET_HYPER_LINK_UI_PLUGIN";var rn=Object.getOwnPropertyDescriptor,on=(e,n,t,i)=>{for(var r=i>1?void 0:i?rn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},we=(e,n)=>(t,i)=>n(t,i,e);g.SheetsHyperLinkCopyPasteController=class extends o.Disposable{constructor(t,i,r,s){super();F(this,"_plainTextFilter",new Set);F(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=i,this._injector=r,this._resolverService=s,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(t){this._plainTextFilter.add(t)}removePlainTextFilter(t){this._plainTextFilter.delete(t)}_filterPlainText(t){return Array.from(this._plainTextFilter).every(i=>i(t))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Fe,onBeforeCopy:(t,i,r)=>this._collect(t,i,r),onPasteCells:(t,i,r,s)=>{const{copyType:a=P.COPY_TYPE.COPY,pasteType:u}=s,{range:l}=t||{},{range:h,unitId:d,subUnitId:p}=i;return this._generateMutations(h,{copyType:a,pasteType:u,copyRange:l,unitId:d,subUnitId:p})},onPastePlainText:(t,i)=>{const r=this._filterPlainText(i);if(Ce(i)&&r){const{range:s,unitId:a,subUnitId:u}=t,{ranges:[l],mapFunc:h}=P.virtualizeDiscreteRanges([s]),d=[],p=[];return o.Range.foreach(l,(I,S)=>{const{row:R,col:w}=h(I,S),T=this._hyperLinkModel.getHyperLinkByLocation(a,u,R,w);T&&d.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:u,id:T.id}}),T&&p.push({id:_.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:u,link:T}})}),{redos:d,undos:p}}return{undos:[],redos:[]}},priority:99})}_collect(t,i,r){const s=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:i,matrix:s};const a=this._injector.invoke(h=>f.rangeToDiscreteRange(r,h,t,i));if(!a)return;const{rows:u,cols:l}=a;u.forEach((h,d)=>{l.forEach((p,I)=>{var R;const S=this._hyperLinkModel.getHyperLinkByLocation(t,i,h,p);s.setValue(d,I,(R=S==null?void 0:S.id)!=null?R:"")})})}_generateMutations(t,i){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!i.copyRange)return{redos:[],undos:[]};if([P.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,P.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,P.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,P.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(i.pasteType))return{redos:[],undos:[]};const{unitId:s,subUnitId:a}=this._copyInfo,u=[],l=[],{ranges:[h,d],mapFunc:p}=P.virtualizeDiscreteRanges([i.copyRange,t]);return P.getRepeatRange(h,d,!0).forEach(({startRange:S})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((w,T,c)=>{const D=o.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:T,endColumn:T},S),A=this._hyperLinkModel.getHyperLink(s,a,c),{row:M,col:U}=p(D.startRow,D.startColumn),j=this._hyperLinkModel.getHyperLinkByLocation(i.unitId,i.subUnitId,M,U),V=o.generateRandomId();j&&u.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:j.id}}),A&&(u.push({id:_.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:{...A,id:V,row:M,column:U}}}),l.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:V}})),j&&l.push({id:_.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:j}})})}),{redos:u,undos:l}}},g.SheetsHyperLinkCopyPasteController=on([we(0,P.ISheetClipboardService),we(1,o.Inject(_.HyperLinkModel)),we(2,o.Inject(o.Injector)),we(3,o.Inject(g.SheetsHyperLinkResolverService))],g.SheetsHyperLinkCopyPasteController);const Ke=(e,n=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const t=e.get(o.IUniverInstanceService),i=(r=e.get(he.IRenderManagerService).getRenderById(n))==null?void 0:r.with(J.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(k.map(()=>{const a=e.get(P.IEditorBridgeService).getEditCellState();if(!a)return!0;const u=f.getSheetCommandTarget(t,{unitId:a.unitId,subUnitId:a.sheetId});return!(u!=null&&u.worksheet)||Ze(e,u.worksheet,a.row,a.column)===1?!0:nn(e)})):k.of(!0)},dt=e=>{var r;const n=e.get(o.IUniverInstanceService),t=e.has(P.IEditorBridgeService)?e.get(P.IEditorBridgeService):null;return((r=t==null?void 0:t.currentEditCellState$.pipe(k.map(s=>{if(!s)return ve.DISABLED_BY_CELL;const a=f.getSheetCommandTarget(n,{unitId:s.unitId,subUnitId:s.sheetId});return a?Ze(e,a.worksheet,s.row,s.column):ve.DISABLED_BY_CELL}),k.switchMap(s=>{if(s===ve.DISABLED_BY_CELL)return k.of(!0);const a=t?t.visible$:k.of(null);return k.combineLatest([a,n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC)]).pipe(k.switchMap(([u,l])=>u!=null&&u.visible?(l==null?void 0:l.getUnitId())===o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?k.of(!0):Ke(e,o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):k.of(s!==ve.ALLOWED)))})))!=null?r:k.of(!0)).pipe(k.switchMap(s=>s?k.of(!0):P.getCurrentRangeDisable$(e,{workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},!0)))},De={commandId:Le.id,type:m.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkIcon"},be=e=>`${e}-zen-editor`,sn=e=>({...De,id:De.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:dt(e)}),an=e=>({...De,id:be(De.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(e)}),Oe={tooltip:"hyperLink.form.addTitle",commandId:re.id,type:m.MenuItemType.BUTTON,icon:"LinkIcon"},cn=e=>({...Oe,id:Oe.commandId,hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:dt(e)}),un=e=>({...Oe,id:be(Oe.commandId),hidden$:m.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(e)}),We={id:re.id,binding:m.KeyCode.K|m.MetaKeys.CTRL_COMMAND,preconditions:P.whenSheetEditorFocused};var ln=Object.getOwnPropertyDescriptor,dn=(e,n,t,i)=>{for(var r=i>1?void 0:i?ln(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},pt=(e,n)=>(t,i)=>n(t,i,e);let ke=class extends o.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:s,target:a,unitId:u,subUnitId:l}=i,h=P.virtualizeDiscreteRanges([s,a]),[d,p]=h.ranges,{mapFunc:I}=h,S={row:d.startRow,col:d.startColumn},R=P.getAutoFillRepeatRange(d,p),w=[],T=[];return R.forEach(c=>{const D=c.repeatStartCell,A=c.relativeRange,M={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},U={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};o.Range.foreach(A,(j,V)=>{const q=o.Rectangle.getPositionRange({startRow:j,startColumn:V,endColumn:V,endRow:j},M),{row:oe,col:Ae}=I(q.startRow,q.startColumn),se=this._hyperLinkModel.getHyperLinkByLocation(u,l,oe,Ae),Ie=o.Rectangle.getPositionRange({startRow:j,startColumn:V,endColumn:V,endRow:j},U),{row:_e,col:me}=I(Ie.startRow,Ie.startColumn),Be=o.generateRandomId(),ue=this._hyperLinkModel.getHyperLinkByLocation(u,l,_e,me);ue&&w.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:ue.id}}),(P.APPLY_TYPE.COPY===r||P.APPLY_TYPE.SERIES===r)&&se&&(w.push({id:_.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:{...se,id:Be,row:_e,column:me}}}),T.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:Be}})),ue&&T.push({id:_.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:ue}})})}),{undos:T,redos:w}},t={id:Fe,onFillData:(i,r,s)=>s===P.APPLY_TYPE.COPY||s===P.APPLY_TYPE.ONLY_FORMAT||s===P.APPLY_TYPE.SERIES?n(i,s):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};ke=dn([pt(0,P.IAutoFillService),pt(1,o.Inject(_.HyperLinkModel))],ke);var pn=Object.getOwnPropertyDescriptor,hn=(e,n,t,i)=>{for(var r=i>1?void 0:i?pn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ye=(e,n)=>(t,i)=>n(t,i,e);let Ne=class extends o.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===We.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],rangeTypes:[f.RangeProtectionPermissionEditPoint],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Ne=hn([Ye(0,o.Inject(o.LocaleService)),Ye(1,o.ICommandService),Ye(2,o.Inject(f.SheetPermissionCheckController))],Ne);var vn=Object.getOwnPropertyDescriptor,gn=(e,n,t,i)=>{for(var r=i>1?void 0:i?vn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},K=(e,n)=>(t,i)=>n(t,i,e);let Me=class extends o.Disposable{constructor(e,n,t,i,r,s,a,u,l,h){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=i,this._sheetPermissionCheckController=r,this._commandService=s,this._editorBridgeService=a,this._textSelectionManagerService=u,this._univerInstanceService=l,this._zenZoneService=h,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(t);if(!a)return{viewPermission:!1,editPermission:!1,copyPermission:!1};const u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookViewPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]);let l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]);const h=a.getCellRaw(i,r);h!=null&&h.f&&h.f.startsWith("=HYPERLINK(")&&(l=!1);const d=this._permissionService.composePermission([new f.WorkbookCopyPermission(n).id,new f.WorksheetCopyPermission(n,t).id]).every(p=>p.value);return{viewPermission:u,editPermission:l,copyPermission:d}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(k.debounceTime(200)).subscribe(e=>{var M,U,j;if(!e||((M=e.customRange)==null?void 0:M.rangeType)!==o.CustomRangeType.HYPERLINK){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:i,col:r}=e,s=this._renderManagerService.getRenderById(n);if(!s)return;const a=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(t);if(!u)return;if(!s.with(P.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING);return}const h=(U=s==null?void 0:s.with(P.SheetSkeletonManagerService).getSkeletonParam(t))==null?void 0:U.skeleton,d=r,p=i;let I=p,S=d;h&&h.overflowCache.forValue((V,q,oe)=>{o.Rectangle.contains(oe,{startColumn:d,endColumn:d,startRow:p,endRow:p})&&(I=V,S=q)});const{viewPermission:R,editPermission:w,copyPermission:T}=this._getLinkPermission(e);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=u.getCellStyleOnly(I,S),D=a.getStyles().getStyleByCell(c),A=(j=D==null?void 0:D.tr)==null?void 0:j.a;if(!A&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:I,col:S,editPermission:w,copyPermission:T,customRange:e.customRange,customRangeRect:e.rect,type:C.VIEWING,unitId:n,subUnitId:t,showAll:!!A})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(k.switchMap(n=>this._editorBridgeService.visible$.pipe(k.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:s,row:a,column:u}=t,l=this._renderManagerService.getRenderById(i);if(!l)return;const{editPermission:h,viewPermission:d,copyPermission:p}=this._getLinkPermission({unitId:r,subUnitId:s,row:a,col:u}),I=l.with(J.DocEventManagerService);d&&(e==null||e.unsubscribe(),e=I.hoverCustomRanges$.pipe(k.debounceTime(200)).subscribe(S=>{var D,A;const R=S.find(M=>M.range.rangeType===o.CustomRangeType.HYPERLINK);if(!R){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const w=R.rects[R.rects.length-1];if(!((A=(D=this._renderManagerService.getRenderById(r))==null?void 0:D.with(P.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:A.skeleton)||!w)return;const c=l.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:s,row:a,col:u,customRange:R.range,customRangeRect:{left:w.left+c.left,top:w.top+c.top,bottom:w.bottom+c.top,right:w.right+c.left},editPermission:h,copyPermission:p,type:C.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(C.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(k.switchMap(e=>{const n=e===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(J.DocEventManagerService).hoverCustomRanges$.pipe(k.debounceTime(200)):new k.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(i=>i.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:i,sheetId:r,row:s,column:a}=t,{editPermission:u,viewPermission:l,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:r,row:s,col:a});l&&this._sheetsHyperLinkPopupService.showPopup({type:C.ZEN_EDITOR,unitId:i,subUnitId:r,row:s,col:a,customRange:n.range,editPermission:u,copyPermission:h})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(C.EDITING)}))}_initCommandListener(){const e=[f.ClearSelectionContentCommand.id,f.ClearSelectionAllCommand.id,f.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Me=gn([K(0,o.Inject(P.HoverManagerService)),K(1,o.Inject(g.SheetsHyperLinkPopupService)),K(2,o.Inject(he.IRenderManagerService)),K(3,o.Inject(o.IPermissionService)),K(4,o.Inject(f.SheetPermissionCheckController)),K(5,o.ICommandService),K(6,P.IEditorBridgeService),K(7,o.Inject(pe.DocSelectionManagerService)),K(8,o.IUniverInstanceService),K(9,m.IZenZoneService)],Me);var Sn=Object.getOwnPropertyDescriptor,ht=(e,n,t,i)=>{for(var r=i>1?void 0:i?Sn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Ge=(e,n)=>(t,i)=>n(t,i,e);let ze=class extends o.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{e()}))}};ze=ht([Ge(1,o.Inject(_.HyperLinkModel))],ze);let Ue=class extends o.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:i,col:r,unitId:s,subUnitId:a}=n,u=this._hyperLinkModel.getHyperLinkByLocation(s,a,i,r);return u&&e&&(e===n.rawData&&(e={...n.rawData}),e.linkUrl=u.payload,e.linkId=u.id),t(e)}}))}};Ue=ht([Ge(0,o.Inject(f.SheetInterceptorService)),Ge(1,o.Inject(_.HyperLinkModel))],Ue);const In={[m.RibbonInsertGroup.MEDIA]:{[re.id]:{order:1,menuItemFactory:cn},[be(re.id)]:{order:1,menuItemFactory:un}},[m.ContextMenuPosition.MAIN_AREA]:{[m.ContextMenuGroup.OTHERS]:{order:1,[re.id]:{order:0,menuItemFactory:sn},[be(re.id)]:{order:0,menuItemFactory:an}}}};var _n=Object.getOwnPropertyDescriptor,mn=(e,n,t,i)=>{for(var r=i>1?void 0:i?_n(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},Se=(e,n)=>(t,i)=>n(t,i,e);let He=class extends o.Disposable{constructor(e,n,t,i,r){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=i,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Re.componentKey,Re],[Ee.componentKey,Ee],["LinkIcon",$e]].forEach(([e,n])=>{this._componentManager.register(e,n)})}_initCommands(){[Te,ge,Le,re].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(In)}_initShortCut(){this._shortcutService.registerShortcut(We)}};He=mn([Se(0,o.Inject(m.ComponentManager)),Se(1,o.ICommandService),Se(2,m.IMenuManagerService),Se(3,o.Inject(o.Injector)),Se(4,o.Inject(m.IShortcutService))],He);var fn=Object.getOwnPropertyDescriptor,yn=(e,n,t,i)=>{for(var r=i>1?void 0:i?fn(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},vt=(e,n)=>(t,i)=>n(t,i,e);let xe=class extends o.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};xe=yn([vt(0,o.Inject(_.SheetsHyperLinkParserService)),vt(1,o.Inject(g.SheetsHyperLinkResolverService))],xe);var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Pn=(e,n,t)=>n in e?Cn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Rn=(e,n,t,i)=>{for(var r=i>1?void 0:i?En(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=a(r)||r);return r},gt=(e,n)=>(t,i)=>n(t,i,e),St=(e,n,t)=>Pn(e,typeof n!="symbol"?n+"":n,t);g.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=it,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{menu:r,...s}=o.merge({},it,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(nt,s)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[je],[Ue],[Me],[He],[ke],[g.SheetsHyperLinkCopyPasteController],[Ne],[xe]].forEach(t=>this._injector.add(t)),this._injector.get(Ue)}onReady(){this._injector.get(he.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ze]),this._injector.get(ke),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(He)}onRendered(){this._injector.get(Ne),this._injector.get(xe),this._injector.get(Me)}},St(g.UniverSheetsHyperLinkUIPlugin,"pluginName",Fe),St(g.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Rn([o.DependentOn(_.UniverSheetsHyperLinkPlugin,J.UniverDocsUIPlugin),gt(1,o.Inject(o.Injector)),gt(2,o.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=ge,g.InsertHyperLinkOperation=Le,g.InsertLinkShortcut=We,g.OpenHyperLinkEditPanelOperation=Te,g.SheetsHyperLinkSidePanelService=je,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
10
|
+
(function(g,s){typeof exports=="object"&&typeof module<"u"?s(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("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-hyper-link"),require("react"),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","react/jsx-runtime","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-hyper-link","react","@univerjs/sheets-data-validation"],s):(g=typeof globalThis<"u"?globalThis:g||self,s(g.UniverSheetsHyperLinkUi={},g.UniverCore,g.UniverSheets,g.UniverSheetsUi,g.UniverDocs,g.UniverDocsUi,g.UniverEngineRender,g.UniverUi,g.rxjs,g.React,g.UniverDesign,g.UniverEngineFormula,g.UniverSheetsFormulaUi,g.UniverSheetsHyperLink,g.React,g.UniverSheetsDataValidation))})(this,(function(g,s,f,E,de,X,pe,m,O,y,L,G,Nt,_,R,et){"use strict";var bn=Object.defineProperty;var kn=(g,s,f)=>s in g?bn(g,s,{enumerable:!0,configurable:!0,writable:!0,value:f}):g[s]=f;var Z=(g,s,f)=>kn(g,typeof s!="symbol"?s+"":s,f);var C=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(C||{});function ye(t){return s.Tools.isLegalUrl(t)}function Mt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Ut(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function Ht(t){if(ye(t)){const n=Mt(t)?t:Ut(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(n)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:n}return t}const tt="sheets-hyper-link-ui.config",nt={};var xt=Object.getOwnPropertyDescriptor,At=(t,n,e,i)=>{for(var r=i>1?void 0:i?xt(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},ae=(t,n)=>(e,i)=>n(e,i,t);function $t(t,n){const e=n.getMergeData(),i=n.getMaxColumns()-1,r=n.getMaxRows()-1;if(i<t.endColumn&&(t.endColumn=i),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const o=[];return e.forEach(a=>{s.Rectangle.intersects(t,a)&&o.push(a)}),s.Rectangle.realUnion(t,...o)}g.SheetsHyperLinkResolverService=class{constructor(n,e,i,r,o,a){this._univerInstanceService=n,this._commandService=e,this._definedNamesService=i,this._messageService=r,this._localeService=o,this._configService=a}navigate(n){switch(n.type){case _.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:e,range:i,rangeid:r}=n,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(r){const u=this._definedNamesService.getValueById(a,r);if(!u)return;const{formulaOrRefString:l}=u,h=this._definedNamesService.getWorksheetByRef(a,l);if(!h){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:L.MessageType.Error});return}if(h.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error});return}this.navigateToDefineName(a,r)}if(e){if(i){const u=G.deserializeRangeWithSheet(i);s.isValidRange(u.range)&&i!==_.ERROR_RANGE&&this.navigateToRange(a,e,u.range);return}this.navigateToSheetById(a,e)}}async navigateToRange(n,e,i,r){const o=await this.navigateToSheetById(n,e);if(o){const a=$t(i,o);await this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:e,selections:[{range:a,primary:null}]}),await this._commandService.executeCommand(E.ScrollToRangeOperation.id,{range:a,forceTop:r})}}async navigateToSheetById(n,e){const i=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const o=i.getSheetBySheetId(e);return o?i.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error}),!1):await this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:e})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:L.MessageType.Error}),!1)}async navigateToDefineName(n,e){return this._definedNamesService.focusRange(n,e),!0}async navigateToOtherWebsite(n){var i;const e=this._configService.getConfig(tt);if((i=e==null?void 0:e.urlHandler)!=null&&i.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}},g.SheetsHyperLinkResolverService=At([ae(0,s.IUniverInstanceService),ae(1,s.ICommandService),ae(2,G.IDefinedNamesService),ae(3,m.IMessageService),ae(4,s.Inject(s.LocaleService)),ae(5,s.IConfigService)],g.SheetsHyperLinkResolverService);class Be extends s.Disposable{constructor(){super(...arguments);Z(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==_.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:i}=this;i.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const Ce=()=>{var _t;const[t,n]=R.useState(""),[e,i]=R.useState(!1),[r,o]=R.useState(""),[a,u]=R.useState(!0),[l,h]=R.useState(_.SheetHyperLinkType.URL),[d,p]=R.useState(""),S=m.useDependency(s.LocaleService),I=m.useDependency(G.IDefinedNamesService),P=m.useDependency(E.IEditorBridgeService),w=m.useDependency(s.IUniverInstanceService),T=m.useDependency(g.SheetsHyperLinkPopupService),c=m.useObservable(T.currentEditing$),D=m.useDependency(_.SheetsHyperLinkParserService),A=m.useDependency(g.SheetsHyperLinkResolverService),M=m.useDependency(s.ICommandService),U=m.useDependency(Be),V=R.useMemo(()=>U.getOptions(),[U]),B=m.useDependency(m.IZenZoneService),z=m.useDependency(pe.IRenderManagerService),re=m.useDependency(E.IMarkSelectionService),xe=m.useDependency(de.DocSelectionManagerService),se=m.useDependency(s.IContextService),Ie=m.useDependency(s.ThemeService),Se=m.useDependency(de.DocSelectionManagerService),[_e,Ae]=R.useState(!1),ce=m.useDependency(f.SheetsSelectionsService),Rn=R.useMemo(()=>ce.getCurrentSelections(),[]),$e=R.useMemo(()=>{if(!U.isBuiltInLinkType(l))return U.getCustomHyperLink(l)},[U,l]),[ue,Pn]=R.useState(!1),[me,It]=R.useState(!1),j=R.useRef(!1),K=w.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Tn=(K==null?void 0:K.getActiveSheet().getSheetId())||"",J=R.useCallback(v=>{o(v.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[o]);R.useEffect(()=>{var v,b,k,N,x,W,mt,ft,yt,Ct,Et,Rt,Pt,Tt,Lt,wt,Dt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:oe,row:Je,col:Qe}=c;let{label:q}=c;typeof q=="number"&&(q=`${q}`);let Y;if(oe)Y={id:(v=oe==null?void 0:oe.rangeId)!=null?v:"",display:q!=null?q:"",payload:(k=(b=oe==null?void 0:oe.properties)==null?void 0:b.url)!=null?k:"",row:Je,column:Qe};else if(c.type===C.VIEWING){const H=w.getUnit(c.unitId),ee=H==null?void 0:H.getSheetBySheetId(c.subUnitId),$=ee==null?void 0:ee.getCellRaw(c.row,c.col),le=(W=(x=(N=$==null?void 0:$.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:W.find(kt=>{var Ot;return kt.rangeType===s.CustomRangeType.HYPERLINK&&((Ot=kt.properties)==null?void 0:Ot.url)}),fe=$==null?void 0:$.v;$&&(!s.BuildTextUtils.transform.isEmptyDocument((ft=(mt=$.p)==null?void 0:mt.body)==null?void 0:ft.dataStream)||s.Tools.isDefine(fe))&&u(!1),Y={id:"",display:"",payload:(Ct=(yt=le==null?void 0:le.properties)==null?void 0:yt.url)!=null?Ct:"",row:Je,column:Qe}}else{const H=w.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ee=xe.getActiveTextRange(),$=H==null?void 0:H.getBody(),le=ee&&$?ee:null,fe=le&&((Rt=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(le,(Et=$==null?void 0:$.customRanges)!=null?Et:[]))==null?void 0:Rt[0]);u(!1),Y={id:"",display:q!=null?q:"",payload:(Tt=(Pt=fe==null?void 0:fe.properties)==null?void 0:Pt.url)!=null?Tt:"",row:Je,column:Qe}}n(Y.id);const bt=U.findCustomHyperLink(Y);if(bt){const H=bt.convert(Y);h(H.type),p(H.payload),J(H.display);return}J(Y.display);const Q=D.parseHyperLink(Y.payload);switch(h(Q.type===_.SheetHyperLinkType.INVALID?_.SheetHyperLinkType.RANGE:Q.type),Q.type){case _.SheetHyperLinkType.URL:{p(Q.url),Q.url===Y.display&&(j.current=!0);break}case _.SheetHyperLinkType.RANGE:{const H=Q.searchObj,ee=H.gid&&(Dt=(wt=(Lt=w.getUnit(c.unitId))==null?void 0:Lt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Dt:"",$=G.serializeRangeWithSheet(ee,G.deserializeRangeWithSheet(H.range).range);p($),$===Y.display&&(j.current=!0);break}case _.SheetHyperLinkType.SHEET:{const H=Q.searchObj;p(H.gid);break}case _.SheetHyperLinkType.DEFINE_NAME:{const H=Q.searchObj;p(H.rangeid);break}default:p("");break}}},[c,A,U,xe,w]),R.useEffect(()=>{let v=null;if(c&&!c.customRangeId&&c.type===C.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=w.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),k=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=k==null?void 0:k.getMergedCell(c.row,c.col),x=new s.ColorKit(Ie.getColorFromTheme("primary.600")).toRgb();v=re.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{v&&re.removeShape(v)}},[c,re,Ie,w]),R.useEffect(()=>{It(l===_.SheetHyperLinkType.RANGE)},[l]),R.useEffect(()=>{const v=(c==null?void 0:c.type)===C.ZEN_EDITOR?z.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):z.getRenderById(P.getCurrentEditorId()),b=new s.DisposableCollection;if(v){const k=v.with(X.DocSelectionRenderService);k.setReserveRangesStatus(!0),b.add(()=>{k.setReserveRangesStatus(!1)})}return()=>{P.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,P,z]),R.useEffect(()=>(me&&T.setIsKeepVisible(me),T.setIsKeepVisible(_e),()=>{T.setIsKeepVisible(!1)}),[me,_e,T]),R.useEffect(()=>()=>{B.temporaryHidden&&(B.show(),se.setContextValue(s.FOCUSING_SHEET,!1))},[se,B]),R.useEffect(()=>{if(me)return P.enableForceKeepVisible(),()=>{P.disableForceKeepVisible()}},[me,P]);const Ln=[{label:S.t("hyperLink.form.link"),value:_.SheetHyperLinkType.URL},{label:S.t("hyperLink.form.range"),value:_.SheetHyperLinkType.RANGE},{label:S.t("hyperLink.form.worksheet"),value:_.SheetHyperLinkType.SHEET},{label:S.t("hyperLink.form.definedName"),value:_.SheetHyperLinkType.DEFINE_NAME},...V];if(!K)return;const wn=K.getHiddenWorksheets(),ze=K.getSheets().map(v=>({label:v.getName(),value:v.getSheetId()})).filter(v=>wn.indexOf(v.value)===-1),qe=Object.values((_t=I.getDefinedNameMap(K.getUnitId()))!=null?_t:{}).map(v=>({label:v.name,value:v.id})),St=(v,b)=>{if(v===_.SheetHyperLinkType.URL)return Ht(b);if(v===_.SheetHyperLinkType.RANGE){const k=G.deserializeRangeWithSheet(b),N=K.getSheetBySheetName(k.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${G.serializeRange(k.range)}`}return`#${v}=${b}`},Dn=m.useEvent(v=>{var x;const k=v.split(",").map(G.deserializeRangeWithSheet)[0];if(!k||!s.isValidRange(k.range))return;k.sheetName||(k.sheetName=((x=K.getActiveSheet())==null?void 0:x.getName())||"");const N=G.serializeRangeToRefString(k);p(N),N&&(j.current||!r)&&(J(N),j.current=!0)}),Xe=async()=>{if(a&&!r||!d||l===_.SheetHyperLinkType.URL&&!ye(d)){Pn(!0);return}if(c)if(t){const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.UpdateRichHyperLinkCommand.id:_.UpdateHyperLinkCommand.id;await M.executeCommand(v,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:a?r:"",payload:St(l,d)},row:c.row,column:c.col,documentId:c.type===C.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}else{const v=c.type===C.ZEN_EDITOR||c.type===C.EDITING?_.AddRichHyperLinkCommand.id:_.AddHyperLinkCommand.id;await M.executeCommand(v,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:St(l,d),display:a?r:""},documentId:c.type===C.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:P.getCurrentEditorId()})}if((c==null?void 0:c.type)===C.VIEWING){await M.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const v=1;await M.executeCommand(E.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-v,0),endRow:c.row+v,startColumn:Math.max(c.col-v,0),endColumn:c.col+v}})}M.executeCommand(ve.id)};return c?y.jsxs("div",{className: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:[a?y.jsx(L.FormLayout,{label:S.t("hyperLink.form.label"),error:ue&&!r?S.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:r,onChange:v=>{J(v),j.current=!1},placeholder:S.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Xe()}})}):null,y.jsx(L.FormLayout,{label:S.t("hyperLink.form.type"),children:y.jsx(L.Select,{className:"univer-w-full",options:Ln,value:l,onChange:v=>{h(v),p("")}})}),l===_.SheetHyperLinkType.URL&&y.jsx(L.FormLayout,{error:ue?d?ye(d)?"":S.t("hyperLink.form.linkError"):S.t("hyperLink.form.inputError"):"",children:y.jsx(L.Input,{value:d,onChange:v=>{p(v),v&&(j.current||!r||r===v)&&(J(v),j.current=!0)},placeholder:S.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:v=>{v.keyCode===m.KeyCode.ENTER&&Xe()}})}),l===_.SheetHyperLinkType.RANGE&&y.jsx(L.FormLayout,{error:ue&&!d?S.t("hyperLink.form.inputError"):"",children:y.jsx(Nt.RangeSelector,{unitId:K.getUnitId(),subUnitId:Tn,maxRangeCount:1,supportAcrossSheet:!0,initialValue:d,resetRange:Rn,onChange:(v,b)=>Dn(b),onRangeSelectorDialogVisibleChange:async v=>{var b,k;if(Ae(v),v)c.type===C.ZEN_EDITOR&&(B.hide(),se.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==C.VIEWING&&P.enableForceKeepVisible(),i(!0);else{if(await A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===C.ZEN_EDITOR){await M.executeCommand(f.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),B.show(),se.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=z.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(X.DocBackScrollRenderController),x=(k=Se.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:k[0];N&&x&&(N.scrollToRange(x),Se.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}P.disableForceKeepVisible(),i(!1)}},onFocusChange:v=>It(v)})}),l===_.SheetHyperLinkType.SHEET&&y.jsx(L.FormLayout,{error:ue&&!d?S.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:ze,value:d,onChange:v=>{var N,x;p(v);const b=(N=ze.find(W=>W.value===v))==null?void 0:N.label,k=(x=ze.find(W=>W.value===d))==null?void 0:x.label;b&&(j.current||!r||r===k)&&(J(b),j.current=!0)}})}),l===_.SheetHyperLinkType.DEFINE_NAME&&y.jsx(L.FormLayout,{error:ue&&!d?S.t("hyperLink.form.selectError"):"",children:y.jsx(L.Select,{className:"univer-w-full",options:qe,value:d,onChange:v=>{var N,x;p(v);const b=(N=qe.find(W=>W.value===v))==null?void 0:N.label,k=(x=qe.find(W=>W.value===d))==null?void 0:x.label;b&&(j.current||!r||r===k)&&(J(b),j.current=!0)}})}),($e==null?void 0:$e.Form)&&y.jsx($e.Form,{linkId:t,payload:d,display:r,showError:ue,setByPayload:j,setDisplay:v=>{J(v),j.current=!0},setPayload:p}),y.jsxs("div",{className:"univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[y.jsx(L.Button,{onClick:()=>{c&&A.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),M.executeCommand(ve.id)},children:S.t("hyperLink.form.cancel")}),y.jsx(L.Button,{variant:"primary",onClick:async()=>{Xe()},children:S.t("hyperLink.form.ok")})]})]}):null};Ce.componentKey="univer.sheet.cell-link-edit";function te({ref:t,...n}){const{icon:e,id:i,className:r,extend:o,...a}=n,u=`univerjs-icon univerjs-icon-${i} ${r||""}`.trim(),l=R.useRef(`_${jt()}`);return it(e,`${i}`,{defIds:e.defIds,idSuffix:l.current},{ref:t,className:u,...a},o)}function it(t,n,e,i,r){return R.createElement(t.tag,{key:n,...Bt(t,e,r),...i},(Vt(t,e).children||[]).map((o,a)=>it(o,`${n}-${t.tag}-${a}`,e,void 0,r)))}function Bt(t,n,e){const i={...t.attrs};e!=null&&e.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=e.colorChannel1),t.tag==="mask"&&i.id&&(i.id=i.id+n.idSuffix),Object.entries(i).forEach(([o,a])=>{o==="mask"&&typeof a=="string"&&(i[o]=a.replace(/url\(#(.*)\)/,`url(#$1${n.idSuffix})`))});const{defIds:r}=n;return!r||r.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(([o,a])=>{typeof a=="string"&&(i[o]=a.replace(/url\(#(.*)\)/,`url(#$1${n.idSuffix})`))})),i}function Vt(t,n){var i;const{defIds:e}=n;return!e||e.length===0?t:t.tag==="defs"&&((i=t.children)!=null&&i.length)?{...t,children:t.children.map(r=>typeof r.attrs.id=="string"&&e&&e.includes(r.attrs.id)?{...r,attrs:{...r.attrs,id:r.attrs.id+n.idSuffix}}:r)}:t}function jt(){return Math.random().toString(36).substring(2,8)}te.displayName="UniverIcon";const Zt={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"}}]},Ee=R.forwardRef(function(n,e){return R.createElement(te,Object.assign({},n,{id:"all-border-icon",ref:e,icon:Zt}))});Ee.displayName="AllBorderIcon";const Ft={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"}}]},rt=R.forwardRef(function(n,e){return R.createElement(te,Object.assign({},n,{id:"copy-icon",ref:e,icon:Ft}))});rt.displayName="CopyIcon";const Kt={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"}}]},Ve=R.forwardRef(function(n,e){return R.createElement(te,Object.assign({},n,{id:"link-icon",ref:e,icon:Kt}))});Ve.displayName="LinkIcon";const Wt={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"}}]},st=R.forwardRef(function(n,e){return R.createElement(te,Object.assign({},n,{id:"unlink-icon",ref:e,icon:Wt}))});st.displayName="UnlinkIcon";const Yt={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"}}]},ot=R.forwardRef(function(n,e){return R.createElement(te,Object.assign({},n,{id:"write-icon",ref:e,icon:Yt}))});ot.displayName="WriteIcon";const Gt={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"}}]},at=R.forwardRef(function(n,e){return R.createElement(te,Object.assign({},n,{id:"xlsx-multi-icon",ref:e,icon:Gt}))});at.displayName="XlsxMultiIcon";const zt={[_.SheetHyperLinkType.URL]:y.jsx(Ve,{}),[_.SheetHyperLinkType.SHEET]:y.jsx(at,{className:"univer-text-green-500"}),[_.SheetHyperLinkType.RANGE]:y.jsx(Ee,{}),[_.SheetHyperLinkType.DEFINE_NAME]:y.jsx(Ee,{}),[_.SheetHyperLinkType.INVALID]:y.jsx(Ee,{})},ct=t=>{var A,M;const n=m.useDependency(g.SheetsHyperLinkPopupService),e=m.useDependency(s.ICommandService),i=m.useDependency(m.IMessageService),r=m.useDependency(s.LocaleService),o=m.useDependency(g.SheetsHyperLinkResolverService),a=m.useDependency(E.IEditorBridgeService),u=m.useDependency(_.SheetsHyperLinkParserService),l=m.useDependency(m.IZenZoneService),{customRange:h,row:d,col:p,unitId:S,subUnitId:I,editPermission:P,copyPermission:w,type:T}=t;if(!((A=h==null?void 0:h.properties)!=null&&A.url))return null;const c=u.parseHyperLink((M=h.properties.url)!=null?M:""),D=c.type===_.SheetHyperLinkType.INVALID;return y.jsxs("div",{className: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:()=>n.hideCurrentPopup(),children:[y.jsxs("div",{className: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":D}),onClick:()=>{l.visible||D||o.navigate(c)},children:[y.jsx("div",{className:"univer-mr-2 univer-flex univer-h-5 univer-w-5 univer-flex-none univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",children:zt[c.type]}),y.jsx(L.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:y.jsx("span",{className:"univer-flex-1 univer-overflow-hidden univer-text-ellipsis",children:c.name})})]}),y.jsxs("div",{className:"univer-flex univer-h-6 univer-flex-none univer-flex-row univer-items-center univer-justify-center",children:[w&&y.jsx("div",{className: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":D}),onClick:()=>{if(!D){if(c.type!==_.SheetHyperLinkType.URL){const U=new URL(window.location.href);U.hash=c.url.slice(1),navigator.clipboard.writeText(U.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:L.MessageType.Info})}},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:y.jsx(rt,{className:"dark:!univer-text-white"})})}),P&&y.jsxs(y.Fragment,{children:[y.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:()=>{e.executeCommand(Pe.id,{unitId:S,subUnitId:I,row:d,col:p,customRangeId:h.rangeId,type:T})},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:y.jsx(ot,{className:"dark:!univer-text-white"})})}),y.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:()=>{const U=T===C.EDITING||T===C.ZEN_EDITOR?_.CancelRichHyperLinkCommand.id:_.CancelHyperLinkCommand.id;e.syncExecuteCommand(U,{unitId:S,subUnitId:I,id:h.rangeId,row:d,column:p,documentId:T===C.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:a.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:y.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:y.jsx(st,{className:"dark:!univer-text-white"})})})]})]})]})},Re=()=>{var r,o;const t=m.useDependency(g.SheetsHyperLinkPopupService),[n,e]=R.useState(null),i=m.useDependency(s.IUniverInstanceService);if(R.useEffect(()=>{e(t.currentPopup);const a=t.currentPopup$.subscribe(u=>{e(u)});return()=>{a.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!n)return null;if(n.showAll){const a=i.getUnit(n.unitId,s.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(n.subUnitId),l=u==null?void 0:u.getCell(n.row,n.col),h=(o=(r=l==null?void 0:l.p)==null?void 0:r.body)==null?void 0:o.customRanges;return h!=null&&h.length?y.jsx("div",{children:h.map(d=>y.jsx(ct,{...n,customRange:d},d.rangeId))}):null}return y.jsx(ct,{...n})};Re.componentKey="univer.sheet.cell-link-popup";var qt=Object.getOwnPropertyDescriptor,Xt=(t,n,e,i)=>{for(var r=i>1?void 0:i?qt(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},ne=(t,n)=>(e,i)=>n(e,i,t);const ut=(t,n)=>{var e,i;return t.unitId===n.unitId&&t.subUnitId===n.subUnitId&&t.row===n.row&&t.col===n.col&&((e=t.customRange)==null?void 0:e.rangeId)===((i=n.customRange)==null?void 0:i.rangeId)&&t.type===n.type};g.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,i,r,o,a,u,l){super();Z(this,"_currentPopup",null);Z(this,"_currentPopup$",new O.Subject);Z(this,"currentPopup$",this._currentPopup$.asObservable());Z(this,"_currentEditingPopup",null);Z(this,"_currentEditing$",new O.BehaviorSubject(null));Z(this,"currentEditing$",this._currentEditing$.asObservable());Z(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=o,this._textSelectionManagerService=a,this._docCanvasPopManagerService=u,this._zenZoneService=l,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){var S;if(this._currentPopup&&ut(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==C.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&&ut(e,i))return;const{unitId:r,subUnitId:o,row:a,col:u,customRangeRect:l,customRange:h}=e;let d;const p={componentKey:Re.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===C.EDITING){if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(l,p)}else if(e.type===C.ZEN_EDITOR){if(!h)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:h.startIndex,endOffset:h.endIndex+1,collapsed:!1},p,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,p,r,o);else{if(!h)return;d=l&&this._sheetCanvasPopManagerService.attachPopupByPosition(l,p,e)}d&&(this._currentPopup&&((S=this._currentPopup.disposable)==null||S.dispose()),this._currentPopup={unitId:r,subUnitId:o,disposable:d,row:a,col:u,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:h,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,i){var r,o;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((o=(r=this._currentPopup)==null?void 0:r.disposable)==null||o.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}dispose(){super.dispose(),this.hideCurrentPopup(),this.endEditing(),this._currentPopup$.complete(),this._currentEditing$.complete()}_getEditingRange(){var r,o,a;const e=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(e&&i){const u=this._textSelectionManagerService.getActiveTextRange(),l=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!l)return null;if(!u||u.collapsed)return{startOffset:0,endOffset:l.dataStream.length-2,collapsed:l.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(l.dataStream)};const h=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(u,(a=(o=l.customRanges)==null?void 0:o.filter(S=>S.rangeType===s.CustomRangeType.HYPERLINK))!=null?a:[]);let d=u.startOffset,p=u.endOffset;return h.forEach(S=>{d=Math.min(d,S.startIndex),p=Math.max(p,S.endIndex+1)}),{startOffset:d,endOffset:p,collapsed:d===p,label:s.BuildTextUtils.transform.getPlainText(l.dataStream.slice(d,p))}}return null}get _editPopup(){return{componentKey:Ce.componentKey,direction:"vertical",onClickOutside:()=>{this.endEditing()},onContextMenu:()=>{this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var a,u,l,h,d;const{unitId:i,subUnitId:r,type:o}=e;if(o===C.ZEN_EDITOR){const p=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!p)return;const S=this._textSelectionManagerService.getActiveTextRange();if(!S)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(S,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const I=(a=p.getBody())==null?void 0:a.dataStream.slice(S.startOffset,S.endOffset);this._currentEditing$.next({...e,label:I})}else if(o===C.EDITING){const p=this._getEditingRange();if(!p)return;this._textSelectionManagerService.replaceDocRanges([{...p}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const S=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!S)return;const I=X.calcDocRangePositions(p,S);if(!(I!=null&&I.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(I.pop(),this._editPopup,i,r),this._currentEditing$.next({...e,label:(u=p==null?void 0:p.label)!=null?u:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,r);const p=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),S=p==null?void 0:p.getSheetBySheetId(r),I=S==null?void 0:S.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:I!=null&&I.p?s.BuildTextUtils.transform.getPlainText((h=(l=I.p.body)==null?void 0:l.dataStream)!=null?h:""):((d=I==null?void 0:I.v)!=null?d:"").toString()})}}startEditing(e){var u,l,h,d,p,S;(u=this._currentEditingPopup)==null||u.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=e;let o,a;if(e.type===C.ZEN_EDITOR){const I=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(o=(h=(l=I==null?void 0:I.getBody())==null?void 0:l.customRanges)==null?void 0:h.find(P=>P.rangeId===e.customRangeId),a=o?(d=I==null?void 0:I.getBody())==null?void 0:d.dataStream.slice(o.startIndex,o.endIndex+1):"",!o||!a)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,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===C.EDITING){const I=E.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!I||!((p=I.rects)!=null&&p.length))return;o=I.customRange,a=I.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:o.startIndex,endOffset:o.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(I.rects.pop(),this._editPopup,i,r)}else{const I=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),P=I==null?void 0:I.getSheetBySheetId(r),w=P==null?void 0:P.getCellRaw(e.row,e.col),T=I==null?void 0:I.getStyles().getStyleByCell(w),c=T==null?void 0:T.tr,D=E.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!D||!((S=D.rects)!=null&&S.length))return;o=D.customRange,a=D.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(D.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:o,label:a})}endEditing(e){var r;if(this.getIsKeepVisible())return;const i=this._currentEditing$.getValue();i&&(!e||e===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=Xt([ne(0,s.Inject(E.SheetCanvasPopManagerService)),ne(1,s.Inject(s.Injector)),ne(2,s.IUniverInstanceService),ne(3,E.IEditorBridgeService),ne(4,s.Inject(de.DocSelectionManagerService)),ne(5,s.Inject(X.DocCanvasPopManagerService)),ne(6,m.IZenZoneService)],g.SheetsHyperLinkPopupService);var he=(t=>(t[t.ALLOWED=0]="ALLOWED",t[t.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",t[t.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",t))(he||{});const Jt=new Set([s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE]),je=(t,n,e,i)=>{var u,l,h,d,p;const r=n.getCell(e,i);if(r!=null&&r.f||r!=null&&r.si||(h=(l=(u=r==null?void 0:r.p)==null?void 0:u.body)==null?void 0:l.customBlocks)!=null&&h.length)return 1;const o=t.has(et.SheetDataValidationModel)?t.get(et.SheetDataValidationModel):null,a=o==null?void 0:o.getRuleByLocation(n.getUnitId(),n.getSheetId(),e,i);return a&&Jt.has(a.type)?!0:(p=(d=r==null?void 0:r.p)==null?void 0:d.drawingsOrder)!=null&&p.length?2:0},Qt=t=>{const n=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const e=n.getActiveSheet(),i=t.get(f.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,o=i[0].range.startColumn;return je(t,e,r,o)===1},en=t=>{const n=t.get(de.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(a=>a.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},Pe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,n){if(!n)return!1;const e=t.get(g.SheetsHyperLinkPopupService);return n.customRangeId?e.startEditing(n):e.startAddEditing(n),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},Te={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var p;const n=t.get(s.IUniverInstanceService),e=f.getSheetCommandTarget(n),i=t.get(E.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),a=t.get(f.SheetsSelectionsService).getCurrentLastSelection();if(!a)return!1;const u=a.range.startRow,l=a.range.startColumn,h=i.isVisible(),d=((p=n.getFocusedUnit())==null?void 0:p.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Pe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:u,col:l,type:d?C.ZEN_EDITOR:h.visible?C.EDITING:C.VIEWING})}},ie={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Qt(t))return!1;const n=t.get(s.ICommandService);return t.get(g.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ve.id):n.executeCommand(Te.id)}},Ze="SHEET_HYPER_LINK_UI_PLUGIN";var tn=Object.getOwnPropertyDescriptor,nn=(t,n,e,i)=>{for(var r=i>1?void 0:i?tn(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},Le=(t,n)=>(e,i)=>n(e,i,t);g.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,i,r,o){super();Z(this,"_plainTextFilter",new Set);Z(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=i,this._injector=r,this._resolverService=o,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(i=>i(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ze,onBeforeCopy:(e,i,r)=>this._collect(e,i,r),onPasteCells:(e,i,r,o)=>{const{copyType:a=E.COPY_TYPE.COPY,pasteType:u}=o,{range:l}=e||{},{range:h,unitId:d,subUnitId:p}=i;return this._generateMutations(h,{copyType:a,pasteType:u,copyRange:l,unitId:d,subUnitId:p})},onPastePlainText:(e,i)=>{const r=this._filterPlainText(i);if(ye(i)&&r){const{range:o,unitId:a,subUnitId:u}=e,{ranges:[l],mapFunc:h}=E.virtualizeDiscreteRanges([o]),d=[],p=[];return s.Range.foreach(l,(S,I)=>{const{row:P,col:w}=h(S,I),T=this._hyperLinkModel.getHyperLinkByLocation(a,u,P,w);T&&d.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:u,id:T.id}}),T&&p.push({id:_.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:u,link:T}})}),{redos:d,undos:p}}return{undos:[],redos:[]}},priority:99})}_collect(e,i,r){const o=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:i,matrix:o};const a=this._injector.invoke(h=>f.rangeToDiscreteRange(r,h,e,i));if(!a)return;const{rows:u,cols:l}=a;u.forEach((h,d)=>{l.forEach((p,S)=>{var P;const I=this._hyperLinkModel.getHyperLinkByLocation(e,i,h,p);o.setValue(d,S,(P=I==null?void 0:I.id)!=null?P:"")})})}_generateMutations(e,i){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!i.copyRange)return{redos:[],undos:[]};if([E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(i.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:a}=this._copyInfo,u=[],l=[],{ranges:[h,d],mapFunc:p}=E.virtualizeDiscreteRanges([i.copyRange,e]);return E.getRepeatRange(h,d,!0).forEach(({startRange:I})=>{var P;(P=this._copyInfo)==null||P.matrix.forValue((w,T,c)=>{const D=s.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:T,endColumn:T},I),A=this._hyperLinkModel.getHyperLink(o,a,c),{row:M,col:U}=p(D.startRow,D.startColumn),V=this._hyperLinkModel.getHyperLinkByLocation(i.unitId,i.subUnitId,M,U),B=s.generateRandomId();V&&u.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:V.id}}),A&&(u.push({id:_.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:{...A,id:B,row:M,column:U}}}),l.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:B}})),V&&l.push({id:_.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:V}})})}),{redos:u,undos:l}}},g.SheetsHyperLinkCopyPasteController=nn([Le(0,E.ISheetClipboardService),Le(1,s.Inject(_.HyperLinkModel)),Le(2,s.Inject(s.Injector)),Le(3,s.Inject(g.SheetsHyperLinkResolverService))],g.SheetsHyperLinkCopyPasteController);const Fe=(t,n=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),i=(r=t.get(pe.IRenderManagerService).getRenderById(n))==null?void 0:r.with(X.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(O.map(()=>{const a=t.get(E.IEditorBridgeService).getEditCellState();if(!a)return!0;const u=f.getSheetCommandTarget(e,{unitId:a.unitId,subUnitId:a.sheetId});return!(u!=null&&u.worksheet)||je(t,u.worksheet,a.row,a.column)===1?!0:en(t)})):O.of(!0)},lt=t=>{var r;const n=t.get(s.IUniverInstanceService),e=t.has(E.IEditorBridgeService)?t.get(E.IEditorBridgeService):null;return((r=e==null?void 0:e.currentEditCellState$.pipe(O.map(o=>{if(!o)return he.DISABLED_BY_CELL;const a=f.getSheetCommandTarget(n,{unitId:o.unitId,subUnitId:o.sheetId});return a?je(t,a.worksheet,o.row,o.column):he.DISABLED_BY_CELL}),O.switchMap(o=>{if(o===he.DISABLED_BY_CELL)return O.of(!0);const a=e?e.visible$:O.of(null);return O.combineLatest([a,n.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_DOC)]).pipe(O.switchMap(([u,l])=>u!=null&&u.visible?(l==null?void 0:l.getUnitId())===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?O.of(!0):Fe(t,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY):O.of(o!==he.ALLOWED)))})))!=null?r:O.of(!0)).pipe(O.switchMap(o=>o?O.of(!0):E.getCurrentRangeDisable$(t,{workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},!0)))},we={commandId:Te.id,type:m.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkIcon"},De=t=>`${t}-zen-editor`,rn=t=>({...we,id:we.commandId,hidden$:m.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:lt(t)}),sn=t=>({...we,id:De(we.commandId),hidden$:m.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Fe(t)}),be={tooltip:"hyperLink.form.addTitle",commandId:ie.id,type:m.MenuItemType.BUTTON,icon:"LinkIcon"},on=t=>({...be,id:be.commandId,hidden$:m.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:lt(t)}),an=t=>({...be,id:De(be.commandId),hidden$:m.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Fe(t)}),Ke={id:ie.id,binding:m.KeyCode.K|m.MetaKeys.CTRL_COMMAND,preconditions:E.whenSheetEditorFocused};var cn=Object.getOwnPropertyDescriptor,un=(t,n,e,i)=>{for(var r=i>1?void 0:i?cn(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},dt=(t,n)=>(e,i)=>n(e,i,t);let ke=class extends s.Disposable{constructor(t,n){super(),this._autoFillService=t,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:o,target:a,unitId:u,subUnitId:l}=i,h=E.virtualizeDiscreteRanges([o,a]),[d,p]=h.ranges,{mapFunc:S}=h,I={row:d.startRow,col:d.startColumn},P=E.getAutoFillRepeatRange(d,p),w=[],T=[];return P.forEach(c=>{const D=c.repeatStartCell,A=c.relativeRange,M={startRow:I.row,startColumn:I.col,endColumn:I.col,endRow:I.row},U={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};s.Range.foreach(A,(V,B)=>{const z=s.Rectangle.getPositionRange({startRow:V,startColumn:B,endColumn:B,endRow:V},M),{row:re,col:xe}=S(z.startRow,z.startColumn),se=this._hyperLinkModel.getHyperLinkByLocation(u,l,re,xe),Ie=s.Rectangle.getPositionRange({startRow:V,startColumn:B,endColumn:B,endRow:V},U),{row:Se,col:_e}=S(Ie.startRow,Ie.startColumn),Ae=s.generateRandomId(),ce=this._hyperLinkModel.getHyperLinkByLocation(u,l,Se,_e);ce&&w.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:ce.id}}),(E.APPLY_TYPE.COPY===r||E.APPLY_TYPE.SERIES===r)&&se&&(w.push({id:_.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:{...se,id:Ae,row:Se,column:_e}}}),T.push({id:_.RemoveHyperLinkMutation.id,params:{unitId:u,subUnitId:l,id:Ae}})),ce&&T.push({id:_.AddHyperLinkMutation.id,params:{unitId:u,subUnitId:l,link:ce}})})}),{undos:T,redos:w}},e={id:Ze,onFillData:(i,r,o)=>o===E.APPLY_TYPE.COPY||o===E.APPLY_TYPE.ONLY_FORMAT||o===E.APPLY_TYPE.SERIES?n(i,o):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};ke=un([dt(0,E.IAutoFillService),dt(1,s.Inject(_.HyperLinkModel))],ke);var ln=Object.getOwnPropertyDescriptor,dn=(t,n,e,i)=>{for(var r=i>1?void 0:i?ln(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},We=(t,n)=>(e,i)=>n(e,i,t);let Oe=class extends s.Disposable{constructor(t,n,e){super(),this._localeService=t,this._commandService=n,this._sheetPermissionCheckController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===Ke.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],rangeTypes:[f.RangeProtectionPermissionEditPoint],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetSetCellValuePermission,f.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Oe=dn([We(0,s.Inject(s.LocaleService)),We(1,s.ICommandService),We(2,s.Inject(f.SheetPermissionCheckController))],Oe);var pn=Object.getOwnPropertyDescriptor,hn=(t,n,e,i)=>{for(var r=i>1?void 0:i?pn(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},F=(t,n)=>(e,i)=>n(e,i,t);let Ne=class extends s.Disposable{constructor(t,n,e,i,r,o,a,u,l,h){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=n,this._renderManagerService=e,this._permissionService=i,this._sheetPermissionCheckController=r,this._commandService=o,this._editorBridgeService=a,this._textSelectionManagerService=u,this._univerInstanceService=l,this._zenZoneService=h,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:n,subUnitId:e,row:i,col:r}=t,o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),a=o==null?void 0:o.getSheetBySheetId(e);if(!a)return{viewPermission:!1,editPermission:!1,copyPermission:!1};const u=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookViewPermission],worksheetTypes:[f.WorksheetViewPermission],rangeTypes:[f.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]);let l=this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[f.WorkbookEditablePermission],worksheetTypes:[f.WorksheetEditPermission,f.WorksheetInsertHyperlinkPermission],rangeTypes:[f.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]);const h=a.getCellRaw(i,r);h!=null&&h.f&&h.f.startsWith("=HYPERLINK(")&&(l=!1);const d=this._permissionService.composePermission([new f.WorkbookCopyPermission(n).id,new f.WorksheetCopyPermission(n,e).id]).every(p=>p.value);return{viewPermission:u,editPermission:l,copyPermission:d}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(O.debounceTime(200)).subscribe(t=>{var M,U,V;if(!t||((M=t.customRange)==null?void 0:M.rangeType)!==s.CustomRangeType.HYPERLINK){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:e,row:i,col:r}=t,o=this._renderManagerService.getRenderById(n);if(!o)return;const a=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),u=a==null?void 0:a.getSheetBySheetId(e);if(!u)return;if(!o.with(E.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING);return}const h=(U=o==null?void 0:o.with(E.SheetSkeletonManagerService).getSkeletonParam(e))==null?void 0:U.skeleton,d=r,p=i;let S=p,I=d;h&&h.overflowCache.forValue((B,z,re)=>{s.Rectangle.contains(re,{startColumn:d,endColumn:d,startRow:p,endRow:p})&&(S=B,I=z)});const{viewPermission:P,editPermission:w,copyPermission:T}=this._getLinkPermission(t);if(!P){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=u.getCellStyleOnly(S,I),D=a.getStyles().getStyleByCell(c),A=(V=D==null?void 0:D.tr)==null?void 0:V.a;if(!A&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:S,col:I,editPermission:w,copyPermission:T,customRange:t.customRange,customRangeRect:t.rect,type:C.VIEWING,unitId:n,subUnitId:e,showAll:!!A})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(O.switchMap(n=>this._editorBridgeService.visible$.pipe(O.map(e=>({visible:e,state:n}))))).subscribe(({visible:n,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:o,row:a,column:u}=e,l=this._renderManagerService.getRenderById(i);if(!l)return;const{editPermission:h,viewPermission:d,copyPermission:p}=this._getLinkPermission({unitId:r,subUnitId:o,row:a,col:u}),S=l.with(X.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=S.hoverCustomRanges$.pipe(O.debounceTime(200)).subscribe(I=>{var D,A;const P=I.find(M=>M.range.rangeType===s.CustomRangeType.HYPERLINK);if(!P){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const w=P.rects[P.rects.length-1];if(!((A=(D=this._renderManagerService.getRenderById(r))==null?void 0:D.with(E.SheetSkeletonManagerService).getSkeletonParam(o))==null?void 0:A.skeleton)||!w)return;const c=l.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:o,row:a,col:u,customRange:P.range,customRangeRect:{left:w.left+c.left,top:w.top+c.top,bottom:w.bottom+c.top,right:w.right+c.left},editPermission:h,copyPermission:p,type:C.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.EDITING),this._sheetsHyperLinkPopupService.endEditing(C.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(C.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(C.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(O.switchMap(t=>{const n=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return n?n.with(X.DocEventManagerService).hoverCustomRanges$.pipe(O.debounceTime(200)):new O.Observable(e=>{e.next(null)})})).subscribe(t=>{const n=t==null?void 0:t.find(i=>i.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(n&&e){const{unitId:i,sheetId:r,row:o,column:a}=e,{editPermission:u,viewPermission:l,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:r,row:o,col:a});l&&this._sheetsHyperLinkPopupService.showPopup({type:C.ZEN_EDITOR,unitId:i,subUnitId:r,row:o,col:a,customRange:n.range,editPermission:u,copyPermission:h})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(C.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(C.EDITING)}))}_initCommandListener(){const t=[f.ClearSelectionContentCommand.id,f.ClearSelectionAllCommand.id,f.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ne=hn([F(0,s.Inject(E.HoverManagerService)),F(1,s.Inject(g.SheetsHyperLinkPopupService)),F(2,s.Inject(pe.IRenderManagerService)),F(3,s.Inject(s.IPermissionService)),F(4,s.Inject(f.SheetPermissionCheckController)),F(5,s.ICommandService),F(6,E.IEditorBridgeService),F(7,s.Inject(de.DocSelectionManagerService)),F(8,s.IUniverInstanceService),F(9,m.IZenZoneService)],Ne);var vn=Object.getOwnPropertyDescriptor,pt=(t,n,e,i)=>{for(var r=i>1?void 0:i?vn(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},Ye=(t,n)=>(e,i)=>n(e,i,t);let Ge=class extends s.Disposable{constructor(t,n){super(),this._context=t,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(O.debounceTime(16)).subscribe(()=>{t()}))}};Ge=pt([Ye(1,s.Inject(_.HyperLinkModel))],Ge);let Me=class extends s.Disposable{constructor(t,n){super(),this._sheetInterceptorService=t,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(f.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,n,e)=>{const{row:i,col:r,unitId:o,subUnitId:a}=n,u=this._hyperLinkModel.getHyperLinkByLocation(o,a,i,r);return u&&t&&(t===n.rawData&&(t={...n.rawData}),t.linkUrl=u.payload,t.linkId=u.id),e(t)}}))}};Me=pt([Ye(0,s.Inject(f.SheetInterceptorService)),Ye(1,s.Inject(_.HyperLinkModel))],Me);const gn={[m.RibbonInsertGroup.MEDIA]:{[ie.id]:{order:1,menuItemFactory:on},[De(ie.id)]:{order:1,menuItemFactory:an}},[m.ContextMenuPosition.MAIN_AREA]:{[m.ContextMenuGroup.OTHERS]:{order:1,[ie.id]:{order:0,menuItemFactory:rn},[De(ie.id)]:{order:0,menuItemFactory:sn}}}};var In=Object.getOwnPropertyDescriptor,Sn=(t,n,e,i)=>{for(var r=i>1?void 0:i?In(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},ge=(t,n)=>(e,i)=>n(e,i,t);let Ue=class extends s.Disposable{constructor(t,n,e,i,r){super(),this._componentManager=t,this._commandService=n,this._menuManagerService=e,this._injector=i,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Re.componentKey,Re],[Ce.componentKey,Ce],["LinkIcon",Ve]].forEach(([t,n])=>{this._componentManager.register(t,n)})}_initCommands(){[Pe,ve,Te,ie].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(gn)}_initShortCut(){this._shortcutService.registerShortcut(Ke)}};Ue=Sn([ge(0,s.Inject(m.ComponentManager)),ge(1,s.ICommandService),ge(2,m.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(m.IShortcutService))],Ue);var _n=Object.getOwnPropertyDescriptor,mn=(t,n,e,i)=>{for(var r=i>1?void 0:i?_n(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},ht=(t,n)=>(e,i)=>n(e,i,t);let He=class extends s.Disposable{constructor(t,n){super(),this._parserService=t,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const n=this._parserService.parseHyperLink(t);this._resolverService.navigate(n)}}};He=mn([ht(0,s.Inject(_.SheetsHyperLinkParserService)),ht(1,s.Inject(g.SheetsHyperLinkResolverService))],He);var fn=Object.defineProperty,yn=Object.getOwnPropertyDescriptor,Cn=(t,n,e)=>n in t?fn(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,En=(t,n,e,i)=>{for(var r=i>1?void 0:i?yn(n,e):n,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},vt=(t,n)=>(e,i)=>n(e,i,t),gt=(t,n,e)=>Cn(t,typeof n!="symbol"?n+"":n,e);g.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(n=nt,e,i){super(),this._config=n,this._injector=e,this._configService=i;const{menu:r,...o}=s.merge({},nt,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,o)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[Be],[Me],[Ne],[Ue],[ke],[g.SheetsHyperLinkCopyPasteController],[Oe],[He]].forEach(e=>this._injector.add(e)),this._injector.get(Me)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[Ge]),this._injector.get(ke),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(Ue)}onRendered(){this._injector.get(Oe),this._injector.get(He),this._injector.get(Ne)}},gt(g.UniverSheetsHyperLinkUIPlugin,"pluginName",Ze),gt(g.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=En([s.DependentOn(_.UniverSheetsHyperLinkPlugin,X.UniverDocsUIPlugin),vt(1,s.Inject(s.Injector)),vt(2,s.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=ve,g.InsertHyperLinkOperation=Te,g.InsertLinkShortcut=Ke,g.OpenHyperLinkEditPanelOperation=Pe,g.SheetsHyperLinkSidePanelService=Be,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
// @univerjs/sheets-hyper-link-ui/facade
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-hyper-link",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.13",
|
|
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.10.
|
|
62
|
-
"@univerjs/sheets-hyper-link-ui": "0.10.
|
|
61
|
+
"@univerjs/sheets-hyper-link": "0.10.13",
|
|
62
|
+
"@univerjs/sheets-hyper-link-ui": "0.10.13"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@univerjs/core": "0.10.
|
|
65
|
+
"@univerjs/core": "0.10.13",
|
|
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.10.
|
|
70
|
+
"@univerjs-infra/shared": "0.10.13"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"prebuild:preset": "tsx prepare.ts",
|