@univerjs/preset-sheets-hyper-link 0.5.0-beta.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -1,16 +1,13 @@
1
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link
1
+ // @univerjs/sheets-hyper-link/index
2
+ (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,T,m,C,x){"use strict";var Qe=Object.defineProperty;var et=(p,o,T)=>o in p?Qe(p,o,{enumerable:!0,configurable:!0,writable:!0,value:T}):p[o]=T;var L=(p,o,T)=>et(p,typeof o!="symbol"?o+"":o,T);var Ie=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Me=(r,t,e,n)=>{for(var i=n>1?void 0:n?Re(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ie(t,e,i),i},Ce=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();L(this,"_linkUpdate$",new T.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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Me([Ce(0,o.IUniverInstanceService)],p.HyperLinkModel);var w=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(w||{});const Ue="sheets-hyper-link.config",Le={},k={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},E={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},z={type:o.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(r,t){var _,h,y;if(!t)return!1;const{unitId:e,subUnitId:n,row:i,col:s,id:a,url:d}=t,c=r.get(o.IUniverInstanceService),l=m.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,g=u.getCellRaw(i,s),f=(y=(h=(_=g==null?void 0:g.p)==null?void 0:_.body)==null?void 0:h.customRanges)==null?void 0:y.find(I=>I.rangeType===o.CustomRangeType.HYPERLINK&&I.rangeId===a);return f&&(f.properties.url=d),!0}},ae="SHEET_HYPER_LINK_PLUGIN",$="err";var we=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&we(t,e,i),i},K=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.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 a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return i?{redos:[{id:B.id,params:{unitId:t,subUnitId:e,id:n.id,row:i.startRow,column:i.startColumn,silent:s}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:E.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=C.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&C.serializeRange(h)===C.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:W.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`}}}],undos:[{id:W.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([K(0,o.Inject(m.RefRangeService)),K(1,o.Inject(p.HyperLinkModel)),K(2,o.Inject(m.SheetsSelectionsService)),K(3,o.ICommandService)],G);var be=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(r,t,e,n)=>{for(var i=n>1?void 0:n?Pe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&be(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};Y=Te([te(0,o.Inject(m.SheetInterceptorService)),te(1,o.IUniverInstanceService),te(2,o.Inject(p.HyperLinkModel))],Y);var He=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Oe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ne(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=C.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return{range:g,worksheet:u}}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,I=this._isLegalRangeUrl(t,y);if(I){const{range:v,worksheet:U}=I;f=!0,g.add(this._refRangeService.registerRefRange(v,S=>{const R=m.handleDefaultRangeChangeWithEffectRefCommands(v,S);return R&&o.Rectangle.equals(R,v)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:z.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:_.rangeId,url:`#gid=${e}&range=${R?C.serializeRange(R):$}`}}],undos:[{id:z.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:_.rangeId,url:y}}],redos:[]}},U.getUnitId(),U.getSheetId()))}}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.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===z.id){const e=t.params,{unitId:n,subUnitId:i,row:s,col:a}=e,d=m.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:i}),l=this._enusreMap(n,i).getValue(s,a);if(l&&l.dispose(),d){const{worksheet:u}=d,g=u.getCellRaw(s,a);g&&g.p&&this._registerRange(n,i,s,a,g.p)}}}))}};q=Oe([ne(0,o.ICommandService),ne(1,o.IUniverInstanceService),ne(2,o.Inject(m.RefRangeService))],q);var De=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,$e=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ve(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&De(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:E.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:E.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:k.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};J=$e([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],J);const oe={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:I,id:v}=f,U=g.getCell(y,I),S=g.getBlankCellDocumentModel(U),R=S.documentModel.getSnapshot(),M=o.Tools.deepClone(R.body);if(!M)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:M.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:M,ranges:[{startOffset:0,endOffset:M.dataStream.length-2,collapsed:!1}],rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(M,b.serialize()),P={p:{...R,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,I,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},re={id:m.SetRangeValuesMutation.id,params:O},Q=m.SetRangeValuesUndoMutationFactory(r,O),se={id:m.SetRangeValuesMutation.id,params:Q},A=[re],D=[se],V=s.getHyperLinkByLocation(c,l,y,I);return V&&(A.push({id:E.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:k.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},de={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const U=o.TextX.apply(y.body,v.serialize()),S=[],R=[],M={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:U},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:M});const b=m.SetRangeValuesUndoMutationFactory(r,M);R.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:E.id,params:{unitId:u,subUnitId:g,id:l}}),R.push({id:k.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:R,unitID:u}),!0):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var ye,ve,Se;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:I,display:v=""}=c,U=_.getCell(l,u);if(!U)return!1;const S=_.getCellDocumentModelWithFormula(U);if(!(S!=null&&S.documentModel))return!1;const R=S.documentModel.getSnapshot(),M=(ve=(ye=R.body)==null?void 0:ye.customRanges)==null?void 0:ve.find(Ze=>Ze.rangeId===g);if(!M)return!1;const b=o.generateRandomId(),H=(Se=o.getBodySlice(S.documentModel.getBody(),M.startIndex,M.endIndex+1).textRuns)==null?void 0:Se[0];H&&(H.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:I}}],textRuns:H?[H]:void 0},selection:{startOffset:M.startIndex,endOffset:M.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(R.body),P.textX.serialize()),O={p:{...R,body:N},t:o.CellValueType.STRING},re=await a.onWriteCell(f,_,l,u,O),Q={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:re}}}},se=m.SetRangeValuesUndoMutationFactory(r,Q.params),A={id:m.SetRangeValuesMutation.id,params:se},D=[Q],V=[A],ee=s.getHyperLinkByLocation(h,y,l,u);return ee&&(D.push({id:E.id,params:{unitId:h,subUnitId:y,id:ee.id}}),V.push({id:k.id,params:{unitId:h,subUnitId:y,link:ee}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},pe={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,I,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(U=>U.rangeId===i);if(!c)return!1;const l=(I=t.payload.display)!=null?I:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var je=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,xe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ae(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&je(t,e,i),i},We=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[oe,ue,ce,pe,le,de,k,W,E,B,z].forEach(r=>{this._commandService.registerCommand(r)})}};X=xe([We(0,o.ICommandService)],X);var ge=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(ge||{}),Be=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Ke=(r,t,e,n)=>{for(var i=n>1?void 0:n?ze(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},he=(r,t)=>(e,n)=>t(e,n,r);let Z=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:ae,businesses:[ge.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};Z=Ke([he(0,o.IResourceManagerService),he(1,o.Inject(p.HyperLinkModel))],Z);var Ge=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,qe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ye(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ie=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${w.SHEET}=${e}${n?`&${typeof n=="string"?w.DEFINE_NAME:w.RANGE}=${typeof n=="string"?n:C.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:w.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:w.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=C.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:w.RANGE,name:C.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:w.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:w.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=qe([ie(0,o.IUniverInstanceService),ie(1,o.Inject(o.LocaleService)),ie(2,C.IDefinedNamesService)],p.SheetsHyperLinkParserService);var me=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Je=(r,t,e)=>t in r?me(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&me(t,e,i),i},fe=(r,t)=>(e,n)=>t(e,n,r),_e=(r,t,e)=>Je(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Le,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ue,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[Z],[X],[G],[J],[Y],[q]]),o.touchDependencies(this._injector,[[G],[Z],[X],[J],[Y],[q]])}},_e(p.UniverSheetsHyperLinkPlugin,"pluginName",ae),_e(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Xe([o.DependentOn(m.UniverSheetsPlugin),fe(1,o.Inject(o.Injector)),fe(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=oe,p.AddHyperLinkMutation=k,p.AddRichHyperLinkCommand=de,p.CancelHyperLinkCommand=ce,p.CancelRichHyperLinkCommand=le,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=E,p.SheetHyperLinkType=w,p.UpdateHyperLinkCommand=ue,p.UpdateHyperLinkMutation=W,p.UpdateHyperLinkRefMutation=B,p.UpdateRichHyperLinkCommand=pe,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
2
3
 
3
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,H,m,M,x){"use strict";var Ze=Object.defineProperty;var Qe=(p,o,H)=>o in p?Ze(p,o,{enumerable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={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:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
4
-
5
-
6
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link/facade
7
4
 
5
+ // @univerjs/sheets-hyper-link/facade
8
6
  (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
9
7
 
10
8
 
11
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui
12
-
13
- (function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={exports:{}},Re={};/**
9
+ // @univerjs/sheets-hyper-link-ui/index
10
+ (function(v,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-data-validation")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui","@univerjs/sheets-data-validation"],o):(v=typeof globalThis<"u"?globalThis:v||self,o(v.UniverSheetsHyperLinkUi={},v.UniverCore,v.UniverSheetsHyperLink,v.UniverSheetsUi,v.UniverDesign,v.UniverEngineFormula,v.UniverSheets,v.UniverUi,v.UniverDocsUi,v.UniverEngineRender,v.rxjs,v.UniverDocs,v.React,v.UniverSheetsFormulaUi,v.UniverSheetsDataValidation))})(this,function(v,o,g,y,w,J,R,D,ee,pe,P,he,C,xt,tt){"use strict";var Xn=Object.defineProperty;var Jn=(v,o,g)=>o in v?Xn(v,o,{enumerable:!0,configurable:!0,writable:!0,value:g}):v[o]=g;var W=(v,o,g)=>Jn(v,typeof o!="symbol"?o+"":o,g);function Ce(t){return o.Tools.isLegalUrl(t)}function Bt(t){return/^[a-zA-Z]+:\/\//.test(t)}function At(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function Vt(t){if(Ce(t)){const n=Bt(t)?t:At(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 nt="sheets-hyper-link-ui.config",Ft={};var Zt=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,Wt=(t,n,e,i)=>{for(var r=i>1?void 0:i?Kt(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&Zt(n,e,r),r},ue=(t,n)=>(e,i)=>n(e,i,t);function Yt(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===o.RANGE_TYPE.COLUMN||o.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(s=>{o.Rectangle.intersects(t,s)&&a.push(s)}),o.Rectangle.realUnion(t,...a)}v.SheetsHyperLinkResolverService=class{constructor(n,e,i,r,a,s){this._univerInstanceService=n,this._commandService=e,this._definedNamesService=i,this._messageService=r,this._localeService=a,this._configService=s}navigate(n){switch(n.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(n.url);break;default:this._navigateToUniver(n.searchObj)}}_navigateToUniver(n){const{gid:e,range:i,rangeid:r}=n,a=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!a)return;const s=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(s,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(s,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(s,r)}if(e){if(i){const l=J.deserializeRangeWithSheet(i);o.isValidRange(l.range)&&i!==g.ERROR_RANGE&&this.navigateToRange(s,e,l.range);return}this.navigateToSheetById(s,e)}}async navigateToRange(n,e,i,r){const a=await this.navigateToSheetById(n,e);if(a){const s=Yt(i,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:n,subUnitId:e,selections:[{range:s}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:s,forceTop:r})}}async navigateToSheetById(n,e){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()===e)return r;const a=i.getSheetBySheetId(e);return a?i.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(n,e){return this._definedNamesService.focusRange(n,e),!0}async navigateToOtherWebsite(n){var i;const e=this._configService.getConfig(nt);if((i=e==null?void 0:e.urlHandler)!=null&&i.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(n);window.open(n,"_blank","noopener noreferrer")}},v.SheetsHyperLinkResolverService=Wt([ue(0,o.IUniverInstanceService),ue(1,o.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,o.Inject(o.LocaleService)),ue(5,o.IConfigService)],v.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Gt=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,zt=(t,n,e,i)=>{for(var r=i>1?void 0:i?$t(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&Gt(n,e,r),r},Ee=(t,n)=>(e,i)=>n(e,i,t);v.SheetsHyperLinkCopyPasteController=class extends o.Disposable{constructor(e,i,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=i,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(i=>i(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,i,r)=>this._collect(e,i,r),onPasteCells:(e,i,r,a)=>{const{copyType:s=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=i;return this._generateMutations(p,{copyType:s,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,i)=>{const r=this._filterPlainText(i);if(Ce(i)&&r){const{range:a,unitId:s,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return o.Range.foreach(u,(m,S)=>{const{row:E,col:T}=p(m,S),O=this._hyperLinkModel.getHyperLinkByLocation(s,l,E,T);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,i,r){const a=new o.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:i,matrix:a};const s=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,i));if(!s)return;const{rows:l,cols:u}=s;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const S=this._hyperLinkModel.getHyperLinkByLocation(e,i,p,h);a.setValue(d,m,(E=S==null?void 0:S.id)!=null?E:"")})})}_generateMutations(e,i){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!i.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(i.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,s=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([i.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((E,T,O)=>{const c=o.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:T,endColumn:T},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:x,col:U}=d(c.startRow,c.startColumn),N=this._hyperLinkModel.getHyperLinkByLocation(i.unitId,i.subUnitId,x,U),Z=o.Tools.generateRandomId();N&&s.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:N.id}}),k&&(s.push({id:g.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:{...k,id:Z,row:x,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,id:Z}})),N&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:i.unitId,subUnitId:i.subUnitId,link:N}})})}),{redos:s,undos:l}}},v.SheetsHyperLinkCopyPasteController=zt([Ee(0,y.ISheetClipboardService),Ee(1,o.Inject(g.HyperLinkModel)),Ee(2,o.Inject(o.Injector)),Ee(3,o.Inject(v.SheetsHyperLinkResolverService))],v.SheetsHyperLinkCopyPasteController);var f=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(f||{}),it={exports:{}},Re={};/**
14
11
  * @license React
15
12
  * react-jsx-runtime.production.min.js
16
13
  *
@@ -18,178 +15,12 @@
18
15
  *
19
16
  * This source code is licensed under the MIT license found in the
20
17
  * LICENSE file in the root directory of this source tree.
21
- */var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
18
+ */var Xt=C,Jt=Symbol.for("react.element"),Qt=Symbol.for("react.fragment"),qt=Object.prototype.hasOwnProperty,en=Xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,tn={key:!0,ref:!0,__self:!0,__source:!0};function rt(t,n,e){var i,r={},a=null,s=null;e!==void 0&&(a=""+e),n.key!==void 0&&(a=""+n.key),n.ref!==void 0&&(s=n.ref);for(i in n)qt.call(n,i)&&!tn.hasOwnProperty(i)&&(r[i]=n[i]);if(t&&t.defaultProps)for(i in n=t.defaultProps,n)r[i]===void 0&&(r[i]=n[i]);return{$$typeof:Jt,type:t,key:a,ref:s,props:r,_owner:en.current}}Re.Fragment=Qt,Re.jsx=rt,Re.jsxs=rt,it.exports=Re;var I=it.exports;class Ve extends o.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:i}=this;i.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const ot={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Et;const[t,n]=C.useState(""),[e,i]=C.useState(!1),[r,a]=C.useState(""),[s,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=o.useDependency(o.LocaleService),S=o.useDependency(J.IDefinedNamesService),E=o.useDependency(y.IEditorBridgeService),T=o.useDependency(o.IUniverInstanceService),O=o.useDependency(v.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=o.useDependency(g.SheetsHyperLinkParserService),x=o.useDependency(v.SheetsHyperLinkResolverService),U=o.useDependency(o.ICommandService),N=o.useDependency(Ve),Z=C.useMemo(()=>N.getOptions(),[N]),F=o.useDependency(D.IZenZoneService),Q=o.useDependency(pe.IRenderManagerService),Se=o.useDependency(y.IMarkSelectionService),Be=o.useDependency(he.DocSelectionManagerService),ae=o.useDependency(o.IContextService),_e=o.useDependency(o.ThemeService),me=o.useDependency(he.DocSelectionManagerService),Ie=C.useRef({}),ce=C.useMemo(()=>{if(!N.isBuiltInLinkType(u))return N.getCustomHyperLink(u)},[N,u]),[K,Kn]=C.useState(!1),[fe,ze]=C.useState(!1),A=C.useRef(!1),$=T.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),Wn=($==null?void 0:$.getActiveSheet().getSheetId())||"",te=C.useCallback(_=>{a(_.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,L,M,j,z,Rt,Pt,Tt,Lt,Ot,kt,bt,Dt,wt,Nt,Mt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:q}=c;typeof q=="number"&&(q=`${q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:q!=null?q:"",payload:(L=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?L:"",row:qe,column:et};else if(c.type===f.VIEWING){const H=T.getUnit(c.unitId),ie=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ie==null?void 0:ie.getCellRaw(c.row,c.col),de=(z=(j=(M=B==null?void 0:B.p)==null?void 0:M.body)==null?void 0:j.customRanges)==null?void 0:z.find(Ht=>{var jt;return Ht.rangeType===o.CustomRangeType.HYPERLINK&&((jt=Ht.properties)==null?void 0:jt.url)}),ye=B==null?void 0:B.v;B&&(!o.BuildTextUtils.transform.isEmptyDocument((Pt=(Rt=B.p)==null?void 0:Rt.body)==null?void 0:Pt.dataStream)||o.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Tt=de==null?void 0:de.properties)==null?void 0:Tt.url)!=null?Lt:"",row:qe,column:et}}else{const H=T.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),ie=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ie&&B?ie:null,ye=de&&((kt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Ot=B==null?void 0:B.customRanges)!=null?Ot:[]))==null?void 0:kt[0]);l(!1),X={id:"",display:q!=null?q:"",payload:(Dt=(bt=ye==null?void 0:ye.properties)==null?void 0:bt.url)!=null?Dt:"",row:qe,column:et}}n(X.id);const Ut=N.findCustomHyperLink(X);if(Ut){const H=Ut.convert(X);p(H.type),h(H.payload),te(H.display);return}te(X.display);const ne=k.parseHyperLink(X.payload);switch(p(ne.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:ne.type),ne.type){case g.SheetHyperLinkType.URL:{h(ne.url),ne.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=ne.searchObj,ie=H.gid&&(Mt=(Nt=(wt=T.getUnit(c.unitId))==null?void 0:wt.getSheetBySheetId(H.gid))==null?void 0:Nt.getName())!=null?Mt:"",B=J.serializeRangeWithSheet(ie,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=ne.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=ne.searchObj;h(H.rangeid);break}default:h("");break}}},[c,x,N,Be,T]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===f.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const b=T.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),L=b==null?void 0:b.getSheetBySheetId(c.subUnitId),M=L==null?void 0:L.getMergedCell(c.row,c.col),j=new o.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:M!=null?M:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${j.r}, ${j.g}, ${j.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,T]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===f.ZEN_EDITOR?Q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):Q.getRenderById(E.getCurrentEditorId()),b=new o.DisposableCollection;if(_){const L=_.with(ee.DocSelectionRenderService);L.setReserveRangesStatus(!0),b.add(()=>{L.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,Q]),C.useEffect(()=>(O.setIsKeepVisible(fe),()=>{O.setIsKeepVisible(!1)}),[fe,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(o.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(fe)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[fe,E]);const Yn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Gn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Gn.indexOf(_.value)===-1),Je=Object.values((Et=S.getDefinedNameMap($.getUnitId()))!=null?Et:{}).map(_=>({label:_.name,value:_.id})),Ct=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return Vt(b);if(_===g.SheetHyperLinkType.RANGE){const L=J.deserializeRangeWithSheet(b),M=$.getSheetBySheetName(L.sheetName);if(M)return`#gid=${M.getSheetId()}&range=${J.serializeRange(L.range)}`}return`#${_}=${b}`},$n=D.useEvent(_=>{var j;const L=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!L||!o.isValidRange(L.range))return;L.sheetName||(L.sheetName=((j=$.getActiveSheet())==null?void 0:j.getName())||"");const M=J.serializeRangeToRefString(L);h(M),M&&(A.current||!r)&&(te(M),A.current=!0)}),Qe=async()=>{if(s&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Kn(!0);return}if(c)if(t){const _=c.type===f.ZEN_EDITOR||c.type===f.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:s?r:"",payload:Ct(u,d)},row:c.row,column:c.col,documentId:c.type===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===f.ZEN_EDITOR||c.type===f.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:Ct(u,d),display:s?r:""},documentId:c.type===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===f.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},zn=_=>{var L;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(L=Ie.current)==null?void 0:L.handleOutClick;b&&b(_,()=>ze(!1))};return c?I.jsxs("div",{className:ot.cellLinkEdit,style:{display:e?"none":"block"},onClick:zn,children:[s?I.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:I.jsx(w.Input,{value:r,onChange:_=>{te(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,I.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:I.jsx(w.Select,{options:Yn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&I.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:I.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(te(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&I.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:I.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Wn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:$n,isFocus:fe,onFocus:()=>ze(!0),actions:Ie.current,onRangeSelectorDialogVisibleChange:async _=>{var b,L;if(_)c.type===f.ZEN_EDITOR&&(F.hide(),ae.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==f.VIEWING&&E.enableForceKeepVisible(),i(!0);else{if(await x.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===f.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(o.FOCUSING_SHEET,!1);const M=(b=Q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(ee.DocBackScrollRenderController),j=(L=me.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:L[0];M&&j&&(M.scrollToRange(j),me.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),i(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&I.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:I.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var M,j;h(_);const b=(M=Xe.find(z=>z.value===_))==null?void 0:M.label,L=(j=Xe.find(z=>z.value===d))==null?void 0:j.label;b&&(A.current||!r||r===L)&&(te(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&I.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:I.jsx(w.Select,{options:Je,value:d,onChange:_=>{var M,j;h(_);const b=(M=Je.find(z=>z.value===_))==null?void 0:M.label,L=(j=Je.find(z=>z.value===d))==null?void 0:j.label;b&&(A.current||!r||r===L)&&(te(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&I.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{te(_),A.current=!0},setPayload:h}),I.jsxs("div",{className:ot.cellLinkEditButtons,children:[I.jsx(w.Button,{onClick:()=>{c&&x.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),I.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},V.apply(this,arguments)},nn=function(t,n){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.indexOf(i)<0&&(e[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(e[i[r]]=t[i[r]]);return e},re=C.forwardRef(function(t,n){var e=t.icon,i=t.id,r=t.className,a=t.extend,s=nn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(i),{defIds:e.defIds,idSuffix:u.current},V({ref:n,className:l},s),a)});function st(t,n,e,i,r){return C.createElement(t.tag,V(V({key:n},rn(t,e,r)),i),(on(t,e).children||[]).map(function(a,s){return st(a,"".concat(n,"-").concat(t.tag,"-").concat(s),e,void 0,r)}))}function rn(t,n,e){var i=V({},t.attrs);e!=null&&e.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=e.colorChannel1);var r=n.defIds;return!r||r.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function on(t,n){var e,i=n.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Te=C.forwardRef(function(t,n){return C.createElement(re,Object.assign({},t,{id:"all-border-single",ref:n,icon:an}))});Te.displayName="AllBorderSingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},at=C.forwardRef(function(t,n){return C.createElement(re,Object.assign({},t,{id:"copy-single",ref:n,icon:cn}))});at.displayName="CopySingle";var ln={tag:"svg",attrs:{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"}}]},Fe=C.forwardRef(function(t,n){return C.createElement(re,Object.assign({},t,{id:"link-single",ref:n,icon:ln}))});Fe.displayName="LinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},ct=C.forwardRef(function(t,n){return C.createElement(re,Object.assign({},t,{id:"unlink-single",ref:n,icon:un}))});ct.displayName="UnlinkSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},lt=C.forwardRef(function(t,n){return C.createElement(re,Object.assign({},t,{id:"write-single",ref:n,icon:dn}))});lt.displayName="WriteSingle";var pn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ut=C.forwardRef(function(t,n){return C.createElement(re,Object.assign({},t,{id:"xlsx",ref:n,icon:pn}))});ut.displayName="Xlsx";function dt(t){var n,e,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(n=0;n<r;n++)t[n]&&(e=dt(t[n]))&&(i&&(i+=" "),i+=e)}else for(e in t)t[e]&&(i&&(i+=" "),i+=e);return i}function pt(){for(var t,n,e=0,i="",r=arguments.length;e<r;e++)(t=arguments[e])&&(n=dt(t))&&(i&&(i+=" "),i+=n);return i}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},hn={[g.SheetHyperLinkType.URL]:I.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:I.jsx(ut,{}),[g.SheetHyperLinkType.RANGE]:I.jsx(Te,{}),[g.SheetHyperLinkType.DEFINE_NAME]:I.jsx(Te,{}),[g.SheetHyperLinkType.INVALID]:I.jsx(Te,{})},ht=t=>{var x,U;const n=o.useDependency(v.SheetsHyperLinkPopupService),e=o.useDependency(o.ICommandService),i=o.useDependency(D.IMessageService),r=o.useDependency(o.LocaleService),a=o.useDependency(v.SheetsHyperLinkResolverService),s=o.useDependency(y.IEditorBridgeService),l=o.useDependency(g.SheetsHyperLinkParserService),u=o.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:S,editPermission:E,copyPermission:T,type:O}=t;if(!((x=p==null?void 0:p.properties)!=null&&x.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return I.jsxs("div",{className:Y.cellLink,onClick:()=>n.hideCurrentPopup(),children:[I.jsxs("div",{className:pt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[I.jsx("div",{className:Y.cellLinkType,children:hn[c.type]}),I.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:I.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),I.jsxs("div",{className:Y.cellLinkOperations,children:[T&&I.jsx("div",{className:pt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const N=new URL(window.location.href);N.hash=c.url.slice(1),navigator.clipboard.writeText(N.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:I.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:I.jsx(at,{})})}),E&&I.jsxs(I.Fragment,{children:[I.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:S,row:d,col:h,customRangeId:p.rangeId,type:O})},children:I.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:I.jsx(lt,{})})}),I.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const N=O===f.EDITING||O===f.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(N,{unitId:m,subUnitId:S,id:p.rangeId,row:d,column:h,documentId:O===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:s.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:I.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:I.jsx(ct,{})})})]})]})]})},Le=()=>{var r,a;const t=o.useDependency(v.SheetsHyperLinkPopupService),[n,e]=C.useState(null),i=o.useDependency(o.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const s=t.currentPopup$.subscribe(l=>{e(l)});return()=>{s.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!n)return null;if(n.showAll){const s=i.getUnit(n.unitId,o.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?I.jsx("div",{children:p.map(d=>I.jsx(ht,{...n,customRange:d},d.rangeId))}):null}return I.jsx(ht,{...n})};Le.componentKey="univer.sheet.cell-link-popup";var vn=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,Sn=(t,n,e,i)=>{for(var r=i>1?void 0:i?gn(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&vn(n,e,r),r},oe=(t,n)=>(e,i)=>n(e,i,t);const vt=(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};v.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(e,i,r,a,s,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=s,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&vt(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==f.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&&vt(e,i))return;const{unitId:r,subUnitId:a,row:s,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Le.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===f.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===f.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:s,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,i){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,s;const e=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(e&&i){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(s=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===o.CustomRangeType.HYPERLINK))!=null?s:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:o.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var s,l,u,p,d;const{unitId:i,subUnitId:r,type:a}=e;if(a===f.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const S=(s=h.getBody())==null?void 0:s.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:S})}else if(a===f.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const S=ee.calcDocRangePositions(h,m);if(!(S!=null&&S.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(S.pop(),this._editPopup,i,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,r);const h=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),S=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:S!=null&&S.p?o.BuildTextUtils.transform.getPlainText((p=(u=S.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=S==null?void 0:S.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=e;let a,s;if(e.type===f.ZEN_EDITOR){const S=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=S==null?void 0:S.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),s=a?(d=S==null?void 0:S.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!s)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===f.EDITING){const S=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!S||!((h=S.rects)!=null&&h.length))return;a=S.customRange,s=S.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.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),E=S==null?void 0:S.getSheetBySheetId(r),T=E==null?void 0:E.getCellRaw(e.row,e.col),O=S==null?void 0:S.getStyles().getStyleByCell(T),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,s=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:s})}endEditing(e){var r;const i=this._currentEditing$.getValue();i&&(!e||e===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},v.SheetsHyperLinkPopupService=Sn([oe(0,o.Inject(y.SheetCanvasPopManagerService)),oe(1,o.Inject(o.Injector)),oe(2,o.IUniverInstanceService),oe(3,y.IEditorBridgeService),oe(4,o.Inject(he.DocSelectionManagerService)),oe(5,o.Inject(ee.DocCanvasPopManagerService)),oe(6,D.IZenZoneService)],v.SheetsHyperLinkPopupService);const Ze=(t,n,e,i)=>{const r=n.getCell(e,i);if(r!=null&&r.f||r!=null&&r.si)return!0;const a=[o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE],s=t.has(tt.SheetDataValidationModel)?t.get(tt.SheetDataValidationModel):null,l=s==null?void 0:s.getRuleByLocation(n.getUnitId(),n.getSheetId(),e,i);return!!(l&&a.includes(l.type))},_n=t=>{const n=t.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const e=n.getActiveSheet(),i=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,a=i[0].range.startColumn;return Ze(t,e,r,a)},mn=t=>{const n=t.get(he.DocSelectionManagerService),e=t.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(s=>s.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},Oe={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,n){if(!n)return!1;const e=t.get(v.SheetsHyperLinkPopupService);return n.customRangeId?e.startEditing(n):e.startAddEditing(n),!0}},ve={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(v.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const n=t.get(o.IUniverInstanceService),e=R.getSheetCommandTarget(n),i=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(o.ICommandService),s=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!s)return!1;const l=s.range.startRow,u=s.range.startColumn,p=i.isVisible(),d=((h=n.getFocusedUnit())==null?void 0:h.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?f.ZEN_EDITOR:p.visible?f.EDITING:f.VIEWING})}},se={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(_n(t))return!1;const n=t.get(o.ICommandService);return t.get(v.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ve.id):n.executeCommand(ke.id)}},Ke=(t,n=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(o.IUniverInstanceService),i=(r=t.get(pe.IRenderManagerService).getRenderById(n))==null?void 0:r.with(ee.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(P.map(()=>{const s=t.get(y.IEditorBridgeService).getEditCellState();if(!s)return!0;const l=R.getSheetCommandTarget(e,{unitId:s.unitId,subUnitId:s.sheetId});return!(l!=null&&l.worksheet)||Ze(t,l.worksheet,s.row,s.column)?!0:mn(t)})):P.of(!0)},gt=t=>{const n=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(o.IUniverInstanceService),i=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(s=>!!s),P.map(s=>e.getUnit(s,o.UniverInstanceType.UNIVER_SHEET)),P.filter(s=>!!s),P.switchMap(s=>s.activeSheet$),P.switchMap(s=>i.selectionMoveEnd$.pipe(P.map(l=>s&&{selections:l,sheet:s}))),P.map(s=>{if(!s)return!0;const{selections:l,sheet:u}=s;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(t,u,p,d))return!0}),P.switchMap(s=>{if(s)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(o.IContextService).subscribeContextValue$(o.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return n.pipe(P.distinctUntilChanged(),P.switchMap(s=>a.pipe(P.map(l=>s||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,In=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:gt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},yn=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:gt(t)}),Cn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var En=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,Pn=(t,n,e,i)=>{for(var r=i>1?void 0:i?Rn(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&En(n,e,r),r},St=(t,n)=>(e,i)=>n(e,i,t);let Ne=class extends o.Disposable{constructor(t,n){super(),this._autoFillService=t,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:a,target:s,unitId:l,subUnitId:u}=i,p=y.virtualizeDiscreteRanges([a,s]),[d,h]=p.ranges,{mapFunc:m}=p,S={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),T=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,x=c.relativeRange,U={startRow:S.row,startColumn:S.col,endColumn:S.col,endRow:S.row},N={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};o.Range.foreach(x,(Z,F)=>{const Q=o.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(Q.startRow,Q.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=o.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},N),{row:me,col:Ie}=m(_e.startRow,_e.startColumn),ce=o.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,Ie);K&&T.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(T.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:Ie}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:T}},e={id:Ae,onFillData:(i,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?n(i,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Pn([St(0,y.IAutoFillService),St(1,o.Inject(g.HyperLinkModel))],Ne);var Tn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,On=(t,n,e,i)=>{for(var r=i>1?void 0:i?Ln(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&Tn(n,e,r),r},Ye=(t,n)=>(e,i)=>n(e,i,t);let Me=class extends o.Disposable{constructor(t,n,e){super(),this._localeService=t,this._commandService=n,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=On([Ye(0,o.Inject(o.LocaleService)),Ye(1,o.ICommandService),Ye(2,o.Inject(y.SheetPermissionInterceptorBaseController))],Me);var kn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,Dn=(t,n,e,i)=>{for(var r=i>1?void 0:i?bn(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&kn(n,e,r),r},G=(t,n)=>(e,i)=>n(e,i,t);let Ue=class extends o.Disposable{constructor(t,n,e,i,r,a,s,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=n,this._renderManagerService=e,this._permissionService=i,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=s,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:n,subUnitId:e,row:i,col:r}=t,a=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(n).id,new R.WorksheetCopyPermission(n,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U,N;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:e,row:i,col:r}=t,a=this._renderManagerService.getRenderById(n);if(!a)return;const s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=i;let m=h,S=d;p&&p.overflowCache.forValue((Z,F,Q)=>{o.Rectangle.contains(Q,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=Z,S=F)});const{viewPermission:E,editPermission:T,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,S),k=s.getStyles().getStyleByCell(c),x=(N=k==null?void 0:k.tr)==null?void 0:N.a;if(!x&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:S,editPermission:T,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:f.VIEWING,unitId:n,subUnitId:e,showAll:!!x})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(n=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:n}))))).subscribe(({visible:n,state:e})=>{if(!e||e.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING),this._sheetsHyperLinkPopupService.endEditing(f.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:a,row:s,column:l}=e,u=this._renderManagerService.getRenderById(i);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:s,col:l}),m=u.with(ee.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(S=>{var k,x;const E=S.find(U=>U.range.rangeType===o.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const T=E.rects[E.rects.length-1];if(!((x=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:x.skeleton)||!T)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:s,col:l,customRange:E.range,customRangeRect:{left:T.left+c.left,top:T.top+c.top,bottom:T.bottom+c.top,right:T.right+c.left},editPermission:p,copyPermission:h,type:f.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING),this._sheetsHyperLinkPopupService.endEditing(f.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(f.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const n=t===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return n?n.with(ee.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const n=t==null?void 0:t.find(i=>i.range.rangeType===o.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(n&&e){const{unitId:i,sheetId:r,row:a,column:s}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:i,subUnitId:r,row:a,col:s});u&&this._sheetsHyperLinkPopupService.showPopup({type:f.ZEN_EDITOR,unitId:i,subUnitId:r,row:a,col:s,customRange:n.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(f.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=Dn([G(0,o.Inject(y.HoverManagerService)),G(1,o.Inject(v.SheetsHyperLinkPopupService)),G(2,o.Inject(pe.IRenderManagerService)),G(3,o.Inject(o.IPermissionService)),G(4,o.Inject(y.SheetPermissionInterceptorBaseController)),G(5,o.ICommandService),G(6,y.IEditorBridgeService),G(7,o.Inject(he.DocSelectionManagerService)),G(8,o.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var wn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,_t=(t,n,e,i)=>{for(var r=i>1?void 0:i?Nn(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&wn(n,e,r),r},Ge=(t,n)=>(e,i)=>n(e,i,t);let $e=class extends o.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(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=_t([Ge(1,o.Inject(g.HyperLinkModel))],$e);let He=class extends o.Disposable{constructor(t,n){super(),this._sheetInterceptorService=t,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(t,n,e)=>{const{row:i,col:r,unitId:a,subUnitId:s}=n,l=this._hyperLinkModel.getHyperLinkByLocation(a,s,i,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=_t([Ge(0,o.Inject(R.SheetInterceptorService)),Ge(1,o.Inject(g.HyperLinkModel))],He);const Mn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:yn},[De(se.id)]:{order:2,menuItemFactory:Cn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:In},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Un=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,jn=(t,n,e,i)=>{for(var r=i>1?void 0:i?Hn(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&Un(n,e,r),r},ge=(t,n)=>(e,i)=>n(e,i,t);let je=class extends o.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(){[[Le,Le.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,n])=>{this._componentManager.register(n,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Mn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};je=jn([ge(0,o.Inject(D.ComponentManager)),ge(1,o.ICommandService),ge(2,D.IMenuManagerService),ge(3,o.Inject(o.Injector)),ge(4,o.Inject(D.IShortcutService))],je);var xn=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,An=(t,n,e,i)=>{for(var r=i>1?void 0:i?Bn(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&xn(n,e,r),r},mt=(t,n)=>(e,i)=>n(e,i,t);let xe=class extends o.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)}}};xe=An([mt(0,o.Inject(g.SheetsHyperLinkParserService)),mt(1,o.Inject(v.SheetsHyperLinkResolverService))],xe);var It=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,Fn=(t,n,e)=>n in t?It(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,Zn=(t,n,e,i)=>{for(var r=i>1?void 0:i?Vn(n,e):n,a=t.length-1,s;a>=0;a--)(s=t[a])&&(r=(i?s(n,e,r):s(r))||r);return i&&r&&It(n,e,r),r},ft=(t,n)=>(e,i)=>n(e,i,t),yt=(t,n,e)=>Fn(t,typeof n!="symbol"?n+"":n,e);v.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=Ft,e,i){super(),this._config=n,this._injector=e,this._configService=i;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(nt,a)}onStarting(){[[v.SheetsHyperLinkResolverService],[v.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[je],[Ne],[v.SheetsHyperLinkCopyPasteController],[Me],[xe]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(v.SheetsHyperLinkCopyPasteController),this._injector.get(je)}onRendered(){this._injector.get(Me),this._injector.get(xe),this._injector.get(Ue)}},yt(v.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),yt(v.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),v.UniverSheetsHyperLinkUIPlugin=Zn([o.DependentOn(g.UniverSheetsHyperLinkPlugin,ee.UniverDocsUIPlugin),ft(1,o.Inject(o.Injector)),ft(2,o.IConfigService)],v.UniverSheetsHyperLinkUIPlugin),v.CloseHyperLinkPopupOperation=ve,v.InsertHyperLinkOperation=ke,v.InsertLinkShortcut=We,v.OpenHyperLinkEditPanelOperation=Oe,v.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
22
19
 
23
20
 
24
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui/facade
25
-
26
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
27
-
28
-
29
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link
30
-
31
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,H,m,M,x){"use strict";var Ze=Object.defineProperty;var Qe=(p,o,H)=>o in p?Ze(p,o,{enumerable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={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:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
32
-
33
-
34
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link/facade
35
-
36
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
37
-
38
-
39
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui
40
-
41
- (function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={exports:{}},Re={};/**
42
- * @license React
43
- * react-jsx-runtime.production.min.js
44
- *
45
- * Copyright (c) Facebook, Inc. and its affiliates.
46
- *
47
- * This source code is licensed under the MIT license found in the
48
- * LICENSE file in the root directory of this source tree.
49
- */var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
50
-
51
-
52
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui/facade
53
-
54
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
55
-
56
-
57
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link
58
-
59
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,H,m,M,x){"use strict";var Ze=Object.defineProperty;var Qe=(p,o,H)=>o in p?Ze(p,o,{enumerable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={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:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
60
-
61
-
62
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link/facade
63
-
64
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
65
-
66
-
67
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui
68
-
69
- (function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={exports:{}},Re={};/**
70
- * @license React
71
- * react-jsx-runtime.production.min.js
72
- *
73
- * Copyright (c) Facebook, Inc. and its affiliates.
74
- *
75
- * This source code is licensed under the MIT license found in the
76
- * LICENSE file in the root directory of this source tree.
77
- */var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
78
-
79
-
80
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui/facade
81
-
82
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
83
-
84
-
85
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link
86
-
87
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,H,m,M,x){"use strict";var Ze=Object.defineProperty;var Qe=(p,o,H)=>o in p?Ze(p,o,{enumerable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={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:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
88
-
89
-
90
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link/facade
91
-
92
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
93
-
94
-
95
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui
96
-
97
- (function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={exports:{}},Re={};/**
98
- * @license React
99
- * react-jsx-runtime.production.min.js
100
- *
101
- * Copyright (c) Facebook, Inc. and its affiliates.
102
- *
103
- * This source code is licensed under the MIT license found in the
104
- * LICENSE file in the root directory of this source tree.
105
- */var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
106
-
107
-
108
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui/facade
109
-
110
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
111
-
112
-
113
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link
114
-
115
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,H,m,M,x){"use strict";var Ze=Object.defineProperty;var Qe=(p,o,H)=>o in p?Ze(p,o,{enumerable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={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:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
116
-
117
-
118
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link/facade
119
-
120
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
121
-
122
-
123
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui
124
-
125
- (function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={exports:{}},Re={};/**
126
- * @license React
127
- * react-jsx-runtime.production.min.js
128
- *
129
- * Copyright (c) Facebook, Inc. and its affiliates.
130
- *
131
- * This source code is licensed under the MIT license found in the
132
- * LICENSE file in the root directory of this source tree.
133
- */var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
134
-
135
-
136
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui/facade
137
-
138
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
139
-
140
-
141
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link
142
-
143
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,H,m,M,x){"use strict";var Ze=Object.defineProperty;var Qe=(p,o,H)=>o in p?Ze(p,o,{enumerable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={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:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
144
-
145
-
146
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link/facade
147
-
148
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
149
-
150
-
151
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui
152
-
153
- (function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={exports:{}},Re={};/**
154
- * @license React
155
- * react-jsx-runtime.production.min.js
156
- *
157
- * Copyright (c) Facebook, Inc. and its affiliates.
158
- *
159
- * This source code is licensed under the MIT license found in the
160
- * LICENSE file in the root directory of this source tree.
161
- */var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
162
-
163
-
164
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui/facade
165
-
21
+ // @univerjs/sheets-hyper-link-ui/facade
166
22
  (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
167
23
 
168
24
 
25
+ // index
169
26
  (function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-hyper-link-ui"),require("@univerjs/sheets-hyper-link/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-hyper-link","@univerjs/sheets-hyper-link-ui","@univerjs/sheets-hyper-link/facade"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverPresetSheetsHyperLink={},e.UniverSheetsHyperLink,e.UniverSheetsHyperLinkUi))})(this,function(e,i,n){"use strict";function r(){return{plugins:[i.UniverSheetsHyperLinkPlugin,n.UniverSheetsHyperLinkUIPlugin].filter(s=>!!s)}}e.UniverSheetsHyperLinkPreset=r,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
170
- rable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(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 o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.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,a=!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:a})),!0}updateHyperLinkRef(e,n,i,s,a=!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:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.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:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,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))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={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:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.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},a=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,a,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,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.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,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.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:a}=n;a.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,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));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(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.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(o.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 a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(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 o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.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:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.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,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.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 o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.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:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,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"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.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:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=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:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.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 _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.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:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.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(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
171
-
172
-
173
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link/facade
174
-
175
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
176
-
177
-
178
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui
179
-
180
- (function(S,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs"),require("react"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets","@univerjs/ui","@univerjs/docs-ui","@univerjs/engine-render","rxjs","@univerjs/docs","react","@univerjs/sheets-formula-ui"],s):(S=typeof globalThis<"u"?globalThis:S||self,s(S.UniverSheetsHyperLinkUi={},S.UniverCore,S.UniverSheetsHyperLink,S.UniverSheetsUi,S.UniverDesign,S.UniverEngineFormula,S.UniverSheets,S.UniverUi,S.UniverDocsUi,S.UniverEngineRender,S.rxjs,S.UniverDocs,S.React,S.UniverSheetsFormulaUi))})(this,function(S,s,g,y,w,J,R,D,q,pe,P,he,C,xt){"use strict";var zn=Object.defineProperty;var Xn=(S,s,g)=>s in S?zn(S,s,{enumerable:!0,configurable:!0,writable:!0,value:g}):S[s]=g;var W=(S,s,g)=>Xn(S,typeof s!="symbol"?s+"":s,g);function Ce(t){return s.Tools.isLegalUrl(t)}function jt(t){return/^[a-zA-Z]+:\/\//.test(t)}function Bt(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function At(t){if(Ce(t)){const i=jt(t)?t:Bt(t)?`mailto://${t}`:`http://${t}`;let e;try{e=new URL(i)}catch{return t}return e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol&&e.pathname===location.pathname&&e.hash&&!e.search?e.hash:i}return t}const tt="sheets-hyper-link-ui.config",Vt={};var Ft=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Kt=(t,i,e,n)=>{for(var r=n>1?void 0:n?Zt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Ft(i,e,r),r},ue=(t,i)=>(e,n)=>i(e,n,t);function Wt(t,i){const e=i.getMergeData(),n=i.getMaxColumns()-1,r=i.getMaxRows()-1;if(n<t.endColumn&&(t.endColumn=n),r<t.endRow&&(t.endRow=r),t.rangeType===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return t;const a=[];return e.forEach(o=>{s.Rectangle.intersects(t,o)&&a.push(o)}),s.Rectangle.realUnion(t,...a)}S.SheetsHyperLinkResolverService=class{constructor(i,e,n,r,a,o){this._univerInstanceService=i,this._commandService=e,this._definedNamesService=n,this._messageService=r,this._localeService=a,this._configService=o}navigate(i){switch(i.type){case g.SheetHyperLinkType.URL:this.navigateToOtherWebsite(i.url);break;default:this._navigateToUniver(i.searchObj)}}_navigateToUniver(i){const{gid:e,range:n,rangeid:r}=i,a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!a)return;const o=a.getUnitId();if(r){const l=this._definedNamesService.getValueById(o,r);if(!l)return;const{formulaOrRefString:u}=l,p=this._definedNamesService.getWorksheetByRef(o,u);if(!p){this._messageService.show({content:this._localeService.t("hyperLink.message.refError"),type:w.MessageType.Error});return}if(p.isSheetHidden()){this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error});return}this.navigateToDefineName(o,r)}if(e){if(n){const l=J.deserializeRangeWithSheet(n);s.isValidRange(l.range)&&n!==g.ERROR_RANGE&&this.navigateToRange(o,e,l.range);return}this.navigateToSheetById(o,e)}}async navigateToRange(i,e,n,r){const a=await this.navigateToSheetById(i,e);if(a){const o=Wt(n,a);await this._commandService.executeCommand(R.SetSelectionsOperation.id,{unitId:i,subUnitId:e,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o,forceTop:r})}}async navigateToSheetById(i,e){const n=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===e)return r;const a=n.getSheetBySheetId(e);return a?n.getHiddenWorksheets().indexOf(e)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:w.MessageType.Error}),!1):await this._commandService.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:i,subUnitId:e})?a:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:w.MessageType.Error}),!1)}async navigateToDefineName(i,e){return this._definedNamesService.focusRange(i,e),!0}async navigateToOtherWebsite(i){var n;const e=this._configService.getConfig(tt);if((n=e==null?void 0:e.urlHandler)!=null&&n.navigateToOtherWebsite)return e.urlHandler.navigateToOtherWebsite(i);window.open(i,"_blank","noopener noreferrer")}},S.SheetsHyperLinkResolverService=Kt([ue(0,s.IUniverInstanceService),ue(1,s.ICommandService),ue(2,J.IDefinedNamesService),ue(3,D.IMessageService),ue(4,s.Inject(s.LocaleService)),ue(5,s.IConfigService)],S.SheetsHyperLinkResolverService);const Ae="SHEET_HYPER_LINK_UI_PLUGIN";var Yt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,$t=(t,i,e,n)=>{for(var r=n>1?void 0:n?Gt(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Yt(i,e,r),r},Ee=(t,i)=>(e,n)=>i(e,n,t);S.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(e,n,r,a){super();W(this,"_plainTextFilter",new Set);W(this,"_copyInfo");this._sheetClipboardService=e,this._hyperLinkModel=n,this._injector=r,this._resolverService=a,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(e){this._plainTextFilter.add(e)}removePlainTextFilter(e){this._plainTextFilter.delete(e)}_filterPlainText(e){return Array.from(this._plainTextFilter).every(n=>n(e))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:Ae,onBeforeCopy:(e,n,r)=>this._collect(e,n,r),onPasteCells:(e,n,r,a)=>{const{copyType:o=y.COPY_TYPE.COPY,pasteType:l}=a,{range:u}=e||{},{range:p,unitId:d,subUnitId:h}=n;return this._generateMutations(p,{copyType:o,pasteType:l,copyRange:u,unitId:d,subUnitId:h})},onPastePlainText:(e,n)=>{const r=this._filterPlainText(n);if(Ce(n)&&r){const{range:a,unitId:o,subUnitId:l}=e,{ranges:[u],mapFunc:p}=y.virtualizeDiscreteRanges([a]),d=[],h=[];return s.Range.foreach(u,(m,v)=>{const{row:E,col:L}=p(m,v),O=this._hyperLinkModel.getHyperLinkByLocation(o,l,E,L);O&&d.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:l,id:O.id}}),O&&h.push({id:g.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:l,link:O}})}),{redos:d,undos:h}}return{undos:[],redos:[]}},priority:99})}_collect(e,n,r){const a=new s.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};const o=this._injector.invoke(p=>y.rangeToDiscreteRange(r,p,e,n));if(!o)return;const{rows:l,cols:u}=o;l.forEach((p,d)=>{u.forEach((h,m)=>{var E;const v=this._hyperLinkModel.getHyperLinkByLocation(e,n,p,h);a.setValue(d,m,(E=v==null?void 0:v.id)!=null?E:"")})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:a}=this._copyInfo,o=[],l=[],{ranges:[u,p],mapFunc:d}=y.virtualizeDiscreteRanges([n.copyRange,e]);return y.getRepeatRange(u,p,!0).forEach(({startRange:m})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((E,L,O)=>{const c=s.Rectangle.getPositionRange({startRow:E,endRow:E,startColumn:L,endColumn:L},m),k=this._hyperLinkModel.getHyperLink(r,a,O),{row:j,col:U}=d(c.startRow,c.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,j,U),Z=s.Tools.generateRandomId();M&&o.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),k&&(o.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...k,id:Z,row:j,column:U}}}),l.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&l.push({id:g.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:o,undos:l}}},S.SheetsHyperLinkCopyPasteController=$t([Ee(0,y.ISheetClipboardService),Ee(1,s.Inject(g.HyperLinkModel)),Ee(2,s.Inject(s.Injector)),Ee(3,s.Inject(S.SheetsHyperLinkResolverService))],S.SheetsHyperLinkCopyPasteController);var I=(t=>(t.EDITING="editing",t.VIEWING="viewing",t.ZEN_EDITOR="zen_mode",t))(I||{}),nt={exports:{}},Re={};/**
181
- * @license React
182
- * react-jsx-runtime.production.min.js
183
- *
184
- * Copyright (c) Facebook, Inc. and its affiliates.
185
- *
186
- * This source code is licensed under the MIT license found in the
187
- * LICENSE file in the root directory of this source tree.
188
- */var zt=C,Xt=Symbol.for("react.element"),Jt=Symbol.for("react.fragment"),Qt=Object.prototype.hasOwnProperty,qt=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,en={key:!0,ref:!0,__self:!0,__source:!0};function it(t,i,e){var n,r={},a=null,o=null;e!==void 0&&(a=""+e),i.key!==void 0&&(a=""+i.key),i.ref!==void 0&&(o=i.ref);for(n in i)Qt.call(i,n)&&!en.hasOwnProperty(n)&&(r[n]=i[n]);if(t&&t.defaultProps)for(n in i=t.defaultProps,i)r[n]===void 0&&(r[n]=i[n]);return{$$typeof:Xt,type:t,key:a,ref:o,props:r,_owner:qt.current}}Re.Fragment=Jt,Re.jsx=it,Re.jsxs=it,nt.exports=Re;var f=nt.exports;class Ve extends s.Disposable{constructor(){super(...arguments);W(this,"_customHyperLinks",new Map)}isBuiltInLinkType(e){return e!==g.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:e})=>e)}findCustomHyperLink(e){return Array.from(this._customHyperLinks.values()).find(r=>r.match(e))}registerCustomHyperLink(e){this._customHyperLinks.set(e.type,e)}getCustomHyperLink(e){return this._customHyperLinks.get(e)}removeCustomHyperLink(e){const{_customHyperLinks:n}=this;n.delete(e)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const rt={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Pe=()=>{var Ct;const[t,i]=C.useState(""),[e,n]=C.useState(!1),[r,a]=C.useState(""),[o,l]=C.useState(!0),[u,p]=C.useState(g.SheetHyperLinkType.URL),[d,h]=C.useState(""),m=s.useDependency(s.LocaleService),v=s.useDependency(J.IDefinedNamesService),E=s.useDependency(y.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),O=s.useDependency(S.SheetsHyperLinkPopupService),c=D.useObservable(O.currentEditing$),k=s.useDependency(g.SheetsHyperLinkParserService),j=s.useDependency(S.SheetsHyperLinkResolverService),U=s.useDependency(s.ICommandService),M=s.useDependency(Ve),Z=C.useMemo(()=>M.getOptions(),[M]),F=s.useDependency(D.IZenZoneService),oe=s.useDependency(pe.IRenderManagerService),Se=s.useDependency(y.IMarkSelectionService),Be=s.useDependency(he.DocSelectionManagerService),ae=s.useDependency(s.IContextService),_e=s.useDependency(s.ThemeService),me=s.useDependency(he.DocSelectionManagerService),fe=C.useRef({}),ce=C.useMemo(()=>{if(!M.isBuiltInLinkType(u))return M.getCustomHyperLink(u)},[M,u]),[K,Zn]=C.useState(!1),[Ie,ze]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),Kn=($==null?void 0:$.getActiveSheet().getSheetId())||"",ee=C.useCallback(_=>{a(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var _,b,T,N,x,z,Et,Rt,Pt,Lt,Tt,Ot,kt,bt,Dt,wt,Nt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:qe,col:et}=c;let{label:Q}=c;typeof Q=="number"&&(Q=`${Q}`);let X;if(le)X={id:(_=le==null?void 0:le.rangeId)!=null?_:"",display:Q!=null?Q:"",payload:(T=(b=le==null?void 0:le.properties)==null?void 0:b.url)!=null?T:"",row:qe,column:et};else if(c.type===I.VIEWING){const H=L.getUnit(c.unitId),ne=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ne==null?void 0:ne.getCellRaw(c.row,c.col),de=(z=(x=(N=B==null?void 0:B.p)==null?void 0:N.body)==null?void 0:x.customRanges)==null?void 0:z.find(Ut=>{var Ht;return Ut.rangeType===s.CustomRangeType.HYPERLINK&&((Ht=Ut.properties)==null?void 0:Ht.url)}),ye=B==null?void 0:B.v;B&&(!s.BuildTextUtils.transform.isEmptyDocument((Rt=(Et=B.p)==null?void 0:Et.body)==null?void 0:Rt.dataStream)||s.Tools.isDefine(ye))&&l(!1),X={id:"",display:"",payload:(Lt=(Pt=de==null?void 0:de.properties)==null?void 0:Pt.url)!=null?Lt:"",row:qe,column:et}}else{const H=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),ne=Be.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ne&&B?ne:null,ye=de&&((Ot=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(Tt=B==null?void 0:B.customRanges)!=null?Tt:[]))==null?void 0:Ot[0]);l(!1),X={id:"",display:Q!=null?Q:"",payload:(bt=(kt=ye==null?void 0:ye.properties)==null?void 0:kt.url)!=null?bt:"",row:qe,column:et}}i(X.id);const Mt=M.findCustomHyperLink(X);if(Mt){const H=Mt.convert(X);p(H.type),h(H.payload),ee(H.display);return}ee(X.display);const te=k.parseHyperLink(X.payload);switch(p(te.type===g.SheetHyperLinkType.INVALID?g.SheetHyperLinkType.RANGE:te.type),te.type){case g.SheetHyperLinkType.URL:{h(te.url),te.url===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.RANGE:{const H=te.searchObj,ne=H.gid&&(Nt=(wt=(Dt=L.getUnit(c.unitId))==null?void 0:Dt.getSheetBySheetId(H.gid))==null?void 0:wt.getName())!=null?Nt:"",B=J.serializeRangeWithSheet(ne,J.deserializeRangeWithSheet(H.range).range);h(B),B===X.display&&(A.current=!0);break}case g.SheetHyperLinkType.SHEET:{const H=te.searchObj;h(H.gid);break}case g.SheetHyperLinkType.DEFINE_NAME:{const H=te.searchObj;h(H.rangeid);break}default:h("");break}}},[c,j,M,Be,L]),C.useEffect(()=>{let _=null;if(c&&!c.customRangeId&&c.type===I.VIEWING&&s.Tools.isDefine(c.row)&&s.Tools.isDefine(c.col)){const b=L.getUnit(c.unitId,s.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getSheetBySheetId(c.subUnitId),N=T==null?void 0:T.getMergedCell(c.row,c.col),x=new s.ColorKit(_e.getCurrentTheme().hyacinth500).toRgb();_=Se.addShape({range:N!=null?N:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${x.r}, ${x.g}, ${x.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&Se.removeShape(_)}},[c,Se,_e,L]),C.useEffect(()=>{ze(u===g.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const _=(c==null?void 0:c.type)===I.ZEN_EDITOR?oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):oe.getRenderById(E.getCurrentEditorId()),b=new s.DisposableCollection;if(_){const T=_.with(q.DocSelectionRenderService);T.setReserveRangesStatus(!0),b.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),b.dispose()}},[c==null?void 0:c.type,E,oe]),C.useEffect(()=>(O.setIsKeepVisible(Ie),()=>{O.setIsKeepVisible(!1)}),[Ie,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ie)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ie,E]);const Wn=[{label:m.t("hyperLink.form.link"),value:g.SheetHyperLinkType.URL},{label:m.t("hyperLink.form.range"),value:g.SheetHyperLinkType.RANGE},{label:m.t("hyperLink.form.worksheet"),value:g.SheetHyperLinkType.SHEET},{label:m.t("hyperLink.form.definedName"),value:g.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Xe=$.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Yn.indexOf(_.value)===-1),Je=Object.values((Ct=v.getDefinedNameMap($.getUnitId()))!=null?Ct:{}).map(_=>({label:_.name,value:_.id})),yt=(_,b)=>{if(_===g.SheetHyperLinkType.URL)return At(b);if(_===g.SheetHyperLinkType.RANGE){const T=J.deserializeRangeWithSheet(b),N=$.getSheetBySheetName(T.sheetName);if(N)return`#gid=${N.getSheetId()}&range=${J.serializeRange(T.range)}`}return`#${_}=${b}`},Gn=D.useEvent(_=>{var x;const T=_.split(",").map(J.deserializeRangeWithSheet)[0];if(!T||!s.isValidRange(T.range))return;T.sheetName||(T.sheetName=((x=$.getActiveSheet())==null?void 0:x.getName())||"");const N=J.serializeRangeToRefString(T);h(N),N&&(A.current||!r)&&(ee(N),A.current=!0)}),Qe=async()=>{if(o&&!r||!d||u===g.SheetHyperLinkType.URL&&!Ce(d)){Zn(!0);return}if(c)if(t){const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.UpdateRichHyperLinkCommand.id:g.UpdateHyperLinkCommand.id;await U.executeCommand(_,{id:t,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:o?r:"",payload:yt(u,d)},row:c.row,column:c.col,documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const _=c.type===I.ZEN_EDITOR||c.type===I.EDITING?g.AddRichHyperLinkCommand.id:g.AddHyperLinkCommand.id;await U.executeCommand(_,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:s.generateRandomId(),row:c.row,column:c.col,payload:yt(u,d),display:o?r:""},documentId:c.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===I.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const _=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-_,0),endRow:c.row+_,startColumn:Math.max(c.col-_,0),endColumn:c.col+_}})}U.executeCommand(ve.id)},$n=_=>{var T;if(u!==g.SheetHyperLinkType.RANGE)return;const b=(T=fe.current)==null?void 0:T.handleOutClick;b&&b(_,()=>ze(!1))};return c?f.jsxs("div",{className:rt.cellLinkEdit,style:{display:e?"none":"block"},onClick:$n,children:[o?f.jsx(w.FormLayout,{label:m.t("hyperLink.form.label"),error:K&&!r?m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:r,onChange:_=>{ee(_),A.current=!1},placeholder:m.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}):null,f.jsx(w.FormLayout,{label:m.t("hyperLink.form.type"),children:f.jsx(w.Select,{options:Wn,value:u,onChange:_=>{p(_),h("")}})}),u===g.SheetHyperLinkType.URL&&f.jsx(w.FormLayout,{error:K?d?Ce(d)?"":m.t("hyperLink.form.linkError"):m.t("hyperLink.form.inputError"):"",children:f.jsx(w.Input,{value:d,onChange:_=>{h(_),_&&(A.current||!r||r===d)&&(ee(_),A.current=!0)},placeholder:m.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===D.KeyCode.ENTER&&Qe()}})}),u===g.SheetHyperLinkType.RANGE&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.inputError"):"",children:f.jsx(xt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Kn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ie,onFocus:()=>ze(!0),actions:fe.current,onRangeSelectorDialogVisibleChange:async _=>{var b,T;if(_)c.type===I.ZEN_EDITOR&&(F.hide(),ae.setContextValue(s.FOCUSING_SHEET,!0)),c.type!==I.VIEWING&&E.enableForceKeepVisible(),n(!0);else{if(await j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===I.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(s.FOCUSING_SHEET,!1);const N=(b=oe.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:b.with(q.DocBackScrollRenderController),x=(T=me.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];N&&x&&(N.scrollToRange(x),me.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),n(!1)}}})}),u===g.SheetHyperLinkType.SHEET&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Xe,value:d,onChange:_=>{var N,x;h(_);const b=(N=Xe.find(z=>z.value===_))==null?void 0:N.label,T=(x=Xe.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),u===g.SheetHyperLinkType.DEFINE_NAME&&f.jsx(w.FormLayout,{error:K&&!d?m.t("hyperLink.form.selectError"):"",children:f.jsx(w.Select,{options:Je,value:d,onChange:_=>{var N,x;h(_);const b=(N=Je.find(z=>z.value===_))==null?void 0:N.label,T=(x=Je.find(z=>z.value===d))==null?void 0:x.label;b&&(A.current||!r||r===T)&&(ee(b),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&f.jsx(ce.Form,{linkId:t,payload:d,display:r,showError:K,setByPayload:A,setDisplay:_=>{ee(_),A.current=!0},setPayload:h}),f.jsxs("div",{className:rt.cellLinkEditButtons,children:[f.jsx(w.Button,{onClick:()=>{c&&j.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(ve.id)},children:m.t("hyperLink.form.cancel")}),f.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Qe()},children:m.t("hyperLink.form.ok")})]})]}):null};Pe.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},V.apply(this,arguments)},tn=function(t,i){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(t);r<n.length;r++)i.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(e[n[r]]=t[n[r]]);return e},ie=C.forwardRef(function(t,i){var e=t.icon,n=t.id,r=t.className,a=t.extend,o=tn(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=C.useRef("_".concat(sn()));return st(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},V({ref:i,className:l},o),a)});function st(t,i,e,n,r){return C.createElement(t.tag,V(V({key:i},nn(t,e,r)),n),(rn(t,e).children||[]).map(function(a,o){return st(a,"".concat(i,"-").concat(t.tag,"-").concat(o),e,void 0,r)}))}function nn(t,i,e){var n=V({},t.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=i.defIds;return!r||r.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+i.idSuffix),Object.entries(n).forEach(function(a){var o=a[0],l=a[1];typeof l=="string"&&(n[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(i.idSuffix,")")))})),n}function rn(t,i){var e,n=i.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((e=t.children)===null||e===void 0)&&e.length)?V(V({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+i.idSuffix})}):r})}):t}function sn(){return Math.random().toString(36).substring(2,8)}ie.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"all-border-single",ref:i,icon:on}))});Le.displayName="AllBorderSingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ot=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"copy-single",ref:i,icon:an}))});ot.displayName="CopySingle";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"link-single",ref:i,icon:cn}))});Fe.displayName="LinkSingle";var ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},at=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"unlink-single",ref:i,icon:ln}))});at.displayName="UnlinkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ct=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"write-single",ref:i,icon:un}))});ct.displayName="WriteSingle";var dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=C.forwardRef(function(t,i){return C.createElement(ie,Object.assign({},t,{id:"xlsx",ref:i,icon:dn}))});lt.displayName="Xlsx";function ut(t){var i,e,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(i=0;i<r;i++)t[i]&&(e=ut(t[i]))&&(n&&(n+=" "),n+=e)}else for(e in t)t[e]&&(n&&(n+=" "),n+=e);return n}function dt(){for(var t,i,e=0,n="",r=arguments.length;e<r;e++)(t=arguments[e])&&(i=ut(t))&&(n&&(n+=" "),n+=i);return n}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},pn={[g.SheetHyperLinkType.URL]:f.jsx(Fe,{}),[g.SheetHyperLinkType.SHEET]:f.jsx(lt,{}),[g.SheetHyperLinkType.RANGE]:f.jsx(Le,{}),[g.SheetHyperLinkType.DEFINE_NAME]:f.jsx(Le,{}),[g.SheetHyperLinkType.INVALID]:f.jsx(Le,{})},pt=t=>{var j,U;const i=s.useDependency(S.SheetsHyperLinkPopupService),e=s.useDependency(s.ICommandService),n=s.useDependency(D.IMessageService),r=s.useDependency(s.LocaleService),a=s.useDependency(S.SheetsHyperLinkResolverService),o=s.useDependency(y.IEditorBridgeService),l=s.useDependency(g.SheetsHyperLinkParserService),u=s.useDependency(D.IZenZoneService),{customRange:p,row:d,col:h,unitId:m,subUnitId:v,editPermission:E,copyPermission:L,type:O}=t;if(!((j=p==null?void 0:p.properties)!=null&&j.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),k=c.type===g.SheetHyperLinkType.INVALID;return f.jsxs("div",{className:Y.cellLink,onClick:()=>i.hideCurrentPopup(),children:[f.jsxs("div",{className:dt(Y.cellLinkContent,{[Y.cellLinkContentError]:k}),onClick:()=>{u.visible||k||a.navigate(c)},children:[f.jsx("div",{className:Y.cellLinkType,children:pn[c.type]}),f.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:f.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),f.jsxs("div",{className:Y.cellLinkOperations,children:[L&&f.jsx("div",{className:dt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(c.type!==g.SheetHyperLinkType.URL){const M=new URL(window.location.href);M.hash=c.url.slice(1),navigator.clipboard.writeText(M.href)}else navigator.clipboard.writeText(c.url);n.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:f.jsx(ot,{})})}),E&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{e.executeCommand(Oe.id,{unitId:m,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:f.jsx(ct,{})})}),f.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const M=O===I.EDITING||O===I.ZEN_EDITOR?g.CancelRichHyperLinkCommand.id:g.CancelHyperLinkCommand.id;e.syncExecuteCommand(M,{unitId:m,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&i.hideCurrentPopup(void 0,!0)},children:f.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:f.jsx(at,{})})})]})]})]})},Te=()=>{var r,a;const t=s.useDependency(S.SheetsHyperLinkPopupService),[i,e]=C.useState(null),n=s.useDependency(s.IUniverInstanceService);if(C.useEffect(()=>{e(t.currentPopup);const o=t.currentPopup$.subscribe(l=>{e(l)});return()=>{o.unsubscribe()}},[t.currentPopup,t.currentPopup$]),!i)return null;if(i.showAll){const o=n.getUnit(i.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(i.subUnitId),u=l==null?void 0:l.getCell(i.row,i.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?f.jsx("div",{children:p.map(d=>f.jsx(pt,{...i,customRange:d},d.rangeId))}):null}return f.jsx(pt,{...i})};Te.componentKey="univer.sheet.cell-link-popup";var hn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,gn=(t,i,e,n)=>{for(var r=n>1?void 0:n?vn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&hn(i,e,r),r},re=(t,i)=>(e,n)=>i(e,n,t);const ht=(t,i)=>{var e,n;return t.unitId===i.unitId&&t.subUnitId===i.subUnitId&&t.row===i.row&&t.col===i.col&&((e=t.customRange)==null?void 0:e.rangeId)===((n=i.customRange)==null?void 0:n.rangeId)&&t.type===i.type};S.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(e,n,r,a,o,l,u){super();W(this,"_currentPopup",null);W(this,"_currentPopup$",new P.Subject);W(this,"currentPopup$",this._currentPopup$.asObservable());W(this,"_currentEditingPopup",null);W(this,"_currentEditing$",new P.BehaviorSubject(null));W(this,"currentEditing$",this._currentEditing$.asObservable());W(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=e,this._injector=n,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(e){this._isKeepVisible=e}getIsKeepVisible(){return this._isKeepVisible}showPopup(e){if(this._currentPopup&&ht(e,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),e.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const n=this._currentEditing$.getValue();if(n&&ht(e,n))return;const{unitId:r,subUnitId:a,row:o,col:l,customRangeRect:u,customRange:p}=e;let d;const h={componentKey:Te.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(e.type,!0)}};if(e.type===I.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(e.type===I.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,e)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:o,col:l,editPermission:!!e.editPermission,copyPermission:!!e.copyPermission,customRange:p,type:e.type,showAll:e.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(e,n){var r,a;this._currentPopup&&((!e||e===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||n)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,o;const e=this._editorBridgeService.isVisible().visible,n=this._editorBridgeService.getEditCellState();if(e&&n){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=n.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(a=u.customRanges)==null?void 0:a.filter(m=>m.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(m=>{d=Math.min(d,m.startIndex),h=Math.max(h,m.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Pe.componentKey,direction:"bottom",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(e){var o,l,u,p,d;const{unitId:n,subUnitId:r,type:a}=e;if(a===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const m=this._textSelectionManagerService.getActiveTextRange();if(!m)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(m,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(o=h.getBody())==null?void 0:o.dataStream.slice(m.startOffset,m.endOffset);this._currentEditing$.next({...e,label:v})}else if(a===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const m=this._injector.get(pe.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!m)return;const v=q.calcDocRangePositions(h,m);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,n,r),this._currentEditing$.next({...e,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r);const h=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),m=h==null?void 0:h.getSheetBySheetId(r),v=m==null?void 0:m.getCellRaw(e.row,e.col);this._currentEditing$.next({...e,label:v!=null&&v.p?s.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(e){var l,u,p,d,h,m;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:n,subUnitId:r}=e;let a,o;if(e.type===I.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===e.customRangeId),o=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(e.type===I.EDITING){const v=y.getEditingCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,o=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,n,r)}else{const v=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(e.row,e.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,k=y.getCustomRangePosition(this._injector,e.unitId,e.subUnitId,e.row,e.col,e.customRangeId);if(!k||!((m=k.rects)!=null&&m.length))return;a=k.customRange,o=k.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(e.row,e.col,this._editPopup,n,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:n,subUnitId:r,row:e.row,col:e.col})}this._currentEditing$.next({...e,customRange:a,label:o})}endEditing(e){var r;const n=this._currentEditing$.getValue();n&&(!e||e===n.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},S.SheetsHyperLinkPopupService=gn([re(0,s.Inject(y.SheetCanvasPopManagerService)),re(1,s.Inject(s.Injector)),re(2,s.IUniverInstanceService),re(3,y.IEditorBridgeService),re(4,s.Inject(he.DocSelectionManagerService)),re(5,s.Inject(q.DocCanvasPopManagerService)),re(6,D.IZenZoneService)],S.SheetsHyperLinkPopupService);const Ze=(t,i,e)=>{const n=t.getCell(i,e);if(n!=null&&n.f||n!=null&&n.si)return!0;const r=[s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE];return!!(n!=null&&n.dataValidation&&r.includes(n.dataValidation.rule.type))},Sn=t=>{const i=t.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!i)return!0;const e=i.getActiveSheet(),n=t.get(R.SheetsSelectionsService).getCurrentSelections();if(!n.length)return!0;const r=n[0].range.startRow,a=n[0].range.startColumn;return Ze(e,r,a)},_n=t=>{var p,d;const i=t.get(he.DocSelectionManagerService),e=t.get(s.IUniverInstanceService),n=i.getDocRanges();if(!n.length||n.length>1)return!0;const r=n[0],a=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!a||!r||r.collapsed)return!0;const o=a.getSelfOrHeaderFooterModel(r.segmentId).getBody();if(!o)return!0;const l=(p=o==null?void 0:o.paragraphs)!=null?p:[];for(let h=0,m=l.length;h<m;h++){const v=l[h];if(r.startOffset<=v.startIndex&&r.endOffset>v.startIndex)return!0;if(v.startIndex>r.endOffset)break}return!s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(r,(d=o.customRanges)!=null?d:[]).every(h=>h.rangeType===s.CustomRangeType.HYPERLINK)},Oe={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(t,i){if(!i)return!1;const e=t.get(S.SheetsHyperLinkPopupService);return i.customRangeId?e.startEditing(i):e.startAddEditing(i),!0}},ve={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(t){return t.get(S.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(t){var h;const i=t.get(s.IUniverInstanceService),e=R.getSheetCommandTarget(i),n=t.get(y.IEditorBridgeService);if(!e)return!1;const r=t.get(s.ICommandService),o=t.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,p=n.isVisible(),d=((h=i.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(Oe.id,{unitId:e.unitId,subUnitId:e.subUnitId,row:l,col:u,type:d?I.ZEN_EDITOR:p.visible?I.EDITING:I.VIEWING})}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(t){if(Sn(t))return!1;const i=t.get(s.ICommandService);return t.get(S.SheetsHyperLinkPopupService).currentEditing?i.executeCommand(ve.id):i.executeCommand(ke.id)}},Ke=(t,i=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const e=t.get(s.IUniverInstanceService),n=(r=t.get(pe.IRenderManagerService).getRenderById(i))==null?void 0:r.with(q.DocSelectionRenderService);return n?n.textSelectionInner$.pipe(P.map(()=>{const o=t.get(y.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=R.getSheetCommandTarget(e,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Ze(l.worksheet,o.row,o.column)?!0:_n(t)})):P.of(!0)},vt=t=>{const i=y.getCurrentRangeDisable$(t,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),e=t.get(s.IUniverInstanceService),n=t.get(R.SheetsSelectionsService),r=t.has(y.IEditorBridgeService)?t.get(y.IEditorBridgeService):null,a=e.focused$.pipe(P.filter(o=>!!o),P.map(o=>e.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),P.filter(o=>!!o),P.switchMap(o=>o.activeSheet$),P.switchMap(o=>n.selectionMoveEnd$.pipe(P.map(l=>o&&{selections:l,sheet:o}))),P.map(o=>{if(!o)return!0;const{selections:l,sheet:u}=o;if(!l.length)return!0;const p=l[0].range.startRow,d=l[0].range.startColumn;if(Ze(u,p,d))return!0}),P.switchMap(o=>{if(o)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=t.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ke(t,p):P.of(!1)))}));return i.pipe(P.distinctUntilChanged(),P.switchMap(o=>a.pipe(P.map(l=>o||l))))},be={commandId:ke.id,type:D.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},De=t=>`${t}-zen-editor`,mn=t=>({...be,id:be.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),fn=t=>({...be,id:De(be.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),we={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:D.MenuItemType.BUTTON,icon:"LinkSingle"},In=t=>({...we,id:we.commandId,hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:vt(t)}),yn=t=>({...we,id:De(we.commandId),hidden$:D.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ke(t)}),We={id:se.id,binding:D.KeyCode.K|D.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(t,i,e,n)=>{for(var r=n>1?void 0:n?En(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Cn(i,e,r),r},gt=(t,i)=>(e,n)=>i(e,n,t);let Ne=class extends s.Disposable{constructor(t,i){super(),this._autoFillService=t,this._hyperLinkModel=i,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),i=(n,r)=>{const{source:a,target:o,unitId:l,subUnitId:u}=n,p=y.virtualizeDiscreteRanges([a,o]),[d,h]=p.ranges,{mapFunc:m}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const k=c.repeatStartCell,j=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},M={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(j,(Z,F)=>{const oe=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Se,col:Be}=m(oe.startRow,oe.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Se,Be),_e=s.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},M),{row:me,col:fe}=m(_e.startRow,_e.startColumn),ce=s.Tools.generateRandomId(),K=this._hyperLinkModel.getHyperLinkByLocation(l,u,me,fe);K&&L.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:K.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:me,column:fe}}}),O.push({id:g.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),K&&O.push({id:g.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:K}})})}),{undos:O,redos:L}},e={id:Ae,onFillData:(n,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?i(n,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}};Ne=Rn([gt(0,y.IAutoFillService),gt(1,s.Inject(g.HyperLinkModel))],Ne);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Ln(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Pn(i,e,r),r},Ye=(t,i)=>(e,n)=>i(e,n,t);let Me=class extends s.Disposable{constructor(t,i,e){super(),this._localeService=t,this._commandService=i,this._sheetPermissionInterceptorBaseController=e,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===We.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Me=Tn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(y.SheetPermissionInterceptorBaseController))],Me);var On=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?kn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&On(i,e,r),r},G=(t,i)=>(e,n)=>i(e,n,t);let Ue=class extends s.Disposable{constructor(t,i,e,n,r,a,o,l,u,p){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=i,this._renderManagerService=e,this._permissionService=n,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(t){const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(e)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:n,startColumn:r,endRow:n,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(i).id,new R.WorksheetCopyPermission(i,e).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(t=>{var U;if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:i,subUnitId:e,row:n,col:r}=t,a=this._renderManagerService.getRenderById(i);if(!a)return;const o=this._univerInstanceService.getUnit(i,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(e);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:U.skeleton,d=r,h=n;let m=h,v=d;p&&p.overflowCache.forValue((M,Z,F)=>{s.Rectangle.contains(F,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(m=M,v=Z)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(t);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(m,v),k=o.getStyles().getStyleByCell(c),j=k==null?void 0:k.tr;if(!j&&!t.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:m,col:v,editPermission:L,copyPermission:O,customRange:t.customRange,customRangeRect:t.rect,type:I.VIEWING,unitId:i,subUnitId:e,showAll:!!j})}))}_initHoverEditingListener(){let t=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(i=>this._editorBridgeService.visible$.pipe(P.map(e=>({visible:e,state:i}))))).subscribe(({visible:i,state:e})=>{if(!e||e.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!i.visible){t==null||t.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:n,unitId:r,sheetId:a,row:o,column:l}=e,u=this._renderManagerService.getRenderById(n);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:o,col:l}),m=u.with(q.DocEventManagerService);d&&(t==null||t.unsubscribe(),t=m.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var k,j;const E=v.find(U=>U.range.rangeType===s.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((j=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:j.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:o,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{t==null||t.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(t=>{const i=t===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(t):null;return i?i.with(q.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(e=>{e.next(null)})})).subscribe(t=>{const i=t==null?void 0:t.find(n=>n.range.rangeType===s.CustomRangeType.HYPERLINK),e=this._editorBridgeService.getEditCellState();if(i&&e){const{unitId:n,sheetId:r,row:a,column:o}=e,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:n,subUnitId:r,row:a,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:n,subUnitId:r,row:a,col:o,customRange:i.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(t=>{t&&t.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const t=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{t.includes(i.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ue=bn([G(0,s.Inject(y.HoverManagerService)),G(1,s.Inject(S.SheetsHyperLinkPopupService)),G(2,s.Inject(pe.IRenderManagerService)),G(3,s.Inject(s.IPermissionService)),G(4,s.Inject(y.SheetPermissionInterceptorBaseController)),G(5,s.ICommandService),G(6,y.IEditorBridgeService),G(7,s.Inject(he.DocSelectionManagerService)),G(8,s.IUniverInstanceService),G(9,D.IZenZoneService)],Ue);var Dn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,St=(t,i,e,n)=>{for(var r=n>1?void 0:n?wn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Dn(i,e,r),r},Ge=(t,i)=>(e,n)=>i(e,n,t);let $e=class extends s.Disposable{constructor(t,i){super(),this._context=t,this._hyperLinkModel=i,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{var i;(i=this._context.mainComponent)==null||i.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{t()}))}};$e=St([Ge(1,s.Inject(g.HyperLinkModel))],$e);let He=class extends s.Disposable{constructor(t,i){super(),this._sheetInterceptorService=t,this._hyperLinkModel=i,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(t,i,e)=>{const{row:n,col:r,unitId:a,subUnitId:o}=i,l=this._hyperLinkModel.getHyperLinkByLocation(a,o,n,r);return e(l?{...t,linkUrl:l.payload,linkId:l.id}:t)}}))}};He=St([Ge(0,s.Inject(R.SheetInterceptorService)),Ge(1,s.Inject(g.HyperLinkModel))],He);const Nn={[D.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:In},[De(se.id)]:{order:2,menuItemFactory:yn}},[D.ContextMenuPosition.MAIN_AREA]:{[D.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:mn},[De(se.id)]:{order:0,menuItemFactory:fn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(t,i,e,n)=>{for(var r=n>1?void 0:n?Un(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&Mn(i,e,r),r},ge=(t,i)=>(e,n)=>i(e,n,t);let xe=class extends s.Disposable{constructor(t,i,e,n,r){super(),this._componentManager=t,this._commandService=i,this._menuManagerService=e,this._injector=n,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Te,Te.componentKey],[Pe,Pe.componentKey],[Fe,"LinkSingle"]].forEach(([t,i])=>{this._componentManager.register(i,t)})}_initCommands(){[Oe,ve,ke,se].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(We)}};xe=Hn([ge(0,s.Inject(D.ComponentManager)),ge(1,s.ICommandService),ge(2,D.IMenuManagerService),ge(3,s.Inject(s.Injector)),ge(4,s.Inject(D.IShortcutService))],xe);var xn=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(t,i,e,n)=>{for(var r=n>1?void 0:n?jn(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&xn(i,e,r),r},_t=(t,i)=>(e,n)=>i(e,n,t);let je=class extends s.Disposable{constructor(t,i){super(),this._parserService=t,this._resolverService=i,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;if(t){const i=this._parserService.parseHyperLink(t);this._resolverService.navigate(i)}}};je=Bn([_t(0,s.Inject(g.SheetsHyperLinkParserService)),_t(1,s.Inject(S.SheetsHyperLinkResolverService))],je);var mt=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(t,i,e)=>i in t?mt(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Fn=(t,i,e,n)=>{for(var r=n>1?void 0:n?An(i,e):i,a=t.length-1,o;a>=0;a--)(o=t[a])&&(r=(n?o(i,e,r):o(r))||r);return n&&r&&mt(i,e,r),r},ft=(t,i)=>(e,n)=>i(e,n,t),It=(t,i,e)=>Vn(t,typeof i!="symbol"?i+"":i,e);S.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(i=Vt,e,n){super(),this._config=i,this._injector=e,this._configService=n;const{menu:r,...a}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(tt,a)}onStarting(){[[S.SheetsHyperLinkResolverService],[S.SheetsHyperLinkPopupService],[Ve],[He],[Ue],[xe],[Ne],[S.SheetsHyperLinkCopyPasteController],[Me],[je]].forEach(e=>this._injector.add(e)),this._injector.get(He)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[$e]),this._injector.get(Ne),this._injector.get(S.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Me),this._injector.get(je),this._injector.get(Ue)}},It(S.UniverSheetsHyperLinkUIPlugin,"pluginName",Ae),It(S.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),S.UniverSheetsHyperLinkUIPlugin=Fn([s.DependentOn(g.UniverSheetsHyperLinkPlugin,q.UniverDocsUIPlugin),ft(1,s.Inject(s.Injector)),ft(2,s.IConfigService)],S.UniverSheetsHyperLinkUIPlugin),S.CloseHyperLinkPopupOperation=ve,S.InsertHyperLinkOperation=ke,S.InsertLinkShortcut=We,S.OpenHyperLinkEditPanelOperation=Oe,S.SheetsHyperLinkSidePanelService=Ve,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
189
-
190
-
191
- // /home/runner/work/univer-presets/univer-presets/packages/preset-sheets-hyper-link/node_modules/@univerjs/sheets-hyper-link-ui/facade
192
-
193
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
194
-
195
-