@univerjs/sheets-ui 0.6.3-nightly.202503071606 → 0.6.4-nightly.202503101606
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
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer
|
|
35
35
|
univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200
|
|
36
36
|
hover:univer-bg-gray-100
|
|
37
|
-
`,{"univer-cursor-not-allowed univer-text-gray-300 hover:univer-bg-transparent":n}),children:I.jsx(En,{})})})]})}const fh="univer-formula-box",ph="univer-name-ranges",vh="univer-formula-bar",Ch="univer-formula-icon",_h="univer-formula-icon-disable",Ih="univer-formula-icon-wrapper",bh="univer-icon-container",Rh="univer-icon-container-success",Eh="univer-formula-active",wh="univer-icon-container-error",Th="univer-icon-container-fx",yh="univer-formula-input",Mh="univer-formula-input-mask",Ph="univer-formula-container",Oh="univer-formula-content",xh="univer-arrow-container",Ah="univer-arrow-container-disable",_e={formulaBox:fh,nameRanges:ph,formulaBar:vh,formulaIcon:Ch,formulaIconDisable:_h,formulaIconWrapper:Ih,iconContainer:bh,iconContainerSuccess:Rh,formulaActive:Eh,iconContainerError:wh,iconContainerFx:Th,formulaInput:yh,formulaInputMask:Mh,formulaContainer:Ph,formulaContent:Oh,arrowContainer:xh,arrowContainerDisable:Ah};function cl(n){var G,q,ie,oe;const{className:i}=n,[e,t]=V.useState(_e.formulaGrey),[r,o]=V.useState(0),s=_.useDependency(gr),l=_.useDependency(Se),c=_.useDependency(m.WorksheetProtectionRuleModel),d=_.useDependency(m.RangeProtectionRuleModel),u=_.useDependency(a.IUniverInstanceService),h=_.useDependency(m.SheetsSelectionsService),g=_.useDependency(a.IPermissionService),S=_.useDependency(m.RangeProtectionCache),f=_.useDependency(a.ICommandService),[p,v]=V.useState({editDisable:!1,viewDisable:!1}),[C,b]=V.useState(!1),R=gt(),w=_.useDependency(_.ComponentManager),M=_.useObservable(()=>u.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),y=V.useRef(0),P=_.useObservable(l.currentEditCellState$),x=ll(y,(G=P==null?void 0:P.unitId)!=null?G:""),A=w.get(Pi),k=_.useComponentsOfPart(hs.FORMULA_AUX),N=_.useDependency(a.IContextService);_.useObservable(V.useMemo(()=>N.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR),[N]));const H=N.getContextValue(a.FOCUSING_FX_BAR_EDITOR),W=V.useRef(null),D=_.useDependency($.IEditorService);V.useLayoutEffect(()=>{const J=M.activeSheet$.pipe(O.switchMap(ee=>ee?O.merge(c.ruleChange$,d.ruleChange$,h.selectionMoveEnd$,h.selectionSet$).pipe(O.switchMap(()=>{var Fe,St;const de=M.getUnitId(),fe=ee.getSheetId();if(!((Fe=h.getCurrentLastSelection())==null?void 0:Fe.range))return O.EMPTY;const we=(St=h.getCurrentLastSelection())==null?void 0:St.primary;return we?O.of({unitId:de,subUnitId:fe,primary:we}):O.of(null)})):O.EMPTY)).subscribe(ee=>{var de,fe,Te,we,Fe,St;if(ee){const{unitId:Mt,subUnitId:Hr,primary:od}=ee;if(c.getRule(Mt,Hr)){const ld=!((fe=(de=g.getPermissionPoint(new m.WorksheetEditPermission(Mt,Hr).id))==null?void 0:de.value)==null||fe),cd=!((we=(Te=g.getPermissionPoint(new m.WorksheetViewPermission(Mt,Hr).id))==null?void 0:Te.value)==null||we);v({viewDisable:cd,editDisable:ld});return}const{actualRow:sd,actualColumn:ad}=od,nn=S.getCellInfo(Mt,Hr,sd,ad);v({editDisable:!((Fe=nn==null?void 0:nn[m.UnitAction.Edit])==null||Fe),viewDisable:!((St=nn==null?void 0:nn[m.UnitAction.View])==null||St)})}else v({viewDisable:!1,editDisable:!1})});return()=>{J.unsubscribe()}},[M]),V.useEffect(()=>{const J=l.visible$.subscribe(ee=>{t(ee.visible?_e.formulaActive:_e.formulaGrey)});return()=>J.unsubscribe()},[l.visible$]),V.useEffect(()=>{const J=l.currentEditCellState$.subscribe(ee=>{var de,fe,Te;(Te=(fe=(de=ee==null?void 0:ee.documentLayoutObject.documentModel)==null?void 0:de.getBody())==null?void 0:fe.customBlocks)!=null&&Te.length?b(!0):b(!1)});return()=>J.unsubscribe()},[l.currentEditCellState$]),V.useEffect(()=>{const J=()=>{if(!W.current)return;const ee=W.current.getBoundingClientRect();s.setPosition(ee)};if(W.current){J();const ee=new ResizeObserver(J);return ee.observe(W.current),()=>ee.disconnect()}},[s]);function U(){o(r===0?1:0),setTimeout(()=>{s.handleFoldBtnClick(r===1)},150)}function L(){var ee;l.isVisible().visible&&f.executeCommand(Ce.id,{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:(ee=R==null?void 0:R.getUnitId())!=null?ee:""})}function F(){var ee;l.isVisible().visible&&f.executeCommand(Ce.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:(ee=R==null?void 0:R.getUnitId())!=null?ee:""})}function B(){s.handleFxBtnClick(!0)}const{viewDisable:j,editDisable:z}=p,K=z||C,ne=V.useRef(!1),Q=()=>{try{l.isVisible().visible===!1&&f.syncExecuteCommand(Ce.id,{visible:!0,eventType:T.DeviceInputEventType.PointerDown,unitId:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY}),N.setContextValue(a.FOCUSING_FX_BAR_EDITOR,!0)}catch(J){throw ne.current=!0,J}},se=J=>{ne.current&&setTimeout(()=>{D.blur(!0)},30),ne.current=!1},X=((oe=(ie=(q=P==null?void 0:P.documentLayoutObject.documentModel)==null?void 0:q.getDrawingsOrder())==null?void 0:ie.length)!=null?oe:0)>0||j;return I.jsxs("div",{className:Y.clsx(_e.formulaBox,i),style:{height:r===0?"28px":"82px",pointerEvents:z?"none":"auto"},children:[I.jsx("div",{className:_e.nameRanges,children:I.jsx(Sh,{disable:z})}),I.jsxs("div",{className:_e.formulaBar,children:[I.jsx("div",{className:Y.clsx(_e.formulaIcon,{[_e.formulaIconDisable]:K}),children:I.jsxs("div",{className:_e.formulaIconWrapper,children:[I.jsx("span",{className:Y.clsx(_e.iconContainer,_e.iconContainerError,e),onClick:L,children:I.jsx(el,{})}),I.jsx("span",{className:Y.clsx(_e.iconContainer,_e.iconContainerSuccess,e),onClick:F,children:I.jsx(Zt,{})}),I.jsx("span",{className:Y.clsx(_e.iconContainer,_e.iconContainerFx),onClick:B,children:I.jsx(rl,{})})]})}),I.jsxs("div",{className:_e.formulaContainer,children:[I.jsxs("div",{className:_e.formulaInput,onPointerDown:Q,onPointerUp:se,ref:W,style:{pointerEvents:X?"none":"auto"},children:[A&&I.jsx(A,{disableSelectionOnClick:!0,editorId:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:()=>{},isFocus:H,className:_e.formulaContent,unitId:P==null?void 0:P.unitId,subUnitId:P==null?void 0:P.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboradEventConfig:x,onFormulaSelectingChange:J=>{y.current=J,J?l.enableForceKeepVisible():l.disableForceKeepVisible()},autoScrollbar:!1,disableContextMenu:!1}),X?I.jsx("div",{className:_e.formulaInputMask}):null]}),I.jsx("div",{className:Y.clsx(_e.arrowContainer,{[_e.arrowContainerDisable]:z}),onClick:U,children:r===0?I.jsx(Lo,{}):I.jsx(Lo,{style:{transform:"rotateZ(180deg)"}})})]})]}),I.jsx(_.ComponentContainer,{components:k},"formula-aux")]})}const Kt=a.createIdentifier("univer.sheetbar-service");class dl extends a.Disposable{constructor(){super();E(this,"renameId$");E(this,"removeId$");E(this,"scroll$");E(this,"scrollX$");E(this,"addSheet$");E(this,"_renameId$");E(this,"_removeId$");E(this,"_scroll$");E(this,"_scrollX$");E(this,"_addSheet$");E(this,"_currentHandler",null);this._renameId$=new O.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new O.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new O.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new O.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new O.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,a.toDisposable(()=>{this._currentHandler=null})}}const kh="univer-sheet-bar",Nh="univer-sheet-bar-options",Dh="univer-sheet-bar-options-divider",Ur={sheetBar:kh,sheetBarOptions:Nh,sheetBarOptionsDivider:Dh},Hh="univer-sheet-bar-btn",Vh={sheetBarBtn:Hh};function qr(n){const{children:i,className:e,style:t,disabled:r=!1,onClick:o,...s}=n,l=c=>{if(r){c.preventDefault();return}o&&o(c)};return I.jsx("button",{type:"button",className:Vh.sheetBarBtn,style:t,disabled:r,onClick:l,...s,children:i})}function Wh(){const[n,i]=V.useState([]),[e,t]=V.useState(!1),r=_.useDependency(a.IUniverInstanceService),o=_.useDependency(a.ICommandService),s=_.useDependency(Kt),l=_.useDependency(m.WorksheetProtectionRuleModel),c=_.useObservable(()=>r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[]),d=p=>{const{sheetId:v}=p;!v||!c||(p.hidden?o.executeCommand(m.SetWorksheetShowCommand.id,{unitId:c.getUnitId(),subUnitId:v,value:v}):p.selected||o.executeCommand(m.SetWorksheetActivateCommand.id,{unitId:c.getUnitId(),subUnitId:v}),t(!1))},u=V.useCallback(()=>{if(!c)return;const p=c.getSheets(),v=c.getActiveSheet(),C=p.map((b,R)=>({label:b.getName(),index:`${R}`,sheetId:b.getSheetId(),hidden:b.isSheetHidden()===a.BooleanNumber.TRUE,selected:v===b}));i(C)},[c,l]),h=V.useCallback(()=>o.onCommandExecuted(p=>{switch(p.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:u();break}}),[o,u]);function g(){t(!0)}const S=p=>{t(p)};V.useEffect(()=>{u();const p=new a.DisposableCollection;return p.add(h()),p.add(s.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>p.dispose()},[h,s,u,c]);const f=V.useMemo(()=>n.map(p=>({type:"item",children:I.jsxs("div",{className:"univer-pl-6 univer-box-border univer-relative",children:[(p.selected||p.hidden)&&I.jsxs("span",{className:"univer-absolute univer-left-1 univer-top-0.5",children:[p.selected&&I.jsx(Zt,{className:"univer-text-primary-600 univer-size-4"}),p.hidden&&I.jsx(nl,{className:"univer-text-gray-400 univer-size-4"})]}),I.jsx("span",{className:Y.clsx({"univer-text-primary-600":p.selected}),children:p.label})]}),onSelect:()=>{d(p)}})),[n]);return I.jsx(Y.DropdownMenu,{align:"start",items:f,open:e,onOpenChange:S,children:I.jsx("div",{children:I.jsx(qr,{children:I.jsx(tl,{})})})})}const Uh="univer-slide-tab-bar-container",Lh="univer-slide-tab-bar",Bh="univer-slide-tab-item",Fh="univer-slide-tab-active",jh="univer-slide-tab-div",zh="univer-slide-tab-div-edit",Xh="univer-slide-tab-item-dropdown",He={slideTabBarContainer:Uh,slideTabBar:Lh,slideTabItem:Bh,slideTabActive:Fh,slideTabDiv:jh,slideTabDivEdit:zh,slideTabItemDropdown:Xh};function Yh(n){const{sheetId:i,label:e,color:t,selected:r}=n,[o,s]=V.useState(r),l=_.useDependency(a.ThemeService);V.useEffect(()=>{s(r)},[r]);const c=d=>{const u=l.getCurrentTheme(),h=u.textColor,g=u.colorWhite;return new a.ColorKit(d).isDark()?g:h};return I.jsx("div",{"data-id":i,className:o?`
|
|
37
|
+
`,{"univer-cursor-not-allowed univer-text-gray-300 hover:univer-bg-transparent":n}),children:I.jsx(En,{})})})]})}const fh="univer-formula-box",ph="univer-name-ranges",vh="univer-formula-bar",Ch="univer-formula-icon",_h="univer-formula-icon-disable",Ih="univer-formula-icon-wrapper",bh="univer-icon-container",Rh="univer-icon-container-success",Eh="univer-formula-active",wh="univer-icon-container-error",Th="univer-icon-container-fx",yh="univer-formula-input",Mh="univer-formula-input-mask",Ph="univer-formula-container",Oh="univer-formula-content",xh="univer-arrow-container",Ah="univer-arrow-container-disable",_e={formulaBox:fh,nameRanges:ph,formulaBar:vh,formulaIcon:Ch,formulaIconDisable:_h,formulaIconWrapper:Ih,iconContainer:bh,iconContainerSuccess:Rh,formulaActive:Eh,iconContainerError:wh,iconContainerFx:Th,formulaInput:yh,formulaInputMask:Mh,formulaContainer:Ph,formulaContent:Oh,arrowContainer:xh,arrowContainerDisable:Ah};function cl(n){var G,q,ie,oe;const{className:i}=n,[e,t]=V.useState(_e.formulaGrey),[r,o]=V.useState(0),s=_.useDependency(gr),l=_.useDependency(Se),c=_.useDependency(m.WorksheetProtectionRuleModel),d=_.useDependency(m.RangeProtectionRuleModel),u=_.useDependency(a.IUniverInstanceService),h=_.useDependency(m.SheetsSelectionsService),g=_.useDependency(a.IPermissionService),S=_.useDependency(m.RangeProtectionCache),f=_.useDependency(a.ICommandService),[p,v]=V.useState({editDisable:!1,viewDisable:!1}),[C,b]=V.useState(!1),R=gt(),w=_.useDependency(_.ComponentManager),M=_.useObservable(()=>u.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),y=V.useRef(0),P=_.useObservable(l.currentEditCellState$),x=ll(y,(G=P==null?void 0:P.unitId)!=null?G:""),A=w.get(Pi),k=_.useComponentsOfPart(hs.FORMULA_AUX),N=_.useDependency(a.IContextService);_.useObservable(V.useMemo(()=>N.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR),[N]));const H=N.getContextValue(a.FOCUSING_FX_BAR_EDITOR),W=V.useRef(null),D=_.useDependency($.IEditorService);V.useLayoutEffect(()=>{const J=M.activeSheet$.pipe(O.switchMap(ee=>ee?O.merge(c.ruleChange$,d.ruleChange$,h.selectionMoveEnd$,h.selectionSet$).pipe(O.switchMap(()=>{var Fe,St;const de=M.getUnitId(),fe=ee.getSheetId();if(!((Fe=h.getCurrentLastSelection())==null?void 0:Fe.range))return O.EMPTY;const we=(St=h.getCurrentLastSelection())==null?void 0:St.primary;return we?O.of({unitId:de,subUnitId:fe,primary:we}):O.of(null)})):O.EMPTY)).subscribe(ee=>{var de,fe,Te,we,Fe,St;if(ee){const{unitId:Mt,subUnitId:Hr,primary:od}=ee;if(c.getRule(Mt,Hr)){const ld=!((fe=(de=g.getPermissionPoint(new m.WorksheetEditPermission(Mt,Hr).id))==null?void 0:de.value)==null||fe),cd=!((we=(Te=g.getPermissionPoint(new m.WorksheetViewPermission(Mt,Hr).id))==null?void 0:Te.value)==null||we);v({viewDisable:cd,editDisable:ld});return}const{actualRow:sd,actualColumn:ad}=od,nn=S.getCellInfo(Mt,Hr,sd,ad);v({editDisable:!((Fe=nn==null?void 0:nn[m.UnitAction.Edit])==null||Fe),viewDisable:!((St=nn==null?void 0:nn[m.UnitAction.View])==null||St)})}else v({viewDisable:!1,editDisable:!1})});return()=>{J.unsubscribe()}},[M]),V.useEffect(()=>{const J=l.visible$.subscribe(ee=>{t(ee.visible?_e.formulaActive:_e.formulaGrey)});return()=>J.unsubscribe()},[l.visible$]),V.useEffect(()=>{const J=l.currentEditCellState$.subscribe(ee=>{var de,fe,Te;(Te=(fe=(de=ee==null?void 0:ee.documentLayoutObject.documentModel)==null?void 0:de.getBody())==null?void 0:fe.customBlocks)!=null&&Te.length?b(!0):b(!1)});return()=>J.unsubscribe()},[l.currentEditCellState$]),V.useEffect(()=>{const J=()=>{if(!W.current)return;const ee=W.current.getBoundingClientRect();s.setPosition(ee)};if(W.current){J();const ee=new ResizeObserver(J);return ee.observe(W.current),()=>ee.disconnect()}},[s]);function U(){o(r===0?1:0),setTimeout(()=>{s.handleFoldBtnClick(r===1)},150)}function L(){var ee;l.isVisible().visible&&f.executeCommand(Ce.id,{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:(ee=R==null?void 0:R.getUnitId())!=null?ee:""})}function F(){var ee;l.isVisible().visible&&f.executeCommand(Ce.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown,unitId:(ee=R==null?void 0:R.getUnitId())!=null?ee:""})}function B(){s.handleFxBtnClick(!0)}const{viewDisable:j,editDisable:z}=p,K=z||C,ne=V.useRef(!1),Q=()=>{try{l.isVisible().visible===!1&&f.syncExecuteCommand(Ce.id,{visible:!0,eventType:T.DeviceInputEventType.PointerDown,unitId:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY}),N.setContextValue(a.FOCUSING_FX_BAR_EDITOR,!0)}catch(J){throw ne.current=!0,J}},se=J=>{ne.current&&setTimeout(()=>{D.blur(!0)},30),ne.current=!1},X=((oe=(ie=(q=P==null?void 0:P.documentLayoutObject.documentModel)==null?void 0:q.getDrawingsOrder())==null?void 0:ie.length)!=null?oe:0)>0||j;return I.jsxs("div",{className:Y.clsx(_e.formulaBox,i),style:{height:r===0?"28px":"82px",pointerEvents:z?"none":"auto"},children:[I.jsx("div",{className:_e.nameRanges,children:I.jsx(Sh,{disable:z})}),I.jsxs("div",{className:_e.formulaBar,children:[I.jsx("div",{className:Y.clsx(_e.formulaIcon,{[_e.formulaIconDisable]:K}),children:I.jsxs("div",{className:_e.formulaIconWrapper,children:[I.jsx("span",{className:Y.clsx(_e.iconContainer,_e.iconContainerError,e),onClick:L,children:I.jsx(el,{})}),I.jsx("span",{className:Y.clsx(_e.iconContainer,_e.iconContainerSuccess,e),onClick:F,children:I.jsx(Zt,{})}),I.jsx("span",{className:Y.clsx(_e.iconContainer,_e.iconContainerFx),onClick:B,children:I.jsx(rl,{})})]})}),I.jsxs("div",{className:_e.formulaContainer,children:[I.jsxs("div",{className:_e.formulaInput,onPointerDown:Q,onPointerUp:se,ref:W,style:{pointerEvents:X?"none":"auto"},children:[A&&I.jsx(A,{disableSelectionOnClick:!0,editorId:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:()=>{},isFocus:H,className:_e.formulaContent,unitId:P==null?void 0:P.unitId,subUnitId:P==null?void 0:P.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboradEventConfig:x,onFormulaSelectingChange:J=>{y.current=J,J?l.enableForceKeepVisible():l.disableForceKeepVisible()},autoScrollbar:!1,disableContextMenu:!1}),X?I.jsx("div",{className:_e.formulaInputMask}):null]}),I.jsx("div",{className:Y.clsx(_e.arrowContainer,{[_e.arrowContainerDisable]:z}),onClick:U,children:r===0?I.jsx(Lo,{}):I.jsx(Lo,{style:{transform:"rotateZ(180deg)"}})})]})]}),I.jsx(_.ComponentContainer,{components:k},"formula-aux")]})}const Kt=a.createIdentifier("univer.sheetbar-service");class dl extends a.Disposable{constructor(){super();E(this,"renameId$");E(this,"removeId$");E(this,"scroll$");E(this,"scrollX$");E(this,"addSheet$");E(this,"_renameId$");E(this,"_removeId$");E(this,"_scroll$");E(this,"_scrollX$");E(this,"_addSheet$");E(this,"_currentHandler",null);this._renameId$=new O.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new O.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new O.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new O.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new O.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,a.toDisposable(()=>{this._currentHandler=null})}}const kh="univer-sheet-bar",Nh="univer-sheet-bar-options",Dh="univer-sheet-bar-options-divider",Ur={sheetBar:kh,sheetBarOptions:Nh,sheetBarOptionsDivider:Dh},Hh="univer-sheet-bar-btn",Vh={sheetBarBtn:Hh};function qr(n){const{children:i,className:e,style:t,disabled:r=!1,onClick:o,...s}=n,l=c=>{if(r){c.preventDefault();return}o&&o(c)};return I.jsx("button",{type:"button",className:Vh.sheetBarBtn,style:t,disabled:r,onClick:l,...s,children:i})}function Wh(){const[n,i]=V.useState([]),[e,t]=V.useState(!1),r=_.useDependency(a.IUniverInstanceService),o=_.useDependency(a.ICommandService),s=_.useDependency(Kt),l=_.useDependency(m.WorksheetProtectionRuleModel),c=_.useObservable(()=>r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[]),d=p=>{const{sheetId:v}=p;!v||!c||(p.hidden?o.executeCommand(m.SetWorksheetShowCommand.id,{unitId:c.getUnitId(),subUnitId:v,value:v}):p.selected||o.executeCommand(m.SetWorksheetActivateCommand.id,{unitId:c.getUnitId(),subUnitId:v}),t(!1))},u=V.useCallback(()=>{if(!c)return;const p=c.getSheets(),v=c.getActiveSheet(),C=p.map((b,R)=>({label:b.getName(),index:`${R}`,sheetId:b.getSheetId(),hidden:b.isSheetHidden()===a.BooleanNumber.TRUE,selected:v===b}));i(C)},[c,l]),h=V.useCallback(()=>o.onCommandExecuted(p=>{switch(p.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:u();break}}),[o,u]);function g(){t(!0)}const S=p=>{t(p)};V.useEffect(()=>{u();const p=new a.DisposableCollection;return p.add(h()),p.add(s.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>p.dispose()},[h,s,u,c]);const f=V.useMemo(()=>n.map(p=>({type:"item",children:I.jsxs("div",{className:"univer-relative univer-box-border univer-pl-6",children:[(p.selected||p.hidden)&&I.jsxs("span",{className:"univer-absolute univer-left-1 univer-top-0.5",children:[p.selected&&I.jsx(Zt,{className:"univer-size-4 univer-text-primary-600"}),p.hidden&&I.jsx(nl,{className:"univer-size-4 univer-text-gray-400"})]}),I.jsx("span",{className:Y.clsx({"univer-text-primary-600":p.selected}),children:p.label})]}),onSelect:()=>{d(p)}})),[n]);return I.jsx(Y.DropdownMenu,{align:"start",items:f,open:e,onOpenChange:S,children:I.jsx("div",{children:I.jsx(qr,{children:I.jsx(tl,{})})})})}const Uh="univer-slide-tab-bar-container",Lh="univer-slide-tab-bar",Bh="univer-slide-tab-item",Fh="univer-slide-tab-active",jh="univer-slide-tab-div",zh="univer-slide-tab-div-edit",Xh="univer-slide-tab-item-dropdown",He={slideTabBarContainer:Uh,slideTabBar:Lh,slideTabItem:Bh,slideTabActive:Fh,slideTabDiv:jh,slideTabDivEdit:zh,slideTabItemDropdown:Xh};function Yh(n){const{sheetId:i,label:e,color:t,selected:r}=n,[o,s]=V.useState(r),l=_.useDependency(a.ThemeService);V.useEffect(()=>{s(r)},[r]);const c=d=>{const u=l.getCurrentTheme(),h=u.textColor,g=u.colorWhite;return new a.ColorKit(d).isDark()?g:h};return I.jsx("div",{"data-id":i,className:o?`
|
|
38
38
|
${He.slideTabActive}
|
|
39
39
|
${He.slideTabItem}
|
|
40
40
|
`:He.slideTabItem,style:{backgroundColor:!o&&t?t:"",color:!o&&t?c(t):"",boxShadow:o&&t?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${t}`:""},children:I.jsx("div",{className:He.slideTabDiv,children:e})},i)}const Gh={easeOutStrong(n,i,e,t){return-e*((n=n/t-1)*n*n*n-1)+i},backOut(n,i,e,t,r){return typeof r>"u"&&(r=.7),e*((n=n/t-1)*n*((r+1)*n+r)+1)+i}},Zh={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(n){},success(n){},cancel(n){},complete(n){}};class Kh{constructor(i){E(this,"_config");E(this,"_status",0);E(this,"_start",0);E(this,"_handle",0);E(this,"_delayHandle",null);this._config={...Zh,...i},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...i){let e=0;return new Promise(t=>{for(let r=0;r<i.length;r++){const o=i[r],s=o._config,l=s.success;s.loop||(s.success=d=>{e++,l&&l.call(o,d),e===i.length&&t()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let i=Date.now()-this._start;i=i>=this._config.duration?this._config.duration:i;const t=Gh[this._config.type](i,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(t),this._status===1){this._config.cancel(t),this._config.complete(t);return}if(i===this._config.duration){this._config.success(t),this._config.complete(t);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class Ht{constructor(i,e){E(this,"_slideTabItem");E(this,"_animate");E(this,"_midline",0);E(this,"_translateX");E(this,"_scrollbar");E(this,"_slideTabBar");E(this,"_editMode");E(this,"_placeholder");this._slideTabItem=i,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=e,this._placeholder=null,this._scrollbar=e.getScrollbar(),this.update()}static midline(i){return i.getBoundingRect().x+i.getBoundingRect().width/2}static leftLine(i){return i.getBoundingRect().x}static rightLine(i){return i.getBoundingRect().x+i.getBoundingRect().width}static make(i,e){const t=[];return i.forEach(r=>t.push(new Ht(r,e))),t}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var i;(i=this.getEditor())==null||i.focus()}selectAll(){const i=this.getEditor();i&&mn.keepSelectAll(i)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(i){return this._translateX=i,this._slideTabItem.style.transform=`translateX(${i}px)`,this.getTranslateXDirection()}setEditor(i){if(!this._slideTabBar.getConfig().onNameChangeCheck())return;let e=!0;if(this._editMode===!1){const t=this._slideTabItem.querySelector("span"),r=d=>{if(!this.nameCheck()){if(this._editMode=!1,t&&(t.removeAttribute("contentEditable"),t.removeEventListener("focusout",r),t.removeEventListener("compositionstart",s),t.removeEventListener("compositionend",l),t.removeEventListener("input",c),t.removeEventListener("keydown",o),t.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(t==null?void 0:t.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}i&&i(d)}};let o=d=>{t&&(d.stopPropagation(),d.key==="Enter"&&t.blur())};const s=d=>{e=!1},l=d=>{e=!0},c=d=>{if(!t)return;const u=31;setTimeout(()=>{if(e){const h=t.innerText;h.length>u&&(t.innerText=h.substring(0,u),mn.keepLastIndex(t))}},0)};t&&(t.setAttribute("contentEditable","true"),t.addEventListener("focusout",r),t.addEventListener("compositionstart",s),t.addEventListener("compositionend",l),t.addEventListener("input",c),t.addEventListener("keydown",o),t.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,mn.keepSelectAll(t))}}nameCheck(){const i=this._slideTabItem.querySelector("span");if(!i)return!1;const e=i.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(e)}animate(){return{translateX:i=>{this._translateX!==i&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new Kh({begin:this._translateX,end:i,receive:e=>{this._slideTabItem.style.transform=`translateX(${e}px)`}}),this._translateX=i,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(i){this._slideTabItem.after(i._slideTabItem||i)}update(){this._midline=Ht.midline(this)}disableFixed(){if(this._placeholder){const i=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),i.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const i=document.createElement("div"),e=this.getBoundingRect(),t=getComputedStyle(this._slideTabItem),r=this._slideTabItem.querySelector("span");if(this._placeholder=i,this._placeholder.style.width=`${e.width}px`,this._placeholder.style.height=`${e.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=t.margin,this._slideTabItem.style.background=t.background,r){const o=getComputedStyle(r).padding;this._slideTabItem.style.padding=o}this._slideTabItem.style.boxSizing=t.boxSizing,this._slideTabItem.style.fontSize=t.fontSize,this._slideTabItem.style.fontFamily=t.fontFamily,this._slideTabItem.style.fontWeight=t.fontWeight,this._slideTabItem.style.color=t.color,this._slideTabItem.style.borderRadius=t.borderRadius,this._slideTabItem.style.left=`${e.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${e.y}px`,this._slideTabItem.style.width=`${e.width}px`,this._slideTabItem.style.height=`${e.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(i),document.body.appendChild(this._slideTabItem)}addEventListener(i,e,t){this._slideTabItem.addEventListener(i,e,t)}removeEventListener(i,e,t){this._slideTabItem.removeEventListener(i,e,t)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const i=this._slideTabItem.getBoundingClientRect();return i.x+=this._scrollbar.getScrollX(),i}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const i=Ht.midline(this);return i>this._midline?1:i<this._midline?-1:0}equals(i){return i&&i._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class qh{constructor(i){E(this,"_slideTabBar");E(this,"_scrollX");const e=i.primeval();this._scrollX=e.scrollLeft,this._slideTabBar=i}scrollX(i){const e=this._slideTabBar.primeval();e.scrollLeft=i,this._scrollX=e.scrollLeft}scrollRight(){const i=this._slideTabBar.primeval();i.scrollLeft=i.scrollWidth,this._scrollX=i.scrollLeft}getScrollX(){return this._scrollX}}const hn=class hn{constructor(i){E(this,"_activeTabItemIndex",0);E(this,"_slideTabBar");E(this,"_slideTabItems",[]);E(this,"_config");E(this,"_downActionX",0);E(this,"_moveActionX",0);E(this,"_compareIndex",0);E(this,"_activeTabItem",null);E(this,"_moveAction");E(this,"_upAction");E(this,"_downAction");E(this,"_wheelAction");E(this,"_scrollIncremental",0);E(this,"_compareDirection",0);E(this,"_autoScrollTime",null);E(this,"_slideScrollbar");E(this,"_longPressTimer",null);E(this,"_leftBoundingLine",0);E(this,"_rightBoundingLine",0);E(this,"_leftMoveX",0);E(this,"_rightMoveX",0);var s;if(i.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const e=i.slideTabBarContainer.querySelector(`.${(s=i.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(e==null)throw new Error("not found slide-tab-bar");this._slideTabBar=e,this._slideScrollbar=new qh(this),this._config=i,this._initConfig();let t=0,r=0,o=0;this._downAction=l=>{var y,P,x,A,k,N;if((y=this._activeTabItem)!=null&&y.isEditMode())return;this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null);const c=(x=(P=l.target)==null?void 0:P.closest(`.${i.slideTabBarItemClassName}`))==null?void 0:x.getAttribute("data-id"),d=this._slideTabItems.findIndex(H=>H.getId()===c);if(c==null||d===-1)return;if(this._activeTabItemIndex!==d){(A=this._activeTabItem)==null||A.removeEventListener("pointermove",this._moveAction),(k=this._activeTabItem)==null||k.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(l,c);return}if(this._compareIndex=d,this._downActionX=l.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[d],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const u=this._activeTabItem.getSlideTabItem();u==null||u.setPointerCapture(l.pointerId),(N=this._activeTabItem)==null||N.addEventListener("pointerup",this._upAction);const{x:h,width:g}=this._activeTabItem.getBoundingRect(),{x:S,width:f}=this.getBoundingRect(),p=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-p),this._rightBoundingLine=h-p+g-this._downActionX,this._leftMoveX=h-S-p,this._rightMoveX=S+f-(h+g)+p,l.button===2||this._hasEditItem())return;const{pageX:v,pageY:C}=l,b=Date.now(),R=b-o<=hn.DoubleClickDelay,w=Math.abs(v-t)<10,M=Math.abs(C-r)<10;R&&w&&M&&this._activeTabItem.setEditor(),t=v,r=C,o=b,this._longPressTimer=setTimeout(()=>{var H,W,D;!u||(H=this._activeTabItem)!=null&&H.isEditMode()||((W=this._activeTabItem)==null||W.enableFixed(),this._startAutoScroll(),u.setPointerCapture(l.pointerId),u.style.cursor="move",(D=this._activeTabItem)==null||D.addEventListener("pointermove",this._moveAction))},hn.LongPressDelay)},this._upAction=l=>{var u,h,g,S;if((u=this._activeTabItem)!=null&&u.isEditMode()||(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem))return;const c=this._autoScrollTime!==null;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const d=(h=this._activeTabItem)==null?void 0:h.getSlideTabItem();d&&(d.style.cursor="",d.releasePointerCapture(l.pointerId),(g=this._activeTabItem)==null||g.removeEventListener("pointermove",this._moveAction),(S=this._activeTabItem)==null||S.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&c&&(this.removeListener(),this._config.onSlideEnd(l,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=l=>{this._activeTabItem&&(this._moveActionX=l.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(l),this._scrollRight(l))},this._wheelAction=l=>{this.setScroll(l.deltaY)},this.addListener()}static checkedSkipSlide(i){let e=i.target;for(;e!=null&&e!==document.body;){if(e.getAttribute("data-slide-skip"))return!0;e=e.parentElement}return!1}static keepLastIndex(i){setTimeout(()=>{const e=window.getSelection();e&&(e.selectAllChildren(i),e.collapseToEnd())})}static keepSelectAll(i){setTimeout(()=>{const e=window.getSelection();if(!e)return;const t=document.createRange();t.selectNodeContents(i),e.removeAllRanges(),e.addRange(t)})}update(i){this._config.currentIndex=i,this._initConfig(),this.removeListener(),this.addListener(),this.scrollToItem(i)}primeval(){return this._slideTabBar}updateItems(){for(let i=0;i<this._slideTabItems.length;i++)this._slideTabItems[i].animate().cancel(),this._slideTabItems[i].translateX(0),this._slideTabItems[i].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const i=this._slideTabBar.parentElement;return i?this._slideTabBar.scrollWidth-i.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(i=>{i.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(i=>{i.removeEventListener("pointerdown",this._downAction)})}setScroll(i){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+i),i>0){const e=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(i<0){const e=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(i){if(i>0){const e=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(i<0){const e=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}scrollToItem(i){if(i=i!=null?i:this._config.currentIndex,i<0||i>=this._slideTabItems.length){console.error("Index out of bounds");return}const e=this.calculateTabItemScrollX(i);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e),this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(i){let e=0;const t=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left+o.width,l=r.getSlideTabItem().getBoundingClientRect(),c=l.left,d=l.width;return c<s&&c+d+t*2>s?(e=i?c-o.left-t:c+d-s+t,!0):!1}),e}calculateRightScrollX(i){let e=0;const t=4;return this._slideTabItems.some(r=>{const o=this._slideTabBar.getBoundingClientRect(),s=o.left,l=r.getSlideTabItem().getBoundingClientRect(),c=l.left,d=l.width;return c-t*2<s&&c+d>s?(e=i?c+d-o.left-o.width+t:c-s-t,!0):!1}),e}calculateTabItemScrollX(i){let e=0;const t=4,r=this._slideTabBar.getBoundingClientRect(),o=r.left,s=r.left+r.width,l=this._slideTabItems[i].getSlideTabItem().getBoundingClientRect(),c=l.left,d=l.width;return c-t*2<o&&(e=c-o-t),c+d+t*2>s&&(e=c+d-s+t),e}calculateActiveTabItemScrollX(){var d;let i=0;const e=4,t=this._slideTabBar.getBoundingClientRect(),r=t.left,o=t.left+t.width,s=(d=this._activeTabItem)==null?void 0:d.getSlideTabItem().getBoundingClientRect();if(!s)return 0;const l=s.left,c=s.width;return l-e*2<r&&l+c>r&&(i=l-r-e),l<o&&l+c+e*2>o&&(i=l+c-o+e),i}destroy(){this.removeListener(),this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null}_hasEditItem(){for(let i=0;i<this._slideTabItems.length;i++)if(this._slideTabItems[i].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(i){const e=this.getBoundingRect(),t=i.pageX-e.x;t<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(t-this._leftBoundingLine)*.1,50))}_scrollRight(i){const e=this.getBoundingRect(),t=i.pageX-e.x;t>e.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(t-(e.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let i=0;i<this._slideTabItems.length;i++){const e=this._slideTabItems[i],t=this._slideTabItems[i+1];t&&e.after(t)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const i=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),e=this._slideTabItems.length,t=[];for(let o=0;o<i&&!(o>=i);o++)t.push(this._slideTabItems[o]);for(let o=i+1;o<e;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=t.length-1;o>=0;o--){const s=t[o];Ht.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=o,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const i=this._slideTabItems.findIndex(o=>o.equals(this._activeTabItem)),e=this._slideTabItems.length,t=[];for(let o=i+1;o<e;o++)t.push(this._slideTabItems[o]);for(let o=0;o<i;o++)this._slideTabItems[o].animate().translateX(0);let r=!0;for(let o=0;o<t.length;o++){const s=t[o];Ht.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=i+o+1,r=!1):(s.animate().translateX(0),r&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var e;const i=this._slideTabBar.querySelectorAll(`.${(e=this._config.slideTabBarItemClassName)!=null?e:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=Ht.make(i,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};E(hn,"LongPressDelay",500),E(hn,"DoubleClickDelay",300);let mn=hn;function Qh(){var ce;const[n,i]=V.useState([]),[e,t]=V.useState(""),[r,o]=V.useState(""),[s,l]=V.useState(!1),[c,d]=V.useState([0,0]),u=V.useRef({slideTabBar:null}),h=V.useRef(null),g=_.useDependency(a.ICommandService),S=_.useDependency(Kt),f=_.useDependency(a.LocaleService),p=_.useDependency(_.IConfirmService),v=_.useDependency(a.IConfigService),C=_.useDependency(Se,a.Quantity.OPTIONAL),b=_.useDependency(m.WorksheetProtectionRuleModel),R=_.useDependency(m.RangeProtectionRuleModel),w=_.useObservable(b.resetOrder$),M=gt(),y=_.useDependency(a.IPermissionService),P=V.useCallback(()=>{var oe;const X=((oe=M.getActiveSheet())==null?void 0:oe.getSheetId())||"";t(X);const G=M.getSheets(),q=M.getActiveSheet(),ie=G.filter(J=>!J.isSheetHidden()).map((J,ee)=>{var Fe;const de=b.getRule(M.getUnitId(),J.getSheetId()),fe=R.getSubunitRuleList(M.getUnitId(),J.getSheetId()).length>0,we=(de==null?void 0:de.permissionId)||fe?I.jsxs(I.Fragment,{children:[I.jsx(Is,{}),I.jsx("span",{children:J.getName()})]}):I.jsx("span",{children:J.getName()});return{sheetId:J.getSheetId(),label:we,index:ee,selected:q===J,color:(Fe=J.getTabColor())!=null?Fe:void 0}});i(ie),t(X)},[R,M,b]);V.useEffect(()=>{P();const{slideTabBar:X,disconnectResizeObserver:G}=x(),q=F(),ie=[B(),j(),z()];return()=>{q.dispose(),X.destroy(),ie.forEach(oe=>oe.unsubscribe()),G&&G()}},[w,M]),V.useEffect(()=>{n.length>0&&L()},[n]),V.useEffect(()=>{const X=O.merge(b.ruleChange$,R.ruleChange$).subscribe(()=>{P()});return()=>{X.unsubscribe()}},[b,P]);const x=()=>{const X=new mn({slideTabBarClassName:He.slideTabBar,slideTabBarItemActiveClassName:He.slideTabActive,slideTabBarItemClassName:He.slideTabItem,slideTabBarSpanEditClassName:He.slideTabDivEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(q,ie)=>{g.executeCommand(m.SetWorksheetNameCommand.id,{subUnitId:q,name:ie})},onSlideEnd:async(q,ie)=>{await g.executeCommand(m.SetWorksheetOrderCommand.id,{order:ie})},onChangeTab:(q,ie)=>{g.executeCommand(m.SetWorksheetActiveOperation.id,{subUnitId:ie,unitId:M.getUnitId()}).then(()=>{q.button===2&&se(!0)})},onScroll:q=>{S.setScroll(q)},onNameCheckAlert:q=>N(q)||H(q)||W(q),onNameChangeCheck:()=>{var de,fe,Te,we;const q=M.getUnitId(),ie=M==null?void 0:M.getActiveSheet();if(!ie)throw new Error("No active sheet found");const oe=ie.getSheetId(),J=b.getRule(q,oe),ee=R.getSubunitRuleList(q,oe).length>0;return J||ee?(fe=(de=y.getPermissionPoint(new m.WorkbookManageCollaboratorPermission(q).id))==null?void 0:de.value)!=null?fe:!1:(we=(Te=y.getPermissionPoint(new m.WorkbookRenameSheetPermission(q).id))==null?void 0:Te.value)!=null?we:!1}});u.current.slideTabBar=X;const G=Q(X);return{slideTabBar:X,disconnectResizeObserver:G}},A=v.getConfig(_.UI_PLUGIN_CONFIG_KEY),k=(ce=A==null?void 0:A.contextMenu)!=null?ce:!0,N=X=>{if(X.trim()===""){const G="sheetNameEmptyAlert";return p.open({id:G,title:{title:f.t("sheetConfig.sheetNameErrorTitle")},children:{title:f.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:f.t("button.cancel"),confirmText:f.t("button.confirm"),onClose(){D(),p.close(G)},onConfirm(){D(),p.close(G)}}),!0}return!1},H=X=>{if(!a.nameCharacterCheck(X)){const G="sheetNameSpecCharAlert";return p.open({id:G,title:{title:f.t("sheetConfig.sheetNameErrorTitle")},children:{title:f.t("sheetConfig.sheetNameSpecCharError")},cancelText:f.t("button.cancel"),confirmText:f.t("button.confirm"),onClose(){D(),p.close(G)},onConfirm(){D(),p.close(G)}}),!0}return!1},W=X=>{const G=M.getActiveSheet();if((G==null?void 0:G.getName())===X)return!1;const ie=M.checkSheetName(X);if(ie){const oe="sheetNameRepeatAlert";p.open({id:oe,title:{title:f.t("sheetConfig.sheetNameErrorTitle")},children:{title:f.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:f.t("button.cancel"),confirmText:f.t("button.confirm"),onClose(){p.close(oe),D()},onConfirm(){p.close(oe),D()}})}return ie},D=()=>{setTimeout(()=>{var G;const X=(G=u.current.slideTabBar)==null?void 0:G.getActiveItem();X&&(X.focus(),X.selectAll())},0)},U=()=>{var X,G;(G=(X=u.current.slideTabBar)==null?void 0:X.getActiveItem())==null||G.setEditor()},L=()=>{var G;const X=n.findIndex(q=>q.selected);(G=u.current.slideTabBar)==null||G.update(X)},F=()=>g.onCommandExecuted(X=>{switch(X.id){case m.SetTabColorMutation.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:P();break}}),B=()=>S.scroll$.subscribe(X=>{K(X)}),j=()=>S.scrollX$.subscribe(X=>{var G;(G=u.current.slideTabBar)==null||G.flipPage(X)}),z=()=>S.renameId$.subscribe(()=>{U()}),K=X=>{const{leftEnd:G,rightEnd:q}=X;let ie="";G&&q?ie="":G&&!q?ie="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!G&&q?ie="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!G&&!q&&(ie="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),o(ie)},ne=X=>{const G=X.calculateActiveTabItemScrollX();if(G){const q=X.getScrollbar();q.scrollX(q.getScrollX()+G)}S.setScroll({leftEnd:X.isLeftEnd(),rightEnd:X.isRightEnd()})},Q=X=>{var ie;const G=(ie=h.current)==null?void 0:ie.querySelector(`.${He.slideTabBar}`);if(!G)return;const q=new ResizeObserver(()=>{ne(X)});return q.observe(G),()=>q.disconnect()},se=X=>{var G,q,ie,oe,J;if(k&&!(C!=null&&C.isForceKeepVisible())){if(X){const{left:ee}=(q=(G=h.current)==null?void 0:G.getBoundingClientRect())!=null?q:{},{left:de}=(J=(oe=(ie=u.current.slideTabBar)==null?void 0:ie.getActiveItem())==null?void 0:oe.getSlideTabItem().getBoundingClientRect())!=null?J:{};ee!==void 0&&de!==void 0&&d([de-ee,0])}l(X)}};return I.jsx(Y.DropdownLegacy,{className:He.slideTabItemDropdown,visible:s,align:{offset:c},trigger:["contextMenu"],overlay:I.jsx(_.UIMenu,{menuType:_.ContextMenuPosition.FOOTER_TABS,onOptionSelect:X=>{const{label:G,value:q,commandId:ie}=X;g.executeCommand(ie!=null?ie:G,{value:q,subUnitId:e}),l(!1)}}),onVisibleChange:se,children:I.jsx("div",{className:He.slideTabBarContainer,ref:h,onDragStart:X=>X.preventDefault(),onContextMenu:X=>X.preventDefault(),children:I.jsx("div",{className:He.slideTabBar,style:{boxShadow:r},children:n.map(X=>V.createElement(Yh,{...X,key:X.sheetId,selected:e===X.sheetId}))})})})}const Jh=100,ul=()=>{var p,v;const[n,i]=V.useState(!0),[e,t]=V.useState(!0),r=_.useDependency(a.ICommandService),o=_.useDependency(Kt),s=_.useDependency(a.IPermissionService),c=gt().getUnitId(),d=_.useObservable(s.getPermissionPoint$((p=new m.WorkbookEditablePermission(c))==null?void 0:p.id)),u=_.useObservable(s.getPermissionPoint$((v=new m.WorkbookCreateSheetPermission(c))==null?void 0:v.id));V.useEffect(()=>{const C=o.scroll$.subscribe(b=>{h(b)});return()=>{C.unsubscribe()}},[]);const h=C=>{const{leftEnd:b,rightEnd:R}=C;i(b),t(R)},g=()=>{r.executeCommand(m.InsertSheetCommand.id),setTimeout(()=>{o.setAddSheet(0)},0)},S=()=>{o.setScrollX(-100)},f=()=>{o.setScrollX(Jh)};return I.jsxs("div",{className:Y.clsx(Ur.sheetBar,"univer-relative univer-flex univer-h-full univer-flex-1"),children:[I.jsxs("div",{className:Ur.sheetBarOptions,children:[I.jsx(qr,{onClick:g,disabled:!(u!=null&&u.value&&(d!=null&&d.value)),children:I.jsx(_s,{})}),I.jsx(Wh,{})]}),I.jsx(Qh,{}),(!n||!e)&&I.jsxs("div",{className:`
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
`,g={...u,body:{dataStream:h,textRuns:c.textRuns,paragraphs:Gi(h)}};d==null||d.reset(g),o=d==null?void 0:d.getSnapshot(),r=c.dataStream}else r=Bm(i.innerHTML.replace(/[\r\n]/g,""));return{cellText:r,cellRichStyle:o}}_generateDocumentDataModelSnapshot(i){var l;const e=this._getCurrentSkeleton();if(e==null)return null;const{skeleton:t}=e,r=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...r==null?void 0:r.getSnapshot(),...i};return r==null||r.reset(s),r==null?void 0:r.getSnapshot()}process(i,e,t,r){var o,s,l;for(const c of e)if(c.nodeName.toLowerCase()==="table")r.push({index:((o=t==null?void 0:t.paragraphs)==null?void 0:o.length)||0});else if(c.nodeType===Node.TEXT_NODE){if(((s=c.nodeValue)==null?void 0:s.trim())==="")continue;const d=(l=c.nodeValue)==null?void 0:l.replace(/[\r\n]/g,"");let u;i&&this._styleCache.has(i)&&(u=this._styleCache.get(i));const h={dataStream:"",textRuns:[]};t.dataStream+=d,h.dataStream+=d,u&&Object.getOwnPropertyNames(u).length&&(t.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}),h.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}))}else{if(a.skipParseTagNames.includes(c.nodeName.toLowerCase()))continue;if(c.nodeName.toLowerCase()==="br")t.paragraphs||(t.paragraphs=[]),t.paragraphs.push({startIndex:t.dataStream.length}),t.dataStream+="\r";else if(c.nodeType===Node.ELEMENT_NODE){if(c.nodeName==="STYLE")continue;const d=c,u=this._processBeforeLink(d,{body:t}),h=i?this._styleCache.get(i):{},g=this._styleRules.find(({filter:v})=>ua(c,v)),S=g?g.getStyle(c):ii(c);this._styleCache.set(c,{...h,...S});const{childNodes:f}=c;this.process(c,f,t,r);const p=this._afterProcessRules.find(({filter:v})=>ua(c,v));p&&p.handler(t,c),this._processAfterLink(d,{body:t},u)}}}_processBeforeLink(i,e){return e.body.dataStream.length}_processAfterLink(i,e,t){var s,l;const r=e.body,o=i;o.tagName.toUpperCase()==="A"&&(r.customRanges=(s=r.customRanges)!=null?s:[],r.customRanges.push({startIndex:t,endIndex:r.dataStream.length-1,rangeId:(l=o.dataset.rangeid)!=null?l:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:o.href}}))}dispose(){this._dom=null,this._styleCache.clear(),this._styleMap.clear()}};E(yi,"_pluginList",[]);let wn=yi;function Um(n){const i=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=n.matchAll(i);if(!e)return{rowProperties:[],rowCount:0};const r=Array.from(e).map(o=>Al(o[1])).map(o=>{if(!o.height){const s=o.style,l=s&&s.match(/height\s*:\s*(\d+(\.\d+)?)px/);o.height=`${l?Number.parseInt(l[1],10):a.DEFAULT_WORKSHEET_ROW_HEIGHT}`}return o});return{rowProperties:r,rowCount:r.length}}function ha(n){const i={};return n.split(";").forEach(t=>{const[r,o]=t.split(":");i[r]=o}),i}function Al(n){if(!n)return{};const i={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let t;for(;(t=e.exec(n))!==null;){const[,r,,o,s]=t,l=o!==void 0?o:s;i[r]=l}return i}function Lm(n){const i=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=n.match(i),t=/<col([\s\S]*?)>/g;let r;if(e!=null&&e[2]?r=e[2].matchAll(t):r=n.matchAll(t),!r)return null;const o=Array.from(r).map(l=>Al(l[1])),s=[];return o.forEach(l=>{const c=Number(l.span);if(c)for(let d=0;d<c;d++){const u={...l};delete u.span,s.push(u)}else s.push(l)}),s}function Bm(n){const i={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return n.replace(/<|>|&|"|'| |<br>/g,e=>i[e])}function ma(n,i){if(!n||!i)return null;const e=new RegExp(`(${i}\\s*:\\s*[^;]+);`,"i"),t=n.match(e);return t?t[1]:null}function Fm(n,i,e,t){const{rowSpan:r,colSpan:o,rowIndex:s,colSetValueIndex:l}=t;for(let c=s;c<s+r;c++)for(let d=l;d<l+o;d++)c===s&&d===l?n.setValue(c,d,{...e,style:i}):n.setValue(c,d,{style:i})}const jm={name:"univer-doc-paste-plugin-lark",checkPasteType(n){return/lark-record-clipboard/i.test(n)},stylesRules:[{filter:["s"],getStyle(n){const i=ii(n);return{st:{s:a.BooleanNumber.TRUE},...i}}}],afterProcessRules:[{filter(n){return n.tagName==="DIV"&&/ace-line/i.test(n.className)},handler(n){n.paragraphs==null&&(n.paragraphs=[]),n.paragraphs.push({startIndex:n.dataStream.length}),n.dataStream+="\r"}}]},zm={name:"univer-doc-paste-plugin-univer",checkPasteType(n){return/UniverNormal/i.test(n)},stylesRules:[],afterProcessRules:[{filter(n){return n.tagName==="P"&&/UniverNormal/i.test(n.className)},handler(n,i){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=xl(i);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]},Xm={name:"univer-doc-paste-plugin-word",checkPasteType(n){return/word|mso/i.test(n)},stylesRules:[{filter:["b"],getStyle(n){const i=ii(n);return{bl:a.BooleanNumber.TRUE,...i}}}],afterProcessRules:[{filter(n){return n.tagName==="P"&&/mso/i.test(n.className)},handler(n,i){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=xl(i);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]};var ct=(n=>(n.COPY="COPY",n.CUT="CUT",n))(ct||{});function Ym(n,i,e,t,r){const o=e.map(d=>{var u;return(u=d.onCopyRow)==null?void 0:u.call(d,n)}).filter(d=>!!d),s=ws(o),l=Ts(s),c=i.map(d=>{if(!r.has(`${n}-${d}`)){const u=t.getValue(n,d);if(u!=null&&u.rowSpan&&(u!=null&&u.colSpan))for(let h=n;h<n+u.rowSpan;h++)for(let g=d;g<d+u.colSpan;g++)r.add(`${h}-${g}`);return Gm(n,d,e,t)}return null}).filter(d=>!!d).join("");return`<tr${l}>${c}</tr>`}function Gm(n,i,e,t){const r=t.getValue(n,i),o=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,n,i,r==null?void 0:r.rowSpan,r==null?void 0:r.colSpan)}).filter(d=>!!d),s=ws(o),l=Ts(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,n,i))||""},"");return`<td${l}>${c}</td>`}function Zm(n,i){return`<colgroup>${n.map(t=>{const r=i.map(l=>{var c;return(c=l.onCopyColumn)==null?void 0:c.call(l,t)}).filter(l=>!!l),o=ws(r);return`<col ${Ts(o)}>`}).join("")}</colgroup>`}function ws(n){return n.reduce((i,e)=>(Object.keys(e).forEach(r=>{i[r]?i[r]+=`;${e[r]}`:i[r]=e[r]}),i),{})}function Ts(n){return Object.keys(n).reduce((i,e)=>(i+=` ${e}="${n[e]}"`,i),"")}class Km{convert(i,e,t){const{cols:r,rows:o}=e;if(!r.length)return"";const s=Zm(r,t),l=[],c=new Set;return o.forEach(u=>{l.push(Ym(u,r,t,i,c))}),`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
|
|
56
56
|
<tbody>${l.join("")}</tbody></table>`}}const qm=(n,i,e=!1)=>{const t=h=>h.endRow-h.startRow+1,r=h=>h.endColumn-h.startColumn+1,o=t(i)%t(n),s=r(i)%r(n),l={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:r(n)-1},c=Math.floor(t(i)/t(n)),d=Math.floor(r(i)/r(n)),u=[];if(!o&&!s)for(let h=1;h<=c;h++)for(let g=1;g<=d;g++){const S=t(n)*(h-1),f=r(n)*(g-1),p={startRow:S+i.startRow,endRow:S+i.startRow,startColumn:f+i.startColumn,endColumn:f+i.startColumn};u.push({repeatRelativeRange:l,startRange:p})}else if(!o&&s&&!e)for(let h=1;h<=c;h++){const g=t(n)*(h-1),S=0,f={startRow:g+i.startRow,endRow:g+i.startRow,startColumn:S+i.startColumn,endColumn:S+i.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else if(o&&!s&&!e)for(let h=1;h<=d;h++){const S=r(n)*(h-1),f={startRow:0+i.startRow,endRow:0+i.startRow,startColumn:S+i.startColumn,endColumn:S+i.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else{const h={startRow:i.startRow,endRow:i.startRow,startColumn:i.startColumn,endColumn:i.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};function ga(n){return n?[/<td[^>]*class=".*?xl.*?"[^>]*>/i,/xmlns:x="urn:schemas-microsoft-com:office:excel"/i,/ProgId="Excel.Sheet"/i,/xmlns:o="urn:schemas-microsoft-com:office:office"/i,/@mso-|mso-excel/i,/<x:ExcelWorkbook>/i].some(e=>e.test(n)):!1}function Qm(n){if(!n)return!1;const i=/<img[^>]*src\s*=\s*["']data:image\/[^;]+;base64,[^"']*["'][^>]*>/i;return(n.match(i)||[]).length>0}function Jm(...n){if(n.length===1)return n[0];const i=new a.ObjectMatrix;return n.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((r,o,s)=>{i.setValue(r,o,{...i.getValue(r,o),...s})})}),i.getMatrix()}function $m(n,i){return n.id===i.id&&n.params.unitId===i.params.unitId&&n.params.subUnitId===i.params.subUnitId}function Xo(n){const i=[];for(let e=0;e<n.length;){let t=1;if(n[e].id===m.SetRangeValuesMutation.id){const r=n[e],o=[r];for(;e+t<n.length&&$m(r,n[e+t]);)o.push(n[e+t]),t+=1;const s=Jm(...o.map(l=>l.params.cellValue||{}));i.push({...r,params:{...r.params,cellValue:s}})}else i.push(n[e]);e+=t}return i}function Zi(n,i){const{startRow:e,endRow:t,startColumn:r,endColumn:o}=n;for(let s=e;s<=t;s++)for(let l=r;l<=o;l++)if(i.rows.includes(s)&&i.cols.includes(l))return!0}function Sa(n,i){const{startRow:e,endRow:t,startColumn:r,endColumn:o}=i;for(let s=e;s<=t;s++)if(!n.rows.includes(s))return!1;for(let s=r;s<=o;s++)if(!n.cols.includes(s))return!1;return!0}function eg(n){const i=n.trim().split(`
|
|
57
57
|
`);let e="<table>";return i.forEach(t=>{const r=t.split(" ");e+="<tr>",r.forEach(o=>{e+=`<td>${o}</td>`}),e+="</tr>"}),e+="</table>",e}var tg=Object.getOwnPropertyDescriptor,ng=(n,i,e,t)=>{for(var r=t>1?void 0:t?tg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Oe=(n,i)=>(e,t)=>i(e,t,n);const ge={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border",SPECIAL_PASTE_FORMULA:"special-paste-formula"},rg={[_.FILE_PNG_CLIPBOARD_MIME_TYPE]:"png",[_.FILE__JPEG_CLIPBOARD_MIME_TYPE]:"jpg",[_.FILE__WEBP_CLIPBOARD_MIME_TYPE]:"webp",[_.FILE__BMP_CLIPBOARD_MIME_TYPE]:"bmp"};wn.use(Xm);wn.use(jm);wn.use(zm);const Be=a.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d,u,h,g,S,f,p){super();E(this,"_clipboardHooks",[]);E(this,"_clipboardHooks$",new O.BehaviorSubject([]));E(this,"clipboardHooks$",this._clipboardHooks$.asObservable());E(this,"_htmlToUSM");E(this,"_usmToHtml");E(this,"_copyContentCache");E(this,"_copyMarkId",null);E(this,"_pasteOptionsCache$",new O.BehaviorSubject(null));E(this,"pasteOptionsCache$",this._pasteOptionsCache$.asObservable());E(this,"_showMenu$",new O.BehaviorSubject(!1));E(this,"showMenu$",this._showMenu$.asObservable());this._logService=e,this._univerInstanceService=t,this._selectionManagerService=r,this._clipboardInterfaceService=o,this._undoRedoService=s,this._commandService=l,this._markSelectionService=c,this._notificationService=d,this._platformService=u,this._renderManagerService=h,this._themeService=g,this._localeService=S,this._errorService=f,this._injector=p,this._htmlToUSM=new wn({getCurrentSkeleton:()=>{var v;return(v=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._univerInstanceService,this._renderManagerService))==null?void 0:v.getCurrentParam()}}),this._usmToHtml=new Km,this._copyContentCache=new Hm,this.disposeWithMe(this._htmlToUSM),this._initUnitDisposed()}setShowMenu(e){this._showMenu$.next(e)}getPasteMenuVisible(){return this._showMenu$.getValue()}getPasteOptionsCache(){return this._pasteOptionsCache$.getValue()}copyContentCache(){return this._copyContentCache}generateCopyContent(e,t,r,o=ct.COPY){const s=this._clipboardHooks;s.forEach(c=>{var d;return(d=c.onBeforeCopy)==null?void 0:d.call(c,e,t,r,o)});const l=this._generateCopyContent(e,t,r,this._clipboardHooks);return s.forEach(c=>{var d;return(d=c.onAfterCopy)==null?void 0:d.call(c)}),l}async copy(e=ct.COPY){const t=this._selectionManagerService.getCurrentLastSelection();if(!t)return!1;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=r.getActiveSheet();if(!o)return!1;const s=r.getUnitId(),l=o.getSheetId(),c=this.generateCopyContent(s,l,t.range);if(!c)return!1;const{html:d,plain:u,matrixFragment:h,copyId:g,discreteRange:S}=c;this._copyContentCache.set(g,{unitId:r.getUnitId(),subUnitId:o.getSheetId(),range:S,matrix:h,copyType:e}),await this._clipboardInterfaceService.write(u,d),this._markSelectionService.removeAllShapes();const f=Ol(this._themeService);return this._copyMarkId=this._markSelectionService.addShape({...t,style:f}),!0}async cut(){return this.copy(ct.CUT)}async paste(e,t=ge.DEFAULT_PASTE){const r=e.types,o=r.indexOf(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",s=r.indexOf(_.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.HTML_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",l=r.findIndex(d=>_.imageMimeTypeSet.has(d)),c=l===-1||!Qm(s);if(s&&c)return this._platformService.isWindows&&ga(s)&&this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),this._pasteHTML(s,t);if(l!==-1){const d=r[l],u=await e.getType(d);if(u){const h=rg[d],g=new File([u],`clipboard-image.${h}`,{type:d});return this._pasteFiles([g],t)}}return o?this._pastePlainText(o,t):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}async legacyPaste(e,t,r){const o=ga(e!=null?e:"");return r&&!o?this._pasteFiles(r,ge.DEFAULT_PASTE):e?this._pasteHTML(e,ge.DEFAULT_PASTE):t?/[\n\t]/.test(t)?this._pasteHTML(eg(t),ge.DEFAULT_PASTE):this._pastePlainText(t,ge.DEFAULT_PASTE):this._pasteUnrecognized()}rePasteWithPasteType(e){const t=this._pasteOptionsCache$.getValue();if(!t)return!1;const r=this._injector.get(a.IUndoRedoService),o=r.pitchTopUndoElement();o&&a.sequenceExecute(o.undoMutations,this._commandService)&&r.popUndoToRedo();const{cellMatrix:s,rowProperties:l=[],colProperties:c=[],source:d,target:u}=t;return this._pasteUSM({cellMatrix:s,colProperties:c,rowProperties:l},u,ge[e],d),!0}updatePasteOptionsCache(e){this._pasteOptionsCache$.next(e)}addClipboardHook(e){if(this._clipboardHooks.findIndex(r=>r.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const t=this._clipboardHooks.findIndex(r=>{const o=r.priority||0;return(e.priority||0)<o});return this._clipboardHooks.splice(t!==-1?t:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const r=this._clipboardHooks.indexOf(e);r>-1&&(this._clipboardHooks.splice(r,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,t,r,o){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(t);if(!s||!l)return null;const c=o.reduce((M,y)=>{var x;const P=(x=y.getFilteredOutRows)==null?void 0:x.call(y,r);return P==null||P.forEach(A=>M.add(A)),M},new Set),{startColumn:d,startRow:u,endColumn:h,endRow:g}=r,S=l.getMatrixWithMergedCells(u,d,g,h,a.CellModeEnum.Both),f=new a.ObjectMatrix;let p=u;const v=new a.ObjectMatrix,C={rows:[],cols:[]};for(let M=u;M<=g;M++)if(!c.has(M)){C.rows.push(M);for(let y=d;y<=h;y++){const P=S.getValue(M,y);if(P){const x=a.Tools.deepClone(P);v.setValue(p-u,y-d,{...Bn(),...x}),delete x.displayV,f.setValue(p-u,y-d,{...Bn(),...x})}else v.setValue(p-u,y-d,Bn()),f.setValue(p-u,y-d,Bn()),S.setValue(M,y,Bn())}p+=1}for(let M=d;M<=h;M++)C.cols.push(M);let b=this._usmToHtml.convert(S,C,o);const R=kl(v),w=Nm();return b=b.replace(/(<[a-z]+)/,(M,y)=>`${y} data-copy-id="${w}"`),{copyId:w,plain:R,html:b,matrixFragment:f,discreteRange:C}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _executePaste(e){const t=this._getPastingTarget();if(!t.subUnitId||!t.selection)return!1;const r=this._injector.invoke(S=>m.rangeToDiscreteRange(t.selection.range,S,t.unitId,t.subUnitId));if(!r)return!1;const{unitId:o,subUnitId:s}=t,l=this._clipboardHooks,c=[];if(l.some(S=>{var f;return c.push(S)&&((f=S.onBeforePaste)==null?void 0:f.call(S,{unitId:o,subUnitId:s,range:r}))===!1}))return c.forEach(S=>{var f;return(f=S.onAfterPaste)==null?void 0:f.call(S,!1)}),!1;const u=[],h=[];c.forEach(S=>{const f=e(S,{unitId:o,subUnitId:s,range:r});f&&(u.push(...f.redos),h.push(...f.undos))});const g=u.every(S=>this._commandService.executeCommand(S.id,S.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:h,redoMutations:u}),g}async _pasteFiles(e,t){return this._executePaste((r,o)=>{var s;return(s=r.onPasteFiles)==null?void 0:s.call(r,o,e,{pasteType:t})})}async _pastePlainText(e,t){return this._executePaste((r,o)=>{var s;return(s=r.onPastePlainText)==null?void 0:s.call(r,o,e,{pasteType:t})})}_pasteUnrecognized(){return this._executePaste((e,t)=>{var r;return(r=e.onPasteUnrecognized)==null?void 0:r.call(e,t)})}async _pasteHTML(e,t){const r=Dm(e);return r&&this._copyContentCache.get(r)?this._pasteInternal(r,t):this._pasteExternal(e,t)}async _pasteExternal(e,t){var h;const{rowProperties:r,colProperties:o,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const l=this._getPastedRange(s);if(!l)return!1;const c=(h=this._univerInstanceService.getUniverSheetInstance(l.unitId))==null?void 0:h.getSheetBySheetId(l.subUnitId);if(!c)return!1;const d=c==null?void 0:c.getMergeData();return d.length&&d.some(S=>Zi(S,l.pastedRange)&&!Sa(l.pastedRange,S))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:r,colProperties:o,cellMatrix:s},l,t)}async _pasteInternal(e,t){var y,P;const r=a.Tools.deepClone(this._copyContentCache.get(e)),{range:o,matrix:s,unitId:l,subUnitId:c}=r||{};if(!s||!r||!o||!l||!c||!s||!r)return!1;const d=(y=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:y.getStyles();s.forValue((x,A,k)=>{if(typeof k.s=="string"){const N=a.Tools.deepClone(k);N.s=d==null?void 0:d.getStyleByCell(k),s.setValue(x,A,N)}if(k.colSpan||k.rowSpan)for(let N=0;N<k.rowSpan;N++)for(let H=0;H<k.colSpan;H++){if(N===0&&H===0)continue;const W=x+N,D=A+H;s.setValue(W,D,{s:d==null?void 0:d.getStyleByCell(k)})}});const u=this._getPastedRange(s);if(!u)return!1;const h=(P=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:P.getSheetBySheetId(u.subUnitId);if(!h)return!1;const g=h==null?void 0:h.getMergeData();if(g&&g.some(A=>Zi(A,u.pastedRange)&&!Sa(u.pastedRange,A)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const S=this._univerInstanceService.getUnit(l);if(!S)return!1;const f=S.getSheetBySheetId(c);if(!f)return!1;const p=f.getColumnManager(),v=f.getRowManager(),C=f.getConfig().defaultColumnWidth,b=f.getConfig().defaultRowHeight,R=[],w=[];if(o.cols.forEach(x=>{const A=p.getColumnOrCreate(x);R.push({width:`${A.w||C}`})}),o.rows.forEach(x=>{const A=v.getRowOrCreate(x),{ah:k=b,h:N=b}=A,H=Math.max(k,N);w.push({height:`${H}`})}),r.copyType===ct.CUT){const x=u.pastedRange.rows[0],A=o.rows[o.rows.length-1]-o.rows[0]+x;u.pastedRange.rows=Array.from(new Array(A+1).keys()).slice(x)}const M=this._pasteUSM({cellMatrix:s,colProperties:R,rowProperties:w},u,t,{range:o,unitId:r.unitId,subUnitId:r.subUnitId,copyType:r.copyType,copyId:e});return r.copyType===ct.CUT&&(this._copyContentCache.set(e,{...r,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),M}_pasteUSM(e,t,r,o){const{rowProperties:s,colProperties:l,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=t,g=h.cols.length,S=this._clipboardHooks,f=[];if(S.some(P=>{var x;return f.push(P)&&((x=P.onBeforePaste)==null?void 0:x.call(P,{unitId:d,subUnitId:u,range:h}))===!1}))return f.forEach(P=>{var x;return(x=P.onAfterPaste)==null?void 0:x.call(P,!1)}),!1;if(!c)return!1;const v=o?{unitId:o.unitId,subUnitId:o.subUnitId,range:o.range}:null,C={copyType:(o==null?void 0:o.copyType)||ct.COPY,copyId:o==null?void 0:o.copyId,pasteType:r};let b=[],R=[];const w=f.filter(P=>!P.specialPasteInfo&&P.id!==ge.DEFAULT_PASTE||r===P.id);w.forEach(P=>{var k,N,H;if(s){const W=(k=P.onPasteRows)==null?void 0:k.call(P,{range:h,unitId:d,subUnitId:u},s,{pasteType:r});W&&(b.push(...W.redos),R.push(...W.undos))}const x=(N=P.onPasteColumns)==null?void 0:N.call(P,{range:h,unitId:d,subUnitId:u},l||new Array(g).map(()=>({})),{pasteType:r});x&&(b.push(...x.redos),R.push(...x.undos));const A=(H=P.onPasteCells)==null?void 0:H.call(P,v,{range:h,unitId:d,subUnitId:u},c,C);A&&(b.push(...A.redos),R.push(...A.undos))});const M=this._getSetSelectionOperation(d,u,h,c,r);M&&b.push(M),b=Xo(b),R=Xo(R),R.push({id:m.SetWorksheetActiveOperation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId}}),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:R,redoMutationsInfo:b});const y=b.every(P=>this._commandService.syncExecuteCommand(P.id,P.params));return y&&(this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:R,redoMutations:b}),this.updatePasteOptionsCache({target:{pastedRange:h,unitId:d,subUnitId:u},cellMatrix:c,rowProperties:s,colProperties:l,pasteType:r,source:o}),this.setShowMenu(!0)),w.forEach(P=>{var x;return(x=P.onAfterPaste)==null?void 0:x.call(P,y)}),y}_getSetSelectionOperation(e,t,r,o,s){var M;const l=(M=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:M.getSheetBySheetId(t);if(!l)return null;const{rows:c,cols:d}=r,u=c[0],h=d[0],g=c[c.length-1],S=d[d.length-1],f={startRow:u,endRow:u,startColumn:h,endColumn:h},p=m.getPrimaryForRange(f,l),v=o.getValue(0,0),C=(v==null?void 0:v.rowSpan)||1,b=(v==null?void 0:v.colSpan)||1;if((s===ge.DEFAULT_PASTE||s===ge.SPECIAL_PASTE_BESIDES_BORDER||s===ge.SPECIAL_PASTE_FORMAT)&&(C>1||b>1)){const y={startRow:u,endRow:u+C-1,startColumn:h,endColumn:h+b-1};p.startRow=y.startRow,p.endRow=y.endRow,p.startColumn=y.startColumn,p.endColumn=y.endColumn,p.isMerged=!0,p.isMergedMainCell=!0}const w={unitId:e,subUnitId:t,selections:[{range:{startRow:u,endRow:g,startColumn:h,endColumn:S},primary:p,style:null}]};return{id:m.SetSelectionsOperation.id,params:w}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=e.getActiveSheet(),r=this._selectionManagerService.getCurrentLastSelection();return{unitId:e.getUnitId(),subUnitId:t==null?void 0:t.getSheetId(),selection:r}}_transformPastedData(e,t,r){const o=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:c}=o;if(!c||!s)return null;const d=this._injector.invoke(N=>m.rangeToDiscreteRange(s.range,N,l,c));if(!d)return null;const{ranges:[u],mapFunc:h}=Gt([d]),{startRow:g,startColumn:S,endRow:f,endColumn:p}=u,v=f-g+1,C=p-S+1,b=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),R=b==null?void 0:b.getActiveSheet();if(!R)return null;const M=R.getMergeData().filter(N=>d.rows.includes(N.startRow)&&d.cols.includes(N.startColumn)),y=M[0];let P=0,x=0,A=0,k=0;if(y&&(P=y.startRow,x=y.startColumn,A=y.endRow,k=y.endColumn),v%e===0&&C%t===0)if(M.length>0&&(v!==e||C!==t))if(P===d.rows[0]&&x===d.cols[0]&&A===d.rows[v-1]&&k===d.cols[C-1])if(ag(r))for(let H=0;H<v;H++)for(let W=0;W<C;W++){const D=r.getValue(H%e,W%t);D&&r.setValue(H,W,D)}else r.forValue((H,W,D)=>{D.s=null,delete D.colSpan,delete D.rowSpan});else for(let N=0;N<v;N++)for(let H=0;H<C;H++){const W=r.getValue(N%e,H%t);W&&r.setValue(N,H,W)}else for(let N=0;N<v;N++)for(let H=0;H<C;H++){const W=r.getValue(N%e,H%t);W&&r.setValue(N,H,W)}else if(M.length>0){const{row:N,col:H}=h(g,S);if(this._topLeftCellsMatch(e,t,{topRow:N,leftCol:H})){const D=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=D.rows,d.cols=D.cols}else{if(f>y.endRow||p>y.endColumn)return null;r.forValue((D,U,L)=>{L.s=null,delete L.colSpan,delete L.rowSpan})}}else{const N=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=N.rows,d.cols=N.cols}return{pastedRange:d,unitId:l,subUnitId:c}}_getPastedRange(e){var R;const t=this._getPastingTarget(),{selection:r,unitId:o,subUnitId:s}=t;if(!s||!r)return null;const l=this._injector.invoke(w=>m.rangeToDiscreteRange(r.range,w,o,s));if(!l)return null;const{startColumn:c,endColumn:d,startRow:u,endRow:h}=e.getDataRange(),g=h-u+1,S=d-c+1;if(g<=0||S<=0)return null;const f=l.rows.length,p=l.cols.length,v=(R=this._univerInstanceService.getUniverSheetInstance(o))==null?void 0:R.getSheetBySheetId(s);if(!v)return null;const C=v==null?void 0:v.getMergeData();if(f%g===0&&p%S===0&&!(C==null?void 0:C.some(M=>Zi(M,l)))){for(let M=0;M<f;M++)for(let y=0;y<p;y++){const P=e.getValue(M%g,y%S);P&&e.setValue(M,y,P)}return{pastedRange:l,unitId:o,subUnitId:s}}const b=this._expandOrShrinkRowsCols(o,s,l,S,g);return l.rows=b.rows,l.cols=b.cols,{pastedRange:l,unitId:o,subUnitId:s}}_expandOrShrinkRowsCols(e,t,r,o,s){const{rows:l,cols:c}=r,d=this._univerInstanceService.getUniverSheetInstance(e),u=d==null?void 0:d.getSheetBySheetId(t);let h,g;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let S=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(S)||h.push(S),S++}if(c.length>=o)g=c.slice(0,o);else{g=c.slice(0);let S=c[c.length-1]+1;for(;g.length<o;)g.push(S),S++}return{rows:h,cols:g}}_topLeftCellsMatch(e,t,r){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:c}=r,d=og(l+e-1,c,c+t-1,s),u=sg(c+t-1,l,l+e-1,s);return!d&&!u}removeMarkSelection(){this._copyMarkId&&(this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null)}_initUnitDisposed(){this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&this.copyContentCache().clearWithUnitId(e.getUnitId())}))}disposePasteOptionsCache(){this.setShowMenu(!1),this.updatePasteOptionsCache(null)}};exports.SheetClipboardService=ng([Oe(0,a.ILogService),Oe(1,a.IUniverInstanceService),Oe(2,a.Inject(m.SheetsSelectionsService)),Oe(3,_.IClipboardInterfaceService),Oe(4,a.IUndoRedoService),Oe(5,a.ICommandService),Oe(6,qt),Oe(7,_.INotificationService),Oe(8,_.IPlatformService),Oe(9,T.IRenderManagerService),Oe(10,a.Inject(a.ThemeService)),Oe(11,a.Inject(a.LocaleService)),Oe(12,a.Inject(a.ErrorService)),Oe(13,a.Inject(a.Injector))],exports.SheetClipboardService);function kl(n){let i="";const e=n.getLength();return n.forRow((t,r)=>{const o=[];r.forEach(s=>{const l=n.getValue(t,s);if(l){const c=ig(l);o.push(c)}}),i+=o.join(" "),t!==e-1&&(i+=`
|
|
58
|
-
`)}),i}function ig(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function og(n,i,e,t){return t.getMergeData().some(r=>r.startRow<=n&&n<r.endRow&&i<=r.startColumn&&r.startColumn<=e)}function sg(n,i,e,t){return t.getMergeData().some(r=>r.startColumn<=n&&n<r.endColumn&&i<=r.startRow&&r.startRow<=e)}function ag(n){let i=0;return n.forValue((e,t,r)=>{if(r&&i++,i>1)return!1}),i>1}function Bn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const ys=998,Xe={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).copy()},Ms={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).cut()},Ye={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:ys,preconditions:Es,handler:async(n,i)=>{const t=await n.get(_.IClipboardInterfaceService).read(),r=n.get(Be);return t.length!==0?r.paste(t[0],i==null?void 0:i.value):!1}},oi={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(Be),{htmlContent:t,textContent:r,files:o}=i;return e.legacyPaste(t,r,o),!0}},gn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_VALUE})},Sn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_FORMAT})},Vt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_COL_WIDTH})},fn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_BESIDES_BORDER})},Nl={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:i})=>n.get(Be).rePasteWithPasteType(i)},fr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(Ka(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetRowHiddenCommand.id),!0}},pr={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetColHiddenCommand.id),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatBoldCommand.id):i.executeCommand(m.SetBoldCommand.id)}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatItalicCommand.id):i.executeCommand(m.SetItalicCommand.id)}},$t={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatUnderlineCommand.id):i.executeCommand(m.SetUnderlineCommand.id)}},en={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatStrikethroughCommand.id):i.executeCommand(m.SetStrikeThroughCommand.id)}},Ps={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatSubscriptCommand.id):!1}},Os={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatSuperscriptCommand.id):!1}},vr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand($.SetInlineFormatFontSizeCommand.id,i):e.executeCommand(m.SetFontSizeCommand.id,i)}},Cr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand($.SetInlineFormatFontFamilyCommand.id,i):e.executeCommand(m.SetFontFamilyCommand.id,i)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand($.SetInlineFormatTextColorCommand.id,i):e.executeCommand(m.SetTextColorCommand.id,i)}},xs={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const i=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),r=n.get(a.ThemeService);return t?i.executeCommand($.SetInlineFormatTextColorCommand.id,{value:null}):i.executeCommand(m.SetTextColorCommand.id,{value:r.getCurrentTheme().textColor})}};var lg=Object.getOwnPropertyDescriptor,cg=(n,i,e,t)=>{for(var r=t>1?void 0:t?lg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},ln=(n,i)=>(e,t)=>i(e,t,n),Ne=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Ne||{});const et=a.createIdentifier("univer.format-painter-service");let si=class extends a.Disposable{constructor(i,e,t,r,o,s){super();E(this,"status$");E(this,"_selectionFormat");E(this,"_markId",null);E(this,"_status$");E(this,"_defaultHook",null);E(this,"_extendHooks",[]);this._selectionManagerService=i,this._themeService=e,this._markSelectionService=t,this._logService=r,this._commandService=o,this._undoRedoService=s,this._status$=new O.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(i){var e,t,r;i.isDefaultHook&&((e=i.priority)!=null?e:0)>((r=(t=this._defaultHook)==null?void 0:t.priority)!=null?r:-1)?this._defaultHook=i:(this._extendHooks.push(i),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(i){this._updateRangeMark(i),this._status$.next(i),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(i)})}getStatus(){return this._status$.getValue()}setSelectionFormat(i){this._selectionFormat=i}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(i,e,t){const r=this.getHooks(),o=[],s=[];r.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(i,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of r)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:i,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:i,undoMutations:s,redoMutations:o}),l}_updateRangeMark(i){if(this._markSelectionService.removeAllShapes(),i!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=Ol(this._themeService);i===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};si=cg([ln(0,a.Inject(m.SheetsSelectionsService)),ln(1,a.Inject(a.ThemeService)),ln(2,qt),ln(3,a.ILogService),ln(4,a.ICommandService),ln(5,a.IUndoRedoService)],si);const _r={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,i)=>i?(n.get(et).setStatus(i.status),!0):!1},Vi={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.INFINITE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},kn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.ONCE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},Ir={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,i)=>n.get(et).applyFormatPainter(i.unitId,i.subUnitId,i.range)},ht={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,i)=>{const{type:e}=i||{},t=n.get(a.IUniverInstanceService),r=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(T.IRenderManagerService).getRenderById(s).with(exports.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,b,R,w;const{startRow:M,startColumn:y,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=M,R=M-p,b=-1,w=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,R=0,b=y,w=y-v;else if(P===a.RANGE_TYPE.NORMAL)C=M,R=M-p,b=y,w=y-v;else return!1;const x={unitId:s,subUnitId:l,startRow:C,startColumn:b,xSplit:b>0?Math.max(1,w):w,ySplit:C>0?Math.max(1,R):R},A=m.SetFrozenMutationFactory(n,x);return c.syncExecuteCommand(m.SetFrozenMutation.id,x)&&r.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:A}],redoMutations:[{id:m.SetFrozenMutation.id,params:x}]}),!0}},br={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:1}),!0)},Rr={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:2}),!0)};var dg=Object.getOwnPropertyDescriptor,ug=(n,i,e,t)=>{for(var r=t>1?void 0:t?dg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},fa=(n,i)=>(e,t)=>i(e,t,n);const hg=(n,i)=>{const{unitId:e,subUnitId:t,ranges:r}=n,o={},s=i.getColumnManager();for(let l=0;l<r.length;l++){const c=r[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);o[d]=u.w}}return{unitId:e,subUnitId:t,ranges:r,colWidth:o}};exports.AutoWidthController=class extends a.Disposable{constructor(i,e){super(),this._renderManagerService=i,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(i){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,r=m.getSheetCommandTarget(t);if(!r)return e;const{unitId:o,subUnitId:s,worksheet:l}=r,c=this._renderManagerService.getRenderById(o).with(exports.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(i.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const g={subUnitId:s,unitId:o,ranges:i.ranges,colWidth:h},S=hg(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}};exports.AutoWidthController=ug([fa(0,T.IRenderManagerService),fa(1,a.Inject(a.IUniverInstanceService))],exports.AutoWidthController);const Er={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,i);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(i!=null&&i.ranges)d=[...i.ranges];else{const f=r.getCurrentSelections();for(let p=0;p<f.length;p++)d.push(f[p].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(exports.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Nn="UI_PLUGIN_SHEETS",wr=`${Nn}_COLOR_PICKER_COMPONENT`,Wi=`${Nn}_FONT_FAMILY_COMPONENT`,Ui=`${Nn}_FONT_FAMILY_ITEM_COMPONENT`,Li=`${Nn}_FONT_SIZE_COMPONENT`,tt=`${Nn}_MENU_ITEM_INPUT_COMPONENT`,mg="univer-sheets-ui-context-menu-input",gg="univer-sheets-ui-context-menu-input-container",Sg="univer-sheets-ui-context-menu-input-number",Ki={sheetsUiContextMenuInput:mg,sheetsUiContextMenuInputContainer:gg,sheetsUiContextMenuInputNumber:Sg},Dl=n=>{const{prefix:i,suffix:e,value:t,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=V.useState(),h=S=>{var f;u(S==null?void 0:S.toString()),r((f=S==null?void 0:S.toString())!=null?f:"")};V.useEffect(()=>{c.visible||u(t)},[c.visible]),V.useEffect(()=>{u(t)},[t]);function g(S){S.key==="Backspace"&&S.stopPropagation()}return I.jsxs("div",{className:Ki.sheetsUiContextMenuInput,children:[l.t(i),I.jsx("span",{className:Ki.sheetsUiContextMenuInputContainer,onClick:S=>S.stopPropagation(),children:I.jsx(Y.InputNumber,{className:Ki.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:g,onChange:h,min:o,max:s})}),l.t(e)]})};function fg(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(i=>i?i.activeSheet$.pipe(me.map(e=>e?{workbook:i,worksheet:e}:null)):O.of(null)))}function be(n,i,e){return fg(n).pipe(me.switchMap(t=>t?e(t):O.of(i)))}function Hl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),r=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(s=>s?O.combineLatest([r.selectionMoveEnd$,s.activeSheet$]).pipe(me.switchMap(([l,c])=>{if(!c||l.length===0)return O.of(!1);const d=t.getInterestGroupId(l);if(i){const u=d.filter(h=>i.has(h));return O.of(u.length>0)}else return O.of(d.length>0)})):O.of(!1)))}function tn(n,i,e){return O.combineLatest([i,Hl(n,e)]).pipe(me.map(([t,r])=>t||r))}function te(n,i={},e=!1){var g;const r=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(Se)?n.get(Se):null,l=n.get(a.IContextService),c=new O.BehaviorSubject(!1),d=(g=s==null?void 0:s.visible$)!=null?g:O.of(null),u=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(S=>{c.next(S)});return O.combineLatest([o.currentUser$,r,d,c]).pipe(me.finalize(()=>{u.unsubscribe(),c.complete()}),me.switchMap(([S,f,p,v])=>!f||p!=null&&p.visible&&p.unitId===f.getUnitId()&&!e||v&&!e?O.of(!0):f.activeSheet$.pipe(me.switchMap(C=>{if(!C)return O.of(!0);const b=n.get(m.SheetsSelectionsService),R=n.get(m.RangeProtectionRuleModel),w=n.get(m.WorksheetProtectionRuleModel),y=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(me.startWith(!1));return O.combineLatest([b.selectionMoveEnd$,y]).pipe(me.switchMap(([P,x])=>{if(x)return O.of(!0);const A=f.getUnitId(),k=C.getSheetId(),N=n.get(a.IPermissionService),{workbookTypes:H=[m.WorkbookEditablePermission],worksheetTypes:W,rangeTypes:D}=i,U=[];if(H==null||H.forEach(j=>{U.push(new j(A).id)}),W==null||W.forEach(j=>{U.push(new j(A,k).id)}),w.getRule(A,k))return N.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)));const F=P==null?void 0:P.map(j=>j.range),B=R.getSubunitRuleList(A,k).filter(j=>F==null?void 0:F.some(z=>j.ranges.some(K=>a.Rectangle.intersects(z,K))));return D==null||D.forEach(j=>{B.forEach(z=>{U.push(new j(A,k,z.permissionId).id)})}),N.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)))}))}))))}function Dn(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return O.merge(e.selectionMoveEnd$,r.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),r.composePermission(u).some(g=>g.value===!1)}))}function Vl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return r.getSubunitRuleList(d,u).filter(S=>i==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function Wl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Bi(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Hn(n,i){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return O.combineLatest([l.currentUser$,t]).pipe(me.switchMap(([c,d])=>d?d.activeSheet$.pipe(me.switchMap(u=>{if(!u)return O.of(!0);const h=d.getUnitId(),g=[];return i.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(me.map(f=>f.every(p=>p.value===!0))).pipe(me.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=r.getRule(h,p),C=o.getSubunitRuleList(h,p);return!!(v||C.length)}))})):O.of(!0)))}var Ul=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(Ul||{});function pg(n){const i=n.get(et);return{id:kn.id,subId:Vi.id,type:_.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new O.Observable(e=>{let t=!1;const r=i.status$.subscribe(o=>{t=o!==Ne.OFF,e.next(t)});return e.next(t),()=>{r.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function vg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),r=n.get(m.SheetsSelectionsService);return{id:Qt.id,type:_.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=r.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=r.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Cg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:Jt.id,type:_.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.it;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _g(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:$t.id,type:_.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.ul;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ig(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:en.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.st;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=a.DEFAULT_STYLES.ff;return{id:Cr.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:Wi,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:Ui},value:o.value})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var p;const g=h.id;if(g!==m.SetRangeValuesMutation.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=t.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const v=o.getRange(S.startRow,S.startColumn);f=v==null?void 0:v.getFontFamily()}s.next(f!=null?f:r)}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontFamily()}return s.next(d!=null?d:r),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:vr.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Li,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new O.Observable(c=>{var g;const d=i.onCommandExecuted(S=>{var p,v;const f=S.id;if(f===m.SetRangeValuesMutation.id||f===m.SetSelectionsOperation.id||f===m.SetWorksheetActiveOperation.id){const C=(p=t.getCurrentLastSelection())==null?void 0:p.primary;let b;if(C!=null){const R=l.getRange(C.startRow,C.startColumn);b=R==null?void 0:R.getFontSize()}c.next(b!=null?b:o)}if((f===Re.SetTextSelectionsOperation.id||f===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const C=yr(n);if(C==null)return;const b=(v=C.ts)==null?void 0:v.fs;c.next(b!=null?b:o)}}),u=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let h;if(u!=null){const S=l.getRange(u.startRow,u.startColumn);h=S==null?void 0:S.getFontSize()}return c.next(h!=null?h:o),d.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Eg(n){return{id:xs.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().textColor,o=i.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Tg(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().primaryColor,o=i.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const pa=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function Mg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:pa[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:pa,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const va=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function Pg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:va[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:va,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ca=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function Og(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Ca[0].icon,type:_.MenuItemType.SELECTOR,selections:Ca,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=i.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const _a=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function xg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:_a[0].icon,type:_.MenuItemType.SELECTOR,selections:_a,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=i.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const C=r.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((v=f&&f.a)!=null?v:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=r.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Tr(n){return new O.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function pn(n){return{id:Xe.name,commandId:Xe.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:te(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qi(n){return{id:Ye.name,commandId:Ye.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Jn="sheet.menu.paste-special";function Qi(n){return{id:Jn,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:tn(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function Ji(n){return{id:gn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function $i(n){return{id:Sn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function eo(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e))}}function to(n){return{id:fn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ag(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function kg(n){return{id:Er.id,type:_.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Ll="sheet.menu.sheet-frozen";function Ng(n){return{id:Ll,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Yo="sheet.header-menu.sheet-frozen";function Ia(n){return{id:Yo,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function no(n){return{id:ht.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Dg(n){return{id:br.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hg(n){return{id:Rr.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ro(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vg(n){return{id:fr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wg(n){return{id:pr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ug(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Lg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:tt,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):r;s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Fg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:tt,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=r;d!=null&&(u=o.getColumnWidth(d.startColumn)),s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yr(n){var c;const i=n.get(a.IUniverInstanceService),e=n.get(Re.DocSelectionManagerService),t=i.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=e.getActiveTextRange();if(t==null||r==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var jg=Object.getOwnPropertyDescriptor,zg=(n,i,e,t)=>{for(var r=t>1?void 0:t?jg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xt=(n,i)=>(e,t)=>i(e,t,n);const Xg="__SpreadsheetFreezeRowMainName__",Yg="__SpreadsheetFreezeRowHeaderName__",Gg="__SpreadsheetFreezeColumnMainName__",Zg="__SpreadsheetFreezeColumnHeaderName__",io=2,Kg=.01,Fn=a.createInterceptorKey("freezePermissionCheck");exports.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d){super();E(this,"_rowFreezeHeaderRect");E(this,"_rowFreezeMainRect");E(this,"_columnFreezeHeaderRect");E(this,"_columnFreezeMainRect");E(this,"_freezeDownSubs");E(this,"_freezePointerEnterSubs");E(this,"_freezePointerLeaveSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_changeToRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToOffsetX",0);E(this,"_changeToOffsetY",0);E(this,"_activeViewport",null);E(this,"_freezeNormalHeaderColor","");E(this,"_freezeNormalMainColor","");E(this,"_freezeActiveColor","");E(this,"_freezeHoverColor","");E(this,"_lastFreeze");E(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:Fn}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var x;const r=t!=null?t:this._getFreeze();if(r==null)return null;const o=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton,{startRow:s,startColumn:l}=r,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:b,columnHeaderHeightAndMarginTop:R}=o,w=h>C+b?h:C+R,M=g>v+R?g:v+R;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const y=Math.max(S.scaleX,S.scaleY);let P=io/(y<1?1:y);if(e===0){(s===-1||s===0)&&(P=P*2);const A=P;this._rowFreezeHeaderRect=new T.Rect(Yg,{fill:this._freezeNormalHeaderColor,width:b,height:P,left:0,top:p-A,zIndex:3});let k=this._freezeNormalHeaderColor;(s===-1||s===0)&&(k=this._freezeNormalMainColor),this._rowFreezeMainRect=new T.Rect(Xg,{fill:k,width:w*2/y,height:P,left:b,top:p-A,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],bt)}else{(l===-1||l===0)&&(P=P*2);const A=P;this._columnFreezeHeaderRect=new T.Rect(Zg,{fill:this._freezeNormalHeaderColor,width:P,height:R,left:f-A,top:0,zIndex:3});let k=this._freezeNormalHeaderColor;(l===-1||l===0)&&(k=this._freezeNormalMainColor),this._columnFreezeMainRect=new T.Rect(Gg,{fill:k,width:P,height:M*2/y,left:f-A,top:R,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],bt)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,r=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,r=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new O.Subscription,this._freezePointerLeaveSubs=new O.Subscription,this._freezeDownSubs=new O.Subscription,r){const d=r.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=r.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});l&&this._freezeDownSubs.add(l);const c=r==null?void 0:r.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,b,R,w,M,y,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const r=e.scene,o=Math.max(r.scaleX,r.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(b=s==null?void 0:s.sheetViewStartRow)!=null?b:0,u=d===0?-((R=s==null?void 0:s.offsetY)!=null?R:0):t.rowHeightAccumulation[d-1]-((w=s==null?void 0:s.offsetY)!=null?w:0);let h=0,g=!1;for(let x=d,A=t.rowHeightAccumulation.length;x<A;x++)if(t.rowHeightAccumulation[x]-u>l){h=x,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(M=s==null?void 0:s.sheetViewStartColumn)!=null?M:0,f=S===0?-((y=s==null?void 0:s.offsetX)!=null?y:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let p=0,v=!1;for(let x=S,A=t.columnWidthAccumulation.length;x<A;x++)if(t.columnWidthAccumulation[x]-f>c){p=x,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var r;const t=(r=this._getSheetObject())==null?void 0:r.scene.getViewports();return t&&t.find(o=>o.isHit(new T.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,r,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;const{scene:d}=l;d.setCursor(T.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var P,x,A,k;const v=this._getActiveViewport(p),{startX:C,startY:b,row:R,column:w}=qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;d.setCursor(T.CURSOR_TYPE.GRABBING);const y=io/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(b,h)-y/2}))==null||P.setProps({fill:this._freezeActiveColor}),(x=r.transformByState({top:Math.min(b,h)-y/2}))==null||x.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?R:Math.min(R,u.lastRow),this._changeToOffsetY=Math.min(b,h),this._activeViewport=v):((A=t.transformByState({left:Math.min(C,g)-y/2}))==null||A.setProps({fill:this._freezeActiveColor}),(k=r.transformByState({left:Math.min(C,g)-y/2}))==null||k.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?w:Math.min(w,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var N,H;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),r.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),r==null||r.setProps({fill:this._freezeNormalHeaderColor}));const C=io/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),r.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),r.transformByState({left:p-C}));const b=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:R,sheetViewStartColumn:w}=b;if(w==null||R==null)return;const M=this._context.unit,y=M.getActiveSheet();if(!y)return;const P=(N=y.getConfig())==null?void 0:N.freeze;let x=(P==null?void 0:P.xSplit)||0,A=(P==null?void 0:P.ySplit)||0;const k=(H=this._activeViewport)==null?void 0:H.viewportKey;o===0&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?A=this._changeToRow-(P.startRow-P.ySplit):A=this._changeToRow-R,A=A<0?0:A),o===1&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||k===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?x=this._changeToColumn-(P.startColumn-P.xSplit):x=this._changeToColumn-w,x=x<0?0:x),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:A===0?-1:this._changeToRow,startColumn:x===0?-1:this._changeToColumn,ySplit:A,xSplit:x,unitId:M.getUnitId(),subUnitId:y.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,r=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(r==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:r,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),r.isActive&&r.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,r=0,o=0,s=3){var x;const l=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:b,viewLeftTop:R}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d,right:0}),b.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c}),R.resizeWhenFreezeChange({left:0,top:0,width:c,height:d});let w=!0,M=!0;g.enable(),(e===-1||e===0)&&(w=!1),(t===-1||t===0)&&(M=!1);const y=l.getNoMergeCellWithCoordByIndex(e-r,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),p.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),p.resetPadding(),w===!1&&M===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c,height:0}),p.resizeWhenFreezeChange({left:0,top:0,height:d,width:0});else if(w===!0&&M===!1){const A=P.startY-y.startY;h.resizeWhenFreezeChange({left:c,top:d+A,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(ze.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:A,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c,height:A}),C.updateScrollVal({viewportScrollY:y.startY}),b.resizeWhenFreezeChange({left:0,top:d+A,bottom:0,width:c}),f.enable(),C.enable()}else if(w===!1&&M===!0){const A=P.startX-y.startX;h.resizeWhenFreezeChange({left:c+A,top:d,bottom:0,right:0}),h.setPadding({startX:y.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(ze.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:A,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d,right:0}),S.enable(),p.enable()}else{const A=P.startX-y.startX,k=P.startY-y.startY;h.resizeWhenFreezeChange({left:c+A,top:d+k,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:y.startX,endX:P.startX}),s&&this._commandService.executeCommand(ze.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+k,width:A,bottom:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+A,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:A,height:k}),g.updateScrollVal({viewportScrollX:y.startX,viewportScrollY:y.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c,height:k}),C.updateScrollVal({viewportScrollY:y.startY}),b.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),p.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=r;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new a.ColorKit(e.grey400).setAlpha(Kg).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},r=this._getFreeze();if(!r)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<r.startRow||l.startRow+1===r.startRow&&c===a.Direction.UP){const u={...r,startRow:Math.max(1,r.startRow+d),ySplit:Math.max(1,r.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<r.startColumn||l.startColumn+1===r.startColumn&&c===a.Direction.LEFT){const u={...r,startColumn:Math.max(1,r.startColumn+d),xSplit:Math.max(1,r.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!r||r.startColumn<=0||u.startColumn>=r.startColumn&&h.startColumn>=r.startColumn||u.startColumn===h.startColumn||u.endColumn<r.startColumn&&h.startColumn<r.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(r.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=r.startColumn?(f=Math.max(r.startColumn-S,1),p=Math.max(r.xSplit-S,1)):(f=r.startColumn+g-S,p=r.xSplit+g-S);const v={...r,startColumn:f,xSplit:p};return o(v)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!r||r.startRow<=0||u.startRow>=r.startRow&&h.startRow>=r.startRow||u.startRow===h.startRow||u.endRow<r.startRow&&h.startRow<r.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(r.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=r.startRow?(f=Math.max(r.startRow-S,1),p=Math.max(r.ySplit-S,1)):(f=r.startRow+g-S,p=r.ySplit+g-S);const v={...r,startRow:f,ySplit:p};return o(v)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<r.startColumn){const c=Math.min(r.startColumn,l.endColumn+1)-l.startColumn,d={...r,startColumn:Math.max(1,r.startColumn-c),xSplit:Math.max(1,r.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<r.startRow){const c=Math.min(r.startRow,l.endRow+1)-l.startRow,d={...r,startRow:Math.max(1,r.startRow-c),ySplit:Math.max(1,r.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,r=this._context.unit,o=r.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===r.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),r=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&r&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(r=>r.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,r=this._getFreeze();if(r&&r.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}break;case Oi.id:case xi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(r=>{[T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(r.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,r;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,r,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return Ge(this._context.unit,this._context)}_refreshFreeze(e,t,r,o,s){var c;const l={startRow:e,startColumn:t,ySplit:r,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,r,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}};exports.HeaderFreezeRenderController=zg([xt(1,a.Inject(exports.SheetSkeletonManagerService)),xt(2,a.ICommandService),xt(3,a.Inject(m.SheetsSelectionsService)),xt(4,a.Inject(exports.SheetScrollManagerService)),xt(5,a.Inject(a.ThemeService)),xt(6,a.Inject(m.SheetInterceptorService)),xt(7,a.Inject(a.Injector))],exports.HeaderFreezeRenderController);function qg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),r=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return O.combineLatest([i.selectionMoveEnd$,o.pipe(O.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(O.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:O.of(null)}))]).pipe(O.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(r.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(p=>a.Rectangle.intersects(p,S)&&!a.Rectangle.contains(p,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function Bl(n,i){return!!ir(n,i,a.RANGE_TYPE.ROW)}function Fl(n,i){return!!ir(n,i,a.RANGE_TYPE.COLUMN)}function ir(n,i,e){return n.find(r=>{const o=r.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=i&&i<=d||e===a.RANGE_TYPE.ROW&&s<=i&&i<=l)})}var Qg=Object.getOwnPropertyDescriptor,Jg=(n,i,e,t)=>{for(var r=t>1?void 0:t?Qg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},oo=(n,i)=>(e,t)=>i(e,t,n);const $g="__SpreadsheetHeaderMoveControllerBackground__",eS="__SpreadsheetHeaderMoveControllerShapeLine__",tS="rgba(0, 0, 0, 0.1)",nS="rgb(119, 119, 119)",rS=4,so=a.createInterceptorKey("headerMovePermissionCheck");exports.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_startOffsetX",Number.NEGATIVE_INFINITY);E(this,"_startOffsetY",Number.NEGATIVE_INFINITY);E(this,"_moveHelperBackgroundShape");E(this,"_moveHelperLineShape");E(this,"_headerPointerDownSubs");E(this,"_headerPointerMoveSubs");E(this,"_headerPointerLeaveSubs");E(this,"_dragHeaderMoveSub");E(this,"_scenePointerUpSub");E(this,"_scrollTimer");E(this,"_changeFromColumn",-1);E(this,"_changeFromRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToRow",-1);E(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:so}));E(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=r,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,r,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(r=this._headerPointerMoveSubs)==null||r.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?r:t,l=u=>{var b,R;const h=(b=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:b.skeleton;if(h==null)return;const g=(R=this._workbookSelections.getCurrentLastSelection())==null?void 0:R.range;if(!g||!this.interceptor.fetchThroughInterceptors(so)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=qe(u.offsetX,u.offsetY,o,h);if(!ir(f,e===a.RANGE_TYPE.ROW?p:v,e)){o.resetCursor();return}o.setCursor(T.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var W,D;if(h.isStopPropagation)return;const g=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(g==null)return;const S=(D=this._workbookSelections.getCurrentLastSelection())==null?void 0:D.range;if(!S||!this.interceptor.fetchThroughInterceptors(so)(!1,S))return;const{offsetX:p,offsetY:v}=u,C=o.getCoordRelativeToViewport(T.Vector2.FromArray([p,v])),{x:b,y:R}=C;this._startOffsetX=b,this._startOffsetY=R;const{row:w,column:M}=qe(u.offsetX,u.offsetY,o,g);let y;e===a.RANGE_TYPE.ROW?(this._changeFromRow=w,y=T.ScrollTimerType.Y):(this._changeFromColumn=M,y=T.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),x=ir(P,e===a.RANGE_TYPE.ROW?w:M,e);if(!x)return;const A=o.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(T.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let k=!1,N;const H=()=>{if(k)return;N=T.ScrollTimer.create(o,y),this._scrollTimer=N;const U=o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);N.startScroll(b,R,U),k=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{H();const{offsetX:L,offsetY:F}=U,{x:B,y:j}=o.getCoordRelativeToViewport(T.Vector2.FromArray([L,F]));this._rowColumnMoving(B,j,x,A,e),N.scrolling(B,j,()=>{this._rowColumnMoving(B,j,x,A,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var L,F,B;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(L=this._scrollTimer)==null||L.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const z=(F=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.ROW&&K.range.startRow<=this._changeFromRow&&this._changeFromRow<=K.range.endRow))||[])[0])==null?void 0:F.range;z&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:z,toRange:{...z,startRow:this._changeToRow,endRow:this._changeToRow+z.endRow-z.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const z=(B=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.COLUMN&&K.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=K.range.endColumn))||[])[0])==null?void 0:B.range;z&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:z,toRange:{...z,startColumn:this._changeToColumn,endColumn:this._changeToColumn+z.endColumn-z.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new O.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new O.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new O.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,r,o,s){var j,z,K,ne,Q,se,ce;const l=this._context.scene,c=(j=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:j.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,S),{row:C,column:b}=v,R=c.getNoMergeCellWithCoordByIndex(C,b),{startX:w,startY:M,endX:y,endY:P}=R,x=this._sheetSkeletonManagerService.attachRangeWithCoord(r.range);if(x==null)return;const A=Math.max(f,f),{startX:k,endX:N,startY:H,endY:W,startRow:D,startColumn:U,endRow:L,endColumn:F}=x;s===a.RANGE_TYPE.ROW?(z=this._moveHelperBackgroundShape)==null||z.transformByState({height:W-H,width:g+d,left:0,top:H+(t-this._startOffsetY)/A+S.y-o.y}):(K=this._moveHelperBackgroundShape)==null||K.transformByState({height:h+u,width:N-k,left:k+(e-this._startOffsetX)/A+S.x-o.x,top:0}),(ne=this._moveHelperBackgroundShape)==null||ne.show();const B=rS/A;if(s===a.RANGE_TYPE.ROW){let X=0;if(C<=D)X=M-B/2,this._changeToRow=C;else if(C>L)X=P-B/2,this._changeToRow=C+1;else return;(Q=this._moveHelperLineShape)==null||Q.transformByState({height:B,width:g,left:d,top:X})}else{let X=0;if(b<=U)X=w-B/2,this._changeToColumn=b;else if(b>F)X=y-B/2,this._changeToColumn=b+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:B,left:X,top:u})}(ce=this._moveHelperLineShape)==null||ce.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new T.Rect($g,{fill:tS,evented:!1,zIndex:100}),this._moveHelperLineShape=new T.Rect(eS,{fill:nS,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],bt)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}};exports.HeaderMoveRenderController=Jg([oo(1,a.Inject(m.SheetsSelectionsService)),oo(2,a.Inject(exports.SheetSkeletonManagerService)),oo(3,a.ICommandService)],exports.HeaderMoveRenderController);var Go=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Go||{});const iS="rgba(120, 120, 120, 0.01)",ao="rgb(68, 71, 70)",Zn=12,oS=44,Zo=4;class ba extends T.Shape{constructor(e,t){super(e,t);E(this,"_size",Zn);E(this,"_color",ao);E(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:r,scaleY:o}=t.getAncestorScale(),s=Math.max(r,o),l=Zn/s,c=Zo/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),T.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:iS}),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.save(),e.transform(1,0,0,1,h,g),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:Zn,height:this.size}):this.transformByState({width:this.size,height:Zn}),this}}var sS=Object.getOwnPropertyDescriptor,aS=(n,i,e,t)=>{for(var r=t>1?void 0:t?sS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},lo=(n,i)=>(e,t)=>i(e,t,n);const lS="__SpreadsheetHeaderResizeControllerShapeRow__",cS="__SpreadsheetHeaderResizeControllerShapeColumn__",Ra="__SpreadsheetHeaderResizeControllerShapeHelper__",Ea="rgb(199, 199, 199)",dS=2,co=a.createInterceptorKey("headerResizePermissionCheck");exports.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_currentRow",0);E(this,"_currentColumn",0);E(this,"_rowResizeRect");E(this,"_columnResizeRect");E(this,"_headerPointerSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_resizeHelperShape");E(this,"_startOffsetX",Number.POSITIVE_INFINITY);E(this,"_startOffsetY",Number.POSITIVE_INFINITY);E(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:co}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=r,this._commandService=o,this._init()}dispose(){var e,t,r;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(r=this._headerPointerSubs)==null||r.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new ba(lS,{visible:!1,mode:Go.HORIZONTAL,zIndex:100}),this._columnResizeRect=new ba(cS,{visible:!1,mode:Go.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],bt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?r:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var A;const h=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:p,endX:v,endY:C,row:b,column:R}=qe(d.offsetX,d.offsetY,o,h),w=Qn(d.offsetX,d.offsetY,o),{scaleX:M,scaleY:y}=o.getAncestorScale(),P=Math.max(M,y),x=Zn/P;if(e===0){let k=p-x/2;if(w.y<=p+x/2&&w.y>=p)this._currentRow=b-1;else if(w.y>=C-x/2&&w.y<=C)this._currentRow=b,k=C-x/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{row:this._currentRow}))return!1;const H=Math.min(oS,g/3);this._rowResizeRect.transformByState({left:g/2-H/2,top:k}),this._rowResizeRect.setShapeProps({size:H}),this._rowResizeRect.show()}else{let k=f-x/2;if(w.x<=f+x/2&&w.x>=f)this._currentColumn=R-1;else if(w.x>=v-x/2&&w.x<=v)this._currentColumn=R,k=v-x/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{col:this._currentColumn}))return!1;const H=S*.7;this._columnResizeRect.transformByState({left:k,top:S/2-H/2}),this._columnResizeRect.setShapeProps({size:H}),this._columnResizeRect.show()}};this._headerPointerSubs=new O.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,r=e===0?this._rowResizeRect:this._columnResizeRect;r!=null&&(this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r!=null&&(r.show(),t.setCursor(e===0?T.CURSOR_TYPE.ROW_RESIZE:T.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r!=null&&(r.hide(),t.resetCursor())})),this.disposeWithMe(r.onPointerDown$.subscribeEvent(o=>{var F,B,j,z,K,ne,Q;const s=(F=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:F.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((j=(B=h==null?void 0:h.getScrollBar())==null?void 0:B.horizonScrollTrack)==null?void 0:j.height)||0)+10,S=(((K=(z=h==null?void 0:h.getScrollBar())==null?void 0:z.verticalScrollTrack)==null?void 0:K.width)||0)+10,f=Qn(o.offsetX,o.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),b=s.getOffsetByRow(this._currentRow),R=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let w=!1,M=0,y=0;const{columnTotalWidth:P,rowHeaderWidth:x,rowTotalHeight:A,columnHeaderHeight:k}=s,N=u>P+x?u:P+x,H=d>A+k?d:A+k,W=Math.max(p,v),D=Zo/W;e===0?this._resizeHelperShape=new T.Rect(Ra,{width:N,height:D,fill:Ea,left:0,top:b-D/2}):this._resizeHelperShape=new T.Rect(Ra,{width:D,height:H,fill:Ea,left:C-D/2,top:0});const U=((ne=this._columnResizeRect)==null?void 0:ne.left)||0,L=((Q=this._rowResizeRect)==null?void 0:Q.top)||0;l.addObject(this._resizeHelperShape,bt),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var fe,Te,we,Fe,St,Mt;const ce=l.getCoordRelativeToViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),X=l.getScrollXYInfoByViewport(ce,h),G=Qn(se.offsetX,se.offsetY,l),{x:q,y:ie}=G,{scaleX:oe,scaleY:J}=l.getAncestorScale(),ee=Math.max(oe,J),de=Zo/ee;M=q-this._startOffsetX-de/2,y=ie-this._startOffsetY-de/2,Math.abs(e===0?y:M)>=dS&&(w=!0),e===0?(y>d-g+X.y-R.startY&&(y=d-g+X.y-R.startY),y<-(R.endY-R.startY)+2&&(y=-(R.endY-R.startY)+2),w&&((fe=this._resizeHelperShape)==null||fe.transformByState({top:b+y}),(Te=this._rowResizeRect)==null||Te.transformByState({top:L+y+de/2}),(we=this._rowResizeRect)==null||we.show(),l.setCursor(T.CURSOR_TYPE.ROW_RESIZE))):(M>u-S+X.x-R.startX&&(M=u-S+X.x-R.startX),M<-(R.endX-R.startX)+2&&(M=-(R.endX-R.startX)+2),w&&((Fe=this._resizeHelperShape)==null||Fe.transformByState({left:C+M}),(St=this._columnResizeRect)==null||St.transformByState({left:U+M+de/2}),(Mt=this._columnResizeRect)==null||Mt.show(),l.setCursor(T.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var X,G,q;const ce=this._context.scene;this._clearObserverEvent(),(X=this._resizeHelperShape)==null||X.dispose(),this._resizeHelperShape=null,ce.enableObjectsEvent(),w&&(ce.resetCursor(),(G=this._rowResizeRect)==null||G.hide(),(q=this._columnResizeRect)==null||q.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:y,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:M,anchorCol:this._currentColumn}))})})),this.disposeWithMe(r.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),p=[];for(let v=0;v<f.length;v++){const C=f[v];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&p.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}p.length===0&&p.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(Er.id,{ranges:p}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}};exports.HeaderResizeRenderController=aS([lo(1,a.Inject(exports.SheetSkeletonManagerService)),lo(2,a.Inject(m.SheetsSelectionsService)),lo(3,a.ICommandService)],exports.HeaderResizeRenderController);var uS=Object.getOwnPropertyDescriptor,hS=(n,i,e,t)=>{for(var r=t>1?void 0:t?uS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Lr=(n,i)=>(e,t)=>i(e,t,n);const mS=60;exports.SheetRenderController=class extends a.RxDisposable{constructor(e,t,r,o,s){super();E(this,"_renderFrameTimeMetric",null);E(this,"_renderFrameTags",{});E(this,"_afterRenderMetric$",new O.Subject);this._context=e,this._sheetSkeletonManagerService=t,this._sheetRenderService=r,this._commandService=o,this._telemetryService=s,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:r}=this._context;this._addComponent(r),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){if(!this._telemetryService)return;const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(T.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([r,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[r]||(this._renderFrameTimeMetric[r]=[]),this._renderFrameTimeMetric[r].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([r,o])=>{this._renderFrameTags[r]=o});const t=[];this._afterRenderMetric$.pipe(O.withLatestFrom(e.endFrame$)).subscribe(([r,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...r.frameTimeMetric,...r.tags}),t.length>mS&&(this._renderMetricCapture(t),t.length=0)})}_renderMetricCapture(e){if(!this._telemetryService)return;const t=e;if(t.length===0)return;const r=g=>{let S=0;const p=Object.entries(g).filter(([C,b])=>Array.isArray(b)).map(([C])=>C).reduce((C,b)=>{const R=g[b].reduce((w,M)=>w+M,0);return C[b]=R,C},{});return Object.keys(g).filter(C=>C.startsWith(T.SHEET_EXTENSION_PREFIX)).forEach(C=>{S+=p[C]}),{...p,extensionTotal:S}},o=e.map(g=>({...g,...r(g)})),l=(g=>Object.entries(g[0]).filter(([p,v])=>!["elapsedTime"].includes(p)).filter(([p,v])=>typeof v=="number").map(([p])=>p).reduce((p,v)=>{const C=g.map(M=>M[v]),b=Math.max(...C),R=Math.min(...C),w=C.reduce((M,y)=>M+y,0)/C.length;return p[v]={max:Math.round(b*100)/100,min:Math.round(R*100)/100,avg:Math.round(w*100)/100},p},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._telemetryService.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:r}=this._context,o=e.getActiveSheet(),s=new T.Spreadsheet(he.MAIN);this._addViewport(o);const l=new T.SpreadsheetRowHeader(he.ROW),c=new T.SpreadsheetColumnHeader(he.COLUMN),d=new T.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,r.set(he.MAIN,s),r.set(he.ROW,l),r.set(he.COLUMN,c),r.set(he.LEFT_TOP,d),t.addObjects([s],Bs),t.addObjects([l,c,d],bt),t.enableLayerCache(Bs,bt)}_initViewports(e,t,r){const l=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:r.height,bottom:0,width:t.width,isWheelPreventDefaultX:!0}),S=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),p=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:r.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:r,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,r,o);return new T.ScrollBar(s),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:r}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(r);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:r}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(r)||this._sheetRenderService.checkMutationShouldTriggerRerender(r)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:r},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:r})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(r)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:r}=this._context;if(e.id===Z.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),r.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(r);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,r=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),r<Number(S)&&(r=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:r}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:r,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:r[u-1]+l,p=r[h]+l,v=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const r=e.filter(o=>o.isActive&&o.cacheBound);for(const o of r)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}};exports.SheetRenderController=hS([Lr(1,a.Inject(exports.SheetSkeletonManagerService)),Lr(2,a.Inject(exports.SheetsRenderService)),Lr(3,a.ICommandService),Lr(4,a.Optional(md.ITelemetryService))],exports.SheetRenderController);function gS(n,i){if(n.length!==i.length)return!1;const e=n.sort((r,o)=>r.id.localeCompare(o.id)),t=i.sort((r,o)=>r.id.localeCompare(o.id));return e.every((r,o)=>{var s,l;return((s=r.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&r.role===t[o].role})}function jl(n,i){return i.some(e=>SS(n,e))}function SS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function zl(n,i,e,t){const r=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=fS(e,l),d={unitId:i,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);r.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function fS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r,a.CellModeEnum.Intercepted),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function pS(n,i,e,t){const r=e.getActiveViewportByCoord(T.Vector2.FromArray([n,i]));if(!r)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:r.viewportScrollX,y:r.viewportScrollY},c=t.getCellIndexByOffset(n,i,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function wa(n,i,e,t){const r=t.getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0||n>=r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function vS(n,i,e,t){const r=Ta(n.left,n.top,i,e,t),o=Ta(n.right,n.bottom,i,e,t);return{left:r.x,top:r.y,right:o.x,bottom:o.y}}function Ta(n,i,e,t,r){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:i};const c=r.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-S.startX,b=f.startY-S.startY,{top:R,left:w,viewportScrollX:M,viewportScrollY:y}=l;let P;n>w?P=(n-M)*o:P=(C+p-(w-n))*o;let x;return i>R?x=(i-y)*s:x=(b+v-(R-i))*o,{x:P,y:x}}function Xl(n,i,e,t,r){let o=t,s=r;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:i.getSheetId(),workbook:n,worksheet:i,row:l.actualRow,col:l.actualColumn}}function Yl(n,i,e,t,r,o){const{scene:s}=n,l=i.getUnitId(),{skeleton:c,sheetId:d}=t,u=pS(r,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:i,worksheet:e,row:g,col:h};c.overflowCache.forValue((y,P,x)=>{x.startRow<=g&&x.endRow>=g&&x.startColumn<=h&&x.endColumn>=h&&(h=P,g=y)});const f=c.getCellWithCoordByIndex(g,h),p=Xl(i,e,c,g,h);let v;f.mergeInfo?v=f.mergeInfo:v={startRow:p.row,endRow:p.row,startColumn:p.col,endColumn:p.col};const C=s.getActiveViewportByCoord(T.Vector2.FromArray([r,o]));if(!C)return;const{scaleX:b,scaleY:R}=s.getAncestorScale(),w={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-w.x)*b,endX:(c.getOffsetByColumn(v.endColumn)-w.x)*b,startY:(c.getOffsetByRow(v.startRow-1)-w.y)*R,endY:(c.getOffsetByRow(v.endRow)-w.y)*R},location:S,overflowLocation:p}}const Tt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=i.unitId,c=i.subUnitId,d=i.selections,u=m.getAddMergeMutationRangeByType(d,i.value),h=r.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=jl(h,u);if(f&&!i.defaultMerge&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,p),b=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:v}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:b}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const x=zl(n,l,h,u);g.unshift(...x.redos),S.push(...x.undos)}const R=m.AddMergeRedoSelectionsOperationFactory(n,i,u);R&&g.push(R);const w=m.AddMergeUndoSelectionsOperationFactory(n,i);w&&S.push(w);const y=n.get(m.SheetInterceptorService).onCommandExecute({id:Tt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...y.redos),S.push(...y.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},As={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeAll,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{selections:r,unitId:c,subUnitId:d})}},ks={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeVertical,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.COLUMNS,selections:r,unitId:c,subUnitId:d})}},Ns={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeHorizontal,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.ROWS,selections:r,unitId:c,subUnitId:d})}},Vn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Vn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Xt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Xt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Yt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Yt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Yt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},Wn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Wn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var Gl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Gl||{}),re=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(re||{}),ke=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ke||{}),dt=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(dt||{}),Ke=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ke||{});const or="UNIVER_SHEET_PERMISSION_PANEL",ai="UNIVER_SHEET_PERMISSION_USER_PART",Ds="UNIVER_SHEET_PERMISSION_BACKGROUND",Zl="UNIVER_SHEET_PERMISSION_USER_DIALOG",Kl="UNIVER_SHEET_PERMISSION_DIALOG",li="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",ci="UNIVER_SHEET_PERMISSION_DIALOG_ID",Br={[re.Copy]:"Copy",[re.SetCellStyle]:"SetCellStyle",[re.SetCellValue]:"SetCellValue",[re.SetRowStyle]:"SetRowStyle",[re.SetColumnStyle]:"SetColumnStyle",[re.InsertRow]:"InsertRow",[re.InsertColumn]:"InsertColumn",[re.InsertHyperlink]:"InsertHyperlink",[re.DeleteRow]:"DeleteRow",[re.DeleteColumn]:"DeleteColumn",[re.Sort]:"Sort",[re.Filter]:"Filter",[re.PivotTable]:"PivotTable",[re.EditExtraObject]:"EditExtraObject"},CS=[re.Copy,re.SetCellStyle,re.SetCellValue,re.SetRowStyle,re.SetColumnStyle,re.InsertRow,re.InsertColumn,re.InsertHyperlink,re.DeleteRow,re.DeleteColumn,re.Sort,re.Filter,re.PivotTable,re.EditExtraObject,re.View],ql="sheet-permission-menu-icon",_S="sheet-permission-delete-icon",IS="sheet-permission-edit-icon",bS="sheet-permission-check-icon",Ql="sheet-permission-lock-icon",RS={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class yn{constructor(){E(this,"_rule",RS);E(this,"_visible",!1)}setVisible(i){this._visible=i}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class yt{constructor(){E(this,"_userList",[]);E(this,"_userList$",new O.BehaviorSubject(this._userList));E(this,"userList$",this._userList$.asObservable());E(this,"_oldCollaboratorList",[]);E(this,"_selectUserList",[]);E(this,"_selectUserList$",new O.BehaviorSubject(this._selectUserList));E(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(i){this._userList=i,this._userList$.next(i)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(i){this._oldCollaboratorList=i}get selectUserList(){return this._selectUserList}setSelectUserList(i){this._selectUserList=i,this._selectUserList$.next(i)}}const Qe={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,i={}){const e=n.get(_.ISidebarService),t=n.get(yn),r=n.get(yt),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=i,d={header:{title:"permission.panel.title"},children:{label:or,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),r.reset()}};return t.setVisible(!0),e.open(d),!0}},Mr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Pr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{fromSheetBar:!0,showDetail:!0}),!0}},Or={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return i.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=r.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,g)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await i.executeCommand(m.DeleteRangeProtectionMutation.id,v)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:v}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[p]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=r.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(p=>{var v;return(v=p==null?void 0:p.ranges)==null?void 0:v.some(C=>a.Rectangle.intersects(C,h))});if(f){const p={...f,unitId:l,subUnitId:c};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},Mn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(Ka(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Pn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},xr={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{const{subUnitId:e}=i,t=n.get(_.IConfirmService),r=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Ar={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Kt).triggerSheetBarMenu(),!0)},kr={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,i){if(!i)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(Gl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=r.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},Nr={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},Fi={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,i)=>(n.get(Se).setEditCell(i),!0)},Dr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,i)=>{const e=n.get(Kt);return i&&e.setRenameId(i.subUnitId),!0}},Hs={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,i){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:ci,title:{title:"permission.dialog.allowedPermissionType"},children:{label:Kl},width:393,destroyOnClose:!0,onClose:()=>e.close(ci)}),!0}},ES=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),I.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),I.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),I.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),I.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),I.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),I.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),I.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),I.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),I.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),I.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),I.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),I.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),I.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),I.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),I.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),I.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),I.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),I.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),I.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),I.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),I.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),I.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),I.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),I.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),I.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),I.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),wS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),I.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),I.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),I.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),I.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),I.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),I.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),I.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),I.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),I.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),I.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),I.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),I.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),I.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),I.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),I.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),I.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),I.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),I.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),I.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),I.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),I.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),I.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),I.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),I.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),I.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),I.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),I.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),TS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),I.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),I.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),I.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),I.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),I.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),I.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),I.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),I.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),I.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),I.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),I.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),I.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),I.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),I.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),I.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),I.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),I.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),I.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),I.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),yS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),I.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),I.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),I.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),I.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),I.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),I.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),I.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),I.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),I.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),I.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),I.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),I.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),I.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),I.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),I.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),I.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),I.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),I.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),I.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),I.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),I.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),I.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),I.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),I.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),I.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),I.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),I.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),I.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),I.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),I.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),I.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),I.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),I.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),I.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),I.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),I.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),I.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),I.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),I.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),I.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),I.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),I.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),I.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),I.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),I.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),I.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),I.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),MS=()=>I.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),PS=()=>I.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),I.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),I.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),I.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),I.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),I.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),I.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),I.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),I.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),I.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),I.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),I.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),I.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),I.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),I.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),I.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),I.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),I.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),OS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),I.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),I.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),I.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),I.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),I.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),I.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),I.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),I.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),I.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),I.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),I.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),I.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),I.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),I.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),I.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),I.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),I.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),I.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),I.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),xS=()=>I.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),I.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),I.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),I.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),I.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),I.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),I.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),I.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),I.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),I.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),I.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),I.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),I.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),I.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),I.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),I.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),I.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),I.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),I.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),I.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),AS=()=>I.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),ya=()=>I.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Ma(n){const{type:i=a.BorderStyleTypes.THIN}=n;switch(i){case a.BorderStyleTypes.DASH_DOT:return I.jsx(ES,{});case a.BorderStyleTypes.DASH_DOT_DOT:return I.jsx(wS,{});case a.BorderStyleTypes.DASHED:return I.jsx(TS,{});case a.BorderStyleTypes.HAIR:return I.jsx(yS,{});case a.BorderStyleTypes.MEDIUM:return I.jsx(MS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return I.jsx(PS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return I.jsx(OS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return I.jsx(xS,{});case a.BorderStyleTypes.THICK:return I.jsx(AS,{});case a.BorderStyleTypes.THIN:return I.jsx(ya,{});default:return I.jsx(ya,{})}}const Vs=`${Nn}_BORDER_PANEL_COMPONENT`,Jl=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],kS=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function $l(n){var l;const i=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:r}=n;function o(c,d){t==null||t({...r,[d]:c})}function s(c){const d=i.get(c);return d&&I.jsx(d,{extend:{colorChannel1:"#2c53f1"}})}return I.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[I.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2",children:Jl.map(c=>I.jsx("a",{className:Y.clsx(`
|
|
58
|
+
`)}),i}function ig(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function og(n,i,e,t){return t.getMergeData().some(r=>r.startRow<=n&&n<r.endRow&&i<=r.startColumn&&r.startColumn<=e)}function sg(n,i,e,t){return t.getMergeData().some(r=>r.startColumn<=n&&n<r.endColumn&&i<=r.startRow&&r.startRow<=e)}function ag(n){let i=0;return n.forValue((e,t,r)=>{if(r&&i++,i>1)return!1}),i>1}function Bn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const ys=998,Xe={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).copy()},Ms={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:ys,preconditions:Es,handler:async n=>n.get(Be).cut()},Ye={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:ys,preconditions:Es,handler:async(n,i)=>{const t=await n.get(_.IClipboardInterfaceService).read(),r=n.get(Be);return t.length!==0?r.paste(t[0],i==null?void 0:i.value):!1}},oi={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(Be),{htmlContent:t,textContent:r,files:o}=i;return e.legacyPaste(t,r,o),!0}},gn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_VALUE})},Sn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_FORMAT})},Vt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_COL_WIDTH})},fn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_BESIDES_BORDER})},Nl={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:i})=>n.get(Be).rePasteWithPasteType(i)},fr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(Ka(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetRowHiddenCommand.id),!0}},pr={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetColHiddenCommand.id),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatBoldCommand.id):i.executeCommand(m.SetBoldCommand.id)}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatItalicCommand.id):i.executeCommand(m.SetItalicCommand.id)}},$t={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatUnderlineCommand.id):i.executeCommand(m.SetUnderlineCommand.id)}},en={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatStrikethroughCommand.id):i.executeCommand(m.SetStrikeThroughCommand.id)}},Ps={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatSubscriptCommand.id):!1}},Os={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand($.SetInlineFormatSuperscriptCommand.id):!1}},vr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand($.SetInlineFormatFontSizeCommand.id,i):e.executeCommand(m.SetFontSizeCommand.id,i)}},Cr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand($.SetInlineFormatFontFamilyCommand.id,i):e.executeCommand(m.SetFontFamilyCommand.id,i)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand($.SetInlineFormatTextColorCommand.id,i):e.executeCommand(m.SetTextColorCommand.id,i)}},xs={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const i=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),r=n.get(a.ThemeService);return t?i.executeCommand($.SetInlineFormatTextColorCommand.id,{value:null}):i.executeCommand(m.SetTextColorCommand.id,{value:r.getCurrentTheme().textColor})}};var lg=Object.getOwnPropertyDescriptor,cg=(n,i,e,t)=>{for(var r=t>1?void 0:t?lg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},ln=(n,i)=>(e,t)=>i(e,t,n),Ne=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Ne||{});const et=a.createIdentifier("univer.format-painter-service");let si=class extends a.Disposable{constructor(i,e,t,r,o,s){super();E(this,"status$");E(this,"_selectionFormat");E(this,"_markId",null);E(this,"_status$");E(this,"_defaultHook",null);E(this,"_extendHooks",[]);this._selectionManagerService=i,this._themeService=e,this._markSelectionService=t,this._logService=r,this._commandService=o,this._undoRedoService=s,this._status$=new O.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(i){var e,t,r;i.isDefaultHook&&((e=i.priority)!=null?e:0)>((r=(t=this._defaultHook)==null?void 0:t.priority)!=null?r:-1)?this._defaultHook=i:(this._extendHooks.push(i),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(i){this._updateRangeMark(i),this._status$.next(i),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(i)})}getStatus(){return this._status$.getValue()}setSelectionFormat(i){this._selectionFormat=i}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(i,e,t){const r=this.getHooks(),o=[],s=[];r.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(i,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of r)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:i,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:i,undoMutations:s,redoMutations:o}),l}_updateRangeMark(i){if(this._markSelectionService.removeAllShapes(),i!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=Ol(this._themeService);i===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};si=cg([ln(0,a.Inject(m.SheetsSelectionsService)),ln(1,a.Inject(a.ThemeService)),ln(2,qt),ln(3,a.ILogService),ln(4,a.ICommandService),ln(5,a.IUndoRedoService)],si);const _r={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,i)=>i?(n.get(et).setStatus(i.status),!0):!1},Vi={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.INFINITE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},kn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(et).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.ONCE,n.get(a.ICommandService).executeCommand(_r.id,{status:t})}},Ir={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,i)=>n.get(et).applyFormatPainter(i.unitId,i.subUnitId,i.range)},ht={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,i)=>{const{type:e}=i||{},t=n.get(a.IUniverInstanceService),r=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(T.IRenderManagerService).getRenderById(s).with(exports.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,b,R,w;const{startRow:M,startColumn:y,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=M,R=M-p,b=-1,w=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,R=0,b=y,w=y-v;else if(P===a.RANGE_TYPE.NORMAL)C=M,R=M-p,b=y,w=y-v;else return!1;const x={unitId:s,subUnitId:l,startRow:C,startColumn:b,xSplit:b>0?Math.max(1,w):w,ySplit:C>0?Math.max(1,R):R},A=m.SetFrozenMutationFactory(n,x);return c.syncExecuteCommand(m.SetFrozenMutation.id,x)&&r.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:A}],redoMutations:[{id:m.SetFrozenMutation.id,params:x}]}),!0}},br={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:1}),!0)},Rr={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(ht.id,{type:2}),!0)};var dg=Object.getOwnPropertyDescriptor,ug=(n,i,e,t)=>{for(var r=t>1?void 0:t?dg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},fa=(n,i)=>(e,t)=>i(e,t,n);const hg=(n,i)=>{const{unitId:e,subUnitId:t,ranges:r}=n,o={},s=i.getColumnManager();for(let l=0;l<r.length;l++){const c=r[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);o[d]=u.w}}return{unitId:e,subUnitId:t,ranges:r,colWidth:o}};exports.AutoWidthController=class extends a.Disposable{constructor(i,e){super(),this._renderManagerService=i,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(i){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,r=m.getSheetCommandTarget(t);if(!r)return e;const{unitId:o,subUnitId:s,worksheet:l}=r,c=this._renderManagerService.getRenderById(o).with(exports.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(i.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const g={subUnitId:s,unitId:o,ranges:i.ranges,colWidth:h},S=hg(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}};exports.AutoWidthController=ug([fa(0,T.IRenderManagerService),fa(1,a.Inject(a.IUniverInstanceService))],exports.AutoWidthController);const Er={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,i);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(i!=null&&i.ranges)d=[...i.ranges];else{const f=r.getCurrentSelections();for(let p=0;p<f.length;p++)d.push(f[p].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(exports.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Nn="UI_PLUGIN_SHEETS",wr=`${Nn}_COLOR_PICKER_COMPONENT`,Wi=`${Nn}_FONT_FAMILY_COMPONENT`,Ui=`${Nn}_FONT_FAMILY_ITEM_COMPONENT`,Li=`${Nn}_FONT_SIZE_COMPONENT`,tt=`${Nn}_MENU_ITEM_INPUT_COMPONENT`,mg="univer-sheets-ui-context-menu-input",gg="univer-sheets-ui-context-menu-input-container",Sg="univer-sheets-ui-context-menu-input-number",Ki={sheetsUiContextMenuInput:mg,sheetsUiContextMenuInputContainer:gg,sheetsUiContextMenuInputNumber:Sg},Dl=n=>{const{prefix:i,suffix:e,value:t,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=V.useState(),h=S=>{var f;u(S==null?void 0:S.toString()),r((f=S==null?void 0:S.toString())!=null?f:"")};V.useEffect(()=>{c.visible||u(t)},[c.visible]),V.useEffect(()=>{u(t)},[t]);function g(S){S.key==="Backspace"&&S.stopPropagation()}return I.jsxs("div",{className:Ki.sheetsUiContextMenuInput,children:[l.t(i),I.jsx("span",{className:Ki.sheetsUiContextMenuInputContainer,onClick:S=>S.stopPropagation(),children:I.jsx(Y.InputNumber,{className:Ki.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:g,onChange:h,min:o,max:s})}),l.t(e)]})};function fg(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(i=>i?i.activeSheet$.pipe(me.map(e=>e?{workbook:i,worksheet:e}:null)):O.of(null)))}function be(n,i,e){return fg(n).pipe(me.switchMap(t=>t?e(t):O.of(i)))}function Hl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),r=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(s=>s?O.combineLatest([r.selectionMoveEnd$,s.activeSheet$]).pipe(me.switchMap(([l,c])=>{if(!c||l.length===0)return O.of(!1);const d=t.getInterestGroupId(l);if(i){const u=d.filter(h=>i.has(h));return O.of(u.length>0)}else return O.of(d.length>0)})):O.of(!1)))}function tn(n,i,e){return O.combineLatest([i,Hl(n,e)]).pipe(me.map(([t,r])=>t||r))}function te(n,i={},e=!1){var g;const r=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(Se)?n.get(Se):null,l=n.get(a.IContextService),c=new O.BehaviorSubject(!1),d=(g=s==null?void 0:s.visible$)!=null?g:O.of(null),u=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(S=>{c.next(S)});return O.combineLatest([o.currentUser$,r,d,c]).pipe(me.finalize(()=>{u.unsubscribe(),c.complete()}),me.switchMap(([S,f,p,v])=>!f||p!=null&&p.visible&&p.unitId===f.getUnitId()&&!e||v&&!e?O.of(!0):f.activeSheet$.pipe(me.switchMap(C=>{if(!C)return O.of(!0);const b=n.get(m.SheetsSelectionsService),R=n.get(m.RangeProtectionRuleModel),w=n.get(m.WorksheetProtectionRuleModel),y=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(me.startWith(!1));return O.combineLatest([b.selectionMoveEnd$,y]).pipe(me.switchMap(([P,x])=>{if(x)return O.of(!0);const A=f.getUnitId(),k=C.getSheetId(),N=n.get(a.IPermissionService),{workbookTypes:H=[m.WorkbookEditablePermission],worksheetTypes:W,rangeTypes:D}=i,U=[];if(H==null||H.forEach(j=>{U.push(new j(A).id)}),W==null||W.forEach(j=>{U.push(new j(A,k).id)}),w.getRule(A,k))return N.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)));const F=P==null?void 0:P.map(j=>j.range),B=R.getSubunitRuleList(A,k).filter(j=>F==null?void 0:F.some(z=>j.ranges.some(K=>a.Rectangle.intersects(z,K))));return D==null||D.forEach(j=>{B.forEach(z=>{U.push(new j(A,k,z.permissionId).id)})}),N.composePermission$(U).pipe(me.map(j=>j.some(z=>z.value===!1)))}))}))))}function Dn(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return O.merge(e.selectionMoveEnd$,r.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),r.composePermission(u).some(g=>g.value===!1)}))}function Vl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return r.getSubunitRuleList(d,u).filter(S=>i==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function Wl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Bi(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return O.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Hn(n,i){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return O.combineLatest([l.currentUser$,t]).pipe(me.switchMap(([c,d])=>d?d.activeSheet$.pipe(me.switchMap(u=>{if(!u)return O.of(!0);const h=d.getUnitId(),g=[];return i.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(me.map(f=>f.every(p=>p.value===!0))).pipe(me.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=r.getRule(h,p),C=o.getSubunitRuleList(h,p);return!!(v||C.length)}))})):O.of(!0)))}var Ul=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(Ul||{});function pg(n){const i=n.get(et);return{id:kn.id,subId:Vi.id,type:_.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new O.Observable(e=>{let t=!1;const r=i.status$.subscribe(o=>{t=o!==Ne.OFF,e.next(t)});return e.next(t),()=>{r.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function vg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),r=n.get(m.SheetsSelectionsService);return{id:Qt.id,type:_.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=r.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=r.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Cg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:Jt.id,type:_.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.it;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _g(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:$t.id,type:_.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.ul;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ig(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:en.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((g===Re.SetTextSelectionsOperation.id||g===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=yr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.st;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=a.DEFAULT_STYLES.ff;return{id:Cr.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:Wi,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:Ui},value:o.value})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var p;const g=h.id;if(g!==m.SetRangeValuesMutation.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=t.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const v=o.getRange(S.startRow,S.startColumn);f=v==null?void 0:v.getFontFamily()}s.next(f!=null?f:r)}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontFamily()}return s.next(d!=null?d:r),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:vr.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Li,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new O.Observable(c=>{var g;const d=i.onCommandExecuted(S=>{var p,v;const f=S.id;if(f===m.SetRangeValuesMutation.id||f===m.SetSelectionsOperation.id||f===m.SetWorksheetActiveOperation.id){const C=(p=t.getCurrentLastSelection())==null?void 0:p.primary;let b;if(C!=null){const R=l.getRange(C.startRow,C.startColumn);b=R==null?void 0:R.getFontSize()}c.next(b!=null?b:o)}if((f===Re.SetTextSelectionsOperation.id||f===$.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const C=yr(n);if(C==null)return;const b=(v=C.ts)==null?void 0:v.fs;c.next(b!=null?b:o)}}),u=(g=t.getCurrentLastSelection())==null?void 0:g.primary;let h;if(u!=null){const S=l.getRange(u.startRow,u.startColumn);h=S==null?void 0:S.getFontSize()}return c.next(h!=null?h:o),d.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Eg(n){return{id:xs.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().textColor,o=i.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Tg(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:wr,hoverable:!1,selectable:!1}}],value$:new O.Observable(t=>{const r=e.getCurrentTheme().primaryColor,o=i.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const pa=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function Mg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:pa[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:pa,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const va=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function Pg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:va[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:va,value$:be(i,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ca=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function Og(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Ca[0].icon,type:_.MenuItemType.SELECTOR,selections:Ca,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=i.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const _a=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function xg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:_a[0].icon,type:_.MenuItemType.SELECTOR,selections:_a,value$:be(e,t,({worksheet:r})=>new O.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=i.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const C=r.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((v=f&&f.a)!=null?v:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=r.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Tr(n){return new O.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function pn(n){return{id:Xe.name,commandId:Xe.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:te(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qi(n){return{id:Ye.name,commandId:Ye.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Jn="sheet.menu.paste-special";function Qi(n){return{id:Jn,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:tn(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function Ji(n){return{id:gn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function $i(n){return{id:Sn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function eo(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e))}}function to(n){return{id:fn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:Tr(n).pipe(O.combineLatestWith(te(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),O.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ag(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function kg(n){return{id:Er.id,type:_.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Ll="sheet.menu.sheet-frozen";function Ng(n){return{id:Ll,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Yo="sheet.header-menu.sheet-frozen";function Ia(n){return{id:Yo,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function no(n){return{id:ht.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Dg(n){return{id:br.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hg(n){return{id:Rr.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ro(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vg(n){return{id:fr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wg(n){return{id:pr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ug(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Lg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:be(i,!0,({worksheet:o})=>new O.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:tt,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):r;s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Fg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:tt,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new O.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=r;d!=null&&(u=o.getColumnWidth(d.startColumn)),s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:te(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yr(n){var c;const i=n.get(a.IUniverInstanceService),e=n.get(Re.DocSelectionManagerService),t=i.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=e.getActiveTextRange();if(t==null||r==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var jg=Object.getOwnPropertyDescriptor,zg=(n,i,e,t)=>{for(var r=t>1?void 0:t?jg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xt=(n,i)=>(e,t)=>i(e,t,n);const Xg="__SpreadsheetFreezeRowMainName__",Yg="__SpreadsheetFreezeRowHeaderName__",Gg="__SpreadsheetFreezeColumnMainName__",Zg="__SpreadsheetFreezeColumnHeaderName__",io=2,Kg=.01,Fn=a.createInterceptorKey("freezePermissionCheck");exports.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d){super();E(this,"_rowFreezeHeaderRect");E(this,"_rowFreezeMainRect");E(this,"_columnFreezeHeaderRect");E(this,"_columnFreezeMainRect");E(this,"_freezeDownSubs");E(this,"_freezePointerEnterSubs");E(this,"_freezePointerLeaveSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_changeToRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToOffsetX",0);E(this,"_changeToOffsetY",0);E(this,"_activeViewport",null);E(this,"_freezeNormalHeaderColor","");E(this,"_freezeNormalMainColor","");E(this,"_freezeActiveColor","");E(this,"_freezeHoverColor","");E(this,"_lastFreeze");E(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:Fn}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var x;const r=t!=null?t:this._getFreeze();if(r==null)return null;const o=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton,{startRow:s,startColumn:l}=r,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:b,columnHeaderHeightAndMarginTop:R}=o,w=h>C+b?h:C+R,M=g>v+R?g:v+R;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const y=Math.max(S.scaleX,S.scaleY);let P=io/(y<1?1:y);if(e===0){(s===-1||s===0)&&(P=P*2);const A=P;this._rowFreezeHeaderRect=new T.Rect(Yg,{fill:this._freezeNormalHeaderColor,width:b,height:P,left:0,top:p-A,zIndex:3});let k=this._freezeNormalHeaderColor;(s===-1||s===0)&&(k=this._freezeNormalMainColor),this._rowFreezeMainRect=new T.Rect(Xg,{fill:k,width:w*2/y,height:P,left:b,top:p-A,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],bt)}else{(l===-1||l===0)&&(P=P*2);const A=P;this._columnFreezeHeaderRect=new T.Rect(Zg,{fill:this._freezeNormalHeaderColor,width:P,height:R,left:f-A,top:0,zIndex:3});let k=this._freezeNormalHeaderColor;(l===-1||l===0)&&(k=this._freezeNormalMainColor),this._columnFreezeMainRect=new T.Rect(Gg,{fill:k,width:P,height:M*2/y,left:f-A,top:R,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],bt)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,r=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,r=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new O.Subscription,this._freezePointerLeaveSubs=new O.Subscription,this._freezeDownSubs=new O.Subscription,r){const d=r.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=r.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});l&&this._freezeDownSubs.add(l);const c=r==null?void 0:r.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,b,R,w,M,y,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const r=e.scene,o=Math.max(r.scaleX,r.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(b=s==null?void 0:s.sheetViewStartRow)!=null?b:0,u=d===0?-((R=s==null?void 0:s.offsetY)!=null?R:0):t.rowHeightAccumulation[d-1]-((w=s==null?void 0:s.offsetY)!=null?w:0);let h=0,g=!1;for(let x=d,A=t.rowHeightAccumulation.length;x<A;x++)if(t.rowHeightAccumulation[x]-u>l){h=x,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(M=s==null?void 0:s.sheetViewStartColumn)!=null?M:0,f=S===0?-((y=s==null?void 0:s.offsetX)!=null?y:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let p=0,v=!1;for(let x=S,A=t.columnWidthAccumulation.length;x<A;x++)if(t.columnWidthAccumulation[x]-f>c){p=x,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var r;const t=(r=this._getSheetObject())==null?void 0:r.scene.getViewports();return t&&t.find(o=>o.isHit(new T.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,r,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;const{scene:d}=l;d.setCursor(T.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var P,x,A,k;const v=this._getActiveViewport(p),{startX:C,startY:b,row:R,column:w}=qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;d.setCursor(T.CURSOR_TYPE.GRABBING);const y=io/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(b,h)-y/2}))==null||P.setProps({fill:this._freezeActiveColor}),(x=r.transformByState({top:Math.min(b,h)-y/2}))==null||x.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?R:Math.min(R,u.lastRow),this._changeToOffsetY=Math.min(b,h),this._activeViewport=v):((A=t.transformByState({left:Math.min(C,g)-y/2}))==null||A.setProps({fill:this._freezeActiveColor}),(k=r.transformByState({left:Math.min(C,g)-y/2}))==null||k.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?w:Math.min(w,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var N,H;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),r.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),r==null||r.setProps({fill:this._freezeNormalHeaderColor}));const C=io/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),r.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),r.transformByState({left:p-C}));const b=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:R,sheetViewStartColumn:w}=b;if(w==null||R==null)return;const M=this._context.unit,y=M.getActiveSheet();if(!y)return;const P=(N=y.getConfig())==null?void 0:N.freeze;let x=(P==null?void 0:P.xSplit)||0,A=(P==null?void 0:P.ySplit)||0;const k=(H=this._activeViewport)==null?void 0:H.viewportKey;o===0&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?A=this._changeToRow-(P.startRow-P.ySplit):A=this._changeToRow-R,A=A<0?0:A),o===1&&(!k||k===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||k===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||k===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?x=this._changeToColumn-(P.startColumn-P.xSplit):x=this._changeToColumn-w,x=x<0?0:x),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:A===0?-1:this._changeToRow,startColumn:x===0?-1:this._changeToColumn,ySplit:A,xSplit:x,unitId:M.getUnitId(),subUnitId:y.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,r=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(r==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:r,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),r.isActive&&r.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,r=0,o=0,s=3){var x;const l=(x=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:x.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:b,viewLeftTop:R}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d,right:0}),b.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c}),R.resizeWhenFreezeChange({left:0,top:0,width:c,height:d});let w=!0,M=!0;g.enable(),(e===-1||e===0)&&(w=!1),(t===-1||t===0)&&(M=!1);const y=l.getNoMergeCellWithCoordByIndex(e-r,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),p.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),p.resetPadding(),w===!1&&M===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c,height:0}),p.resizeWhenFreezeChange({left:0,top:0,height:d,width:0});else if(w===!0&&M===!1){const A=P.startY-y.startY;h.resizeWhenFreezeChange({left:c,top:d+A,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(ze.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:A,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c,height:A}),C.updateScrollVal({viewportScrollY:y.startY}),b.resizeWhenFreezeChange({left:0,top:d+A,bottom:0,width:c}),f.enable(),C.enable()}else if(w===!1&&M===!0){const A=P.startX-y.startX;h.resizeWhenFreezeChange({left:c+A,top:d,bottom:0,right:0}),h.setPadding({startX:y.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(ze.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:A,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d,right:0}),S.enable(),p.enable()}else{const A=P.startX-y.startX,k=P.startY-y.startY;h.resizeWhenFreezeChange({left:c+A,top:d+k,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:y.startX,endX:P.startX}),s&&this._commandService.executeCommand(ze.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+k,width:A,bottom:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+A,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:A,height:k}),g.updateScrollVal({viewportScrollX:y.startX,viewportScrollY:y.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c,height:k}),C.updateScrollVal({viewportScrollY:y.startY}),b.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c}),p.resizeWhenFreezeChange({left:c,top:0,width:A,height:d}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+A,top:0,height:d,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),p.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=r;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new a.ColorKit(e.grey400).setAlpha(Kg).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},r=this._getFreeze();if(!r)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<r.startRow||l.startRow+1===r.startRow&&c===a.Direction.UP){const u={...r,startRow:Math.max(1,r.startRow+d),ySplit:Math.max(1,r.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<r.startColumn||l.startColumn+1===r.startColumn&&c===a.Direction.LEFT){const u={...r,startColumn:Math.max(1,r.startColumn+d),xSplit:Math.max(1,r.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!r||r.startColumn<=0||u.startColumn>=r.startColumn&&h.startColumn>=r.startColumn||u.startColumn===h.startColumn||u.endColumn<r.startColumn&&h.startColumn<r.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(r.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=r.startColumn?(f=Math.max(r.startColumn-S,1),p=Math.max(r.xSplit-S,1)):(f=r.startColumn+g-S,p=r.xSplit+g-S);const v={...r,startColumn:f,xSplit:p};return o(v)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!r||r.startRow<=0||u.startRow>=r.startRow&&h.startRow>=r.startRow||u.startRow===h.startRow||u.endRow<r.startRow&&h.startRow<r.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(r.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=r.startRow?(f=Math.max(r.startRow-S,1),p=Math.max(r.ySplit-S,1)):(f=r.startRow+g-S,p=r.ySplit+g-S);const v={...r,startRow:f,ySplit:p};return o(v)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<r.startColumn){const c=Math.min(r.startColumn,l.endColumn+1)-l.startColumn,d={...r,startColumn:Math.max(1,r.startColumn-c),xSplit:Math.max(1,r.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<r.startRow){const c=Math.min(r.startRow,l.endRow+1)-l.startRow,d={...r,startRow:Math.max(1,r.startRow-c),ySplit:Math.max(1,r.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,r=this._context.unit,o=r.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===r.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),r=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&r&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(r=>r.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,r=this._getFreeze();if(r&&r.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}break;case Oi.id:case xi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(r=>{[T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(r.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,r;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,r,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return Ge(this._context.unit,this._context)}_refreshFreeze(e,t,r,o,s){var c;const l={startRow:e,startColumn:t,ySplit:r,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,r,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}};exports.HeaderFreezeRenderController=zg([xt(1,a.Inject(exports.SheetSkeletonManagerService)),xt(2,a.ICommandService),xt(3,a.Inject(m.SheetsSelectionsService)),xt(4,a.Inject(exports.SheetScrollManagerService)),xt(5,a.Inject(a.ThemeService)),xt(6,a.Inject(m.SheetInterceptorService)),xt(7,a.Inject(a.Injector))],exports.HeaderFreezeRenderController);function qg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),r=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return O.combineLatest([i.selectionMoveEnd$,o.pipe(O.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(O.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:O.of(null)}))]).pipe(O.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(r.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(p=>a.Rectangle.intersects(p,S)&&!a.Rectangle.contains(p,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function Bl(n,i){return!!ir(n,i,a.RANGE_TYPE.ROW)}function Fl(n,i){return!!ir(n,i,a.RANGE_TYPE.COLUMN)}function ir(n,i,e){return n.find(r=>{const o=r.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=i&&i<=d||e===a.RANGE_TYPE.ROW&&s<=i&&i<=l)})}var Qg=Object.getOwnPropertyDescriptor,Jg=(n,i,e,t)=>{for(var r=t>1?void 0:t?Qg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},oo=(n,i)=>(e,t)=>i(e,t,n);const $g="__SpreadsheetHeaderMoveControllerBackground__",eS="__SpreadsheetHeaderMoveControllerShapeLine__",tS="rgba(0, 0, 0, 0.1)",nS="rgb(119, 119, 119)",rS=4,so=a.createInterceptorKey("headerMovePermissionCheck");exports.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_startOffsetX",Number.NEGATIVE_INFINITY);E(this,"_startOffsetY",Number.NEGATIVE_INFINITY);E(this,"_moveHelperBackgroundShape");E(this,"_moveHelperLineShape");E(this,"_headerPointerDownSubs");E(this,"_headerPointerMoveSubs");E(this,"_headerPointerLeaveSubs");E(this,"_dragHeaderMoveSub");E(this,"_scenePointerUpSub");E(this,"_scrollTimer");E(this,"_changeFromColumn",-1);E(this,"_changeFromRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToRow",-1);E(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:so}));E(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=r,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,r,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(r=this._headerPointerMoveSubs)==null||r.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?r:t,l=u=>{var b,R;const h=(b=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:b.skeleton;if(h==null)return;const g=(R=this._workbookSelections.getCurrentLastSelection())==null?void 0:R.range;if(!g||!this.interceptor.fetchThroughInterceptors(so)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=qe(u.offsetX,u.offsetY,o,h);if(!ir(f,e===a.RANGE_TYPE.ROW?p:v,e)){o.resetCursor();return}o.setCursor(T.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var W,D;if(h.isStopPropagation)return;const g=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(g==null)return;const S=(D=this._workbookSelections.getCurrentLastSelection())==null?void 0:D.range;if(!S||!this.interceptor.fetchThroughInterceptors(so)(!1,S))return;const{offsetX:p,offsetY:v}=u,C=o.getCoordRelativeToViewport(T.Vector2.FromArray([p,v])),{x:b,y:R}=C;this._startOffsetX=b,this._startOffsetY=R;const{row:w,column:M}=qe(u.offsetX,u.offsetY,o,g);let y;e===a.RANGE_TYPE.ROW?(this._changeFromRow=w,y=T.ScrollTimerType.Y):(this._changeFromColumn=M,y=T.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),x=ir(P,e===a.RANGE_TYPE.ROW?w:M,e);if(!x)return;const A=o.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(T.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let k=!1,N;const H=()=>{if(k)return;N=T.ScrollTimer.create(o,y),this._scrollTimer=N;const U=o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);N.startScroll(b,R,U),k=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{H();const{offsetX:L,offsetY:F}=U,{x:B,y:j}=o.getCoordRelativeToViewport(T.Vector2.FromArray([L,F]));this._rowColumnMoving(B,j,x,A,e),N.scrolling(B,j,()=>{this._rowColumnMoving(B,j,x,A,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var L,F,B;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(L=this._scrollTimer)==null||L.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const z=(F=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.ROW&&K.range.startRow<=this._changeFromRow&&this._changeFromRow<=K.range.endRow))||[])[0])==null?void 0:F.range;z&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:z,toRange:{...z,startRow:this._changeToRow,endRow:this._changeToRow+z.endRow-z.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const z=(B=((U==null?void 0:U.filter(K=>K.range.rangeType===a.RANGE_TYPE.COLUMN&&K.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=K.range.endColumn))||[])[0])==null?void 0:B.range;z&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:z,toRange:{...z,startColumn:this._changeToColumn,endColumn:this._changeToColumn+z.endColumn-z.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new O.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new O.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new O.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,r,o,s){var j,z,K,ne,Q,se,ce;const l=this._context.scene,c=(j=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:j.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,S),{row:C,column:b}=v,R=c.getNoMergeCellWithCoordByIndex(C,b),{startX:w,startY:M,endX:y,endY:P}=R,x=this._sheetSkeletonManagerService.attachRangeWithCoord(r.range);if(x==null)return;const A=Math.max(f,f),{startX:k,endX:N,startY:H,endY:W,startRow:D,startColumn:U,endRow:L,endColumn:F}=x;s===a.RANGE_TYPE.ROW?(z=this._moveHelperBackgroundShape)==null||z.transformByState({height:W-H,width:g+d,left:0,top:H+(t-this._startOffsetY)/A+S.y-o.y}):(K=this._moveHelperBackgroundShape)==null||K.transformByState({height:h+u,width:N-k,left:k+(e-this._startOffsetX)/A+S.x-o.x,top:0}),(ne=this._moveHelperBackgroundShape)==null||ne.show();const B=rS/A;if(s===a.RANGE_TYPE.ROW){let X=0;if(C<=D)X=M-B/2,this._changeToRow=C;else if(C>L)X=P-B/2,this._changeToRow=C+1;else return;(Q=this._moveHelperLineShape)==null||Q.transformByState({height:B,width:g,left:d,top:X})}else{let X=0;if(b<=U)X=w-B/2,this._changeToColumn=b;else if(b>F)X=y-B/2,this._changeToColumn=b+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:B,left:X,top:u})}(ce=this._moveHelperLineShape)==null||ce.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new T.Rect($g,{fill:tS,evented:!1,zIndex:100}),this._moveHelperLineShape=new T.Rect(eS,{fill:nS,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],bt)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}};exports.HeaderMoveRenderController=Jg([oo(1,a.Inject(m.SheetsSelectionsService)),oo(2,a.Inject(exports.SheetSkeletonManagerService)),oo(3,a.ICommandService)],exports.HeaderMoveRenderController);var Go=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Go||{});const iS="rgba(120, 120, 120, 0.01)",ao="rgb(68, 71, 70)",Zn=12,oS=44,Zo=4;class ba extends T.Shape{constructor(e,t){super(e,t);E(this,"_size",Zn);E(this,"_color",ao);E(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:r,scaleY:o}=t.getAncestorScale(),s=Math.max(r,o),l=Zn/s,c=Zo/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),T.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:iS}),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.save(),e.transform(1,0,0,1,h,g),T.Rect.drawWith(e,{width:d,height:u,fill:ao,radius:c}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:Zn,height:this.size}):this.transformByState({width:this.size,height:Zn}),this}}var sS=Object.getOwnPropertyDescriptor,aS=(n,i,e,t)=>{for(var r=t>1?void 0:t?sS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},lo=(n,i)=>(e,t)=>i(e,t,n);const lS="__SpreadsheetHeaderResizeControllerShapeRow__",cS="__SpreadsheetHeaderResizeControllerShapeColumn__",Ra="__SpreadsheetHeaderResizeControllerShapeHelper__",Ea="rgb(199, 199, 199)",dS=2,co=a.createInterceptorKey("headerResizePermissionCheck");exports.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_currentRow",0);E(this,"_currentColumn",0);E(this,"_rowResizeRect");E(this,"_columnResizeRect");E(this,"_headerPointerSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_resizeHelperShape");E(this,"_startOffsetX",Number.POSITIVE_INFINITY);E(this,"_startOffsetY",Number.POSITIVE_INFINITY);E(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:co}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=r,this._commandService=o,this._init()}dispose(){var e,t,r;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(r=this._headerPointerSubs)==null||r.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new ba(lS,{visible:!1,mode:Go.HORIZONTAL,zIndex:100}),this._columnResizeRect=new ba(cS,{visible:!1,mode:Go.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],bt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?r:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var A;const h=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:p,endX:v,endY:C,row:b,column:R}=qe(d.offsetX,d.offsetY,o,h),w=Qn(d.offsetX,d.offsetY,o),{scaleX:M,scaleY:y}=o.getAncestorScale(),P=Math.max(M,y),x=Zn/P;if(e===0){let k=p-x/2;if(w.y<=p+x/2&&w.y>=p)this._currentRow=b-1;else if(w.y>=C-x/2&&w.y<=C)this._currentRow=b,k=C-x/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{row:this._currentRow}))return!1;const H=Math.min(oS,g/3);this._rowResizeRect.transformByState({left:g/2-H/2,top:k}),this._rowResizeRect.setShapeProps({size:H}),this._rowResizeRect.show()}else{let k=f-x/2;if(w.x<=f+x/2&&w.x>=f)this._currentColumn=R-1;else if(w.x>=v-x/2&&w.x<=v)this._currentColumn=R,k=v-x/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(co)(null,{col:this._currentColumn}))return!1;const H=S*.7;this._columnResizeRect.transformByState({left:k,top:S/2-H/2}),this._columnResizeRect.setShapeProps({size:H}),this._columnResizeRect.show()}};this._headerPointerSubs=new O.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,r=e===0?this._rowResizeRect:this._columnResizeRect;r!=null&&(this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r!=null&&(r.show(),t.setCursor(e===0?T.CURSOR_TYPE.ROW_RESIZE:T.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r!=null&&(r.hide(),t.resetCursor())})),this.disposeWithMe(r.onPointerDown$.subscribeEvent(o=>{var F,B,j,z,K,ne,Q;const s=(F=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:F.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((j=(B=h==null?void 0:h.getScrollBar())==null?void 0:B.horizonScrollTrack)==null?void 0:j.height)||0)+10,S=(((K=(z=h==null?void 0:h.getScrollBar())==null?void 0:z.verticalScrollTrack)==null?void 0:K.width)||0)+10,f=Qn(o.offsetX,o.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),b=s.getOffsetByRow(this._currentRow),R=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let w=!1,M=0,y=0;const{columnTotalWidth:P,rowHeaderWidth:x,rowTotalHeight:A,columnHeaderHeight:k}=s,N=u>P+x?u:P+x,H=d>A+k?d:A+k,W=Math.max(p,v),D=Zo/W;e===0?this._resizeHelperShape=new T.Rect(Ra,{width:N,height:D,fill:Ea,left:0,top:b-D/2}):this._resizeHelperShape=new T.Rect(Ra,{width:D,height:H,fill:Ea,left:C-D/2,top:0});const U=((ne=this._columnResizeRect)==null?void 0:ne.left)||0,L=((Q=this._rowResizeRect)==null?void 0:Q.top)||0;l.addObject(this._resizeHelperShape,bt),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var fe,Te,we,Fe,St,Mt;const ce=l.getCoordRelativeToViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),X=l.getScrollXYInfoByViewport(ce,h),G=Qn(se.offsetX,se.offsetY,l),{x:q,y:ie}=G,{scaleX:oe,scaleY:J}=l.getAncestorScale(),ee=Math.max(oe,J),de=Zo/ee;M=q-this._startOffsetX-de/2,y=ie-this._startOffsetY-de/2,Math.abs(e===0?y:M)>=dS&&(w=!0),e===0?(y>d-g+X.y-R.startY&&(y=d-g+X.y-R.startY),y<-(R.endY-R.startY)+2&&(y=-(R.endY-R.startY)+2),w&&((fe=this._resizeHelperShape)==null||fe.transformByState({top:b+y}),(Te=this._rowResizeRect)==null||Te.transformByState({top:L+y+de/2}),(we=this._rowResizeRect)==null||we.show(),l.setCursor(T.CURSOR_TYPE.ROW_RESIZE))):(M>u-S+X.x-R.startX&&(M=u-S+X.x-R.startX),M<-(R.endX-R.startX)+2&&(M=-(R.endX-R.startX)+2),w&&((Fe=this._resizeHelperShape)==null||Fe.transformByState({left:C+M}),(St=this._columnResizeRect)==null||St.transformByState({left:U+M+de/2}),(Mt=this._columnResizeRect)==null||Mt.show(),l.setCursor(T.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var X,G,q;const ce=this._context.scene;this._clearObserverEvent(),(X=this._resizeHelperShape)==null||X.dispose(),this._resizeHelperShape=null,ce.enableObjectsEvent(),w&&(ce.resetCursor(),(G=this._rowResizeRect)==null||G.hide(),(q=this._columnResizeRect)==null||q.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:y,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:M,anchorCol:this._currentColumn}))})})),this.disposeWithMe(r.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),p=[];for(let v=0;v<f.length;v++){const C=f[v];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&p.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}p.length===0&&p.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(Er.id,{ranges:p}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}};exports.HeaderResizeRenderController=aS([lo(1,a.Inject(exports.SheetSkeletonManagerService)),lo(2,a.Inject(m.SheetsSelectionsService)),lo(3,a.ICommandService)],exports.HeaderResizeRenderController);var uS=Object.getOwnPropertyDescriptor,hS=(n,i,e,t)=>{for(var r=t>1?void 0:t?uS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Lr=(n,i)=>(e,t)=>i(e,t,n);const mS=60;exports.SheetRenderController=class extends a.RxDisposable{constructor(e,t,r,o,s){super();E(this,"_renderMetric$",new O.Subject);E(this,"renderMetric$",this._renderMetric$.asObservable());E(this,"_renderFrameTimeMetric",null);E(this,"_renderFrameTags",{});E(this,"_afterRenderMetric$",new O.Subject);this._context=e,this._sheetSkeletonManagerService=t,this._sheetRenderService=r,this._commandService=o,this._telemetryService=s,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:r}=this._context;this._addComponent(r),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(T.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([r,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[r]||(this._renderFrameTimeMetric[r]=[]),this._renderFrameTimeMetric[r].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([r,o])=>{this._renderFrameTags[r]=o});const t=[];this._afterRenderMetric$.pipe(O.withLatestFrom(e.endFrame$)).subscribe(([r,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...r.frameTimeMetric,...r.tags}),t.length>mS&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var g;const t=e;if(t.length===0)return;const r=S=>{let f=0;const v=Object.entries(S).filter(([b,R])=>Array.isArray(R)).map(([b])=>b).reduce((b,R)=>{const w=S[R].reduce((M,y)=>M+y,0);return b[R]=w,b},{});return Object.keys(S).filter(b=>b.startsWith(T.SHEET_EXTENSION_PREFIX)).forEach(b=>{f+=v[b]}),{...v,extensionTotal:f}},o=e.map(S=>({...S,...r(S)})),l=(S=>Object.entries(S[0]).filter(([v,C])=>!["elapsedTime"].includes(v)).filter(([v,C])=>typeof C=="number").map(([v])=>v).reduce((v,C)=>{const b=S.map(y=>y[C]),R=Math.max(...b),w=Math.min(...b),M=b.reduce((y,P)=>y+P,0)/b.length;return v[C]={max:Math.round(R*100)/100,min:Math.round(w*100)/100,avg:Math.round(M*100)/100},v},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._renderMetric$.next(h),(g=this._telemetryService)==null||g.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:r}=this._context,o=e.getActiveSheet(),s=new T.Spreadsheet(he.MAIN);this._addViewport(o);const l=new T.SpreadsheetRowHeader(he.ROW),c=new T.SpreadsheetColumnHeader(he.COLUMN),d=new T.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,r.set(he.MAIN,s),r.set(he.ROW,l),r.set(he.COLUMN,c),r.set(he.LEFT_TOP,d),t.addObjects([s],Bs),t.addObjects([l,c,d],bt),t.enableLayerCache(Bs,bt)}_initViewports(e,t,r){const l=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:r.height,bottom:0,width:t.width,isWheelPreventDefaultX:!0}),S=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),p=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:r.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:r,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,r,o);return new T.ScrollBar(s),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:r}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(r);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:r}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(r)||this._sheetRenderService.checkMutationShouldTriggerRerender(r)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:r},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:r})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(r)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:r}=this._context;if(e.id===Z.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),r.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(r);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,r=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),r<Number(S)&&(r=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:r}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:r,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:r[u-1]+l,p=r[h]+l,v=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const r=e.filter(o=>o.isActive&&o.cacheBound);for(const o of r)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}};exports.SheetRenderController=hS([Lr(1,a.Inject(exports.SheetSkeletonManagerService)),Lr(2,a.Inject(exports.SheetsRenderService)),Lr(3,a.ICommandService),Lr(4,a.Optional(md.ITelemetryService))],exports.SheetRenderController);function gS(n,i){if(n.length!==i.length)return!1;const e=n.sort((r,o)=>r.id.localeCompare(o.id)),t=i.sort((r,o)=>r.id.localeCompare(o.id));return e.every((r,o)=>{var s,l;return((s=r.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&r.role===t[o].role})}function jl(n,i){return i.some(e=>SS(n,e))}function SS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function zl(n,i,e,t){const r=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=fS(e,l),d={unitId:i,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);r.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function fS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r,a.CellModeEnum.Intercepted),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function pS(n,i,e,t){const r=e.getActiveViewportByCoord(T.Vector2.FromArray([n,i]));if(!r)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:r.viewportScrollX,y:r.viewportScrollY},c=t.getCellIndexByOffset(n,i,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function wa(n,i,e,t){const r=t.getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0||n>=r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function vS(n,i,e,t){const r=Ta(n.left,n.top,i,e,t),o=Ta(n.right,n.bottom,i,e,t);return{left:r.x,top:r.y,right:o.x,bottom:o.y}}function Ta(n,i,e,t,r){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:i};const c=r.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-S.startX,b=f.startY-S.startY,{top:R,left:w,viewportScrollX:M,viewportScrollY:y}=l;let P;n>w?P=(n-M)*o:P=(C+p-(w-n))*o;let x;return i>R?x=(i-y)*s:x=(b+v-(R-i))*o,{x:P,y:x}}function Xl(n,i,e,t,r){let o=t,s=r;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:i.getSheetId(),workbook:n,worksheet:i,row:l.actualRow,col:l.actualColumn}}function Yl(n,i,e,t,r,o){const{scene:s}=n,l=i.getUnitId(),{skeleton:c,sheetId:d}=t,u=pS(r,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:i,worksheet:e,row:g,col:h};c.overflowCache.forValue((y,P,x)=>{x.startRow<=g&&x.endRow>=g&&x.startColumn<=h&&x.endColumn>=h&&(h=P,g=y)});const f=c.getCellWithCoordByIndex(g,h),p=Xl(i,e,c,g,h);let v;f.mergeInfo?v=f.mergeInfo:v={startRow:p.row,endRow:p.row,startColumn:p.col,endColumn:p.col};const C=s.getActiveViewportByCoord(T.Vector2.FromArray([r,o]));if(!C)return;const{scaleX:b,scaleY:R}=s.getAncestorScale(),w={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-w.x)*b,endX:(c.getOffsetByColumn(v.endColumn)-w.x)*b,startY:(c.getOffsetByRow(v.startRow-1)-w.y)*R,endY:(c.getOffsetByRow(v.endRow)-w.y)*R},location:S,overflowLocation:p}}const Tt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=i.unitId,c=i.subUnitId,d=i.selections,u=m.getAddMergeMutationRangeByType(d,i.value),h=r.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=jl(h,u);if(f&&!i.defaultMerge&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,p),b=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:v}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:b}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const x=zl(n,l,h,u);g.unshift(...x.redos),S.push(...x.undos)}const R=m.AddMergeRedoSelectionsOperationFactory(n,i,u);R&&g.push(R);const w=m.AddMergeUndoSelectionsOperationFactory(n,i);w&&S.push(w);const y=n.get(m.SheetInterceptorService).onCommandExecute({id:Tt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...y.redos),S.push(...y.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},As={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeAll,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{selections:r,unitId:c,subUnitId:d})}},ks={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeVertical,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.COLUMNS,selections:r,unitId:c,subUnitId:d})}},Ns={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=fs(ki.MergeHorizontal,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(Tt.id,{value:a.Dimension.ROWS,selections:r,unitId:c,subUnitId:d})}},Vn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Vn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Xt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Xt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Yt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Yt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Yt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},Wn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Wn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var Gl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Gl||{}),re=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(re||{}),ke=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ke||{}),dt=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(dt||{}),Ke=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ke||{});const or="UNIVER_SHEET_PERMISSION_PANEL",ai="UNIVER_SHEET_PERMISSION_USER_PART",Ds="UNIVER_SHEET_PERMISSION_BACKGROUND",Zl="UNIVER_SHEET_PERMISSION_USER_DIALOG",Kl="UNIVER_SHEET_PERMISSION_DIALOG",li="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",ci="UNIVER_SHEET_PERMISSION_DIALOG_ID",Br={[re.Copy]:"Copy",[re.SetCellStyle]:"SetCellStyle",[re.SetCellValue]:"SetCellValue",[re.SetRowStyle]:"SetRowStyle",[re.SetColumnStyle]:"SetColumnStyle",[re.InsertRow]:"InsertRow",[re.InsertColumn]:"InsertColumn",[re.InsertHyperlink]:"InsertHyperlink",[re.DeleteRow]:"DeleteRow",[re.DeleteColumn]:"DeleteColumn",[re.Sort]:"Sort",[re.Filter]:"Filter",[re.PivotTable]:"PivotTable",[re.EditExtraObject]:"EditExtraObject"},CS=[re.Copy,re.SetCellStyle,re.SetCellValue,re.SetRowStyle,re.SetColumnStyle,re.InsertRow,re.InsertColumn,re.InsertHyperlink,re.DeleteRow,re.DeleteColumn,re.Sort,re.Filter,re.PivotTable,re.EditExtraObject,re.View],ql="sheet-permission-menu-icon",_S="sheet-permission-delete-icon",IS="sheet-permission-edit-icon",bS="sheet-permission-check-icon",Ql="sheet-permission-lock-icon",RS={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class yn{constructor(){E(this,"_rule",RS);E(this,"_visible",!1)}setVisible(i){this._visible=i}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class yt{constructor(){E(this,"_userList",[]);E(this,"_userList$",new O.BehaviorSubject(this._userList));E(this,"userList$",this._userList$.asObservable());E(this,"_oldCollaboratorList",[]);E(this,"_selectUserList",[]);E(this,"_selectUserList$",new O.BehaviorSubject(this._selectUserList));E(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(i){this._userList=i,this._userList$.next(i)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(i){this._oldCollaboratorList=i}get selectUserList(){return this._selectUserList}setSelectUserList(i){this._selectUserList=i,this._selectUserList$.next(i)}}const Qe={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,i={}){const e=n.get(_.ISidebarService),t=n.get(yn),r=n.get(yt),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=i,d={header:{title:"permission.panel.title"},children:{label:or,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),r.reset()}};return t.setVisible(!0),e.open(d),!0}},Mr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!0}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Pr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{fromSheetBar:!0,showDetail:!0}),!0}},Or={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Qe.id,{showDetail:!1}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return i.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=r.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,g)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await i.executeCommand(m.DeleteRangeProtectionMutation.id,v)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:v}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[p]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=r.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(p=>{var v;return(v=p==null?void 0:p.ranges)==null?void 0:v.some(C=>a.Rectangle.intersects(C,h))});if(f){const p={...f,unitId:l,subUnitId:c};return await i.executeCommand(Qe.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},Mn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(Ka(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Pn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await r.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},xr={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{const{subUnitId:e}=i,t=n.get(_.IConfirmService),r=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Ar={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Kt).triggerSheetBarMenu(),!0)},kr={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,i){if(!i)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(Gl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=r.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},Nr={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},Fi={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,i)=>(n.get(Se).setEditCell(i),!0)},Dr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,i)=>{const e=n.get(Kt);return i&&e.setRenameId(i.subUnitId),!0}},Hs={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,i){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:ci,title:{title:"permission.dialog.allowedPermissionType"},children:{label:Kl},width:393,destroyOnClose:!0,onClose:()=>e.close(ci)}),!0}},ES=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),I.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),I.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),I.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),I.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),I.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),I.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),I.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),I.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),I.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),I.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),I.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),I.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),I.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),I.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),I.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),I.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),I.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),I.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),I.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),I.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),I.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),I.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),I.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),I.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),I.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),I.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),wS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),I.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),I.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),I.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),I.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),I.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),I.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),I.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),I.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),I.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),I.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),I.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),I.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),I.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),I.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),I.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),I.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),I.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),I.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),I.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),I.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),I.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),I.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),I.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),I.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),I.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),I.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),I.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),TS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),I.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),I.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),I.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),I.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),I.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),I.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),I.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),I.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),I.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),I.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),I.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),I.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),I.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),I.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),I.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),I.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),I.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),I.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),I.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),yS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),I.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),I.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),I.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),I.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),I.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),I.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),I.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),I.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),I.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),I.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),I.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),I.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),I.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),I.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),I.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),I.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),I.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),I.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),I.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),I.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),I.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),I.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),I.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),I.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),I.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),I.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),I.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),I.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),I.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),I.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),I.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),I.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),I.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),I.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),I.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),I.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),I.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),I.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),I.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),I.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),I.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),I.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),I.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),I.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),I.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),I.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),I.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),I.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),MS=()=>I.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),PS=()=>I.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),I.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),I.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),I.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),I.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),I.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),I.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),I.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),I.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),I.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),I.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),I.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),I.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),I.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),I.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),I.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),I.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),I.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),OS=()=>I.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),I.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),I.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),I.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),I.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),I.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),I.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),I.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),I.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),I.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),I.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),I.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),I.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),I.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),I.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),I.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),I.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),I.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),I.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),I.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),xS=()=>I.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),I.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),I.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),I.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),I.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),I.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),I.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),I.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),I.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),I.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),I.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),I.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),I.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),I.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),I.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),I.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),I.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),I.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),I.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),I.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),AS=()=>I.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),ya=()=>I.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Ma(n){const{type:i=a.BorderStyleTypes.THIN}=n;switch(i){case a.BorderStyleTypes.DASH_DOT:return I.jsx(ES,{});case a.BorderStyleTypes.DASH_DOT_DOT:return I.jsx(wS,{});case a.BorderStyleTypes.DASHED:return I.jsx(TS,{});case a.BorderStyleTypes.HAIR:return I.jsx(yS,{});case a.BorderStyleTypes.MEDIUM:return I.jsx(MS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return I.jsx(PS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return I.jsx(OS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return I.jsx(xS,{});case a.BorderStyleTypes.THICK:return I.jsx(AS,{});case a.BorderStyleTypes.THIN:return I.jsx(ya,{});default:return I.jsx(ya,{})}}const Vs=`${Nn}_BORDER_PANEL_COMPONENT`,Jl=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],kS=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function $l(n){var l;const i=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:r}=n;function o(c,d){t==null||t({...r,[d]:c})}function s(c){const d=i.get(c);return d&&I.jsx(d,{extend:{colorChannel1:"#2c53f1"}})}return I.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[I.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2",children:Jl.map(c=>I.jsx("a",{className:Y.clsx(`
|
|
59
59
|
univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center
|
|
60
60
|
univer-justify-self-center univer-rounded
|
|
61
61
|
hover:univer-bg-gray-100
|