@univerjs/sheets-ui 0.8.0-nightly.202506061607 → 0.8.0-nightly.202506081606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +190 -169
- package/lib/index.js +190 -169
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
`,paragraphs:[{startIndex:r.length}],customRanges:[i]}}let o=n.replace(/(\r\n|\n)/g,"\r");o.endsWith(`\r
|
|
21
21
|
`)||(o+=`\r
|
|
22
22
|
`);const e=[];for(let t=0;t<o.length;t++)o[t]==="\r"&&e.push({startIndex:t});return{dataStream:o,paragraphs:e,sectionBreaks:[{startIndex:o.indexOf(`
|
|
23
|
-
`)}]}}var FS=Object.getOwnPropertyDescriptor,jS=(n,o,e,t)=>{for(var r=t>1?void 0:t?FS(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},Fe=(n,o)=>(e,t)=>o(e,t,n);const zS=[m.InsertColMutation.id,m.InsertRowMutation.id,m.RemoveColMutation.id,m.RemoveRowMutation.id,m.MoveRangeMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id];let In=class extends a.RxDisposable{constructor(o,e,t,r,i,s,l,c,d,u){super();E(this,"_refreshOptionalPaste$",new O.Subject);E(this,"refreshOptionalPaste$",this._refreshOptionalPaste$.asObservable());this._injector=o,this._instanceService=e,this._renderManagerService=t,this._commandService=r,this._contextService=i,this._configService=s,this._sheetClipboardService=l,this._messageService=c,this._localService=d,this._uiPartsService=u,this._init(),this._initCommandListener(),this._initUIComponents(),this._pasteWithDoc()}refreshOptionalPaste(){this._refreshOptionalPaste$.next(Math.random())}_pasteWithDoc(){var t;const o=r=>{r.onPaste$.pipe(O.takeUntil(this.dispose$)).subscribe(i=>{var u,h;if(!ae(this._contextService))return;i.event.preventDefault();const s=i.event,l=(u=s.clipboardData)==null?void 0:u.getData("text/html"),c=(h=s.clipboardData)==null?void 0:h.getData("text/plain"),d=this._resolveClipboardFiles(s.clipboardData);this._commandService.executeCommand(qr.id,{htmlContent:l,textContent:c,files:d})})};let e=(t=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:t.with(J.DocSelectionRenderService);e&&o(e),this._renderManagerService.created$.subscribe(r=>{var i;r.unitId===a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(e=(i=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:i.with(J.DocSelectionRenderService),e&&o(e))})}_resolveClipboardFiles(o){if(!o)return;const e=Array.from(o.items).map(t=>t.kind==="file"?t.getAsFile():void 0).filter(Boolean);return e.length>0?e:void 0}_init(){[Le,Oo,Be].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[nn,rn,Pt,on,qr,_l].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const o=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>o.forEach(e=>e.dispose())})}_initCopyingHooks(){const o=this;let e=null;return{id:ge.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,r){e=o._getWorksheet(t,r)},onCopyCellContent(t,r){var l,c,d,u;const i=e.getCell(t,r);return(c=(l=i==null?void 0:i.p)==null?void 0:l.body)!=null&&c.paragraphs||(u=(d=i==null?void 0:i.p)==null?void 0:d.body)!=null&&u.textRuns?J.convertBodyToHtml(i.p):i?a.extractPureTextFromCell(i):""},onCopyCellStyle:(t,r,i,s)=>{const l={};(i||s)&&(l.rowspan=`${i||1}`,l.colspan=`${s||1}`);const c=e.getMergedCell(t,r),d=e.getComposedCellStyle(t,r);let u="";if(d&&(u=a.handleStyleToString(d)),c){const h=c.endRow,g=c.endColumn,f=e.getRange(h,g).getTextStyle();if(f){const p=a.handleStyleToString(f);u?u+=p?`;${p}`:"":u=p}}return u&&(l.style=u),Object.keys(l).length?l:null},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null},getFilteredOutRows(t){var c;const{startRow:r,endRow:i}=t,s=(c=o._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getActiveSheet(),l=[];if(!s)return l;for(let d=r;d<=i;d++)s.getRowFiltered(d)&&l.push(d);return l}}}_initPastingHook(){const o=this;let e=null,t=null,r=null;return{id:ge.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:i,subUnitId:s,range:l}){r=o._getWorksheet(i,s),e=i,t=s;const c=o._configService.getConfig(m.MAX_CELL_PER_SHEET_KEY),d=l.rows[l.rows.length-1],u=l.cols[l.cols.length-1];return c&&d*u>c?(o._messageService.show({type:j.MessageType.Error,content:o._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(i,s){const{range:l}=i,c=[],d=[],u=r.getMaxRows(),h=u-1,g=l.rows[l.rows.length-1]-h,S=s.length-g,f=r.getRowManager();if(g>0){const C={};s.slice(S).forEach((w,P)=>{const{height:y}=w||{};y&&(C[P]={h:Number.parseFloat(y),hd:a.BooleanNumber.FALSE})});const b={startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1],endRow:l.rows[l.rows.length-1],startRow:u},R={unitId:e,subUnitId:t,range:b,rowInfo:C};c.push({id:m.InsertRowMutation.id,params:R}),d.push({id:m.RemoveRowMutation.id,params:{unitId:e,subUnitId:t,range:b}})}const p={},v={};if(s.slice(0,S).forEach((C,b)=>{var w,P;const{height:R}=C;if(R){const y=f.getRow(l.rows[0]+b),M=Number.parseFloat(R);if(y){const{h:x=a.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:A=0}=y,D=Math.max(x,A);M>D?(p[b+l.rows[0]]=M,v[b+l.rows[0]]=D):(p[b+l.rows[0]]=D,v[b+l.rows[0]]=D)}else p[b+l.rows[0]]=M,v[b+l.rows[0]]=(P=(w=f.getRow(l.rows[0]+b))==null?void 0:w.h)!=null?P:a.DEFAULT_WORKSHEET_ROW_HEIGHT}}),Object.keys(p).length){const C={unitId:e,subUnitId:t,ranges:[{startRow:l.rows[0],endRow:Math.min(l.rows[l.rows.length-1],u),startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1]}],rowHeight:p};c.push({id:m.SetWorksheetRowHeightMutation.id,params:C}),d.push({id:m.SetWorksheetRowHeightMutation.id,params:{...C,rowHeight:v}})}return{redos:c,undos:d}},onPasteColumns(i,s,l){var R;const{range:c}=i,d=[],u=[],h=r.getMaxColumns(),g=h-1,S=c.cols[c.cols.length-1]-g,f=s.length-S,p=(R=o._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?R:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,v=c.cols,C=v[0];if(S>0){const w={startRow:c.rows[0],endRow:c.rows[c.rows.length-1],endColumn:c.cols[c.cols.length-1],startColumn:h},P={unitId:e,subUnitId:t,range:w,colInfo:s.slice(f).map((y,M)=>({w:y.width?Math.max(+y.width,r.getColumnWidth(v[M])):p,hd:a.BooleanNumber.FALSE}))};d.push({id:m.InsertColMutation.id,params:P}),u.push({id:m.RemoveColMutation.id,params:{unitId:e,subUnitId:t,range:w}})}const b={unitId:e,subUnitId:t,ranges:[{startRow:c.rows[0],endRow:c.rows[c.rows.length-1],startColumn:c.cols[0],endColumn:Math.min(c.cols[c.cols.length-1],h)}]};if(s.length>0){const w={...b,colWidth:s.slice(0,f).reduce((y,M,x)=>{var A;return y[x+C]=M.width?Math.max(+M.width,(A=r.getColumnWidth(v[x]))!=null?A:p):p,y},{})},P={...b,colWidth:s.slice(0,f).reduce((y,M,x)=>{var A;return y[x+C]=(A=r.getColumnWidth(v[x]))!=null?A:p,y},{})};d.push({id:m.SetWorksheetColWidthMutation.id,params:w}),u.push({id:m.SetWorksheetColWidthMutation.id,params:P})}return{redos:d,undos:u}},onPastePlainText(i,s,l){return o._onPastePlainText(i,s,l)},onPasteCells(i,s,l,c){return o._onPasteCells(i,s,l,c)},onAfterPaste(i){r=null}}}_generateDocumentDataModelSnapshot(o){var l,c;const e=(l=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._instanceService,this._renderManagerService))==null?void 0:l.getCurrentParam();if(e==null)return null;const{skeleton:t}=e,r=(c=t.getBlankCellDocumentModel())==null?void 0:c.documentModel,s={...r==null?void 0:r.getSnapshot(),...o};return r==null||r.reset(s),r==null?void 0:r.getSnapshot()}_onPastePlainText(o,e,t){const{range:r,unitId:i,subUnitId:s}=o;let l;if(/\r|\n/.test(e)||a.Tools.isLegalUrl(e)){const d=BS(e),u=this._generateDocumentDataModelSnapshot({body:d});l={[r.rows[0]]:{[r.cols[0]]:{p:u}}}}else a.isFormulaString(e)?l={[r.rows[0]]:{[r.cols[0]]:{f:e}}}:l={[r.rows[0]]:{[r.cols[0]]:{v:e}}};const c={unitId:i,subUnitId:s,cellValue:l};return{redos:[{id:m.SetRangeValuesMutation.id,params:c}],undos:[{id:m.SetRangeValuesMutation.id,params:m.SetRangeValuesUndoMutationFactory(this._injector,c)}]}}_onPasteCells(o,e,t,r){return this._injector.invoke(i=>WS(o,e,t,r,i))}_initSpecialPasteHooks(){const o=this,e={id:ge.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,l,c)=>this._injector.invoke(d=>xc(l,s,c,d))},t={id:ge.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells:(s,l,c)=>{const d=[],u=[],{undos:h,redos:g}=this._injector.invoke(C=>Ac(l,c,C));d.push(...g),u.push(...h);const{undos:S,redos:f}=this._injector.invoke(C=>Ni(l,c,C));d.push(...f),u.push(...S);const{undos:p,redos:v}=this._injector.invoke(C=>Oc(l,s,c,C));return d.push(...v),u.push(...p),{undos:u,redos:d}}},r={id:ge.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,l,c){var x,A;const d=o._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=d.getUnitId(),h=(x=d.getActiveSheet())==null?void 0:x.getSheetId();if(!u||!h)throw new Error("Cannot find unitId or subUnitId");const g=[],S=[],f=o._getWorksheet(u,h),{range:p}=s,v=p.cols,C=v[0],b=f.getMaxColumns(),R=p.cols[p.cols.length-1]-b,w=l.length-R,P=(A=o._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?A:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,y={unitId:u,subUnitId:h,ranges:[{startRow:p.rows[0],endRow:Math.min(p.cols[p.cols.length-1],b),startColumn:p.cols[0],endColumn:p.cols[p.cols.length-1]}],colWidth:l.slice(0,w).reduce((D,k,V)=>{var W;return D[V+C]=k.width?Math.max(+k.width,(W=f.getColumnWidth(v[V]))!=null?W:P):P,D},{})},M={unitId:u,subUnitId:h,ranges:[{startRow:p.rows[0],endRow:Math.min(p.cols[p.cols.length-1],b),startColumn:p.cols[0],endColumn:p.cols[p.cols.length-1]}],colWidth:l.slice(0,w).reduce((D,k,V)=>{var W;return D[V+C]=(W=f.getColumnWidth(v[V]))!=null?W:P,D},{})};return g.push({id:m.SetWorksheetColWidthMutation.id,params:y}),S.push({id:m.SetWorksheetColWidthMutation.id,params:M}),{redos:g,undos:S}}},i={id:ge.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells:(s,l,c,d)=>{o._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);const u=[],h=[],{range:g,unitId:S,subUnitId:f}=l,p=new a.ObjectMatrix;c.forValue((w,P,y)=>{const M=y.s;if(typeof M=="object"){const x=a.Tools.deepClone(y);x.s&&(x.s={...M,bd:null}),p.setValue(g.rows[w],g.cols[P],x)}});const v={unitId:S,subUnitId:f,cellValue:p.getData()};u.push({id:m.SetRangeValuesMutation.id,params:v});const C=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,v);h.push({id:m.SetRangeValuesMutation.id,params:C});const{undos:b,redos:R}=this._injector.invoke(w=>Ni(l,c,w));return h.push(...b),u.push(...R),{redos:u,undos:h}}};return[e,t,r,i]}_getWorksheet(o,e){var r;const t=(r=this._instanceService.getUniverSheetInstance(o))==null?void 0:r.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${o} and subUnitId ${e}.`);return t}_initCommandListener(){var e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===vt.id?this._sheetClipboardService.removeMarkSelection():zS.includes(t.id)&&this._sheetClipboardService.removeMarkSelection()}));const o=this._configService.getConfig(He);(e=o==null?void 0:o.clipboardConfig)!=null&&e.hidePasteOptions||(this.disposeWithMe(this._commandService.onCommandExecuted(t=>{VS.includes(t.id)&&this._sheetClipboardService.disposePasteOptionsCache()})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===We.id){if(!this._sheetClipboardService.getPasteMenuVisible())return;const i=t.params.unitId,s=this._sheetClipboardService.getPasteOptionsCache(),l=s==null?void 0:s.target.unitId;i===l&&this._refreshOptionalPaste$.next(Math.random())}})))}_initUIComponents(){var e;const o=this._configService.getConfig(He);(e=o==null?void 0:o.clipboardConfig)!=null&&e.hidePasteOptions||this.disposeWithMe(this._uiPartsService.registerComponent(_.BuiltInUIPart.CONTENT,()=>_.connectInjector(HS,this._injector)))}};In=jS([Fe(0,a.Inject(a.Injector)),Fe(1,a.IUniverInstanceService),Fe(2,T.IRenderManagerService),Fe(3,a.ICommandService),Fe(4,a.IContextService),Fe(5,a.IConfigService),Fe(6,Ve),Fe(7,_.IMessageService),Fe(8,a.Inject(a.LocaleService)),Fe(9,_.IUIPartsService)],In);var XS=Object.getOwnPropertyDescriptor,YS=(n,o,e,t)=>{for(var r=t>1?void 0:t?XS(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},va=(n,o)=>(e,t)=>o(e,t,n);exports.DragManagerService=class extends a.Disposable{constructor(e,t){super();E(this,"_currentCell$",new O.Subject);E(this,"currentCell$",this._currentCell$.asObservable().pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));E(this,"_endCell$",new O.Subject);E(this,"endCell$",this._endCell$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._endCell$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||(this._currentCell$.next(null),this._endCell$.next(null))}))}_calcActiveCell(e,t){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return null;const i=r.getActiveSheet();if(!i)return;const s=this._renderManagerService.getRenderById(r.getUnitId());if(!s)return;const l=s.with(exports.SheetSkeletonManagerService).getCurrentParam(),d=s.with(exports.SheetScrollManagerService).getCurrentScrollState();if(!(!l||!d||!s))return Dl(s,r,i,l,e,t)}onDragOver(e){const{offsetX:t,offsetY:r,dataTransfer:i}=e,s=this._calcActiveCell(t,r);if(!s){this._currentCell$.next(null);return}const{location:l,position:c}=s;this._currentCell$.next({location:l,position:c,dataTransfer:i})}onDrop(e){const{offsetX:t,offsetY:r,dataTransfer:i}=e,s=this._calcActiveCell(t,r);if(!s){this._endCell$.next(null);return}const{location:l,position:c}=s;this._endCell$.next({location:l,position:c,dataTransfer:i})}};exports.DragManagerService=YS([va(0,a.IUniverInstanceService),va(1,T.IRenderManagerService)],exports.DragManagerService);var GS=Object.getOwnPropertyDescriptor,ZS=(n,o,e,t)=>{for(var r=t>1?void 0:t?GS(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},ci=(n,o)=>(e,t)=>o(e,t,n);exports.DragRenderController=class extends a.Disposable{constructor(o,e,t,r){super(),this._context=o,this._renderManagerService=e,this._dragManagerService=t,this._sheetSkeletonManagerService=r,this._initDragEvent()}_initDragEvent(){const o=new a.DisposableCollection,e=t=>{if(o.dispose(),!t)return;const{scene:r}=this._context,i=r.onDragOver$.subscribeEvent(l=>{this._dragManagerService.onDragOver(l)}),s=r.onDrop$.subscribeEvent(l=>{this._dragManagerService.onDrop(l)});o.add({dispose(){i.unsubscribe(),s.unsubscribe()}})};e(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{e(t)}))}};exports.DragRenderController=ZS([ci(1,T.IRenderManagerService),ci(2,a.Inject(exports.DragManagerService)),ci(3,a.Inject(exports.SheetSkeletonManagerService))],exports.DragRenderController);const Is=(n,o)=>{var h,g,S,f,p;const t=o.findNodePositionByCharIndex(n.startOffset,!0,n.segmentId,-1),r=o.getSkeletonData();let i=n.endOffset;if(n.segmentId){const v=(p=Array.from((g=(h=r==null?void 0:r.skeFooters.get(n.segmentId))==null?void 0:h.values())!=null?g:[])[0])!=null?p:Array.from((f=(S=r==null?void 0:r.skeHeaders.get(n.segmentId))==null?void 0:S.values())!=null?f:[])[0];v&&(i=Math.min(v.ed,i))}const s=o.findNodePositionByCharIndex(i,!0,n.segmentId,-1);if(!s||!t)return;const l={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},c=new J.NodePositionConvertToCursor(l,o),{borderBoxPointGroup:d}=c.getRangePointData(t,s);return J.getLineBounding(d).map(v=>({top:v.top,bottom:v.bottom,left:v.left,right:v.right}))},KS=(n,o,e=-1)=>{const t=o.findPositionByGlyph(n,e);if(!t)return;const r={...t,isBack:!0},i={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},s=new J.NodePositionConvertToCursor(i,o),{borderBoxPointGroup:l}=s.getRangePointData(r,r),d=J.getLineBounding(l)[0];return{top:d.top,bottom:d.bottom,left:d.left,right:d.right}},qS=(n,o,e=0,t=0)=>{const r=Is({startOffset:o.startIndex,endOffset:o.endIndex+1},n);if(r)return{rects:r.map(i=>({top:i.top+t,bottom:i.bottom+t,left:i.left+e,right:i.right+e})),range:o}},QS=(n,o,e=0,t=0)=>{var h,g,S;const r=n.findNodeByCharIndex(o.startIndex),i=r==null?void 0:r.parent,s=i==null?void 0:i.parent,l=s==null?void 0:s.parent,c=l==null?void 0:l.lines.find(f=>f.paragraphStart&&f.paragraphIndex===o.startIndex),d=(S=(g=(h=c==null?void 0:c.divides)==null?void 0:h[0])==null?void 0:g.glyphGroup)==null?void 0:S[0];if(!d||!d)return;const u=KS(d,n);if(u)return{rect:{top:u.top+t,bottom:u.bottom+t,left:u.left+e,right:u.right+e},segmentId:void 0,segmentPageIndex:-1,paragraph:o}},Dc=(n,o=0,e=0)=>{var l,c,d,u,h,g,S;const t=n.getViewModel().getDataModel(),r=(d=(c=(l=t.getBody())==null?void 0:l.customRanges)==null?void 0:c.filter(f=>f.rangeType===a.CustomRangeType.HYPERLINK))!=null?d:[],i=(g=(h=(u=t.getBody())==null?void 0:u.paragraphs)==null?void 0:h.filter(f=>{var p;return((p=f.bullet)==null?void 0:p.listType.indexOf(a.PresetListType.CHECK_LIST))===0}))!=null?g:[],s=(S=n.getSkeletonData())==null?void 0:S.pages[0].skeDrawings;return{links:r.map(f=>qS(n,f,o,e)).filter(Boolean),checkLists:i.map(f=>QS(n,f,o,e)).filter(Boolean),drawings:s?Array.from(s.keys()).map(f=>({drawingId:f,rect:{top:s.get(f).aTop,bottom:s.get(f).aTop+s.get(f).width,left:s.get(f).aLeft,right:s.get(f).aLeft+s.get(f).height},drawing:s.get(f)})):[]}};function kc(n,o,e){var d,u,h,g,S,f;const t=(h=(u=(d=o.documentSkeleton)==null?void 0:d.getSkeletonData())==null?void 0:u.pages[0].height)!=null?h:0,r=(f=(S=(g=o.documentSkeleton)==null?void 0:g.getSkeletonData())==null?void 0:S.pages[0].width)!=null?f:0,i=o.verticalAlign,s=o.horizontalAlign;let l=0;switch(i){case a.VerticalAlign.UNSPECIFIED:case a.VerticalAlign.BOTTOM:l=n.mergeInfo.endY-n.mergeInfo.startY-t;break;case a.VerticalAlign.MIDDLE:l=(n.mergeInfo.endY-n.mergeInfo.startY-t)/2;break}let c=0;switch(s){case a.HorizontalAlign.RIGHT:c=n.mergeInfo.endX-n.mergeInfo.startX-r;break;case a.HorizontalAlign.CENTER:c=(n.mergeInfo.endX-n.mergeInfo.startX-r)/2;break;case a.HorizontalAlign.UNSPECIFIED:{e&&(c=n.mergeInfo.endX-n.mergeInfo.startX-r);break}}return{paddingLeft:c,paddingTop:l}}const JS=(n,o,e,t,r,i)=>{var k,V,W;const s=n.get(a.IUniverInstanceService),l=n.get(T.IRenderManagerService),c=s.getUnit(o,a.UniverInstanceType.UNIVER_SHEET);if(!c)return null;const d=c.getSheetBySheetId(e);if(!d)return null;const u=l.getRenderById(c.getUnitId()),h=u==null?void 0:u.with(exports.SheetSkeletonManagerService).getSkeletonParam(d.getSheetId()),g=h==null?void 0:h.skeleton;if(!g||!u)return;const S=g.getFont(t,r),f=S==null?void 0:S.documentSkeleton;if(!f)return null;const p=(V=(k=f.getViewModel().getBody())==null?void 0:k.customRanges)==null?void 0:V.find(N=>N.rangeId===i);if(!p)return null;const v=J.DOC_VERTICAL_PADDING,C=g.getCellWithCoordByIndex(t,r);let{actualColumn:b,actualRow:R}=C;g.overflowCache.forValue((N,U,L)=>{L.startRow<=R&&L.endRow>=R&&L.startColumn<=b&&L.endColumn>=b&&(b=U,R=N)});const w=g.getCellWithCoordByIndex(R,b),P=d.getCell(w.actualRow,w.actualColumn),{topOffset:y=0,leftOffset:M=0}=(W=P==null?void 0:P.fontRenderExtension)!=null?W:{},{paddingLeft:x,paddingTop:A}=kc(w,S,!1),D=Is({startOffset:p.startIndex,endOffset:p.endIndex},f);return{rects:D==null?void 0:D.map(N=>({top:N.top+w.mergeInfo.startY+A+y+v,bottom:N.bottom+w.mergeInfo.startY+A+y+v,left:N.left+w.mergeInfo.startX+x+M,right:N.right+w.mergeInfo.startX+x+M})),customRange:p,label:f.getViewModel().getBody().dataStream.slice(p.startIndex,p.endIndex+1)}},$S=(n,o,e,t,r,i)=>{var M,x,A;const s=n.get(he),l=s.getEditCellState();if(!l||!s.isVisible().visible)return null;const{editorUnitId:d,unitId:u,sheetId:h,row:g,column:S}=l;if(o!==u||e!==h||g!==t||S!==r)return null;const f=n.get(T.IRenderManagerService),p=f.getRenderById(d),v=f.getRenderById(o);if(!p||!v)return null;const C=p.with(Ce.DocSkeletonManagerService).getSkeleton(),b=(M=v.with(exports.SheetSkeletonManagerService).getSkeletonParam(h))==null?void 0:M.skeleton;if(!C||!b)return null;const R=(A=(x=C.getViewModel().getBody())==null?void 0:x.customRanges)==null?void 0:A.find(D=>D.rangeId===i);if(!R)return null;const w=4,P=Is({startOffset:R.startIndex,endOffset:R.endIndex},C),y=p.engine.getCanvasElement().getBoundingClientRect();return{rects:P==null?void 0:P.map(D=>({top:D.top+y.top-w,bottom:D.bottom+y.top+w,left:D.left+y.left,right:D.right+y.left})),customRange:R,label:C.getViewModel().getBody().dataStream.slice(R.startIndex,R.endIndex+1)}};var ef=Object.getOwnPropertyDescriptor,tf=(n,o,e,t)=>{for(var r=t>1?void 0:t?ef(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},Ca=(n,o)=>(e,t)=>o(e,t,n);function Et(n){const{workbook:o,worksheet:e,...t}=n;return t}exports.HoverManagerService=class extends a.Disposable{constructor(e,t){super();E(this,"_currentCell$",new O.BehaviorSubject(null));E(this,"_currentRichText$",new O.BehaviorSubject(null));E(this,"_currentClickedCell$",new O.Subject);E(this,"_currentDbClickedCell$",new O.Subject);E(this,"_currentCellWithEvent$",new O.Subject);E(this,"_currentPointerDownCell$",new O.Subject);E(this,"_currentPointerUpCell$",new O.Subject);E(this,"_currentHoveredRowHeader$",new O.BehaviorSubject(null));E(this,"_currentHoveredColHeader$",new O.BehaviorSubject(null));E(this,"_currentRowHeaderClick$",new O.Subject);E(this,"_currentColHeaderClick$",new O.Subject);E(this,"_currentRowHeaderDbClick$",new O.Subject);E(this,"_currentColHeaderDbClick$",new O.Subject);E(this,"_currentRowHeaderPointerDown$",new O.Subject);E(this,"_currentColHeaderPointerDown$",new O.Subject);E(this,"_currentRowHeaderPointerUp$",new O.Subject);E(this,"_currentColHeaderPointerUp$",new O.Subject);E(this,"currentCell$",this._currentCell$.asObservable().pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));E(this,"currentRichTextNoDistinct$",this._currentRichText$.pipe(O.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));E(this,"currentRichText$",this._currentRichText$.pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h,g,S,f,p,v,C,b,R,w,P;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)&&((g=e==null?void 0:e.customRange)==null?void 0:g.rangeId)===((S=t==null?void 0:t.customRange)==null?void 0:S.rangeId)&&((f=e==null?void 0:e.bullet)==null?void 0:f.startIndex)===((p=t==null?void 0:t.bullet)==null?void 0:p.startIndex)&&((v=e==null?void 0:e.customRange)==null?void 0:v.startIndex)===((C=t==null?void 0:t.customRange)==null?void 0:C.startIndex)&&((b=e==null?void 0:e.customRange)==null?void 0:b.endIndex)===((R=t==null?void 0:t.customRange)==null?void 0:R.endIndex)&&((w=e==null?void 0:e.drawing)==null?void 0:w.drawingId)===((P=t==null?void 0:t.drawing)==null?void 0:P.drawingId)}),O.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));E(this,"currentCellPosWithEvent$",this._currentCellWithEvent$.pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)}),O.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,event:e.event})));E(this,"currentPosition$",this._currentCell$.asObservable());E(this,"currentClickedCell$",this._currentClickedCell$.asObservable());E(this,"currentDbClickedCell$",this._currentDbClickedCell$.asObservable());E(this,"currentPointerDownCell$",this._currentPointerDownCell$.asObservable());E(this,"currentPointerUpCell$",this._currentPointerUpCell$.asObservable());E(this,"currentHoveredRowHeader$",this._currentHoveredRowHeader$.asObservable());E(this,"currentHoveredColHeader$",this._currentHoveredColHeader$.asObservable());E(this,"currentRowHeaderClick$",this._currentRowHeaderClick$.asObservable());E(this,"currentColHeaderClick$",this._currentColHeaderClick$.asObservable());E(this,"currentRowHeaderDbClick$",this._currentRowHeaderDbClick$.asObservable());E(this,"currentColHeaderDbClick$",this._currentColHeaderDbClick$.asObservable());E(this,"currentRowHeaderPointerDown$",this._currentRowHeaderPointerDown$.asObservable());E(this,"currentColHeaderPointerDown$",this._currentColHeaderPointerDown$.asObservable());E(this,"currentRowHeaderPointerUp$",this._currentRowHeaderPointerUp$.asObservable());E(this,"currentColHeaderPointerUp$",this._currentColHeaderPointerUp$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._currentClickedCell$.complete(),this._currentPointerDownCell$.complete(),this._currentPointerUpCell$.complete(),this._currentCellWithEvent$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t,r;((t=this._currentCell$.getValue())==null?void 0:t.location.unitId)===e.getUnitId()&&this._currentCell$.next(null),((r=this._currentRichText$.getValue())==null?void 0:r.location.unitId)===e.getUnitId()&&this._currentRichText$.next(null)}))}_getCalcDeps(e){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const r=t.getActiveSheet();if(!r)return null;const i=this._renderManagerService.getRenderById(t.getUnitId());if(!i)return null;const s=i.with(exports.SheetSkeletonManagerService).getSkeletonParam(r.getSheetId());if(!s)return null;const l=i.with(exports.SheetScrollManagerService);if(!(!(l!=null&&l.getCurrentScrollState())||!i))return{currentRender:i,workbook:t,worksheet:r,skeletonParam:s}}_calcActiveCell(e,t,r,i,s,l){var y,M,x;const c=Dl(e,t,r,i,s,l),d=i.skeleton;if(!c)return null;const{position:u,overflowLocation:h,location:g}=c,S=d.getFont(h.row,h.col);let f=null,p=null,v=null;const C=d.getCellWithCoordByIndex(h.row,h.col),b=r.getCell(h.row,h.col),{topOffset:R=0,leftOffset:w=0}=(y=b==null?void 0:b.fontRenderExtension)!=null?y:{};if(S!=null&&S.documentSkeleton){const{paddingLeft:A,paddingTop:D}=kc(C,S,(b==null?void 0:b.v)!==null&&(b==null?void 0:b.v)!==void 0?!Number.isNaN(+b.v):!1),k=Dc(S.documentSkeleton,A,D),V=s-u.startX-w,W=l-u.startY-R;f=k.links.find(N=>N.rects.some(U=>U.left<=V&&V<=U.right&&U.top<=W&&W<=U.bottom)),p=k.checkLists.find(N=>N.rect.left<=V&&V<=N.rect.right&&N.rect.top<=W&&W<=N.rect.bottom),v=k.drawings.find(N=>N.rect.left<=V&&V<=N.rect.right&&N.rect.top<=W&&W<=N.rect.bottom)}const P=(x=(M=f==null?void 0:f.rects.pop())!=null?M:p==null?void 0:p.rect)!=null?x:v==null?void 0:v.rect;return{location:g,position:u,overflowLocation:h,customRange:f==null?void 0:f.range,bullet:p==null?void 0:p.paragraph,drawing:v,rect:P&&{top:P.top+C.mergeInfo.startY+R,bottom:P.bottom+C.mergeInfo.startY+R,left:P.left+C.mergeInfo.startX+w,right:P.right+C.mergeInfo.startX+w}}}_calcActiveRowHeader(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,worksheet:l,skeletonParam:c}=i,{scaleY:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new T.Vector2(t,r)));if(!u||u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP&&u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getRowIndexByOffsetY(r,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}_calcActiveColHeader(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,worksheet:l,skeletonParam:c}=i,{scaleX:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new T.Vector2(t,r)));if(!u||u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT&&u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getColumnIndexByOffsetX(t,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}triggerPointerDown(e,t){const r=this._getCalcDeps(e);if(!r)return;const{currentRender:i,workbook:s,worksheet:l,skeletonParam:c}=r,d=this._calcActiveCell(i,s,l,c,t.offsetX,t.offsetY);if(d&&d.location){const{unitId:u,subUnitId:h,row:g,col:S}=Et(d.location);this._currentPointerDownCell$.next({unitId:u,subUnitId:h,row:g,col:S,event:t})}}triggerPointerUp(e,t){const r=this._getCalcDeps(e);if(!r)return;const{currentRender:i,workbook:s,worksheet:l,skeletonParam:c}=r,d=this._calcActiveCell(i,s,l,c,t.offsetX,t.offsetY);if(d){const u=Et(d.location);this._currentPointerUpCell$.next({...u,event:t})}}triggerMouseMove(e,t){const r=this._getCalcDeps(e);if(!r)return;const{currentRender:i,workbook:s,worksheet:l,skeletonParam:c}=r,d=this._calcActiveCell(i,s,l,c,t.offsetX,t.offsetY);this._currentCell$.next(d&&{location:Et(d.location),position:d.position}),this._currentRichText$.next(d&&{...d,location:Et(d.overflowLocation)}),this._currentCellWithEvent$.next(d&&{...d,location:Et(d.location),event:t})}triggerClick(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=i,u=this._calcActiveCell(s,l,c,d,t,r);u&&this._currentClickedCell$.next({...u,location:Et(u.location)})}triggerDbClick(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=i,u=this._calcActiveCell(s,l,c,d,t,r);u&&this._currentDbClickedCell$.next({...u,location:Et(u.location)})}triggerScroll(){this._currentCell$.next(null)}triggerRowHeaderClick(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderClick$.next(i)}triggerColHeaderClick(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderClick$.next(i)}triggerRowHeaderDbClick(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderDbClick$.next(i)}triggerColHeaderDbClick(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderDbClick$.next(i)}triggerRowHeaderMouseMove(e,t,r){this._currentHoveredRowHeader$.next(this._calcActiveRowHeader(e,t,r))}triggerColHeaderMouseMove(e,t,r){this._currentHoveredColHeader$.next(this._calcActiveColHeader(e,t,r))}triggerRowHeaderPoniterDown(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderPointerDown$.next(i)}triggerColHeaderPoniterDown(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderPointerDown$.next(i)}triggerRowHeaderPoniterUp(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderPointerUp$.next(i)}triggerColHeaderPoniterUp(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderPointerUp$.next(i)}};exports.HoverManagerService=tf([Ca(0,a.IUniverInstanceService),Ca(1,T.IRenderManagerService)],exports.HoverManagerService);var nf=Object.getOwnPropertyDescriptor,rf=(n,o,e,t)=>{for(var r=t>1?void 0:t?nf(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},Hn=(n,o)=>(e,t)=>o(e,t,n);const di="SHEET_FORCE_STRING_ALERT";let no=class extends a.Disposable{constructor(n,o,e,t,r,i){super(),this._context=n,this._hoverManagerService=o,this._cellAlertManagerService=e,this._localeService=t,this._zenZoneService=r,this._configService=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(n=>{var o,e;if(n){const r=this._context.unit.getActiveSheet();if(!r)return;const i=r.getCell(n.location.row,n.location.col);if((i==null?void 0:i.t)===a.CellValueType.FORCE_STRING&&i.v&&a.isRealNum(i.v)){const s=this._cellAlertManagerService.currentAlert.get(di),l=(o=s==null?void 0:s.alert)==null?void 0:o.location;if(l&&l.row===n.location.row&&l.col===n.location.col&&l.subUnitId===n.location.subUnitId&&l.unitId===n.location.unitId||(e=this._configService.getConfig(He))!=null&&e.disableForceStringAlert)return;this._cellAlertManagerService.showAlert({type:an.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n.location,width:200,height:74,key:di});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(di)}};no=rf([Hn(1,a.Inject(exports.HoverManagerService)),Hn(2,a.Inject(exports.CellAlertManagerService)),Hn(3,a.Inject(a.LocaleService)),Hn(4,_.IZenZoneService),Hn(5,a.IConfigService)],no);var of=Object.getOwnPropertyDescriptor,sf=(n,o,e,t)=>{for(var r=t>1?void 0:t?of(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},ui=(n,o)=>(e,t)=>o(e,t,n);let ro=class extends a.RxDisposable{constructor(n,o,e,t){super(),this._context=n,this._sheetSkeletonManagerService=o,this._sheetInterceptorService=e,this._configService=t,this._initViewModelIntercept()}_initViewModelIntercept(){const n={tl:{size:6,color:"#409f11"}};this.disposeWithMe(this._sheetInterceptorService.intercept(m.INTERCEPTOR_POINT.CELL_CONTENT,{priority:10,effect:a.InterceptorEffectEnum.Style,handler:(o,e,t)=>{var s,l,c;if(!((s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton))return t(o);const i=e.rawData;if(!i||i.v===null||i.v===void 0)return t(o);if(((o==null?void 0:o.t)===a.CellValueType.FORCE_STRING||(o==null?void 0:o.t)===a.CellValueType.STRING)&&a.isRealNum(i.v)){const d=e.workbook.getStyles().get(i.s);return _o.isTextFormat((l=d==null?void 0:d.n)==null?void 0:l.pattern)||(c=this._configService.getConfig(He))!=null&&c.disableForceStringMark||(o===i&&(o={...i}),o.markers={...o==null?void 0:o.markers,...n}),t(o)}return t(o)}}))}};ro=sf([ui(1,a.Inject(exports.SheetSkeletonManagerService)),ui(2,a.Inject(m.SheetInterceptorService)),ui(3,a.IConfigService)],ro);var af=Object.getOwnPropertyDescriptor,lf=(n,o,e,t)=>{for(var r=t>1?void 0:t?af(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},hi=(n,o)=>(e,t)=>o(e,t,n);exports.HoverRenderController=class extends a.Disposable{constructor(e,t,r,i){super();E(this,"_active",!1);this._context=e,this._hoverManagerService=t,this._sheetSkeletonManagerService=r,this._scrollManagerService=i,this._initPointerEvent(),this._initScrollEvent()}get active(){return this._active}_initPointerEvent(){const e=new a.DisposableCollection,t=r=>{if(e.dispose(),!r)return;const{mainComponent:i,unitId:s,components:l}=this._context;if(!i)return;e.add(i.onPointerEnter$.subscribeEvent(u=>{this._active=!0})),e.add(a.fromEventSubject(i.onPointerMove$).subscribe(u=>{this._active=!0,this._hoverManagerService.triggerMouseMove(s,u)})),e.add(i.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerDown(s,u)})),e.add(i.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerUp(s,u)})),e.add(i.onClick$.subscribeEvent(u=>{this._hoverManagerService.triggerClick(s,u.offsetX,u.offsetY)})),e.add(i.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerDbClick(s,u.offsetX,u.offsetY)})),e.add(i.onPointerLeave$.subscribeEvent(()=>{this._active=!1}));const c=l.get(ue.ROW),d=l.get(ue.COLUMN);c&&(e.add(c.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(c.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(c.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerRowHeaderClick(s,u.offsetX,u.offsetY)})),e.add(c.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderDbClick(s,u.offsetX,u.offsetY)}))),d&&(e.add(d.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(d.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(d.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerColHeaderClick(s,u.offsetX,u.offsetY)})),e.add(d.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderDbClick(s,u.offsetX,u.offsetY)})))};t(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(r=>{t(r)}))}_initScrollEvent(){this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(()=>this._hoverManagerService.triggerScroll()))}};exports.HoverRenderController=lf([hi(1,a.Inject(exports.HoverManagerService)),hi(2,a.Inject(exports.SheetSkeletonManagerService)),hi(3,a.Inject(exports.SheetScrollManagerService))],exports.HoverRenderController);var cf=Object.getOwnPropertyDescriptor,df=(n,o,e,t)=>{for(var r=t>1?void 0:t?cf(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},mi=(n,o)=>(e,t)=>o(e,t,n);let oo=class extends a.Disposable{constructor(n,o,e,t){super(),this._context=n,this._markSelectionService=o,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const n=[Se.id];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{n.includes(o.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((t,r)=>{t.exits.includes(o.id)&&this._markSelectionService.removeShape(r)})}))}_addRefreshListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(n=>{n&&this._markSelectionService.refreshShapes()}))}};oo=df([mi(1,a.Inject(Lt)),mi(2,a.ICommandService),mi(3,a.Inject(exports.SheetSkeletonManagerService))],oo);function Nc(){const n=ft();return n?I.jsx(uf,{workbook:n}):null}function uf(n){const{workbook:o}=n,[e,t]=H.useState([]),[r,i]=H.useState(""),s=H.useRef(new Map),l=_.useDependency(a.ICommandService),c=H.useCallback(()=>{const u=o.getActiveSheet().getSheetId(),h=o.getSheets(),g=o.getActiveSheet(),S=h.filter(f=>!f.isSheetHidden()).map((f,p)=>{var v;return{sheetId:f.getSheetId(),label:f.getName(),index:p,selected:g===f,color:(v=f.getTabColor())!=null?v:void 0}});if(t(S),i(u),s.current.has(u)){const f=s.current.get(u);f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})}s.current.clear()},[o]);H.useEffect(()=>c(),[c]);const d=H.useCallback(u=>{l.executeCommand(m.SetWorksheetActiveOperation.id,{unitId:o.getUnitId(),subUnitId:u})},[l,o]);return H.useEffect(()=>{const u=l.onCommandExecuted(h=>{switch(h.id){case m.SetWorksheetHideMutation.id:case m.RemoveSheetMutation.id:case m.SetWorksheetNameMutation.id:case m.InsertSheetMutation.id:case m.SetWorksheetOrderMutation.id:case m.SetWorksheetActiveOperation.id:c();break}});return()=>u.dispose()},[l,c]),I.jsx("div",{className:"univer-h-8 univer-w-full univer-overflow-x-scroll univer-bg-gray-100 dark:!univer-bg-gray-900",children:I.jsx("div",{className:"univer-flex univer-h-8 univer-flex-nowrap univer-items-center",children:e.map(u=>I.jsx("div",{ref:h=>{s.current.set(u.sheetId,h)},className:j.clsx(`
|
|
23
|
+
`)}]}}var FS=Object.getOwnPropertyDescriptor,jS=(n,o,e,t)=>{for(var r=t>1?void 0:t?FS(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},Fe=(n,o)=>(e,t)=>o(e,t,n);const zS=[m.InsertColMutation.id,m.InsertRowMutation.id,m.RemoveColMutation.id,m.RemoveRowMutation.id,m.MoveRangeMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id];let In=class extends a.RxDisposable{constructor(o,e,t,r,i,s,l,c,d,u){super();E(this,"_refreshOptionalPaste$",new O.Subject);E(this,"refreshOptionalPaste$",this._refreshOptionalPaste$.asObservable());this._injector=o,this._instanceService=e,this._renderManagerService=t,this._commandService=r,this._contextService=i,this._configService=s,this._sheetClipboardService=l,this._messageService=c,this._localService=d,this._uiPartsService=u,this._init(),this._initCommandListener(),this._initUIComponents(),this._pasteWithDoc()}refreshOptionalPaste(){this._refreshOptionalPaste$.next(Math.random())}_pasteWithDoc(){var t;const o=r=>{r.onPaste$.pipe(O.takeUntil(this.dispose$)).subscribe(i=>{var u,h;if(!ae(this._contextService))return;i.event.preventDefault();const s=i.event,l=(u=s.clipboardData)==null?void 0:u.getData("text/html"),c=(h=s.clipboardData)==null?void 0:h.getData("text/plain"),d=this._resolveClipboardFiles(s.clipboardData);this._commandService.executeCommand(qr.id,{htmlContent:l,textContent:c,files:d})})};let e=(t=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:t.with(J.DocSelectionRenderService);e&&o(e),this._renderManagerService.created$.subscribe(r=>{var i;r.unitId===a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(e=(i=this._renderManagerService.getRenderById(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:i.with(J.DocSelectionRenderService),e&&o(e))})}_resolveClipboardFiles(o){if(!o)return;const e=Array.from(o.items).map(t=>t.kind==="file"?t.getAsFile():void 0).filter(Boolean);return e.length>0?e:void 0}_init(){[Le,Oo,Be].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e))),[nn,rn,Pt,on,qr,_l].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const o=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>o.forEach(e=>e.dispose())})}_initCopyingHooks(){const o=this;let e=null;return{id:ge.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,r){e=o._getWorksheet(t,r)},onCopyCellContent(t,r){var l,c,d,u;const i=e.getCell(t,r);return(c=(l=i==null?void 0:i.p)==null?void 0:l.body)!=null&&c.paragraphs||(u=(d=i==null?void 0:i.p)==null?void 0:d.body)!=null&&u.textRuns?J.convertBodyToHtml(i.p):i?a.extractPureTextFromCell(i):""},onCopyCellStyle:(t,r,i,s)=>{const l={};(i||s)&&(l.rowspan=`${i||1}`,l.colspan=`${s||1}`);const c=e.getMergedCell(t,r),d=e.getComposedCellStyle(t,r);let u="";if(d&&(u=a.handleStyleToString(d)),c){const h=c.endRow,g=c.endColumn,f=e.getRange(h,g).getTextStyle();if(f){const p=a.handleStyleToString(f);u?u+=p?`;${p}`:"":u=p}}return u&&(l.style=u),Object.keys(l).length?l:null},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null},getFilteredOutRows(t){var c;const{startRow:r,endRow:i}=t,s=(c=o._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:c.getActiveSheet(),l=[];if(!s)return l;for(let d=r;d<=i;d++)s.getRowFiltered(d)&&l.push(d);return l}}}_initPastingHook(){const o=this;let e=null,t=null,r=null;return{id:ge.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:i,subUnitId:s,range:l}){r=o._getWorksheet(i,s),e=i,t=s;const c=o._configService.getConfig(m.MAX_CELL_PER_SHEET_KEY),d=l.rows[l.rows.length-1],u=l.cols[l.cols.length-1];return c&&d*u>c?(o._messageService.show({type:j.MessageType.Error,content:o._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(i,s){const{range:l}=i,c=[],d=[],u=r.getMaxRows(),h=u-1,g=l.rows[l.rows.length-1]-h,S=s.length-g,f=r.getRowManager();if(g>0){const C={};s.slice(S).forEach((w,P)=>{const{height:y}=w||{};y&&(C[P]={h:Number.parseFloat(y),hd:a.BooleanNumber.FALSE})});const b={startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1],endRow:l.rows[l.rows.length-1],startRow:u},R={unitId:e,subUnitId:t,range:b,rowInfo:C};c.push({id:m.InsertRowMutation.id,params:R}),d.push({id:m.RemoveRowMutation.id,params:{unitId:e,subUnitId:t,range:b}})}const p={},v={};if(s.slice(0,S).forEach((C,b)=>{var w,P;const{height:R}=C;if(R){const y=f.getRow(l.rows[0]+b),M=Number.parseFloat(R);if(y){const{h:x=a.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:A=0}=y,D=Math.max(x,A);M>D?(p[b+l.rows[0]]=M,v[b+l.rows[0]]=D):(p[b+l.rows[0]]=D,v[b+l.rows[0]]=D)}else p[b+l.rows[0]]=M,v[b+l.rows[0]]=(P=(w=f.getRow(l.rows[0]+b))==null?void 0:w.h)!=null?P:a.DEFAULT_WORKSHEET_ROW_HEIGHT}}),Object.keys(p).length){const C={unitId:e,subUnitId:t,ranges:[{startRow:l.rows[0],endRow:Math.min(l.rows[l.rows.length-1],u),startColumn:l.cols[0],endColumn:l.cols[l.cols.length-1]}],rowHeight:p};c.push({id:m.SetWorksheetRowHeightMutation.id,params:C}),d.push({id:m.SetWorksheetRowHeightMutation.id,params:{...C,rowHeight:v}})}return{redos:c,undos:d}},onPasteColumns(i,s,l){var R;const{range:c}=i,d=[],u=[],h=r.getMaxColumns(),g=h-1,S=c.cols[c.cols.length-1]-g,f=s.length-S,p=(R=o._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?R:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,v=c.cols,C=v[0];if(S>0){const w={startRow:c.rows[0],endRow:c.rows[c.rows.length-1],endColumn:c.cols[c.cols.length-1],startColumn:h},P={unitId:e,subUnitId:t,range:w,colInfo:s.slice(f).map((y,M)=>({w:y.width?Math.max(+y.width,r.getColumnWidth(v[M])):p,hd:a.BooleanNumber.FALSE}))};d.push({id:m.InsertColMutation.id,params:P}),u.push({id:m.RemoveColMutation.id,params:{unitId:e,subUnitId:t,range:w}})}const b={unitId:e,subUnitId:t,ranges:[{startRow:c.rows[0],endRow:c.rows[c.rows.length-1],startColumn:c.cols[0],endColumn:Math.min(c.cols[c.cols.length-1],h)}]};if(s.length>0){const w={...b,colWidth:s.slice(0,f).reduce((y,M,x)=>{var A;return y[x+C]=M.width?Math.max(+M.width,(A=r.getColumnWidth(v[x]))!=null?A:p):p,y},{})},P={...b,colWidth:s.slice(0,f).reduce((y,M,x)=>{var A;return y[x+C]=(A=r.getColumnWidth(v[x]))!=null?A:p,y},{})};d.push({id:m.SetWorksheetColWidthMutation.id,params:w}),u.push({id:m.SetWorksheetColWidthMutation.id,params:P})}return{redos:d,undos:u}},onPastePlainText(i,s,l){return o._onPastePlainText(i,s,l)},onPasteCells(i,s,l,c){return o._onPasteCells(i,s,l,c)},onAfterPaste(i){r=null}}}_generateDocumentDataModelSnapshot(o){var l,c;const e=(l=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._instanceService,this._renderManagerService))==null?void 0:l.getCurrentParam();if(e==null)return null;const{skeleton:t}=e,r=(c=t.getBlankCellDocumentModel())==null?void 0:c.documentModel,s={...r==null?void 0:r.getSnapshot(),...o};return r==null||r.reset(s),r==null?void 0:r.getSnapshot()}_onPastePlainText(o,e,t){const{range:r,unitId:i,subUnitId:s}=o;let l;if(/\r|\n/.test(e)||a.Tools.isLegalUrl(e)){const d=BS(e),u=this._generateDocumentDataModelSnapshot({body:d});l={[r.rows[0]]:{[r.cols[0]]:{p:u,v:null,f:null}}}}else if(a.isFormulaString(e))l={[r.rows[0]]:{[r.cols[0]]:{f:e,v:null,p:null}}};else{const d=a.numfmt.parseNumber(e);d!=null&&d.z?l={[r.rows[0]]:{[r.cols[0]]:{v:d.v,s:{n:{pattern:d.z}},f:null}}}:l={[r.rows[0]]:{[r.cols[0]]:{v:e,f:null}}}}const c={unitId:i,subUnitId:s,cellValue:l};return{redos:[{id:m.SetRangeValuesMutation.id,params:c}],undos:[{id:m.SetRangeValuesMutation.id,params:m.SetRangeValuesUndoMutationFactory(this._injector,c)}]}}_onPasteCells(o,e,t,r){return this._injector.invoke(i=>WS(o,e,t,r,i))}_initSpecialPasteHooks(){const o=this,e={id:ge.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,l,c)=>this._injector.invoke(d=>xc(l,s,c,d))},t={id:ge.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells:(s,l,c)=>{const d=[],u=[],{undos:h,redos:g}=this._injector.invoke(C=>Ac(l,c,C));d.push(...g),u.push(...h);const{undos:S,redos:f}=this._injector.invoke(C=>Ni(l,c,C));d.push(...f),u.push(...S);const{undos:p,redos:v}=this._injector.invoke(C=>Oc(l,s,c,C));return d.push(...v),u.push(...p),{undos:u,redos:d}}},r={id:ge.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,l,c){var x,A;const d=o._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=d.getUnitId(),h=(x=d.getActiveSheet())==null?void 0:x.getSheetId();if(!u||!h)throw new Error("Cannot find unitId or subUnitId");const g=[],S=[],f=o._getWorksheet(u,h),{range:p}=s,v=p.cols,C=v[0],b=f.getMaxColumns(),R=p.cols[p.cols.length-1]-b,w=l.length-R,P=(A=o._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?A:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,y={unitId:u,subUnitId:h,ranges:[{startRow:p.rows[0],endRow:Math.min(p.cols[p.cols.length-1],b),startColumn:p.cols[0],endColumn:p.cols[p.cols.length-1]}],colWidth:l.slice(0,w).reduce((D,k,V)=>{var W;return D[V+C]=k.width?Math.max(+k.width,(W=f.getColumnWidth(v[V]))!=null?W:P):P,D},{})},M={unitId:u,subUnitId:h,ranges:[{startRow:p.rows[0],endRow:Math.min(p.cols[p.cols.length-1],b),startColumn:p.cols[0],endColumn:p.cols[p.cols.length-1]}],colWidth:l.slice(0,w).reduce((D,k,V)=>{var W;return D[V+C]=(W=f.getColumnWidth(v[V]))!=null?W:P,D},{})};return g.push({id:m.SetWorksheetColWidthMutation.id,params:y}),S.push({id:m.SetWorksheetColWidthMutation.id,params:M}),{redos:g,undos:S}}},i={id:ge.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells:(s,l,c,d)=>{o._instanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);const u=[],h=[],{range:g,unitId:S,subUnitId:f}=l,p=new a.ObjectMatrix;c.forValue((w,P,y)=>{const M=y.s;if(typeof M=="object"){const x=a.Tools.deepClone(y);x.s&&(x.s={...M,bd:null}),p.setValue(g.rows[w],g.cols[P],x)}});const v={unitId:S,subUnitId:f,cellValue:p.getData()};u.push({id:m.SetRangeValuesMutation.id,params:v});const C=this._injector.invoke(m.SetRangeValuesUndoMutationFactory,v);h.push({id:m.SetRangeValuesMutation.id,params:C});const{undos:b,redos:R}=this._injector.invoke(w=>Ni(l,c,w));return h.push(...b),u.push(...R),{redos:u,undos:h}}};return[e,t,r,i]}_getWorksheet(o,e){var r;const t=(r=this._instanceService.getUniverSheetInstance(o))==null?void 0:r.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${o} and subUnitId ${e}.`);return t}_initCommandListener(){var e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===vt.id?this._sheetClipboardService.removeMarkSelection():zS.includes(t.id)&&this._sheetClipboardService.removeMarkSelection()}));const o=this._configService.getConfig(He);(e=o==null?void 0:o.clipboardConfig)!=null&&e.hidePasteOptions||(this.disposeWithMe(this._commandService.onCommandExecuted(t=>{VS.includes(t.id)&&this._sheetClipboardService.disposePasteOptionsCache()})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===We.id){if(!this._sheetClipboardService.getPasteMenuVisible())return;const i=t.params.unitId,s=this._sheetClipboardService.getPasteOptionsCache(),l=s==null?void 0:s.target.unitId;i===l&&this._refreshOptionalPaste$.next(Math.random())}})))}_initUIComponents(){var e;const o=this._configService.getConfig(He);(e=o==null?void 0:o.clipboardConfig)!=null&&e.hidePasteOptions||this.disposeWithMe(this._uiPartsService.registerComponent(_.BuiltInUIPart.CONTENT,()=>_.connectInjector(HS,this._injector)))}};In=jS([Fe(0,a.Inject(a.Injector)),Fe(1,a.IUniverInstanceService),Fe(2,T.IRenderManagerService),Fe(3,a.ICommandService),Fe(4,a.IContextService),Fe(5,a.IConfigService),Fe(6,Ve),Fe(7,_.IMessageService),Fe(8,a.Inject(a.LocaleService)),Fe(9,_.IUIPartsService)],In);var XS=Object.getOwnPropertyDescriptor,YS=(n,o,e,t)=>{for(var r=t>1?void 0:t?XS(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},va=(n,o)=>(e,t)=>o(e,t,n);exports.DragManagerService=class extends a.Disposable{constructor(e,t){super();E(this,"_currentCell$",new O.Subject);E(this,"currentCell$",this._currentCell$.asObservable().pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));E(this,"_endCell$",new O.Subject);E(this,"endCell$",this._endCell$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._endCell$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||(this._currentCell$.next(null),this._endCell$.next(null))}))}_calcActiveCell(e,t){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return null;const i=r.getActiveSheet();if(!i)return;const s=this._renderManagerService.getRenderById(r.getUnitId());if(!s)return;const l=s.with(exports.SheetSkeletonManagerService).getCurrentParam(),d=s.with(exports.SheetScrollManagerService).getCurrentScrollState();if(!(!l||!d||!s))return Dl(s,r,i,l,e,t)}onDragOver(e){const{offsetX:t,offsetY:r,dataTransfer:i}=e,s=this._calcActiveCell(t,r);if(!s){this._currentCell$.next(null);return}const{location:l,position:c}=s;this._currentCell$.next({location:l,position:c,dataTransfer:i})}onDrop(e){const{offsetX:t,offsetY:r,dataTransfer:i}=e,s=this._calcActiveCell(t,r);if(!s){this._endCell$.next(null);return}const{location:l,position:c}=s;this._endCell$.next({location:l,position:c,dataTransfer:i})}};exports.DragManagerService=YS([va(0,a.IUniverInstanceService),va(1,T.IRenderManagerService)],exports.DragManagerService);var GS=Object.getOwnPropertyDescriptor,ZS=(n,o,e,t)=>{for(var r=t>1?void 0:t?GS(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},ci=(n,o)=>(e,t)=>o(e,t,n);exports.DragRenderController=class extends a.Disposable{constructor(o,e,t,r){super(),this._context=o,this._renderManagerService=e,this._dragManagerService=t,this._sheetSkeletonManagerService=r,this._initDragEvent()}_initDragEvent(){const o=new a.DisposableCollection,e=t=>{if(o.dispose(),!t)return;const{scene:r}=this._context,i=r.onDragOver$.subscribeEvent(l=>{this._dragManagerService.onDragOver(l)}),s=r.onDrop$.subscribeEvent(l=>{this._dragManagerService.onDrop(l)});o.add({dispose(){i.unsubscribe(),s.unsubscribe()}})};e(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{e(t)}))}};exports.DragRenderController=ZS([ci(1,T.IRenderManagerService),ci(2,a.Inject(exports.DragManagerService)),ci(3,a.Inject(exports.SheetSkeletonManagerService))],exports.DragRenderController);const Is=(n,o)=>{var h,g,S,f,p;const t=o.findNodePositionByCharIndex(n.startOffset,!0,n.segmentId,-1),r=o.getSkeletonData();let i=n.endOffset;if(n.segmentId){const v=(p=Array.from((g=(h=r==null?void 0:r.skeFooters.get(n.segmentId))==null?void 0:h.values())!=null?g:[])[0])!=null?p:Array.from((f=(S=r==null?void 0:r.skeHeaders.get(n.segmentId))==null?void 0:S.values())!=null?f:[])[0];v&&(i=Math.min(v.ed,i))}const s=o.findNodePositionByCharIndex(i,!0,n.segmentId,-1);if(!s||!t)return;const l={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},c=new J.NodePositionConvertToCursor(l,o),{borderBoxPointGroup:d}=c.getRangePointData(t,s);return J.getLineBounding(d).map(v=>({top:v.top,bottom:v.bottom,left:v.left,right:v.right}))},KS=(n,o,e=-1)=>{const t=o.findPositionByGlyph(n,e);if(!t)return;const r={...t,isBack:!0},i={docsLeft:0,docsTop:0,pageMarginLeft:0,pageMarginTop:0},s=new J.NodePositionConvertToCursor(i,o),{borderBoxPointGroup:l}=s.getRangePointData(r,r),d=J.getLineBounding(l)[0];return{top:d.top,bottom:d.bottom,left:d.left,right:d.right}},qS=(n,o,e=0,t=0)=>{const r=Is({startOffset:o.startIndex,endOffset:o.endIndex+1},n);if(r)return{rects:r.map(i=>({top:i.top+t,bottom:i.bottom+t,left:i.left+e,right:i.right+e})),range:o}},QS=(n,o,e=0,t=0)=>{var h,g,S;const r=n.findNodeByCharIndex(o.startIndex),i=r==null?void 0:r.parent,s=i==null?void 0:i.parent,l=s==null?void 0:s.parent,c=l==null?void 0:l.lines.find(f=>f.paragraphStart&&f.paragraphIndex===o.startIndex),d=(S=(g=(h=c==null?void 0:c.divides)==null?void 0:h[0])==null?void 0:g.glyphGroup)==null?void 0:S[0];if(!d||!d)return;const u=KS(d,n);if(u)return{rect:{top:u.top+t,bottom:u.bottom+t,left:u.left+e,right:u.right+e},segmentId:void 0,segmentPageIndex:-1,paragraph:o}},Dc=(n,o=0,e=0)=>{var l,c,d,u,h,g,S;const t=n.getViewModel().getDataModel(),r=(d=(c=(l=t.getBody())==null?void 0:l.customRanges)==null?void 0:c.filter(f=>f.rangeType===a.CustomRangeType.HYPERLINK))!=null?d:[],i=(g=(h=(u=t.getBody())==null?void 0:u.paragraphs)==null?void 0:h.filter(f=>{var p;return((p=f.bullet)==null?void 0:p.listType.indexOf(a.PresetListType.CHECK_LIST))===0}))!=null?g:[],s=(S=n.getSkeletonData())==null?void 0:S.pages[0].skeDrawings;return{links:r.map(f=>qS(n,f,o,e)).filter(Boolean),checkLists:i.map(f=>QS(n,f,o,e)).filter(Boolean),drawings:s?Array.from(s.keys()).map(f=>({drawingId:f,rect:{top:s.get(f).aTop,bottom:s.get(f).aTop+s.get(f).width,left:s.get(f).aLeft,right:s.get(f).aLeft+s.get(f).height},drawing:s.get(f)})):[]}};function kc(n,o,e){var d,u,h,g,S,f;const t=(h=(u=(d=o.documentSkeleton)==null?void 0:d.getSkeletonData())==null?void 0:u.pages[0].height)!=null?h:0,r=(f=(S=(g=o.documentSkeleton)==null?void 0:g.getSkeletonData())==null?void 0:S.pages[0].width)!=null?f:0,i=o.verticalAlign,s=o.horizontalAlign;let l=0;switch(i){case a.VerticalAlign.UNSPECIFIED:case a.VerticalAlign.BOTTOM:l=n.mergeInfo.endY-n.mergeInfo.startY-t;break;case a.VerticalAlign.MIDDLE:l=(n.mergeInfo.endY-n.mergeInfo.startY-t)/2;break}let c=0;switch(s){case a.HorizontalAlign.RIGHT:c=n.mergeInfo.endX-n.mergeInfo.startX-r;break;case a.HorizontalAlign.CENTER:c=(n.mergeInfo.endX-n.mergeInfo.startX-r)/2;break;case a.HorizontalAlign.UNSPECIFIED:{e&&(c=n.mergeInfo.endX-n.mergeInfo.startX-r);break}}return{paddingLeft:c,paddingTop:l}}const JS=(n,o,e,t,r,i)=>{var k,V,W;const s=n.get(a.IUniverInstanceService),l=n.get(T.IRenderManagerService),c=s.getUnit(o,a.UniverInstanceType.UNIVER_SHEET);if(!c)return null;const d=c.getSheetBySheetId(e);if(!d)return null;const u=l.getRenderById(c.getUnitId()),h=u==null?void 0:u.with(exports.SheetSkeletonManagerService).getSkeletonParam(d.getSheetId()),g=h==null?void 0:h.skeleton;if(!g||!u)return;const S=g.getFont(t,r),f=S==null?void 0:S.documentSkeleton;if(!f)return null;const p=(V=(k=f.getViewModel().getBody())==null?void 0:k.customRanges)==null?void 0:V.find(N=>N.rangeId===i);if(!p)return null;const v=J.DOC_VERTICAL_PADDING,C=g.getCellWithCoordByIndex(t,r);let{actualColumn:b,actualRow:R}=C;g.overflowCache.forValue((N,U,L)=>{L.startRow<=R&&L.endRow>=R&&L.startColumn<=b&&L.endColumn>=b&&(b=U,R=N)});const w=g.getCellWithCoordByIndex(R,b),P=d.getCell(w.actualRow,w.actualColumn),{topOffset:y=0,leftOffset:M=0}=(W=P==null?void 0:P.fontRenderExtension)!=null?W:{},{paddingLeft:x,paddingTop:A}=kc(w,S,!1),D=Is({startOffset:p.startIndex,endOffset:p.endIndex},f);return{rects:D==null?void 0:D.map(N=>({top:N.top+w.mergeInfo.startY+A+y+v,bottom:N.bottom+w.mergeInfo.startY+A+y+v,left:N.left+w.mergeInfo.startX+x+M,right:N.right+w.mergeInfo.startX+x+M})),customRange:p,label:f.getViewModel().getBody().dataStream.slice(p.startIndex,p.endIndex+1)}},$S=(n,o,e,t,r,i)=>{var M,x,A;const s=n.get(he),l=s.getEditCellState();if(!l||!s.isVisible().visible)return null;const{editorUnitId:d,unitId:u,sheetId:h,row:g,column:S}=l;if(o!==u||e!==h||g!==t||S!==r)return null;const f=n.get(T.IRenderManagerService),p=f.getRenderById(d),v=f.getRenderById(o);if(!p||!v)return null;const C=p.with(Ce.DocSkeletonManagerService).getSkeleton(),b=(M=v.with(exports.SheetSkeletonManagerService).getSkeletonParam(h))==null?void 0:M.skeleton;if(!C||!b)return null;const R=(A=(x=C.getViewModel().getBody())==null?void 0:x.customRanges)==null?void 0:A.find(D=>D.rangeId===i);if(!R)return null;const w=4,P=Is({startOffset:R.startIndex,endOffset:R.endIndex},C),y=p.engine.getCanvasElement().getBoundingClientRect();return{rects:P==null?void 0:P.map(D=>({top:D.top+y.top-w,bottom:D.bottom+y.top+w,left:D.left+y.left,right:D.right+y.left})),customRange:R,label:C.getViewModel().getBody().dataStream.slice(R.startIndex,R.endIndex+1)}};var ef=Object.getOwnPropertyDescriptor,tf=(n,o,e,t)=>{for(var r=t>1?void 0:t?ef(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},Ca=(n,o)=>(e,t)=>o(e,t,n);function Et(n){const{workbook:o,worksheet:e,...t}=n;return t}exports.HoverManagerService=class extends a.Disposable{constructor(e,t){super();E(this,"_currentCell$",new O.BehaviorSubject(null));E(this,"_currentRichText$",new O.BehaviorSubject(null));E(this,"_currentClickedCell$",new O.Subject);E(this,"_currentDbClickedCell$",new O.Subject);E(this,"_currentCellWithEvent$",new O.Subject);E(this,"_currentPointerDownCell$",new O.Subject);E(this,"_currentPointerUpCell$",new O.Subject);E(this,"_currentHoveredRowHeader$",new O.BehaviorSubject(null));E(this,"_currentHoveredColHeader$",new O.BehaviorSubject(null));E(this,"_currentRowHeaderClick$",new O.Subject);E(this,"_currentColHeaderClick$",new O.Subject);E(this,"_currentRowHeaderDbClick$",new O.Subject);E(this,"_currentColHeaderDbClick$",new O.Subject);E(this,"_currentRowHeaderPointerDown$",new O.Subject);E(this,"_currentColHeaderPointerDown$",new O.Subject);E(this,"_currentRowHeaderPointerUp$",new O.Subject);E(this,"_currentColHeaderPointerUp$",new O.Subject);E(this,"currentCell$",this._currentCell$.asObservable().pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)})));E(this,"currentRichTextNoDistinct$",this._currentRichText$.pipe(O.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));E(this,"currentRichText$",this._currentRichText$.pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h,g,S,f,p,v,C,b,R,w,P;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)&&((g=e==null?void 0:e.customRange)==null?void 0:g.rangeId)===((S=t==null?void 0:t.customRange)==null?void 0:S.rangeId)&&((f=e==null?void 0:e.bullet)==null?void 0:f.startIndex)===((p=t==null?void 0:t.bullet)==null?void 0:p.startIndex)&&((v=e==null?void 0:e.customRange)==null?void 0:v.startIndex)===((C=t==null?void 0:t.customRange)==null?void 0:C.startIndex)&&((b=e==null?void 0:e.customRange)==null?void 0:b.endIndex)===((R=t==null?void 0:t.customRange)==null?void 0:R.endIndex)&&((w=e==null?void 0:e.drawing)==null?void 0:w.drawingId)===((P=t==null?void 0:t.drawing)==null?void 0:P.drawingId)}),O.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,customRange:e.customRange,bullet:e.bullet,rect:e.rect,drawing:e.drawing})));E(this,"currentCellPosWithEvent$",this._currentCellWithEvent$.pipe(O.distinctUntilChanged((e,t)=>{var r,i,s,l,c,d,u,h;return((r=e==null?void 0:e.location)==null?void 0:r.unitId)===((i=t==null?void 0:t.location)==null?void 0:i.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=t==null?void 0:t.location)==null?void 0:l.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=t==null?void 0:t.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=t==null?void 0:t.location)==null?void 0:h.col)}),O.map(e=>e&&{unitId:e.location.unitId,subUnitId:e.location.subUnitId,row:e.location.row,col:e.location.col,event:e.event})));E(this,"currentPosition$",this._currentCell$.asObservable());E(this,"currentClickedCell$",this._currentClickedCell$.asObservable());E(this,"currentDbClickedCell$",this._currentDbClickedCell$.asObservable());E(this,"currentPointerDownCell$",this._currentPointerDownCell$.asObservable());E(this,"currentPointerUpCell$",this._currentPointerUpCell$.asObservable());E(this,"currentHoveredRowHeader$",this._currentHoveredRowHeader$.asObservable());E(this,"currentHoveredColHeader$",this._currentHoveredColHeader$.asObservable());E(this,"currentRowHeaderClick$",this._currentRowHeaderClick$.asObservable());E(this,"currentColHeaderClick$",this._currentColHeaderClick$.asObservable());E(this,"currentRowHeaderDbClick$",this._currentRowHeaderDbClick$.asObservable());E(this,"currentColHeaderDbClick$",this._currentColHeaderDbClick$.asObservable());E(this,"currentRowHeaderPointerDown$",this._currentRowHeaderPointerDown$.asObservable());E(this,"currentColHeaderPointerDown$",this._currentColHeaderPointerDown$.asObservable());E(this,"currentRowHeaderPointerUp$",this._currentRowHeaderPointerUp$.asObservable());E(this,"currentColHeaderPointerUp$",this._currentColHeaderPointerUp$.asObservable());this._univerInstanceService=e,this._renderManagerService=t,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._currentClickedCell$.complete(),this._currentPointerDownCell$.complete(),this._currentPointerUpCell$.complete(),this._currentCellWithEvent$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t,r;((t=this._currentCell$.getValue())==null?void 0:t.location.unitId)===e.getUnitId()&&this._currentCell$.next(null),((r=this._currentRichText$.getValue())==null?void 0:r.location.unitId)===e.getUnitId()&&this._currentRichText$.next(null)}))}_getCalcDeps(e){const t=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const r=t.getActiveSheet();if(!r)return null;const i=this._renderManagerService.getRenderById(t.getUnitId());if(!i)return null;const s=i.with(exports.SheetSkeletonManagerService).getSkeletonParam(r.getSheetId());if(!s)return null;const l=i.with(exports.SheetScrollManagerService);if(!(!(l!=null&&l.getCurrentScrollState())||!i))return{currentRender:i,workbook:t,worksheet:r,skeletonParam:s}}_calcActiveCell(e,t,r,i,s,l){var y,M,x;const c=Dl(e,t,r,i,s,l),d=i.skeleton;if(!c)return null;const{position:u,overflowLocation:h,location:g}=c,S=d.getFont(h.row,h.col);let f=null,p=null,v=null;const C=d.getCellWithCoordByIndex(h.row,h.col),b=r.getCell(h.row,h.col),{topOffset:R=0,leftOffset:w=0}=(y=b==null?void 0:b.fontRenderExtension)!=null?y:{};if(S!=null&&S.documentSkeleton){const{paddingLeft:A,paddingTop:D}=kc(C,S,(b==null?void 0:b.v)!==null&&(b==null?void 0:b.v)!==void 0?!Number.isNaN(+b.v):!1),k=Dc(S.documentSkeleton,A,D),V=s-u.startX-w,W=l-u.startY-R;f=k.links.find(N=>N.rects.some(U=>U.left<=V&&V<=U.right&&U.top<=W&&W<=U.bottom)),p=k.checkLists.find(N=>N.rect.left<=V&&V<=N.rect.right&&N.rect.top<=W&&W<=N.rect.bottom),v=k.drawings.find(N=>N.rect.left<=V&&V<=N.rect.right&&N.rect.top<=W&&W<=N.rect.bottom)}const P=(x=(M=f==null?void 0:f.rects.pop())!=null?M:p==null?void 0:p.rect)!=null?x:v==null?void 0:v.rect;return{location:g,position:u,overflowLocation:h,customRange:f==null?void 0:f.range,bullet:p==null?void 0:p.paragraph,drawing:v,rect:P&&{top:P.top+C.mergeInfo.startY+R,bottom:P.bottom+C.mergeInfo.startY+R,left:P.left+C.mergeInfo.startX+w,right:P.right+C.mergeInfo.startX+w}}}_calcActiveRowHeader(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,worksheet:l,skeletonParam:c}=i,{scaleY:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new T.Vector2(t,r)));if(!u||u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP&&u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getRowIndexByOffsetY(r,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}_calcActiveColHeader(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,worksheet:l,skeletonParam:c}=i,{scaleX:d}=s.scene.getAncestorScale(),u=s.scene.getViewports().find(S=>S.isHit(new T.Vector2(t,r)));if(!u||u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT&&u.viewportKey!==T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT)return;const h={x:u.viewportScrollX,y:u.viewportScrollY},g=c.skeleton.getColumnIndexByOffsetX(t,d,h);return{unitId:e,index:g,subUnitId:l.getSheetId()}}triggerPointerDown(e,t){const r=this._getCalcDeps(e);if(!r)return;const{currentRender:i,workbook:s,worksheet:l,skeletonParam:c}=r,d=this._calcActiveCell(i,s,l,c,t.offsetX,t.offsetY);if(d&&d.location){const{unitId:u,subUnitId:h,row:g,col:S}=Et(d.location);this._currentPointerDownCell$.next({unitId:u,subUnitId:h,row:g,col:S,event:t})}}triggerPointerUp(e,t){const r=this._getCalcDeps(e);if(!r)return;const{currentRender:i,workbook:s,worksheet:l,skeletonParam:c}=r,d=this._calcActiveCell(i,s,l,c,t.offsetX,t.offsetY);if(d){const u=Et(d.location);this._currentPointerUpCell$.next({...u,event:t})}}triggerMouseMove(e,t){const r=this._getCalcDeps(e);if(!r)return;const{currentRender:i,workbook:s,worksheet:l,skeletonParam:c}=r,d=this._calcActiveCell(i,s,l,c,t.offsetX,t.offsetY);this._currentCell$.next(d&&{location:Et(d.location),position:d.position}),this._currentRichText$.next(d&&{...d,location:Et(d.overflowLocation)}),this._currentCellWithEvent$.next(d&&{...d,location:Et(d.location),event:t})}triggerClick(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=i,u=this._calcActiveCell(s,l,c,d,t,r);u&&this._currentClickedCell$.next({...u,location:Et(u.location)})}triggerDbClick(e,t,r){const i=this._getCalcDeps(e);if(!i)return;const{currentRender:s,workbook:l,worksheet:c,skeletonParam:d}=i,u=this._calcActiveCell(s,l,c,d,t,r);u&&this._currentDbClickedCell$.next({...u,location:Et(u.location)})}triggerScroll(){this._currentCell$.next(null)}triggerRowHeaderClick(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderClick$.next(i)}triggerColHeaderClick(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderClick$.next(i)}triggerRowHeaderDbClick(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderDbClick$.next(i)}triggerColHeaderDbClick(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderDbClick$.next(i)}triggerRowHeaderMouseMove(e,t,r){this._currentHoveredRowHeader$.next(this._calcActiveRowHeader(e,t,r))}triggerColHeaderMouseMove(e,t,r){this._currentHoveredColHeader$.next(this._calcActiveColHeader(e,t,r))}triggerRowHeaderPoniterDown(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderPointerDown$.next(i)}triggerColHeaderPoniterDown(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderPointerDown$.next(i)}triggerRowHeaderPoniterUp(e,t,r){const i=this._calcActiveRowHeader(e,t,r);i&&this._currentRowHeaderPointerUp$.next(i)}triggerColHeaderPoniterUp(e,t,r){const i=this._calcActiveColHeader(e,t,r);i&&this._currentColHeaderPointerUp$.next(i)}};exports.HoverManagerService=tf([Ca(0,a.IUniverInstanceService),Ca(1,T.IRenderManagerService)],exports.HoverManagerService);var nf=Object.getOwnPropertyDescriptor,rf=(n,o,e,t)=>{for(var r=t>1?void 0:t?nf(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},Hn=(n,o)=>(e,t)=>o(e,t,n);const di="SHEET_FORCE_STRING_ALERT";let no=class extends a.Disposable{constructor(n,o,e,t,r,i){super(),this._context=n,this._hoverManagerService=o,this._cellAlertManagerService=e,this._localeService=t,this._zenZoneService=r,this._configService=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(n=>{var o,e;if(n){const r=this._context.unit.getActiveSheet();if(!r)return;const i=r.getCell(n.location.row,n.location.col);if((i==null?void 0:i.t)===a.CellValueType.FORCE_STRING&&i.v&&a.isRealNum(i.v)){const s=this._cellAlertManagerService.currentAlert.get(di),l=(o=s==null?void 0:s.alert)==null?void 0:o.location;if(l&&l.row===n.location.row&&l.col===n.location.col&&l.subUnitId===n.location.subUnitId&&l.unitId===n.location.unitId||(e=this._configService.getConfig(He))!=null&&e.disableForceStringAlert)return;this._cellAlertManagerService.showAlert({type:an.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n.location,width:200,height:74,key:di});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(di)}};no=rf([Hn(1,a.Inject(exports.HoverManagerService)),Hn(2,a.Inject(exports.CellAlertManagerService)),Hn(3,a.Inject(a.LocaleService)),Hn(4,_.IZenZoneService),Hn(5,a.IConfigService)],no);var of=Object.getOwnPropertyDescriptor,sf=(n,o,e,t)=>{for(var r=t>1?void 0:t?of(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},ui=(n,o)=>(e,t)=>o(e,t,n);let ro=class extends a.RxDisposable{constructor(n,o,e,t){super(),this._context=n,this._sheetSkeletonManagerService=o,this._sheetInterceptorService=e,this._configService=t,this._initViewModelIntercept()}_initViewModelIntercept(){const n={tl:{size:6,color:"#409f11"}};this.disposeWithMe(this._sheetInterceptorService.intercept(m.INTERCEPTOR_POINT.CELL_CONTENT,{priority:10,effect:a.InterceptorEffectEnum.Style,handler:(o,e,t)=>{var s,l,c;if(!((s=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:s.skeleton))return t(o);const i=e.rawData;if(!i||i.v===null||i.v===void 0)return t(o);if(((o==null?void 0:o.t)===a.CellValueType.FORCE_STRING||(o==null?void 0:o.t)===a.CellValueType.STRING)&&a.isRealNum(i.v)){const d=e.workbook.getStyles().get(i.s);return _o.isTextFormat((l=d==null?void 0:d.n)==null?void 0:l.pattern)||(c=this._configService.getConfig(He))!=null&&c.disableForceStringMark||(o===i&&(o={...i}),o.markers={...o==null?void 0:o.markers,...n}),t(o)}return t(o)}}))}};ro=sf([ui(1,a.Inject(exports.SheetSkeletonManagerService)),ui(2,a.Inject(m.SheetInterceptorService)),ui(3,a.IConfigService)],ro);var af=Object.getOwnPropertyDescriptor,lf=(n,o,e,t)=>{for(var r=t>1?void 0:t?af(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},hi=(n,o)=>(e,t)=>o(e,t,n);exports.HoverRenderController=class extends a.Disposable{constructor(e,t,r,i){super();E(this,"_active",!1);this._context=e,this._hoverManagerService=t,this._sheetSkeletonManagerService=r,this._scrollManagerService=i,this._initPointerEvent(),this._initScrollEvent()}get active(){return this._active}_initPointerEvent(){const e=new a.DisposableCollection,t=r=>{if(e.dispose(),!r)return;const{mainComponent:i,unitId:s,components:l}=this._context;if(!i)return;e.add(i.onPointerEnter$.subscribeEvent(u=>{this._active=!0})),e.add(a.fromEventSubject(i.onPointerMove$).subscribe(u=>{this._active=!0,this._hoverManagerService.triggerMouseMove(s,u)})),e.add(i.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerDown(s,u)})),e.add(i.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerPointerUp(s,u)})),e.add(i.onClick$.subscribeEvent(u=>{this._hoverManagerService.triggerClick(s,u.offsetX,u.offsetY)})),e.add(i.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerDbClick(s,u.offsetX,u.offsetY)})),e.add(i.onPointerLeave$.subscribeEvent(()=>{this._active=!1}));const c=l.get(ue.ROW),d=l.get(ue.COLUMN);c&&(e.add(c.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(c.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(c.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerRowHeaderClick(s,u.offsetX,u.offsetY)})),e.add(c.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerRowHeaderDbClick(s,u.offsetX,u.offsetY)}))),d&&(e.add(d.onPointerMove$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderMouseMove(s,u.offsetX,u.offsetY)})),e.add(d.onPointerDown$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterDown(s,u.offsetX,u.offsetY)})),e.add(d.onPointerUp$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderPoniterUp(s,u.offsetX,u.offsetY),this._hoverManagerService.triggerColHeaderClick(s,u.offsetX,u.offsetY)})),e.add(d.onDblclick$.subscribeEvent(u=>{this._hoverManagerService.triggerColHeaderDbClick(s,u.offsetX,u.offsetY)})))};t(this._sheetSkeletonManagerService.getCurrentParam()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(r=>{t(r)}))}_initScrollEvent(){this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(()=>this._hoverManagerService.triggerScroll()))}};exports.HoverRenderController=lf([hi(1,a.Inject(exports.HoverManagerService)),hi(2,a.Inject(exports.SheetSkeletonManagerService)),hi(3,a.Inject(exports.SheetScrollManagerService))],exports.HoverRenderController);var cf=Object.getOwnPropertyDescriptor,df=(n,o,e,t)=>{for(var r=t>1?void 0:t?cf(o,e):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r},mi=(n,o)=>(e,t)=>o(e,t,n);let oo=class extends a.Disposable{constructor(n,o,e,t){super(),this._context=n,this._markSelectionService=o,this._commandService=e,this._sheetSkeletonManagerService=t,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const n=[Se.id];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{n.includes(o.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((t,r)=>{t.exits.includes(o.id)&&this._markSelectionService.removeShape(r)})}))}_addRefreshListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(n=>{n&&this._markSelectionService.refreshShapes()}))}};oo=df([mi(1,a.Inject(Lt)),mi(2,a.ICommandService),mi(3,a.Inject(exports.SheetSkeletonManagerService))],oo);function Nc(){const n=ft();return n?I.jsx(uf,{workbook:n}):null}function uf(n){const{workbook:o}=n,[e,t]=H.useState([]),[r,i]=H.useState(""),s=H.useRef(new Map),l=_.useDependency(a.ICommandService),c=H.useCallback(()=>{const u=o.getActiveSheet().getSheetId(),h=o.getSheets(),g=o.getActiveSheet(),S=h.filter(f=>!f.isSheetHidden()).map((f,p)=>{var v;return{sheetId:f.getSheetId(),label:f.getName(),index:p,selected:g===f,color:(v=f.getTabColor())!=null?v:void 0}});if(t(S),i(u),s.current.has(u)){const f=s.current.get(u);f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})}s.current.clear()},[o]);H.useEffect(()=>c(),[c]);const d=H.useCallback(u=>{l.executeCommand(m.SetWorksheetActiveOperation.id,{unitId:o.getUnitId(),subUnitId:u})},[l,o]);return H.useEffect(()=>{const u=l.onCommandExecuted(h=>{switch(h.id){case m.SetWorksheetHideMutation.id:case m.RemoveSheetMutation.id:case m.SetWorksheetNameMutation.id:case m.InsertSheetMutation.id:case m.SetWorksheetOrderMutation.id:case m.SetWorksheetActiveOperation.id:c();break}});return()=>u.dispose()},[l,c]),I.jsx("div",{className:"univer-h-8 univer-w-full univer-overflow-x-scroll univer-bg-gray-100 dark:!univer-bg-gray-900",children:I.jsx("div",{className:"univer-flex univer-h-8 univer-flex-nowrap univer-items-center",children:e.map(u=>I.jsx("div",{ref:h=>{s.current.set(u.sheetId,h)},className:j.clsx(`
|
|
24
24
|
univer-box-border univer-h-full univer-min-w-12 univer-max-w-[120px] univer-shrink-0
|
|
25
25
|
univer-flex-nowrap univer-items-center univer-overflow-hidden univer-truncate
|
|
26
26
|
univer-whitespace-nowrap univer-px-1 univer-py-0.5 univer-text-center univer-text-xs
|