@univerjs/ui 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var wa=s,Ma=Symbol.for("react.element"),Oa=Symbol.for("react.fragment"),Ia=Object.prototype.hasOwnProperty,Ha=wa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Da={key:!0,ref:!0,__self:!0,__source:!0};function Sr(e,t,n){var r,i={},a=null,o=null;n!==void 0&&(a=""+n),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)Ia.call(t,r)&&!Da.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:Ma,type:e,key:a,ref:o,props:i,_owner:Ha.current}}A1.Fragment=Oa,A1.jsx=Sr,A1.jsxs=Sr,Cr.exports=A1;var v=Cr.exports;function br(e){return typeof e=="function"?e():e}function Ta(e,t){return e.length!==t.length?!0:e.some((n,r)=>n!==t[r])}function Ae(e,t,n,r){var S;if(typeof e=="function"&&!r)throw new Error("[useObservable]: expect deps when observable is a function! Otherwise it would cause an infinite loop.");const i=s.useRef(null),a=s.useRef(null),o=s.useRef(r!=null?r:void 0),u=s.useRef(!1),[d,h]=s.useState(0),p=s.useRef((()=>{let _;return e&&br(e).subscribe(U=>{u.current=!0,_=U}).unsubscribe(),_!=null?_:t})()),f=(()=>{if(typeof o.current<"u"){const _=r!=null?r:[];return Ta(o.current,_)?(o.current=_,!0):!1}return i.current!==e})();if((!a.current||f)&&e&&(i.current=br(e),(S=a.current)==null||S.unsubscribe(),a.current=i.current.subscribe(_=>{p.current=_,h(L=>L+1)})),s.useEffect(()=>()=>{var _;(_=a.current)==null||_.unsubscribe(),a.current=null},[]),n&&!u.current)throw new Error("[useObservable]: expect shouldHaveSyncValue but not getting a sync value!");return p.current}function je(e){const{title:t,icon:n,label:r,value:i,value$:a}=e,o=le.useDependency(y.LocaleService),u=le.useDependency(Ke),d=[];let h=0,p=i;a&&(p=Ae(a,void 0,!0));let f;ee.isObservable(n)?f=Ae(n,void 0,!0):f=n;let S=!1;if(p&&typeof p=="string"&&(S=new y.ColorKit(p).isValid),n){const _=u.get(f!=null?f:"");_&&d.push(v.jsx(_,{extend:{colorChannel1:S?p:"rgb(var(--primary-color))"}},h++))}if(r){const _=typeof r=="string",L=_?{...e}:{...r==null?void 0:r.props,...e},U=_?r:r==null?void 0:r.name,H=u.get(U);H?d.push(v.jsx(H,{...L,value:p},h++)):d.push(v.jsx("span",{children:o.t(U)},h++))}return t&&d.push(v.jsx("span",{children:typeof t=="string"?o.t(t):t},h++)),v.jsx(v.Fragment,{children:d})}const yr={uiPluginSheetsFontFamily:"univer-ui-plugin-sheets-font-family",uiPluginSheetsFontFamilyItem:"univer-ui-plugin-sheets-font-family-item"},xa=e=>{const{value:t}=e,n=le.useDependency(y.LocaleService),r=s.useMemo(()=>{var a;let i=n.t(`fontFamily.${((a=`${t}`)!=null?a:"").replace(/\s/g,"")}`);return i.startsWith("fontFamily.")&&typeof t=="string"&&(i=t.split(",")[0]),i},[t]);return v.jsx("div",{className:yr.uiPluginSheetsFontFamily,style:{fontFamily:t},children:r})},Va=e=>{var r;const{value:t}=e,n=le.useDependency(y.LocaleService);return v.jsx("span",{className:yr.uiPluginSheetsFontFamilyItem,style:{fontFamily:t},children:n.t(`fontFamily.${((r=`${t}`)!=null?r:"").replace(/\s/g,"")}`)})},Na=[{value:"Arial"},{value:"Times New Roman"},{value:"Tahoma"},{value:"Verdana"},{value:"Microsoft YaHei"},{value:"SimSun"},{value:"SimHei"},{value:"Kaiti"},{value:"FangSong"},{value:"NSimSun"},{value:"STXinwei"},{value:"STXingkai"},{value:"STLiti"}],_r={uiPluginSheetsFontSize:"univer-ui-plugin-sheets-font-size",uiPluginSheetsFontSizeInput:"univer-ui-plugin-sheets-font-size-input"},ka=e=>{const{value:t,min:n,max:r,onChange:i,disabled$:a}=e,o=Ae(a),[u,d]=s.useState(Number(t!=null?t:0)),h=s.useMemo(()=>Number(t!=null?t:u),[t]);function p(S){S!==null&&d(S)}function f(S){S.stopPropagation(),S.code==="Enter"&&i(u.toString())}return v.jsx("div",{className:_r.uiPluginSheetsFontSize,children:v.jsx(ge.InputNumber,{className:_r.uiPluginSheetsFontSizeInput,value:h,controls:!1,min:n,max:r,onKeyDown:f,onChange:p,disabled:o})})},Aa=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}];var Fe=(e=>(e.VOID="void",e.TOOLBAR_START="uiToolbar.start",e.TOOLBAR_INSERT="uiToolbar.insert",e.TOOLBAR_FORMULAS="uiToolbar.formulas",e.TOOLBAR_DATA="uiToolbar.data",e.TOOLBAR_VIEW="uiToolbar.view",e.TOOLBAR_OTHERS="uiToolbar.others",e.CONTEXT_MENU="contextMenu",e))(Fe||{}),i1=(e=>(e[e.TOOLBAR_HISTORY=0]="TOOLBAR_HISTORY",e[e.TOOLBAR_FORMAT=1]="TOOLBAR_FORMAT",e[e.TOOLBAR_LAYOUT=2]="TOOLBAR_LAYOUT",e[e.TOOLBAR_FORMULAS_INSERT=3]="TOOLBAR_FORMULAS_INSERT",e[e.TOOLBAR_FORMULAS_VIEW=4]="TOOLBAR_FORMULAS_VIEW",e[e.TOOLBAR_FILE=5]="TOOLBAR_FILE",e[e.TOOLBAR_OTHERS=6]="TOOLBAR_OTHERS",e[e.CONTEXT_MENU_FORMAT=7]="CONTEXT_MENU_FORMAT",e[e.CONTEXT_MENU_LAYOUT=8]="CONTEXT_MENU_LAYOUT",e[e.CONTEXT_MENU_DATA=9]="CONTEXT_MENU_DATA",e[e.CONTEXT_MENU_OTHERS=10]="CONTEXT_MENU_OTHERS",e))(i1||{}),$e=(e=>(e[e.BUTTON=0]="BUTTON",e[e.SELECTOR=1]="SELECTOR",e[e.BUTTON_SELECTOR=2]="BUTTON_SELECTOR",e[e.SUBITEMS=3]="SUBITEMS",e))($e||{});function Ra(e,t,n){return window.addEventListener(e,t,n),y.toDisposable(()=>window.removeEventListener(e,t,n))}var Ua=Object.defineProperty,Pa=Object.getOwnPropertyDescriptor,ja=(e,t,n,r)=>{for(var i=r>1?void 0:r?Pa(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ua(t,n,i),i},y1=(e,t)=>(n,r)=>t(n,r,e);class $a{constructor(t){z(this,"_focus",!1);z(this,"_valueLegality",!0);z(this,"_openForSheetUnitId");z(this,"_openForSheetSubUnitId");this._param=t,this._openForSheetUnitId=this._param.openForSheetUnitId,this._openForSheetSubUnitId=this._param.openForSheetSubUnitId}get documentDataModel(){return this._param.documentDataModel}get editorUnitId(){return this._param.editorUnitId}get cancelDefaultResizeListener(){return this._param.cancelDefaultResizeListener}get render(){return this._param.render}isSingleChoice(){return this._param.isSingleChoice}setOpenForSheetUnitId(t){this._openForSheetUnitId=t}getOpenForSheetUnitId(){return this._openForSheetUnitId}setOpenForSheetSubUnitId(t){this._openForSheetSubUnitId=t}getOpenForSheetSubUnitId(){return this._openForSheetSubUnitId}isValueLegality(){return this._valueLegality===!0}setValueLegality(t=!0){this._valueLegality=t}isFocus(){return this._focus}setFocus(t=!1){this._focus=t}isSingle(){return this._param.isSingle===!0||this.onlyInputRange()}isReadOnly(){return this._param.isReadonly===!0}onlyInputContent(){return this._param.onlyInputContent===!0}onlyInputFormula(){return this._param.onlyInputFormula===!0}onlyInputRange(){return this._param.onlyInputRange===!0}getBoundingClientRect(){return this._param.editorDom.getBoundingClientRect()}isVisible(){return this._param.visible}isSheetEditor(){return this._param.isSheetEditor===!0}getValue(){var n;return(((n=this._param.documentDataModel.getBody())==null?void 0:n.dataStream)||"").replace(/\r\n/g,"").replace(/\n/g,"").replace(/\n/g,"")}getBody(){return this._param.documentDataModel.getBody()}update(t){this._param={...this._param,...t}}verticalAlign(){var o,u;const t=(o=this._param)==null?void 0:o.documentDataModel;if(t==null)return;const{width:n,height:r}=this._param.editorDom.getBoundingClientRect();if(!this.isSingle()){t.updateDocumentDataPageSize(n,void 0);return}let i=h1.UNIVER_GLOBAL_DEFAULT_FONT_SIZE;(u=this._param.canvasStyle)!=null&&u.fontSize&&(i=this._param.canvasStyle.fontSize);const a=(r-i*4/3)/2-2;t.updateDocumentDataMargin({t:a<0?0:a}),t.updateDocumentDataPageSize(void 0,void 0)}updateCanvasStyle(){var r;const t=this._param.documentDataModel;if(t==null)return;const n={};(r=this._param.canvasStyle)!=null&&r.fontSize&&(n.textStyle==null&&(n.textStyle={}),n.textStyle.fs=this._param.canvasStyle.fontSize),t.updateDocumentStyle(n)}}E.EditorService=class extends y.Disposable{constructor(n,r,i,a,o){super();z(this,"_editors",new Map);z(this,"_focusEditorUnitId");z(this,"_state$",new ee.Subject);z(this,"state$",this._state$.asObservable());z(this,"_currentSheetUnitId");z(this,"_currentSheetSubUnitId");z(this,"_inputFormula$",new ee.Subject);z(this,"inputFormula$",this._inputFormula$.asObservable());z(this,"_resize$",new ee.Subject);z(this,"resize$",this._resize$.asObservable());z(this,"_closeRangePrompt$",new ee.Subject);z(this,"closeRangePrompt$",this._closeRangePrompt$.asObservable());z(this,"_blur$",new ee.Subject);z(this,"blur$",this._blur$.asObservable());z(this,"_focus$",new ee.Subject);z(this,"focus$",this._focus$.asObservable());z(this,"_setValue$",new ee.Subject);z(this,"setValue$",this._setValue$.asObservable());z(this,"_valueChange$",new ee.Subject);z(this,"valueChange$",this._valueChange$.asObservable());z(this,"_focusStyle$",new ee.Subject);z(this,"focusStyle$",this._focusStyle$.asObservable());z(this,"_singleSelection$",new ee.Subject);z(this,"singleSelection$",this._singleSelection$.asObservable());z(this,"_spreadsheetFocusState",!1);this._injector=n,this._univerInstanceService=r,this._renderManagerService=i,this._lexerTreeBuilder=a,this._contextService=o}setFocusId(n){this._focusEditorUnitId=n}getFocusId(){return this._focusEditorUnitId}getFocusEditor(){if(this._focusEditorUnitId)return this.getEditor(this._focusEditorUnitId)}isEditor(n){return this._editors.has(n)}isSheetEditor(n){const r=this._editors.get(n);return!!(r&&r.isSheetEditor())}closeRangePrompt(){const n=this._univerInstanceService.getCurrentUniverDocInstance();if(!n)return;const r=n.getUnitId();this._contextService.setContextValue(y.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(y.FOCUSING_EDITOR_STANDALONE,!1),!(!this.isEditor(r)||this.isSheetEditor(r))&&(this.changeSpreadsheetFocusState(!1),this.blur())}changeSpreadsheetFocusState(n){this._spreadsheetFocusState=n}getSpreadsheetFocusState(){return this._spreadsheetFocusState}focusStyle(n){const r=this.getEditor(n);if(!r)return!1;r.setFocus(!0),this._contextService.setContextValue(y.EDITOR_ACTIVATED,!0),this._contextService.setContextValue(y.FOCUSING_EDITOR_STANDALONE,!0),this._contextService.setContextValue(y.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,r.isSingle()),this._spreadsheetFocusState||this.singleSelection(r.isSingleChoice()),this._focusStyle$.next(n),this.setFocusId(n)}singleSelection(n){this._singleSelection$.next(n)}selectionChangingState(){const n=this.getFocusId();if(n==null)return!0;const r=this.getEditor(n);return!r||r.isSheetEditor()?!0:r.onlyInputRange()!==!0&&r.onlyInputFormula()!==!0?(this.blur(),!0):r.onlyInputFormula()===!0&&this._contextService.getContextValue(y.FOCUSING_EDITOR_INPUT_FORMULA)!==!0?(this.blur(),!0):!this.getSpreadsheetFocusState()}blur(){this._spreadsheetFocusState||(this._closeRangePrompt$.next(null),this.singleSelection(!1),this.setFocusId(null),this._contextService.setContextValue(y.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(y.FOCUSING_EDITOR_STANDALONE,!1)),this.getAllEditor().forEach(n=>{n.setFocus(!1)}),this._focusStyle$.next(),this._blur$.next(null)}focus(n){if(n==null){const a=this._univerInstanceService.getCurrentUniverDocInstance();if(!a)return;n=a.getUnitId()}const r=this.getEditor(n);if(r==null)return;this._univerInstanceService.setCurrentUnitForType(n);const i=r.getValue().length;this.focusStyle(n),this._focus$.next({startOffset:i-2,endOffset:i-2})}setFormula(n,r){r==null&&(r=this._getCurrentEditorUnitId()),this._inputFormula$.next({formulaString:n,editorUnitId:r})}setValue(n,r){r==null&&(r=this._getCurrentEditorUnitId()),this.setValueNoRefresh(n,r),this._refreshValueChange(r)}setValueNoRefresh(n,r){this._setValue$.next({body:{dataStream:n},editorUnitId:r}),this.resize(r)}getValue(n){const r=this.getEditor(n);if(r!=null)return r.getValue()}setRichValue(n,r){r==null&&(r=this._getCurrentEditorUnitId()),this._setValue$.next({body:n,editorUnitId:r}),this._refreshValueChange(r)}getRichValue(n){const r=this.getEditor(n);if(r!=null)return r.getBody()}dispose(){this._state$.complete(),this._editors.clear(),super.dispose()}getEditor(n){return n==null&&(n=this._getCurrentEditorUnitId()),this._editors.get(n)}getAllEditor(){return this._editors}getFirstEditor(){return[...this.getAllEditor().values()][0]}resize(n){const r=this.getEditor(n);r!=null&&(r.verticalAlign(),this._resize$.next(n))}isVisible(n){var r;return(r=this.getEditor(n))==null?void 0:r.isVisible()}setOperationSheetUnitId(n){this._currentSheetUnitId=n}getOperationSheetUnitId(){return this._currentSheetUnitId}setOperationSheetSubUnitId(n){this._currentSheetSubUnitId=n}getOperationSheetSubUnitId(){return this._currentSheetSubUnitId}register(n,r){var p,f,S,_;const{initialSnapshot:i,editorUnitId:a,canvasStyle:o={}}=n,u=this._univerInstanceService.createUnit(y.UniverInstanceType.UNIVER_DOC,i||this._getBlank(a));let d=this._renderManagerService.getRenderById(a);d==null&&(this._renderManagerService.create(a),d=this._renderManagerService.getRenderById(a)),d.engine.setContainer(r);const h=new $a({...n,render:d,documentDataModel:u,editorDom:r,canvasStyle:o});return this._editors.set(a,h),(_=(S=(f=(p=d.mainComponent)==null?void 0:p.getScene())==null?void 0:f.getViewports())==null?void 0:S[0].getScrollBar())==null||_.dispose(),h.isSheetEditor()||(h.verticalAlign(),h.updateCanvasStyle()),y.toDisposable(()=>{this._unRegister(a)})}_unRegister(n){const r=this._editors.get(n);if(r==null)return;if(this._renderManagerService.removeRender(n),r.documentDataModel.dispose(),this._editors.delete(n),this._univerInstanceService.disposeUnit(n),this._univerInstanceService.getAllUnitsForType(y.UniverInstanceType.UNIVER_SHEET).length>0){const a=this._univerInstanceService.getCurrentUnitForType(y.UniverInstanceType.UNIVER_SHEET);this._univerInstanceService.focusUnit(a.getUnitId())}}refreshValueChange(n){this._refreshValueChange(n)}checkValueLegality(n){const r=this._editors.get(n);if(r==null)return!0;let i=r.getValue();if(r.setValueLegality(),i=i.replace(/\r\n/g,"").replace(/\n/g,"").replace(/\n/g,""),i.length===0)return!0;if(r.onlyInputFormula()){if(i.substring(0,1)!==n1.operatorToken.EQUALS)return r.setValueLegality(!1),!1;const a=this._lexerTreeBuilder.checkIfAddBracket(i);r.setValueLegality(a===0)}else if(r.onlyInputRange()){const a=i.split(",");if(r.isSingleChoice()&&a.length>1)return r.setValueLegality(!1),!1;r.setValueLegality(n1.isReferenceStrings(i))}return r.isValueLegality()}_refreshValueChange(n){const r=this.getEditor(n);r!=null&&this._valueChange$.next(r)}_getCurrentEditorUnitId(){return this._univerInstanceService.getCurrentUniverDocInstance().getUnitId()}_refresh(n){this._state$.next(n)}_getBlank(n){return{id:n,body:{dataStream:`${y.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{renderConfig:{verticalAlign:y.VerticalAlign.TOP,horizontalAlign:y.HorizontalAlign.LEFT},marginLeft:6,marginTop:2,marginRight:6}}}},E.EditorService=ja([y1(0,se.Inject(se.Injector)),y1(1,y.IUniverInstanceService),y1(2,h1.IRenderManagerService),y1(3,se.Inject(n1.LexerTreeBuilder)),y1(4,y.IContextService)],E.EditorService);const _1=se.createIdentifier("univer.editor.service");var Ba=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Fa=(e,t,n,r)=>{for(var i=r>1?void 0:r?za(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ba(t,n,i),i},R1=(e,t)=>(n,r)=>t(n,r,e);const Za="FOCUSING_UNIVER",Wa=["univer-app-layout","univer-toolbar-btn","univer-menu-item","univer-button","univer-sheet-bar-btn"],L1=se.createIdentifier("ui.layout-service");E.DesktopLayoutService=class extends y.Disposable{constructor(n,r,i,a){super();z(this,"_rootContainerElement",null);z(this,"_isFocused",!1);z(this,"_focusHandlers",new Map);z(this,"_canvasContainers",[]);z(this,"_allContainers",[]);this._contextService=n,this._univerInstanceService=r,this._logService=i,this._editorService=a,this._initUniverFocusListener(),this._initEditorStatus()}get isFocused(){return this._isFocused}focus(){const n=this._univerInstanceService.getFocusedUnit();if(!n)return;let r;n instanceof y.Workbook?r=this._focusHandlers.get(y.UniverInstanceType.UNIVER_SHEET):n instanceof y.DocumentDataModel?r=this._focusHandlers.get(y.UniverInstanceType.UNIVER_DOC):n instanceof y.SlideDataModel&&(r=this._focusHandlers.get(y.UniverInstanceType.UNIVER_SLIDE)),r&&r(n.getUnitId())}registerFocusHandler(n,r){if(this._focusHandlers.has(n))throw new Error(`[DesktopLayoutService]: handler of type ${n} bas been registered!`);return this._focusHandlers.set(n,r),y.toDisposable(()=>this._focusHandlers.delete(n))}registerCanvasElement(n){if(this._canvasContainers.indexOf(n)===-1)return this._canvasContainers.push(n),y.toDisposable(()=>y.remove(this._canvasContainers,n));throw new Error("[DesktopLayoutService]: canvas container already registered!")}registerRootContainerElement(n){if(this._rootContainerElement)throw new Error("[DesktopLayoutService]: root container already registered!");this._rootContainerElement=n;const r=this.registerContainerElement(n);return y.toDisposable(()=>{this._rootContainerElement=null,r.dispose()})}registerContainerElement(n){if(this._allContainers.indexOf(n)===-1)return this._allContainers.push(n),y.toDisposable(()=>y.remove(this._allContainers,n));throw new Error("[LayoutService]: container already registered!")}checkElementInCurrentContainers(n){return this._allContainers.some(r=>r.contains(n))}checkCanvasIsFocused(){return this._canvasContainers.some(n=>n===document.activeElement||n.contains(document.activeElement))}_initUniverFocusListener(){this.disposeWithMe(ee.fromEvent(window,"focusin").subscribe(n=>{const r=n.target;if(Wa.some(i=>r.classList.contains(i))){this._editorBlurListener(),queueMicrotask(()=>this.focus());return}r&&this.checkElementInCurrentContainers(r)?this._isFocused=!0:this._isFocused=!1,this._contextService.setContextValue(Za,this._isFocused),this._contextService.setContextValue(y.FOCUSING_UNIVER_EDITOR,Lr())}))}_initEditorStatus(){this._contextService.setContextValue(y.FOCUSING_UNIVER_EDITOR,Lr())}_editorBlurListener(){const n=this._editorService.getFocusEditor();n&&n.isSheetEditor()!==!0&&this._editorService.blur()}},E.DesktopLayoutService=Fa([y.OnLifecycle(y.LifecycleStages.Ready,L1),R1(0,y.IContextService),R1(1,y.IUniverInstanceService),R1(2,y.ILogService),R1(3,_1)],E.DesktopLayoutService);function Lr(){var e;return!!((e=document.activeElement)!=null&&e.classList.contains("univer-editor"))}const Lt=se.createIdentifier("univer.platform-service");class Er{get isMac(){return/Mac/.test(navigator.appVersion)}get isWindows(){return/Windows/.test(navigator.appVersion)}get isLinux(){return/Linux/.test(navigator.appVersion)}}var a1=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.BACKSPACE=8]="BACKSPACE",e[e.TAB=9]="TAB",e[e.ENTER=13]="ENTER",e[e.ESC=27]="ESC",e[e.SPACE=32]="SPACE",e[e.ARROW_LEFT=37]="ARROW_LEFT",e[e.ARROW_UP=38]="ARROW_UP",e[e.ARROW_RIGHT=39]="ARROW_RIGHT",e[e.ARROW_DOWN=40]="ARROW_DOWN",e[e.INSERT=45]="INSERT",e[e.DELETE=46]="DELETE",e[e.Digit0=48]="Digit0",e[e.Digit1=49]="Digit1",e[e.Digit2=50]="Digit2",e[e.Digit3=51]="Digit3",e[e.Digit4=52]="Digit4",e[e.Digit5=53]="Digit5",e[e.Digit6=54]="Digit6",e[e.Digit7=55]="Digit7",e[e.Digit8=56]="Digit8",e[e.Digit9=57]="Digit9",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NUM_LOCK=144]="NUM_LOCK",e[e.SCROLL_LOCK=145]="SCROLL_LOCK",e[e.MINUS=189]="MINUS",e[e.EQUAL=187]="EQUAL",e[e.BACK_SLASH=220]="BACK_SLASH",e))(a1||{});const Ga={8:"Backspace",9:"Tab",13:"Enter",46:"Del",27:"Esc",32:"Space",37:"←",39:"→",38:"↑",40:"↓",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",189:"-",187:"=",220:"\\"};var Re=(e=>(e[e.SHIFT=1024]="SHIFT",e[e.ALT=2048]="ALT",e[e.CTRL_COMMAND=4096]="CTRL_COMMAND",e[e.MAC_CTRL=8192]="MAC_CTRL",e))(Re||{}),Ya=Object.defineProperty,qa=Object.getOwnPropertyDescriptor,Xa=(e,t,n,r)=>{for(var i=r>1?void 0:r?qa(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ya(t,n,i),i},U1=(e,t)=>(n,r)=>t(n,r,e);const m1=se.createIdentifier("univer.shortcut");E.DesktopShortcutService=class extends y.Disposable{constructor(n,r,i,a){super();z(this,"_shortCutMapping",new Map);z(this,"_commandIDMapping",new Map);z(this,"_shortcutChanged$",new ee.Subject);z(this,"shortcutChanged$",this._shortcutChanged$.asObservable());z(this,"_forceEscaped",!1);z(this,"_disable",!1);this._commandService=n,this._platformService=r,this._contextService=i,this._layoutService=a,this.disposeWithMe(Ra("keydown",o=>{this._resolveKeyboardEvent(o)},{capture:!0}))}setDisable(n){this._disable=n}getAllShortcuts(){return Array.from(this._shortCutMapping.values()).map(n=>Array.from(n.values())).flat()}registerShortcut(n){const r=this._getBindingFromItem(n),i=this._shortCutMapping.get(r);i?i.add(n):this._shortCutMapping.set(r,new Set([n]));const a=n.id,o=this._commandIDMapping.get(a);return o?o.add(n):this._commandIDMapping.set(a,new Set([n])),this._emitShortcutChanged(),y.toDisposable(()=>{var u,d,h,p;(u=this._shortCutMapping.get(r))==null||u.delete(n),((d=this._shortCutMapping.get(r))==null?void 0:d.size)===0&&this._shortCutMapping.delete(r),(h=this._commandIDMapping.get(a))==null||h.delete(n),((p=this._commandIDMapping.get(a))==null?void 0:p.size)===0&&this._commandIDMapping.delete(a),this._emitShortcutChanged()})}getShortcutDisplayOfCommand(n){const r=this._commandIDMapping.get(n);return r?this.getShortcutDisplay(r.values().next().value):null}getShortcutDisplay(n){var h;const r=this._getBindingFromItem(n),i=r&Re.CTRL_COMMAND,a=r&Re.SHIFT,o=r&Re.ALT,u=r&Re.MAC_CTRL,d=(h=Ga[r&255])!=null?h:"<->";return this._platformService.isMac?`${i?"⌘":""}${a?"⇧":""}${o?"⌥":""}${u?"⌃":""}${d}`:`${i?"Ctrl+":""}${a?"Shift+":""}${o?"Alt+":""}${d}`}_emitShortcutChanged(){this._shortcutChanged$.next()}forceEscape(){return this._forceEscaped=!0,y.toDisposable(()=>this._forceEscaped=!1)}_resolveKeyboardEvent(n){if(this._forceEscaped||this._disable||this._layoutService&&!this._layoutService.checkElementInCurrentContainers(n.target))return;this._dispatch(n)&&n.preventDefault()}_dispatch(n){const r=this._deriveBindingFromEvent(n);if(r===null)return!1;const i=this._shortCutMapping.get(r);if(i===void 0)return!1;const a=Array.from(i).sort((o,u)=>{var d,h;return((d=u.priority)!=null?d:0)-((h=o.priority)!=null?h:0)}).find(o=>{var u,d;return(d=(u=o.preconditions)==null?void 0:u.call(o,this._contextService))!=null?d:!0});return a?(this._commandService.executeCommand(a.id,a.staticParameters),!0):!1}_getBindingFromItem(n){return this._platformService.isMac&&n.mac?n.mac:this._platformService.isWindows&&n.win?n.win:this._platformService.isLinux&&n.linux?n.linux:n.binding}_deriveBindingFromEvent(n){const{shiftKey:r,metaKey:i,altKey:a,keyCode:o}=n;let u=o;return r&&(u|=Re.SHIFT),a&&(u|=Re.ALT),(this._platformService.isMac?i:n.ctrlKey)&&(u|=Re.CTRL_COMMAND),this._platformService.isMac&&n.ctrlKey&&(u|=Re.MAC_CTRL),u}},E.DesktopShortcutService=Xa([U1(0,y.ICommandService),U1(1,Lt),U1(2,y.IContextService),U1(3,se.Optional(L1))],E.DesktopShortcutService);var Qa=Object.defineProperty,Ja=Object.getOwnPropertyDescriptor,Ka=(e,t,n,r)=>{for(var i=r>1?void 0:r?Ja(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Qa(t,n,i),i},eo=(e,t)=>(n,r)=>t(n,r,e);const s1=se.createIdentifier("univer.menu-service");E.DesktopMenuService=class extends y.Disposable{constructor(n){super();z(this,"_menuItemMap",new Map);z(this,"_menuByPositions",new Map);z(this,"_menuChanged$",new ee.BehaviorSubject(void 0));z(this,"menuChanged$",this._menuChanged$.asObservable());this._shortcutService=n}dispose(){this._menuItemMap.clear(),this._menuChanged$.complete()}addMenuItem(n){if(this._menuItemMap.has(n.id))throw new Error(`Menu item with the same id ${n.id} has already been added!`);return this._menuItemMap.set(n.id,n),Array.isArray(n.positions)?n.positions.forEach(r=>this._appendMenuToPosition(n,r)):this._appendMenuToPosition(n,n.positions),this._menuChanged$.next(),y.toDisposable(()=>{if(this._menuItemMap.delete(n.id),Array.isArray(n.positions))n.positions.forEach(r=>{const i=this._menuByPositions.get(r);if(!i)return;const a=i.findIndex(o=>o[0]===n.id);a>-1&&i.splice(a,1)});else{const r=this._menuByPositions.get(n.positions);if(!r)return;const i=r.findIndex(a=>a[0]===n.id);i>-1&&r.splice(i,1)}this._menuChanged$.next()})}getMenuItems(n){if(this._menuByPositions.has(n)){const r=this._menuByPositions.get(n);if(r)return[...r.values()].map(i=>this._getDisplayMenuItems(i[1]))}return[]}getMenuItem(n){return this._menuItemMap.has(n)?this._menuItemMap.get(n):null}_getDisplayMenuItems(n){const r=this._shortcutService.getShortcutDisplayOfCommand(n.id);return r?{...n,shortcut:r}:n}_appendMenuToPosition(n,r){this._menuByPositions.has(r)||this._menuByPositions.set(r,[]);const i=this._menuByPositions.get(r);if(i.findIndex(a=>a[0]===n.id)>-1)throw new Error(`Menu item with the same id ${n.id} has already been added!`);i.push([n.id,n])}},E.DesktopMenuService=Ka([eo(0,m1)],E.DesktopMenuService);const qe={menuItemNoHover:"univer-menu-item-no-hover",menuItemActivated:"univer-menu-item-activated",menuItemContent:"univer-menu-item-content",menuItemSelectable:"univer-menu-item-selectable",menuItemSelectableIcon:"univer-menu-item-selectable-icon",menuItemMoreIcon:"univer-menu-item-more-icon"};function wr(e){const{menuType:t,onOptionSelect:n}=e,r=le.useDependency(s1);if(!t)return;if(Array.isArray(t)){const o=t.map(u=>r.getMenuItems(u)).map(u=>u.reduce((d,h)=>{var p,f;return h.group?(d[h.group]=(p=d[h.group])!=null?p:[],d[h.group].push(h)):(d[i1.CONTEXT_MENU_OTHERS]=(f=d[i1.CONTEXT_MENU_OTHERS])!=null?f:[],d[i1.CONTEXT_MENU_OTHERS].push(h)),d},{}));return v.jsx(v.Fragment,{children:o.map(u=>Object.keys(u).map(d=>v.jsx(ge.MenuItemGroup,{eventKey:d,children:u[d].map(h=>v.jsx(Or,{menuItem:h,onClick:p=>{n==null||n({value:"",label:h.id,...p})}},h.id))},d)))})}return r.getMenuItems(t).map(a=>v.jsx(Or,{menuItem:a,onClick:o=>{n==null||n({value:"",label:a.id,...o})}},a.id))}function Mr(e){var a;const{options:t,value:n,onOptionSelect:r,parentKey:i}=e;return(a=t==null?void 0:t.map((o,u)=>{var S,_,L;const d=`${i}-${(S=o.label)!=null?S:o.id}-${u}`,h=U=>{r==null||r({value:U,label:o==null?void 0:o.label})},p=()=>{typeof o.value>"u"||r==null||r({...o})},f=Ve({[qe.menuItemNoHover]:typeof o.label!="string"&&!((_=o.label)!=null&&_.hoverable)});return v.jsx(ge.MenuItem,{disabled:o.disabled,eventKey:d,className:f,onClick:p,children:v.jsxs("span",{className:Ve(qe.menuItemContent,{[qe.menuItemSelectable]:!(typeof o.label!="string"&&!((L=o.label)!=null&&L.hoverable))}),children:[typeof n<"u"&&String(n)===String(o.value)&&v.jsx("span",{className:qe.menuItemSelectableIcon,children:v.jsx(ji,{style:{color:"rgb(var(--success-color))"}})}),v.jsx(je,{value$:o.value$,value:o.value,label:o.label,icon:o.icon,onChange:h})]})},d)}))!=null?a:v.jsx(v.Fragment,{})}const P1=e=>v.jsxs(ge.Menu,{selectable:!1,children:[v.jsx(Mr,{...e}),v.jsx(wr,{...e})]});function Or({menuItem:e,onClick:t}){const n=le.useDependency(s1),r=e.id?n.getMenuItems(e.id):[],i=Ae(e.disabled$,!1),a=Ae(e.activated$,!1),o=Ae(e.hidden$,!1),u=Ae(e.value$),[d,h]=s.useState(u),p=L=>{const U=y.isRealNum(L)&&typeof L=="string"?Number.parseInt(L):L;h(U)},f=()=>{const L=e,{title:U,label:H}=L;return v.jsx(ge.MenuItem,{eventKey:L.id,disabled:i,className:Ve({[qe.menuItemActivated]:a}),onClick:()=>{t({value:d,id:L.id})},children:v.jsx("span",{className:qe.menuItemContent,children:v.jsx(je,{value:u,title:U,label:H,icon:L.icon,onChange:p})})},L.id)},S=()=>{var A;const L=e,U=Ae(ee.isObservable(L.selections)?L.selections:void 0),H=(A=U!=null?U:L.selections)!=null?A:[];return H.length>0?v.jsx(ge.SubMenu,{eventKey:L.id,popupOffset:[18,0],title:v.jsxs("span",{className:qe.menuItemContent,children:[v.jsx(je,{title:L.title,value:d,onChange:p,icon:L.icon,label:L.label}),L.shortcut&&` (${L.shortcut})`]}),expandIcon:v.jsx(V3,{className:qe.menuItemMoreIcon}),children:H.length>0&&v.jsx(Mr,{parentKey:L.id,menuType:L.id,options:H,onOptionSelect:k=>{t({value:k.value,id:L.id})}})},L.id):v.jsx(ge.MenuItem,{eventKey:L.id,children:v.jsxs("span",{className:qe.menuItemContent,children:[v.jsx(je,{title:L.title,value:d,icon:L.icon,label:L.label,onChange:p}),L.shortcut&&` (${L.shortcut})`]})},L.id)},_=()=>{const L=e;return v.jsx(ge.SubMenu,{eventKey:L.id,popupOffset:[18,0],title:v.jsx("span",{className:qe.menuItemContent,children:v.jsx(je,{title:L.title,icon:L.icon,label:L.label,onChange:p})}),expandIcon:v.jsx(V3,{className:qe.menuItemMoreIcon}),children:r.length&&v.jsx(wr,{menuType:L.id,parentKey:L.id,onOptionSelect:t})},L.id)};return o?null:v.jsxs(v.Fragment,{children:[e.type===$e.SELECTOR&&S(),e.type===$e.SUBITEMS&&_(),e.type===$e.BUTTON&&f()]})}function to(e,t,...n){return e.t(t)}function no(e){const t=s.useRef(e);return t.current=e,s.useCallback((...n)=>t.current(...n),[])}const Ir="univer.command.copy",Et={id:Ir,name:Ir,multi:!0,priority:0,type:y.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Hr="univer.command.cut",wt={id:Hr,name:Hr,multi:!0,priority:0,type:y.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Dr="univer.command.paste",Mt={id:Dr,name:Dr,multi:!0,priority:0,type:y.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Tr={id:"sheet.operation.set-editor-resize",type:y.CommandType.OPERATION,handler:(e,t)=>!0};function ro(e){const t=e.get(y.IUndoRedoService);return{id:y.UndoCommand.id,group:i1.TOOLBAR_HISTORY,type:$e.BUTTON,icon:"UndoSingle",title:"Undo",tooltip:"toolbar.undo",positions:[Fe.TOOLBAR_START],disabled$:t.undoRedoStatus$.pipe(Cn.map(n=>n.undos<=0))}}function io(e){const t=e.get(y.IUndoRedoService);return{id:y.RedoCommand.id,group:i1.TOOLBAR_HISTORY,type:$e.BUTTON,icon:"RedoSingle",title:"Redo",tooltip:"toolbar.redo",positions:[Fe.TOOLBAR_START],disabled$:t.undoRedoStatus$.pipe(Cn.map(n=>n.redos<=0))}}var ao=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,so=(e,t,n,r)=>{for(var i=r>1?void 0:r?oo(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ao(t,n,i),i},j1=(e,t)=>(n,r)=>t(n,r,e);function $1(e){return e.getContextValue(y.FOCUSING_UNIVER_EDITOR)}const xr={id:Et.id,description:"shortcut.copy",group:"1_common-edit",binding:a1.C|Re.CTRL_COMMAND,preconditions:$1},Vr={id:wt.id,description:"shortcut.cut",group:"1_common-edit",binding:a1.X|Re.CTRL_COMMAND,preconditions:$1},lo={id:Mt.id,description:"shortcut.paste",group:"1_common-edit",binding:a1.V|Re.CTRL_COMMAND,preconditions:()=>!1},Nr={id:y.UndoCommand.id,description:"shortcut.undo",group:"1_common-edit",binding:a1.Z|Re.CTRL_COMMAND,preconditions:$1},kr={id:y.RedoCommand.id,description:"shortcut.redo",group:"1_common-edit",binding:a1.Y|Re.CTRL_COMMAND,preconditions:$1};E.SharedController=class extends y.Disposable{constructor(t,n,r,i){super(),this._injector=t,this._menuService=n,this._shortcutService=r,this._commandService=i,this.initialize()}initialize(){this._registerCommands(),this._registerShortcuts(),this._registerMenus()}_registerMenus(){[ro,io].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))})}_registerCommands(){[wt,Et,Mt,Tr].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t)))}_registerShortcuts(){const t=[Nr,kr];t.push(Vr,xr,lo),t.forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}},E.SharedController=so([y.OnLifecycle(y.LifecycleStages.Ready,E.SharedController),j1(0,se.Inject(se.Injector)),j1(1,s1),j1(2,m1),j1(3,y.ICommandService)],E.SharedController);const B1=se.createIdentifier("univer.ui-controller");var E1={},Ar={exports:{}},Rr={exports:{}};(function(e){function t(n){"@babel/helpers - typeof";return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(Rr);var w1=Rr.exports;(function(e){var t=w1.default;function n(i){if(typeof WeakMap!="function")return null;var a=new WeakMap,o=new WeakMap;return(n=function(d){return d?o:a})(i)}function r(i,a){if(!a&&i&&i.__esModule)return i;if(i===null||t(i)!="object"&&typeof i!="function")return{default:i};var o=n(a);if(o&&o.has(i))return o.get(i);var u={__proto__:null},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var h in i)if(h!=="default"&&{}.hasOwnProperty.call(i,h)){var p=d?Object.getOwnPropertyDescriptor(i,h):null;p&&(p.get||p.set)?Object.defineProperty(u,h,p):u[h]=i[h]}return u.default=i,o&&o.set(i,u),u}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(Ar);var co=Ar.exports,Ur={exports:{}};(function(e){function t(n){return n&&n.__esModule?n:{default:n}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(Ur);var uo=Ur.exports,Pr={exports:{}};(function(e){var t=w1.default;function n(){e.exports=n=function(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var r,i={},a=Object.prototype,o=a.hasOwnProperty,u=Object.defineProperty||function(O,w,D){O[w]=D.value},d=typeof Symbol=="function"?Symbol:{},h=d.iterator||"@@iterator",p=d.asyncIterator||"@@asyncIterator",f=d.toStringTag||"@@toStringTag";function S(O,w,D){return Object.defineProperty(O,w,{value:D,enumerable:!0,configurable:!0,writable:!0}),O[w]}try{S({},"")}catch{S=function(D,Y,W){return D[Y]=W}}function _(O,w,D,Y){var W=w&&w.prototype instanceof G?w:G,X=Object.create(W.prototype),ie=new pe(Y||[]);return u(X,"_invoke",{value:K(O,D,ie)}),X}function L(O,w,D){try{return{type:"normal",arg:O.call(w,D)}}catch(Y){return{type:"throw",arg:Y}}}i.wrap=_;var U="suspendedStart",H="suspendedYield",A="executing",k="completed",F={};function G(){}function M(){}function V(){}var R={};S(R,h,function(){return this});var N=Object.getPrototypeOf,$=N&&N(N(Ee([])));$&&$!==a&&o.call($,h)&&(R=$);var q=V.prototype=G.prototype=Object.create(R);function Z(O){["next","throw","return"].forEach(function(w){S(O,w,function(D){return this._invoke(w,D)})})}function J(O,w){function D(W,X,ie,oe){var Le=L(O[W],O,X);if(Le.type!=="throw"){var xe=Le.arg,Ie=xe.value;return Ie&&t(Ie)=="object"&&o.call(Ie,"__await")?w.resolve(Ie.__await).then(function(we){D("next",we,ie,oe)},function(we){D("throw",we,ie,oe)}):w.resolve(Ie).then(function(we){xe.value=we,ie(xe)},function(we){return D("throw",we,ie,oe)})}oe(Le.arg)}var Y;u(this,"_invoke",{value:function(X,ie){function oe(){return new w(function(Le,xe){D(X,ie,Le,xe)})}return Y=Y?Y.then(oe,oe):oe()}})}function K(O,w,D){var Y=U;return function(W,X){if(Y===A)throw Error("Generator is already running");if(Y===k){if(W==="throw")throw X;return{value:r,done:!0}}for(D.method=W,D.arg=X;;){var ie=D.delegate;if(ie){var oe=me(ie,D);if(oe){if(oe===F)continue;return oe}}if(D.method==="next")D.sent=D._sent=D.arg;else if(D.method==="throw"){if(Y===U)throw Y=k,D.arg;D.dispatchException(D.arg)}else D.method==="return"&&D.abrupt("return",D.arg);Y=A;var Le=L(O,w,D);if(Le.type==="normal"){if(Y=D.done?k:H,Le.arg===F)continue;return{value:Le.arg,done:D.done}}Le.type==="throw"&&(Y=k,D.method="throw",D.arg=Le.arg)}}}function me(O,w){var D=w.method,Y=O.iterator[D];if(Y===r)return w.delegate=null,D==="throw"&&O.iterator.return&&(w.method="return",w.arg=r,me(O,w),w.method==="throw")||D!=="return"&&(w.method="throw",w.arg=new TypeError("The iterator does not provide a '"+D+"' method")),F;var W=L(Y,O.iterator,w.arg);if(W.type==="throw")return w.method="throw",w.arg=W.arg,w.delegate=null,F;var X=W.arg;return X?X.done?(w[O.resultName]=X.value,w.next=O.nextLoc,w.method!=="return"&&(w.method="next",w.arg=r),w.delegate=null,F):X:(w.method="throw",w.arg=new TypeError("iterator result is not an object"),w.delegate=null,F)}function fe(O){var w={tryLoc:O[0]};1 in O&&(w.catchLoc=O[1]),2 in O&&(w.finallyLoc=O[2],w.afterLoc=O[3]),this.tryEntries.push(w)}function ae(O){var w=O.completion||{};w.type="normal",delete w.arg,O.completion=w}function pe(O){this.tryEntries=[{tryLoc:"root"}],O.forEach(fe,this),this.reset(!0)}function Ee(O){if(O||O===""){var w=O[h];if(w)return w.call(O);if(typeof O.next=="function")return O;if(!isNaN(O.length)){var D=-1,Y=function W(){for(;++D<O.length;)if(o.call(O,D))return W.value=O[D],W.done=!1,W;return W.value=r,W.done=!0,W};return Y.next=Y}}throw new TypeError(t(O)+" is not iterable")}return M.prototype=V,u(q,"constructor",{value:V,configurable:!0}),u(V,"constructor",{value:M,configurable:!0}),M.displayName=S(V,f,"GeneratorFunction"),i.isGeneratorFunction=function(O){var w=typeof O=="function"&&O.constructor;return!!w&&(w===M||(w.displayName||w.name)==="GeneratorFunction")},i.mark=function(O){return Object.setPrototypeOf?Object.setPrototypeOf(O,V):(O.__proto__=V,S(O,f,"GeneratorFunction")),O.prototype=Object.create(q),O},i.awrap=function(O){return{__await:O}},Z(J.prototype),S(J.prototype,p,function(){return this}),i.AsyncIterator=J,i.async=function(O,w,D,Y,W){W===void 0&&(W=Promise);var X=new J(_(O,w,D,Y),W);return i.isGeneratorFunction(w)?X:X.next().then(function(ie){return ie.done?ie.value:X.next()})},Z(q),S(q,f,"Generator"),S(q,h,function(){return this}),S(q,"toString",function(){return"[object Generator]"}),i.keys=function(O){var w=Object(O),D=[];for(var Y in w)D.push(Y);return D.reverse(),function W(){for(;D.length;){var X=D.pop();if(X in w)return W.value=X,W.done=!1,W}return W.done=!0,W}},i.values=Ee,pe.prototype={constructor:pe,reset:function(w){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(ae),!w)for(var D in this)D.charAt(0)==="t"&&o.call(this,D)&&!isNaN(+D.slice(1))&&(this[D]=r)},stop:function(){this.done=!0;var w=this.tryEntries[0].completion;if(w.type==="throw")throw w.arg;return this.rval},dispatchException:function(w){if(this.done)throw w;var D=this;function Y(xe,Ie){return ie.type="throw",ie.arg=w,D.next=xe,Ie&&(D.method="next",D.arg=r),!!Ie}for(var W=this.tryEntries.length-1;W>=0;--W){var X=this.tryEntries[W],ie=X.completion;if(X.tryLoc==="root")return Y("end");if(X.tryLoc<=this.prev){var oe=o.call(X,"catchLoc"),Le=o.call(X,"finallyLoc");if(oe&&Le){if(this.prev<X.catchLoc)return Y(X.catchLoc,!0);if(this.prev<X.finallyLoc)return Y(X.finallyLoc)}else if(oe){if(this.prev<X.catchLoc)return Y(X.catchLoc,!0)}else{if(!Le)throw Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return Y(X.finallyLoc)}}}},abrupt:function(w,D){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var W=this.tryEntries[Y];if(W.tryLoc<=this.prev&&o.call(W,"finallyLoc")&&this.prev<W.finallyLoc){var X=W;break}}X&&(w==="break"||w==="continue")&&X.tryLoc<=D&&D<=X.finallyLoc&&(X=null);var ie=X?X.completion:{};return ie.type=w,ie.arg=D,X?(this.method="next",this.next=X.finallyLoc,F):this.complete(ie)},complete:function(w,D){if(w.type==="throw")throw w.arg;return w.type==="break"||w.type==="continue"?this.next=w.arg:w.type==="return"?(this.rval=this.arg=w.arg,this.method="return",this.next="end"):w.type==="normal"&&D&&(this.next=D),F},finish:function(w){for(var D=this.tryEntries.length-1;D>=0;--D){var Y=this.tryEntries[D];if(Y.finallyLoc===w)return this.complete(Y.completion,Y.afterLoc),ae(Y),F}},catch:function(w){for(var D=this.tryEntries.length-1;D>=0;--D){var Y=this.tryEntries[D];if(Y.tryLoc===w){var W=Y.completion;if(W.type==="throw"){var X=W.arg;ae(Y)}return X}}throw Error("illegal catch attempt")},delegateYield:function(w,D,Y){return this.delegate={iterator:Ee(w),resultName:D,nextLoc:Y},this.method==="next"&&(this.arg=r),F}},i}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(Pr);var fo=Pr.exports,jr={exports:{}};(function(e){function t(r,i,a,o,u,d,h){try{var p=r[d](h),f=p.value}catch(S){a(S);return}p.done?i(f):Promise.resolve(f).then(o,u)}function n(r){return function(){var i=this,a=arguments;return new Promise(function(o,u){var d=r.apply(i,a);function h(f){t(d,o,u,h,p,"next",f)}function p(f){t(d,o,u,h,p,"throw",f)}h(void 0)})}}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(jr);var ho=jr.exports,$r={exports:{}},Br={exports:{}},zr={exports:{}},Fr={exports:{}};(function(e){var t=w1.default;function n(r,i){if(t(r)!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var o=a.call(r,i||"default");if(t(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(Fr);var mo=Fr.exports;(function(e){var t=w1.default,n=mo;function r(i){var a=n(i,"string");return t(a)=="symbol"?a:a+""}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(zr);var po=zr.exports;(function(e){var t=po;function n(r,i,a){return i=t(i),i in r?Object.defineProperty(r,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[i]=a,r}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(Br);var go=Br.exports;(function(e){var t=go;function n(i,a){var o=Object.keys(i);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(i);a&&(u=u.filter(function(d){return Object.getOwnPropertyDescriptor(i,d).enumerable})),o.push.apply(o,u)}return o}function r(i){for(var a=1;a<arguments.length;a++){var o=arguments[a]!=null?arguments[a]:{};a%2?n(Object(o),!0).forEach(function(u){t(i,u,o[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(u){Object.defineProperty(i,u,Object.getOwnPropertyDescriptor(o,u))})}return i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})($r);var vo=$r.exports,Co=co.default,z1=uo.default;Object.defineProperty(E1,"__esModule",{value:!0}),E1._r=Do,E1._u=No;var So=E1.render=To,bo=E1.unmount=ko,F1=z1(fo),Zr=z1(ho),yo=z1(w1),_o=z1(vo),Lo=Co(yt),M1=(0,_o.default)({},Lo),Eo=M1.version,wo=M1.render,Mo=M1.unmountComponentAtNode,Z1;try{var Oo=Number((Eo||"").split(".")[0]);Oo>=18&&(Z1=M1.createRoot)}catch{}function Wr(e){var t=M1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;t&&(0,yo.default)(t)==="object"&&(t.usingClientEntryPoint=e)}var W1="__rc_react_root__";function Io(e,t){Wr(!0);var n=t[W1]||Z1(t);Wr(!1),n.render(e),t[W1]=n}function Ho(e,t){wo(e,t)}function Do(e,t){}function To(e,t){if(Z1){Io(e,t);return}Ho(e,t)}function xo(e){return Ot.apply(this,arguments)}function Ot(){return Ot=(0,Zr.default)((0,F1.default)().mark(function e(t){return(0,F1.default)().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",Promise.resolve().then(function(){var i;(i=t[W1])===null||i===void 0||i.unmount(),delete t[W1]}));case 1:case"end":return r.stop()}},e)})),Ot.apply(this,arguments)}function Vo(e){Mo(e)}function No(e){}function ko(e){return It.apply(this,arguments)}function It(){return It=(0,Zr.default)((0,F1.default)().mark(function e(t){return(0,F1.default)().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(Z1===void 0){r.next=2;break}return r.abrupt("return",xo(t));case 2:Vo(t);case 3:case"end":return r.stop()}},e)})),It.apply(this,arguments)}const G1=se.createIdentifier("univer.message-service"),r1={appLayout:"univer-app-layout",appContainer:"univer-app-container",appContainerHeader:"univer-app-container-header",appContainerWrapper:"univer-app-container-wrapper",appContainerContent:"univer-app-container-content",appContainerCanvas:"univer-app-container-canvas",appContainerLeftSidebar:"univer-app-container-left-sidebar",appContainerSidebar:"univer-app-container-sidebar"};function p1(e){const{components:t}=e;return t?Array.from(t.values()).map((n,r)=>s.createElement(n(),{key:`${r}`})):null}const Gr={toolbarBtn:"univer-toolbar-btn",toolbarBtnActive:"univer-toolbar-btn-active"};function Yr(e){const{children:t,className:n,style:r,disabled:i=!1,active:a=!1,onClick:o,onDoubleClick:u,...d}=e,h=S=>{if(i){S.preventDefault();return}o&&o(S)},p=S=>{if(i){S.preventDefault();return}u&&u(S)},f=Ve(Gr.toolbarBtn,{[`${Gr.toolbarBtn}-active`]:a},n);return v.jsx("button",{className:f,style:r,disabled:i,onClick:h,onDoubleClick:p,...d,children:t})}const de={headerbar:"univer-headerbar",headerMenu:"univer-header-menu",menubar:"univer-menubar",menubarItem:"univer-menubar-item",menubarItemActive:"univer-menubar-item-active",toolbar:"univer-toolbar",toolbarContainer:"univer-toolbar-container",toolbarMore:"univer-toolbar-more",toolbarMoreContainer:"univer-toolbar-more-container",toolbarGroup:"univer-toolbar-group",toolbarItemSelectButton:"univer-toolbar-item-select-button",toolbarItemSelectButtonDisabled:"univer-toolbar-item-select-button-disabled",toolbarItemSelectButtonActivated:"univer-toolbar-item-select-button-activated",toolbarItemSelectButtonLabel:"univer-toolbar-item-select-button-label",toolbarItemSelectButtonArrow:"univer-toolbar-item-select-button-arrow",toolbarItemSelect:"univer-toolbar-item-select",toolbarItemSelectDisabled:"univer-toolbar-item-select-disabled",toolbarItemSelectActivated:"univer-toolbar-item-select-activated",toolbarItemSelectArrow:"univer-toolbar-item-select-arrow",toolbarItemSelectArrowDisabled:"univer-toolbar-item-select-arrow-disabled",toolbarItemSelectArrowActivated:"univer-toolbar-item-select-arrow-activated"},Ht=s.forwardRef((e,t)=>{const n=le.useDependency(y.LocaleService),r=le.useDependency(y.ICommandService),i=le.useInjector(),[a,o]=s.useState(),[u,d]=s.useState(!1),[h,p]=s.useState(!1),[f,S]=s.useState(!1),[_,L]=s.useState(!1),[U,H]=s.useState(!1),A=(O,w)=>{r.executeCommand(O,w),i.get(h1.ITextSelectionRenderManager).focus()};function k(O){L(O)}function F(O){H(O),O||L(!1)}s.useEffect(()=>{const O=[];return e.disabled$&&O.push(e.disabled$.subscribe(w=>{d(w)})),e.hidden$&&O.push(e.hidden$.subscribe(w=>{S(w)})),e.activated$&&O.push(e.activated$.subscribe(w=>{p(w)})),e.value$&&O.push(e.value$.subscribe(w=>{o(w)})),()=>{O.forEach(w=>{w.unsubscribe()})}},[]);const{tooltip:G,shortcut:M,icon:V,title:R,label:N,id:$}=e,q=n.t(G!=null?G:"")+(M?` (${M})`:""),{selections:Z}=e,J=s.useMemo(()=>ee.isObservable(Z)?Z:new ee.Observable(O=>{O.next(Z)}),[Z]),K=Ae(J),me=s.useMemo(()=>ee.isObservable(V)?V:new ee.Observable(O=>{var D,Y;const w=(Y=(D=K==null?void 0:K.find(W=>W.value===a))==null?void 0:D.icon)!=null?Y:V;O.next(w)}),[V,K,a]),fe=Ae(me,void 0,!0);function ae(O){function w(W){if(u)return;let X=$;const ie=W;W.id&&(X=W.id),A(X,ie)}function D(W){if(u)return;A($,{value:W})}function Y(){u||O===$e.BUTTON_SELECTOR&&A($,{value:a})}return O===$e.BUTTON_SELECTOR?v.jsxs("div",{className:Ve(de.toolbarItemSelectButton,{[de.toolbarItemSelectButtonDisabled]:u,[de.toolbarItemSelectButtonActivated]:h}),"data-disabled":u,children:[v.jsx("div",{className:de.toolbarItemSelectButtonLabel,onClick:Y,children:v.jsx(je,{icon:fe,title:R,value:a,label:N,onChange:D})}),u?v.jsx("div",{className:Ve(de.toolbarItemSelectButtonArrow,{[de.toolbarItemSelectButtonArrowDisabled]:u,[de.toolbarItemSelectButtonArrowActivated]:h}),"data-disabled":u,children:v.jsx(V1,{})}):v.jsx(ge.Dropdown,{overlay:v.jsx(P1,{menuType:$,options:K,onOptionSelect:w,value:a}),onVisibleChange:F,children:v.jsx("div",{className:Ve(de.toolbarItemSelectButtonArrow,{[de.toolbarItemSelectButtonArrowDisabled]:u,[de.toolbarItemSelectButtonArrowActivated]:h}),"data-disabled":u,children:v.jsx(V1,{})})})]}):u?v.jsxs("div",{className:Ve(de.toolbarItemSelect,{[de.toolbarItemSelectDisabled]:u,[de.toolbarItemSelectActivated]:h}),children:[v.jsx(je,{icon:fe,title:R,value:a,label:N,onChange:D}),v.jsx("div",{className:Ve(de.toolbarItemSelectArrow,{[de.toolbarItemSelectArrowDisabled]:u,[de.toolbarItemSelectArrowActivated]:h}),children:v.jsx(V1,{})})]}):v.jsx(ge.Dropdown,{overlay:v.jsx(P1,{menuType:$,options:K,onOptionSelect:w,value:a}),onVisibleChange:F,children:v.jsxs("div",{className:Ve(de.toolbarItemSelect,{[de.toolbarItemSelectDisabled]:u,[de.toolbarItemSelectActivated]:h}),children:[v.jsx(je,{icon:fe,title:R,value:a,label:N,onChange:D}),v.jsx("div",{className:Ve(de.toolbarItemSelectArrow,{[de.toolbarItemSelectArrowDisabled]:u}),children:v.jsx(V1,{})})]})})}function pe(){var D;const w=le.useDependency(Ke).get(typeof N=="string"?N:(D=N==null?void 0:N.name)!=null?D:"");return v.jsx(Yr,{className:de.toolbarItemTextButton,active:h,disabled:u,onClick:()=>A(e.id),onDoubleClick:()=>e.subId&&A(e.subId),children:w?v.jsx(je,{title:R,value:a,label:N}):v.jsx(je,{icon:V})})}function Ee(){switch(e.type){case $e.BUTTON_SELECTOR:case $e.SELECTOR:case $e.SUBITEMS:return ae(e.type);case $e.BUTTON:default:return pe()}}return f?null:v.jsx(ge.Tooltip,{ref:t,visible:U?!1:_,title:q,placement:"bottom",onVisibleChange:k,children:Ee()})}),Ao=[Fe.TOOLBAR_START,Fe.TOOLBAR_INSERT,Fe.TOOLBAR_FORMULAS,Fe.TOOLBAR_DATA,Fe.TOOLBAR_VIEW,Fe.TOOLBAR_OTHERS];function Ro(e){const{headerMenuComponents:t}=e,n=le.useDependency(y.LocaleService),r=le.useDependency(s1),[i,a]=s.useState(Fe.TOOLBAR_START),o=s.useRef(null),u=s.useRef({}),[d,h]=s.useState([]),[p,f]=s.useState([]),[S,_]=s.useState([]);s.useEffect(()=>{var F,G;const H=(G=(F=d.find(M=>M.name===i))==null?void 0:F.menuItems)!=null?G:[],k=ee.combineLatest(H.map(M=>{var V;return(V=M.hidden$)!=null?V:new ee.Observable(R=>R.next(!1))})).pipe(ee.map(M=>H.filter((V,R)=>!M[R]))).subscribe(M=>{_(M)});return()=>{k.unsubscribe()}},[d]),s.useEffect(()=>{const H=r.menuChanged$.subscribe(()=>{const A=[];for(const k of Ao){const F=r.getMenuItems(k);F.length&&A.push({name:k,menuItems:F})}h(A)});return()=>{H.unsubscribe()}},[i]),s.useEffect(()=>{function H(){var R,N;const k=(N=(R=o.current)==null?void 0:R.clientWidth)!=null?N:0,F=8,G=Object.entries(u.current).filter(([$,q])=>q.el&&q.key&&S.find(Z=>Z.id===q.key)).map(([$,q])=>{var Z;return{key:q.key,width:((Z=q.el)==null?void 0:Z.clientWidth)+F}}),M=[];let V=182;for(const $ of G)V+=$.width,V>k&&M.push($.key);f(M)}H();const A=new ResizeObserver(()=>H());return A.observe(document.body),()=>{A.unobserve(document.body)}},[S,d,i]);const L=s.useMemo(()=>{var H,A;return(A=(H=d.find(k=>k.name===i))==null?void 0:H.menuItems.reduce((k,F)=>{var M;const G=(M=F.group)!=null?M:i1.TOOLBAR_OTHERS;return k[G]||(k[G]=[]),k[G].push(F),k},{}))!=null?A:{}},[d]),U=s.useMemo(()=>t&&t.size>0||d.length>1,[t,d]);return v.jsxs(v.Fragment,{children:[U?v.jsxs("header",{className:de.headerbar,children:[v.jsx("div",{className:de.menubar,children:d.length>1&&d.map((H,A)=>v.jsx("a",{className:Ve(de.menubarItem,{[de.menubarItemActive]:H.name===i}),onClick:()=>{a(H.name)},children:n.t(H.name)},A))}),v.jsx("div",{className:de.headerMenu,children:v.jsx(p1,{components:t})})]}):null,v.jsx("div",{ref:o,className:de.toolbar,children:v.jsxs("div",{className:de.toolbarContainer,children:[Object.entries(L).filter(([H,A])=>A.filter(F=>!p.includes(F.id)).length).map(([H,A])=>v.jsx("div",{className:de.toolbarGroup,children:A.map(k=>!p.includes(k.id)&&v.jsx(Ht,{...k},k.id))},H)),p.length>0&&v.jsx(ge.Tooltip,{title:n.t("more"),placement:"bottom",children:v.jsx(ge.Dropdown,{forceRender:!0,className:de.toolbarMore,overlay:v.jsx("div",{className:de.toolbarMoreContainer,onClick:H=>H.stopPropagation(),children:Object.entries(L).map(([H,A])=>v.jsx("div",{className:de.toolbarGroup,children:A.map(k=>p.includes(k.id)&&v.jsx(Ht,{...k},k.id))},H))}),children:v.jsx(Yr,{className:de.toolbarItemTextButton,children:v.jsx(j2,{})})})})]})}),v.jsx("div",{className:de.toolbarContainer,style:{position:"absolute",top:-9999,left:-9999,opacity:0},children:Object.entries(L).map(([H,A])=>v.jsx("div",{className:de.toolbarGroup,children:A.map(k=>v.jsx(Ht,{ref:F=>{u.current[k.id]={el:F==null?void 0:F.nativeElement,key:k.id}},...k},k.id))},H))})]})}const Y1=se.createIdentifier("univer.sidebar-service"),l1={sidebar:"univer-sidebar",sidebarOpen:"univer-sidebar-open",sidebarContainer:"univer-sidebar-container",sidebarHeader:"univer-sidebar-header",sidebarHeaderClose:"univer-sidebar-header-close",sidebarBody:"univer-sidebar-body",sidebarFooter:"univer-sidebar-footer"};function Uo(){const e=le.useDependency(Y1),[t,n]=s.useState({});s.useEffect(()=>{const u=e.sidebarOptions$.subscribe(d=>{n(d)});return()=>{u.unsubscribe()}},[]);const r=t;for(const u of["children","header","footer"]){const d=u;if(t[d]){const h=t[d];h&&(r[d]=v.jsx(je,{...h}))}}const i=Ve(l1.sidebar,{[l1.sidebarOpen]:r.visible}),a=s.useMemo(()=>r.visible?typeof r.width=="number"?`${r.width}px`:r.width:0,[r]);function o(){var d;const u={...t,visible:!1};n(u),e.sidebarOptions$.next(u),(d=u==null?void 0:u.onClose)==null||d.call(u)}return v.jsx("section",{className:i,style:{width:a},children:v.jsxs("section",{className:l1.sidebarContainer,children:[v.jsxs("header",{className:l1.sidebarHeader,children:[r==null?void 0:r.header,v.jsx("a",{className:l1.sidebarHeaderClose,onClick:o,children:v.jsx(_t,{})})]}),v.jsx("section",{className:l1.sidebarBody,children:r==null?void 0:r.children}),(r==null?void 0:r.footer)&&v.jsx("footer",{className:l1.sidebarFooter,children:r.footer})]})})}const Dt=se.createIdentifier("univer.zen-zone-service"),Tt={zenZone:"univer-zen-zone",zenZoneOpen:"univer-zen-zone-open",zenZoneClose:"univer-zen-zone-close"};function Po(){const e=le.useDependency(Dt),[t,n]=s.useState(!1),[r,i]=s.useState(),a=le.useDependency(Ke);s.useEffect(()=>{const d=[e.visible$.subscribe(h=>{n(h)}),e.componentKey$.subscribe(h=>{i(h)})];return()=>{d.forEach(h=>{h.unsubscribe()})}},[]);const o=Ve(Tt.zenZone,t?Tt.zenZoneOpen:Tt.zenZoneClose),u=s.useMemo(()=>{const d=a.get(r!=null?r:"");if(d)return d},[r]);return v.jsx("section",{className:o,children:u&&v.jsx(u,{})})}function xt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function jo(e){if(Array.isArray(e))return xt(e)}function $o(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function qr(e,t){if(e){if(typeof e=="string")return xt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xt(e,t)}}function Bo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
9
+ */var wa=s,Ma=Symbol.for("react.element"),Oa=Symbol.for("react.fragment"),Ia=Object.prototype.hasOwnProperty,Ha=wa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Da={key:!0,ref:!0,__self:!0,__source:!0};function Sr(e,t,n){var r,i={},a=null,o=null;n!==void 0&&(a=""+n),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)Ia.call(t,r)&&!Da.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:Ma,type:e,key:a,ref:o,props:i,_owner:Ha.current}}A1.Fragment=Oa,A1.jsx=Sr,A1.jsxs=Sr,Cr.exports=A1;var v=Cr.exports;function br(e){return typeof e=="function"?e():e}function Ta(e,t){return e.length!==t.length?!0:e.some((n,r)=>n!==t[r])}function Ae(e,t,n,r){var S;if(typeof e=="function"&&!r)throw new Error("[useObservable]: expect deps when observable is a function! Otherwise it would cause an infinite loop.");const i=s.useRef(null),a=s.useRef(null),o=s.useRef(r!=null?r:void 0),u=s.useRef(!1),[d,h]=s.useState(0),p=s.useRef((()=>{let _;return e&&br(e).subscribe(U=>{u.current=!0,_=U}).unsubscribe(),_!=null?_:t})()),f=(()=>{if(typeof o.current<"u"){const _=r!=null?r:[];return Ta(o.current,_)?(o.current=_,!0):!1}return i.current!==e})();if((!a.current||f)&&e&&(i.current=br(e),(S=a.current)==null||S.unsubscribe(),a.current=i.current.subscribe(_=>{p.current=_,h(L=>L+1)})),s.useEffect(()=>()=>{var _;(_=a.current)==null||_.unsubscribe(),a.current=null},[]),n&&!u.current)throw new Error("[useObservable]: expect shouldHaveSyncValue but not getting a sync value!");return p.current}function je(e){const{title:t,icon:n,label:r,value:i,value$:a}=e,o=le.useDependency(y.LocaleService),u=le.useDependency(Ke),d=[];let h=0,p=i;a&&(p=Ae(a,void 0,!0));let f;ee.isObservable(n)?f=Ae(n,void 0,!0):f=n;let S=!1;if(p&&typeof p=="string"&&(S=new y.ColorKit(p).isValid),n){const _=u.get(f!=null?f:"");_&&d.push(v.jsx(_,{extend:{colorChannel1:S?p:"rgb(var(--primary-color))"}},h++))}if(r){const _=typeof r=="string",L=_?{...e}:{...r==null?void 0:r.props,...e},U=_?r:r==null?void 0:r.name,H=u.get(U);H?d.push(v.jsx(H,{...L,value:p},h++)):d.push(v.jsx("span",{children:o.t(U)},h++))}return t&&d.push(v.jsx("span",{children:typeof t=="string"?o.t(t):t},h++)),v.jsx(v.Fragment,{children:d})}const yr={uiPluginSheetsFontFamily:"univer-ui-plugin-sheets-font-family",uiPluginSheetsFontFamilyItem:"univer-ui-plugin-sheets-font-family-item"},xa=e=>{const{value:t}=e,n=le.useDependency(y.LocaleService),r=s.useMemo(()=>{var a;let i=n.t(`fontFamily.${((a=`${t}`)!=null?a:"").replace(/\s/g,"")}`);return i.startsWith("fontFamily.")&&typeof t=="string"&&(i=t.split(",")[0]),i},[t]);return v.jsx("div",{className:yr.uiPluginSheetsFontFamily,style:{fontFamily:t},children:r})},Va=e=>{var r;const{value:t}=e,n=le.useDependency(y.LocaleService);return v.jsx("span",{className:yr.uiPluginSheetsFontFamilyItem,style:{fontFamily:t},children:n.t(`fontFamily.${((r=`${t}`)!=null?r:"").replace(/\s/g,"")}`)})},Na=[{value:"Arial"},{value:"Times New Roman"},{value:"Tahoma"},{value:"Verdana"},{value:"Microsoft YaHei"},{value:"SimSun"},{value:"SimHei"},{value:"Kaiti"},{value:"FangSong"},{value:"NSimSun"},{value:"STXinwei"},{value:"STXingkai"},{value:"STLiti"}],_r={uiPluginSheetsFontSize:"univer-ui-plugin-sheets-font-size",uiPluginSheetsFontSizeInput:"univer-ui-plugin-sheets-font-size-input"},ka=e=>{const{value:t,min:n,max:r,onChange:i,disabled$:a}=e,o=Ae(a),[u,d]=s.useState(Number(t!=null?t:0)),h=s.useMemo(()=>Number(t!=null?t:u),[t]);function p(S){S!==null&&d(S)}function f(S){S.stopPropagation(),S.code==="Enter"&&i(u.toString())}return v.jsx("div",{className:_r.uiPluginSheetsFontSize,children:v.jsx(ge.InputNumber,{className:_r.uiPluginSheetsFontSizeInput,value:h,controls:!1,min:n,max:r,onKeyDown:f,onChange:p,disabled:o})})},Aa=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}];var Fe=(e=>(e.VOID="void",e.TOOLBAR_START="uiToolbar.start",e.TOOLBAR_INSERT="uiToolbar.insert",e.TOOLBAR_FORMULAS="uiToolbar.formulas",e.TOOLBAR_DATA="uiToolbar.data",e.TOOLBAR_VIEW="uiToolbar.view",e.TOOLBAR_OTHERS="uiToolbar.others",e.CONTEXT_MENU="contextMenu",e))(Fe||{}),i1=(e=>(e[e.TOOLBAR_HISTORY=0]="TOOLBAR_HISTORY",e[e.TOOLBAR_FORMAT=1]="TOOLBAR_FORMAT",e[e.TOOLBAR_LAYOUT=2]="TOOLBAR_LAYOUT",e[e.TOOLBAR_FORMULAS_INSERT=3]="TOOLBAR_FORMULAS_INSERT",e[e.TOOLBAR_FORMULAS_VIEW=4]="TOOLBAR_FORMULAS_VIEW",e[e.TOOLBAR_FILE=5]="TOOLBAR_FILE",e[e.TOOLBAR_OTHERS=6]="TOOLBAR_OTHERS",e[e.CONTEXT_MENU_FORMAT=7]="CONTEXT_MENU_FORMAT",e[e.CONTEXT_MENU_LAYOUT=8]="CONTEXT_MENU_LAYOUT",e[e.CONTEXT_MENU_DATA=9]="CONTEXT_MENU_DATA",e[e.CONTEXT_MENU_OTHERS=10]="CONTEXT_MENU_OTHERS",e))(i1||{}),$e=(e=>(e[e.BUTTON=0]="BUTTON",e[e.SELECTOR=1]="SELECTOR",e[e.BUTTON_SELECTOR=2]="BUTTON_SELECTOR",e[e.SUBITEMS=3]="SUBITEMS",e))($e||{});function Ra(e,t,n){return window.addEventListener(e,t,n),y.toDisposable(()=>window.removeEventListener(e,t,n))}var Ua=Object.defineProperty,Pa=Object.getOwnPropertyDescriptor,ja=(e,t,n,r)=>{for(var i=r>1?void 0:r?Pa(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ua(t,n,i),i},y1=(e,t)=>(n,r)=>t(n,r,e);class $a{constructor(t){z(this,"_focus",!1);z(this,"_valueLegality",!0);z(this,"_openForSheetUnitId");z(this,"_openForSheetSubUnitId");this._param=t,this._openForSheetUnitId=this._param.openForSheetUnitId,this._openForSheetSubUnitId=this._param.openForSheetSubUnitId}get documentDataModel(){return this._param.documentDataModel}get editorUnitId(){return this._param.editorUnitId}get cancelDefaultResizeListener(){return this._param.cancelDefaultResizeListener}get render(){return this._param.render}isSingleChoice(){return this._param.isSingleChoice}setOpenForSheetUnitId(t){this._openForSheetUnitId=t}getOpenForSheetUnitId(){return this._openForSheetUnitId}setOpenForSheetSubUnitId(t){this._openForSheetSubUnitId=t}getOpenForSheetSubUnitId(){return this._openForSheetSubUnitId}isValueLegality(){return this._valueLegality===!0}setValueLegality(t=!0){this._valueLegality=t}isFocus(){return this._focus}setFocus(t=!1){this._focus=t}isSingle(){return this._param.isSingle===!0||this.onlyInputRange()}isReadOnly(){return this._param.isReadonly===!0}onlyInputContent(){return this._param.onlyInputContent===!0}onlyInputFormula(){return this._param.onlyInputFormula===!0}onlyInputRange(){return this._param.onlyInputRange===!0}getBoundingClientRect(){return this._param.editorDom.getBoundingClientRect()}isVisible(){return this._param.visible}isSheetEditor(){return this._param.isSheetEditor===!0}getValue(){var n;return(((n=this._param.documentDataModel.getBody())==null?void 0:n.dataStream)||"").replace(/\r\n/g,"").replace(/\n/g,"").replace(/\n/g,"")}getBody(){return this._param.documentDataModel.getBody()}update(t){this._param={...this._param,...t}}verticalAlign(){var o,u;const t=(o=this._param)==null?void 0:o.documentDataModel;if(t==null)return;const{width:n,height:r}=this._param.editorDom.getBoundingClientRect();if(!this.isSingle()){t.updateDocumentDataPageSize(n,void 0);return}let i=h1.UNIVER_GLOBAL_DEFAULT_FONT_SIZE;(u=this._param.canvasStyle)!=null&&u.fontSize&&(i=this._param.canvasStyle.fontSize);const a=(r-i*4/3)/2-2;t.updateDocumentDataMargin({t:a<0?0:a}),t.updateDocumentDataPageSize(void 0,void 0)}updateCanvasStyle(){var r;const t=this._param.documentDataModel;if(t==null)return;const n={};(r=this._param.canvasStyle)!=null&&r.fontSize&&(n.textStyle==null&&(n.textStyle={}),n.textStyle.fs=this._param.canvasStyle.fontSize),t.updateDocumentStyle(n)}}E.EditorService=class extends y.Disposable{constructor(n,r,i,a,o){super();z(this,"_editors",new Map);z(this,"_focusEditorUnitId");z(this,"_state$",new ee.Subject);z(this,"state$",this._state$.asObservable());z(this,"_currentSheetUnitId");z(this,"_currentSheetSubUnitId");z(this,"_inputFormula$",new ee.Subject);z(this,"inputFormula$",this._inputFormula$.asObservable());z(this,"_resize$",new ee.Subject);z(this,"resize$",this._resize$.asObservable());z(this,"_closeRangePrompt$",new ee.Subject);z(this,"closeRangePrompt$",this._closeRangePrompt$.asObservable());z(this,"_blur$",new ee.Subject);z(this,"blur$",this._blur$.asObservable());z(this,"_focus$",new ee.Subject);z(this,"focus$",this._focus$.asObservable());z(this,"_setValue$",new ee.Subject);z(this,"setValue$",this._setValue$.asObservable());z(this,"_valueChange$",new ee.Subject);z(this,"valueChange$",this._valueChange$.asObservable());z(this,"_focusStyle$",new ee.Subject);z(this,"focusStyle$",this._focusStyle$.asObservable());z(this,"_singleSelection$",new ee.Subject);z(this,"singleSelection$",this._singleSelection$.asObservable());z(this,"_spreadsheetFocusState",!1);this._injector=n,this._univerInstanceService=r,this._renderManagerService=i,this._lexerTreeBuilder=a,this._contextService=o}setFocusId(n){this._focusEditorUnitId=n}getFocusId(){return this._focusEditorUnitId}getFocusEditor(){if(this._focusEditorUnitId)return this.getEditor(this._focusEditorUnitId)}isEditor(n){return this._editors.has(n)}isSheetEditor(n){const r=this._editors.get(n);return!!(r&&r.isSheetEditor())}closeRangePrompt(){const n=this._univerInstanceService.getCurrentUniverDocInstance();if(!n)return;const r=n.getUnitId();this._contextService.setContextValue(y.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(y.FOCUSING_EDITOR_STANDALONE,!1),!(!this.isEditor(r)||this.isSheetEditor(r))&&(this.changeSpreadsheetFocusState(!1),this.blur())}changeSpreadsheetFocusState(n){this._spreadsheetFocusState=n}getSpreadsheetFocusState(){return this._spreadsheetFocusState}focusStyle(n){const r=this.getEditor(n);if(!r)return!1;r.setFocus(!0),this._contextService.setContextValue(y.EDITOR_ACTIVATED,!0),this._contextService.setContextValue(y.FOCUSING_EDITOR_STANDALONE,!0),this._contextService.setContextValue(y.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE,r.isSingle()),this._spreadsheetFocusState||this.singleSelection(r.isSingleChoice()),this._focusStyle$.next(n),this.setFocusId(n)}singleSelection(n){this._singleSelection$.next(n)}selectionChangingState(){const n=this.getFocusId();if(n==null)return!0;const r=this.getEditor(n);return!r||r.isSheetEditor()?!0:r.onlyInputRange()!==!0&&r.onlyInputFormula()!==!0?(this.blur(),!0):r.onlyInputFormula()===!0&&this._contextService.getContextValue(y.FOCUSING_EDITOR_INPUT_FORMULA)!==!0?(this.blur(),!0):!this.getSpreadsheetFocusState()}blur(){this._spreadsheetFocusState||(this._closeRangePrompt$.next(null),this.singleSelection(!1),this.setFocusId(null),this._contextService.setContextValue(y.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(y.FOCUSING_EDITOR_STANDALONE,!1)),this.getAllEditor().forEach(n=>{n.setFocus(!1)}),this._focusStyle$.next(),this._blur$.next(null)}focus(n){if(n==null){const a=this._univerInstanceService.getCurrentUniverDocInstance();if(!a)return;n=a.getUnitId()}const r=this.getEditor(n);if(r==null)return;this._univerInstanceService.setCurrentUnitForType(n);const i=r.getValue().length;this.focusStyle(n),this._focus$.next({startOffset:i-2,endOffset:i-2})}setFormula(n,r){r==null&&(r=this._getCurrentEditorUnitId()),this._inputFormula$.next({formulaString:n,editorUnitId:r})}setValue(n,r){r==null&&(r=this._getCurrentEditorUnitId()),this.setValueNoRefresh(n,r),this._refreshValueChange(r)}setValueNoRefresh(n,r){this._setValue$.next({body:{dataStream:n},editorUnitId:r}),this.resize(r)}getValue(n){const r=this.getEditor(n);if(r!=null)return r.getValue()}setRichValue(n,r){r==null&&(r=this._getCurrentEditorUnitId()),this._setValue$.next({body:n,editorUnitId:r}),this._refreshValueChange(r)}getRichValue(n){const r=this.getEditor(n);if(r!=null)return r.getBody()}dispose(){this._state$.complete(),this._editors.clear(),super.dispose()}getEditor(n){return n==null&&(n=this._getCurrentEditorUnitId()),this._editors.get(n)}getAllEditor(){return this._editors}getFirstEditor(){return[...this.getAllEditor().values()][0]}resize(n){const r=this.getEditor(n);r!=null&&(r.verticalAlign(),this._resize$.next(n))}isVisible(n){var r;return(r=this.getEditor(n))==null?void 0:r.isVisible()}setOperationSheetUnitId(n){this._currentSheetUnitId=n}getOperationSheetUnitId(){return this._currentSheetUnitId}setOperationSheetSubUnitId(n){this._currentSheetSubUnitId=n}getOperationSheetSubUnitId(){return this._currentSheetSubUnitId}register(n,r){var p,f,S,_;const{initialSnapshot:i,editorUnitId:a,canvasStyle:o={}}=n,u=this._univerInstanceService.createUnit(y.UniverInstanceType.UNIVER_DOC,i||this._getBlank(a));let d=this._renderManagerService.getRenderById(a);d==null&&(this._renderManagerService.create(a),d=this._renderManagerService.getRenderById(a)),d.engine.setContainer(r);const h=new $a({...n,render:d,documentDataModel:u,editorDom:r,canvasStyle:o});return this._editors.set(a,h),(_=(S=(f=(p=d.mainComponent)==null?void 0:p.getScene())==null?void 0:f.getViewports())==null?void 0:S[0].getScrollBar())==null||_.dispose(),h.isSheetEditor()||(h.verticalAlign(),h.updateCanvasStyle()),y.toDisposable(()=>{this._unRegister(a)})}_unRegister(n){const r=this._editors.get(n);if(r==null)return;if(this._renderManagerService.removeRender(n),r.documentDataModel.dispose(),this._editors.delete(n),this._univerInstanceService.disposeUnit(n),this._univerInstanceService.getAllUnitsForType(y.UniverInstanceType.UNIVER_SHEET).length>0){const a=this._univerInstanceService.getCurrentUnitForType(y.UniverInstanceType.UNIVER_SHEET);this._univerInstanceService.focusUnit(a.getUnitId())}}refreshValueChange(n){this._refreshValueChange(n)}checkValueLegality(n){const r=this._editors.get(n);if(r==null)return!0;let i=r.getValue();if(r.setValueLegality(),i=i.replace(/\r\n/g,"").replace(/\n/g,"").replace(/\n/g,""),i.length===0)return!0;if(r.onlyInputFormula()){if(i.substring(0,1)!==n1.operatorToken.EQUALS)return r.setValueLegality(!1),!1;const a=this._lexerTreeBuilder.checkIfAddBracket(i);r.setValueLegality(a===0)}else if(r.onlyInputRange()){const a=i.split(",");if(r.isSingleChoice()&&a.length>1)return r.setValueLegality(!1),!1;r.setValueLegality(n1.isReferenceStrings(i))}return r.isValueLegality()}_refreshValueChange(n){const r=this.getEditor(n);r!=null&&this._valueChange$.next(r)}_getCurrentEditorUnitId(){return this._univerInstanceService.getCurrentUniverDocInstance().getUnitId()}_refresh(n){this._state$.next(n)}_getBlank(n){return{id:n,body:{dataStream:`${y.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{renderConfig:{verticalAlign:y.VerticalAlign.TOP,horizontalAlign:y.HorizontalAlign.LEFT},marginLeft:6,marginTop:2,marginRight:6}}}},E.EditorService=ja([y1(0,se.Inject(se.Injector)),y1(1,y.IUniverInstanceService),y1(2,h1.IRenderManagerService),y1(3,se.Inject(n1.LexerTreeBuilder)),y1(4,y.IContextService)],E.EditorService);const _1=se.createIdentifier("univer.editor.service");var Ba=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Fa=(e,t,n,r)=>{for(var i=r>1?void 0:r?za(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ba(t,n,i),i},R1=(e,t)=>(n,r)=>t(n,r,e);const Za="FOCUSING_UNIVER",Wa=["univer-app-layout","univer-toolbar-btn","univer-menu-item","univer-button","univer-sheet-bar-btn","univer-render-canvas"],L1=se.createIdentifier("ui.layout-service");E.DesktopLayoutService=class extends y.Disposable{constructor(n,r,i,a){super();z(this,"_rootContainerElement",null);z(this,"_isFocused",!1);z(this,"_focusHandlers",new Map);z(this,"_canvasContainers",[]);z(this,"_allContainers",[]);this._contextService=n,this._univerInstanceService=r,this._logService=i,this._editorService=a,this._initUniverFocusListener(),this._initEditorStatus()}get isFocused(){return this._isFocused}focus(){const n=this._univerInstanceService.getFocusedUnit();if(!n)return;let r;n instanceof y.Workbook?r=this._focusHandlers.get(y.UniverInstanceType.UNIVER_SHEET):n instanceof y.DocumentDataModel?r=this._focusHandlers.get(y.UniverInstanceType.UNIVER_DOC):n instanceof y.SlideDataModel&&(r=this._focusHandlers.get(y.UniverInstanceType.UNIVER_SLIDE)),r&&r(n.getUnitId())}registerFocusHandler(n,r){if(this._focusHandlers.has(n))throw new Error(`[DesktopLayoutService]: handler of type ${n} bas been registered!`);return this._focusHandlers.set(n,r),y.toDisposable(()=>this._focusHandlers.delete(n))}registerCanvasElement(n){if(this._canvasContainers.indexOf(n)===-1)return this._canvasContainers.push(n),y.toDisposable(()=>y.remove(this._canvasContainers,n));throw new Error("[DesktopLayoutService]: canvas container already registered!")}registerRootContainerElement(n){if(this._rootContainerElement)throw new Error("[DesktopLayoutService]: root container already registered!");this._rootContainerElement=n;const r=this.registerContainerElement(n);return y.toDisposable(()=>{this._rootContainerElement=null,r.dispose()})}registerContainerElement(n){if(this._allContainers.indexOf(n)===-1)return this._allContainers.push(n),y.toDisposable(()=>y.remove(this._allContainers,n));throw new Error("[LayoutService]: container already registered!")}checkElementInCurrentContainers(n){return this._allContainers.some(r=>r.contains(n))}checkCanvasIsFocused(){return this._canvasContainers.some(n=>n===document.activeElement||n.contains(document.activeElement))}_initUniverFocusListener(){this.disposeWithMe(ee.fromEvent(window,"focusin").subscribe(n=>{const r=n.target;if(Wa.some(i=>r.classList.contains(i))){this._blurSheetEditor(),queueMicrotask(()=>this.focus());return}r&&this.checkElementInCurrentContainers(r)?this._isFocused=!0:this._isFocused=!1,this._contextService.setContextValue(Za,this._isFocused),this._contextService.setContextValue(y.FOCUSING_UNIVER_EDITOR,Lr())}))}_initEditorStatus(){this._contextService.setContextValue(y.FOCUSING_UNIVER_EDITOR,Lr())}_blurSheetEditor(){const n=this._editorService.getFocusEditor();n&&n.isSheetEditor()!==!0&&this._editorService.blur()}},E.DesktopLayoutService=Fa([y.OnLifecycle(y.LifecycleStages.Ready,L1),R1(0,y.IContextService),R1(1,y.IUniverInstanceService),R1(2,y.ILogService),R1(3,_1)],E.DesktopLayoutService);function Lr(){var e;return!!((e=document.activeElement)!=null&&e.classList.contains("univer-editor"))}const Lt=se.createIdentifier("univer.platform-service");class Er{get isMac(){return/Mac/.test(navigator.appVersion)}get isWindows(){return/Windows/.test(navigator.appVersion)}get isLinux(){return/Linux/.test(navigator.appVersion)}}var a1=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.BACKSPACE=8]="BACKSPACE",e[e.TAB=9]="TAB",e[e.ENTER=13]="ENTER",e[e.ESC=27]="ESC",e[e.SPACE=32]="SPACE",e[e.ARROW_LEFT=37]="ARROW_LEFT",e[e.ARROW_UP=38]="ARROW_UP",e[e.ARROW_RIGHT=39]="ARROW_RIGHT",e[e.ARROW_DOWN=40]="ARROW_DOWN",e[e.INSERT=45]="INSERT",e[e.DELETE=46]="DELETE",e[e.Digit0=48]="Digit0",e[e.Digit1=49]="Digit1",e[e.Digit2=50]="Digit2",e[e.Digit3=51]="Digit3",e[e.Digit4=52]="Digit4",e[e.Digit5=53]="Digit5",e[e.Digit6=54]="Digit6",e[e.Digit7=55]="Digit7",e[e.Digit8=56]="Digit8",e[e.Digit9=57]="Digit9",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NUM_LOCK=144]="NUM_LOCK",e[e.SCROLL_LOCK=145]="SCROLL_LOCK",e[e.MINUS=189]="MINUS",e[e.EQUAL=187]="EQUAL",e[e.BACK_SLASH=220]="BACK_SLASH",e))(a1||{});const Ga={8:"Backspace",9:"Tab",13:"Enter",46:"Del",27:"Esc",32:"Space",37:"←",39:"→",38:"↑",40:"↓",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",189:"-",187:"=",220:"\\"};var Re=(e=>(e[e.SHIFT=1024]="SHIFT",e[e.ALT=2048]="ALT",e[e.CTRL_COMMAND=4096]="CTRL_COMMAND",e[e.MAC_CTRL=8192]="MAC_CTRL",e))(Re||{}),Ya=Object.defineProperty,qa=Object.getOwnPropertyDescriptor,Xa=(e,t,n,r)=>{for(var i=r>1?void 0:r?qa(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ya(t,n,i),i},U1=(e,t)=>(n,r)=>t(n,r,e);const m1=se.createIdentifier("univer.shortcut");E.DesktopShortcutService=class extends y.Disposable{constructor(n,r,i,a){super();z(this,"_shortCutMapping",new Map);z(this,"_commandIDMapping",new Map);z(this,"_shortcutChanged$",new ee.Subject);z(this,"shortcutChanged$",this._shortcutChanged$.asObservable());z(this,"_forceEscaped",!1);z(this,"_disable",!1);this._commandService=n,this._platformService=r,this._contextService=i,this._layoutService=a,this.disposeWithMe(Ra("keydown",o=>{this._resolveKeyboardEvent(o)},{capture:!0}))}setDisable(n){this._disable=n}getAllShortcuts(){return Array.from(this._shortCutMapping.values()).map(n=>Array.from(n.values())).flat()}registerShortcut(n){const r=this._getBindingFromItem(n),i=this._shortCutMapping.get(r);i?i.add(n):this._shortCutMapping.set(r,new Set([n]));const a=n.id,o=this._commandIDMapping.get(a);return o?o.add(n):this._commandIDMapping.set(a,new Set([n])),this._emitShortcutChanged(),y.toDisposable(()=>{var u,d,h,p;(u=this._shortCutMapping.get(r))==null||u.delete(n),((d=this._shortCutMapping.get(r))==null?void 0:d.size)===0&&this._shortCutMapping.delete(r),(h=this._commandIDMapping.get(a))==null||h.delete(n),((p=this._commandIDMapping.get(a))==null?void 0:p.size)===0&&this._commandIDMapping.delete(a),this._emitShortcutChanged()})}getShortcutDisplayOfCommand(n){const r=this._commandIDMapping.get(n);return r?this.getShortcutDisplay(r.values().next().value):null}getShortcutDisplay(n){var h;const r=this._getBindingFromItem(n),i=r&Re.CTRL_COMMAND,a=r&Re.SHIFT,o=r&Re.ALT,u=r&Re.MAC_CTRL,d=(h=Ga[r&255])!=null?h:"<->";return this._platformService.isMac?`${i?"⌘":""}${a?"⇧":""}${o?"⌥":""}${u?"⌃":""}${d}`:`${i?"Ctrl+":""}${a?"Shift+":""}${o?"Alt+":""}${d}`}_emitShortcutChanged(){this._shortcutChanged$.next()}forceEscape(){return this._forceEscaped=!0,y.toDisposable(()=>this._forceEscaped=!1)}_resolveKeyboardEvent(n){if(this._forceEscaped||this._disable||this._layoutService&&!this._layoutService.checkElementInCurrentContainers(n.target))return;this._dispatch(n)&&n.preventDefault()}_dispatch(n){const r=this._deriveBindingFromEvent(n);if(r===null)return!1;const i=this._shortCutMapping.get(r);if(i===void 0)return!1;const a=Array.from(i).sort((o,u)=>{var d,h;return((d=u.priority)!=null?d:0)-((h=o.priority)!=null?h:0)}).find(o=>{var u,d;return(d=(u=o.preconditions)==null?void 0:u.call(o,this._contextService))!=null?d:!0});return a?(this._commandService.executeCommand(a.id,a.staticParameters),!0):!1}_getBindingFromItem(n){return this._platformService.isMac&&n.mac?n.mac:this._platformService.isWindows&&n.win?n.win:this._platformService.isLinux&&n.linux?n.linux:n.binding}_deriveBindingFromEvent(n){const{shiftKey:r,metaKey:i,altKey:a,keyCode:o}=n;let u=o;return r&&(u|=Re.SHIFT),a&&(u|=Re.ALT),(this._platformService.isMac?i:n.ctrlKey)&&(u|=Re.CTRL_COMMAND),this._platformService.isMac&&n.ctrlKey&&(u|=Re.MAC_CTRL),u}},E.DesktopShortcutService=Xa([U1(0,y.ICommandService),U1(1,Lt),U1(2,y.IContextService),U1(3,se.Optional(L1))],E.DesktopShortcutService);var Qa=Object.defineProperty,Ja=Object.getOwnPropertyDescriptor,Ka=(e,t,n,r)=>{for(var i=r>1?void 0:r?Ja(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Qa(t,n,i),i},eo=(e,t)=>(n,r)=>t(n,r,e);const s1=se.createIdentifier("univer.menu-service");E.DesktopMenuService=class extends y.Disposable{constructor(n){super();z(this,"_menuItemMap",new Map);z(this,"_menuByPositions",new Map);z(this,"_menuChanged$",new ee.BehaviorSubject(void 0));z(this,"menuChanged$",this._menuChanged$.asObservable());this._shortcutService=n}dispose(){this._menuItemMap.clear(),this._menuChanged$.complete()}addMenuItem(n){if(this._menuItemMap.has(n.id))throw new Error(`Menu item with the same id ${n.id} has already been added!`);return this._menuItemMap.set(n.id,n),Array.isArray(n.positions)?n.positions.forEach(r=>this._appendMenuToPosition(n,r)):this._appendMenuToPosition(n,n.positions),this._menuChanged$.next(),y.toDisposable(()=>{if(this._menuItemMap.delete(n.id),Array.isArray(n.positions))n.positions.forEach(r=>{const i=this._menuByPositions.get(r);if(!i)return;const a=i.findIndex(o=>o[0]===n.id);a>-1&&i.splice(a,1)});else{const r=this._menuByPositions.get(n.positions);if(!r)return;const i=r.findIndex(a=>a[0]===n.id);i>-1&&r.splice(i,1)}this._menuChanged$.next()})}getMenuItems(n){if(this._menuByPositions.has(n)){const r=this._menuByPositions.get(n);if(r)return[...r.values()].map(i=>this._getDisplayMenuItems(i[1]))}return[]}getMenuItem(n){return this._menuItemMap.has(n)?this._menuItemMap.get(n):null}_getDisplayMenuItems(n){const r=this._shortcutService.getShortcutDisplayOfCommand(n.id);return r?{...n,shortcut:r}:n}_appendMenuToPosition(n,r){this._menuByPositions.has(r)||this._menuByPositions.set(r,[]);const i=this._menuByPositions.get(r);if(i.findIndex(a=>a[0]===n.id)>-1)throw new Error(`Menu item with the same id ${n.id} has already been added!`);i.push([n.id,n])}},E.DesktopMenuService=Ka([eo(0,m1)],E.DesktopMenuService);const qe={menuItemNoHover:"univer-menu-item-no-hover",menuItemActivated:"univer-menu-item-activated",menuItemContent:"univer-menu-item-content",menuItemSelectable:"univer-menu-item-selectable",menuItemSelectableIcon:"univer-menu-item-selectable-icon",menuItemMoreIcon:"univer-menu-item-more-icon"};function wr(e){const{menuType:t,onOptionSelect:n}=e,r=le.useDependency(s1);if(!t)return;if(Array.isArray(t)){const o=t.map(u=>r.getMenuItems(u)).map(u=>u.reduce((d,h)=>{var p,f;return h.group?(d[h.group]=(p=d[h.group])!=null?p:[],d[h.group].push(h)):(d[i1.CONTEXT_MENU_OTHERS]=(f=d[i1.CONTEXT_MENU_OTHERS])!=null?f:[],d[i1.CONTEXT_MENU_OTHERS].push(h)),d},{}));return v.jsx(v.Fragment,{children:o.map(u=>Object.keys(u).map(d=>v.jsx(ge.MenuItemGroup,{eventKey:d,children:u[d].map(h=>v.jsx(Or,{menuItem:h,onClick:p=>{n==null||n({value:"",label:h.id,...p})}},h.id))},d)))})}return r.getMenuItems(t).map(a=>v.jsx(Or,{menuItem:a,onClick:o=>{n==null||n({value:"",label:a.id,...o})}},a.id))}function Mr(e){var a;const{options:t,value:n,onOptionSelect:r,parentKey:i}=e;return(a=t==null?void 0:t.map((o,u)=>{var S,_,L;const d=`${i}-${(S=o.label)!=null?S:o.id}-${u}`,h=U=>{r==null||r({value:U,label:o==null?void 0:o.label})},p=()=>{typeof o.value>"u"||r==null||r({...o})},f=Ve({[qe.menuItemNoHover]:typeof o.label!="string"&&!((_=o.label)!=null&&_.hoverable)});return v.jsx(ge.MenuItem,{disabled:o.disabled,eventKey:d,className:f,onClick:p,children:v.jsxs("span",{className:Ve(qe.menuItemContent,{[qe.menuItemSelectable]:!(typeof o.label!="string"&&!((L=o.label)!=null&&L.hoverable))}),children:[typeof n<"u"&&String(n)===String(o.value)&&v.jsx("span",{className:qe.menuItemSelectableIcon,children:v.jsx(ji,{style:{color:"rgb(var(--success-color))"}})}),v.jsx(je,{value$:o.value$,value:o.value,label:o.label,icon:o.icon,onChange:h})]})},d)}))!=null?a:v.jsx(v.Fragment,{})}const P1=e=>v.jsxs(ge.Menu,{selectable:!1,children:[v.jsx(Mr,{...e}),v.jsx(wr,{...e})]});function Or({menuItem:e,onClick:t}){const n=le.useDependency(s1),r=e.id?n.getMenuItems(e.id):[],i=Ae(e.disabled$,!1),a=Ae(e.activated$,!1),o=Ae(e.hidden$,!1),u=Ae(e.value$),[d,h]=s.useState(u),p=L=>{const U=y.isRealNum(L)&&typeof L=="string"?Number.parseInt(L):L;h(U)},f=()=>{const L=e,{title:U,label:H}=L;return v.jsx(ge.MenuItem,{eventKey:L.id,disabled:i,className:Ve({[qe.menuItemActivated]:a}),onClick:()=>{t({value:d,id:L.id})},children:v.jsx("span",{className:qe.menuItemContent,children:v.jsx(je,{value:u,title:U,label:H,icon:L.icon,onChange:p})})},L.id)},S=()=>{var A;const L=e,U=Ae(ee.isObservable(L.selections)?L.selections:void 0),H=(A=U!=null?U:L.selections)!=null?A:[];return H.length>0?v.jsx(ge.SubMenu,{eventKey:L.id,popupOffset:[18,0],title:v.jsxs("span",{className:qe.menuItemContent,children:[v.jsx(je,{title:L.title,value:d,onChange:p,icon:L.icon,label:L.label}),L.shortcut&&` (${L.shortcut})`]}),expandIcon:v.jsx(V3,{className:qe.menuItemMoreIcon}),children:H.length>0&&v.jsx(Mr,{parentKey:L.id,menuType:L.id,options:H,onOptionSelect:k=>{t({value:k.value,id:L.id})}})},L.id):v.jsx(ge.MenuItem,{eventKey:L.id,children:v.jsxs("span",{className:qe.menuItemContent,children:[v.jsx(je,{title:L.title,value:d,icon:L.icon,label:L.label,onChange:p}),L.shortcut&&` (${L.shortcut})`]})},L.id)},_=()=>{const L=e;return v.jsx(ge.SubMenu,{eventKey:L.id,popupOffset:[18,0],title:v.jsx("span",{className:qe.menuItemContent,children:v.jsx(je,{title:L.title,icon:L.icon,label:L.label,onChange:p})}),expandIcon:v.jsx(V3,{className:qe.menuItemMoreIcon}),children:r.length&&v.jsx(wr,{menuType:L.id,parentKey:L.id,onOptionSelect:t})},L.id)};return o?null:v.jsxs(v.Fragment,{children:[e.type===$e.SELECTOR&&S(),e.type===$e.SUBITEMS&&_(),e.type===$e.BUTTON&&f()]})}function to(e,t,...n){return e.t(t)}function no(e){const t=s.useRef(e);return t.current=e,s.useCallback((...n)=>t.current(...n),[])}const Ir="univer.command.copy",Et={id:Ir,name:Ir,multi:!0,priority:0,type:y.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Hr="univer.command.cut",wt={id:Hr,name:Hr,multi:!0,priority:0,type:y.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Dr="univer.command.paste",Mt={id:Dr,name:Dr,multi:!0,priority:0,type:y.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Tr={id:"sheet.operation.set-editor-resize",type:y.CommandType.OPERATION,handler:(e,t)=>!0};function ro(e){const t=e.get(y.IUndoRedoService);return{id:y.UndoCommand.id,group:i1.TOOLBAR_HISTORY,type:$e.BUTTON,icon:"UndoSingle",title:"Undo",tooltip:"toolbar.undo",positions:[Fe.TOOLBAR_START],disabled$:t.undoRedoStatus$.pipe(Cn.map(n=>n.undos<=0))}}function io(e){const t=e.get(y.IUndoRedoService);return{id:y.RedoCommand.id,group:i1.TOOLBAR_HISTORY,type:$e.BUTTON,icon:"RedoSingle",title:"Redo",tooltip:"toolbar.redo",positions:[Fe.TOOLBAR_START],disabled$:t.undoRedoStatus$.pipe(Cn.map(n=>n.redos<=0))}}var ao=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,so=(e,t,n,r)=>{for(var i=r>1?void 0:r?oo(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ao(t,n,i),i},j1=(e,t)=>(n,r)=>t(n,r,e);function $1(e){return e.getContextValue(y.FOCUSING_UNIVER_EDITOR)}const xr={id:Et.id,description:"shortcut.copy",group:"1_common-edit",binding:a1.C|Re.CTRL_COMMAND,preconditions:$1},Vr={id:wt.id,description:"shortcut.cut",group:"1_common-edit",binding:a1.X|Re.CTRL_COMMAND,preconditions:$1},lo={id:Mt.id,description:"shortcut.paste",group:"1_common-edit",binding:a1.V|Re.CTRL_COMMAND,preconditions:()=>!1},Nr={id:y.UndoCommand.id,description:"shortcut.undo",group:"1_common-edit",binding:a1.Z|Re.CTRL_COMMAND,preconditions:$1},kr={id:y.RedoCommand.id,description:"shortcut.redo",group:"1_common-edit",binding:a1.Y|Re.CTRL_COMMAND,preconditions:$1};E.SharedController=class extends y.Disposable{constructor(t,n,r,i){super(),this._injector=t,this._menuService=n,this._shortcutService=r,this._commandService=i,this.initialize()}initialize(){this._registerCommands(),this._registerShortcuts(),this._registerMenus()}_registerMenus(){[ro,io].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))})}_registerCommands(){[wt,Et,Mt,Tr].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t)))}_registerShortcuts(){const t=[Nr,kr];t.push(Vr,xr,lo),t.forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}},E.SharedController=so([y.OnLifecycle(y.LifecycleStages.Ready,E.SharedController),j1(0,se.Inject(se.Injector)),j1(1,s1),j1(2,m1),j1(3,y.ICommandService)],E.SharedController);const B1=se.createIdentifier("univer.ui-controller");var E1={},Ar={exports:{}},Rr={exports:{}};(function(e){function t(n){"@babel/helpers - typeof";return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(Rr);var w1=Rr.exports;(function(e){var t=w1.default;function n(i){if(typeof WeakMap!="function")return null;var a=new WeakMap,o=new WeakMap;return(n=function(d){return d?o:a})(i)}function r(i,a){if(!a&&i&&i.__esModule)return i;if(i===null||t(i)!="object"&&typeof i!="function")return{default:i};var o=n(a);if(o&&o.has(i))return o.get(i);var u={__proto__:null},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var h in i)if(h!=="default"&&{}.hasOwnProperty.call(i,h)){var p=d?Object.getOwnPropertyDescriptor(i,h):null;p&&(p.get||p.set)?Object.defineProperty(u,h,p):u[h]=i[h]}return u.default=i,o&&o.set(i,u),u}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(Ar);var co=Ar.exports,Ur={exports:{}};(function(e){function t(n){return n&&n.__esModule?n:{default:n}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(Ur);var uo=Ur.exports,Pr={exports:{}};(function(e){var t=w1.default;function n(){e.exports=n=function(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var r,i={},a=Object.prototype,o=a.hasOwnProperty,u=Object.defineProperty||function(O,w,D){O[w]=D.value},d=typeof Symbol=="function"?Symbol:{},h=d.iterator||"@@iterator",p=d.asyncIterator||"@@asyncIterator",f=d.toStringTag||"@@toStringTag";function S(O,w,D){return Object.defineProperty(O,w,{value:D,enumerable:!0,configurable:!0,writable:!0}),O[w]}try{S({},"")}catch{S=function(D,Y,W){return D[Y]=W}}function _(O,w,D,Y){var W=w&&w.prototype instanceof G?w:G,X=Object.create(W.prototype),ie=new pe(Y||[]);return u(X,"_invoke",{value:K(O,D,ie)}),X}function L(O,w,D){try{return{type:"normal",arg:O.call(w,D)}}catch(Y){return{type:"throw",arg:Y}}}i.wrap=_;var U="suspendedStart",H="suspendedYield",A="executing",k="completed",F={};function G(){}function M(){}function V(){}var R={};S(R,h,function(){return this});var N=Object.getPrototypeOf,$=N&&N(N(Ee([])));$&&$!==a&&o.call($,h)&&(R=$);var q=V.prototype=G.prototype=Object.create(R);function Z(O){["next","throw","return"].forEach(function(w){S(O,w,function(D){return this._invoke(w,D)})})}function J(O,w){function D(W,X,ie,oe){var Le=L(O[W],O,X);if(Le.type!=="throw"){var xe=Le.arg,Ie=xe.value;return Ie&&t(Ie)=="object"&&o.call(Ie,"__await")?w.resolve(Ie.__await).then(function(we){D("next",we,ie,oe)},function(we){D("throw",we,ie,oe)}):w.resolve(Ie).then(function(we){xe.value=we,ie(xe)},function(we){return D("throw",we,ie,oe)})}oe(Le.arg)}var Y;u(this,"_invoke",{value:function(X,ie){function oe(){return new w(function(Le,xe){D(X,ie,Le,xe)})}return Y=Y?Y.then(oe,oe):oe()}})}function K(O,w,D){var Y=U;return function(W,X){if(Y===A)throw Error("Generator is already running");if(Y===k){if(W==="throw")throw X;return{value:r,done:!0}}for(D.method=W,D.arg=X;;){var ie=D.delegate;if(ie){var oe=me(ie,D);if(oe){if(oe===F)continue;return oe}}if(D.method==="next")D.sent=D._sent=D.arg;else if(D.method==="throw"){if(Y===U)throw Y=k,D.arg;D.dispatchException(D.arg)}else D.method==="return"&&D.abrupt("return",D.arg);Y=A;var Le=L(O,w,D);if(Le.type==="normal"){if(Y=D.done?k:H,Le.arg===F)continue;return{value:Le.arg,done:D.done}}Le.type==="throw"&&(Y=k,D.method="throw",D.arg=Le.arg)}}}function me(O,w){var D=w.method,Y=O.iterator[D];if(Y===r)return w.delegate=null,D==="throw"&&O.iterator.return&&(w.method="return",w.arg=r,me(O,w),w.method==="throw")||D!=="return"&&(w.method="throw",w.arg=new TypeError("The iterator does not provide a '"+D+"' method")),F;var W=L(Y,O.iterator,w.arg);if(W.type==="throw")return w.method="throw",w.arg=W.arg,w.delegate=null,F;var X=W.arg;return X?X.done?(w[O.resultName]=X.value,w.next=O.nextLoc,w.method!=="return"&&(w.method="next",w.arg=r),w.delegate=null,F):X:(w.method="throw",w.arg=new TypeError("iterator result is not an object"),w.delegate=null,F)}function fe(O){var w={tryLoc:O[0]};1 in O&&(w.catchLoc=O[1]),2 in O&&(w.finallyLoc=O[2],w.afterLoc=O[3]),this.tryEntries.push(w)}function ae(O){var w=O.completion||{};w.type="normal",delete w.arg,O.completion=w}function pe(O){this.tryEntries=[{tryLoc:"root"}],O.forEach(fe,this),this.reset(!0)}function Ee(O){if(O||O===""){var w=O[h];if(w)return w.call(O);if(typeof O.next=="function")return O;if(!isNaN(O.length)){var D=-1,Y=function W(){for(;++D<O.length;)if(o.call(O,D))return W.value=O[D],W.done=!1,W;return W.value=r,W.done=!0,W};return Y.next=Y}}throw new TypeError(t(O)+" is not iterable")}return M.prototype=V,u(q,"constructor",{value:V,configurable:!0}),u(V,"constructor",{value:M,configurable:!0}),M.displayName=S(V,f,"GeneratorFunction"),i.isGeneratorFunction=function(O){var w=typeof O=="function"&&O.constructor;return!!w&&(w===M||(w.displayName||w.name)==="GeneratorFunction")},i.mark=function(O){return Object.setPrototypeOf?Object.setPrototypeOf(O,V):(O.__proto__=V,S(O,f,"GeneratorFunction")),O.prototype=Object.create(q),O},i.awrap=function(O){return{__await:O}},Z(J.prototype),S(J.prototype,p,function(){return this}),i.AsyncIterator=J,i.async=function(O,w,D,Y,W){W===void 0&&(W=Promise);var X=new J(_(O,w,D,Y),W);return i.isGeneratorFunction(w)?X:X.next().then(function(ie){return ie.done?ie.value:X.next()})},Z(q),S(q,f,"Generator"),S(q,h,function(){return this}),S(q,"toString",function(){return"[object Generator]"}),i.keys=function(O){var w=Object(O),D=[];for(var Y in w)D.push(Y);return D.reverse(),function W(){for(;D.length;){var X=D.pop();if(X in w)return W.value=X,W.done=!1,W}return W.done=!0,W}},i.values=Ee,pe.prototype={constructor:pe,reset:function(w){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(ae),!w)for(var D in this)D.charAt(0)==="t"&&o.call(this,D)&&!isNaN(+D.slice(1))&&(this[D]=r)},stop:function(){this.done=!0;var w=this.tryEntries[0].completion;if(w.type==="throw")throw w.arg;return this.rval},dispatchException:function(w){if(this.done)throw w;var D=this;function Y(xe,Ie){return ie.type="throw",ie.arg=w,D.next=xe,Ie&&(D.method="next",D.arg=r),!!Ie}for(var W=this.tryEntries.length-1;W>=0;--W){var X=this.tryEntries[W],ie=X.completion;if(X.tryLoc==="root")return Y("end");if(X.tryLoc<=this.prev){var oe=o.call(X,"catchLoc"),Le=o.call(X,"finallyLoc");if(oe&&Le){if(this.prev<X.catchLoc)return Y(X.catchLoc,!0);if(this.prev<X.finallyLoc)return Y(X.finallyLoc)}else if(oe){if(this.prev<X.catchLoc)return Y(X.catchLoc,!0)}else{if(!Le)throw Error("try statement without catch or finally");if(this.prev<X.finallyLoc)return Y(X.finallyLoc)}}}},abrupt:function(w,D){for(var Y=this.tryEntries.length-1;Y>=0;--Y){var W=this.tryEntries[Y];if(W.tryLoc<=this.prev&&o.call(W,"finallyLoc")&&this.prev<W.finallyLoc){var X=W;break}}X&&(w==="break"||w==="continue")&&X.tryLoc<=D&&D<=X.finallyLoc&&(X=null);var ie=X?X.completion:{};return ie.type=w,ie.arg=D,X?(this.method="next",this.next=X.finallyLoc,F):this.complete(ie)},complete:function(w,D){if(w.type==="throw")throw w.arg;return w.type==="break"||w.type==="continue"?this.next=w.arg:w.type==="return"?(this.rval=this.arg=w.arg,this.method="return",this.next="end"):w.type==="normal"&&D&&(this.next=D),F},finish:function(w){for(var D=this.tryEntries.length-1;D>=0;--D){var Y=this.tryEntries[D];if(Y.finallyLoc===w)return this.complete(Y.completion,Y.afterLoc),ae(Y),F}},catch:function(w){for(var D=this.tryEntries.length-1;D>=0;--D){var Y=this.tryEntries[D];if(Y.tryLoc===w){var W=Y.completion;if(W.type==="throw"){var X=W.arg;ae(Y)}return X}}throw Error("illegal catch attempt")},delegateYield:function(w,D,Y){return this.delegate={iterator:Ee(w),resultName:D,nextLoc:Y},this.method==="next"&&(this.arg=r),F}},i}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(Pr);var fo=Pr.exports,jr={exports:{}};(function(e){function t(r,i,a,o,u,d,h){try{var p=r[d](h),f=p.value}catch(S){a(S);return}p.done?i(f):Promise.resolve(f).then(o,u)}function n(r){return function(){var i=this,a=arguments;return new Promise(function(o,u){var d=r.apply(i,a);function h(f){t(d,o,u,h,p,"next",f)}function p(f){t(d,o,u,h,p,"throw",f)}h(void 0)})}}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(jr);var ho=jr.exports,$r={exports:{}},Br={exports:{}},zr={exports:{}},Fr={exports:{}};(function(e){var t=w1.default;function n(r,i){if(t(r)!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var o=a.call(r,i||"default");if(t(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(Fr);var mo=Fr.exports;(function(e){var t=w1.default,n=mo;function r(i){var a=n(i,"string");return t(a)=="symbol"?a:a+""}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(zr);var po=zr.exports;(function(e){var t=po;function n(r,i,a){return i=t(i),i in r?Object.defineProperty(r,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[i]=a,r}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports})(Br);var go=Br.exports;(function(e){var t=go;function n(i,a){var o=Object.keys(i);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(i);a&&(u=u.filter(function(d){return Object.getOwnPropertyDescriptor(i,d).enumerable})),o.push.apply(o,u)}return o}function r(i){for(var a=1;a<arguments.length;a++){var o=arguments[a]!=null?arguments[a]:{};a%2?n(Object(o),!0).forEach(function(u){t(i,u,o[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(u){Object.defineProperty(i,u,Object.getOwnPropertyDescriptor(o,u))})}return i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})($r);var vo=$r.exports,Co=co.default,z1=uo.default;Object.defineProperty(E1,"__esModule",{value:!0}),E1._r=Do,E1._u=No;var So=E1.render=To,bo=E1.unmount=ko,F1=z1(fo),Zr=z1(ho),yo=z1(w1),_o=z1(vo),Lo=Co(yt),M1=(0,_o.default)({},Lo),Eo=M1.version,wo=M1.render,Mo=M1.unmountComponentAtNode,Z1;try{var Oo=Number((Eo||"").split(".")[0]);Oo>=18&&(Z1=M1.createRoot)}catch{}function Wr(e){var t=M1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;t&&(0,yo.default)(t)==="object"&&(t.usingClientEntryPoint=e)}var W1="__rc_react_root__";function Io(e,t){Wr(!0);var n=t[W1]||Z1(t);Wr(!1),n.render(e),t[W1]=n}function Ho(e,t){wo(e,t)}function Do(e,t){}function To(e,t){if(Z1){Io(e,t);return}Ho(e,t)}function xo(e){return Ot.apply(this,arguments)}function Ot(){return Ot=(0,Zr.default)((0,F1.default)().mark(function e(t){return(0,F1.default)().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",Promise.resolve().then(function(){var i;(i=t[W1])===null||i===void 0||i.unmount(),delete t[W1]}));case 1:case"end":return r.stop()}},e)})),Ot.apply(this,arguments)}function Vo(e){Mo(e)}function No(e){}function ko(e){return It.apply(this,arguments)}function It(){return It=(0,Zr.default)((0,F1.default)().mark(function e(t){return(0,F1.default)().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(Z1===void 0){r.next=2;break}return r.abrupt("return",xo(t));case 2:Vo(t);case 3:case"end":return r.stop()}},e)})),It.apply(this,arguments)}const G1=se.createIdentifier("univer.message-service"),r1={appLayout:"univer-app-layout",appContainer:"univer-app-container",appContainerHeader:"univer-app-container-header",appContainerWrapper:"univer-app-container-wrapper",appContainerContent:"univer-app-container-content",appContainerCanvas:"univer-app-container-canvas",appContainerLeftSidebar:"univer-app-container-left-sidebar",appContainerSidebar:"univer-app-container-sidebar"};function p1(e){const{components:t}=e;return t?Array.from(t.values()).map((n,r)=>s.createElement(n(),{key:`${r}`})):null}const Gr={toolbarBtn:"univer-toolbar-btn",toolbarBtnActive:"univer-toolbar-btn-active"};function Yr(e){const{children:t,className:n,style:r,disabled:i=!1,active:a=!1,onClick:o,onDoubleClick:u,...d}=e,h=S=>{if(i){S.preventDefault();return}o&&o(S)},p=S=>{if(i){S.preventDefault();return}u&&u(S)},f=Ve(Gr.toolbarBtn,{[`${Gr.toolbarBtn}-active`]:a},n);return v.jsx("button",{className:f,style:r,disabled:i,onClick:h,onDoubleClick:p,...d,children:t})}const de={headerbar:"univer-headerbar",headerMenu:"univer-header-menu",menubar:"univer-menubar",menubarItem:"univer-menubar-item",menubarItemActive:"univer-menubar-item-active",toolbar:"univer-toolbar",toolbarContainer:"univer-toolbar-container",toolbarMore:"univer-toolbar-more",toolbarMoreContainer:"univer-toolbar-more-container",toolbarGroup:"univer-toolbar-group",toolbarItemSelectButton:"univer-toolbar-item-select-button",toolbarItemSelectButtonDisabled:"univer-toolbar-item-select-button-disabled",toolbarItemSelectButtonActivated:"univer-toolbar-item-select-button-activated",toolbarItemSelectButtonLabel:"univer-toolbar-item-select-button-label",toolbarItemSelectButtonArrow:"univer-toolbar-item-select-button-arrow",toolbarItemSelect:"univer-toolbar-item-select",toolbarItemSelectDisabled:"univer-toolbar-item-select-disabled",toolbarItemSelectActivated:"univer-toolbar-item-select-activated",toolbarItemSelectArrow:"univer-toolbar-item-select-arrow",toolbarItemSelectArrowDisabled:"univer-toolbar-item-select-arrow-disabled",toolbarItemSelectArrowActivated:"univer-toolbar-item-select-arrow-activated"},Ht=s.forwardRef((e,t)=>{const n=le.useDependency(y.LocaleService),r=le.useDependency(y.ICommandService),i=le.useInjector(),[a,o]=s.useState(),[u,d]=s.useState(!1),[h,p]=s.useState(!1),[f,S]=s.useState(!1),[_,L]=s.useState(!1),[U,H]=s.useState(!1),A=(O,w)=>{r.executeCommand(O,w),i.get(h1.ITextSelectionRenderManager).focus()};function k(O){L(O)}function F(O){H(O),O||L(!1)}s.useEffect(()=>{const O=[];return e.disabled$&&O.push(e.disabled$.subscribe(w=>{d(w)})),e.hidden$&&O.push(e.hidden$.subscribe(w=>{S(w)})),e.activated$&&O.push(e.activated$.subscribe(w=>{p(w)})),e.value$&&O.push(e.value$.subscribe(w=>{o(w)})),()=>{O.forEach(w=>{w.unsubscribe()})}},[]);const{tooltip:G,shortcut:M,icon:V,title:R,label:N,id:$}=e,q=n.t(G!=null?G:"")+(M?` (${M})`:""),{selections:Z}=e,J=s.useMemo(()=>ee.isObservable(Z)?Z:new ee.Observable(O=>{O.next(Z)}),[Z]),K=Ae(J),me=s.useMemo(()=>ee.isObservable(V)?V:new ee.Observable(O=>{var D,Y;const w=(Y=(D=K==null?void 0:K.find(W=>W.value===a))==null?void 0:D.icon)!=null?Y:V;O.next(w)}),[V,K,a]),fe=Ae(me,void 0,!0);function ae(O){function w(W){if(u)return;let X=$;const ie=W;W.id&&(X=W.id),A(X,ie)}function D(W){if(u)return;A($,{value:W})}function Y(){u||O===$e.BUTTON_SELECTOR&&A($,{value:a})}return O===$e.BUTTON_SELECTOR?v.jsxs("div",{className:Ve(de.toolbarItemSelectButton,{[de.toolbarItemSelectButtonDisabled]:u,[de.toolbarItemSelectButtonActivated]:h}),"data-disabled":u,children:[v.jsx("div",{className:de.toolbarItemSelectButtonLabel,onClick:Y,children:v.jsx(je,{icon:fe,title:R,value:a,label:N,onChange:D})}),u?v.jsx("div",{className:Ve(de.toolbarItemSelectButtonArrow,{[de.toolbarItemSelectButtonArrowDisabled]:u,[de.toolbarItemSelectButtonArrowActivated]:h}),"data-disabled":u,children:v.jsx(V1,{})}):v.jsx(ge.Dropdown,{overlay:v.jsx(P1,{menuType:$,options:K,onOptionSelect:w,value:a}),onVisibleChange:F,children:v.jsx("div",{className:Ve(de.toolbarItemSelectButtonArrow,{[de.toolbarItemSelectButtonArrowDisabled]:u,[de.toolbarItemSelectButtonArrowActivated]:h}),"data-disabled":u,children:v.jsx(V1,{})})})]}):u?v.jsxs("div",{className:Ve(de.toolbarItemSelect,{[de.toolbarItemSelectDisabled]:u,[de.toolbarItemSelectActivated]:h}),children:[v.jsx(je,{icon:fe,title:R,value:a,label:N,onChange:D}),v.jsx("div",{className:Ve(de.toolbarItemSelectArrow,{[de.toolbarItemSelectArrowDisabled]:u,[de.toolbarItemSelectArrowActivated]:h}),children:v.jsx(V1,{})})]}):v.jsx(ge.Dropdown,{overlay:v.jsx(P1,{menuType:$,options:K,onOptionSelect:w,value:a}),onVisibleChange:F,children:v.jsxs("div",{className:Ve(de.toolbarItemSelect,{[de.toolbarItemSelectDisabled]:u,[de.toolbarItemSelectActivated]:h}),children:[v.jsx(je,{icon:fe,title:R,value:a,label:N,onChange:D}),v.jsx("div",{className:Ve(de.toolbarItemSelectArrow,{[de.toolbarItemSelectArrowDisabled]:u}),children:v.jsx(V1,{})})]})})}function pe(){var D;const w=le.useDependency(Ke).get(typeof N=="string"?N:(D=N==null?void 0:N.name)!=null?D:"");return v.jsx(Yr,{className:de.toolbarItemTextButton,active:h,disabled:u,onClick:()=>A(e.id),onDoubleClick:()=>e.subId&&A(e.subId),children:w?v.jsx(je,{title:R,value:a,label:N}):v.jsx(je,{icon:V})})}function Ee(){switch(e.type){case $e.BUTTON_SELECTOR:case $e.SELECTOR:case $e.SUBITEMS:return ae(e.type);case $e.BUTTON:default:return pe()}}return f?null:v.jsx(ge.Tooltip,{ref:t,visible:U?!1:_,title:q,placement:"bottom",onVisibleChange:k,children:Ee()})}),Ao=[Fe.TOOLBAR_START,Fe.TOOLBAR_INSERT,Fe.TOOLBAR_FORMULAS,Fe.TOOLBAR_DATA,Fe.TOOLBAR_VIEW,Fe.TOOLBAR_OTHERS];function Ro(e){const{headerMenuComponents:t}=e,n=le.useDependency(y.LocaleService),r=le.useDependency(s1),[i,a]=s.useState(Fe.TOOLBAR_START),o=s.useRef(null),u=s.useRef({}),[d,h]=s.useState([]),[p,f]=s.useState([]),[S,_]=s.useState([]);s.useEffect(()=>{var F,G;const H=(G=(F=d.find(M=>M.name===i))==null?void 0:F.menuItems)!=null?G:[],k=ee.combineLatest(H.map(M=>{var V;return(V=M.hidden$)!=null?V:new ee.Observable(R=>R.next(!1))})).pipe(ee.map(M=>H.filter((V,R)=>!M[R]))).subscribe(M=>{_(M)});return()=>{k.unsubscribe()}},[d]),s.useEffect(()=>{const H=r.menuChanged$.subscribe(()=>{const A=[];for(const k of Ao){const F=r.getMenuItems(k);F.length&&A.push({name:k,menuItems:F})}h(A)});return()=>{H.unsubscribe()}},[i]),s.useEffect(()=>{function H(){var R,N;const k=(N=(R=o.current)==null?void 0:R.clientWidth)!=null?N:0,F=8,G=Object.entries(u.current).filter(([$,q])=>q.el&&q.key&&S.find(Z=>Z.id===q.key)).map(([$,q])=>{var Z;return{key:q.key,width:((Z=q.el)==null?void 0:Z.clientWidth)+F}}),M=[];let V=182;for(const $ of G)V+=$.width,V>k&&M.push($.key);f(M)}H();const A=new ResizeObserver(()=>H());return A.observe(document.body),()=>{A.unobserve(document.body)}},[S,d,i]);const L=s.useMemo(()=>{var H,A;return(A=(H=d.find(k=>k.name===i))==null?void 0:H.menuItems.reduce((k,F)=>{var M;const G=(M=F.group)!=null?M:i1.TOOLBAR_OTHERS;return k[G]||(k[G]=[]),k[G].push(F),k},{}))!=null?A:{}},[d]),U=s.useMemo(()=>t&&t.size>0||d.length>1,[t,d]);return v.jsxs(v.Fragment,{children:[U?v.jsxs("header",{className:de.headerbar,children:[v.jsx("div",{className:de.menubar,children:d.length>1&&d.map((H,A)=>v.jsx("a",{className:Ve(de.menubarItem,{[de.menubarItemActive]:H.name===i}),onClick:()=>{a(H.name)},children:n.t(H.name)},A))}),v.jsx("div",{className:de.headerMenu,children:v.jsx(p1,{components:t})})]}):null,v.jsx("div",{ref:o,className:de.toolbar,children:v.jsxs("div",{className:de.toolbarContainer,children:[Object.entries(L).filter(([H,A])=>A.filter(F=>!p.includes(F.id)).length).map(([H,A])=>v.jsx("div",{className:de.toolbarGroup,children:A.map(k=>!p.includes(k.id)&&v.jsx(Ht,{...k},k.id))},H)),p.length>0&&v.jsx(ge.Tooltip,{title:n.t("more"),placement:"bottom",children:v.jsx(ge.Dropdown,{forceRender:!0,className:de.toolbarMore,overlay:v.jsx("div",{className:de.toolbarMoreContainer,onClick:H=>H.stopPropagation(),children:Object.entries(L).map(([H,A])=>v.jsx("div",{className:de.toolbarGroup,children:A.map(k=>p.includes(k.id)&&v.jsx(Ht,{...k},k.id))},H))}),children:v.jsx(Yr,{className:de.toolbarItemTextButton,children:v.jsx(j2,{})})})})]})}),v.jsx("div",{className:de.toolbarContainer,style:{position:"absolute",top:-9999,left:-9999,opacity:0},children:Object.entries(L).map(([H,A])=>v.jsx("div",{className:de.toolbarGroup,children:A.map(k=>v.jsx(Ht,{ref:F=>{u.current[k.id]={el:F==null?void 0:F.nativeElement,key:k.id}},...k},k.id))},H))})]})}const Y1=se.createIdentifier("univer.sidebar-service"),l1={sidebar:"univer-sidebar",sidebarOpen:"univer-sidebar-open",sidebarContainer:"univer-sidebar-container",sidebarHeader:"univer-sidebar-header",sidebarHeaderClose:"univer-sidebar-header-close",sidebarBody:"univer-sidebar-body",sidebarFooter:"univer-sidebar-footer"};function Uo(){const e=le.useDependency(Y1),[t,n]=s.useState({});s.useEffect(()=>{const u=e.sidebarOptions$.subscribe(d=>{n(d)});return()=>{u.unsubscribe()}},[]);const r=t;for(const u of["children","header","footer"]){const d=u;if(t[d]){const h=t[d];h&&(r[d]=v.jsx(je,{...h}))}}const i=Ve(l1.sidebar,{[l1.sidebarOpen]:r.visible}),a=s.useMemo(()=>r.visible?typeof r.width=="number"?`${r.width}px`:r.width:0,[r]);function o(){var d;const u={...t,visible:!1};n(u),e.sidebarOptions$.next(u),(d=u==null?void 0:u.onClose)==null||d.call(u)}return v.jsx("section",{className:i,style:{width:a},children:v.jsxs("section",{className:l1.sidebarContainer,children:[v.jsxs("header",{className:l1.sidebarHeader,children:[r==null?void 0:r.header,v.jsx("a",{className:l1.sidebarHeaderClose,onClick:o,children:v.jsx(_t,{})})]}),v.jsx("section",{className:l1.sidebarBody,children:r==null?void 0:r.children}),(r==null?void 0:r.footer)&&v.jsx("footer",{className:l1.sidebarFooter,children:r.footer})]})})}const Dt=se.createIdentifier("univer.zen-zone-service"),Tt={zenZone:"univer-zen-zone",zenZoneOpen:"univer-zen-zone-open",zenZoneClose:"univer-zen-zone-close"};function Po(){const e=le.useDependency(Dt),[t,n]=s.useState(!1),[r,i]=s.useState(),a=le.useDependency(Ke);s.useEffect(()=>{const d=[e.visible$.subscribe(h=>{n(h)}),e.componentKey$.subscribe(h=>{i(h)})];return()=>{d.forEach(h=>{h.unsubscribe()})}},[]);const o=Ve(Tt.zenZone,t?Tt.zenZoneOpen:Tt.zenZoneClose),u=s.useMemo(()=>{const d=a.get(r!=null?r:"");if(d)return d},[r]);return v.jsx("section",{className:o,children:u&&v.jsx(u,{})})}function xt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function jo(e){if(Array.isArray(e))return xt(e)}function $o(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function qr(e,t){if(e){if(typeof e=="string")return xt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xt(e,t)}}function Bo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
10
10
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function O1(e){return jo(e)||$o(e)||qr(e)||Bo()}function zo(e){if(Array.isArray(e))return e}function Fo(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,u=[],d=!0,h=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;d=!1}else for(;!(d=(r=a.call(n)).done)&&(u.push(r.value),u.length!==t);d=!0);}catch(p){h=!0,i=p}finally{try{if(!d&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(h)throw i}}return u}}function Zo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
11
11
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ne(e,t){return zo(e)||Fo(e,t)||qr(e,t)||Zo()}function Wo(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function q1(e,t){if(e==null)return{};var n=Wo(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Ze(e){"@babel/helpers - typeof";return Ze=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ze(e)}function Go(e,t){if(Ze(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Ze(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Xr(e){var t=Go(e,"string");return Ze(t)=="symbol"?t:t+""}function Te(e,t,n){return t=Xr(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ce(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Qr(Object(n),!0).forEach(function(r){Te(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qr(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function c1(){return c1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c1.apply(this,arguments)}var Jr={exports:{}};/*!
12
12
  Copyright (c) 2018 Jed Watson.
@@ -37,13 +37,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37
37
  onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel
38
38
  onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
39
39
  onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
40
- onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`,w9="".concat(L9," ").concat(E9).split(/[\s\n]+/),M9="aria-",O9="data-";function w6(e,t){return e.indexOf(t)===0}function I9(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n;t===!1?n={aria:!0,data:!0,attr:!0}:t===!0?n={aria:!0}:n=Ce({},t);var r={};return Object.keys(e).forEach(function(i){(n.aria&&(i==="role"||w6(i,M9))||n.data&&w6(i,O9)||n.attr&&w9.includes(i))&&(r[i]=e[i])}),r}var H9=ne.forwardRef(function(e,t){var n=e.prefixCls,r=e.style,i=e.className,a=e.duration,o=a===void 0?4.5:a,u=e.eventKey,d=e.content,h=e.closable,p=e.closeIcon,f=p===void 0?"x":p,S=e.props,_=e.onClick,L=e.onNoticeClose,U=e.times,H=e.hovering,A=ne.useState(!1),k=Ne(A,2),F=k[0],G=k[1],M=H||F,V=function(){L(u)},R=function(J){(J.key==="Enter"||J.code==="Enter"||J.keyCode===te.ENTER)&&V()};ne.useEffect(function(){if(!M&&o>0){var Z=setTimeout(function(){V()},o*1e3);return function(){clearTimeout(Z)}}},[o,M,U]);var N=ne.useMemo(function(){return Ze(h)==="object"&&h!==null?h:h?{closeIcon:f}:{}},[h,f]),$=I9(N,!0),q="".concat(n,"-notice");return ne.createElement("div",c1({},S,{ref:t,className:I1(q,i,Te({},"".concat(q,"-closable"),h)),style:r,onMouseEnter:function(J){var K;G(!0),S==null||(K=S.onMouseEnter)===null||K===void 0||K.call(S,J)},onMouseLeave:function(J){var K;G(!1),S==null||(K=S.onMouseLeave)===null||K===void 0||K.call(S,J)},onClick:_}),ne.createElement("div",{className:"".concat(q,"-content")},d),h&&ne.createElement("a",c1({tabIndex:0,className:"".concat(q,"-close"),onKeyDown:R,"aria-label":"Close"},$,{onClick:function(J){J.preventDefault(),J.stopPropagation(),V()}}),N.closeIcon))}),D9=s.createContext({}),M6=8,O6=3,I6=16,T9=function(t){var n={offset:M6,threshold:O6,gap:I6};if(t&&Ze(t)==="object"){var r,i,a;n.offset=(r=t.offset)!==null&&r!==void 0?r:M6,n.threshold=(i=t.threshold)!==null&&i!==void 0?i:O6,n.gap=(a=t.gap)!==null&&a!==void 0?a:I6}return[!!t,n]},x9=["className","style","classNames","styles"],V9=function(t){var n=t.configList,r=t.placement,i=t.prefixCls,a=t.className,o=t.style,u=t.motion,d=t.onAllNoticeRemoved,h=t.onNoticeClose,p=t.stack,f=s.useContext(D9),S=f.classNames,_=s.useRef({}),L=s.useState(null),U=Ne(L,2),H=U[0],A=U[1],k=s.useState([]),F=Ne(k,2),G=F[0],M=F[1],V=n.map(function(ae){return{config:ae,key:String(ae.key)}}),R=T9(p),N=Ne(R,2),$=N[0],q=N[1],Z=q.offset,J=q.threshold,K=q.gap,me=$&&(G.length>0||V.length<=J),fe=typeof u=="function"?u(r):u;return s.useEffect(function(){$&&G.length>1&&M(function(ae){return ae.filter(function(pe){return V.some(function(Ee){var O=Ee.key;return pe===O})})})},[G,V,$]),s.useEffect(function(){var ae;if($&&_.current[(ae=V[V.length-1])===null||ae===void 0?void 0:ae.key]){var pe;A(_.current[(pe=V[V.length-1])===null||pe===void 0?void 0:pe.key])}},[V,$]),s.createElement(_9,c1({key:r,className:I1(i,"".concat(i,"-").concat(r),S==null?void 0:S.list,a,Te(Te({},"".concat(i,"-stack"),!!$),"".concat(i,"-stack-expanded"),me)),style:o,keys:V,motionAppear:!0},fe,{onAllRemoved:function(){d(r)}}),function(ae,pe){var Ee=ae.config,O=ae.className,w=ae.style,D=ae.index,Y=Ee,W=Y.key,X=Y.times,ie=String(W),oe=Ee,Le=oe.className,xe=oe.style,Ie=oe.classNames,we=oe.styles,Je=q1(oe,x9),Ge=V.findIndex(function(d1){return d1.key===ie}),Be={};if($){var ce=V.length-1-(Ge>-1?Ge:D-1),re=r==="top"||r==="bottom"?"-50%":"0";if(ce>0){var ye,Ue,He;Be.height=me?(ye=_.current[ie])===null||ye===void 0?void 0:ye.offsetHeight:H==null?void 0:H.offsetHeight;for(var Me=0,he=0;he<ce;he++){var ve;Me+=((ve=_.current[V[V.length-1-he].key])===null||ve===void 0?void 0:ve.offsetHeight)+K}var Pe=(me?Me:ce*Z)*(r.startsWith("top")?1:-1),e1=!me&&H!==null&&H!==void 0&&H.offsetWidth&&(Ue=_.current[ie])!==null&&Ue!==void 0&&Ue.offsetWidth?((H==null?void 0:H.offsetWidth)-Z*2*(ce<3?ce:3))/((He=_.current[ie])===null||He===void 0?void 0:He.offsetWidth):1;Be.transform="translate3d(".concat(re,", ").concat(Pe,"px, 0) scaleX(").concat(e1,")")}else Be.transform="translate3d(".concat(re,", 0, 0)")}return s.createElement("div",{ref:pe,className:I1("".concat(i,"-notice-wrapper"),O,Ie==null?void 0:Ie.wrapper),style:Ce(Ce(Ce({},w),Be),we==null?void 0:we.wrapper),onMouseEnter:function(){return M(function(t1){return t1.includes(ie)?t1:[].concat(O1(t1),[ie])})},onMouseLeave:function(){return M(function(t1){return t1.filter(function(St){return St!==ie})})}},s.createElement(H9,c1({},Je,{ref:function(t1){Ge>-1?_.current[ie]=t1:delete _.current[ie]},prefixCls:i,classNames:Ie,styles:we,className:I1(Le,S==null?void 0:S.notice),style:xe,times:X,key:W,eventKey:W,onNoticeClose:h,hovering:$&&G.length>0})))})},N9=ne.forwardRef(function(e,t){var n=e.prefixCls,r=n===void 0?"rc-notification":n,i=e.container,a=e.motion,o=e.maxCount,u=e.className,d=e.style,h=e.onAllRemoved,p=e.stack,f=e.renderNotifications,S=ne.useState([]),_=Ne(S,2),L=_[0],U=_[1],H=function($){var q,Z=L.find(function(J){return J.key===$});Z==null||(q=Z.onClose)===null||q===void 0||q.call(Z),U(function(J){return J.filter(function(K){return K.key!==$})})};ne.useImperativeHandle(t,function(){return{open:function($){U(function(q){var Z=O1(q),J=Z.findIndex(function(fe){return fe.key===$.key}),K=Ce({},$);if(J>=0){var me;K.times=(((me=q[J])===null||me===void 0?void 0:me.times)||0)+1,Z[J]=K}else K.times=0,Z.push(K);return o>0&&Z.length>o&&(Z=Z.slice(-o)),Z})},close:function($){H($)},destroy:function(){U([])}}});var A=ne.useState({}),k=Ne(A,2),F=k[0],G=k[1];ne.useEffect(function(){var N={};L.forEach(function($){var q=$.placement,Z=q===void 0?"topRight":q;Z&&(N[Z]=N[Z]||[],N[Z].push($))}),Object.keys(F).forEach(function($){N[$]=N[$]||[]}),G(N)},[L]);var M=function($){G(function(q){var Z=Ce({},q),J=Z[$]||[];return J.length||delete Z[$],Z})},V=ne.useRef(!1);if(ne.useEffect(function(){Object.keys(F).length>0?V.current=!0:V.current&&(h==null||h(),V.current=!1)},[F]),!i)return null;var R=Object.keys(F);return yt.createPortal(ne.createElement(ne.Fragment,null,R.map(function(N){var $=F[N],q=ne.createElement(V9,{key:N,configList:$,placement:N,prefixCls:r,className:u==null?void 0:u(N),style:d==null?void 0:d(N),motion:a,onNoticeClose:H,onAllNoticeRemoved:M,stack:p});return f?f(q,{prefixCls:r,key:N}):q})),i)}),k9=["getContainer","motion","prefixCls","maxCount","className","style","onAllRemoved","stack","renderNotifications"],A9=function(){return document.body},H6=0;function R9(){for(var e={},t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach(function(i){i&&Object.keys(i).forEach(function(a){var o=i[a];o!==void 0&&(e[a]=o)})}),e}function U9(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.getContainer,n=t===void 0?A9:t,r=e.motion,i=e.prefixCls,a=e.maxCount,o=e.className,u=e.style,d=e.onAllRemoved,h=e.stack,p=e.renderNotifications,f=q1(e,k9),S=ne.useState(),_=Ne(S,2),L=_[0],U=_[1],H=ne.useRef(),A=ne.createElement(N9,{container:L,ref:H,prefixCls:i,motion:r,maxCount:a,className:o,style:u,onAllRemoved:d,stack:h,renderNotifications:p}),k=ne.useState([]),F=Ne(k,2),G=F[0],M=F[1],V=ne.useMemo(function(){return{open:function(N){var $=R9(f,N);($.key===null||$.key===void 0)&&($.key="rc-notification-".concat(H6),H6+=1),M(function(q){return[].concat(O1(q),[{type:"open",config:$}])})},close:function(N){M(function($){return[].concat(O1($),[{type:"close",key:N}])})},destroy:function(){M(function(N){return[].concat(O1(N),[{type:"destroy"}])})}}},[]);return ne.useEffect(function(){U(n())}),ne.useEffect(function(){H.current&&G.length&&(G.forEach(function(R){switch(R.type){case"open":H.current.open(R.config);break;case"close":H.current.close(R.key);break;case"destroy":H.current.destroy();break}}),M(function(R){return R.filter(function(N){return!G.includes(N)})}))},[G]),[V,A]}const Qe={notification:"univer-notification",notificationNotice:"univer-notification-notice",notificationNoticeWrapper:"univer-notification-notice-wrapper",notificationNoticeContent:"univer-notification-notice-content",notificationNoticeClose:"univer-notification-notice-close",notificationIcon:"univer-notification-icon",notificationIconSuccess:"univer-notification-icon-success",notificationIconInfo:"univer-notification-icon-info",notificationIconWarning:"univer-notification-icon-warning",notificationIconError:"univer-notification-icon-error",notificationContentContainer:"univer-notification-content-container",notificationTitle:"univer-notification-title",notificationContent:"univer-notification-content",notificationContentEllipsis:"univer-notification-content-ellipsis",notificationTop:"univer-notification-top",notificationTopLeft:"univer-notification-topLeft",notificationTopRight:"univer-notification-topRight",notificationBottom:"univer-notification-bottom",notificationBottomRight:"univer-notification-bottomRight",notificationBottomLeft:"univer-notification-bottomLeft",notificationFade:"univer-notification-fade",notificationFadeAppearPrepare:"univer-notification-fade-appear-prepare",notificationFadeAppearStart:"univer-notification-fade-appear-start",notificationFadeAppearActive:"univer-notification-fade-appear-active",notificationFadeAppear:"univer-notification-fade-appear",notificationFadeEnter:"univer-notification-fade-enter",notificationFadeLeave:"univer-notification-fade-leave",notificationFadeEnterActive:"univer-notification-fade-enter-active",notificationFadeIn:"univer-notification-fade-in",notificationFadeLeaveActive:"univer-notification-fade-leave-active",notificationFadeOut:"univer-notification-fade-out"},P9={success:v.jsx(fa,{className:Qe.notificationIconSuccess}),info:v.jsx(mr,{className:Qe.notificationIconInfo}),warning:v.jsx(mr,{className:Qe.notificationIconWarning}),error:v.jsx(i2,{className:Qe.notificationIconError})},D6=new ee.Subject,j9=e=>{const{type:t,content:n,title:r,lines:i=0}=e,a=Ve(Qe.notificationContent,{[Qe.notificationContentEllipsis]:i!==0});return v.jsxs(v.Fragment,{children:[v.jsx("span",{className:Qe.notificationIcon,children:P9[t]}),v.jsxs("div",{className:Qe.notificationContentContainer,children:[v.jsx("span",{className:Qe.notificationTitle,children:r}),v.jsx("span",{className:a,style:{WebkitLineClamp:i},children:n})]})]})};function $9(){const{mountContainer:e}=s.useContext(ge.ConfigContext);if(!e)return v.jsx(v.Fragment,{});const[t,n]=U9({prefixCls:Qe.notification,maxCount:3,closeIcon:v.jsx(_t,{}),getContainer:()=>e,motion:{motionName:Qe.notificationFade,motionAppear:!0,motionEnter:!0,motionLeave:!0}}),r=s.useRef(D6);return s.useEffect(()=>{const i=r.current.subscribe(a=>{var o,u,d;t.open({content:v.jsx(j9,{content:a.content,type:a.type,title:a.title,lines:a.lines}),placement:(o=a.placement)!=null?o:"topRight",duration:(u=a.duration)!=null?u:4.5,closable:(d=a.closable)!=null?d:!0})});return()=>{i.unsubscribe()}},[]),v.jsx(v.Fragment,{children:n})}const B9={show:e=>{D6.next(e)}},Gt=se.createIdentifier("univer.confirm-service");function z9(){const e=le.useDependency(Gt),[t,n]=s.useState([]);s.useEffect(()=>{const i=e.confirmOptions$.subscribe(a=>{n(a)});return()=>{i.unsubscribe()}},[]);const r=t.map(i=>{const{children:a,title:o,...u}=i,d=u;for(const h of["children","title"]){const p=h,f=i[p];f&&(d[p]=v.jsx(je,{...f}))}return d});return r==null?void 0:r.map((i,a)=>v.jsx(ge.Confirm,{...i},a))}const Yt=se.createIdentifier("univer.context-menu-service");class T6 extends y.Disposable{constructor(){super(...arguments);z(this,"_currentHandler",null);z(this,"disabled",!1)}disable(){this.disabled=!0}enable(){this.disabled=!1}triggerContextMenu(n,r){var i;n.stopPropagation(),!this.disabled&&((i=this._currentHandler)==null||i.handleContextMenu(n,r))}registerContextMenuHandler(n){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=n,y.toDisposable(()=>{this._currentHandler=null})}}function F9(){const[e,t]=s.useState(!1),[n,r]=s.useState(""),[i,a]=s.useState([0,0]),o=le.useDependency(Yt),u=le.useDependency(y.ICommandService),d=le.useInjector();s.useEffect(()=>{const f=o.registerContextMenuHandler({handleContextMenu:h});return document.addEventListener("pointerdown",p),document.addEventListener("wheel",p),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("wheel",p),f.dispose()}},[]);function h(f,S){r(S),a([f.clientX,f.clientY]),t(!0)}function p(){t(!1)}return v.jsx(ge.Popup,{visible:e,offset:i,children:v.jsx("section",{onPointerDown:f=>f.stopPropagation(),children:n&&v.jsx(P1,{menuType:[n],onOptionSelect:f=>{const{label:S,value:_}=f;u&&u.executeCommand(S,{value:_}),d.get(h1.ITextSelectionRenderManager).focus(),t(!1)}})})})}const qt=se.createIdentifier("univer.ui.dialog-service");function Z9(){const e=le.useDependency(qt),[t,n]=s.useState([]);s.useEffect(()=>{const a=e.getObservableDialog().subscribe(o=>{n(o)});return()=>{a.unsubscribe()}},[e]);const r=t.map(i=>{const{children:a,title:o,closeIcon:u,footer:d,...h}=i,p=h;for(const f of["children","title","closeIcon","footer"]){const S=f,_=i[S];_&&(p[S]=v.jsx(je,{..._}))}return p});return v.jsx(v.Fragment,{children:r==null?void 0:r.map(i=>v.jsx(ge.Dialog,{...i},i.id))})}const Xt=se.createIdentifier("univer.global-zone-service"),x6={globalZone:"univer-global-zone",globalZoneOpen:"univer-global-zone-open",globalZoneClose:"univer-global-zone-close"};function W9(){const e=le.useDependency(Xt),[t,n]=s.useState(!1),r=Ae(e.componentKey$),i=le.useDependency(Ke),a=Ve(x6.globalZone,x6.globalZoneOpen),o=s.useMemo(()=>{const u=i.get(r!=null?r:"");if(u)return u},[r]);return s.useEffect(()=>{const u=e.visible$.subscribe(d=>{n(d)});return()=>{u.unsubscribe()}},[e.visible$]),t?v.jsx("section",{className:a,children:o&&v.jsx(o,{})}):null}const G9=new Set([()=>Z9,()=>z9,()=>$9,()=>F9,()=>W9]),Qt=se.createIdentifier("univer.popup.service");class V6{constructor(){z(this,"_popupMap",new Map);z(this,"_popups$",new ee.BehaviorSubject([]));z(this,"popups$",this._popups$.asObservable())}get popups(){return Array.from(this._popupMap.entries())}_notice(){this._popups$.next(Array.from(this._popupMap.entries()))}addPopup(t){const n=y.Tools.generateRandomId();return this._popupMap.set(n,t),this._notice(),n}removePopup(t){this._popupMap.delete(t)&&this._notice()}removeAll(){this._popupMap.clear(),this._notice()}}const Y9=({popup:e,children:t})=>{const n=Ae(e.anchorRect$,e.anchorRect),r=s.useMemo(()=>{var o;const[i=0,a=0]=(o=e.offset)!=null?o:[];return{left:n.left-i,right:n.right+i,top:n.top-a,bottom:n.bottom+a}},[n.bottom,n.left,n.right,n.top,e.offset]);return v.jsx(ge.RectPopup,{anchorRect:r,direction:e.direction,onClickOutside:e.onClickOutside,excludeOutside:e.excludeOutside,closeOnSelfTarget:e.closeOnSelfTarget,children:t})};function q9(){const e=le.useDependency(Qt),t=Ae(e.popups$,void 0,!0),n=le.useDependency(Ke);return t.map(r=>{const[i,a]=r,o=n.get(a.componentKey);return v.jsx(Y9,{popup:a,children:o?v.jsx(o,{popup:a}):null},i)})}function X9(e){const{header:t,footer:n,mountContainer:r,headerComponents:i,headerMenuComponents:a,contentComponents:o,footerComponents:u,leftSidebarComponents:d,onRendered:h}=e,p=le.useDependency(y.LocaleService),f=le.useDependency(y.ThemeService),S=le.useDependency(G1),_=s.useRef(null);s.useEffect(()=>{f.getCurrentTheme()||f.setTheme(ge.defaultTheme)},[]),s.useEffect(()=>{_.current&&(h==null||h(_.current))},[h]);const[L,U]=s.useState(p.getLocales()),H=s.useMemo(()=>document.createElement("div"),[]);return s.useEffect(()=>{document.body.appendChild(H),S.setContainer(H);const A=[p.localeChanged$.subscribe(()=>{U(p.getLocales())}),f.currentTheme$.subscribe(k=>{ge.themeInstance.setTheme(r,k),H&&ge.themeInstance.setTheme(H,k)})];return()=>{A.forEach(k=>k.unsubscribe()),document.body.removeChild(H)}},[p,S,r,H,f.currentTheme$]),v.jsxs(ge.ConfigProvider,{locale:L,mountContainer:H,children:[v.jsxs("div",{className:r1.appLayout,tabIndex:-1,onBlur:A=>A.stopPropagation(),children:[t&&v.jsx("header",{className:r1.appContainerHeader,children:v.jsx(Ro,{headerMenuComponents:a})}),v.jsxs("section",{className:r1.appContainer,children:[v.jsxs("div",{className:r1.appContainerWrapper,children:[v.jsx("aside",{className:r1.appContainerLeftSidebar,children:v.jsx(p1,{components:d})}),v.jsxs("section",{className:r1.appContainerContent,children:[v.jsx("header",{children:t&&v.jsx(p1,{components:i})}),v.jsx("section",{className:r1.appContainerCanvas,ref:_,"data-range-selector":!0,onContextMenu:A=>A.preventDefault(),children:v.jsx(p1,{components:o})})]}),v.jsx("aside",{className:r1.appContainerSidebar,children:v.jsx(Uo,{})})]}),n&&v.jsx("footer",{className:r1.appFooter,children:v.jsx(p1,{components:u})}),v.jsx(Po,{})]}),v.jsx(q9,{})]}),v.jsx(p1,{components:G9})]})}var Q9=Object.defineProperty,J9=Object.getOwnPropertyDescriptor,K9=(e,t,n,r)=>{for(var i=r>1?void 0:r?J9(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Q9(t,n,i),i},H1=(e,t)=>(n,r)=>t(n,r,e),N6=(e=>(e.HEADER="header",e.HEADER_MENU="header-menu",e.CONTENT="content",e.FOOTER="footer",e.LEFT_SIDEBAR="left-sidebar",e))(N6||{});const e4=3e3;E.DesktopUIController=class extends y.Disposable{constructor(n,r,i,a,o){super();z(this,"_componentsByPart",new Map);z(this,"_componentRegistered$",new ee.Subject);z(this,"componentRegistered$",this._componentRegistered$.asObservable());this._instanceService=n,this._renderManagerService=r,this._injector=i,this._lifecycleService=a,this._layoutService=o}bootstrapWorkbench(n){this.disposeWithMe(t4(this._injector,n,(r,i)=>{this._layoutService&&(this.disposeWithMe(this._layoutService.registerRootContainerElement(i)),this.disposeWithMe(this._layoutService.registerCanvasElement(r))),this._renderManagerService.currentRender$.subscribe(a=>{if(a){const o=this._renderManagerService.getRenderById(a);if(!o.unitId||this._instanceService.getUnitType(o.unitId)!==y.UniverInstanceType.UNIVER_SHEET)return;o.engine.setContainer(r)}}),this._lifecycleService.lifecycle$.pipe(ee.filter(a=>a===y.LifecycleStages.Ready),ee.delay(300),ee.take(1)).subscribe(()=>{var o;const a=(o=this._renderManagerService.getFirst())==null?void 0:o.engine;a==null||a.setContainer(r),this._lifecycleService.stage=y.LifecycleStages.Rendered,setTimeout(()=>this._lifecycleService.stage=y.LifecycleStages.Steady,e4)})}))}registerComponent(n,r){const i=(this._componentsByPart.get(n)||this._componentsByPart.set(n,new Set).get(n)).add(r);return this._componentRegistered$.next(),y.toDisposable(()=>{i.delete(r),i.size===0&&this._componentsByPart.delete(n)})}getComponents(n){return new Set([...this._componentsByPart.get(n)||new Set])}},E.DesktopUIController=K9([H1(0,y.IUniverInstanceService),H1(1,h1.IRenderManagerService),H1(2,se.Inject(se.Injector)),H1(3,se.Inject(y.LifecycleService)),H1(4,se.Optional(L1))],E.DesktopUIController);function t4(e,t,n){let r;const i=t.container;if(typeof i=="string"){const p=document.getElementById(i);p?r=p:r=k6(i)}else i instanceof HTMLElement?r=i:r=k6("univer");const a=le.connectInjector(X9,e),o=e.get(B1),u=p=>n(p,r);function d(){const p=o.getComponents("header"),f=o.getComponents("content"),S=o.getComponents("footer"),_=o.getComponents("header-menu"),L=o.getComponents("left-sidebar");So(v.jsx(a,{...t,mountContainer:r,headerComponents:p,headerMenuComponents:_,leftSidebarComponents:L,contentComponents:f,onRendered:u,footerComponents:S}),r)}const h=o.componentRegistered$.subscribe(d);return d(),y.toDisposable(()=>{bo(r),h.unsubscribe()})}function k6(e){const t=document.createElement("div");return t.id=e,t}const n4={uiToolbar:{start:"Start",insert:"Insert",formulas:"Formulas",data:"Data",view:"View",others:"Others"},more:"More",fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"Shortcuts"},shortcut:{undo:"Undo",redo:"Redo",cut:"Cut",copy:"Copy",paste:"Paste","shortcut-panel":"Toggle Shortcut Panel"},"common-edit":"Common Editing Shortcuts","toggle-shortcut-panel":"Toggle Shortcut Panel",clipboard:{authentication:{title:"Permission Denied",content:"Please allow Univer to access your clipboard."}},textEditor:{formulaError:"Please enter a valid formula, such as =SUM(A1)",rangeError:"Please enter a valid range, such as A1:B10"},rangeSelector:{title:"Select a data range",addAnotherRange:"Add range",buttonTooltip:"Select data range",placeHolder:"Select range or enter.",confirm:"Confirm",cancel:"Cancel"},"global-shortcut":"Global Shortcut"},A6={uiToolbar:{start:"开始",insert:"插入",formulas:"公式",data:"数据",view:"视图",others:"其他"},more:"更多",fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"快捷键面板"},shortcut:{undo:"撤销",redo:"重做",cut:"剪切",copy:"复制",paste:"粘贴","shortcut-panel":"打开收起快捷键面板"},"common-edit":"常用编辑","toggle-shortcut-panel":"打开收起快捷键面板",clipboard:{authentication:{title:"无法访问剪贴板",content:"请允许 Univer 访问您的剪贴板。"}},textEditor:{formulaError:"请输入合法的公式,例如=SUM(A1)",rangeError:"请输入合法的范围,例如 A1:B10"},rangeSelector:{title:"选择一个数据范围",addAnotherRange:"添加范围",buttonTooltip:"选择数据范围",placeHolder:"框选范围或输入",confirm:"确认",cancel:"取消"},"global-shortcut":"全局快捷键"},dt=se.createIdentifier("univer.notification-service");var r4=Object.defineProperty,i4=Object.getOwnPropertyDescriptor,a4=(e,t,n,r)=>{for(var i=r>1?void 0:r?i4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&r4(t,n,i),i},o4=(e,t)=>(n,r)=>t(n,r,e);const R6=se.createIdentifier("univer.ui.before-close-service");E.DesktopBeforeCloseService=class{constructor(t){z(this,"_beforeUnloadCallbacks",[]);z(this,"_onCloseCallbacks",[]);this._notificationService=t,this._init()}registerBeforeClose(t){return this._beforeUnloadCallbacks.push(t),{dispose:()=>{this._beforeUnloadCallbacks=this._beforeUnloadCallbacks.filter(n=>n!==t)}}}registerOnClose(t){return this._onCloseCallbacks.push(t),{dispose:()=>{this._onCloseCallbacks=this._onCloseCallbacks.filter(n=>n!==t)}}}_init(){window.addEventListener("beforeunload",t=>{const n=this._beforeUnloadCallbacks.map(r=>r()).filter(r=>!!r).join(`
41
- `);if(n)return this._notificationService.show({type:"error",title:"Some changes are not saved",content:n}),typeof t>"u"&&(t=window.event),t.returnValue=n,n}),window.addEventListener("unload",()=>{this._onCloseCallbacks.forEach(t=>t())})}},E.DesktopBeforeCloseService=a4([o4(0,dt)],E.DesktopBeforeCloseService);function s4(){return typeof navigator.clipboard<"u"&&typeof navigator.clipboard.readText<"u"}var l4=Object.defineProperty,c4=Object.getOwnPropertyDescriptor,u4=(e,t,n,r)=>{for(var i=r>1?void 0:r?c4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&l4(t,n,i),i},Jt=(e,t)=>(n,r)=>t(n,r,e);const Kt="text/plain",en="text/html",U6=se.createIdentifier("univer.clipboard-interface-service");E.BrowserClipboardService=class extends y.Disposable{constructor(t,n,r){super(),this._localeService=t,this._logService=n,this._notificationService=r}get supportClipboard(){return s4()}async write(t,n){if(!this.supportClipboard)return this._legacyCopyHtml(n);try{return await navigator.clipboard.write([new ClipboardItem({[Kt]:new Blob([t],{type:Kt}),[en]:new Blob([n],{type:en})})])}catch(r){this._logService.error("[BrowserClipboardService]",r),this._showClipboardAuthenticationNotification()}}async writeText(t){if(!this.supportClipboard)return this._legacyCopyText(t);try{return await navigator.clipboard.writeText(t)}catch(n){this._logService.error("[BrowserClipboardService]",n),this._showClipboardAuthenticationNotification()}}async read(){if(!this.supportClipboard)throw new Error("[BrowserClipboardService] read() is not supported on this platform.");try{return navigator.clipboard.read()}catch(t){return this._logService.error("[BrowserClipboardService]",t),this._showClipboardAuthenticationNotification(),[]}}async readText(){if(!this.supportClipboard)throw new Error("[BrowserClipboardService] read() is not supported on this platform.");try{return await navigator.clipboard.readText()}catch(t){return this._logService.error("[BrowserClipboardService]",t),this._showClipboardAuthenticationNotification(),""}}_legacyCopyHtml(t){const n=document.activeElement,r=d4();document.body.appendChild(r),r.innerHTML=t;try{P6(r),document.execCommand("copy")}finally{n instanceof HTMLElement&&n.focus(),document.body.removeChild(r)}}_legacyCopyText(t){const n=document.activeElement,r=f4();document.body.appendChild(r),r.value=t;try{P6(r),document.execCommand("copy")}finally{n instanceof HTMLElement&&n.focus(),document.body.removeChild(r)}}_showClipboardAuthenticationNotification(){var t;(t=this._notificationService)==null||t.show({type:"warning",title:this._localeService.t("clipboard.authentication.title"),content:this._localeService.t("clipboard.authentication.content")})}},E.BrowserClipboardService=u4([Jt(0,se.Inject(y.LocaleService)),Jt(1,y.ILogService),Jt(2,se.Optional(dt))],E.BrowserClipboardService);function f4(){const e=document.createElement("textarea");return e.style.position="absolute",e.style.height="1px",e.style.width="1px",e.style.opacity="0",e.readOnly=!0,e}function d4(){const e=document.createElement("div");return e.contentEditable="true",e.style.position="absolute",e.style.opacity="0",e.style.height="1px",e.style.width="1px",e}function P6(e){if(e instanceof HTMLTextAreaElement){const r=e.hasAttribute("readonly");return r||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),r||e.removeAttribute("readonly"),e.value}e.hasAttribute("contenteditable")&&e.focus();const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();if(!n)throw new Error;return n.removeAllRanges(),n.addRange(t),n.toString()}class j6{constructor(){z(this,"_confirmOptions",[]);z(this,"confirmOptions$",new ee.Subject)}open(t){return this._confirmOptions.find(n=>n.id===t.id)?this._confirmOptions=this._confirmOptions.map(n=>({...n.id===t.id?t:n,visible:n.id===t.id?!0:n.visible})):this._confirmOptions.push({...t,visible:!0}),this.confirmOptions$.next(this._confirmOptions),y.toDisposable(()=>{this._confirmOptions=[],this.confirmOptions$.next([])})}confirm(t){return new Promise(n=>{const r=this.open({...t,onConfirm:()=>{r.dispose(),n(!0)},onClose:()=>{r.dispose(),n(!1)}})})}close(t){this._confirmOptions=this._confirmOptions.map(n=>({...n,visible:n.id===t?!1:n.visible})),this.confirmOptions$.next([...this._confirmOptions])}}class $6 extends y.Disposable{constructor(){super(...arguments);z(this,"_dialogOptions",[]);z(this,"_dialogOptions$",new ee.Subject)}dispose(){super.dispose(),this._dialogOptions$.complete()}open(n){return this._dialogOptions.find(r=>r.id===n.id)?this._dialogOptions=this._dialogOptions.map(r=>({...r.id===n.id?n:r,visible:!0})):this._dialogOptions.push({...n,visible:!0}),this._dialogOptions$.next(this._dialogOptions),y.toDisposable(()=>{this._dialogOptions=[],this._dialogOptions$.next([])})}close(n){this._dialogOptions=this._dialogOptions.map(r=>({...r,visible:r.id===n?!1:r.visible})),this._dialogOptions$.next([...this._dialogOptions])}getObservableDialog(){return this._dialogOptions$}}class B6{constructor(){z(this,"portalContainer",document.body);z(this,"message")}setContainer(t){this.portalContainer=t,this.message=new ge.Message(t)}show(t){const{type:n,...r}=t;return this.message&&this.message[n](r),y.toDisposable(()=>{})}}class z6{show(t){return B9.show(t),y.toDisposable(()=>{})}}var h4=Object.defineProperty,m4=Object.getOwnPropertyDescriptor,p4=(e,t,n,r)=>{for(var i=r>1?void 0:r?m4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&h4(t,n,i),i},g4=(e,t)=>(n,r)=>t(n,r,e);E.DesktopGlobalZoneService=class{constructor(t){z(this,"visible$",new ee.Subject);z(this,"componentKey$",new ee.Subject);this._componentManager=t}set(t,n){return this._componentManager.register(t,n),this.componentKey$.next(t),y.toDisposable(()=>{this._componentManager.delete(t),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}},E.DesktopGlobalZoneService=p4([g4(0,se.Inject(Ke))],E.DesktopGlobalZoneService);class F6{constructor(){z(this,"_sidebarOptions",{});z(this,"sidebarOptions$",new ee.Subject)}open(t){return this._sidebarOptions={...t,visible:!0},this.sidebarOptions$.next(this._sidebarOptions),y.toDisposable(()=>{this.sidebarOptions$.complete()})}set(t){this._sidebarOptions={...t},this.sidebarOptions$.next(this._sidebarOptions)}close(){this._sidebarOptions={...this._sidebarOptions,visible:!1},this.sidebarOptions$.next(this._sidebarOptions),this._sidebarOptions.onClose&&this._sidebarOptions.onClose()}}var v4=Object.defineProperty,C4=Object.getOwnPropertyDescriptor,S4=(e,t,n,r)=>{for(var i=r>1?void 0:r?C4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&v4(t,n,i),i},Z6=(e,t)=>(n,r)=>t(n,r,e);let ht=class extends y.Disposable{constructor(e,t){super(),this._errorService=e,this._messageService=t,this.disposeWithMe(y.toDisposable(this._errorService.error$.subscribe(n=>{this._messageService.show({content:n.errorKey,type:ge.MessageType.Error})})))}};ht=S4([y.OnLifecycle(y.LifecycleStages.Starting,ht),Z6(0,se.Inject(y.ErrorService)),Z6(1,G1)],ht);class W6 extends y.Disposable{constructor(){super(...arguments);z(this,"_open$",new ee.BehaviorSubject(!1));z(this,"open$",this._open$.pipe(ee.distinctUntilChanged()))}get isOpen(){return this._open$.getValue()}dispose(){this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}}const G6="ShortcutPanel",tn={id:"base-ui.operation.toggle-shortcut-panel",type:y.CommandType.OPERATION,handler:e=>{const t=e.get(W6),n=e.get(Y1);return t.isOpen?(t.close(),n.close()):(t.open(),n.open({header:{title:"shortcut-panel.title"},children:{label:G6}})),!0}},C1={shortcutPanelGroupTitle:"univer-shortcut-panel-group-title",shortcutPanelItem:"univer-shortcut-panel-item",shortcutPanelItemTitle:"univer-shortcut-panel-item-title",shortcutPanelItemShortcut:"univer-shortcut-panel-item-shortcut"};function b4(){const e=le.useDependency(m1),t=le.useDependency(y.LocaleService),[n,r]=s.useState([]),i=s.useCallback(()=>{var d;const a=new Map,o=e.getAllShortcuts().filter(h=>!!h.group);for(const h of o){const p=h.group,f={title:t.t((d=h.description)!=null?d:h.id),shortcut:e.getShortcutDisplay(h)};if(!/\d+_[a-zA-Z0-9]/.test(p))throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${p}!`);a.has(p)||a.set(p,[]),a.get(p).push(f)}const u=Array.from(a.entries()).map(([h,p])=>{const f=h.split("_")[0],S=h.slice(f.length+1);return{sequence:+f,name:t.t(S),items:p}}).sort((h,p)=>h.sequence-p.sequence);r(u)},[e,t]);return s.useEffect(()=>{i();const a=e.shortcutChanged$.subscribe(()=>i());return()=>a.unsubscribe()},[e]),v.jsx("div",{className:C1.shortcutPanel,children:n.map(a=>v.jsxs("div",{className:C1.shortcutPanelGroup,children:[v.jsx("div",{className:C1.shortcutPanelGroupTitle,children:a.name}),a.items.map((o,u)=>v.jsxs("div",{className:C1.shortcutPanelItem,children:[v.jsx("span",{className:C1.shortcutPanelItemTitle,children:o.title}),v.jsx("span",{className:C1.shortcutPanelItemShortcut,children:o.shortcut})]},u))]},a.name))})}function y4(e){return{id:tn.id,title:"toggle-shortcut-panel",tooltip:"toggle-shortcut-panel",icon:"KeyboardSingle",type:$e.BUTTON,positions:[Fe.TOOLBAR_START],hidden$:gr(e,y.UniverInstanceType.UNIVER_SHEET)}}var _4=Object.defineProperty,L4=Object.getOwnPropertyDescriptor,E4=(e,t,n,r)=>{for(var i=r>1?void 0:r?L4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&_4(t,n,i),i},D1=(e,t)=>(n,r)=>t(n,r,e);const w4={id:tn.id,binding:Re.CTRL_COMMAND|a1.BACK_SLASH,description:"shortcut.shortcut-panel",group:"10_global-shortcut"};let mt=class extends y.Disposable{constructor(e,t,n,r,i){super(),this.disposeWithMe(r.addMenuItem(e.invoke(y4))),this.disposeWithMe(t.register(G6,b4)),this.disposeWithMe(i.registerCommand(tn)),this.disposeWithMe(n.registerShortcut(w4))}};mt=E4([y.OnLifecycle(y.LifecycleStages.Steady,mt),D1(0,se.Inject(se.Injector)),D1(1,se.Inject(Ke)),D1(2,m1),D1(3,s1),D1(4,y.ICommandService)],mt);function pt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Y6={exports:{}};/*!
40
+ onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`,w9="".concat(L9," ").concat(E9).split(/[\s\n]+/),M9="aria-",O9="data-";function w6(e,t){return e.indexOf(t)===0}function I9(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n;t===!1?n={aria:!0,data:!0,attr:!0}:t===!0?n={aria:!0}:n=Ce({},t);var r={};return Object.keys(e).forEach(function(i){(n.aria&&(i==="role"||w6(i,M9))||n.data&&w6(i,O9)||n.attr&&w9.includes(i))&&(r[i]=e[i])}),r}var H9=ne.forwardRef(function(e,t){var n=e.prefixCls,r=e.style,i=e.className,a=e.duration,o=a===void 0?4.5:a,u=e.eventKey,d=e.content,h=e.closable,p=e.closeIcon,f=p===void 0?"x":p,S=e.props,_=e.onClick,L=e.onNoticeClose,U=e.times,H=e.hovering,A=ne.useState(!1),k=Ne(A,2),F=k[0],G=k[1],M=H||F,V=function(){L(u)},R=function(J){(J.key==="Enter"||J.code==="Enter"||J.keyCode===te.ENTER)&&V()};ne.useEffect(function(){if(!M&&o>0){var Z=setTimeout(function(){V()},o*1e3);return function(){clearTimeout(Z)}}},[o,M,U]);var N=ne.useMemo(function(){return Ze(h)==="object"&&h!==null?h:h?{closeIcon:f}:{}},[h,f]),$=I9(N,!0),q="".concat(n,"-notice");return ne.createElement("div",c1({},S,{ref:t,className:I1(q,i,Te({},"".concat(q,"-closable"),h)),style:r,onMouseEnter:function(J){var K;G(!0),S==null||(K=S.onMouseEnter)===null||K===void 0||K.call(S,J)},onMouseLeave:function(J){var K;G(!1),S==null||(K=S.onMouseLeave)===null||K===void 0||K.call(S,J)},onClick:_}),ne.createElement("div",{className:"".concat(q,"-content")},d),h&&ne.createElement("a",c1({tabIndex:0,className:"".concat(q,"-close"),onKeyDown:R,"aria-label":"Close"},$,{onClick:function(J){J.preventDefault(),J.stopPropagation(),V()}}),N.closeIcon))}),D9=s.createContext({}),M6=8,O6=3,I6=16,T9=function(t){var n={offset:M6,threshold:O6,gap:I6};if(t&&Ze(t)==="object"){var r,i,a;n.offset=(r=t.offset)!==null&&r!==void 0?r:M6,n.threshold=(i=t.threshold)!==null&&i!==void 0?i:O6,n.gap=(a=t.gap)!==null&&a!==void 0?a:I6}return[!!t,n]},x9=["className","style","classNames","styles"],V9=function(t){var n=t.configList,r=t.placement,i=t.prefixCls,a=t.className,o=t.style,u=t.motion,d=t.onAllNoticeRemoved,h=t.onNoticeClose,p=t.stack,f=s.useContext(D9),S=f.classNames,_=s.useRef({}),L=s.useState(null),U=Ne(L,2),H=U[0],A=U[1],k=s.useState([]),F=Ne(k,2),G=F[0],M=F[1],V=n.map(function(ae){return{config:ae,key:String(ae.key)}}),R=T9(p),N=Ne(R,2),$=N[0],q=N[1],Z=q.offset,J=q.threshold,K=q.gap,me=$&&(G.length>0||V.length<=J),fe=typeof u=="function"?u(r):u;return s.useEffect(function(){$&&G.length>1&&M(function(ae){return ae.filter(function(pe){return V.some(function(Ee){var O=Ee.key;return pe===O})})})},[G,V,$]),s.useEffect(function(){var ae;if($&&_.current[(ae=V[V.length-1])===null||ae===void 0?void 0:ae.key]){var pe;A(_.current[(pe=V[V.length-1])===null||pe===void 0?void 0:pe.key])}},[V,$]),s.createElement(_9,c1({key:r,className:I1(i,"".concat(i,"-").concat(r),S==null?void 0:S.list,a,Te(Te({},"".concat(i,"-stack"),!!$),"".concat(i,"-stack-expanded"),me)),style:o,keys:V,motionAppear:!0},fe,{onAllRemoved:function(){d(r)}}),function(ae,pe){var Ee=ae.config,O=ae.className,w=ae.style,D=ae.index,Y=Ee,W=Y.key,X=Y.times,ie=String(W),oe=Ee,Le=oe.className,xe=oe.style,Ie=oe.classNames,we=oe.styles,Je=q1(oe,x9),Ge=V.findIndex(function(d1){return d1.key===ie}),Be={};if($){var ce=V.length-1-(Ge>-1?Ge:D-1),re=r==="top"||r==="bottom"?"-50%":"0";if(ce>0){var ye,Ue,He;Be.height=me?(ye=_.current[ie])===null||ye===void 0?void 0:ye.offsetHeight:H==null?void 0:H.offsetHeight;for(var Me=0,he=0;he<ce;he++){var ve;Me+=((ve=_.current[V[V.length-1-he].key])===null||ve===void 0?void 0:ve.offsetHeight)+K}var Pe=(me?Me:ce*Z)*(r.startsWith("top")?1:-1),e1=!me&&H!==null&&H!==void 0&&H.offsetWidth&&(Ue=_.current[ie])!==null&&Ue!==void 0&&Ue.offsetWidth?((H==null?void 0:H.offsetWidth)-Z*2*(ce<3?ce:3))/((He=_.current[ie])===null||He===void 0?void 0:He.offsetWidth):1;Be.transform="translate3d(".concat(re,", ").concat(Pe,"px, 0) scaleX(").concat(e1,")")}else Be.transform="translate3d(".concat(re,", 0, 0)")}return s.createElement("div",{ref:pe,className:I1("".concat(i,"-notice-wrapper"),O,Ie==null?void 0:Ie.wrapper),style:Ce(Ce(Ce({},w),Be),we==null?void 0:we.wrapper),onMouseEnter:function(){return M(function(t1){return t1.includes(ie)?t1:[].concat(O1(t1),[ie])})},onMouseLeave:function(){return M(function(t1){return t1.filter(function(St){return St!==ie})})}},s.createElement(H9,c1({},Je,{ref:function(t1){Ge>-1?_.current[ie]=t1:delete _.current[ie]},prefixCls:i,classNames:Ie,styles:we,className:I1(Le,S==null?void 0:S.notice),style:xe,times:X,key:W,eventKey:W,onNoticeClose:h,hovering:$&&G.length>0})))})},N9=ne.forwardRef(function(e,t){var n=e.prefixCls,r=n===void 0?"rc-notification":n,i=e.container,a=e.motion,o=e.maxCount,u=e.className,d=e.style,h=e.onAllRemoved,p=e.stack,f=e.renderNotifications,S=ne.useState([]),_=Ne(S,2),L=_[0],U=_[1],H=function($){var q,Z=L.find(function(J){return J.key===$});Z==null||(q=Z.onClose)===null||q===void 0||q.call(Z),U(function(J){return J.filter(function(K){return K.key!==$})})};ne.useImperativeHandle(t,function(){return{open:function($){U(function(q){var Z=O1(q),J=Z.findIndex(function(fe){return fe.key===$.key}),K=Ce({},$);if(J>=0){var me;K.times=(((me=q[J])===null||me===void 0?void 0:me.times)||0)+1,Z[J]=K}else K.times=0,Z.push(K);return o>0&&Z.length>o&&(Z=Z.slice(-o)),Z})},close:function($){H($)},destroy:function(){U([])}}});var A=ne.useState({}),k=Ne(A,2),F=k[0],G=k[1];ne.useEffect(function(){var N={};L.forEach(function($){var q=$.placement,Z=q===void 0?"topRight":q;Z&&(N[Z]=N[Z]||[],N[Z].push($))}),Object.keys(F).forEach(function($){N[$]=N[$]||[]}),G(N)},[L]);var M=function($){G(function(q){var Z=Ce({},q),J=Z[$]||[];return J.length||delete Z[$],Z})},V=ne.useRef(!1);if(ne.useEffect(function(){Object.keys(F).length>0?V.current=!0:V.current&&(h==null||h(),V.current=!1)},[F]),!i)return null;var R=Object.keys(F);return yt.createPortal(ne.createElement(ne.Fragment,null,R.map(function(N){var $=F[N],q=ne.createElement(V9,{key:N,configList:$,placement:N,prefixCls:r,className:u==null?void 0:u(N),style:d==null?void 0:d(N),motion:a,onNoticeClose:H,onAllNoticeRemoved:M,stack:p});return f?f(q,{prefixCls:r,key:N}):q})),i)}),k9=["getContainer","motion","prefixCls","maxCount","className","style","onAllRemoved","stack","renderNotifications"],A9=function(){return document.body},H6=0;function R9(){for(var e={},t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach(function(i){i&&Object.keys(i).forEach(function(a){var o=i[a];o!==void 0&&(e[a]=o)})}),e}function U9(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.getContainer,n=t===void 0?A9:t,r=e.motion,i=e.prefixCls,a=e.maxCount,o=e.className,u=e.style,d=e.onAllRemoved,h=e.stack,p=e.renderNotifications,f=q1(e,k9),S=ne.useState(),_=Ne(S,2),L=_[0],U=_[1],H=ne.useRef(),A=ne.createElement(N9,{container:L,ref:H,prefixCls:i,motion:r,maxCount:a,className:o,style:u,onAllRemoved:d,stack:h,renderNotifications:p}),k=ne.useState([]),F=Ne(k,2),G=F[0],M=F[1],V=ne.useMemo(function(){return{open:function(N){var $=R9(f,N);($.key===null||$.key===void 0)&&($.key="rc-notification-".concat(H6),H6+=1),M(function(q){return[].concat(O1(q),[{type:"open",config:$}])})},close:function(N){M(function($){return[].concat(O1($),[{type:"close",key:N}])})},destroy:function(){M(function(N){return[].concat(O1(N),[{type:"destroy"}])})}}},[]);return ne.useEffect(function(){U(n())}),ne.useEffect(function(){H.current&&G.length&&(G.forEach(function(R){switch(R.type){case"open":H.current.open(R.config);break;case"close":H.current.close(R.key);break;case"destroy":H.current.destroy();break}}),M(function(R){return R.filter(function(N){return!G.includes(N)})}))},[G]),[V,A]}const Qe={notification:"univer-notification",notificationNotice:"univer-notification-notice",notificationNoticeWrapper:"univer-notification-notice-wrapper",notificationNoticeContent:"univer-notification-notice-content",notificationNoticeClose:"univer-notification-notice-close",notificationIcon:"univer-notification-icon",notificationIconSuccess:"univer-notification-icon-success",notificationIconInfo:"univer-notification-icon-info",notificationIconWarning:"univer-notification-icon-warning",notificationIconError:"univer-notification-icon-error",notificationContentContainer:"univer-notification-content-container",notificationTitle:"univer-notification-title",notificationContent:"univer-notification-content",notificationContentEllipsis:"univer-notification-content-ellipsis",notificationTop:"univer-notification-top",notificationTopLeft:"univer-notification-topLeft",notificationTopRight:"univer-notification-topRight",notificationBottom:"univer-notification-bottom",notificationBottomRight:"univer-notification-bottomRight",notificationBottomLeft:"univer-notification-bottomLeft",notificationFade:"univer-notification-fade",notificationFadeAppearPrepare:"univer-notification-fade-appear-prepare",notificationFadeAppearStart:"univer-notification-fade-appear-start",notificationFadeAppearActive:"univer-notification-fade-appear-active",notificationFadeAppear:"univer-notification-fade-appear",notificationFadeEnter:"univer-notification-fade-enter",notificationFadeLeave:"univer-notification-fade-leave",notificationFadeEnterActive:"univer-notification-fade-enter-active",notificationFadeIn:"univer-notification-fade-in",notificationFadeLeaveActive:"univer-notification-fade-leave-active",notificationFadeOut:"univer-notification-fade-out"},P9={success:v.jsx(fa,{className:Qe.notificationIconSuccess}),info:v.jsx(mr,{className:Qe.notificationIconInfo}),warning:v.jsx(mr,{className:Qe.notificationIconWarning}),error:v.jsx(i2,{className:Qe.notificationIconError})},D6=new ee.Subject,j9=e=>{const{type:t,content:n,title:r,lines:i=0}=e,a=Ve(Qe.notificationContent,{[Qe.notificationContentEllipsis]:i!==0});return v.jsxs(v.Fragment,{children:[v.jsx("span",{className:Qe.notificationIcon,children:P9[t]}),v.jsxs("div",{className:Qe.notificationContentContainer,children:[v.jsx("span",{className:Qe.notificationTitle,children:r}),v.jsx("span",{className:a,style:{WebkitLineClamp:i},children:n})]})]})};function $9(){const{mountContainer:e}=s.useContext(ge.ConfigContext);if(!e)return v.jsx(v.Fragment,{});const[t,n]=U9({prefixCls:Qe.notification,maxCount:3,closeIcon:v.jsx(_t,{}),getContainer:()=>e,motion:{motionName:Qe.notificationFade,motionAppear:!0,motionEnter:!0,motionLeave:!0}}),r=s.useRef(D6);return s.useEffect(()=>{const i=r.current.subscribe(a=>{var o,u,d;t.open({content:v.jsx(j9,{content:a.content,type:a.type,title:a.title,lines:a.lines}),placement:(o=a.placement)!=null?o:"topRight",duration:(u=a.duration)!=null?u:4.5,closable:(d=a.closable)!=null?d:!0})});return()=>{i.unsubscribe()}},[]),v.jsx(v.Fragment,{children:n})}const B9={show:e=>{D6.next(e)}},Gt=se.createIdentifier("univer.confirm-service");function z9(){const e=le.useDependency(Gt),[t,n]=s.useState([]);s.useEffect(()=>{const i=e.confirmOptions$.subscribe(a=>{n(a)});return()=>{i.unsubscribe()}},[]);const r=t.map(i=>{const{children:a,title:o,...u}=i,d=u;for(const h of["children","title"]){const p=h,f=i[p];f&&(d[p]=v.jsx(je,{...f}))}return d});return r==null?void 0:r.map((i,a)=>v.jsx(ge.Confirm,{...i},a))}const Yt=se.createIdentifier("univer.context-menu-service");class T6 extends y.Disposable{constructor(){super(...arguments);z(this,"_currentHandler",null);z(this,"disabled",!1)}disable(){this.disabled=!0}enable(){this.disabled=!1}triggerContextMenu(n,r){var i;n.stopPropagation(),!this.disabled&&((i=this._currentHandler)==null||i.handleContextMenu(n,r))}registerContextMenuHandler(n){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=n,y.toDisposable(()=>{this._currentHandler=null})}}function F9(){const[e,t]=s.useState(!1),[n,r]=s.useState(""),[i,a]=s.useState([0,0]),o=le.useDependency(Yt),u=le.useDependency(y.ICommandService),d=le.useInjector();s.useEffect(()=>{const f=o.registerContextMenuHandler({handleContextMenu:h});return document.addEventListener("pointerdown",p),document.addEventListener("wheel",p),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("wheel",p),f.dispose()}},[]);function h(f,S){r(S),a([f.clientX,f.clientY]),t(!0)}function p(){t(!1)}return v.jsx(ge.Popup,{visible:e,offset:i,children:v.jsx("section",{onPointerDown:f=>f.stopPropagation(),children:n&&v.jsx(P1,{menuType:[n],onOptionSelect:f=>{const{label:S,value:_}=f;u&&u.executeCommand(S,{value:_}),d.get(h1.ITextSelectionRenderManager).focus(),t(!1)}})})})}const qt=se.createIdentifier("univer.ui.dialog-service");function Z9(){const e=le.useDependency(qt),[t,n]=s.useState([]);s.useEffect(()=>{const a=e.getObservableDialog().subscribe(o=>{n(o)});return()=>{a.unsubscribe()}},[e]);const r=t.map(i=>{const{children:a,title:o,closeIcon:u,footer:d,...h}=i,p=h;for(const f of["children","title","closeIcon","footer"]){const S=f,_=i[S];_&&(p[S]=v.jsx(je,{..._}))}return p});return v.jsx(v.Fragment,{children:r==null?void 0:r.map(i=>v.jsx(ge.Dialog,{...i},i.id))})}const Xt=se.createIdentifier("univer.global-zone-service"),x6={globalZone:"univer-global-zone",globalZoneOpen:"univer-global-zone-open",globalZoneClose:"univer-global-zone-close"};function W9(){const e=le.useDependency(Xt),[t,n]=s.useState(!1),r=Ae(e.componentKey$,e.componentKey),i=le.useDependency(Ke),a=Ve(x6.globalZone,x6.globalZoneOpen),o=s.useMemo(()=>{const u=i.get(r!=null?r:"");if(u)return u},[r,i]);return s.useEffect(()=>{const u=e.visible$.subscribe(d=>{n(d)});return()=>{u.unsubscribe()}},[e.visible$]),t?v.jsx("section",{className:a,children:o&&v.jsx(o,{})}):null}const G9=new Set([()=>Z9,()=>z9,()=>$9,()=>F9,()=>W9]),Qt=se.createIdentifier("univer.popup.service");class V6{constructor(){z(this,"_popupMap",new Map);z(this,"_popups$",new ee.BehaviorSubject([]));z(this,"popups$",this._popups$.asObservable())}get popups(){return Array.from(this._popupMap.entries())}_notice(){this._popups$.next(Array.from(this._popupMap.entries()))}addPopup(t){const n=y.Tools.generateRandomId();return this._popupMap.set(n,t),this._notice(),n}removePopup(t){this._popupMap.delete(t)&&this._notice()}removeAll(){this._popupMap.clear(),this._notice()}}const Y9=({popup:e,children:t})=>{const n=Ae(e.anchorRect$,e.anchorRect),r=s.useMemo(()=>{var o;const[i=0,a=0]=(o=e.offset)!=null?o:[];return{left:n.left-i,right:n.right+i,top:n.top-a,bottom:n.bottom+a}},[n.bottom,n.left,n.right,n.top,e.offset]);return v.jsx(ge.RectPopup,{anchorRect:r,direction:e.direction,onClickOutside:e.onClickOutside,excludeOutside:e.excludeOutside,closeOnSelfTarget:e.closeOnSelfTarget,children:t})};function q9(){const e=le.useDependency(Qt),t=Ae(e.popups$,void 0,!0),n=le.useDependency(Ke);return t.map(r=>{const[i,a]=r,o=n.get(a.componentKey);return v.jsx(Y9,{popup:a,children:o?v.jsx(o,{popup:a}):null},i)})}function X9(e){const{header:t,footer:n,mountContainer:r,headerComponents:i,headerMenuComponents:a,contentComponents:o,footerComponents:u,leftSidebarComponents:d,onRendered:h}=e,p=le.useDependency(y.LocaleService),f=le.useDependency(y.ThemeService),S=le.useDependency(G1),_=s.useRef(null);s.useEffect(()=>{f.getCurrentTheme()||f.setTheme(ge.defaultTheme)},[]),s.useEffect(()=>{_.current&&(h==null||h(_.current))},[h]);const[L,U]=s.useState(p.getLocales()),H=s.useMemo(()=>document.createElement("div"),[]);return s.useEffect(()=>{document.body.appendChild(H),S.setContainer(H);const A=[p.localeChanged$.subscribe(()=>{U(p.getLocales())}),f.currentTheme$.subscribe(k=>{ge.themeInstance.setTheme(r,k),H&&ge.themeInstance.setTheme(H,k)})];return()=>{A.forEach(k=>k.unsubscribe()),document.body.removeChild(H)}},[p,S,r,H,f.currentTheme$]),v.jsxs(ge.ConfigProvider,{locale:L,mountContainer:H,children:[v.jsxs("div",{className:r1.appLayout,tabIndex:-1,onBlur:A=>A.stopPropagation(),children:[t&&v.jsx("header",{className:r1.appContainerHeader,children:v.jsx(Ro,{headerMenuComponents:a})}),v.jsxs("section",{className:r1.appContainer,children:[v.jsxs("div",{className:r1.appContainerWrapper,children:[v.jsx("aside",{className:r1.appContainerLeftSidebar,children:v.jsx(p1,{components:d})}),v.jsxs("section",{className:r1.appContainerContent,children:[v.jsx("header",{children:t&&v.jsx(p1,{components:i})}),v.jsx("section",{className:r1.appContainerCanvas,ref:_,"data-range-selector":!0,onContextMenu:A=>A.preventDefault(),children:v.jsx(p1,{components:o})})]}),v.jsx("aside",{className:r1.appContainerSidebar,children:v.jsx(Uo,{})})]}),n&&v.jsx("footer",{className:r1.appFooter,children:v.jsx(p1,{components:u})}),v.jsx(Po,{})]}),v.jsx(q9,{})]}),v.jsx(p1,{components:G9})]})}var Q9=Object.defineProperty,J9=Object.getOwnPropertyDescriptor,K9=(e,t,n,r)=>{for(var i=r>1?void 0:r?J9(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Q9(t,n,i),i},H1=(e,t)=>(n,r)=>t(n,r,e),N6=(e=>(e.HEADER="header",e.HEADER_MENU="header-menu",e.CONTENT="content",e.FOOTER="footer",e.LEFT_SIDEBAR="left-sidebar",e))(N6||{});const e4=3e3;E.DesktopUIController=class extends y.Disposable{constructor(n,r,i,a,o){super();z(this,"_componentsByPart",new Map);z(this,"_componentRegistered$",new ee.Subject);z(this,"componentRegistered$",this._componentRegistered$.asObservable());this._instanceService=n,this._renderManagerService=r,this._injector=i,this._lifecycleService=a,this._layoutService=o}bootstrapWorkbench(n){this.disposeWithMe(t4(this._injector,n,(r,i)=>{this._layoutService&&(this.disposeWithMe(this._layoutService.registerRootContainerElement(i)),this.disposeWithMe(this._layoutService.registerCanvasElement(r))),this._renderManagerService.currentRender$.subscribe(a=>{if(a){const o=this._renderManagerService.getRenderById(a);if(!o.unitId||this._instanceService.getUnitType(o.unitId)!==y.UniverInstanceType.UNIVER_SHEET)return;o.engine.setContainer(r)}}),this._lifecycleService.lifecycle$.pipe(ee.filter(a=>a===y.LifecycleStages.Ready),ee.delay(300),ee.take(1)).subscribe(()=>{var o;const a=(o=this._renderManagerService.getFirst())==null?void 0:o.engine;a==null||a.setContainer(r),this._lifecycleService.stage=y.LifecycleStages.Rendered,setTimeout(()=>this._lifecycleService.stage=y.LifecycleStages.Steady,e4)})}))}registerComponent(n,r){const i=(this._componentsByPart.get(n)||this._componentsByPart.set(n,new Set).get(n)).add(r);return this._componentRegistered$.next(),y.toDisposable(()=>{i.delete(r),i.size===0&&this._componentsByPart.delete(n)})}getComponents(n){return new Set([...this._componentsByPart.get(n)||new Set])}},E.DesktopUIController=K9([H1(0,y.IUniverInstanceService),H1(1,h1.IRenderManagerService),H1(2,se.Inject(se.Injector)),H1(3,se.Inject(y.LifecycleService)),H1(4,se.Optional(L1))],E.DesktopUIController);function t4(e,t,n){let r;const i=t.container;if(typeof i=="string"){const p=document.getElementById(i);p?r=p:r=k6(i)}else i instanceof HTMLElement?r=i:r=k6("univer");const a=le.connectInjector(X9,e),o=e.get(B1),u=p=>n(p,r);function d(){const p=o.getComponents("header"),f=o.getComponents("content"),S=o.getComponents("footer"),_=o.getComponents("header-menu"),L=o.getComponents("left-sidebar");So(v.jsx(a,{...t,mountContainer:r,headerComponents:p,headerMenuComponents:_,leftSidebarComponents:L,contentComponents:f,onRendered:u,footerComponents:S}),r)}const h=o.componentRegistered$.subscribe(d);return d(),y.toDisposable(()=>{bo(r),h.unsubscribe()})}function k6(e){const t=document.createElement("div");return t.id=e,t}const n4={uiToolbar:{start:"Start",insert:"Insert",formulas:"Formulas",data:"Data",view:"View",others:"Others"},more:"More",fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"Shortcuts"},shortcut:{undo:"Undo",redo:"Redo",cut:"Cut",copy:"Copy",paste:"Paste","shortcut-panel":"Toggle Shortcut Panel"},"common-edit":"Common Editing Shortcuts","toggle-shortcut-panel":"Toggle Shortcut Panel",clipboard:{authentication:{title:"Permission Denied",content:"Please allow Univer to access your clipboard."}},textEditor:{formulaError:"Please enter a valid formula, such as =SUM(A1)",rangeError:"Please enter a valid range, such as A1:B10"},rangeSelector:{title:"Select a data range",addAnotherRange:"Add range",buttonTooltip:"Select data range",placeHolder:"Select range or enter.",confirm:"Confirm",cancel:"Cancel"},"global-shortcut":"Global Shortcut"},A6={uiToolbar:{start:"开始",insert:"插入",formulas:"公式",data:"数据",view:"视图",others:"其他"},more:"更多",fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},"shortcut-panel":{title:"快捷键面板"},shortcut:{undo:"撤销",redo:"重做",cut:"剪切",copy:"复制",paste:"粘贴","shortcut-panel":"打开收起快捷键面板"},"common-edit":"常用编辑","toggle-shortcut-panel":"打开收起快捷键面板",clipboard:{authentication:{title:"无法访问剪贴板",content:"请允许 Univer 访问您的剪贴板。"}},textEditor:{formulaError:"请输入合法的公式,例如=SUM(A1)",rangeError:"请输入合法的范围,例如 A1:B10"},rangeSelector:{title:"选择一个数据范围",addAnotherRange:"添加范围",buttonTooltip:"选择数据范围",placeHolder:"框选范围或输入",confirm:"确认",cancel:"取消"},"global-shortcut":"全局快捷键"},dt=se.createIdentifier("univer.notification-service");var r4=Object.defineProperty,i4=Object.getOwnPropertyDescriptor,a4=(e,t,n,r)=>{for(var i=r>1?void 0:r?i4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&r4(t,n,i),i},o4=(e,t)=>(n,r)=>t(n,r,e);const R6=se.createIdentifier("univer.ui.before-close-service");E.DesktopBeforeCloseService=class{constructor(t){z(this,"_beforeUnloadCallbacks",[]);z(this,"_onCloseCallbacks",[]);this._notificationService=t,this._init()}registerBeforeClose(t){return this._beforeUnloadCallbacks.push(t),{dispose:()=>{this._beforeUnloadCallbacks=this._beforeUnloadCallbacks.filter(n=>n!==t)}}}registerOnClose(t){return this._onCloseCallbacks.push(t),{dispose:()=>{this._onCloseCallbacks=this._onCloseCallbacks.filter(n=>n!==t)}}}_init(){window.addEventListener("beforeunload",t=>{const n=this._beforeUnloadCallbacks.map(r=>r()).filter(r=>!!r).join(`
41
+ `);if(n)return this._notificationService.show({type:"error",title:"Some changes are not saved",content:n}),typeof t>"u"&&(t=window.event),t.returnValue=n,n}),window.addEventListener("unload",()=>{this._onCloseCallbacks.forEach(t=>t())})}},E.DesktopBeforeCloseService=a4([o4(0,dt)],E.DesktopBeforeCloseService);function s4(){return typeof navigator.clipboard<"u"&&typeof navigator.clipboard.readText<"u"}var l4=Object.defineProperty,c4=Object.getOwnPropertyDescriptor,u4=(e,t,n,r)=>{for(var i=r>1?void 0:r?c4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&l4(t,n,i),i},Jt=(e,t)=>(n,r)=>t(n,r,e);const Kt="text/plain",en="text/html",U6=se.createIdentifier("univer.clipboard-interface-service");E.BrowserClipboardService=class extends y.Disposable{constructor(t,n,r){super(),this._localeService=t,this._logService=n,this._notificationService=r}get supportClipboard(){return s4()}async write(t,n){if(!this.supportClipboard)return this._legacyCopyHtml(n);try{return await navigator.clipboard.write([new ClipboardItem({[Kt]:new Blob([t],{type:Kt}),[en]:new Blob([n],{type:en})})])}catch(r){this._logService.error("[BrowserClipboardService]",r),this._showClipboardAuthenticationNotification()}}async writeText(t){if(!this.supportClipboard)return this._legacyCopyText(t);try{return await navigator.clipboard.writeText(t)}catch(n){this._logService.error("[BrowserClipboardService]",n),this._showClipboardAuthenticationNotification()}}async read(){if(!this.supportClipboard)throw new Error("[BrowserClipboardService] read() is not supported on this platform.");try{return navigator.clipboard.read()}catch(t){return this._logService.error("[BrowserClipboardService]",t),this._showClipboardAuthenticationNotification(),[]}}async readText(){if(!this.supportClipboard)throw new Error("[BrowserClipboardService] read() is not supported on this platform.");try{return await navigator.clipboard.readText()}catch(t){return this._logService.error("[BrowserClipboardService]",t),this._showClipboardAuthenticationNotification(),""}}_legacyCopyHtml(t){const n=document.activeElement,r=d4();document.body.appendChild(r),r.innerHTML=t;try{P6(r),document.execCommand("copy")}finally{n instanceof HTMLElement&&n.focus(),document.body.removeChild(r)}}_legacyCopyText(t){const n=document.activeElement,r=f4();document.body.appendChild(r),r.value=t;try{P6(r),document.execCommand("copy")}finally{n instanceof HTMLElement&&n.focus(),document.body.removeChild(r)}}_showClipboardAuthenticationNotification(){var t;(t=this._notificationService)==null||t.show({type:"warning",title:this._localeService.t("clipboard.authentication.title"),content:this._localeService.t("clipboard.authentication.content")})}},E.BrowserClipboardService=u4([Jt(0,se.Inject(y.LocaleService)),Jt(1,y.ILogService),Jt(2,se.Optional(dt))],E.BrowserClipboardService);function f4(){const e=document.createElement("textarea");return e.style.position="absolute",e.style.height="1px",e.style.width="1px",e.style.opacity="0",e.readOnly=!0,e}function d4(){const e=document.createElement("div");return e.contentEditable="true",e.style.position="absolute",e.style.opacity="0",e.style.height="1px",e.style.width="1px",e}function P6(e){if(e instanceof HTMLTextAreaElement){const r=e.hasAttribute("readonly");return r||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),r||e.removeAttribute("readonly"),e.value}e.hasAttribute("contenteditable")&&e.focus();const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();if(!n)throw new Error;return n.removeAllRanges(),n.addRange(t),n.toString()}class j6{constructor(){z(this,"_confirmOptions",[]);z(this,"confirmOptions$",new ee.Subject)}open(t){return this._confirmOptions.find(n=>n.id===t.id)?this._confirmOptions=this._confirmOptions.map(n=>({...n.id===t.id?t:n,visible:n.id===t.id?!0:n.visible})):this._confirmOptions.push({...t,visible:!0}),this.confirmOptions$.next(this._confirmOptions),y.toDisposable(()=>{this._confirmOptions=[],this.confirmOptions$.next([])})}confirm(t){return new Promise(n=>{const r=this.open({...t,onConfirm:()=>{r.dispose(),n(!0)},onClose:()=>{r.dispose(),n(!1)}})})}close(t){this._confirmOptions=this._confirmOptions.map(n=>({...n,visible:n.id===t?!1:n.visible})),this.confirmOptions$.next([...this._confirmOptions])}}class $6 extends y.Disposable{constructor(){super(...arguments);z(this,"_dialogOptions",[]);z(this,"_dialogOptions$",new ee.Subject)}dispose(){super.dispose(),this._dialogOptions$.complete()}open(n){return this._dialogOptions.find(r=>r.id===n.id)?this._dialogOptions=this._dialogOptions.map(r=>({...r.id===n.id?n:r,visible:!0})):this._dialogOptions.push({...n,visible:!0}),this._dialogOptions$.next(this._dialogOptions),y.toDisposable(()=>{this._dialogOptions=[],this._dialogOptions$.next([])})}close(n){this._dialogOptions=this._dialogOptions.map(r=>({...r,visible:r.id===n?!1:r.visible})),this._dialogOptions$.next([...this._dialogOptions])}getObservableDialog(){return this._dialogOptions$}}class B6{constructor(){z(this,"portalContainer",document.body);z(this,"message")}setContainer(t){this.portalContainer=t,this.message=new ge.Message(t)}show(t){const{type:n,...r}=t;return this.message&&this.message[n](r),y.toDisposable(()=>{})}}class z6{show(t){return B9.show(t),y.toDisposable(()=>{})}}var h4=Object.defineProperty,m4=Object.getOwnPropertyDescriptor,p4=(e,t,n,r)=>{for(var i=r>1?void 0:r?m4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&h4(t,n,i),i},g4=(e,t)=>(n,r)=>t(n,r,e);E.DesktopGlobalZoneService=class{constructor(t){z(this,"visible$",new ee.Subject);z(this,"componentKey$",new ee.Subject);z(this,"_componentKey","");this._componentManager=t}get componentKey(){return this._componentKey}set(t,n){return this._componentManager.register(t,n),this.componentKey$.next(t),this._componentKey=t,y.toDisposable(()=>{this._componentManager.delete(t),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}},E.DesktopGlobalZoneService=p4([g4(0,se.Inject(Ke))],E.DesktopGlobalZoneService);class F6{constructor(){z(this,"_sidebarOptions",{});z(this,"sidebarOptions$",new ee.Subject)}open(t){return this._sidebarOptions={...t,visible:!0},this.sidebarOptions$.next(this._sidebarOptions),y.toDisposable(()=>{this.sidebarOptions$.complete()})}set(t){this._sidebarOptions={...t},this.sidebarOptions$.next(this._sidebarOptions)}close(){this._sidebarOptions={...this._sidebarOptions,visible:!1},this.sidebarOptions$.next(this._sidebarOptions),this._sidebarOptions.onClose&&this._sidebarOptions.onClose()}}var v4=Object.defineProperty,C4=Object.getOwnPropertyDescriptor,S4=(e,t,n,r)=>{for(var i=r>1?void 0:r?C4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&v4(t,n,i),i},Z6=(e,t)=>(n,r)=>t(n,r,e);let ht=class extends y.Disposable{constructor(e,t){super(),this._errorService=e,this._messageService=t,this.disposeWithMe(y.toDisposable(this._errorService.error$.subscribe(n=>{this._messageService.show({content:n.errorKey,type:ge.MessageType.Error})})))}};ht=S4([y.OnLifecycle(y.LifecycleStages.Starting,ht),Z6(0,se.Inject(y.ErrorService)),Z6(1,G1)],ht);class W6 extends y.Disposable{constructor(){super(...arguments);z(this,"_open$",new ee.BehaviorSubject(!1));z(this,"open$",this._open$.pipe(ee.distinctUntilChanged()))}get isOpen(){return this._open$.getValue()}dispose(){this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}}const G6="ShortcutPanel",tn={id:"base-ui.operation.toggle-shortcut-panel",type:y.CommandType.OPERATION,handler:e=>{const t=e.get(W6),n=e.get(Y1);return t.isOpen?(t.close(),n.close()):(t.open(),n.open({header:{title:"shortcut-panel.title"},children:{label:G6}})),!0}},C1={shortcutPanelGroupTitle:"univer-shortcut-panel-group-title",shortcutPanelItem:"univer-shortcut-panel-item",shortcutPanelItemTitle:"univer-shortcut-panel-item-title",shortcutPanelItemShortcut:"univer-shortcut-panel-item-shortcut"};function b4(){const e=le.useDependency(m1),t=le.useDependency(y.LocaleService),[n,r]=s.useState([]),i=s.useCallback(()=>{var d;const a=new Map,o=e.getAllShortcuts().filter(h=>!!h.group);for(const h of o){const p=h.group,f={title:t.t((d=h.description)!=null?d:h.id),shortcut:e.getShortcutDisplay(h)};if(!/\d+_[a-zA-Z0-9]/.test(p))throw new Error(`[ShortcutPanel]: Invalid shortcut group: ${p}!`);a.has(p)||a.set(p,[]),a.get(p).push(f)}const u=Array.from(a.entries()).map(([h,p])=>{const f=h.split("_")[0],S=h.slice(f.length+1);return{sequence:+f,name:t.t(S),items:p}}).sort((h,p)=>h.sequence-p.sequence);r(u)},[e,t]);return s.useEffect(()=>{i();const a=e.shortcutChanged$.subscribe(()=>i());return()=>a.unsubscribe()},[e]),v.jsx("div",{className:C1.shortcutPanel,children:n.map(a=>v.jsxs("div",{className:C1.shortcutPanelGroup,children:[v.jsx("div",{className:C1.shortcutPanelGroupTitle,children:a.name}),a.items.map((o,u)=>v.jsxs("div",{className:C1.shortcutPanelItem,children:[v.jsx("span",{className:C1.shortcutPanelItemTitle,children:o.title}),v.jsx("span",{className:C1.shortcutPanelItemShortcut,children:o.shortcut})]},u))]},a.name))})}function y4(e){return{id:tn.id,title:"toggle-shortcut-panel",tooltip:"toggle-shortcut-panel",icon:"KeyboardSingle",type:$e.BUTTON,positions:[Fe.TOOLBAR_START],hidden$:gr(e,y.UniverInstanceType.UNIVER_SHEET)}}var _4=Object.defineProperty,L4=Object.getOwnPropertyDescriptor,E4=(e,t,n,r)=>{for(var i=r>1?void 0:r?L4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&_4(t,n,i),i},D1=(e,t)=>(n,r)=>t(n,r,e);const w4={id:tn.id,binding:Re.CTRL_COMMAND|a1.BACK_SLASH,description:"shortcut.shortcut-panel",group:"10_global-shortcut"};let mt=class extends y.Disposable{constructor(e,t,n,r,i){super(),this.disposeWithMe(r.addMenuItem(e.invoke(y4))),this.disposeWithMe(t.register(G6,b4)),this.disposeWithMe(i.registerCommand(tn)),this.disposeWithMe(n.registerShortcut(w4))}};mt=E4([y.OnLifecycle(y.LifecycleStages.Steady,mt),D1(0,se.Inject(se.Injector)),D1(1,se.Inject(Ke)),D1(2,m1),D1(3,s1),D1(4,y.ICommandService)],mt);function pt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Y6={exports:{}};/*!
42
42
  localForage -- Offline Storage, Improved
43
43
  Version 1.10.0
44
44
  https://localforage.github.io/localForage
45
45
  (c) 2013-2017 Mozilla, Apache License 2.0
46
- */(function(e,t){(function(n){e.exports=n()})(function(){return function n(r,i,a){function o(h,p){if(!i[h]){if(!r[h]){var f=typeof pt=="function"&&pt;if(!p&&f)return f(h,!0);if(u)return u(h,!0);var S=new Error("Cannot find module '"+h+"'");throw S.code="MODULE_NOT_FOUND",S}var _=i[h]={exports:{}};r[h][0].call(_.exports,function(L){var U=r[h][1][L];return o(U||L)},_,_.exports,n,r,i,a)}return i[h].exports}for(var u=typeof pt=="function"&&pt,d=0;d<a.length;d++)o(a[d]);return o}({1:[function(n,r,i){(function(a){var o=a.MutationObserver||a.WebKitMutationObserver,u;if(o){var d=0,h=new o(L),p=a.document.createTextNode("");h.observe(p,{characterData:!0}),u=function(){p.data=d=++d%2}}else if(!a.setImmediate&&typeof a.MessageChannel<"u"){var f=new a.MessageChannel;f.port1.onmessage=L,u=function(){f.port2.postMessage(0)}}else"document"in a&&"onreadystatechange"in a.document.createElement("script")?u=function(){var H=a.document.createElement("script");H.onreadystatechange=function(){L(),H.onreadystatechange=null,H.parentNode.removeChild(H),H=null},a.document.documentElement.appendChild(H)}:u=function(){setTimeout(L,0)};var S,_=[];function L(){S=!0;for(var H,A,k=_.length;k;){for(A=_,_=[],H=-1;++H<k;)A[H]();k=_.length}S=!1}r.exports=U;function U(H){_.push(H)===1&&!S&&u()}}).call(this,typeof k1<"u"?k1:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,r,i){var a=n(1);function o(){}var u={},d=["REJECTED"],h=["FULFILLED"],p=["PENDING"];r.exports=f;function f(M){if(typeof M!="function")throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,M!==o&&U(this,M)}f.prototype.catch=function(M){return this.then(null,M)},f.prototype.then=function(M,V){if(typeof M!="function"&&this.state===h||typeof V!="function"&&this.state===d)return this;var R=new this.constructor(o);if(this.state!==p){var N=this.state===h?M:V;_(R,N,this.outcome)}else this.queue.push(new S(R,M,V));return R};function S(M,V,R){this.promise=M,typeof V=="function"&&(this.onFulfilled=V,this.callFulfilled=this.otherCallFulfilled),typeof R=="function"&&(this.onRejected=R,this.callRejected=this.otherCallRejected)}S.prototype.callFulfilled=function(M){u.resolve(this.promise,M)},S.prototype.otherCallFulfilled=function(M){_(this.promise,this.onFulfilled,M)},S.prototype.callRejected=function(M){u.reject(this.promise,M)},S.prototype.otherCallRejected=function(M){_(this.promise,this.onRejected,M)};function _(M,V,R){a(function(){var N;try{N=V(R)}catch($){return u.reject(M,$)}N===M?u.reject(M,new TypeError("Cannot resolve promise with itself")):u.resolve(M,N)})}u.resolve=function(M,V){var R=H(L,V);if(R.status==="error")return u.reject(M,R.value);var N=R.value;if(N)U(M,N);else{M.state=h,M.outcome=V;for(var $=-1,q=M.queue.length;++$<q;)M.queue[$].callFulfilled(V)}return M},u.reject=function(M,V){M.state=d,M.outcome=V;for(var R=-1,N=M.queue.length;++R<N;)M.queue[R].callRejected(V);return M};function L(M){var V=M&&M.then;if(M&&(typeof M=="object"||typeof M=="function")&&typeof V=="function")return function(){V.apply(M,arguments)}}function U(M,V){var R=!1;function N(J){R||(R=!0,u.reject(M,J))}function $(J){R||(R=!0,u.resolve(M,J))}function q(){V($,N)}var Z=H(q);Z.status==="error"&&N(Z.value)}function H(M,V){var R={};try{R.value=M(V),R.status="success"}catch(N){R.status="error",R.value=N}return R}f.resolve=A;function A(M){return M instanceof this?M:u.resolve(new this(o),M)}f.reject=k;function k(M){var V=new this(o);return u.reject(V,M)}f.all=F;function F(M){var V=this;if(Object.prototype.toString.call(M)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=M.length,N=!1;if(!R)return this.resolve([]);for(var $=new Array(R),q=0,Z=-1,J=new this(o);++Z<R;)K(M[Z],Z);return J;function K(me,fe){V.resolve(me).then(ae,function(pe){N||(N=!0,u.reject(J,pe))});function ae(pe){$[fe]=pe,++q===R&&!N&&(N=!0,u.resolve(J,$))}}}f.race=G;function G(M){var V=this;if(Object.prototype.toString.call(M)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=M.length,N=!1;if(!R)return this.resolve([]);for(var $=-1,q=new this(o);++$<R;)Z(M[$]);return q;function Z(J){V.resolve(J).then(function(K){N||(N=!0,u.resolve(q,K))},function(K){N||(N=!0,u.reject(q,K))})}}},{1:1}],3:[function(n,r,i){(function(a){typeof a.Promise!="function"&&(a.Promise=n(2))}).call(this,typeof k1<"u"?k1:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,r,i){var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l};function o(l,m){if(!(l instanceof m))throw new TypeError("Cannot call a class as a function")}function u(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var d=u();function h(){try{if(!d||!d.open)return!1;var l=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),m=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!l||m)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function p(l,m){l=l||[],m=m||{};try{return new Blob(l,m)}catch(g){if(g.name!=="TypeError")throw g;for(var c=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,C=new c,b=0;b<l.length;b+=1)C.append(l[b]);return C.getBlob(m.type)}}typeof Promise>"u"&&n(3);var f=Promise;function S(l,m){m&&l.then(function(c){m(null,c)},function(c){m(c)})}function _(l,m,c){typeof m=="function"&&l.then(m),typeof c=="function"&&l.catch(c)}function L(l){return typeof l!="string"&&(console.warn(l+" used as a key, but it is not a string."),l=String(l)),l}function U(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var H="local-forage-detect-blob-support",A=void 0,k={},F=Object.prototype.toString,G="readonly",M="readwrite";function V(l){for(var m=l.length,c=new ArrayBuffer(m),C=new Uint8Array(c),b=0;b<m;b++)C[b]=l.charCodeAt(b);return c}function R(l){return new f(function(m){var c=l.transaction(H,M),C=p([""]);c.objectStore(H).put(C,"key"),c.onabort=function(b){b.preventDefault(),b.stopPropagation(),m(!1)},c.oncomplete=function(){var b=navigator.userAgent.match(/Chrome\/(\d+)/),g=navigator.userAgent.match(/Edge\//);m(g||!b||parseInt(b[1],10)>=43)}}).catch(function(){return!1})}function N(l){return typeof A=="boolean"?f.resolve(A):R(l).then(function(m){return A=m,A})}function $(l){var m=k[l.name],c={};c.promise=new f(function(C,b){c.resolve=C,c.reject=b}),m.deferredOperations.push(c),m.dbReady?m.dbReady=m.dbReady.then(function(){return c.promise}):m.dbReady=c.promise}function q(l){var m=k[l.name],c=m.deferredOperations.pop();if(c)return c.resolve(),c.promise}function Z(l,m){var c=k[l.name],C=c.deferredOperations.pop();if(C)return C.reject(m),C.promise}function J(l,m){return new f(function(c,C){if(k[l.name]=k[l.name]||Y(),l.db)if(m)$(l),l.db.close();else return c(l.db);var b=[l.name];m&&b.push(l.version);var g=d.open.apply(d,b);m&&(g.onupgradeneeded=function(I){var x=g.result;try{x.createObjectStore(l.storeName),I.oldVersion<=1&&x.createObjectStore(H)}catch(P){if(P.name==="ConstraintError")console.warn('The database "'+l.name+'" has been upgraded from version '+I.oldVersion+" to version "+I.newVersion+', but the storage "'+l.storeName+'" already exists.');else throw P}}),g.onerror=function(I){I.preventDefault(),C(g.error)},g.onsuccess=function(){var I=g.result;I.onversionchange=function(x){x.target.close()},c(I),q(l)}})}function K(l){return J(l,!1)}function me(l){return J(l,!0)}function fe(l,m){if(!l.db)return!0;var c=!l.db.objectStoreNames.contains(l.storeName),C=l.version<l.db.version,b=l.version>l.db.version;if(C&&(l.version!==m&&console.warn('The database "'+l.name+`" can't be downgraded from version `+l.db.version+" to version "+l.version+"."),l.version=l.db.version),b||c){if(c){var g=l.db.version+1;g>l.version&&(l.version=g)}return!0}return!1}function ae(l){return new f(function(m,c){var C=new FileReader;C.onerror=c,C.onloadend=function(b){var g=btoa(b.target.result||"");m({__local_forage_encoded_blob:!0,data:g,type:l.type})},C.readAsBinaryString(l)})}function pe(l){var m=V(atob(l.data));return p([m],{type:l.type})}function Ee(l){return l&&l.__local_forage_encoded_blob}function O(l){var m=this,c=m._initReady().then(function(){var C=k[m._dbInfo.name];if(C&&C.dbReady)return C.dbReady});return _(c,l,l),c}function w(l){$(l);for(var m=k[l.name],c=m.forages,C=0;C<c.length;C++){var b=c[C];b._dbInfo.db&&(b._dbInfo.db.close(),b._dbInfo.db=null)}return l.db=null,K(l).then(function(g){return l.db=g,fe(l)?me(l):g}).then(function(g){l.db=m.db=g;for(var I=0;I<c.length;I++)c[I]._dbInfo.db=g}).catch(function(g){throw Z(l,g),g})}function D(l,m,c,C){C===void 0&&(C=1);try{var b=l.db.transaction(l.storeName,m);c(null,b)}catch(g){if(C>0&&(!l.db||g.name==="InvalidStateError"||g.name==="NotFoundError"))return f.resolve().then(function(){if(!l.db||g.name==="NotFoundError"&&!l.db.objectStoreNames.contains(l.storeName)&&l.version<=l.db.version)return l.db&&(l.version=l.db.version+1),me(l)}).then(function(){return w(l).then(function(){D(l,m,c,C-1)})}).catch(c);c(g)}}function Y(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function W(l){var m=this,c={db:null};if(l)for(var C in l)c[C]=l[C];var b=k[c.name];b||(b=Y(),k[c.name]=b),b.forages.push(m),m._initReady||(m._initReady=m.ready,m.ready=O);var g=[];function I(){return f.resolve()}for(var x=0;x<b.forages.length;x++){var P=b.forages[x];P!==m&&g.push(P._initReady().catch(I))}var j=b.forages.slice(0);return f.all(g).then(function(){return c.db=b.db,K(c)}).then(function(B){return c.db=B,fe(c,m._defaultConfig.version)?me(c):B}).then(function(B){c.db=b.db=B,m._dbInfo=c;for(var Q=0;Q<j.length;Q++){var ue=j[Q];ue!==m&&(ue._dbInfo.db=c.db,ue._dbInfo.version=c.version)}})}function X(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){D(c._dbInfo,G,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=P.get(l);j.onsuccess=function(){var B=j.result;B===void 0&&(B=null),Ee(B)&&(B=pe(B)),b(B)},j.onerror=function(){g(j.error)}}catch(B){g(B)}})}).catch(g)});return S(C,m),C}function ie(l,m){var c=this,C=new f(function(b,g){c.ready().then(function(){D(c._dbInfo,G,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=P.openCursor(),B=1;j.onsuccess=function(){var Q=j.result;if(Q){var ue=Q.value;Ee(ue)&&(ue=pe(ue));var Se=l(ue,Q.key,B++);Se!==void 0?b(Se):Q.continue()}else b()},j.onerror=function(){g(j.error)}}catch(Q){g(Q)}})}).catch(g)});return S(C,m),C}function oe(l,m,c){var C=this;l=L(l);var b=new f(function(g,I){var x;C.ready().then(function(){return x=C._dbInfo,F.call(m)==="[object Blob]"?N(x.db).then(function(P){return P?m:ae(m)}):m}).then(function(P){D(C._dbInfo,M,function(j,B){if(j)return I(j);try{var Q=B.objectStore(C._dbInfo.storeName);P===null&&(P=void 0);var ue=Q.put(P,l);B.oncomplete=function(){P===void 0&&(P=null),g(P)},B.onabort=B.onerror=function(){var Se=ue.error?ue.error:ue.transaction.error;I(Se)}}catch(Se){I(Se)}})}).catch(I)});return S(b,c),b}function Le(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){D(c._dbInfo,M,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=P.delete(l);x.oncomplete=function(){b()},x.onerror=function(){g(j.error)},x.onabort=function(){var B=j.error?j.error:j.transaction.error;g(B)}}catch(B){g(B)}})}).catch(g)});return S(C,m),C}function xe(l){var m=this,c=new f(function(C,b){m.ready().then(function(){D(m._dbInfo,M,function(g,I){if(g)return b(g);try{var x=I.objectStore(m._dbInfo.storeName),P=x.clear();I.oncomplete=function(){C()},I.onabort=I.onerror=function(){var j=P.error?P.error:P.transaction.error;b(j)}}catch(j){b(j)}})}).catch(b)});return S(c,l),c}function Ie(l){var m=this,c=new f(function(C,b){m.ready().then(function(){D(m._dbInfo,G,function(g,I){if(g)return b(g);try{var x=I.objectStore(m._dbInfo.storeName),P=x.count();P.onsuccess=function(){C(P.result)},P.onerror=function(){b(P.error)}}catch(j){b(j)}})}).catch(b)});return S(c,l),c}function we(l,m){var c=this,C=new f(function(b,g){if(l<0){b(null);return}c.ready().then(function(){D(c._dbInfo,G,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=!1,B=P.openKeyCursor();B.onsuccess=function(){var Q=B.result;if(!Q){b(null);return}l===0||j?b(Q.key):(j=!0,Q.advance(l))},B.onerror=function(){g(B.error)}}catch(Q){g(Q)}})}).catch(g)});return S(C,m),C}function Je(l){var m=this,c=new f(function(C,b){m.ready().then(function(){D(m._dbInfo,G,function(g,I){if(g)return b(g);try{var x=I.objectStore(m._dbInfo.storeName),P=x.openKeyCursor(),j=[];P.onsuccess=function(){var B=P.result;if(!B){C(j);return}j.push(B.key),B.continue()},P.onerror=function(){b(P.error)}}catch(B){b(B)}})}).catch(b)});return S(c,l),c}function Ge(l,m){m=U.apply(this,arguments);var c=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||c.name,l.storeName=l.storeName||c.storeName);var C=this,b;if(!l.name)b=f.reject("Invalid arguments");else{var g=l.name===c.name&&C._dbInfo.db,I=g?f.resolve(C._dbInfo.db):K(l).then(function(x){var P=k[l.name],j=P.forages;P.db=x;for(var B=0;B<j.length;B++)j[B]._dbInfo.db=x;return x});l.storeName?b=I.then(function(x){if(x.objectStoreNames.contains(l.storeName)){var P=x.version+1;$(l);var j=k[l.name],B=j.forages;x.close();for(var Q=0;Q<B.length;Q++){var ue=B[Q];ue._dbInfo.db=null,ue._dbInfo.version=P}var Se=new f(function(_e,De){var Oe=d.open(l.name,P);Oe.onerror=function(Ye){var x1=Oe.result;x1.close(),De(Ye)},Oe.onupgradeneeded=function(){var Ye=Oe.result;Ye.deleteObjectStore(l.storeName)},Oe.onsuccess=function(){var Ye=Oe.result;Ye.close(),_e(Ye)}});return Se.then(function(_e){j.db=_e;for(var De=0;De<B.length;De++){var Oe=B[De];Oe._dbInfo.db=_e,q(Oe._dbInfo)}}).catch(function(_e){throw(Z(l,_e)||f.resolve()).catch(function(){}),_e})}}):b=I.then(function(x){$(l);var P=k[l.name],j=P.forages;x.close();for(var B=0;B<j.length;B++){var Q=j[B];Q._dbInfo.db=null}var ue=new f(function(Se,_e){var De=d.deleteDatabase(l.name);De.onerror=function(){var Oe=De.result;Oe&&Oe.close(),_e(De.error)},De.onblocked=function(){console.warn('dropInstance blocked for database "'+l.name+'" until all open connections are closed')},De.onsuccess=function(){var Oe=De.result;Oe&&Oe.close(),Se(Oe)}});return ue.then(function(Se){P.db=Se;for(var _e=0;_e<j.length;_e++){var De=j[_e];q(De._dbInfo)}}).catch(function(Se){throw(Z(l,Se)||f.resolve()).catch(function(){}),Se})})}return S(b,m),b}var Be={_driver:"asyncStorage",_initStorage:W,_support:h(),iterate:ie,getItem:X,setItem:oe,removeItem:Le,clear:xe,length:Ie,key:we,keys:Je,dropInstance:Ge};function ce(){return typeof openDatabase=="function"}var re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ye="~~local_forage_type~",Ue=/^~~local_forage_type~([^~]+)~/,He="__lfsc__:",Me=He.length,he="arbf",ve="blob",Pe="si08",e1="ui08",d1="uic8",t1="si16",St="si32",oi="ur16",si="ui32",li="fl32",ci="fl64",ui=Me+he.length,fi=Object.prototype.toString;function di(l){var m=l.length*.75,c=l.length,C,b=0,g,I,x,P;l[l.length-1]==="="&&(m--,l[l.length-2]==="="&&m--);var j=new ArrayBuffer(m),B=new Uint8Array(j);for(C=0;C<c;C+=4)g=re.indexOf(l[C]),I=re.indexOf(l[C+1]),x=re.indexOf(l[C+2]),P=re.indexOf(l[C+3]),B[b++]=g<<2|I>>4,B[b++]=(I&15)<<4|x>>2,B[b++]=(x&3)<<6|P&63;return j}function fn(l){var m=new Uint8Array(l),c="",C;for(C=0;C<m.length;C+=3)c+=re[m[C]>>2],c+=re[(m[C]&3)<<4|m[C+1]>>4],c+=re[(m[C+1]&15)<<2|m[C+2]>>6],c+=re[m[C+2]&63];return m.length%3===2?c=c.substring(0,c.length-1)+"=":m.length%3===1&&(c=c.substring(0,c.length-2)+"=="),c}function X4(l,m){var c="";if(l&&(c=fi.call(l)),l&&(c==="[object ArrayBuffer]"||l.buffer&&fi.call(l.buffer)==="[object ArrayBuffer]")){var C,b=He;l instanceof ArrayBuffer?(C=l,b+=he):(C=l.buffer,c==="[object Int8Array]"?b+=Pe:c==="[object Uint8Array]"?b+=e1:c==="[object Uint8ClampedArray]"?b+=d1:c==="[object Int16Array]"?b+=t1:c==="[object Uint16Array]"?b+=oi:c==="[object Int32Array]"?b+=St:c==="[object Uint32Array]"?b+=si:c==="[object Float32Array]"?b+=li:c==="[object Float64Array]"?b+=ci:m(new Error("Failed to get type for BinaryArray"))),m(b+fn(C))}else if(c==="[object Blob]"){var g=new FileReader;g.onload=function(){var I=ye+l.type+"~"+fn(this.result);m(He+ve+I)},g.readAsArrayBuffer(l)}else try{m(JSON.stringify(l))}catch(I){console.error("Couldn't convert value into a JSON string: ",l),m(null,I)}}function Q4(l){if(l.substring(0,Me)!==He)return JSON.parse(l);var m=l.substring(ui),c=l.substring(Me,ui),C;if(c===ve&&Ue.test(m)){var b=m.match(Ue);C=b[1],m=m.substring(b[0].length)}var g=di(m);switch(c){case he:return g;case ve:return p([g],{type:C});case Pe:return new Int8Array(g);case e1:return new Uint8Array(g);case d1:return new Uint8ClampedArray(g);case t1:return new Int16Array(g);case oi:return new Uint16Array(g);case St:return new Int32Array(g);case si:return new Uint32Array(g);case li:return new Float32Array(g);case ci:return new Float64Array(g);default:throw new Error("Unkown type: "+c)}}var dn={serialize:X4,deserialize:Q4,stringToBuffer:di,bufferToString:fn};function hi(l,m,c,C){l.executeSql("CREATE TABLE IF NOT EXISTS "+m.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],c,C)}function J4(l){var m=this,c={db:null};if(l)for(var C in l)c[C]=typeof l[C]!="string"?l[C].toString():l[C];var b=new f(function(g,I){try{c.db=openDatabase(c.name,String(c.version),c.description,c.size)}catch(x){return I(x)}c.db.transaction(function(x){hi(x,c,function(){m._dbInfo=c,g()},function(P,j){I(j)})},I)});return c.serializer=dn,b}function o1(l,m,c,C,b,g){l.executeSql(c,C,b,function(I,x){x.code===x.SYNTAX_ERR?I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[m.storeName],function(P,j){j.rows.length?g(P,x):hi(P,m,function(){P.executeSql(c,C,b,g)},g)},g):g(I,x)},g)}function K4(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"SELECT * FROM "+I.storeName+" WHERE key = ? LIMIT 1",[l],function(P,j){var B=j.rows.length?j.rows.item(0).value:null;B&&(B=I.serializer.deserialize(B)),b(B)},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function e5(l,m){var c=this,C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"SELECT * FROM "+I.storeName,[],function(P,j){for(var B=j.rows,Q=B.length,ue=0;ue<Q;ue++){var Se=B.item(ue),_e=Se.value;if(_e&&(_e=I.serializer.deserialize(_e)),_e=l(_e,Se.key,ue+1),_e!==void 0){b(_e);return}}b()},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function mi(l,m,c,C){var b=this;l=L(l);var g=new f(function(I,x){b.ready().then(function(){m===void 0&&(m=null);var P=m,j=b._dbInfo;j.serializer.serialize(m,function(B,Q){Q?x(Q):j.db.transaction(function(ue){o1(ue,j,"INSERT OR REPLACE INTO "+j.storeName+" (key, value) VALUES (?, ?)",[l,B],function(){I(P)},function(Se,_e){x(_e)})},function(ue){if(ue.code===ue.QUOTA_ERR){if(C>0){I(mi.apply(b,[l,P,c,C-1]));return}x(ue)}})})}).catch(x)});return S(g,c),g}function t5(l,m,c){return mi.apply(this,[l,m,c,1])}function n5(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"DELETE FROM "+I.storeName+" WHERE key = ?",[l],function(){b()},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function r5(l){var m=this,c=new f(function(C,b){m.ready().then(function(){var g=m._dbInfo;g.db.transaction(function(I){o1(I,g,"DELETE FROM "+g.storeName,[],function(){C()},function(x,P){b(P)})})}).catch(b)});return S(c,l),c}function i5(l){var m=this,c=new f(function(C,b){m.ready().then(function(){var g=m._dbInfo;g.db.transaction(function(I){o1(I,g,"SELECT COUNT(key) as c FROM "+g.storeName,[],function(x,P){var j=P.rows.item(0).c;C(j)},function(x,P){b(P)})})}).catch(b)});return S(c,l),c}function a5(l,m){var c=this,C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"SELECT key FROM "+I.storeName+" WHERE id = ? LIMIT 1",[l+1],function(P,j){var B=j.rows.length?j.rows.item(0).key:null;b(B)},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function o5(l){var m=this,c=new f(function(C,b){m.ready().then(function(){var g=m._dbInfo;g.db.transaction(function(I){o1(I,g,"SELECT key FROM "+g.storeName,[],function(x,P){for(var j=[],B=0;B<P.rows.length;B++)j.push(P.rows.item(B).key);C(j)},function(x,P){b(P)})})}).catch(b)});return S(c,l),c}function s5(l){return new f(function(m,c){l.transaction(function(C){C.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(b,g){for(var I=[],x=0;x<g.rows.length;x++)I.push(g.rows.item(x).name);m({db:l,storeNames:I})},function(b,g){c(g)})},function(C){c(C)})})}function l5(l,m){m=U.apply(this,arguments);var c=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||c.name,l.storeName=l.storeName||c.storeName);var C=this,b;return l.name?b=new f(function(g){var I;l.name===c.name?I=C._dbInfo.db:I=openDatabase(l.name,"","",0),l.storeName?g({db:I,storeNames:[l.storeName]}):g(s5(I))}).then(function(g){return new f(function(I,x){g.db.transaction(function(P){function j(Se){return new f(function(_e,De){P.executeSql("DROP TABLE IF EXISTS "+Se,[],function(){_e()},function(Oe,Ye){De(Ye)})})}for(var B=[],Q=0,ue=g.storeNames.length;Q<ue;Q++)B.push(j(g.storeNames[Q]));f.all(B).then(function(){I()}).catch(function(Se){x(Se)})},function(P){x(P)})})}):b=f.reject("Invalid arguments"),S(b,m),b}var c5={_driver:"webSQLStorage",_initStorage:J4,_support:ce(),iterate:e5,getItem:K4,setItem:t5,removeItem:n5,clear:r5,length:i5,key:a5,keys:o5,dropInstance:l5};function u5(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function pi(l,m){var c=l.name+"/";return l.storeName!==m.storeName&&(c+=l.storeName+"/"),c}function f5(){var l="_localforage_support_test";try{return localStorage.setItem(l,!0),localStorage.removeItem(l),!1}catch{return!0}}function d5(){return!f5()||localStorage.length>0}function h5(l){var m=this,c={};if(l)for(var C in l)c[C]=l[C];return c.keyPrefix=pi(l,m._defaultConfig),d5()?(m._dbInfo=c,c.serializer=dn,f.resolve()):f.reject()}function m5(l){var m=this,c=m.ready().then(function(){for(var C=m._dbInfo.keyPrefix,b=localStorage.length-1;b>=0;b--){var g=localStorage.key(b);g.indexOf(C)===0&&localStorage.removeItem(g)}});return S(c,l),c}function p5(l,m){var c=this;l=L(l);var C=c.ready().then(function(){var b=c._dbInfo,g=localStorage.getItem(b.keyPrefix+l);return g&&(g=b.serializer.deserialize(g)),g});return S(C,m),C}function g5(l,m){var c=this,C=c.ready().then(function(){for(var b=c._dbInfo,g=b.keyPrefix,I=g.length,x=localStorage.length,P=1,j=0;j<x;j++){var B=localStorage.key(j);if(B.indexOf(g)===0){var Q=localStorage.getItem(B);if(Q&&(Q=b.serializer.deserialize(Q)),Q=l(Q,B.substring(I),P++),Q!==void 0)return Q}}});return S(C,m),C}function v5(l,m){var c=this,C=c.ready().then(function(){var b=c._dbInfo,g;try{g=localStorage.key(l)}catch{g=null}return g&&(g=g.substring(b.keyPrefix.length)),g});return S(C,m),C}function C5(l){var m=this,c=m.ready().then(function(){for(var C=m._dbInfo,b=localStorage.length,g=[],I=0;I<b;I++){var x=localStorage.key(I);x.indexOf(C.keyPrefix)===0&&g.push(x.substring(C.keyPrefix.length))}return g});return S(c,l),c}function S5(l){var m=this,c=m.keys().then(function(C){return C.length});return S(c,l),c}function b5(l,m){var c=this;l=L(l);var C=c.ready().then(function(){var b=c._dbInfo;localStorage.removeItem(b.keyPrefix+l)});return S(C,m),C}function y5(l,m,c){var C=this;l=L(l);var b=C.ready().then(function(){m===void 0&&(m=null);var g=m;return new f(function(I,x){var P=C._dbInfo;P.serializer.serialize(m,function(j,B){if(B)x(B);else try{localStorage.setItem(P.keyPrefix+l,j),I(g)}catch(Q){(Q.name==="QuotaExceededError"||Q.name==="NS_ERROR_DOM_QUOTA_REACHED")&&x(Q),x(Q)}})})});return S(b,c),b}function _5(l,m){if(m=U.apply(this,arguments),l=typeof l!="function"&&l||{},!l.name){var c=this.config();l.name=l.name||c.name,l.storeName=l.storeName||c.storeName}var C=this,b;return l.name?b=new f(function(g){l.storeName?g(pi(l,C._defaultConfig)):g(l.name+"/")}).then(function(g){for(var I=localStorage.length-1;I>=0;I--){var x=localStorage.key(I);x.indexOf(g)===0&&localStorage.removeItem(x)}}):b=f.reject("Invalid arguments"),S(b,m),b}var L5={_driver:"localStorageWrapper",_initStorage:h5,_support:u5(),iterate:g5,getItem:p5,setItem:y5,removeItem:b5,clear:m5,length:S5,key:v5,keys:C5,dropInstance:_5},E5=function(m,c){return m===c||typeof m=="number"&&typeof c=="number"&&isNaN(m)&&isNaN(c)},w5=function(m,c){for(var C=m.length,b=0;b<C;){if(E5(m[b],c))return!0;b++}return!1},gi=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"},T1={},vi={},b1={INDEXEDDB:Be,WEBSQL:c5,LOCALSTORAGE:L5},M5=[b1.INDEXEDDB._driver,b1.WEBSQL._driver,b1.LOCALSTORAGE._driver],bt=["dropInstance"],hn=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(bt),O5={description:"",driver:M5.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function I5(l,m){l[m]=function(){var c=arguments;return l.ready().then(function(){return l[m].apply(l,c)})}}function mn(){for(var l=1;l<arguments.length;l++){var m=arguments[l];if(m)for(var c in m)m.hasOwnProperty(c)&&(gi(m[c])?arguments[0][c]=m[c].slice():arguments[0][c]=m[c])}return arguments[0]}var H5=function(){function l(m){o(this,l);for(var c in b1)if(b1.hasOwnProperty(c)){var C=b1[c],b=C._driver;this[c]=b,T1[b]||this.defineDriver(C)}this._defaultConfig=mn({},O5),this._config=mn({},this._defaultConfig,m),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return l.prototype.config=function(c){if((typeof c>"u"?"undefined":a(c))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var C in c){if(C==="storeName"&&(c[C]=c[C].replace(/\W/g,"_")),C==="version"&&typeof c[C]!="number")return new Error("Database version must be a number.");this._config[C]=c[C]}return"driver"in c&&c.driver?this.setDriver(this._config.driver):!0}else return typeof c=="string"?this._config[c]:this._config},l.prototype.defineDriver=function(c,C,b){var g=new f(function(I,x){try{var P=c._driver,j=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!c._driver){x(j);return}for(var B=hn.concat("_initStorage"),Q=0,ue=B.length;Q<ue;Q++){var Se=B[Q],_e=!w5(bt,Se);if((_e||c[Se])&&typeof c[Se]!="function"){x(j);return}}var De=function(){for(var x1=function(x5){return function(){var V5=new Error("Method "+x5+" is not implemented by the current driver"),Ci=f.reject(V5);return S(Ci,arguments[arguments.length-1]),Ci}},pn=0,T5=bt.length;pn<T5;pn++){var gn=bt[pn];c[gn]||(c[gn]=x1(gn))}};De();var Oe=function(x1){T1[P]&&console.info("Redefining LocalForage driver: "+P),T1[P]=c,vi[P]=x1,I()};"_support"in c?c._support&&typeof c._support=="function"?c._support().then(Oe,x):Oe(!!c._support):Oe(!0)}catch(Ye){x(Ye)}});return _(g,C,b),g},l.prototype.driver=function(){return this._driver||null},l.prototype.getDriver=function(c,C,b){var g=T1[c]?f.resolve(T1[c]):f.reject(new Error("Driver not found."));return _(g,C,b),g},l.prototype.getSerializer=function(c){var C=f.resolve(dn);return _(C,c),C},l.prototype.ready=function(c){var C=this,b=C._driverSet.then(function(){return C._ready===null&&(C._ready=C._initDriver()),C._ready});return _(b,c,c),b},l.prototype.setDriver=function(c,C,b){var g=this;gi(c)||(c=[c]);var I=this._getSupportedDrivers(c);function x(){g._config.driver=g.driver()}function P(Q){return g._extend(Q),x(),g._ready=g._initStorage(g._config),g._ready}function j(Q){return function(){var ue=0;function Se(){for(;ue<Q.length;){var _e=Q[ue];return ue++,g._dbInfo=null,g._ready=null,g.getDriver(_e).then(P).catch(Se)}x();var De=new Error("No available storage method found.");return g._driverSet=f.reject(De),g._driverSet}return Se()}}var B=this._driverSet!==null?this._driverSet.catch(function(){return f.resolve()}):f.resolve();return this._driverSet=B.then(function(){var Q=I[0];return g._dbInfo=null,g._ready=null,g.getDriver(Q).then(function(ue){g._driver=ue._driver,x(),g._wrapLibraryMethodsWithReady(),g._initDriver=j(I)})}).catch(function(){x();var Q=new Error("No available storage method found.");return g._driverSet=f.reject(Q),g._driverSet}),_(this._driverSet,C,b),this._driverSet},l.prototype.supports=function(c){return!!vi[c]},l.prototype._extend=function(c){mn(this,c)},l.prototype._getSupportedDrivers=function(c){for(var C=[],b=0,g=c.length;b<g;b++){var I=c[b];this.supports(I)&&C.push(I)}return C},l.prototype._wrapLibraryMethodsWithReady=function(){for(var c=0,C=hn.length;c<C;c++)I5(this,hn[c])},l.prototype.createInstance=function(c){return new l(c)},l}(),D5=new H5;r.exports=D5},{3:3}]},{},[4])(4)})})(Y6);var M4=Y6.exports;const f1=vr(M4);class q6{getItem(t){return f1.getItem(t)}setItem(t,n){return f1.setItem(t,n)}removeItem(t){return f1.removeItem(t)}clear(){return f1.clear()}key(t){return f1.key(t)}keys(){return f1.keys()}iterate(t){return f1.iterate(t)}}var O4=Object.defineProperty,I4=Object.getOwnPropertyDescriptor,H4=(e,t,n,r)=>{for(var i=r>1?void 0:r?I4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&O4(t,n,i),i},D4=(e,t)=>(n,r)=>t(n,r,e);let nn=class{constructor(e){z(this,"visible$",new ee.Subject);z(this,"componentKey$",new ee.Subject);this._componentManager=e}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),y.toDisposable(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}};nn=H4([D4(0,se.Inject(Ke))],nn);class T4 extends y.Disposable{constructor(){super(...arguments);z(this,"_currentSelectorId");z(this,"_selectionChange$",new ee.Subject);z(this,"selectionChange$",this._selectionChange$.asObservable());z(this,"_openSelector$",new ee.Subject);z(this,"openSelector$",this._openSelector$.asObservable())}setCurrentSelectorId(n){this._currentSelectorId=n}getCurrentSelectorId(){return this._currentSelectorId}selectionChange(n){this._currentSelectorId&&this._selectionChange$.next(n)}openSelector(){this._openSelector$.next(null)}}const rn=se.createIdentifier("univer.range-selector.service");class x4 extends y.Disposable{constructor(){super(...arguments);z(this,"_taskCount",0);z(this,"_progressChange$",new ee.Subject);z(this,"_progressVisible$",new ee.Subject);z(this,"progressChange$",this._progressChange$.asObservable());z(this,"progressVisible$",this._progressVisible$.asObservable())}dispose(){super.dispose(),this._clear(),this._progressChange$.complete(),this._progressVisible$.complete()}pushTask(n){if(this._taskCount===0)return;const{count:r}=n;if(r<=0)return;const i=Math.min(1,r/this._taskCount);this._progressChange$.next({step:i}),this._taskCount-=r,this._taskCount<0&&(this._taskCount=0),this._taskCount===0&&this._progressVisible$.next(!1)}insertTaskCount(n){n<=0||(this._taskCount===0&&this._progressVisible$.next(!0),this._taskCount+=n)}complete(){this._taskCount!==0&&(this._progressChange$.next({step:1}),this._clear(),this._progressVisible$.next(!1))}stop(){this._taskCount!==0&&(this._clear(),this._progressVisible$.next(!1))}_clear(){this._taskCount=0}}const an=se.createIdentifier("univer.progress.service");var V4=Object.defineProperty,N4=Object.getOwnPropertyDescriptor,k4=(e,t,n,r)=>{for(var i=r>1?void 0:r?N4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&V4(t,n,i),i},on=(e,t)=>(n,r)=>t(n,r,e);const A4="ui",X6="DISABLE_AUTO_FOCUS";E.UniverUIPlugin=(un=class extends y.Plugin{constructor(t={},n,r,i){super(),this._config=t,this._contextService=n,this._injector=r,this._localeService=i,this._localeService.load({zhCN:A6}),this._config.disableAutoFocus&&this._contextService.setContextValue(X6,!0)}onStarting(t){this._initDependencies(t),this._initUI()}_initDependencies(t){[[Ke],[N1],[W6],[L1,{useClass:E.DesktopLayoutService}],[m1,{useClass:E.DesktopShortcutService}],[Lt,{useClass:Er}],[s1,{useClass:E.DesktopMenuService}],[Yt,{useClass:T6}],[U6,{useClass:E.BrowserClipboardService,lazy:!0}],[dt,{useClass:z6,lazy:!0}],[qt,{useClass:$6,lazy:!0}],[Gt,{useClass:j6,lazy:!0}],[Y1,{useClass:F6,lazy:!0}],[Dt,{useClass:nn,lazy:!0}],[Xt,{useClass:E.DesktopGlobalZoneService,lazy:!0}],[G1,{useClass:B6,lazy:!0}],[y.ILocalStorageService,{useClass:q6,lazy:!0}],[R6,{useClass:E.DesktopBeforeCloseService}],[_1,{useClass:E.EditorService}],[rn,{useClass:T4}],[Qt,{useClass:V6}],[an,{useClass:x4}],[B1,{useClass:E.DesktopUIController}],[E.SharedController],[ht],[mt]].forEach(r=>t.add(r))}_initUI(){Promise.resolve().then(()=>this._injector.get(B1).bootstrapWorkbench(this._config))}},z(un,"pluginName",A4),un),E.UniverUIPlugin=k4([on(1,y.IConfigService),on(2,se.Inject(se.Injector)),on(3,se.Inject(y.LocaleService))],E.UniverUIPlugin);function gt(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,"")}const R4=.75,Q6=78,J6=9,K6="rgba(0,0,0,0)",ei="rgb(0,0,0)";function sn(e){var u;let t=e.childNodes;if(t.length===0)return e.textContent;if(t[0].nodeName==="DIV"&&(t=t[0].childNodes),t.length===1&&t[0].nodeName==="#text")return t[0].textContent;const n=[];let r=0,i=0,a=e.textContent||"";a+=`\r
46
+ */(function(e,t){(function(n){e.exports=n()})(function(){return function n(r,i,a){function o(h,p){if(!i[h]){if(!r[h]){var f=typeof pt=="function"&&pt;if(!p&&f)return f(h,!0);if(u)return u(h,!0);var S=new Error("Cannot find module '"+h+"'");throw S.code="MODULE_NOT_FOUND",S}var _=i[h]={exports:{}};r[h][0].call(_.exports,function(L){var U=r[h][1][L];return o(U||L)},_,_.exports,n,r,i,a)}return i[h].exports}for(var u=typeof pt=="function"&&pt,d=0;d<a.length;d++)o(a[d]);return o}({1:[function(n,r,i){(function(a){var o=a.MutationObserver||a.WebKitMutationObserver,u;if(o){var d=0,h=new o(L),p=a.document.createTextNode("");h.observe(p,{characterData:!0}),u=function(){p.data=d=++d%2}}else if(!a.setImmediate&&typeof a.MessageChannel<"u"){var f=new a.MessageChannel;f.port1.onmessage=L,u=function(){f.port2.postMessage(0)}}else"document"in a&&"onreadystatechange"in a.document.createElement("script")?u=function(){var H=a.document.createElement("script");H.onreadystatechange=function(){L(),H.onreadystatechange=null,H.parentNode.removeChild(H),H=null},a.document.documentElement.appendChild(H)}:u=function(){setTimeout(L,0)};var S,_=[];function L(){S=!0;for(var H,A,k=_.length;k;){for(A=_,_=[],H=-1;++H<k;)A[H]();k=_.length}S=!1}r.exports=U;function U(H){_.push(H)===1&&!S&&u()}}).call(this,typeof k1<"u"?k1:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,r,i){var a=n(1);function o(){}var u={},d=["REJECTED"],h=["FULFILLED"],p=["PENDING"];r.exports=f;function f(M){if(typeof M!="function")throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,M!==o&&U(this,M)}f.prototype.catch=function(M){return this.then(null,M)},f.prototype.then=function(M,V){if(typeof M!="function"&&this.state===h||typeof V!="function"&&this.state===d)return this;var R=new this.constructor(o);if(this.state!==p){var N=this.state===h?M:V;_(R,N,this.outcome)}else this.queue.push(new S(R,M,V));return R};function S(M,V,R){this.promise=M,typeof V=="function"&&(this.onFulfilled=V,this.callFulfilled=this.otherCallFulfilled),typeof R=="function"&&(this.onRejected=R,this.callRejected=this.otherCallRejected)}S.prototype.callFulfilled=function(M){u.resolve(this.promise,M)},S.prototype.otherCallFulfilled=function(M){_(this.promise,this.onFulfilled,M)},S.prototype.callRejected=function(M){u.reject(this.promise,M)},S.prototype.otherCallRejected=function(M){_(this.promise,this.onRejected,M)};function _(M,V,R){a(function(){var N;try{N=V(R)}catch($){return u.reject(M,$)}N===M?u.reject(M,new TypeError("Cannot resolve promise with itself")):u.resolve(M,N)})}u.resolve=function(M,V){var R=H(L,V);if(R.status==="error")return u.reject(M,R.value);var N=R.value;if(N)U(M,N);else{M.state=h,M.outcome=V;for(var $=-1,q=M.queue.length;++$<q;)M.queue[$].callFulfilled(V)}return M},u.reject=function(M,V){M.state=d,M.outcome=V;for(var R=-1,N=M.queue.length;++R<N;)M.queue[R].callRejected(V);return M};function L(M){var V=M&&M.then;if(M&&(typeof M=="object"||typeof M=="function")&&typeof V=="function")return function(){V.apply(M,arguments)}}function U(M,V){var R=!1;function N(J){R||(R=!0,u.reject(M,J))}function $(J){R||(R=!0,u.resolve(M,J))}function q(){V($,N)}var Z=H(q);Z.status==="error"&&N(Z.value)}function H(M,V){var R={};try{R.value=M(V),R.status="success"}catch(N){R.status="error",R.value=N}return R}f.resolve=A;function A(M){return M instanceof this?M:u.resolve(new this(o),M)}f.reject=k;function k(M){var V=new this(o);return u.reject(V,M)}f.all=F;function F(M){var V=this;if(Object.prototype.toString.call(M)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=M.length,N=!1;if(!R)return this.resolve([]);for(var $=new Array(R),q=0,Z=-1,J=new this(o);++Z<R;)K(M[Z],Z);return J;function K(me,fe){V.resolve(me).then(ae,function(pe){N||(N=!0,u.reject(J,pe))});function ae(pe){$[fe]=pe,++q===R&&!N&&(N=!0,u.resolve(J,$))}}}f.race=G;function G(M){var V=this;if(Object.prototype.toString.call(M)!=="[object Array]")return this.reject(new TypeError("must be an array"));var R=M.length,N=!1;if(!R)return this.resolve([]);for(var $=-1,q=new this(o);++$<R;)Z(M[$]);return q;function Z(J){V.resolve(J).then(function(K){N||(N=!0,u.resolve(q,K))},function(K){N||(N=!0,u.reject(q,K))})}}},{1:1}],3:[function(n,r,i){(function(a){typeof a.Promise!="function"&&(a.Promise=n(2))}).call(this,typeof k1<"u"?k1:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,r,i){var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l};function o(l,m){if(!(l instanceof m))throw new TypeError("Cannot call a class as a function")}function u(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var d=u();function h(){try{if(!d||!d.open)return!1;var l=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),m=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!l||m)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function p(l,m){l=l||[],m=m||{};try{return new Blob(l,m)}catch(g){if(g.name!=="TypeError")throw g;for(var c=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,C=new c,b=0;b<l.length;b+=1)C.append(l[b]);return C.getBlob(m.type)}}typeof Promise>"u"&&n(3);var f=Promise;function S(l,m){m&&l.then(function(c){m(null,c)},function(c){m(c)})}function _(l,m,c){typeof m=="function"&&l.then(m),typeof c=="function"&&l.catch(c)}function L(l){return typeof l!="string"&&(console.warn(l+" used as a key, but it is not a string."),l=String(l)),l}function U(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var H="local-forage-detect-blob-support",A=void 0,k={},F=Object.prototype.toString,G="readonly",M="readwrite";function V(l){for(var m=l.length,c=new ArrayBuffer(m),C=new Uint8Array(c),b=0;b<m;b++)C[b]=l.charCodeAt(b);return c}function R(l){return new f(function(m){var c=l.transaction(H,M),C=p([""]);c.objectStore(H).put(C,"key"),c.onabort=function(b){b.preventDefault(),b.stopPropagation(),m(!1)},c.oncomplete=function(){var b=navigator.userAgent.match(/Chrome\/(\d+)/),g=navigator.userAgent.match(/Edge\//);m(g||!b||parseInt(b[1],10)>=43)}}).catch(function(){return!1})}function N(l){return typeof A=="boolean"?f.resolve(A):R(l).then(function(m){return A=m,A})}function $(l){var m=k[l.name],c={};c.promise=new f(function(C,b){c.resolve=C,c.reject=b}),m.deferredOperations.push(c),m.dbReady?m.dbReady=m.dbReady.then(function(){return c.promise}):m.dbReady=c.promise}function q(l){var m=k[l.name],c=m.deferredOperations.pop();if(c)return c.resolve(),c.promise}function Z(l,m){var c=k[l.name],C=c.deferredOperations.pop();if(C)return C.reject(m),C.promise}function J(l,m){return new f(function(c,C){if(k[l.name]=k[l.name]||Y(),l.db)if(m)$(l),l.db.close();else return c(l.db);var b=[l.name];m&&b.push(l.version);var g=d.open.apply(d,b);m&&(g.onupgradeneeded=function(I){var x=g.result;try{x.createObjectStore(l.storeName),I.oldVersion<=1&&x.createObjectStore(H)}catch(P){if(P.name==="ConstraintError")console.warn('The database "'+l.name+'" has been upgraded from version '+I.oldVersion+" to version "+I.newVersion+', but the storage "'+l.storeName+'" already exists.');else throw P}}),g.onerror=function(I){I.preventDefault(),C(g.error)},g.onsuccess=function(){var I=g.result;I.onversionchange=function(x){x.target.close()},c(I),q(l)}})}function K(l){return J(l,!1)}function me(l){return J(l,!0)}function fe(l,m){if(!l.db)return!0;var c=!l.db.objectStoreNames.contains(l.storeName),C=l.version<l.db.version,b=l.version>l.db.version;if(C&&(l.version!==m&&console.warn('The database "'+l.name+`" can't be downgraded from version `+l.db.version+" to version "+l.version+"."),l.version=l.db.version),b||c){if(c){var g=l.db.version+1;g>l.version&&(l.version=g)}return!0}return!1}function ae(l){return new f(function(m,c){var C=new FileReader;C.onerror=c,C.onloadend=function(b){var g=btoa(b.target.result||"");m({__local_forage_encoded_blob:!0,data:g,type:l.type})},C.readAsBinaryString(l)})}function pe(l){var m=V(atob(l.data));return p([m],{type:l.type})}function Ee(l){return l&&l.__local_forage_encoded_blob}function O(l){var m=this,c=m._initReady().then(function(){var C=k[m._dbInfo.name];if(C&&C.dbReady)return C.dbReady});return _(c,l,l),c}function w(l){$(l);for(var m=k[l.name],c=m.forages,C=0;C<c.length;C++){var b=c[C];b._dbInfo.db&&(b._dbInfo.db.close(),b._dbInfo.db=null)}return l.db=null,K(l).then(function(g){return l.db=g,fe(l)?me(l):g}).then(function(g){l.db=m.db=g;for(var I=0;I<c.length;I++)c[I]._dbInfo.db=g}).catch(function(g){throw Z(l,g),g})}function D(l,m,c,C){C===void 0&&(C=1);try{var b=l.db.transaction(l.storeName,m);c(null,b)}catch(g){if(C>0&&(!l.db||g.name==="InvalidStateError"||g.name==="NotFoundError"))return f.resolve().then(function(){if(!l.db||g.name==="NotFoundError"&&!l.db.objectStoreNames.contains(l.storeName)&&l.version<=l.db.version)return l.db&&(l.version=l.db.version+1),me(l)}).then(function(){return w(l).then(function(){D(l,m,c,C-1)})}).catch(c);c(g)}}function Y(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function W(l){var m=this,c={db:null};if(l)for(var C in l)c[C]=l[C];var b=k[c.name];b||(b=Y(),k[c.name]=b),b.forages.push(m),m._initReady||(m._initReady=m.ready,m.ready=O);var g=[];function I(){return f.resolve()}for(var x=0;x<b.forages.length;x++){var P=b.forages[x];P!==m&&g.push(P._initReady().catch(I))}var j=b.forages.slice(0);return f.all(g).then(function(){return c.db=b.db,K(c)}).then(function(B){return c.db=B,fe(c,m._defaultConfig.version)?me(c):B}).then(function(B){c.db=b.db=B,m._dbInfo=c;for(var Q=0;Q<j.length;Q++){var ue=j[Q];ue!==m&&(ue._dbInfo.db=c.db,ue._dbInfo.version=c.version)}})}function X(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){D(c._dbInfo,G,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=P.get(l);j.onsuccess=function(){var B=j.result;B===void 0&&(B=null),Ee(B)&&(B=pe(B)),b(B)},j.onerror=function(){g(j.error)}}catch(B){g(B)}})}).catch(g)});return S(C,m),C}function ie(l,m){var c=this,C=new f(function(b,g){c.ready().then(function(){D(c._dbInfo,G,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=P.openCursor(),B=1;j.onsuccess=function(){var Q=j.result;if(Q){var ue=Q.value;Ee(ue)&&(ue=pe(ue));var Se=l(ue,Q.key,B++);Se!==void 0?b(Se):Q.continue()}else b()},j.onerror=function(){g(j.error)}}catch(Q){g(Q)}})}).catch(g)});return S(C,m),C}function oe(l,m,c){var C=this;l=L(l);var b=new f(function(g,I){var x;C.ready().then(function(){return x=C._dbInfo,F.call(m)==="[object Blob]"?N(x.db).then(function(P){return P?m:ae(m)}):m}).then(function(P){D(C._dbInfo,M,function(j,B){if(j)return I(j);try{var Q=B.objectStore(C._dbInfo.storeName);P===null&&(P=void 0);var ue=Q.put(P,l);B.oncomplete=function(){P===void 0&&(P=null),g(P)},B.onabort=B.onerror=function(){var Se=ue.error?ue.error:ue.transaction.error;I(Se)}}catch(Se){I(Se)}})}).catch(I)});return S(b,c),b}function Le(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){D(c._dbInfo,M,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=P.delete(l);x.oncomplete=function(){b()},x.onerror=function(){g(j.error)},x.onabort=function(){var B=j.error?j.error:j.transaction.error;g(B)}}catch(B){g(B)}})}).catch(g)});return S(C,m),C}function xe(l){var m=this,c=new f(function(C,b){m.ready().then(function(){D(m._dbInfo,M,function(g,I){if(g)return b(g);try{var x=I.objectStore(m._dbInfo.storeName),P=x.clear();I.oncomplete=function(){C()},I.onabort=I.onerror=function(){var j=P.error?P.error:P.transaction.error;b(j)}}catch(j){b(j)}})}).catch(b)});return S(c,l),c}function Ie(l){var m=this,c=new f(function(C,b){m.ready().then(function(){D(m._dbInfo,G,function(g,I){if(g)return b(g);try{var x=I.objectStore(m._dbInfo.storeName),P=x.count();P.onsuccess=function(){C(P.result)},P.onerror=function(){b(P.error)}}catch(j){b(j)}})}).catch(b)});return S(c,l),c}function we(l,m){var c=this,C=new f(function(b,g){if(l<0){b(null);return}c.ready().then(function(){D(c._dbInfo,G,function(I,x){if(I)return g(I);try{var P=x.objectStore(c._dbInfo.storeName),j=!1,B=P.openKeyCursor();B.onsuccess=function(){var Q=B.result;if(!Q){b(null);return}l===0||j?b(Q.key):(j=!0,Q.advance(l))},B.onerror=function(){g(B.error)}}catch(Q){g(Q)}})}).catch(g)});return S(C,m),C}function Je(l){var m=this,c=new f(function(C,b){m.ready().then(function(){D(m._dbInfo,G,function(g,I){if(g)return b(g);try{var x=I.objectStore(m._dbInfo.storeName),P=x.openKeyCursor(),j=[];P.onsuccess=function(){var B=P.result;if(!B){C(j);return}j.push(B.key),B.continue()},P.onerror=function(){b(P.error)}}catch(B){b(B)}})}).catch(b)});return S(c,l),c}function Ge(l,m){m=U.apply(this,arguments);var c=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||c.name,l.storeName=l.storeName||c.storeName);var C=this,b;if(!l.name)b=f.reject("Invalid arguments");else{var g=l.name===c.name&&C._dbInfo.db,I=g?f.resolve(C._dbInfo.db):K(l).then(function(x){var P=k[l.name],j=P.forages;P.db=x;for(var B=0;B<j.length;B++)j[B]._dbInfo.db=x;return x});l.storeName?b=I.then(function(x){if(x.objectStoreNames.contains(l.storeName)){var P=x.version+1;$(l);var j=k[l.name],B=j.forages;x.close();for(var Q=0;Q<B.length;Q++){var ue=B[Q];ue._dbInfo.db=null,ue._dbInfo.version=P}var Se=new f(function(_e,De){var Oe=d.open(l.name,P);Oe.onerror=function(Ye){var x1=Oe.result;x1.close(),De(Ye)},Oe.onupgradeneeded=function(){var Ye=Oe.result;Ye.deleteObjectStore(l.storeName)},Oe.onsuccess=function(){var Ye=Oe.result;Ye.close(),_e(Ye)}});return Se.then(function(_e){j.db=_e;for(var De=0;De<B.length;De++){var Oe=B[De];Oe._dbInfo.db=_e,q(Oe._dbInfo)}}).catch(function(_e){throw(Z(l,_e)||f.resolve()).catch(function(){}),_e})}}):b=I.then(function(x){$(l);var P=k[l.name],j=P.forages;x.close();for(var B=0;B<j.length;B++){var Q=j[B];Q._dbInfo.db=null}var ue=new f(function(Se,_e){var De=d.deleteDatabase(l.name);De.onerror=function(){var Oe=De.result;Oe&&Oe.close(),_e(De.error)},De.onblocked=function(){console.warn('dropInstance blocked for database "'+l.name+'" until all open connections are closed')},De.onsuccess=function(){var Oe=De.result;Oe&&Oe.close(),Se(Oe)}});return ue.then(function(Se){P.db=Se;for(var _e=0;_e<j.length;_e++){var De=j[_e];q(De._dbInfo)}}).catch(function(Se){throw(Z(l,Se)||f.resolve()).catch(function(){}),Se})})}return S(b,m),b}var Be={_driver:"asyncStorage",_initStorage:W,_support:h(),iterate:ie,getItem:X,setItem:oe,removeItem:Le,clear:xe,length:Ie,key:we,keys:Je,dropInstance:Ge};function ce(){return typeof openDatabase=="function"}var re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ye="~~local_forage_type~",Ue=/^~~local_forage_type~([^~]+)~/,He="__lfsc__:",Me=He.length,he="arbf",ve="blob",Pe="si08",e1="ui08",d1="uic8",t1="si16",St="si32",oi="ur16",si="ui32",li="fl32",ci="fl64",ui=Me+he.length,fi=Object.prototype.toString;function di(l){var m=l.length*.75,c=l.length,C,b=0,g,I,x,P;l[l.length-1]==="="&&(m--,l[l.length-2]==="="&&m--);var j=new ArrayBuffer(m),B=new Uint8Array(j);for(C=0;C<c;C+=4)g=re.indexOf(l[C]),I=re.indexOf(l[C+1]),x=re.indexOf(l[C+2]),P=re.indexOf(l[C+3]),B[b++]=g<<2|I>>4,B[b++]=(I&15)<<4|x>>2,B[b++]=(x&3)<<6|P&63;return j}function fn(l){var m=new Uint8Array(l),c="",C;for(C=0;C<m.length;C+=3)c+=re[m[C]>>2],c+=re[(m[C]&3)<<4|m[C+1]>>4],c+=re[(m[C+1]&15)<<2|m[C+2]>>6],c+=re[m[C+2]&63];return m.length%3===2?c=c.substring(0,c.length-1)+"=":m.length%3===1&&(c=c.substring(0,c.length-2)+"=="),c}function X4(l,m){var c="";if(l&&(c=fi.call(l)),l&&(c==="[object ArrayBuffer]"||l.buffer&&fi.call(l.buffer)==="[object ArrayBuffer]")){var C,b=He;l instanceof ArrayBuffer?(C=l,b+=he):(C=l.buffer,c==="[object Int8Array]"?b+=Pe:c==="[object Uint8Array]"?b+=e1:c==="[object Uint8ClampedArray]"?b+=d1:c==="[object Int16Array]"?b+=t1:c==="[object Uint16Array]"?b+=oi:c==="[object Int32Array]"?b+=St:c==="[object Uint32Array]"?b+=si:c==="[object Float32Array]"?b+=li:c==="[object Float64Array]"?b+=ci:m(new Error("Failed to get type for BinaryArray"))),m(b+fn(C))}else if(c==="[object Blob]"){var g=new FileReader;g.onload=function(){var I=ye+l.type+"~"+fn(this.result);m(He+ve+I)},g.readAsArrayBuffer(l)}else try{m(JSON.stringify(l))}catch(I){console.error("Couldn't convert value into a JSON string: ",l),m(null,I)}}function Q4(l){if(l.substring(0,Me)!==He)return JSON.parse(l);var m=l.substring(ui),c=l.substring(Me,ui),C;if(c===ve&&Ue.test(m)){var b=m.match(Ue);C=b[1],m=m.substring(b[0].length)}var g=di(m);switch(c){case he:return g;case ve:return p([g],{type:C});case Pe:return new Int8Array(g);case e1:return new Uint8Array(g);case d1:return new Uint8ClampedArray(g);case t1:return new Int16Array(g);case oi:return new Uint16Array(g);case St:return new Int32Array(g);case si:return new Uint32Array(g);case li:return new Float32Array(g);case ci:return new Float64Array(g);default:throw new Error("Unkown type: "+c)}}var dn={serialize:X4,deserialize:Q4,stringToBuffer:di,bufferToString:fn};function hi(l,m,c,C){l.executeSql("CREATE TABLE IF NOT EXISTS "+m.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],c,C)}function J4(l){var m=this,c={db:null};if(l)for(var C in l)c[C]=typeof l[C]!="string"?l[C].toString():l[C];var b=new f(function(g,I){try{c.db=openDatabase(c.name,String(c.version),c.description,c.size)}catch(x){return I(x)}c.db.transaction(function(x){hi(x,c,function(){m._dbInfo=c,g()},function(P,j){I(j)})},I)});return c.serializer=dn,b}function o1(l,m,c,C,b,g){l.executeSql(c,C,b,function(I,x){x.code===x.SYNTAX_ERR?I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[m.storeName],function(P,j){j.rows.length?g(P,x):hi(P,m,function(){P.executeSql(c,C,b,g)},g)},g):g(I,x)},g)}function K4(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"SELECT * FROM "+I.storeName+" WHERE key = ? LIMIT 1",[l],function(P,j){var B=j.rows.length?j.rows.item(0).value:null;B&&(B=I.serializer.deserialize(B)),b(B)},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function e5(l,m){var c=this,C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"SELECT * FROM "+I.storeName,[],function(P,j){for(var B=j.rows,Q=B.length,ue=0;ue<Q;ue++){var Se=B.item(ue),_e=Se.value;if(_e&&(_e=I.serializer.deserialize(_e)),_e=l(_e,Se.key,ue+1),_e!==void 0){b(_e);return}}b()},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function mi(l,m,c,C){var b=this;l=L(l);var g=new f(function(I,x){b.ready().then(function(){m===void 0&&(m=null);var P=m,j=b._dbInfo;j.serializer.serialize(m,function(B,Q){Q?x(Q):j.db.transaction(function(ue){o1(ue,j,"INSERT OR REPLACE INTO "+j.storeName+" (key, value) VALUES (?, ?)",[l,B],function(){I(P)},function(Se,_e){x(_e)})},function(ue){if(ue.code===ue.QUOTA_ERR){if(C>0){I(mi.apply(b,[l,P,c,C-1]));return}x(ue)}})})}).catch(x)});return S(g,c),g}function t5(l,m,c){return mi.apply(this,[l,m,c,1])}function n5(l,m){var c=this;l=L(l);var C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"DELETE FROM "+I.storeName+" WHERE key = ?",[l],function(){b()},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function r5(l){var m=this,c=new f(function(C,b){m.ready().then(function(){var g=m._dbInfo;g.db.transaction(function(I){o1(I,g,"DELETE FROM "+g.storeName,[],function(){C()},function(x,P){b(P)})})}).catch(b)});return S(c,l),c}function i5(l){var m=this,c=new f(function(C,b){m.ready().then(function(){var g=m._dbInfo;g.db.transaction(function(I){o1(I,g,"SELECT COUNT(key) as c FROM "+g.storeName,[],function(x,P){var j=P.rows.item(0).c;C(j)},function(x,P){b(P)})})}).catch(b)});return S(c,l),c}function a5(l,m){var c=this,C=new f(function(b,g){c.ready().then(function(){var I=c._dbInfo;I.db.transaction(function(x){o1(x,I,"SELECT key FROM "+I.storeName+" WHERE id = ? LIMIT 1",[l+1],function(P,j){var B=j.rows.length?j.rows.item(0).key:null;b(B)},function(P,j){g(j)})})}).catch(g)});return S(C,m),C}function o5(l){var m=this,c=new f(function(C,b){m.ready().then(function(){var g=m._dbInfo;g.db.transaction(function(I){o1(I,g,"SELECT key FROM "+g.storeName,[],function(x,P){for(var j=[],B=0;B<P.rows.length;B++)j.push(P.rows.item(B).key);C(j)},function(x,P){b(P)})})}).catch(b)});return S(c,l),c}function s5(l){return new f(function(m,c){l.transaction(function(C){C.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(b,g){for(var I=[],x=0;x<g.rows.length;x++)I.push(g.rows.item(x).name);m({db:l,storeNames:I})},function(b,g){c(g)})},function(C){c(C)})})}function l5(l,m){m=U.apply(this,arguments);var c=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||c.name,l.storeName=l.storeName||c.storeName);var C=this,b;return l.name?b=new f(function(g){var I;l.name===c.name?I=C._dbInfo.db:I=openDatabase(l.name,"","",0),l.storeName?g({db:I,storeNames:[l.storeName]}):g(s5(I))}).then(function(g){return new f(function(I,x){g.db.transaction(function(P){function j(Se){return new f(function(_e,De){P.executeSql("DROP TABLE IF EXISTS "+Se,[],function(){_e()},function(Oe,Ye){De(Ye)})})}for(var B=[],Q=0,ue=g.storeNames.length;Q<ue;Q++)B.push(j(g.storeNames[Q]));f.all(B).then(function(){I()}).catch(function(Se){x(Se)})},function(P){x(P)})})}):b=f.reject("Invalid arguments"),S(b,m),b}var c5={_driver:"webSQLStorage",_initStorage:J4,_support:ce(),iterate:e5,getItem:K4,setItem:t5,removeItem:n5,clear:r5,length:i5,key:a5,keys:o5,dropInstance:l5};function u5(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function pi(l,m){var c=l.name+"/";return l.storeName!==m.storeName&&(c+=l.storeName+"/"),c}function f5(){var l="_localforage_support_test";try{return localStorage.setItem(l,!0),localStorage.removeItem(l),!1}catch{return!0}}function d5(){return!f5()||localStorage.length>0}function h5(l){var m=this,c={};if(l)for(var C in l)c[C]=l[C];return c.keyPrefix=pi(l,m._defaultConfig),d5()?(m._dbInfo=c,c.serializer=dn,f.resolve()):f.reject()}function m5(l){var m=this,c=m.ready().then(function(){for(var C=m._dbInfo.keyPrefix,b=localStorage.length-1;b>=0;b--){var g=localStorage.key(b);g.indexOf(C)===0&&localStorage.removeItem(g)}});return S(c,l),c}function p5(l,m){var c=this;l=L(l);var C=c.ready().then(function(){var b=c._dbInfo,g=localStorage.getItem(b.keyPrefix+l);return g&&(g=b.serializer.deserialize(g)),g});return S(C,m),C}function g5(l,m){var c=this,C=c.ready().then(function(){for(var b=c._dbInfo,g=b.keyPrefix,I=g.length,x=localStorage.length,P=1,j=0;j<x;j++){var B=localStorage.key(j);if(B.indexOf(g)===0){var Q=localStorage.getItem(B);if(Q&&(Q=b.serializer.deserialize(Q)),Q=l(Q,B.substring(I),P++),Q!==void 0)return Q}}});return S(C,m),C}function v5(l,m){var c=this,C=c.ready().then(function(){var b=c._dbInfo,g;try{g=localStorage.key(l)}catch{g=null}return g&&(g=g.substring(b.keyPrefix.length)),g});return S(C,m),C}function C5(l){var m=this,c=m.ready().then(function(){for(var C=m._dbInfo,b=localStorage.length,g=[],I=0;I<b;I++){var x=localStorage.key(I);x.indexOf(C.keyPrefix)===0&&g.push(x.substring(C.keyPrefix.length))}return g});return S(c,l),c}function S5(l){var m=this,c=m.keys().then(function(C){return C.length});return S(c,l),c}function b5(l,m){var c=this;l=L(l);var C=c.ready().then(function(){var b=c._dbInfo;localStorage.removeItem(b.keyPrefix+l)});return S(C,m),C}function y5(l,m,c){var C=this;l=L(l);var b=C.ready().then(function(){m===void 0&&(m=null);var g=m;return new f(function(I,x){var P=C._dbInfo;P.serializer.serialize(m,function(j,B){if(B)x(B);else try{localStorage.setItem(P.keyPrefix+l,j),I(g)}catch(Q){(Q.name==="QuotaExceededError"||Q.name==="NS_ERROR_DOM_QUOTA_REACHED")&&x(Q),x(Q)}})})});return S(b,c),b}function _5(l,m){if(m=U.apply(this,arguments),l=typeof l!="function"&&l||{},!l.name){var c=this.config();l.name=l.name||c.name,l.storeName=l.storeName||c.storeName}var C=this,b;return l.name?b=new f(function(g){l.storeName?g(pi(l,C._defaultConfig)):g(l.name+"/")}).then(function(g){for(var I=localStorage.length-1;I>=0;I--){var x=localStorage.key(I);x.indexOf(g)===0&&localStorage.removeItem(x)}}):b=f.reject("Invalid arguments"),S(b,m),b}var L5={_driver:"localStorageWrapper",_initStorage:h5,_support:u5(),iterate:g5,getItem:p5,setItem:y5,removeItem:b5,clear:m5,length:S5,key:v5,keys:C5,dropInstance:_5},E5=function(m,c){return m===c||typeof m=="number"&&typeof c=="number"&&isNaN(m)&&isNaN(c)},w5=function(m,c){for(var C=m.length,b=0;b<C;){if(E5(m[b],c))return!0;b++}return!1},gi=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"},T1={},vi={},b1={INDEXEDDB:Be,WEBSQL:c5,LOCALSTORAGE:L5},M5=[b1.INDEXEDDB._driver,b1.WEBSQL._driver,b1.LOCALSTORAGE._driver],bt=["dropInstance"],hn=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(bt),O5={description:"",driver:M5.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function I5(l,m){l[m]=function(){var c=arguments;return l.ready().then(function(){return l[m].apply(l,c)})}}function mn(){for(var l=1;l<arguments.length;l++){var m=arguments[l];if(m)for(var c in m)m.hasOwnProperty(c)&&(gi(m[c])?arguments[0][c]=m[c].slice():arguments[0][c]=m[c])}return arguments[0]}var H5=function(){function l(m){o(this,l);for(var c in b1)if(b1.hasOwnProperty(c)){var C=b1[c],b=C._driver;this[c]=b,T1[b]||this.defineDriver(C)}this._defaultConfig=mn({},O5),this._config=mn({},this._defaultConfig,m),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return l.prototype.config=function(c){if((typeof c>"u"?"undefined":a(c))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var C in c){if(C==="storeName"&&(c[C]=c[C].replace(/\W/g,"_")),C==="version"&&typeof c[C]!="number")return new Error("Database version must be a number.");this._config[C]=c[C]}return"driver"in c&&c.driver?this.setDriver(this._config.driver):!0}else return typeof c=="string"?this._config[c]:this._config},l.prototype.defineDriver=function(c,C,b){var g=new f(function(I,x){try{var P=c._driver,j=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!c._driver){x(j);return}for(var B=hn.concat("_initStorage"),Q=0,ue=B.length;Q<ue;Q++){var Se=B[Q],_e=!w5(bt,Se);if((_e||c[Se])&&typeof c[Se]!="function"){x(j);return}}var De=function(){for(var x1=function(x5){return function(){var V5=new Error("Method "+x5+" is not implemented by the current driver"),Ci=f.reject(V5);return S(Ci,arguments[arguments.length-1]),Ci}},pn=0,T5=bt.length;pn<T5;pn++){var gn=bt[pn];c[gn]||(c[gn]=x1(gn))}};De();var Oe=function(x1){T1[P]&&console.info("Redefining LocalForage driver: "+P),T1[P]=c,vi[P]=x1,I()};"_support"in c?c._support&&typeof c._support=="function"?c._support().then(Oe,x):Oe(!!c._support):Oe(!0)}catch(Ye){x(Ye)}});return _(g,C,b),g},l.prototype.driver=function(){return this._driver||null},l.prototype.getDriver=function(c,C,b){var g=T1[c]?f.resolve(T1[c]):f.reject(new Error("Driver not found."));return _(g,C,b),g},l.prototype.getSerializer=function(c){var C=f.resolve(dn);return _(C,c),C},l.prototype.ready=function(c){var C=this,b=C._driverSet.then(function(){return C._ready===null&&(C._ready=C._initDriver()),C._ready});return _(b,c,c),b},l.prototype.setDriver=function(c,C,b){var g=this;gi(c)||(c=[c]);var I=this._getSupportedDrivers(c);function x(){g._config.driver=g.driver()}function P(Q){return g._extend(Q),x(),g._ready=g._initStorage(g._config),g._ready}function j(Q){return function(){var ue=0;function Se(){for(;ue<Q.length;){var _e=Q[ue];return ue++,g._dbInfo=null,g._ready=null,g.getDriver(_e).then(P).catch(Se)}x();var De=new Error("No available storage method found.");return g._driverSet=f.reject(De),g._driverSet}return Se()}}var B=this._driverSet!==null?this._driverSet.catch(function(){return f.resolve()}):f.resolve();return this._driverSet=B.then(function(){var Q=I[0];return g._dbInfo=null,g._ready=null,g.getDriver(Q).then(function(ue){g._driver=ue._driver,x(),g._wrapLibraryMethodsWithReady(),g._initDriver=j(I)})}).catch(function(){x();var Q=new Error("No available storage method found.");return g._driverSet=f.reject(Q),g._driverSet}),_(this._driverSet,C,b),this._driverSet},l.prototype.supports=function(c){return!!vi[c]},l.prototype._extend=function(c){mn(this,c)},l.prototype._getSupportedDrivers=function(c){for(var C=[],b=0,g=c.length;b<g;b++){var I=c[b];this.supports(I)&&C.push(I)}return C},l.prototype._wrapLibraryMethodsWithReady=function(){for(var c=0,C=hn.length;c<C;c++)I5(this,hn[c])},l.prototype.createInstance=function(c){return new l(c)},l}(),D5=new H5;r.exports=D5},{3:3}]},{},[4])(4)})})(Y6);var M4=Y6.exports;const f1=vr(M4);class q6{getItem(t){return f1.getItem(t)}setItem(t,n){return f1.setItem(t,n)}removeItem(t){return f1.removeItem(t)}clear(){return f1.clear()}key(t){return f1.key(t)}keys(){return f1.keys()}iterate(t){return f1.iterate(t)}}var O4=Object.defineProperty,I4=Object.getOwnPropertyDescriptor,H4=(e,t,n,r)=>{for(var i=r>1?void 0:r?I4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&O4(t,n,i),i},D4=(e,t)=>(n,r)=>t(n,r,e);let nn=class{constructor(e){z(this,"visible$",new ee.Subject);z(this,"componentKey$",new ee.Subject);this._componentManager=e}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),y.toDisposable(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}};nn=H4([D4(0,se.Inject(Ke))],nn);class T4 extends y.Disposable{constructor(){super(...arguments);z(this,"_currentSelectorId");z(this,"_selectionChange$",new ee.Subject);z(this,"selectionChange$",this._selectionChange$.asObservable());z(this,"_openSelector$",new ee.Subject);z(this,"openSelector$",this._openSelector$.asObservable())}setCurrentSelectorId(n){this._currentSelectorId=n}getCurrentSelectorId(){return this._currentSelectorId}selectionChange(n){this._currentSelectorId&&this._selectionChange$.next(n)}openSelector(){this._openSelector$.next(null)}}const rn=se.createIdentifier("univer.range-selector.service");class x4 extends y.Disposable{constructor(){super(...arguments);z(this,"_taskCount",0);z(this,"_progressChange$",new ee.Subject);z(this,"_progressVisible$",new ee.Subject);z(this,"progressChange$",this._progressChange$.asObservable());z(this,"progressVisible$",this._progressVisible$.asObservable())}dispose(){super.dispose(),this._clear(),this._progressChange$.complete(),this._progressVisible$.complete()}pushTask(n){if(this._taskCount===0)return;const{count:r}=n;if(r<=0)return;const i=Math.min(1,r/this._taskCount);this._progressChange$.next({step:i}),this._taskCount-=r,this._taskCount<0&&(this._taskCount=0),this._taskCount===0&&this._progressVisible$.next(!1)}insertTaskCount(n){n<=0||(this._taskCount===0&&this._progressVisible$.next(!0),this._taskCount+=n)}complete(){this._taskCount!==0&&(this._progressChange$.next({step:1}),this._clear(),this._progressVisible$.next(!1))}stop(){this._taskCount!==0&&(this._clear(),this._progressVisible$.next(!1))}_clear(){this._taskCount=0}}const an=se.createIdentifier("univer.progress.service");var V4=Object.defineProperty,N4=Object.getOwnPropertyDescriptor,k4=(e,t,n,r)=>{for(var i=r>1?void 0:r?N4(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&V4(t,n,i),i},on=(e,t)=>(n,r)=>t(n,r,e);const A4="ui",X6="DISABLE_AUTO_FOCUS";E.UniverUIPlugin=(un=class extends y.Plugin{constructor(t={},n,r,i){super(),this._config=t,this._contextService=n,this._injector=r,this._localeService=i,this._localeService.load({zhCN:A6}),this._config.disableAutoFocus&&this._contextService.setContextValue(X6,!0)}onStarting(t){this._initDependencies(t),this._initUI()}_initDependencies(t){[[Ke],[N1],[W6],[L1,{useClass:E.DesktopLayoutService}],[m1,{useClass:E.DesktopShortcutService}],[Lt,{useClass:Er}],[s1,{useClass:E.DesktopMenuService}],[Yt,{useClass:T6}],[U6,{useClass:E.BrowserClipboardService,lazy:!0}],[dt,{useClass:z6,lazy:!0}],[qt,{useClass:$6,lazy:!0}],[Gt,{useClass:j6,lazy:!0}],[Y1,{useClass:F6,lazy:!0}],[Dt,{useClass:nn,lazy:!0}],[Xt,{useClass:E.DesktopGlobalZoneService,lazy:!0}],[G1,{useClass:B6,lazy:!0}],[y.ILocalStorageService,{useClass:q6,lazy:!0}],[R6,{useClass:E.DesktopBeforeCloseService}],[_1,{useClass:E.EditorService}],[rn,{useClass:T4}],[Qt,{useClass:V6}],[an,{useClass:x4}],[B1,{useClass:E.DesktopUIController}],[E.SharedController],[ht],[mt]].forEach(r=>t.add(r))}_initUI(){Promise.resolve().then(()=>this._injector.get(B1).bootstrapWorkbench(this._config))}},z(un,"pluginName",A4),un),E.UniverUIPlugin=k4([on(1,y.IContextService),on(2,se.Inject(se.Injector)),on(3,se.Inject(y.LocaleService))],E.UniverUIPlugin);function gt(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,"")}const R4=.75,Q6=78,J6=9,K6="rgba(0,0,0,0)",ei="rgb(0,0,0)";function sn(e){var u;let t=e.childNodes;if(t.length===0)return e.textContent;if(t[0].nodeName==="DIV"&&(t=t[0].childNodes),t.length===1&&t[0].nodeName==="#text")return t[0].textContent;const n=[];let r=0,i=0,a=e.textContent||"";a+=`\r
47
47
  `;for(let d=0;d<t.length;d++){let h=t[`${d}`],p;h.nodeName==="#text"?(p=(u=h.textContent)!=null?u:"",h=h.parentElement):p=h.innerText;const f=vt(h);ni(p).forEach(_=>{const L=_.length;i+=L,r=i-L;const U=y.Tools.generateRandomId(6);n.push({sId:U,st:r,ed:i-1,ts:f})})}return y.Tools.generateRandomId(6),{id:y.Tools.generateRandomId(6),body:{dataStream:a,textRuns:n},documentStyle:{}}}function vt(e,t=""){var o,u;let n=(u=(o=e==null?void 0:e.style)==null?void 0:o.cssText)!=null?u:"";if(n+=t,n=n.replace(/[\r\n]+/g,""),n.length===0)return{};const r=n.split(";"),i={},a={t:"",r:"",b:"",l:""};return r.forEach(d=>{var S;const h=d;d=d.toLowerCase();const p=gt(d.substr(0,d.indexOf(":"))),f=gt(d.substr(d.indexOf(":")+1));if(p==="font-weight")f==="bold"||f==="700"?i.bl=1:i.bl=0;else if(p==="font-style")f==="italic"?i.it=1:i.it=0;else if(p==="font-family"){const _=gt(h.substr(h.indexOf(":")+1));i.ff=_}else if(p==="font-size"){let _=Number.parseInt(f);n.indexOf("vertical-align")>-1&&(n.indexOf("sub")>-1||n.indexOf("sup")>-1)&&(_*=2),f.indexOf("px")!==-1&&(_=Z4(Number.parseInt(f,10))),i.fs=_}else if(p==="color")i.cl={rgb:f};else if(p==="background"||p==="background-color"){const _=new y.ColorKit(f);if(_){const L=_.toRgbString();L!==K6&&L!==ei&&(i.bg={rgb:_.toRgbString()})}}else if(p==="text-decoration-line")f==="underline"?(i.ul||(i.ul={s:1}),i.ul.s=1):f==="line-through"?(i.st||(i.st={s:1}),i.st.s=1):f==="overline"&&(i.ol||(i.ol={s:1}),i.ol.s=1);else if(p==="text-decoration-color")i.hasOwnProperty("ul")&&(i.ul||(i.ul={s:1,cl:{rgb:f}}),i.ul.cl={rgb:f}),i.hasOwnProperty("st")&&(i.st||(i.st={s:1,cl:{rgb:f}}),i.st.cl={rgb:f}),i.hasOwnProperty("ol")&&(i.ol||(i.ol={s:1,cl:{rgb:f}}),i.ol.cl={rgb:f});else if(p==="text-decoration-style")i.hasOwnProperty("ul")&&(i.ul||(i.ul={s:1,t:Number(f)}),i.ul.t=Number(f)),i.hasOwnProperty("st")&&(i.st||(i.st={s:1,t:Number(f)}),i.st.t=Number(f)),i.hasOwnProperty("ol")&&(i.ol||(i.ol={s:1,t:Number(f)}),i.ol.t=Number(f));else if(p==="text-decoration"||p==="univer-strike"){const _=(S=f.split(" "))==null?void 0:S[0];_==="underline"?(i.ul||(i.ul={s:1}),i.ul.s=1):_==="line-through"?(i.st||(i.st={s:1}),i.st.s=1):_==="overline"&&(i.ol||(i.ol={s:1}),i.ol.s=1)}if(p==="univer-underline"&&(i.ul={s:1}),p==="vertical-align"&&(f==="sub"?i.va=y.BaselineOffset.SUBSCRIPT:f==="super"?i.va=y.BaselineOffset.SUPERSCRIPT:f==="top"?i.vt=1:f==="middle"?i.vt=2:f==="bottom"?i.vt=3:i.va=y.BaselineOffset.NORMAL),p==="transform"){const _=f.split(")"),L=_.findIndex(U=>U.includes("rotate"));if(L>-1){const U=_[L].match(/\d+/g);let H=0,A=0;U!=null&&U.length&&(H=+U[0]),e!=null&&e.dataset.vertical&&(A=+e.dataset.vertical),i.tr={a:H,v:A}}}if(p==="text-align"&&(f==="left"?i.ht=1:f==="center"?i.ht=2:f==="right"?i.ht=3:f==="justify"?i.ht=4:i.ht=0),p==="overflow-wrap"||p==="word-wrap"?f==="break-word"&&(i.tb=3):p==="text-overflow"?f==="clip"&&(i.tb=2):p==="text-break"&&f==="overflow"&&(i.tb=1),p==="white-space"&&(f==="nowrap"?i.tb=1:f==="normal"?i.tb=3:f==="clip"&&(i.tb=2)),p==="border-color"){const _=ti(f,")");if(i.bd)for(const L in _)i.bd[L].cl.rgb=_[L];else{i.bd={b:{cl:{rgb:"#000"},s:0},t:{cl:{rgb:"#000"},s:0},l:{cl:{rgb:"#000"},s:0},r:{cl:{rgb:"#000"},s:0}};for(const L in _)i.bd[L].cl.rgb=_[L]}}if(p==="border-width"||p==="border-style"){const _=ti(f," ");for(const L in _)a[L]+=` ${_[L]}`;i.bd?(i.bd.b.s=y.getBorderStyleType(a.b),i.bd.t.s=y.getBorderStyleType(a.t),i.bd.l.s=y.getBorderStyleType(a.l),i.bd.r.s=y.getBorderStyleType(a.r)):i.bd={b:{cl:{rgb:"#000"},s:y.getBorderStyleType(a.b)},t:{cl:{rgb:"#000"},s:y.getBorderStyleType(a.t)},l:{cl:{rgb:"#000"},s:y.getBorderStyleType(a.l)},r:{cl:{rgb:"#000"},s:y.getBorderStyleType(a.r)}}}if(p==="border-bottom"||p==="border-top"||p==="border-left"||p==="border-right"||p==="border"){i.bd||(i.bd={});const _=f.split(" "),L=`${_[0]} ${_[1]}`;_.splice(0,2);const U=_.join("");if(y.getBorderStyleType(L)!==y.BorderStyleTypes.NONE){const A={cl:{rgb:U},s:y.getBorderStyleType(L)};p==="border-bottom"?i.bd.b=f==="none"?null:A:p==="border-top"?i.bd.t=f==="none"?null:A:p==="border-left"?i.bd.l=f==="none"?null:A:p==="border-right"?i.bd.r=f==="none"?null:A:p==="border"&&(i.bd={r:f==="none"?null:A,t:f==="none"?null:A,b:f==="none"?null:A,l:f==="none"?null:A})}}else if(p==="data-rotate"){const _=/[+-]?\d+/,L=f.match(_);f==="(0deg ,1)"?i.tr={a:0,v:1}:L&&(i.tr={a:Number(L[0])})}}),Object.keys(i).forEach(d=>{typeof i[d]=="object"&&!Object.keys(i[d]).length&&delete i[d]}),i}function ti(e,t){let n;t===" "?n=e.trim().split(t):n=e.trim().split(t).slice(0,-1),n.forEach(i=>`${i.trim()})`);let r={};return n.length===1?r={t:n[0],r:n[0],b:n[0],l:n[0]}:n.length===2?r={t:n[0],r:n[1],b:n[0],l:n[1]}:n.length===3?r={t:n[0],r:n[1],b:n[2],l:n[1]}:n.length===4&&(r={t:n[0],r:n[1],b:n[2],l:n[3]}),r}function ni(e){if(e==="")return[e];const t=/(?:(\n+.+)|(.+))/g;return e.match(t).map(i=>i.replace(/\n/g,`\r
48
48
  `))}function U4(e){const t=document.createElement("DIV"),n=[];t.innerHTML=e;const r=t.querySelectorAll("table col");if(!r.length)return[];for(let i=0;i<r.length;i++){const a=r[i],o=a.getAttribute("span");if(o&&+o>1)for(let u=0;u<+o;u++){const d=Ct(a.getAttribute("width"),72);n.push(d)}else{const u=Ct(a.getAttribute("width"),72);n.push(u)}}return n}function Ct(e,t){if(!e)return t;let n;return e.includes("pt")?n=h1.ptToPx(Number.parseFloat(e)):e.includes("px")?n=Number.parseFloat(e):n=Number.parseFloat(e)*72/96,n}function P4(e){const t=document.createElement("DIV"),n=[];t.innerHTML=e;const r=t.querySelectorAll("table tr");if(!r.length)return[];for(let i=0;i<r.length;i++){const o=r[i].querySelectorAll("td");let u=Ct(o[0].style.height,19);for(let d=0;d<o.length;d++){const h=o[d].getAttribute("rowSpan");if(!(h&&+h>1)){u=Ct(o[d].style.height,19);break}}n.push(u)}return n}function j4(e){let t=[];const n=document.createElement("DIV");if(n.innerHTML=e,t=new Array(n.querySelectorAll("table tr").length),!t.length)return[];let r=0;const i=n.querySelectorAll("table tr");i[0].querySelectorAll("td").forEach(u=>{let d=0;const h=u.getAttribute("colSpan");h!==null?d=+h:d=1,r+=d});for(let u=0;u<t.length;u++)t[u]=new Array(r);let o=0;return i.forEach(u=>{let d=0;u.querySelectorAll("td").forEach(h=>{var _,L;const p={};if(h.querySelectorAll("span").length||h.querySelectorAll("font").length){const U=sn(h);typeof U!="string"&&(p.p=U)}const f=h.innerText;f.trim().length===0?p.v="":p.v=f;const S=vt(h);for(y.Tools.isPlainObject(S)&&(p.s=S);d<r&&t[o][d]!=null;)d++;if(d!==r){if(t[o][d]==null){t[o][d]=p;const U=(_=Number(h.getAttribute("rowSpan")))!=null?_:1,H=(L=Number(h.getAttribute("colSpan")))!=null?L:1;if(U>1||H>1){const A={rs:+U-1,cs:+H-1,r:o,c:d};t[o][d].mc=A;for(let k=0;k<U;k++)for(let F=0;F<H;F++)k===0&&F===0||(t[o+k][d+F]={mc:null})}}d++}}),o++}),t}function $4(e){const t=[],n=document.createElement("DIV");n.innerHTML=e;const i=e.replace(/\r/g,"").split(`
49
49
  `),a=i[0].split(" ").length;for(let o=0;o<i.length;o++)i[o].split(" ").length<a||t.push(i[o].split(" "));for(let o=0;o<t.length;o++)for(let u=0;u<t[o].length;u++)t[o][u].length?t[o][u]={v:t[o][u]||"",m:t[o][u]||""}:t[o][u]=null;return t}function B4(e,t){e.length,e[0].length;let n=0,r=0;t&&(n=t.startRow,r=t.startColumn);const i=[];for(let a=0;a<e.length;a++)for(let o=0;o<e[a].length;o++)if(e[a][o]&&typeof e[a][o]=="object"&&"mc"in e[a][o])if(e[a][o].mc){const u=e[a][o].mc,d=u.r+n,h=d+u.rs,p=u.c+r,f=p+u.cs;i.push({startRow:d,endRow:h,startColumn:p,endColumn:f}),delete e[a][o].mc}else e[a][o]=null;return{data:e,mergeData:i}}function z4(e){var h;let t=[];const n=document.createElement("html");n.innerHTML=e;const r=(h=n.querySelector("style"))==null?void 0:h.innerText;if(!r)return;const i=F4(r);if(t=new Array(n.querySelectorAll("table tr").length),!t.length)return[];let a=0;const o=n.querySelectorAll("table tr");o[0].querySelectorAll("td").forEach(p=>{let f=0;const S=p.getAttribute("colSpan");S!==null?f=+S:f=1,a+=f});for(let p=0;p<t.length;p++)t[p]=new Array(a);let d=0;return o.forEach(p=>{let f=0;p.querySelectorAll("td").forEach(S=>{var A,k;const _={};if(S.querySelectorAll("span").length||S.querySelectorAll("font").length){const F=sn(S);typeof F!="string"&&(_.p=F)}const L=S.innerText;L.trim().length===0?_.v="":_.v=L;let U="";for(const F in i)S.classList.contains(F)&&(U+=i[F]);const H=vt(S,U);for(y.Tools.isPlainObject(H)&&(_.s=H);f<a&&t[d][f]!=null;)f++;if(f!==a){if(t[d][f]==null){t[d][f]=_;const F=(A=Number(S.getAttribute("rowSpan")))!=null?A:1,G=(k=Number(S.getAttribute("colSpan")))!=null?k:1;if(F>1||G>1){const M={rs:+F-1,cs:+G-1,r:d,c:f};t[d][f].mc=M;for(let V=0;V<F;V++)for(let R=0;R<G;R++)V===0&&R===0||(t[d+V][f+R]={mc:null})}}f++}}),d++}),t}function F4(e){const t={},n=e.replaceAll("<!--","").replaceAll("-->","").trim(),r=n==null?void 0:n.replaceAll(" ","").replaceAll(`