@univerjs/sheets-ui 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +10 -10
- package/lib/es/index.js +2571 -2550
- package/lib/types/basics/editor/get-editor-object.d.ts +2 -1
- package/lib/types/controllers/force-string-render.controller.d.ts +2 -3
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +10 -10
- package/package.json +20 -20
package/lib/umd/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(N,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@wendellhu/redi"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/docs"),require("rxjs/operators"),require("@univerjs/design"),require("@univerjs/engine-numfmt"),require("@univerjs/engine-formula"),require("@wendellhu/redi/react-bindings"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/ui","@wendellhu/redi","rxjs","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/docs","rxjs/operators","@univerjs/design","@univerjs/engine-numfmt","@univerjs/engine-formula","@wendellhu/redi/react-bindings","react","clsx"],a):(N=typeof globalThis<"u"?globalThis:N||self,a(N.UniverSheetsUi={},N.UniverCore,N.UniverSheets,N.UniverUi,N["@wendellhu/redi"],N.rxjs,N.UniverDocsUi,N.UniverEngineRender,N.UniverDocs,N.rxjs.operators,N.UniverDesign,N.UniverEngineNumfmt,N.UniverEngineFormula,N["@wendellhu/redi/react-bindings"],N.React,N.clsx))})(this,function(N,a,_,C,P,k,gi,T,te,Ps,re,Sn,K,G,V,Pe){"use strict";var wf=Object.defineProperty;var yf=(N,a,_)=>a in N?wf(N,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):N[a]=_;var I=(N,a,_)=>(yf(N,typeof a!="symbol"?a+"":a,_),_);var fi;const Hs="SheetUI";function _n(i,t){if(i==null)return;const e=t.getRenderById(i);if(e==null)return;const{mainComponent:n,scene:o,engine:r}=e;return{document:n,scene:o,engine:r}}const Si={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},pn=["零","一","二","三","四","五","六","七","八","九"],Io=["","万","亿","万亿","亿亿"],Ls=["","十","百","千"],Ro={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Xe(i){if(!i)return 0;let t=0,e=0,n=0,o=!1;const r=i.split("");for(let s=0;s<r.length;s++){const l=Si[r[s]];if(typeof l<"u")n=l,s===r.length-1&&(e+=n);else{const d=Ro[r[s]],c=d.value;o=d.secUnit,o?(e=(e+n)*c,t+=e,e=0):e+=n*c,n=0}}return t+e}function Us(i){let t="",e="",n=0,o=!0;for(;i>0;){const r=i%10;r===0?o||(o=!0,e=pn[r]+e):(o=!1,t=pn[r],t+=Ls[n],e=t+e),n++,i=Math.floor(i/10)}return e}function Vs(i){let t=0,e="",n="",o=!1;if(i===0)return pn[0];for(;i>0;){const r=i%1e4;o&&(n=pn[0]+n),e=Us(r),e+=r!==0?Io[t]:Io[0],n=e+n,o=r<1e3&&r>0,i=Math.floor(i/1e4),t++}return n}function Bs(i){if(!i)return!1;let t=!0;if(i)if(i.length===1)i==="日"||i in Si?t=!0:t=!1;else{const e=i.split("");for(let n=0;n<e.length;n++)if(!(e[n]in Si||e[n]in Ro)){t=!1;break}}return t}function vn(i){if(!i)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,e=t.test(i);if(e){const n=i.match(t);if(n&&n.length>0){const o=n[n.length-1],r=i.lastIndexOf(o),s=i.substr(0,r),l=i.substr(r+o.length);return{isExtendNumber:!0,matchTxt:Number(o),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function ks(i){let t;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?t=!0:t=!1,t}function Fs(i){let t;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?t=!0:t=!1,t}function Ws(i,t){let e=0;for(let n=0;n<i.length&&i[n]<t;n++)e++;return e}function Vt(i){let t=!0;const e=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==e){t=!1;break}return t}function js(i,t,e){const n=[],o=Math.floor(t/i),r=t%i;let s=0;if(o>0){for(let l=0;l<o;l++)for(let d=0;d<e.length;d++)n[e[d]+l*i]=s,s++;for(let l=0;l<e.length&&e[l]<r;l++)n[e[l]+i*o]=s,s++}else for(let l=0;l<e.length&&e[l]<r;l++)n[e[l]]=s,s++;return n}function at(i,t){const e=[];for(let n=1;n<=t;n++){const o=(n-1)%i.length,r=a.Tools.deepClone(i[o]);e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function zs(i,t){var n;const e=[];for(let o=1;o<=t;o++){const r=(o-1)%i.length,s={s:(n=i[r])==null?void 0:n.s};e.push(s)}return e}function Ys(i){let t=!0;const e=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==e){t=!1;break}return t}function Xs(i){const t=[];for(let e=1;e<=i;e++)t.push(e);return t}function Mo(i,t,e){var r,s,l,d;const n=[],o=[];for(let c=0;c<i.length;c++)o.push(Number((r=i[c])==null?void 0:r.v));if(i.length>2&&Ys(o))for(let c=1;c<=t;c++){const u=(c-1)%i.length,h=a.Tools.deepClone(i[u]),m=Number((s=i[i.length-1])==null?void 0:s.v)*(Number((l=i[1])==null?void 0:l.v)/Number((d=i[0])==null?void 0:d.v))**c;h&&(h.t!==a.CellValueType.BOOLEAN&&(h.v=m),n.push(h))}else{const c=Xs(i.length);for(let u=1;u<=t;u++){const h=(u-1)%i.length,m=a.Tools.deepClone(i[h]),f=e===a.Direction.DOWN||e===a.Direction.RIGHT,g=$s(i.length+u,o,c,f);m&&(m.t!==a.CellValueType.BOOLEAN&&(m.v=g),n.push(m))}}return n}function $s(i,t,e,n=!0){function o(h){let m=0;for(let f=0;f<h.length;f++)m+=h[f];return m/h.length}const r=o(e),s=o(t);let l=0,d=0;for(let h=0;h<e.length;h++)l+=(e[h]-r)*(t[h]-s),d+=(e[h]-r)*(e[h]-r);let c;d===0?c=n?1:-1:c=l/d;const u=s-c*r;return Math.round((u+c*i)*1e5)/1e5}function bo(i,t,e){var r;const n=[],o=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const l=(s-1)%i.length,d=a.Tools.deepClone(i[l]),c=`${(r=i[i.length-1])==null?void 0:r.v}`,u=c==null?void 0:c.match(o),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+e*s);if(!c||!h)continue;const f=c.lastIndexOf(h),g=c.substr(0,f)+m.toString()+c.substr(f+h.length);d&&(d.v=g,n.push(d))}return n}function pt(i,t,e,n=0){var l,d;const o=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=o.length)return[];const r=o[n],s=[];for(let c=1;c<=t;c++){const u=(c-1)%i.length,h=a.Tools.deepClone(i[u]);let m=0;if(((l=i[i.length-1])==null?void 0:l.v)===r[0])m=7+e*c;else{const g=`${(d=i[i.length-1])==null?void 0:d.v}`;if(g){const S=g.substr(g.length-1,1);m=Xe(S)+e*c}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const f=m%7;h&&(h.v=r[f],s.push(h))}return s}function To(i,t,e){var o;const n=[];for(let r=1;r<=t;r++){const s=(r-1)%i.length,l=a.Tools.deepClone(i[s]),d=`${(o=i[i.length-1])==null?void 0:o.v}`,c=Xe(d)+e*r;let u;c<=0?u="零":u=Vs(c),l&&(l.v=u,n.push(l))}return n}const Bt={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Gs(i){let t=!1;return Object.keys(Bt).forEach(e=>{Bt[e].includes(i)&&(t=!0)}),t}function _i(i){let t="";const e=[];return Object.keys(Bt).forEach(n=>{Bt[n].includes(i)&&(t=n,e.push(...Bt[n]))}),{name:t,series:e}}function Eo(i,t,e,n){var s;const o=n.length,r=[];for(let l=1;l<=t;l++){const d=(l-1)%i.length,c=a.Tools.deepClone(i[d]),u=`${(s=i[i.length-1])==null?void 0:s.v}`;let h=n.indexOf(u)+e*l;h<0&&(h+=Math.abs(e)*o);const m=h%o;c&&(c.v=n[m],r.push(c))}return r}function Zs(i,t){const e=[];let n;if(t.startRow<i.startRow)n=a.Direction.UP;else if(t.endRow>i.endRow)n=a.Direction.DOWN;else if(t.startColumn<i.startColumn)n=a.Direction.LEFT;else if(t.endColumn>i.endColumn)n=a.Direction.RIGHT;else return[];if(n===a.Direction.DOWN||n===a.Direction.UP){const o=i.endRow-i.startRow+1,r=t.endRow-t.startRow+1,s=Math.floor(r/o),l=r%o,d={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===a.Direction.DOWN){for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow+(c+1)*o,col:i.startColumn},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow+(s+1)*o,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:l-1,endColumn:i.endColumn-i.startColumn}})}else{for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow-(c+1)*o,col:i.startColumn},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow-(s+1)*o,col:i.startColumn},relativeRange:{startRow:o-l,endRow:o-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===a.Direction.RIGHT||n===a.Direction.LEFT){const o=i.endColumn-i.startColumn+1,r=t.endColumn-t.startColumn+1,s=Math.floor(r/o),l=r%o,d={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===a.Direction.RIGHT){for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(c+1)*o},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*o},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:l-1}})}else{for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(c+1)*o},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*o},relativeRange:{startRow:0,startColumn:o-l,endRow:i.endRow-i.startRow,endColumn:o-1}})}}return e}function Ks(i){const t=new a.ObjectMatrix;return i.forEach(e=>{const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;for(let l=n;l<=r;l++)for(let d=o;d<=s;d++)t.setValue(l,d,{v:null,p:null,f:null,si:null})}),t.getData()}const wo={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,t)=>!0},Cn={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(a.IUniverInstanceService),n=i.get(a.ICommandService),o=i.get(a.IUndoRedoService),r=_.getSheetCommandTarget(e);if(!r)return!1;const{unitId:s,subUnitId:l}=r,{clearRange:d,selectionRange:c}=t,u={subUnitId:l,unitId:s,cellValue:Ks([d])},h=_.SetRangeValuesUndoMutationFactory(i,u),{startColumn:m,startRow:f}=c;return n.executeCommand(_.SetSelectionsOperation.id,{selections:[{primary:{startColumn:m,startRow:f,endColumn:m,endRow:f,actualRow:f,actualColumn:m,isMerge:!1,isMergedMainCell:!1},range:{...c}}],unitId:s,subUnitId:l}),n.syncExecuteCommand(_.SetRangeValuesMutation.id,u)?(o.pushUndoRedo({unitID:s,undoMutations:[{id:_.SetRangeValuesMutation.id,params:h}],redoMutations:[{id:_.SetRangeValuesMutation.id,params:u}]}),!0):!1}};function pi(i){return i.getContextValue(a.FOCUSING_SHEET)}function ie(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.EDITOR_ACTIVATED)}function yo(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.EDITOR_ACTIVATED)&&!i.getContextValue(a.FOCUSING_FORMULA_EDITOR)}function Qs(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)}function Js(i){return i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)}function Oo(i){return i.getContextValue(a.FOCUSING_FORMULA_EDITOR)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function qs(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function kt(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)&&!i.getContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA)&&!i.getContextValue(a.FOCUSING_EDITOR_STANDALONE)}var me=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(me||{}),j=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",i.VIEW_MAIN_TOP="viewMainTop",i.VIEW_MAIN_LEFT="viewMainLeft",i.VIEW_ROW_TOP="viewRowTop",i.VIEW_ROW_BOTTOM="viewRowBottom",i.VIEW_COLUMN_LEFT="viewColumnLeft",i.VIEW_COLUMN_RIGHT="viewColumnRight",i.VIEW_LEFT_TOP="viewLeftTop",i))(j||{});const No=0,tt=2,ea=3,vi=[10,400],xo=1001;var ta=Object.defineProperty,na=Object.getOwnPropertyDescriptor,ia=(i,t,e,n)=>{for(var o=n>1?void 0:n?na(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ta(t,e,o),o},Ci=(i,t)=>(e,n)=>t(e,n,i);N.SheetSkeletonManagerService=class{constructor(t,e,n){I(this,"_currentSkeleton",{unitId:"",sheetId:""});I(this,"_sheetSkeletonParam",[]);I(this,"_currentSkeleton$",new k.BehaviorSubject(null));I(this,"currentSkeleton$",this._currentSkeleton$.asObservable());I(this,"_currentSkeletonBefore$",new k.BehaviorSubject(null));I(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._univerInstanceService=t,this._injector=e,this._localeService=n}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getSkeleton(this._currentSkeleton)}getUnitSkeleton(t,e){return this._getSkeleton({unitId:t,sheetId:e})}setCurrent(t){this._setCurrent(t)}removeSkeleton(t){const e=this._sheetSkeletonParam.findIndex(n=>n.unitId===t.unitId);e!==-1&&(this._sheetSkeletonParam.splice(e,1),this._currentSkeletonBefore$.next(null),this._currentSkeleton$.next(null))}_compareSearch(t,e){return t==null||e==null?!1:t.commandId===e.commandId&&t.sheetId===e.sheetId&&t.unitId===e.unitId}_setCurrent(t){const e=this._getSkeleton(t);if(e!=null)this._reCalculate(e);else{const{unitId:o,sheetId:r}=t,s=this._univerInstanceService.getUniverSheetInstance(t.unitId),l=s==null?void 0:s.getSheetBySheetId(t.sheetId);if(l==null||s==null)return;const d=this._buildSkeleton(l,s);this._sheetSkeletonParam.push({unitId:o,sheetId:r,skeleton:d,dirty:!1})}this._currentSkeleton=t;const n=this.getCurrent();this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n)}reCalculate(){const t=this.getCurrent();t!=null&&this._reCalculate(t)}_reCalculate(t){t.dirty&&(t.skeleton.makeDirty(!0),t.dirty=!1),t.skeleton.calculate()}makeDirtyCurrent(t=!0){this.makeDirty(this._currentSkeleton,t)}makeDirty(t,e=!0){const n=this._getSkeleton(t);n!=null&&(n.dirty=e)}getOrCreateSkeleton(t){const e=this._getSkeleton(t);if(e)return e.skeleton;const n=this._univerInstanceService.getUniverSheetInstance(t.unitId),o=n==null?void 0:n.getSheetBySheetId(t.sheetId);if(!o||!n)return;const r=this._buildSkeleton(o,n);return this._sheetSkeletonParam.push({unitId:t.unitId,sheetId:t.sheetId,skeleton:r,dirty:!1}),r}_getSkeleton(t){const e=this._sheetSkeletonParam.find(n=>n.unitId===t.unitId&&n.sheetId===t.sheetId);return e!=null&&(e.commandId=t.commandId),e}_buildSkeleton(t,e){const n=t.getConfig();return this._injector.createInstance(T.SpreadsheetSkeleton,t,n,t.getCellMatrix(),e.getStyles())}},N.SheetSkeletonManagerService=ia([Ci(0,a.IUniverInstanceService),Ci(1,P.Inject(P.Injector)),Ci(2,P.Inject(a.LocaleService))],N.SheetSkeletonManagerService);class oa{constructor(){I(this,"_startColumn",-1);I(this,"_startRow",-1);I(this,"_endColumn",-1);I(this,"_endRow",-1);I(this,"_startX",0);I(this,"_startY",0);I(this,"_endX",0);I(this,"_endY",0);I(this,"_currentCell");I(this,"_rangeType",a.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:l,endColumn:d,endRow:c}=t;return e===s&&n===l&&o===d&&r===c}isInclude(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:l,endColumn:d,endRow:c}=t;return!(d<e||s>o||l>r||c<n)}highlightToSelection(){return a.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(t,e){const{startColumn:n,startRow:o,endColumn:r,endRow:s,startX:l,startY:d,endX:c,endY:u,rangeType:h}=t;this._startColumn=n,this._startRow=o,this._endColumn=r,this._endRow=s,this._startX=l,this._startY=d,this._endX=c,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(e)}setCurrentCell(t){t&&(this._currentCell=t)}clearCurrentCell(){this._currentCell=null}}const Ao=.3;class In extends a.Disposable{constructor(e,n,o=!0,r){super();I(this,"_leftControl");I(this,"_rightControl");I(this,"_topControl");I(this,"_bottomControl");I(this,"_backgroundControlTop");I(this,"_backgroundControlBottom");I(this,"_backgroundControlMiddleLeft");I(this,"_backgroundControlMiddleRight");I(this,"_fillControl");I(this,"_selectionShape");I(this,"_rowHeaderBackground");I(this,"_rowHeaderBorder");I(this,"_rowHeaderGroup");I(this,"_rowHeaderHighlight");I(this,"_columnHeaderBackground");I(this,"_columnHeaderBorder");I(this,"_columnHeaderGroup");I(this,"_columnHeaderHighlight");I(this,"_topLeftWidget");I(this,"_topCenterWidget");I(this,"_topRightWidget");I(this,"_middleLeftWidget");I(this,"_middleRightWidget");I(this,"_bottomLeftWidget");I(this,"_bottomCenterWidget");I(this,"_bottomRightWidget");I(this,"_dashRect");I(this,"_selectionModel");I(this,"_selectionStyle");I(this,"_rowHeaderWidth",0);I(this,"_columnHeaderHeight",0);I(this,"_widgetRects",[]);I(this,"_dispose$",new k.BehaviorSubject(this));I(this,"dispose$",this._dispose$.asObservable());I(this,"selectionMoving$",new k.Subject);I(this,"selectionMoved$",new k.Subject);I(this,"selectionScaling$",new k.Subject);I(this,"selectionScaled$",new k.Subject);I(this,"selectionFilling$",new k.Subject);I(this,"_selectionFilled$",new k.Subject);I(this,"selectionFilled$",this._selectionFilled$.asObservable());I(this,"_defaultStyle");I(this,"_currentStyle");I(this,"_isHelperSelection",!0);I(this,"_antLineOffset",0);I(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=n,this._isHeaderHighlight=o,this._themeService=r,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,n=0,o=0,r,s){this._selectionModel.setValue(e,s),r==null&&(r=this._selectionStyle),this._updateControl(r,n,o)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,n,o,r,s,l,d,c,u,h,m,f,g,S,p,R,M,E,b,w,y,O,x,D,W;(e=this._leftControl)==null||e.dispose(),(n=this._rightControl)==null||n.dispose(),(o=this._topControl)==null||o.dispose(),(r=this._bottomControl)==null||r.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(l=this._backgroundControlMiddleLeft)==null||l.dispose(),(d=this._backgroundControlMiddleRight)==null||d.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(u=this._fillControl)==null||u.dispose(),(h=this._selectionShape)==null||h.dispose(),(m=this._rowHeaderBackground)==null||m.dispose(),(f=this._rowHeaderBorder)==null||f.dispose(),(g=this._rowHeaderGroup)==null||g.dispose(),(S=this._rowHeaderBackground)==null||S.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(R=this._columnHeaderBorder)==null||R.dispose(),(M=this._columnHeaderGroup)==null||M.dispose(),(E=this._topLeftWidget)==null||E.dispose(),(b=this._topCenterWidget)==null||b.dispose(),(w=this._topRightWidget)==null||w.dispose(),(y=this._middleLeftWidget)==null||y.dispose(),(O=this._middleRightWidget)==null||O.dispose(),(x=this._bottomLeftWidget)==null||x.dispose(),(D=this._bottomCenterWidget)==null||D.dispose(),(W=this._bottomRightWidget)==null||W.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let n;if(e.isMerged){const o=e.mergeInfo;n={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn,startX:o.startX,endX:o.endX,startY:o.startY,endY:o.endY}}else{const{actualRow:o,actualColumn:r,startX:s,endX:l,startY:d,endY:c}=e;n={startRow:o,endRow:o,startColumn:r,endColumn:r,startX:s,endX:l,startY:d,endY:c}}return n}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,n,o){const{startX:r,startY:s,endX:l,endY:d}=this._selectionModel,c=this._defaultStyle;e==null&&(e=c),this._currentStyle=e;const{stroke:u=c.stroke,widgets:h=c.widgets,hasAutoFill:m=c.hasAutoFill,AutofillStroke:f=c.AutofillStroke,strokeDash:g,isAnimationDash:S}=e;let{strokeWidth:p=c.strokeWidth,AutofillSize:R=c.AutofillSize,AutofillStrokeWidth:M=c.AutofillStrokeWidth}=e;const E=this._getScale(),b=(p+_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/E;p/=E,R/=E,M/=E<1?1:E;const w=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/E,y=T.FIX_ONE_PIXEL_BLUR_OFFSET/E;if(this.leftControl.transformByState({height:d-s,left:-b+y,width:p,strokeWidth:w,top:-w/2+y}),this.leftControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:d-s,left:l-r-b+y,width:p,strokeWidth:w,top:-w/2+y}),this.rightControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:l-r+p,top:-b+y,left:-b+y,height:p,strokeWidth:w}),this.topControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:l-r+p,top:d-s-b+y,height:p,left:-b+y,strokeWidth:w}),this.bottomControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),g==null||d-s>1e6||l-r>1e5)this.dashRect.hide(),this._stopAntLineAnimation();else{const O=e.strokeWidth*2/E;this.dashRect.transformByState({height:d-s,width:l-r,strokeWidth:O,left:-O/2+y,top:-O/2+y}),this.dashRect.setProps({strokeDashArray:[0,g/E]}),this._stopAntLineAnimation(),S!==!1&&this._startAntLineAnimation(),this.dashRect.show()}m===!0&&!this._hasWidgets(h)?(this.fillControl.setProps({fill:u,stroke:f,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:R-M,height:R-M,left:l-r-R/2+M/2-y,top:d-s-R/2+M/2-y,strokeWidth:M}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,n,o),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,s),this._selectionStyle=e,this._rowHeaderWidth=n||0,this._columnHeaderHeight=o||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=_.getNormalSelectionStyle(this._themeService),this._selectionModel=new oa;const e=this._zIndex;this._leftControl=new T.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new T.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new T.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new T.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new T.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new T.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new T.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new T.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new T.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const n=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new T.Group("__SpreadsheetSelectionShape__"+e,...n,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e;const o=this.getScene();o.addObject(this._selectionShape,ea),this.disposeWithMe(a.toDisposable(o.onTransformChangeObservable.add(r=>{r.type===T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._updateControl(this._currentStyle,this._rowHeaderWidth,this._columnHeaderHeight)}))),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new T.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new T.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new T.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new T.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new T.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new T.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],T.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new T.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new T.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new T.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new T.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new T.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new T.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new T.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new T.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,n,o){const{startX:r,startY:s,endX:l,endY:d,rangeType:c}=this._selectionModel,u=this._defaultStyle;e==null&&(e=u);const h=this._getScale(),{stroke:m,hasRowHeader:f,rowHeaderFill:g=u.rowHeaderFill,rowHeaderStroke:S=u.rowHeaderStroke,hasColumnHeader:p,columnHeaderFill:R=u.columnHeaderFill,columnHeaderStroke:M=u.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:E=u.rowHeaderStrokeWidth,columnHeaderStrokeWidth:b=u.columnHeaderStrokeWidth}=e;if(E/=h,b/=h,p===!0){let w=R;this._isHeaderHighlight&&c===a.RANGE_TYPE.COLUMN&&(w=new a.ColorKit(m).setAlpha(Ao).toString()),this._columnHeaderBackground.setProps({fill:w}),this._columnHeaderBackground.resize(l-r,o),this._columnHeaderBorder.setProps({fill:M}),this._columnHeaderBorder.transformByState({width:l-r,height:b,top:o-b+1/h}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),f===!0){let w=g;this._isHeaderHighlight&&c===a.RANGE_TYPE.ROW&&(w=new a.ColorKit(m).setAlpha(Ao).toString()),this._rowHeaderBackground.setProps({fill:w}),this._rowHeaderBackground.resize(n,d-s),this._rowHeaderBorder.setProps({fill:S}),this._rowHeaderBorder.transformByState({width:E,height:d-s,left:n-E+1/h}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,s)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,l=this._defaultStyle;e==null&&(e=l);const d=this._getScale(),{fill:c=l.fill}=e;let{strokeWidth:u=l.strokeWidth}=e;u/=d;const h=this._selectionModel.highlightToSelection();if(!h){this._backgroundControlTop.resize(r-n,s-o),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:m,startY:f,endX:g,endY:S}=h,p=u/2,R={left:-p,top:-p,width:r-n+p*2,height:f-o+p};R.height<0&&(R.width=0,R.height=0),this._backgroundControlTop.transformByState(R);const M={left:-p,top:f-o,width:m-n+p,height:S-f};M.width<0&&(M.width=0,M.height=0),this._backgroundControlMiddleLeft.transformByState(M);const E={left:g-n-p,top:f-o,width:r-g+p*2,height:S-f};E.width<0&&(E.width=0,E.height=0),this._backgroundControlMiddleRight.transformByState(E);const b={left:-p,top:S-o,width:r-n+p*2,height:s-S+p};b.height<0&&(b.width=0,b.height=0),this._backgroundControlBottom.transformByState(b),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,l=this._defaultStyle;e==null&&(e=l);const{stroke:d=l.stroke,widgets:c=l.widgets,widgetStroke:u=l.widgetStroke}=e,h=this._getScale();let{widgetSize:m=l.widgetSize,widgetStrokeWidth:f=l.widgetStrokeWidth}=e;m/=h,f/=h;const g={left:-m/2+f/2,center:(r-n)/2-m/2+f/2,right:r-n-m/2+f/2,top:-m/2,middle:(s-o)/2-m/2,bottom:s-o-m/2+f/2},S=m-f;this._widgetRects.forEach(p=>{p.setProps({fill:d,stroke:u})}),c.tl===!0?(this._topLeftWidget.transformByState({height:S,width:S,left:g.left,top:g.top,strokeWidth:f}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:S,width:S,left:g.center,top:g.top,strokeWidth:f}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:S,width:S,left:g.right,top:g.top,strokeWidth:f}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:S,width:S,left:g.left,top:g.middle,strokeWidth:f}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:S,width:S,left:g.right,top:g.middle,strokeWidth:f}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:S,width:S,left:g.left,top:g.bottom,strokeWidth:f}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:S,width:S,left:g.center,top:g.bottom,strokeWidth:f}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:S,width:S,left:g.right,top:g.bottom,strokeWidth:f}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const n=Object.keys(e);if(n.length===0)return!1;for(const o of n)if(e[o]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:n}=this._scene.getAncestorScale();return Math.max(e,n)}_stopAntLineAnimation(){this._antLineOffset=0,T.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>16/e&&(this._antLineOffset=0),this.dashRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=T.requestNewFrame(()=>{this._startAntLineAnimation()})}}const Do="__SpreadsheetHelperSelectionTempRect",ra=35;class Po{constructor(t,e,n,o,r){I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_relativeSelectionPositionRow",0);I(this,"_relativeSelectionPositionColumn",0);I(this,"_relativeSelectionRowLength",0);I(this,"_relativeSelectionColumnLength",0);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_helperSelection");I(this,"_scrollTimer");I(this,"_activeViewport");I(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_isInMergeState",!1);I(this,"_fillControlColors",[]);this._control=t,this._skeleton=e,this._scene=n,this._themeService=o,this._injector=r,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var t,e;(t=this._scrollTimer)==null||t.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e;return(e=this._injector.get(N.SheetSkeletonManagerService).getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(t,e){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(e.viewPortKey){case j.VIEW_MAIN:return t.endRow>=n.startRow&&t.endColumn>=n.startColumn;case j.VIEW_MAIN_TOP:case j.VIEW_COLUMN_RIGHT:return t.endColumn>=n.startColumn&&t.startRow<n.startRow;case j.VIEW_MAIN_LEFT:case j.VIEW_ROW_BOTTOM:return t.endRow>=n.startRow&&t.startColumn<n.startColumn;case j.VIEW_MAIN_LEFT_TOP:case j.VIEW_COLUMN_LEFT:case j.VIEW_ROW_TOP:case j.VIEW_LEFT_TOP:return t.startRow<n.startRow&&t.startColumn<n.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:t,rightControl:e,topControl:n,bottomControl:o}=this._control;[t,e,n,o].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(T.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(t,e){var y;const n=this._scene,o=n.getScrollXYByRelativeCoords(T.Vector2.FromArray([t,e])),{scaleX:r,scaleY:s}=n.getAncestorScale(),l=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{row:d,column:c}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=d+this._relativeSelectionPositionRow;m<0&&(m=0);let f=m+this._relativeSelectionRowLength;f>u&&(f=u,f-m<this._relativeSelectionRowLength&&(m=f-this._relativeSelectionRowLength));let g=c+this._relativeSelectionPositionColumn;g<0&&(g=0);let S=g+this._relativeSelectionColumnLength;S>h&&(S=h,S-g<this._relativeSelectionColumnLength&&(g=S-this._relativeSelectionColumnLength));const p=this._skeleton.getNoMergeCellPositionByIndex(m,g),R=this._skeleton.getNoMergeCellPositionByIndex(f,S),M=(p==null?void 0:p.startY)||0,E=(R==null?void 0:R.endY)||0,b=(p==null?void 0:p.startX)||0,w=(R==null?void 0:R.endX)||0;(y=this._helperSelection)==null||y.transformByState({left:b,top:M,width:w-b,height:E-M}),this._targetSelection={startY:M,endY:E,startX:b,endX:w,startRow:m,endRow:f,startColumn:g,endColumn:S},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(T.Vector2.FromArray([e,n])),{x:s,y:l}=r,d=o.getScrollXYByRelativeCoords(r),{scaleX:c,scaleY:u}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,l,c,u,d);this._startOffsetX=s,this._startOffsetY=l;const{row:m,column:f}=h,{startRow:g,startColumn:S,endRow:p,endColumn:R}=this._control.model;let M=0,E=0;m<g?M-=1:m>p&&(M+=1),f<S?E-=1:f>R&&(E+=1),this._relativeSelectionPositionRow=g-m+M,this._relativeSelectionPositionColumn=S-f+E,this._relativeSelectionRowLength=p-g,this._relativeSelectionColumnLength=R-S;const b=this._control.selectionStyle,w=this._getScale();this.isHelperSelection&&(this._helperSelection=new T.Rect(Do,{stroke:b.stroke,strokeWidth:b.strokeWidth/w}),o.addObject(this._helperSelection));const y=o.getViewport(j.VIEW_MAIN),O=T.ScrollTimer.create(o);O.startScroll(s,l,y),this._scrollTimer=O,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(x=>{const{offsetX:D,offsetY:W}=x,{x:A,y:H}=o.getRelativeCoord(T.Vector2.FromArray([D,W]));this._controlMoving(A,H),o.setCursor(T.CURSOR_TYPE.MOVE),O.scrolling(A,H,()=>{this._controlMoving(A,H)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var D,W;(D=this._helperSelection)==null||D.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(W=this._scrollTimer)==null||W.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:t,topCenterWidget:e,topRightWidget:n,middleLeftWidget:o,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:d}=this._control,c=[T.CURSOR_TYPE.NORTH_WEST_RESIZE,T.CURSOR_TYPE.NORTH_RESIZE,T.CURSOR_TYPE.NORTH_EAST_RESIZE,T.CURSOR_TYPE.WEST_RESIZE,T.CURSOR_TYPE.EAST_RESIZE,T.CURSOR_TYPE.SOUTH_WEST_RESIZE,T.CURSOR_TYPE.SOUTH_RESIZE,T.CURSOR_TYPE.SOUTH_EAST_RESIZE];[t,e,n,o,r,s,l,d].forEach((u,h)=>{u.onPointerEnterObserver.add(()=>{u.setCursor(c[h])}),u.onPointerLeaveObserver.add(()=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,c[h])})})}_widgetMoving(t,e,n){const o=this._scene,r=o.getScrollXYByRelativeCoords(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=o.getAncestorScale(),d=this._skeleton.getCellPositionByOffset(t,e,s,l,r),{row:c,column:u}=d,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let f=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=c,p=u;n===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(f=c,g=u,S=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn):n===T.CURSOR_TYPE.NORTH_RESIZE?(f=c,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===T.CURSOR_TYPE.NORTH_EAST_RESIZE?(f=c,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,p=u):n===T.CURSOR_TYPE.WEST_RESIZE?(f=this._relativeSelectionPositionRow,g=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn):n===T.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===T.CURSOR_TYPE.SOUTH_WEST_RESIZE?(f=this._relativeSelectionPositionRow,g=u,S=c,p=this._relativeSelectionPositionColumn):n===T.CURSOR_TYPE.SOUTH_RESIZE&&(f=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=c,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:R,startColumn:M,endRow:E,endColumn:b}=this._swapPositions(f,g,S,p),w=this._skeleton.getNoMergeCellPositionByIndex(R,M),y=this._skeleton.getNoMergeCellPositionByIndex(E,b),O=(w==null?void 0:w.startY)||0,x=(y==null?void 0:y.endY)||0,D=(w==null?void 0:w.startX)||0,W=(y==null?void 0:y.endX)||0;this._targetSelection={startY:O,endY:x,startX:D,endX:W,startRow:f,endRow:S,startColumn:g,endColumn:p},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(t,e){const{offsetX:n,offsetY:o}=t,r=this._scene,s=r.getRelativeCoord(T.Vector2.FromArray([n,o])),{x:l,y:d}=s;this._startOffsetX=n,this._startOffsetY=o;const{startRow:c,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-c,this._relativeSelectionColumnLength=m-u,e===T.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):e===T.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:e===T.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:e===T.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:e===T.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const f=T.ScrollTimer.create(r);f.startScroll(l,d),this._scrollTimer=f,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(g=>{const{offsetX:S,offsetY:p}=g,{x:R,y:M}=r.getRelativeCoord(T.Vector2.FromArray([S,p]));this._widgetMoving(R,M,e),r.setCursor(e),f.scrolling(R,M,()=>{this._widgetMoving(R,M,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var S;const g=this._scene;g.resetCursor(),this._clearObserverEvent(),g.enableEvent(),(S=this._scrollTimer)==null||S.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:t}=this._control;t.onPointerEnterObserver.add(()=>{t.setCursor(T.CURSOR_TYPE.CROSSHAIR)}),t.onPointerLeaveObserver.add(()=>{t.resetCursor()}),t.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(t,e){var W,A,H;const n=this._scene,o=n.getScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=n.getAncestorScale(),l=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{row:d,column:c}=l,u=n.getRelativeCoord(T.Vector2.FromArray([t,e])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let f=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,R=!1,M=!0;if((c<g||c>p)&&d>=f&&d<=S){const B=this._fillRuler(c,g,p,this._relativeSelectionColumnLength,m);g=B.startRowOrColumn,p=B.endRowOrColumn,R=B.isLighten,M=!1}else if((d<f||d>S)&&c>=g&&c<=p){const B=this._fillRuler(d,f,S,this._relativeSelectionRowLength,h);f=B.startRowOrColumn,S=B.endRowOrColumn,R=B.isLighten}else if(Math.abs(this._startOffsetX-u.x-o.x)/2>Math.abs(this._startOffsetY-u.y-o.y)){const B=this._fillRuler(c,g,p,this._relativeSelectionColumnLength,m);g=B.startRowOrColumn,p=B.endRowOrColumn,R=B.isLighten,M=!1}else{const B=this._fillRuler(d,f,S,this._relativeSelectionRowLength,h);f=B.startRowOrColumn,S=B.endRowOrColumn,R=B.isLighten}const E=this._skeleton.getNoMergeCellPositionByIndex(f,g),b=this._skeleton.getNoMergeCellPositionByIndex(S,p),w=(E==null?void 0:E.startY)||0,y=(b==null?void 0:b.endY)||0,O=(E==null?void 0:E.startX)||0,x=(b==null?void 0:b.endX)||0;R?this._controlHandler((B,z)=>{const Y=new a.ColorKit(this._fillControlColors[z]).lighten(ra).toRgbString();B.setProps({fill:Y})}):this._controlHandler((B,z)=>{B.setProps({fill:this._fillControlColors[z]})});const D=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();f===S&&M===!0||g===p&&M===!1?(W=this._helperSelection)==null||W.hide():((A=this._helperSelection)==null||A.transformByState({left:O-D/2,top:w-D/2,width:x-O,height:y-w}),(H=this._helperSelection)==null||H.show()),this._targetSelection={startY:w,endY:y,startX:O,endX:x,startRow:f,endRow:S,startColumn:g,endColumn:p},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(T.Vector2.FromArray([e,n])),{x:s,y:l}=r;this._startOffsetX=s,this._startOffsetY=l;const{startRow:d,startColumn:c,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(d,c,u,h),this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=c,this._relativeSelectionRowLength=u-d,this._relativeSelectionColumnLength=h-c;const m=this._control.selectionStyle;let f=m==null?void 0:m.stroke,g=m==null?void 0:m.strokeWidth;const S=_.getNormalSelectionStyle(this._themeService);f==null&&(f=S.stroke),g==null&&(g=S.strokeWidth);const p=this._getScale();g/=p;const R=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/p,M=new a.ColorKit(f).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new T.Rect(Do,{stroke:M,strokeWidth:g+R/2}),o.addObject(this._helperSelection)),this._activeViewport=o.getActiveViewportByCoord(T.Vector2.FromArray([e,n]));const E=o.getViewport(j.VIEW_MAIN),b=T.ScrollTimer.create(o,this._activeViewport.viewPortKey===j.VIEW_MAIN?T.ScrollTimerType.ALL:T.ScrollTimerType.NONE);b.startScroll(s,l,E),this._scrollTimer=b,o.disableEvent(),this._controlHandler(w=>{this._fillControlColors.push(w.fill)}),this._moveObserver=o.onPointerMoveObserver.add(w=>{var H;const{offsetX:y,offsetY:O}=w,x=o.getActiveViewportByCoord(T.Vector2.FromArray([y,O])),{x:D,y:W}=o.getRelativeCoord(T.Vector2.FromArray([y,O]));this._fillMoving(D,W),o.setCursor(T.CURSOR_TYPE.CROSSHAIR);const A=this._targetSelection;if(E&&x&&((H=this._activeViewport)==null?void 0:H.viewPortKey)!==(x==null?void 0:x.viewPortKey)){let B;A.startRow!==d?(b.scrollTimerType=T.ScrollTimerType.Y,B={...A,endRow:A.startRow}):A.endRow!==u?(b.scrollTimerType=T.ScrollTimerType.Y,B={...A,startRow:A.endRow}):A.startColumn!==c?(b.scrollTimerType=T.ScrollTimerType.X,B={...A,endColumn:A.startColumn}):(b.scrollTimerType=T.ScrollTimerType.X,B={...A,startColumn:A.endColumn}),this._isSelectionInViewport(B,x)&&(E.scrollTo({x:b.scrollTimerType===T.ScrollTimerType.X?0:void 0,y:b.scrollTimerType===T.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}b.scrolling(D,W,()=>{this._fillMoving(D,W)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var y,O;(y=this._helperSelection)==null||y.dispose();const w=this._scene;w.resetCursor(),this._clearObserverEvent(),w.enableEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,D)=>{x.setProps({fill:this._fillControlColors[D]})}),this._fillControlColors=[]})}_hasMergeInRange(t,e,n,o){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:l,startColumn:d,endRow:c,endColumn:u}=s,h={left:e,top:t,right:o,bottom:n},m={left:d,top:l,right:u,bottom:c};if(T.isRectIntersect(h,m))return!0}return!1}_swapPositions(t,e,n,o){const r=Math.min(t,n),s=Math.min(e,o),l=Math.max(t,n),d=Math.max(e,o);return{startRow:r,startColumn:s,endRow:l,endColumn:d}}_controlHandler(t){const{leftControl:e,rightControl:n,topControl:o,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:d,backgroundControlBottom:c,fillControl:u}=this._control,h=[e,n,o,r,s,l,d,c,u];for(let m=0,f=h.length;m<f;m++){const g=h[m];t(g,m)}}_fillRuler(t,e,n,o,r){let s=!1;if(t<e)if(this._isInMergeState&&t<e){const l=e-t,d=o+1,c=Math.ceil(l/d);let u=e-c*d;u<0&&(u=e-(c-1)*d),e=u}else e=t;else if(t>=e&&t<=n)s=!0,this._isInMergeState||(n=t);else if(this._isInMergeState&&t>n){const l=t-n,d=o+1,c=Math.ceil(l/d);let u=n+c*d;u>r&&(u=n+(c-1)*d),n=u}else n=t;return{rowOrColumn:t,startRowOrColumn:e,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:t,scaleY:e}=this._scene.getAncestorScale();return Math.max(t,e)}}var sa=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,la=(i,t,e,n)=>{for(var o=n>1?void 0:n?aa(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&sa(t,e,o),o},Rn=(i,t)=>(e,n)=>t(e,n,i);N.SelectionRenderService=class{constructor(t,e,n,o){I(this,"hasSelection",!1);I(this,"_downObserver");I(this,"_moveObserver");I(this,"_upObserver");I(this,"_controlFillConfig$",new k.BehaviorSubject(null));I(this,"controlFillConfig$",this._controlFillConfig$.asObservable());I(this,"_selectionControls",[]);I(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_scrollTimer");I(this,"_cancelDownObserver");I(this,"_cancelUpObserver");I(this,"_skeleton");I(this,"_scene");I(this,"_isHeaderHighlight",!0);I(this,"_isDetectMergedCell",!0);I(this,"_selectionStyle");I(this,"_isSelectionEnabled",!0);I(this,"_isShowPreviousEnable",0);I(this,"_isRemainLastEnable",!0);I(this,"_isSkipRemainLastEnable",!1);I(this,"_isSingleSelection",!1);I(this,"_selectionMoveEnd$",new k.BehaviorSubject([]));I(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());I(this,"_selectionMoving$",new k.Subject);I(this,"selectionMoving$",this._selectionMoving$.asObservable());I(this,"_selectionMoveStart$",new k.Subject);I(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());I(this,"_activeViewport");this._themeService=t,this._shortcutService=e,this._sheetSkeletonManagerService=n,this._injector=o,this._selectionStyle=_.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(t){this._selectionStyle=t}resetStyle(){this.setStyle(_.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}enableSingleSelection(){this._isSingleSelection=!0}disableSingleSelection(){this._isSingleSelection=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const{rangeWithCoord:n,primaryWithCoord:o}=t,r=this._skeleton;let s=t.style;s==null&&(s=_.getNormalSelectionStyle(this._themeService));const l=this._scene;if(l==null||r==null)return;const d=new In(l,e.length,this._isHeaderHighlight,this._themeService);new Po(d,r,l,this._themeService,this._injector);const{rowHeaderWidth:c,columnHeaderHeight:u}=r;d.update(n,c,u,s,o),this._isHeaderHighlight?d.enableHeaderHighlight():d.disableHeaderHighlight(),e.push(d)}updateControlForCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:o,columnHeaderHeight:r}=n;for(let s=0,l=t.length;s<l;s++){const{rangeWithCoord:d,primaryWithCoord:c,style:u}=t[s];e[s].update(d,o,r,u,c)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(t,e,n){this._skeleton=t,this._scene=e,this._activeViewport=n||e.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(e=>e.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const t=this.getCurrentControls();if(t.length>0){for(const e of t)e.dispose();t.length=0}}_getFreeze(){var e;return(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_getViewportByCell(t,e){if(!this._scene||t===void 0||e===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(j.VIEW_MAIN);if(t>n.startRow&&e>n.startColumn)return this._scene.getViewport(j.VIEW_MAIN);if(t<=n.startRow&&e<=n.startColumn)return this._scene.getViewport(j.VIEW_MAIN_LEFT_TOP);if(t<=n.startRow&&e>n.startColumn)return this._scene.getViewport(j.VIEW_MAIN_TOP);if(t>n.startRow&&e<=n.startColumn)return this._scene.getViewport(j.VIEW_MAIN_LEFT)}getActiveSelections(){const t=this.getCurrentControls();if(t&&t.length>0)return t==null?void 0:t.map(n=>{const o=n.model,r=o.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn},primary:s}})}getActiveRange(){const t=this.getCurrentControls(),e=t&&t[t.length-1].model;return e&&{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}getActiveSelection(){const t=this.getCurrentControls();return t&&t[t.length-1]}endSelection(){this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}reset(){var t,e,n;this._clearSelectionControls(),(t=this._moveObserver)==null||t.dispose(),(e=this._upObserver)==null||e.dispose(),(n=this._downObserver)==null||n.dispose(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(t,e=0,n=a.RANGE_TYPE.NORMAL,o,r=T.ScrollTimerType.ALL){var Z,ee;if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:l,offsetY:d}=t,c=this._scene;if(c==null||s==null)return;o!=null&&(this._activeViewport=o);const u=c.getViewport(j.VIEW_MAIN),h=c.getRelativeCoord(T.Vector2.FromArray([l,d]));let{x:m,y:f}=h;this._startOffsetX=m,this._startOffsetY=f;const g=c.getScrollXYByRelativeCoords(h),{scaleX:S,scaleY:p}=c.getAncestorScale();n===a.RANGE_TYPE.ROW?m=0:n===a.RANGE_TYPE.COLUMN&&(f=0);const R=this._getSelectedRangeWithMerge(m,f,S,p,g);if(!R)return!1;const{rangeWithCoord:M,primaryWithCoord:E}=R,{startRow:b,startColumn:w,endColumn:y,endRow:O,startY:x,endY:D,startX:W,endX:A}=M,{rowHeaderWidth:H,columnHeaderHeight:B}=s,z={startColumn:w,startRow:b,endColumn:y,endRow:O,startY:x,endY:D,startX:W,endX:A,rangeType:n};this._startSelectionRange=z;let Y=this.getActiveSelection();const Q=this.getCurrentControls();if(!Q)return!1;for(const ne of Q){if(t.button===2&&ne.model.isInclude(z)){Y=ne;return}if(ne.model.isEqual(z)){Y=ne;break}t.shiftKey||ne.clearHighlight()}if(Q.length>0&&!t.ctrlKey&&!t.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable||Q.length>0&&this._isSingleSelection&&!t.shiftKey){for(const ne of Q)ne.dispose();Q.length=0}const J=Y&&Y.model.currentCell;if(Y&&t.shiftKey&&J){const{actualRow:ne,actualColumn:de,mergeInfo:fe}=J,be=Math.min(ne,z.startRow,fe.startRow),Te=Math.max(ne,z.endRow,fe.endRow),De=Math.min(de,z.startColumn,fe.startColumn),Je=Math.max(de,z.endColumn,fe.endColumn),ve=s.getMergeBounding(be,De,Te,Je),he=s.getNoMergeCellPositionByIndex(ve.startRow,ve.startColumn),se=s.getNoMergeCellPositionByIndex(ve.endRow,ve.endColumn),qe={startColumn:ve.startColumn,startRow:ve.startRow,endColumn:ve.endColumn,endRow:ve.endRow,startY:he.startY,endY:se.endY,startX:he.startX,endX:se.endX,rangeType:n},Ce=s.getCellByIndex(ne,de);this._startSelectionRange={startColumn:Ce.mergeInfo.startColumn,startRow:Ce.mergeInfo.startRow,endColumn:Ce.mergeInfo.endColumn,endRow:Ce.mergeInfo.endRow,startY:Ce.mergeInfo.startY||0,endY:Ce.mergeInfo.endY||0,startX:Ce.mergeInfo.startX||0,endX:Ce.mergeInfo.endX||0,rangeType:n},Y.update(qe,H,B,this._selectionStyle,J)}else this._isRemainLastEnable&&Y&&!t.ctrlKey&&!t.shiftKey&&!this._isSkipRemainLastEnable&&!this._isSingleSelection?Y.update(z,H,B,this._selectionStyle,E):(Y=new In(c,Q.length+e,this._isHeaderHighlight,this._themeService),new Po(Y,s,c,this._themeService,this._injector),Y.update(z,H,B,this._selectionStyle,E),Q.push(Y));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),c.disableEvent();const X=c.getActiveViewportByCoord(T.Vector2.FromArray([m,f])),q=T.ScrollTimer.create(this._scene,r);q.startScroll((Z=u==null?void 0:u.left)!=null?Z:0,(ee=u==null?void 0:u.top)!=null?ee:0,u),this._scrollTimer=q,this._addCancelObserver(),(n===a.RANGE_TYPE.ROW||n===a.RANGE_TYPE.COLUMN)&&this._moving(m,f,Y,n);let L=0,U=0,F=m,$=f;this._moveObserver=c.onPointerMoveObserver.add(ne=>{var Ce,un,hn,mn,fn,Os,Ns,xs,As,Ds;const{offsetX:de,offsetY:fe}=ne,{x:be,y:Te}=c.getRelativeCoord(T.Vector2.FromArray([de,fe]));this._moving(be,Te,Y,n);let De=be,Je=Te;const ve=this.getActiveSelection(),he=(Ce=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Ce.skeleton.getWorksheetConfig().freeze,se=ve==null?void 0:ve.model,qe=(un=c.getActiveViewportByCoord(T.Vector2.FromArray([de,fe])))!=null?un:this._getViewportByCell(se==null?void 0:se.endRow,se==null?void 0:se.endColumn);if(X&&qe&&u){const _o=F<u.left&&be>u.left||F>u.left&&be<u.left,po=$<u.top&&Te>u.top||$>u.top&&Te<u.top;_o&&(L+=1),po&&(U+=1);const Ye=X.viewPortKey,gn=qe.viewPortKey;if(Ye===j.VIEW_ROW_TOP)fe<u.top&&((hn=se==null?void 0:se.endRow)!=null?hn:0)<((mn=he==null?void 0:he.startRow)!=null?mn:0)?Je=u.top:po&&U%2===1&&u.scrollTo({y:0});else if(Ye===j.VIEW_COLUMN_LEFT)de<u.left&&((fn=se==null?void 0:se.endColumn)!=null?fn:0)<((Os=he==null?void 0:he.startColumn)!=null?Os:0)?De=u.left:_o&&L%2===1&&u.scrollTo({x:0});else if(Ye===gn){let et=!1,_t=!1;Ye===j.VIEW_MAIN_LEFT_TOP?(et=!0,_t=!0):Ye===j.VIEW_MAIN_TOP?_t=!0:Ye===j.VIEW_MAIN_LEFT&&(et=!0),((Ns=se==null?void 0:se.endRow)!=null?Ns:0)>((xs=he==null?void 0:he.startRow)!=null?xs:0)&&(_t=!1),((As=se==null?void 0:se.endColumn)!=null?As:0)>((Ds=he==null?void 0:he.startColumn)!=null?Ds:0)&&(et=!1),et&&(De=u.left),_t&&(Je=u.top)}else{const et={x:X.scrollX,y:X.scrollY},_t={x:qe.scrollX,y:qe.scrollY},vo=et.x!==_t.x&&_o&&L%2===1,Co=et.y!==_t.y&&po&&U%2===1;(vo||Co)&&(u.scrollTo({x:vo?et.x:void 0,y:Co?et.y:void 0}),vo||(De=u.left),Co||(Je=u.top)),(Ye===j.VIEW_MAIN_LEFT_TOP&&gn===j.VIEW_MAIN_LEFT||gn===j.VIEW_MAIN_LEFT_TOP&&Ye===j.VIEW_MAIN_LEFT)&&(De=u.left),(Ye===j.VIEW_MAIN_LEFT_TOP&&gn===j.VIEW_MAIN_TOP||gn===j.VIEW_MAIN_LEFT_TOP&&Ye===j.VIEW_MAIN_TOP)&&(Je=u.top)}F=be,$=Te}q.scrolling(De,Je,()=>{this._moving(be,Te,Y,n)})}),this._upObserver=c.onPointerUpObserver.add(ne=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(t){const{range:e,primary:n,style:o}=t;let r=this.convertRangeDataToSelection(e);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:a.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:o}}convertRangeDataToSelection(t){const{startRow:e,startColumn:n,endRow:o,endColumn:r,rangeType:s}=t,l=this._scene,d=this._skeleton;if(l==null||d==null)return;l.getAncestorScale();const c=d.getNoMergeCellPositionByIndex(e,n),u=d.getNoMergeCellPositionByIndex(o,r);return{startRow:e,startColumn:n,endRow:o,endColumn:r,rangeType:s,startY:(c==null?void 0:c.startY)||0,endY:(u==null?void 0:u.endY)||0,startX:(c==null?void 0:c.startX)||0,endX:(u==null?void 0:u.endX)||0}}convertCellRangeToInfo(t){if(t==null)return;const e=this._scene,n=this._skeleton;if(e==null||n==null)return;const{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:l,startRow:d,startColumn:c,endRow:u,endColumn:h}=t,m=n.getNoMergeCellPositionByIndex(o,r),f=n.getNoMergeCellPositionByIndex(d,c),g=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:l,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY,mergeInfo:{startRow:d,startColumn:c,endRow:u,endColumn:h,startY:(f==null?void 0:f.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(f==null?void 0:f.startX)||0,endX:(g==null?void 0:g.endX)||0}}}_moving(t,e,n,o){var ee;const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:l,startColumn:d,endRow:c,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:f,endColumn:g}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},S=s.getViewport(j.VIEW_MAIN),p=(ee=this._getViewportByCell(m,g))!=null?ee:S,R=s.getScrollXYByRelativeCoords(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),p),{scaleX:M,scaleY:E}=s.getAncestorScale(),{rowHeaderWidth:b,columnHeaderHeight:w}=r;o===a.RANGE_TYPE.ROW?t=Number.POSITIVE_INFINITY:o===a.RANGE_TYPE.COLUMN&&(e=Number.POSITIVE_INFINITY);const y=this._getSelectedRangeWithMerge(t,e,M,E,R);if(!y)return!1;const{rangeWithCoord:O,primaryWithCoord:x}=y,{startRow:D,startColumn:W,endColumn:A,endRow:H}=O,B=Math.min(D,l),z=Math.min(W,d),Y=Math.max(H,c),Q=Math.max(A,u);let J={startRow:B,startColumn:z,endRow:Y,endColumn:Q};if(this._isDetectMergedCell&&(J=r.getSelectionBounding(B,z,Y,Q)),!J)return!1;const{startRow:X,startColumn:q,endRow:L,endColumn:U}=J,F=r.getNoMergeCellPositionByIndex(X,q),$=r.getNoMergeCellPositionByIndex(L,U),Z={startColumn:q,startRow:X,endColumn:U,endRow:L,startY:(F==null?void 0:F.startY)||0,endY:($==null?void 0:$.endY)||0,startX:(F==null?void 0:F.startX)||0,endX:($==null?void 0:$.endX)||0};(f!==q||h!==X||g!==U||m!==L)&&n!=null&&(n.update(Z,b,w),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,o;const t=this._scene;if(t==null)return;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),t.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const e=(o=t.getEngine())==null?void 0:o.activeScene;e==null||e.onPointerDownObserver.remove(this._cancelDownObserver),e==null||e.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const t=this._scene;if(t==null)return;const e=(n=t.getEngine())==null?void 0:n.activeScene;e==null||e===t||(e.onPointerDownObserver.remove(this._cancelDownObserver),e.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=e.onPointerDownObserver.add(o=>{this._endSelection()}),this._cancelUpObserver=e.onPointerUpObserver.add(o=>{this._endSelection()}))}_getSelectedRangeWithMerge(t,e,n,o,r){var R;if(this._isDetectMergedCell){const M=(R=this._skeleton)==null?void 0:R.calculateCellIndexByPosition(t,e,n,o,r),E=a.makeCellToSelection(M);return E==null?void 0:{primaryWithCoord:M,rangeWithCoord:E}}const s=this._skeleton;if(s==null)return;const l=s.getCellPositionByOffset(t,e,n,o,r),{row:d,column:c}=l,u=s.getNoMergeCellPositionByIndex(d,c),{startX:h,startY:m,endX:f,endY:g}=u,S={startY:m,endY:g,startX:h,endX:f,startRow:d,endRow:d,startColumn:c,endColumn:c};return{primaryWithCoord:{actualRow:d,actualColumn:c,isMerged:!1,isMergedMainCell:!1,startY:m,endY:g,startX:h,endX:f,mergeInfo:S},rangeWithCoord:S}}},N.SelectionRenderService=la([Rn(0,P.Inject(a.ThemeService)),Rn(1,C.IShortcutService),Rn(2,P.Inject(N.SheetSkeletonManagerService)),Rn(3,P.Inject(P.Injector))],N.SelectionRenderService);const Ie=P.createIdentifier("deprecated.univer.sheet.selection-render-service");var ca=Object.defineProperty,da=Object.getOwnPropertyDescriptor,ua=(i,t,e,n)=>{for(var o=n>1?void 0:n?da(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ca(t,e,o),o},Ft=(i,t)=>(e,n)=>t(e,n,i);const ha=1e4,Wt=P.createIdentifier("univer.mark-selection-service");N.MarkSelectionService=class extends a.Disposable{constructor(e,n,o,r,s){super();I(this,"_shapeMap",new Map);this._currentService=e,this._renderManagerService=n,this._selectionRenderService=o,this._sheetSkeletonManagerService=r,this._themeService=s}addShape(e,n=[],o=ha){const r=this._currentService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet().getSheetId(),l=a.Tools.generateRandomId();return this._shapeMap.set(l,{selection:e,subUnitId:s,unitId:r.getUnitId(),zIndex:o,control:null,exits:n}),this.refreshShapes(),l}refreshShapes(){const e=this._currentService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=this._currentService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId();this._shapeMap.forEach(o=>{var M;const{unitId:r,subUnitId:s,selection:l,control:d,zIndex:c}=o;if(d&&d.dispose(),r!==e||s!==n)return;const{style:u}=l,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:f}=this._selectionRenderService.convertSelectionRangeToData(l),g=(M=this._sheetSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(!h||!g)return;const{rowHeaderWidth:S,columnHeaderHeight:p}=g,R=new In(h,c,!1,this._themeService);R.update(m,S,p,u,f),o.control=R})}getShapeMap(){return this._shapeMap}removeShape(e){const n=this._shapeMap.get(e);if(!n)return;const{control:o}=n;o&&o.dispose(),this._shapeMap.delete(e)}removeAllShapes(){for(const e of this._shapeMap.values()){const{control:n}=e;n&&n.dispose()}this._shapeMap.clear()}},N.MarkSelectionService=ua([Ft(0,a.IUniverInstanceService),Ft(1,T.IRenderManagerService),Ft(2,Ie),Ft(3,P.Inject(N.SheetSkeletonManagerService)),Ft(4,P.Inject(a.ThemeService))],N.MarkSelectionService);function vt(i,t,e,n){const o=t.get(a.IUniverInstanceService),r=e?o.getUnit(e,a.UniverInstanceType.UNIVER_SHEET):o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=n?r==null?void 0:r.getSheetBySheetId(n):r==null?void 0:r.getActiveSheet();if(!s)return null;const{startRow:l,endRow:d,startColumn:c,endColumn:u}=i,h=[],m=[];for(let f=l;f<=d;f++)s.getRowFiltered(f)||h.push(f);for(let f=c;f<=u;f++)m.push(f);return{rows:h,cols:m}}function lt(i){const{rows:t,cols:e}=i;return{startRow:t[0],endRow:t[t.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function jt(i){let t=[],e=[];const n=[];return i.forEach(o=>{t.push(...o.rows),e.push(...o.cols)}),t=Array.from(new Set(t)).sort((o,r)=>o-r),e=Array.from(new Set(e)).sort((o,r)=>o-r),i.forEach(o=>{n.push({startRow:t.findIndex(r=>r===o.rows[0]),endRow:t.findIndex(r=>r===o.rows[o.rows.length-1]),startColumn:e.findIndex(r=>r===o.cols[0]),endColumn:e.findIndex(r=>r===o.cols[o.cols.length-1])})}),{ranges:n,mapFunc:(o,r)=>({row:t[o],col:e[r]})}}function ma(i){const t=new a.ObjectMatrix;return i.forEach(e=>{const{rows:n,cols:o}=e;n.forEach(r=>{o.forEach(s=>{t.setValue(r,s,{v:null,p:null,f:null,si:null})})})}),t.getData()}const fa=10,ga=6;function Sa(){return a.Tools.generateRandomId(ga)}function _a(i){const t=i.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class pa{constructor(){I(this,"_cache",new a.LRUMap(fa))}set(t,e){this._cache.set(t,e)}get(t){return this._cache.get(t)}del(t){this._cache.delete(t)}clear(){this._cache.clear()}}function Ho(i,t){const e=t!=null?t:i.style,n={},o=i.tagName.toLowerCase();switch(o){case"b":case"em":case"strong":{n.bl=a.BooleanNumber.TRUE;break}case"s":{n.st={s:a.BooleanNumber.TRUE};break}case"u":{n.ul={s:a.BooleanNumber.TRUE};break}case"i":{n.it=a.BooleanNumber.TRUE;break}case"sub":case"sup":{n.va=o==="sup"?a.BaselineOffset.SUPERSCRIPT:a.BaselineOffset.SUBSCRIPT;break}}return va(e,n),n}function va(i,t){for(let e=0;e<i.length;e++){const n=i[e],o=i.getPropertyValue(n);switch(n){case"font-family":{t.ff=o;break}case"font-size":{const r=Number.parseInt(o);if(!Number.isNaN(r)){if(o.endsWith("pt"))t.fs=r;else if(o.endsWith("px")){const s=r*.75;t.fs=s}}break}case"font-style":{o==="italic"&&(t.it=a.BooleanNumber.TRUE);break}case"font-weight":{(Number(o)>400||o==="bold")&&(t.bl=a.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(o)?t.ul={s:a.BooleanNumber.TRUE}:/overline/.test(o)?t.ol={s:a.BooleanNumber.TRUE}:/line-through/.test(o)&&(t.st={s:a.BooleanNumber.TRUE});break}case"color":{const r=new a.ColorKit(o);r.isValid&&(t.cl={rgb:r.toRgbString()});break}case"background-color":{const r=new a.ColorKit(o),s=r.isValid?r.toRgbString():"";s!==C.DEFAULT_BACKGROUND_COLOR_RGB&&s!==C.DEFAULT_BACKGROUND_COLOR_RGBA&&(t.bg={rgb:r.toRgbString()});break}}}}function Ca(i){const t=new DOMParser,e=`<x-univer id="univer-root">${i}</x-univer>`;return t.parseFromString(e,"text/html").querySelector("#univer-root")}function Ii(i,t){const e=[];for(let n=0,o=i.length;n<o;n++)i[n]===a.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:n});if(t)for(const n of e)t.bullet&&(n.bullet=a.Tools.deepClone(t.bullet)),t.paragraphStyle&&(n.paragraphStyle=a.Tools.deepClone(t.paragraphStyle));return e}const Ia=["color_color","background_background","font-size_fontSize","text-align_textAlign","vertical-align_verticalAlign","font-weight_fontWeight","font-style_fontStyle","font-family_fontFamily","text-decoration_textDecoration","white-space_whiteSpace","word-wrap_wordWrap"],Ra=["border-left_borderLeft","border-right_borderRight","border-top_borderTop","border-bottom_borderBottom"];function Lo(i,t){const e=i.tagName.toLowerCase();return typeof t=="string"?e===t:Array.isArray(t)?t.some(n=>n===e):t(i)}function Ma(i){i.style.display="none",i.style.width="0",i.style.height="0",i.setAttribute("tabindex","-1"),i.setAttribute("aria-hidden","true"),i.setAttribute("title","hidden iframe")}const mi=class mi{constructor(t){I(this,"styleCache",new Map);I(this,"styleRules",[]);I(this,"afterProcessRules",[]);I(this,"htmlElement");I(this,"getCurrentSkeleton");this.getCurrentSkeleton=t.getCurrentSkeleton,this.htmlElement=document.createElement("iframe"),this.htmlElement.style.display="none",document.body.appendChild(this.htmlElement),Ma(this.htmlElement)}static use(t){if(this.pluginList.includes(t))throw new Error(`Univer paste plugin ${t.name} already added`);this.pluginList.push(t)}convert(t){this.htmlElement.contentDocument&&(this.htmlElement.contentDocument.open(),this.htmlElement.contentDocument.write(t),this.htmlElement.contentDocument.close()),t=t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style[\s\S]*?<\/style>/g,"");const e=mi.pluginList.find(f=>f.checkPasteType(t));e&&(this.styleRules=[...e.stylesRules],this.afterProcessRules=[...e.afterProcessRules]);const n=new a.ObjectMatrix,o=Ca(t),r={dataStream:"",textRuns:[]},s=[],l=[],d=t.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi),c=[];this.process(null,o==null?void 0:o.childNodes,r,c);const{paragraphs:u,dataStream:h,textRuns:m}=r;if(u){const f=u.map(g=>g.startIndex+1);f.unshift(0);for(let g=0;g<f.length;g++){let S;g===f.length-1?S=`${h.substring(f[g])}\r
|
|
1
|
+
(function(N,q){typeof exports=="object"&&typeof module<"u"?q(exports,require("@univerjs/docs"),require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@wendellhu/redi"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs/operators"),require("@univerjs/design"),require("@univerjs/engine-numfmt"),require("@univerjs/engine-formula"),require("@wendellhu/redi/react-bindings"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/docs","@univerjs/core","@univerjs/sheets","@univerjs/ui","@wendellhu/redi","rxjs","@univerjs/docs-ui","@univerjs/engine-render","rxjs/operators","@univerjs/design","@univerjs/engine-numfmt","@univerjs/engine-formula","@wendellhu/redi/react-bindings","react","clsx"],q):(N=typeof globalThis<"u"?globalThis:N||self,q(N.UniverSheetsUi={},N.UniverDocs,N.UniverCore,N.UniverSheets,N.UniverUi,N["@wendellhu/redi"],N.rxjs,N.UniverDocsUi,N.UniverEngineRender,N.rxjs.operators,N.UniverDesign,N.UniverEngineNumfmt,N.UniverEngineFormula,N["@wendellhu/redi/react-bindings"],N.React,N.clsx))})(this,function(N,q,a,_,C,P,k,gi,w,Ps,re,Sn,K,Z,V,Pe){"use strict";var Ef=Object.defineProperty;var yf=(N,q,a)=>q in N?Ef(N,q,{enumerable:!0,configurable:!0,writable:!0,value:a}):N[q]=a;var I=(N,q,a)=>(yf(N,typeof q!="symbol"?q+"":q,a),a);var fi;const Hs="SheetUI";function _n(i,t){if(i==null)return;const e=t.getRenderById(i);if(e==null)return;const{mainComponent:n,scene:o,engine:r,components:s}=e,l=n,d=s.get(q.DOCS_VIEW_KEY.BACKGROUND);return{document:l,docBackground:d,scene:o,engine:r}}const Si={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},pn=["零","一","二","三","四","五","六","七","八","九"],Co=["","万","亿","万亿","亿亿"],Ls=["","十","百","千"],Io={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Xe(i){if(!i)return 0;let t=0,e=0,n=0,o=!1;const r=i.split("");for(let s=0;s<r.length;s++){const l=Si[r[s]];if(typeof l<"u")n=l,s===r.length-1&&(e+=n);else{const d=Io[r[s]],c=d.value;o=d.secUnit,o?(e=(e+n)*c,t+=e,e=0):e+=n*c,n=0}}return t+e}function Us(i){let t="",e="",n=0,o=!0;for(;i>0;){const r=i%10;r===0?o||(o=!0,e=pn[r]+e):(o=!1,t=pn[r],t+=Ls[n],e=t+e),n++,i=Math.floor(i/10)}return e}function Vs(i){let t=0,e="",n="",o=!1;if(i===0)return pn[0];for(;i>0;){const r=i%1e4;o&&(n=pn[0]+n),e=Us(r),e+=r!==0?Co[t]:Co[0],n=e+n,o=r<1e3&&r>0,i=Math.floor(i/1e4),t++}return n}function Bs(i){if(!i)return!1;let t=!0;if(i)if(i.length===1)i==="日"||i in Si?t=!0:t=!1;else{const e=i.split("");for(let n=0;n<e.length;n++)if(!(e[n]in Si||e[n]in Io)){t=!1;break}}return t}function vn(i){if(!i)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,e=t.test(i);if(e){const n=i.match(t);if(n&&n.length>0){const o=n[n.length-1],r=i.lastIndexOf(o),s=i.substr(0,r),l=i.substr(r+o.length);return{isExtendNumber:!0,matchTxt:Number(o),beforeTxt:s,afterTxt:l}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function ks(i){let t;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?t=!0:t=!1,t}function Fs(i){let t;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?t=!0:t=!1,t}function Ws(i,t){let e=0;for(let n=0;n<i.length&&i[n]<t;n++)e++;return e}function Vt(i){let t=!0;const e=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==e){t=!1;break}return t}function js(i,t,e){const n=[],o=Math.floor(t/i),r=t%i;let s=0;if(o>0){for(let l=0;l<o;l++)for(let d=0;d<e.length;d++)n[e[d]+l*i]=s,s++;for(let l=0;l<e.length&&e[l]<r;l++)n[e[l]+i*o]=s,s++}else for(let l=0;l<e.length&&e[l]<r;l++)n[e[l]]=s,s++;return n}function at(i,t){const e=[];for(let n=1;n<=t;n++){const o=(n-1)%i.length,r=a.Tools.deepClone(i[o]);e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function zs(i,t){var n;const e=[];for(let o=1;o<=t;o++){const r=(o-1)%i.length,s={s:(n=i[r])==null?void 0:n.s};e.push(s)}return e}function Ys(i){let t=!0;const e=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==e){t=!1;break}return t}function Xs(i){const t=[];for(let e=1;e<=i;e++)t.push(e);return t}function Ro(i,t,e){var r,s,l,d;const n=[],o=[];for(let c=0;c<i.length;c++)o.push(Number((r=i[c])==null?void 0:r.v));if(i.length>2&&Ys(o))for(let c=1;c<=t;c++){const u=(c-1)%i.length,h=a.Tools.deepClone(i[u]),m=Number((s=i[i.length-1])==null?void 0:s.v)*(Number((l=i[1])==null?void 0:l.v)/Number((d=i[0])==null?void 0:d.v))**c;h&&(h.t!==a.CellValueType.BOOLEAN&&(h.v=m),n.push(h))}else{const c=Xs(i.length);for(let u=1;u<=t;u++){const h=(u-1)%i.length,m=a.Tools.deepClone(i[h]),f=e===a.Direction.DOWN||e===a.Direction.RIGHT,g=$s(i.length+u,o,c,f);m&&(m.t!==a.CellValueType.BOOLEAN&&(m.v=g),n.push(m))}}return n}function $s(i,t,e,n=!0){function o(h){let m=0;for(let f=0;f<h.length;f++)m+=h[f];return m/h.length}const r=o(e),s=o(t);let l=0,d=0;for(let h=0;h<e.length;h++)l+=(e[h]-r)*(t[h]-s),d+=(e[h]-r)*(e[h]-r);let c;d===0?c=n?1:-1:c=l/d;const u=s-c*r;return Math.round((u+c*i)*1e5)/1e5}function Mo(i,t,e){var r;const n=[],o=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const l=(s-1)%i.length,d=a.Tools.deepClone(i[l]),c=`${(r=i[i.length-1])==null?void 0:r.v}`,u=c==null?void 0:c.match(o),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+e*s);if(!c||!h)continue;const f=c.lastIndexOf(h),g=c.substr(0,f)+m.toString()+c.substr(f+h.length);d&&(d.v=g,n.push(d))}return n}function pt(i,t,e,n=0){var l,d;const o=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=o.length)return[];const r=o[n],s=[];for(let c=1;c<=t;c++){const u=(c-1)%i.length,h=a.Tools.deepClone(i[u]);let m=0;if(((l=i[i.length-1])==null?void 0:l.v)===r[0])m=7+e*c;else{const g=`${(d=i[i.length-1])==null?void 0:d.v}`;if(g){const S=g.substr(g.length-1,1);m=Xe(S)+e*c}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const f=m%7;h&&(h.v=r[f],s.push(h))}return s}function bo(i,t,e){var o;const n=[];for(let r=1;r<=t;r++){const s=(r-1)%i.length,l=a.Tools.deepClone(i[s]),d=`${(o=i[i.length-1])==null?void 0:o.v}`,c=Xe(d)+e*r;let u;c<=0?u="零":u=Vs(c),l&&(l.v=u,n.push(l))}return n}const Bt={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Gs(i){let t=!1;return Object.keys(Bt).forEach(e=>{Bt[e].includes(i)&&(t=!0)}),t}function _i(i){let t="";const e=[];return Object.keys(Bt).forEach(n=>{Bt[n].includes(i)&&(t=n,e.push(...Bt[n]))}),{name:t,series:e}}function To(i,t,e,n){var s;const o=n.length,r=[];for(let l=1;l<=t;l++){const d=(l-1)%i.length,c=a.Tools.deepClone(i[d]),u=`${(s=i[i.length-1])==null?void 0:s.v}`;let h=n.indexOf(u)+e*l;h<0&&(h+=Math.abs(e)*o);const m=h%o;c&&(c.v=n[m],r.push(c))}return r}function Zs(i,t){const e=[];let n;if(t.startRow<i.startRow)n=a.Direction.UP;else if(t.endRow>i.endRow)n=a.Direction.DOWN;else if(t.startColumn<i.startColumn)n=a.Direction.LEFT;else if(t.endColumn>i.endColumn)n=a.Direction.RIGHT;else return[];if(n===a.Direction.DOWN||n===a.Direction.UP){const o=i.endRow-i.startRow+1,r=t.endRow-t.startRow+1,s=Math.floor(r/o),l=r%o,d={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===a.Direction.DOWN){for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow+(c+1)*o,col:i.startColumn},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow+(s+1)*o,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:l-1,endColumn:i.endColumn-i.startColumn}})}else{for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow-(c+1)*o,col:i.startColumn},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow-(s+1)*o,col:i.startColumn},relativeRange:{startRow:o-l,endRow:o-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===a.Direction.RIGHT||n===a.Direction.LEFT){const o=i.endColumn-i.startColumn+1,r=t.endColumn-t.startColumn+1,s=Math.floor(r/o),l=r%o,d={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===a.Direction.RIGHT){for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(c+1)*o},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*o},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:l-1}})}else{for(let c=0;c<s;c++)e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(c+1)*o},relativeRange:d});l>0&&e.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*o},relativeRange:{startRow:0,startColumn:o-l,endRow:i.endRow-i.startRow,endColumn:o-1}})}}return e}function Ks(i){const t=new a.ObjectMatrix;return i.forEach(e=>{const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;for(let l=n;l<=r;l++)for(let d=o;d<=s;d++)t.setValue(l,d,{v:null,p:null,f:null,si:null})}),t.getData()}const wo={type:a.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,t)=>!0},Cn={id:"sheet.command.auto-clear-content",type:a.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(a.IUniverInstanceService),n=i.get(a.ICommandService),o=i.get(a.IUndoRedoService),r=_.getSheetCommandTarget(e);if(!r)return!1;const{unitId:s,subUnitId:l}=r,{clearRange:d,selectionRange:c}=t,u={subUnitId:l,unitId:s,cellValue:Ks([d])},h=_.SetRangeValuesUndoMutationFactory(i,u),{startColumn:m,startRow:f}=c;return n.executeCommand(_.SetSelectionsOperation.id,{selections:[{primary:{startColumn:m,startRow:f,endColumn:m,endRow:f,actualRow:f,actualColumn:m,isMerge:!1,isMergedMainCell:!1},range:{...c}}],unitId:s,subUnitId:l}),n.syncExecuteCommand(_.SetRangeValuesMutation.id,u)?(o.pushUndoRedo({unitID:s,undoMutations:[{id:_.SetRangeValuesMutation.id,params:h}],redoMutations:[{id:_.SetRangeValuesMutation.id,params:u}]}),!0):!1}};function pi(i){return i.getContextValue(a.FOCUSING_SHEET)}function ie(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.EDITOR_ACTIVATED)}function Eo(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&!i.getContextValue(a.EDITOR_ACTIVATED)&&!i.getContextValue(a.FOCUSING_FORMULA_EDITOR)}function Qs(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)}function Js(i){return i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)}function yo(i){return i.getContextValue(a.FOCUSING_FORMULA_EDITOR)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function qs(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)}function kt(i){return i.getContextValue(a.FOCUSING_SHEET)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)&&!i.getContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA)&&!i.getContextValue(a.FOCUSING_EDITOR_STANDALONE)}var me=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(me||{}),j=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",i.VIEW_MAIN_TOP="viewMainTop",i.VIEW_MAIN_LEFT="viewMainLeft",i.VIEW_ROW_TOP="viewRowTop",i.VIEW_ROW_BOTTOM="viewRowBottom",i.VIEW_COLUMN_LEFT="viewColumnLeft",i.VIEW_COLUMN_RIGHT="viewColumnRight",i.VIEW_LEFT_TOP="viewLeftTop",i))(j||{});const Oo=0,tt=2,ea=3,vi=[10,400],No=1001;var ta=Object.defineProperty,na=Object.getOwnPropertyDescriptor,ia=(i,t,e,n)=>{for(var o=n>1?void 0:n?na(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ta(t,e,o),o},Ci=(i,t)=>(e,n)=>t(e,n,i);N.SheetSkeletonManagerService=class{constructor(t,e,n){I(this,"_currentSkeleton",{unitId:"",sheetId:""});I(this,"_sheetSkeletonParam",[]);I(this,"_currentSkeleton$",new k.BehaviorSubject(null));I(this,"currentSkeleton$",this._currentSkeleton$.asObservable());I(this,"_currentSkeletonBefore$",new k.BehaviorSubject(null));I(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._univerInstanceService=t,this._injector=e,this._localeService=n}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getSkeleton(this._currentSkeleton)}getUnitSkeleton(t,e){return this._getSkeleton({unitId:t,sheetId:e})}setCurrent(t){this._setCurrent(t)}removeSkeleton(t){const e=this._sheetSkeletonParam.findIndex(n=>n.unitId===t.unitId);e!==-1&&(this._sheetSkeletonParam.splice(e,1),this._currentSkeletonBefore$.next(null),this._currentSkeleton$.next(null))}_compareSearch(t,e){return t==null||e==null?!1:t.commandId===e.commandId&&t.sheetId===e.sheetId&&t.unitId===e.unitId}_setCurrent(t){const e=this._getSkeleton(t);if(e!=null)this._reCalculate(e);else{const{unitId:o,sheetId:r}=t,s=this._univerInstanceService.getUniverSheetInstance(t.unitId),l=s==null?void 0:s.getSheetBySheetId(t.sheetId);if(l==null||s==null)return;const d=this._buildSkeleton(l,s);this._sheetSkeletonParam.push({unitId:o,sheetId:r,skeleton:d,dirty:!1})}this._currentSkeleton=t;const n=this.getCurrent();this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n)}reCalculate(){const t=this.getCurrent();t!=null&&this._reCalculate(t)}_reCalculate(t){t.dirty&&(t.skeleton.makeDirty(!0),t.dirty=!1),t.skeleton.calculate()}makeDirtyCurrent(t=!0){this.makeDirty(this._currentSkeleton,t)}makeDirty(t,e=!0){const n=this._getSkeleton(t);n!=null&&(n.dirty=e)}getOrCreateSkeleton(t){const e=this._getSkeleton(t);if(e)return e.skeleton;const n=this._univerInstanceService.getUniverSheetInstance(t.unitId),o=n==null?void 0:n.getSheetBySheetId(t.sheetId);if(!o||!n)return;const r=this._buildSkeleton(o,n);return this._sheetSkeletonParam.push({unitId:t.unitId,sheetId:t.sheetId,skeleton:r,dirty:!1}),r}_getSkeleton(t){const e=this._sheetSkeletonParam.find(n=>n.unitId===t.unitId&&n.sheetId===t.sheetId);return e!=null&&(e.commandId=t.commandId),e}_buildSkeleton(t,e){const n=t.getConfig();return this._injector.createInstance(w.SpreadsheetSkeleton,t,n,t.getCellMatrix(),e.getStyles())}},N.SheetSkeletonManagerService=ia([Ci(0,a.IUniverInstanceService),Ci(1,P.Inject(P.Injector)),Ci(2,P.Inject(a.LocaleService))],N.SheetSkeletonManagerService);class oa{constructor(){I(this,"_startColumn",-1);I(this,"_startRow",-1);I(this,"_endColumn",-1);I(this,"_endRow",-1);I(this,"_startX",0);I(this,"_startY",0);I(this,"_endX",0);I(this,"_endY",0);I(this,"_currentCell");I(this,"_rangeType",a.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:l,endColumn:d,endRow:c}=t;return e===s&&n===l&&o===d&&r===c}isInclude(t){const{startColumn:e,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:l,endColumn:d,endRow:c}=t;return!(d<e||s>o||l>r||c<n)}highlightToSelection(){return a.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(t,e){const{startColumn:n,startRow:o,endColumn:r,endRow:s,startX:l,startY:d,endX:c,endY:u,rangeType:h}=t;this._startColumn=n,this._startRow=o,this._endColumn=r,this._endRow=s,this._startX=l,this._startY=d,this._endX=c,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(e)}setCurrentCell(t){t&&(this._currentCell=t)}clearCurrentCell(){this._currentCell=null}}const xo=.3;class In extends a.Disposable{constructor(e,n,o=!0,r){super();I(this,"_leftControl");I(this,"_rightControl");I(this,"_topControl");I(this,"_bottomControl");I(this,"_backgroundControlTop");I(this,"_backgroundControlBottom");I(this,"_backgroundControlMiddleLeft");I(this,"_backgroundControlMiddleRight");I(this,"_fillControl");I(this,"_selectionShape");I(this,"_rowHeaderBackground");I(this,"_rowHeaderBorder");I(this,"_rowHeaderGroup");I(this,"_rowHeaderHighlight");I(this,"_columnHeaderBackground");I(this,"_columnHeaderBorder");I(this,"_columnHeaderGroup");I(this,"_columnHeaderHighlight");I(this,"_topLeftWidget");I(this,"_topCenterWidget");I(this,"_topRightWidget");I(this,"_middleLeftWidget");I(this,"_middleRightWidget");I(this,"_bottomLeftWidget");I(this,"_bottomCenterWidget");I(this,"_bottomRightWidget");I(this,"_dashRect");I(this,"_selectionModel");I(this,"_selectionStyle");I(this,"_rowHeaderWidth",0);I(this,"_columnHeaderHeight",0);I(this,"_widgetRects",[]);I(this,"_dispose$",new k.BehaviorSubject(this));I(this,"dispose$",this._dispose$.asObservable());I(this,"selectionMoving$",new k.Subject);I(this,"selectionMoved$",new k.Subject);I(this,"selectionScaling$",new k.Subject);I(this,"selectionScaled$",new k.Subject);I(this,"selectionFilling$",new k.Subject);I(this,"_selectionFilled$",new k.Subject);I(this,"selectionFilled$",this._selectionFilled$.asObservable());I(this,"_defaultStyle");I(this,"_currentStyle");I(this,"_isHelperSelection",!0);I(this,"_antLineOffset",0);I(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=n,this._isHeaderHighlight=o,this._themeService=r,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,n=0,o=0,r,s){this._selectionModel.setValue(e,s),r==null&&(r=this._selectionStyle),this._updateControl(r,n,o)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,n,o,r,s,l,d,c,u,h,m,f,g,S,p,R,M,T,b,E,y,O,x,D,W;(e=this._leftControl)==null||e.dispose(),(n=this._rightControl)==null||n.dispose(),(o=this._topControl)==null||o.dispose(),(r=this._bottomControl)==null||r.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(l=this._backgroundControlMiddleLeft)==null||l.dispose(),(d=this._backgroundControlMiddleRight)==null||d.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(u=this._fillControl)==null||u.dispose(),(h=this._selectionShape)==null||h.dispose(),(m=this._rowHeaderBackground)==null||m.dispose(),(f=this._rowHeaderBorder)==null||f.dispose(),(g=this._rowHeaderGroup)==null||g.dispose(),(S=this._rowHeaderBackground)==null||S.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(R=this._columnHeaderBorder)==null||R.dispose(),(M=this._columnHeaderGroup)==null||M.dispose(),(T=this._topLeftWidget)==null||T.dispose(),(b=this._topCenterWidget)==null||b.dispose(),(E=this._topRightWidget)==null||E.dispose(),(y=this._middleLeftWidget)==null||y.dispose(),(O=this._middleRightWidget)==null||O.dispose(),(x=this._bottomLeftWidget)==null||x.dispose(),(D=this._bottomCenterWidget)==null||D.dispose(),(W=this._bottomRightWidget)==null||W.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let n;if(e.isMerged){const o=e.mergeInfo;n={startRow:o.startRow,endRow:o.endRow,startColumn:o.startColumn,endColumn:o.endColumn,startX:o.startX,endX:o.endX,startY:o.startY,endY:o.endY}}else{const{actualRow:o,actualColumn:r,startX:s,endX:l,startY:d,endY:c}=e;n={startRow:o,endRow:o,startColumn:r,endColumn:r,startX:s,endX:l,startY:d,endY:c}}return n}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,n,o){const{startX:r,startY:s,endX:l,endY:d}=this._selectionModel,c=this._defaultStyle;e==null&&(e=c),this._currentStyle=e;const{stroke:u=c.stroke,widgets:h=c.widgets,hasAutoFill:m=c.hasAutoFill,AutofillStroke:f=c.AutofillStroke,strokeDash:g,isAnimationDash:S}=e;let{strokeWidth:p=c.strokeWidth,AutofillSize:R=c.AutofillSize,AutofillStrokeWidth:M=c.AutofillStrokeWidth}=e;const T=this._getScale(),b=(p+_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/T;p/=T,R/=T,M/=T<1?1:T;const E=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/T,y=w.FIX_ONE_PIXEL_BLUR_OFFSET/T;if(this.leftControl.transformByState({height:d-s,left:-b+y,width:p,strokeWidth:E,top:-E/2+y}),this.leftControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:d-s,left:l-r-b+y,width:p,strokeWidth:E,top:-E/2+y}),this.rightControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:l-r+p,top:-b+y,left:-b+y,height:p,strokeWidth:E}),this.topControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:l-r+p,top:d-s-b+y,height:p,left:-b+y,strokeWidth:E}),this.bottomControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),g==null||d-s>1e6||l-r>1e5)this.dashRect.hide(),this._stopAntLineAnimation();else{const O=e.strokeWidth*2/T;this.dashRect.transformByState({height:d-s,width:l-r,strokeWidth:O,left:-O/2+y,top:-O/2+y}),this.dashRect.setProps({strokeDashArray:[0,g/T]}),this._stopAntLineAnimation(),S!==!1&&this._startAntLineAnimation(),this.dashRect.show()}m===!0&&!this._hasWidgets(h)?(this.fillControl.setProps({fill:u,stroke:f,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:R-M,height:R-M,left:l-r-R/2+M/2-y,top:d-s-R/2+M/2-y,strokeWidth:M}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,n,o),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,s),this._selectionStyle=e,this._rowHeaderWidth=n||0,this._columnHeaderHeight=o||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=_.getNormalSelectionStyle(this._themeService),this._selectionModel=new oa;const e=this._zIndex;this._leftControl=new w.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new w.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new w.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new w.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new w.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new w.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new w.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new w.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const n=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new w.Group("__SpreadsheetSelectionShape__"+e,...n,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e;const o=this.getScene();o.addObject(this._selectionShape,ea),this.disposeWithMe(a.toDisposable(o.onTransformChangeObservable.add(r=>{r.type===w.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._updateControl(this._currentStyle,this._rowHeaderWidth,this._columnHeaderHeight)}))),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new w.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new w.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new w.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new w.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new w.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new w.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],w.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new w.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new w.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new w.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new w.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new w.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new w.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new w.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new w.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,n,o){const{startX:r,startY:s,endX:l,endY:d,rangeType:c}=this._selectionModel,u=this._defaultStyle;e==null&&(e=u);const h=this._getScale(),{stroke:m,hasRowHeader:f,rowHeaderFill:g=u.rowHeaderFill,rowHeaderStroke:S=u.rowHeaderStroke,hasColumnHeader:p,columnHeaderFill:R=u.columnHeaderFill,columnHeaderStroke:M=u.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:T=u.rowHeaderStrokeWidth,columnHeaderStrokeWidth:b=u.columnHeaderStrokeWidth}=e;if(T/=h,b/=h,p===!0){let E=R;this._isHeaderHighlight&&c===a.RANGE_TYPE.COLUMN&&(E=new a.ColorKit(m).setAlpha(xo).toString()),this._columnHeaderBackground.setProps({fill:E}),this._columnHeaderBackground.resize(l-r,o),this._columnHeaderBorder.setProps({fill:M}),this._columnHeaderBorder.transformByState({width:l-r,height:b,top:o-b+1/h}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),f===!0){let E=g;this._isHeaderHighlight&&c===a.RANGE_TYPE.ROW&&(E=new a.ColorKit(m).setAlpha(xo).toString()),this._rowHeaderBackground.setProps({fill:E}),this._rowHeaderBackground.resize(n,d-s),this._rowHeaderBorder.setProps({fill:S}),this._rowHeaderBorder.transformByState({width:T,height:d-s,left:n-T+1/h}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,s)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,l=this._defaultStyle;e==null&&(e=l);const d=this._getScale(),{fill:c=l.fill}=e;let{strokeWidth:u=l.strokeWidth}=e;u/=d;const h=this._selectionModel.highlightToSelection();if(!h){this._backgroundControlTop.resize(r-n,s-o),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:m,startY:f,endX:g,endY:S}=h,p=u/2,R={left:-p,top:-p,width:r-n+p*2,height:f-o+p};R.height<0&&(R.width=0,R.height=0),this._backgroundControlTop.transformByState(R);const M={left:-p,top:f-o,width:m-n+p,height:S-f};M.width<0&&(M.width=0,M.height=0),this._backgroundControlMiddleLeft.transformByState(M);const T={left:g-n-p,top:f-o,width:r-g+p*2,height:S-f};T.width<0&&(T.width=0,T.height=0),this._backgroundControlMiddleRight.transformByState(T);const b={left:-p,top:S-o,width:r-n+p*2,height:s-S+p};b.height<0&&(b.width=0,b.height=0),this._backgroundControlBottom.transformByState(b),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:n,startY:o,endX:r,endY:s}=this._selectionModel,l=this._defaultStyle;e==null&&(e=l);const{stroke:d=l.stroke,widgets:c=l.widgets,widgetStroke:u=l.widgetStroke}=e,h=this._getScale();let{widgetSize:m=l.widgetSize,widgetStrokeWidth:f=l.widgetStrokeWidth}=e;m/=h,f/=h;const g={left:-m/2+f/2,center:(r-n)/2-m/2+f/2,right:r-n-m/2+f/2,top:-m/2,middle:(s-o)/2-m/2,bottom:s-o-m/2+f/2},S=m-f;this._widgetRects.forEach(p=>{p.setProps({fill:d,stroke:u})}),c.tl===!0?(this._topLeftWidget.transformByState({height:S,width:S,left:g.left,top:g.top,strokeWidth:f}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:S,width:S,left:g.center,top:g.top,strokeWidth:f}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:S,width:S,left:g.right,top:g.top,strokeWidth:f}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:S,width:S,left:g.left,top:g.middle,strokeWidth:f}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:S,width:S,left:g.right,top:g.middle,strokeWidth:f}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:S,width:S,left:g.left,top:g.bottom,strokeWidth:f}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:S,width:S,left:g.center,top:g.bottom,strokeWidth:f}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:S,width:S,left:g.right,top:g.bottom,strokeWidth:f}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const n=Object.keys(e);if(n.length===0)return!1;for(const o of n)if(e[o]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:n}=this._scene.getAncestorScale();return Math.max(e,n)}_stopAntLineAnimation(){this._antLineOffset=0,w.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>16/e&&(this._antLineOffset=0),this.dashRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=w.requestNewFrame(()=>{this._startAntLineAnimation()})}}const Ao="__SpreadsheetHelperSelectionTempRect",ra=35;class Do{constructor(t,e,n,o,r){I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_relativeSelectionPositionRow",0);I(this,"_relativeSelectionPositionColumn",0);I(this,"_relativeSelectionRowLength",0);I(this,"_relativeSelectionColumnLength",0);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_helperSelection");I(this,"_scrollTimer");I(this,"_activeViewport");I(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_isInMergeState",!1);I(this,"_fillControlColors",[]);this._control=t,this._skeleton=e,this._scene=n,this._themeService=o,this._injector=r,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var t,e;(t=this._scrollTimer)==null||t.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e;return(e=this._injector.get(N.SheetSkeletonManagerService).getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(t,e){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(e.viewPortKey){case j.VIEW_MAIN:return t.endRow>=n.startRow&&t.endColumn>=n.startColumn;case j.VIEW_MAIN_TOP:case j.VIEW_COLUMN_RIGHT:return t.endColumn>=n.startColumn&&t.startRow<n.startRow;case j.VIEW_MAIN_LEFT:case j.VIEW_ROW_BOTTOM:return t.endRow>=n.startRow&&t.startColumn<n.startColumn;case j.VIEW_MAIN_LEFT_TOP:case j.VIEW_COLUMN_LEFT:case j.VIEW_ROW_TOP:case j.VIEW_LEFT_TOP:return t.startRow<n.startRow&&t.startColumn<n.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:t,rightControl:e,topControl:n,bottomControl:o}=this._control;[t,e,n,o].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(w.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(t,e){var y;const n=this._scene,o=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([t,e])),{scaleX:r,scaleY:s}=n.getAncestorScale(),l=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{row:d,column:c}=l,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=d+this._relativeSelectionPositionRow;m<0&&(m=0);let f=m+this._relativeSelectionRowLength;f>u&&(f=u,f-m<this._relativeSelectionRowLength&&(m=f-this._relativeSelectionRowLength));let g=c+this._relativeSelectionPositionColumn;g<0&&(g=0);let S=g+this._relativeSelectionColumnLength;S>h&&(S=h,S-g<this._relativeSelectionColumnLength&&(g=S-this._relativeSelectionColumnLength));const p=this._skeleton.getNoMergeCellPositionByIndex(m,g),R=this._skeleton.getNoMergeCellPositionByIndex(f,S),M=(p==null?void 0:p.startY)||0,T=(R==null?void 0:R.endY)||0,b=(p==null?void 0:p.startX)||0,E=(R==null?void 0:R.endX)||0;(y=this._helperSelection)==null||y.transformByState({left:b,top:M,width:E-b,height:T-M}),this._targetSelection={startY:M,endY:T,startX:b,endX:E,startRow:m,endRow:f,startColumn:g,endColumn:S},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([e,n])),{x:s,y:l}=r,d=o.getScrollXYByRelativeCoords(r),{scaleX:c,scaleY:u}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,l,c,u,d);this._startOffsetX=s,this._startOffsetY=l;const{row:m,column:f}=h,{startRow:g,startColumn:S,endRow:p,endColumn:R}=this._control.model;let M=0,T=0;m<g?M-=1:m>p&&(M+=1),f<S?T-=1:f>R&&(T+=1),this._relativeSelectionPositionRow=g-m+M,this._relativeSelectionPositionColumn=S-f+T,this._relativeSelectionRowLength=p-g,this._relativeSelectionColumnLength=R-S;const b=this._control.selectionStyle,E=this._getScale();this.isHelperSelection&&(this._helperSelection=new w.Rect(Ao,{stroke:b.stroke,strokeWidth:b.strokeWidth/E}),o.addObject(this._helperSelection));const y=o.getViewport(j.VIEW_MAIN),O=w.ScrollTimer.create(o);O.startScroll(s,l,y),this._scrollTimer=O,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(x=>{const{offsetX:D,offsetY:W}=x,{x:A,y:H}=o.getRelativeCoord(w.Vector2.FromArray([D,W]));this._controlMoving(A,H),o.setCursor(w.CURSOR_TYPE.MOVE),O.scrolling(A,H,()=>{this._controlMoving(A,H)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var D,W;(D=this._helperSelection)==null||D.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(W=this._scrollTimer)==null||W.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:t,topCenterWidget:e,topRightWidget:n,middleLeftWidget:o,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:l,bottomRightWidget:d}=this._control,c=[w.CURSOR_TYPE.NORTH_WEST_RESIZE,w.CURSOR_TYPE.NORTH_RESIZE,w.CURSOR_TYPE.NORTH_EAST_RESIZE,w.CURSOR_TYPE.WEST_RESIZE,w.CURSOR_TYPE.EAST_RESIZE,w.CURSOR_TYPE.SOUTH_WEST_RESIZE,w.CURSOR_TYPE.SOUTH_RESIZE,w.CURSOR_TYPE.SOUTH_EAST_RESIZE];[t,e,n,o,r,s,l,d].forEach((u,h)=>{u.onPointerEnterObserver.add(()=>{u.setCursor(c[h])}),u.onPointerLeaveObserver.add(()=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,c[h])})})}_widgetMoving(t,e,n){const o=this._scene,r=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:l}=o.getAncestorScale(),d=this._skeleton.getCellPositionByOffset(t,e,s,l,r),{row:c,column:u}=d,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let f=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=c,p=u;n===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(f=c,g=u,S=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.NORTH_RESIZE?(f=c,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===w.CURSOR_TYPE.NORTH_EAST_RESIZE?(f=c,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,p=u):n===w.CURSOR_TYPE.WEST_RESIZE?(f=this._relativeSelectionPositionRow,g=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===w.CURSOR_TYPE.SOUTH_WEST_RESIZE?(f=this._relativeSelectionPositionRow,g=u,S=c,p=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.SOUTH_RESIZE&&(f=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=c,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:R,startColumn:M,endRow:T,endColumn:b}=this._swapPositions(f,g,S,p),E=this._skeleton.getNoMergeCellPositionByIndex(R,M),y=this._skeleton.getNoMergeCellPositionByIndex(T,b),O=(E==null?void 0:E.startY)||0,x=(y==null?void 0:y.endY)||0,D=(E==null?void 0:E.startX)||0,W=(y==null?void 0:y.endX)||0;this._targetSelection={startY:O,endY:x,startX:D,endX:W,startRow:f,endRow:S,startColumn:g,endColumn:p},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(t,e){const{offsetX:n,offsetY:o}=t,r=this._scene,s=r.getRelativeCoord(w.Vector2.FromArray([n,o])),{x:l,y:d}=s;this._startOffsetX=n,this._startOffsetY=o;const{startRow:c,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-c,this._relativeSelectionColumnLength=m-u,e===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):e===w.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:e===w.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:e===w.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:e===w.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const f=w.ScrollTimer.create(r);f.startScroll(l,d),this._scrollTimer=f,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(g=>{const{offsetX:S,offsetY:p}=g,{x:R,y:M}=r.getRelativeCoord(w.Vector2.FromArray([S,p]));this._widgetMoving(R,M,e),r.setCursor(e),f.scrolling(R,M,()=>{this._widgetMoving(R,M,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var S;const g=this._scene;g.resetCursor(),this._clearObserverEvent(),g.enableEvent(),(S=this._scrollTimer)==null||S.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:t}=this._control;t.onPointerEnterObserver.add(()=>{t.setCursor(w.CURSOR_TYPE.CROSSHAIR)}),t.onPointerLeaveObserver.add(()=>{t.resetCursor()}),t.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(t,e){var W,A,H;const n=this._scene,o=n.getScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=n.getAncestorScale(),l=this._skeleton.getCellPositionByOffset(t,e,r,s,o),{row:d,column:c}=l,u=n.getRelativeCoord(w.Vector2.FromArray([t,e])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let f=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,R=!1,M=!0;if((c<g||c>p)&&d>=f&&d<=S){const B=this._fillRuler(c,g,p,this._relativeSelectionColumnLength,m);g=B.startRowOrColumn,p=B.endRowOrColumn,R=B.isLighten,M=!1}else if((d<f||d>S)&&c>=g&&c<=p){const B=this._fillRuler(d,f,S,this._relativeSelectionRowLength,h);f=B.startRowOrColumn,S=B.endRowOrColumn,R=B.isLighten}else if(Math.abs(this._startOffsetX-u.x-o.x)/2>Math.abs(this._startOffsetY-u.y-o.y)){const B=this._fillRuler(c,g,p,this._relativeSelectionColumnLength,m);g=B.startRowOrColumn,p=B.endRowOrColumn,R=B.isLighten,M=!1}else{const B=this._fillRuler(d,f,S,this._relativeSelectionRowLength,h);f=B.startRowOrColumn,S=B.endRowOrColumn,R=B.isLighten}const T=this._skeleton.getNoMergeCellPositionByIndex(f,g),b=this._skeleton.getNoMergeCellPositionByIndex(S,p),E=(T==null?void 0:T.startY)||0,y=(b==null?void 0:b.endY)||0,O=(T==null?void 0:T.startX)||0,x=(b==null?void 0:b.endX)||0;R?this._controlHandler((B,z)=>{const X=new a.ColorKit(this._fillControlColors[z]).lighten(ra).toRgbString();B.setProps({fill:X})}):this._controlHandler((B,z)=>{B.setProps({fill:this._fillControlColors[z]})});const D=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();f===S&&M===!0||g===p&&M===!1?(W=this._helperSelection)==null||W.hide():((A=this._helperSelection)==null||A.transformByState({left:O-D/2,top:E-D/2,width:x-O,height:y-E}),(H=this._helperSelection)==null||H.show()),this._targetSelection={startY:E,endY:y,startX:O,endX:x,startRow:f,endRow:S,startColumn:g,endColumn:p},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(t){const{offsetX:e,offsetY:n}=t,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([e,n])),{x:s,y:l}=r;this._startOffsetX=s,this._startOffsetY=l;const{startRow:d,startColumn:c,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(d,c,u,h),this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=c,this._relativeSelectionRowLength=u-d,this._relativeSelectionColumnLength=h-c;const m=this._control.selectionStyle;let f=m==null?void 0:m.stroke,g=m==null?void 0:m.strokeWidth;const S=_.getNormalSelectionStyle(this._themeService);f==null&&(f=S.stroke),g==null&&(g=S.strokeWidth);const p=this._getScale();g/=p;const R=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/p,M=new a.ColorKit(f).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new w.Rect(Ao,{stroke:M,strokeWidth:g+R/2}),o.addObject(this._helperSelection)),this._activeViewport=o.getActiveViewportByCoord(w.Vector2.FromArray([e,n]));const T=o.getViewport(j.VIEW_MAIN),b=w.ScrollTimer.create(o,this._activeViewport.viewPortKey===j.VIEW_MAIN?w.ScrollTimerType.ALL:w.ScrollTimerType.NONE);b.startScroll(s,l,T),this._scrollTimer=b,o.disableEvent(),this._controlHandler(E=>{this._fillControlColors.push(E.fill)}),this._moveObserver=o.onPointerMoveObserver.add(E=>{var H;const{offsetX:y,offsetY:O}=E,x=o.getActiveViewportByCoord(w.Vector2.FromArray([y,O])),{x:D,y:W}=o.getRelativeCoord(w.Vector2.FromArray([y,O]));this._fillMoving(D,W),o.setCursor(w.CURSOR_TYPE.CROSSHAIR);const A=this._targetSelection;if(T&&x&&((H=this._activeViewport)==null?void 0:H.viewPortKey)!==(x==null?void 0:x.viewPortKey)){let B;A.startRow!==d?(b.scrollTimerType=w.ScrollTimerType.Y,B={...A,endRow:A.startRow}):A.endRow!==u?(b.scrollTimerType=w.ScrollTimerType.Y,B={...A,startRow:A.endRow}):A.startColumn!==c?(b.scrollTimerType=w.ScrollTimerType.X,B={...A,endColumn:A.startColumn}):(b.scrollTimerType=w.ScrollTimerType.X,B={...A,startColumn:A.endColumn}),this._isSelectionInViewport(B,x)&&(T.scrollTo({x:b.scrollTimerType===w.ScrollTimerType.X?0:void 0,y:b.scrollTimerType===w.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}b.scrolling(D,W,()=>{this._fillMoving(D,W)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var y,O;(y=this._helperSelection)==null||y.dispose();const E=this._scene;E.resetCursor(),this._clearObserverEvent(),E.enableEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,D)=>{x.setProps({fill:this._fillControlColors[D]})}),this._fillControlColors=[]})}_hasMergeInRange(t,e,n,o){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:l,startColumn:d,endRow:c,endColumn:u}=s,h={left:e,top:t,right:o,bottom:n},m={left:d,top:l,right:u,bottom:c};if(w.isRectIntersect(h,m))return!0}return!1}_swapPositions(t,e,n,o){const r=Math.min(t,n),s=Math.min(e,o),l=Math.max(t,n),d=Math.max(e,o);return{startRow:r,startColumn:s,endRow:l,endColumn:d}}_controlHandler(t){const{leftControl:e,rightControl:n,topControl:o,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:l,backgroundControlMiddleRight:d,backgroundControlBottom:c,fillControl:u}=this._control,h=[e,n,o,r,s,l,d,c,u];for(let m=0,f=h.length;m<f;m++){const g=h[m];t(g,m)}}_fillRuler(t,e,n,o,r){let s=!1;if(t<e)if(this._isInMergeState&&t<e){const l=e-t,d=o+1,c=Math.ceil(l/d);let u=e-c*d;u<0&&(u=e-(c-1)*d),e=u}else e=t;else if(t>=e&&t<=n)s=!0,this._isInMergeState||(n=t);else if(this._isInMergeState&&t>n){const l=t-n,d=o+1,c=Math.ceil(l/d);let u=n+c*d;u>r&&(u=n+(c-1)*d),n=u}else n=t;return{rowOrColumn:t,startRowOrColumn:e,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:t,scaleY:e}=this._scene.getAncestorScale();return Math.max(t,e)}}var sa=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,la=(i,t,e,n)=>{for(var o=n>1?void 0:n?aa(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&sa(t,e,o),o},Rn=(i,t)=>(e,n)=>t(e,n,i);N.SelectionRenderService=class{constructor(t,e,n,o){I(this,"hasSelection",!1);I(this,"_downObserver");I(this,"_moveObserver");I(this,"_upObserver");I(this,"_controlFillConfig$",new k.BehaviorSubject(null));I(this,"controlFillConfig$",this._controlFillConfig$.asObservable());I(this,"_selectionControls",[]);I(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});I(this,"_startOffsetX",0);I(this,"_startOffsetY",0);I(this,"_scrollTimer");I(this,"_cancelDownObserver");I(this,"_cancelUpObserver");I(this,"_skeleton");I(this,"_scene");I(this,"_isHeaderHighlight",!0);I(this,"_isDetectMergedCell",!0);I(this,"_selectionStyle");I(this,"_isSelectionEnabled",!0);I(this,"_isShowPreviousEnable",0);I(this,"_isRemainLastEnable",!0);I(this,"_isSkipRemainLastEnable",!1);I(this,"_isSingleSelection",!1);I(this,"_selectionMoveEnd$",new k.BehaviorSubject([]));I(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());I(this,"_selectionMoving$",new k.Subject);I(this,"selectionMoving$",this._selectionMoving$.asObservable());I(this,"_selectionMoveStart$",new k.Subject);I(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());I(this,"_activeViewport");this._themeService=t,this._shortcutService=e,this._sheetSkeletonManagerService=n,this._injector=o,this._selectionStyle=_.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(t){this._selectionStyle=t}resetStyle(){this.setStyle(_.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}enableSingleSelection(){this._isSingleSelection=!0}disableSingleSelection(){this._isSingleSelection=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const{rangeWithCoord:n,primaryWithCoord:o}=t,r=this._skeleton;let s=t.style;s==null&&(s=_.getNormalSelectionStyle(this._themeService));const l=this._scene;if(l==null||r==null)return;const d=new In(l,e.length,this._isHeaderHighlight,this._themeService);new Do(d,r,l,this._themeService,this._injector);const{rowHeaderWidth:c,columnHeaderHeight:u}=r;d.update(n,c,u,s,o),this._isHeaderHighlight?d.enableHeaderHighlight():d.disableHeaderHighlight(),e.push(d)}updateControlForCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:o,columnHeaderHeight:r}=n;for(let s=0,l=t.length;s<l;s++){const{rangeWithCoord:d,primaryWithCoord:c,style:u}=t[s];e[s].update(d,o,r,u,c)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(t,e,n){this._skeleton=t,this._scene=e,this._activeViewport=n||e.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(e=>e.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const t=this.getCurrentControls();if(t.length>0){for(const e of t)e.dispose();t.length=0}}_getFreeze(){var e;return(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_getViewportByCell(t,e){if(!this._scene||t===void 0||e===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(j.VIEW_MAIN);if(t>n.startRow&&e>n.startColumn)return this._scene.getViewport(j.VIEW_MAIN);if(t<=n.startRow&&e<=n.startColumn)return this._scene.getViewport(j.VIEW_MAIN_LEFT_TOP);if(t<=n.startRow&&e>n.startColumn)return this._scene.getViewport(j.VIEW_MAIN_TOP);if(t>n.startRow&&e<=n.startColumn)return this._scene.getViewport(j.VIEW_MAIN_LEFT)}getActiveSelections(){const t=this.getCurrentControls();if(t&&t.length>0)return t==null?void 0:t.map(n=>{const o=n.model,r=o.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn},primary:s}})}getActiveRange(){const t=this.getCurrentControls(),e=t&&t[t.length-1].model;return e&&{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}getActiveSelection(){const t=this.getCurrentControls();return t&&t[t.length-1]}endSelection(){this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}reset(){var t,e,n;this._clearSelectionControls(),(t=this._moveObserver)==null||t.dispose(),(e=this._upObserver)==null||e.dispose(),(n=this._downObserver)==null||n.dispose(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(t,e=0,n=a.RANGE_TYPE.NORMAL,o,r=w.ScrollTimerType.ALL){var G,te;if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:l,offsetY:d}=t,c=this._scene;if(c==null||s==null)return;o!=null&&(this._activeViewport=o);const u=c.getViewport(j.VIEW_MAIN),h=c.getRelativeCoord(w.Vector2.FromArray([l,d]));let{x:m,y:f}=h;this._startOffsetX=m,this._startOffsetY=f;const g=c.getScrollXYByRelativeCoords(h),{scaleX:S,scaleY:p}=c.getAncestorScale();n===a.RANGE_TYPE.ROW?m=0:n===a.RANGE_TYPE.COLUMN&&(f=0);const R=this._getSelectedRangeWithMerge(m,f,S,p,g);if(!R)return!1;const{rangeWithCoord:M,primaryWithCoord:T}=R,{startRow:b,startColumn:E,endColumn:y,endRow:O,startY:x,endY:D,startX:W,endX:A}=M,{rowHeaderWidth:H,columnHeaderHeight:B}=s,z={startColumn:E,startRow:b,endColumn:y,endRow:O,startY:x,endY:D,startX:W,endX:A,rangeType:n};this._startSelectionRange=z;let X=this.getActiveSelection();const Q=this.getCurrentControls();if(!Q)return!1;for(const ne of Q){if(t.button===2&&ne.model.isInclude(z)){X=ne;return}if(ne.model.isEqual(z)){X=ne;break}t.shiftKey||ne.clearHighlight()}if(Q.length>0&&!t.ctrlKey&&!t.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable||Q.length>0&&this._isSingleSelection&&!t.shiftKey){for(const ne of Q)ne.dispose();Q.length=0}const J=X&&X.model.currentCell;if(X&&t.shiftKey&&J){const{actualRow:ne,actualColumn:de,mergeInfo:fe}=J,be=Math.min(ne,z.startRow,fe.startRow),Te=Math.max(ne,z.endRow,fe.endRow),De=Math.min(de,z.startColumn,fe.startColumn),Je=Math.max(de,z.endColumn,fe.endColumn),ve=s.getMergeBounding(be,De,Te,Je),he=s.getNoMergeCellPositionByIndex(ve.startRow,ve.startColumn),se=s.getNoMergeCellPositionByIndex(ve.endRow,ve.endColumn),qe={startColumn:ve.startColumn,startRow:ve.startRow,endColumn:ve.endColumn,endRow:ve.endRow,startY:he.startY,endY:se.endY,startX:he.startX,endX:se.endX,rangeType:n},Ce=s.getCellByIndex(ne,de);this._startSelectionRange={startColumn:Ce.mergeInfo.startColumn,startRow:Ce.mergeInfo.startRow,endColumn:Ce.mergeInfo.endColumn,endRow:Ce.mergeInfo.endRow,startY:Ce.mergeInfo.startY||0,endY:Ce.mergeInfo.endY||0,startX:Ce.mergeInfo.startX||0,endX:Ce.mergeInfo.endX||0,rangeType:n},X.update(qe,H,B,this._selectionStyle,J)}else this._isRemainLastEnable&&X&&!t.ctrlKey&&!t.shiftKey&&!this._isSkipRemainLastEnable&&!this._isSingleSelection?X.update(z,H,B,this._selectionStyle,T):(X=new In(c,Q.length+e,this._isHeaderHighlight,this._themeService),new Do(X,s,c,this._themeService,this._injector),X.update(z,H,B,this._selectionStyle,T),Q.push(X));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),c.disableEvent();const $=c.getActiveViewportByCoord(w.Vector2.FromArray([m,f])),ee=w.ScrollTimer.create(this._scene,r);ee.startScroll((G=u==null?void 0:u.left)!=null?G:0,(te=u==null?void 0:u.top)!=null?te:0,u),this._scrollTimer=ee,this._addCancelObserver(),(n===a.RANGE_TYPE.ROW||n===a.RANGE_TYPE.COLUMN)&&this._moving(m,f,X,n);let L=0,U=0,F=m,Y=f;this._moveObserver=c.onPointerMoveObserver.add(ne=>{var Ce,un,hn,mn,fn,Os,Ns,xs,As,Ds;const{offsetX:de,offsetY:fe}=ne,{x:be,y:Te}=c.getRelativeCoord(w.Vector2.FromArray([de,fe]));this._moving(be,Te,X,n);let De=be,Je=Te;const ve=this.getActiveSelection(),he=(Ce=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Ce.skeleton.getWorksheetConfig().freeze,se=ve==null?void 0:ve.model,qe=(un=c.getActiveViewportByCoord(w.Vector2.FromArray([de,fe])))!=null?un:this._getViewportByCell(se==null?void 0:se.endRow,se==null?void 0:se.endColumn);if($&&qe&&u){const So=F<u.left&&be>u.left||F>u.left&&be<u.left,_o=Y<u.top&&Te>u.top||Y>u.top&&Te<u.top;So&&(L+=1),_o&&(U+=1);const Ye=$.viewPortKey,gn=qe.viewPortKey;if(Ye===j.VIEW_ROW_TOP)fe<u.top&&((hn=se==null?void 0:se.endRow)!=null?hn:0)<((mn=he==null?void 0:he.startRow)!=null?mn:0)?Je=u.top:_o&&U%2===1&&u.scrollTo({y:0});else if(Ye===j.VIEW_COLUMN_LEFT)de<u.left&&((fn=se==null?void 0:se.endColumn)!=null?fn:0)<((Os=he==null?void 0:he.startColumn)!=null?Os:0)?De=u.left:So&&L%2===1&&u.scrollTo({x:0});else if(Ye===gn){let et=!1,_t=!1;Ye===j.VIEW_MAIN_LEFT_TOP?(et=!0,_t=!0):Ye===j.VIEW_MAIN_TOP?_t=!0:Ye===j.VIEW_MAIN_LEFT&&(et=!0),((Ns=se==null?void 0:se.endRow)!=null?Ns:0)>((xs=he==null?void 0:he.startRow)!=null?xs:0)&&(_t=!1),((As=se==null?void 0:se.endColumn)!=null?As:0)>((Ds=he==null?void 0:he.startColumn)!=null?Ds:0)&&(et=!1),et&&(De=u.left),_t&&(Je=u.top)}else{const et={x:$.scrollX,y:$.scrollY},_t={x:qe.scrollX,y:qe.scrollY},po=et.x!==_t.x&&So&&L%2===1,vo=et.y!==_t.y&&_o&&U%2===1;(po||vo)&&(u.scrollTo({x:po?et.x:void 0,y:vo?et.y:void 0}),po||(De=u.left),vo||(Je=u.top)),(Ye===j.VIEW_MAIN_LEFT_TOP&&gn===j.VIEW_MAIN_LEFT||gn===j.VIEW_MAIN_LEFT_TOP&&Ye===j.VIEW_MAIN_LEFT)&&(De=u.left),(Ye===j.VIEW_MAIN_LEFT_TOP&&gn===j.VIEW_MAIN_TOP||gn===j.VIEW_MAIN_LEFT_TOP&&Ye===j.VIEW_MAIN_TOP)&&(Je=u.top)}F=be,Y=Te}ee.scrolling(De,Je,()=>{this._moving(be,Te,X,n)})}),this._upObserver=c.onPointerUpObserver.add(ne=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(t){const{range:e,primary:n,style:o}=t;let r=this.convertRangeDataToSelection(e);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:a.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:o}}convertRangeDataToSelection(t){const{startRow:e,startColumn:n,endRow:o,endColumn:r,rangeType:s}=t,l=this._scene,d=this._skeleton;if(l==null||d==null)return;l.getAncestorScale();const c=d.getNoMergeCellPositionByIndex(e,n),u=d.getNoMergeCellPositionByIndex(o,r);return{startRow:e,startColumn:n,endRow:o,endColumn:r,rangeType:s,startY:(c==null?void 0:c.startY)||0,endY:(u==null?void 0:u.endY)||0,startX:(c==null?void 0:c.startX)||0,endX:(u==null?void 0:u.endX)||0}}convertCellRangeToInfo(t){if(t==null)return;const e=this._scene,n=this._skeleton;if(e==null||n==null)return;const{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:l,startRow:d,startColumn:c,endRow:u,endColumn:h}=t,m=n.getNoMergeCellPositionByIndex(o,r),f=n.getNoMergeCellPositionByIndex(d,c),g=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:l,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY,mergeInfo:{startRow:d,startColumn:c,endRow:u,endColumn:h,startY:(f==null?void 0:f.startY)||0,endY:(g==null?void 0:g.endY)||0,startX:(f==null?void 0:f.startX)||0,endX:(g==null?void 0:g.endX)||0}}}_moving(t,e,n,o){var te;const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:l,startColumn:d,endRow:c,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:f,endColumn:g}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},S=s.getViewport(j.VIEW_MAIN),p=(te=this._getViewportByCell(m,g))!=null?te:S,R=s.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),p),{scaleX:M,scaleY:T}=s.getAncestorScale(),{rowHeaderWidth:b,columnHeaderHeight:E}=r;o===a.RANGE_TYPE.ROW?t=Number.POSITIVE_INFINITY:o===a.RANGE_TYPE.COLUMN&&(e=Number.POSITIVE_INFINITY);const y=this._getSelectedRangeWithMerge(t,e,M,T,R);if(!y)return!1;const{rangeWithCoord:O,primaryWithCoord:x}=y,{startRow:D,startColumn:W,endColumn:A,endRow:H}=O,B=Math.min(D,l),z=Math.min(W,d),X=Math.max(H,c),Q=Math.max(A,u);let J={startRow:B,startColumn:z,endRow:X,endColumn:Q};if(this._isDetectMergedCell&&(J=r.getSelectionBounding(B,z,X,Q)),!J)return!1;const{startRow:$,startColumn:ee,endRow:L,endColumn:U}=J,F=r.getNoMergeCellPositionByIndex($,ee),Y=r.getNoMergeCellPositionByIndex(L,U),G={startColumn:ee,startRow:$,endColumn:U,endRow:L,startY:(F==null?void 0:F.startY)||0,endY:(Y==null?void 0:Y.endY)||0,startX:(F==null?void 0:F.startX)||0,endX:(Y==null?void 0:Y.endX)||0};(f!==ee||h!==$||g!==U||m!==L)&&n!=null&&(n.update(G,b,E),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,o;const t=this._scene;if(t==null)return;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),t.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const e=(o=t.getEngine())==null?void 0:o.activeScene;e==null||e.onPointerDownObserver.remove(this._cancelDownObserver),e==null||e.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const t=this._scene;if(t==null)return;const e=(n=t.getEngine())==null?void 0:n.activeScene;e==null||e===t||(e.onPointerDownObserver.remove(this._cancelDownObserver),e.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=e.onPointerDownObserver.add(o=>{this._endSelection()}),this._cancelUpObserver=e.onPointerUpObserver.add(o=>{this._endSelection()}))}_getSelectedRangeWithMerge(t,e,n,o,r){var R;if(this._isDetectMergedCell){const M=(R=this._skeleton)==null?void 0:R.calculateCellIndexByPosition(t,e,n,o,r),T=a.makeCellToSelection(M);return T==null?void 0:{primaryWithCoord:M,rangeWithCoord:T}}const s=this._skeleton;if(s==null)return;const l=s.getCellPositionByOffset(t,e,n,o,r),{row:d,column:c}=l,u=s.getNoMergeCellPositionByIndex(d,c),{startX:h,startY:m,endX:f,endY:g}=u,S={startY:m,endY:g,startX:h,endX:f,startRow:d,endRow:d,startColumn:c,endColumn:c};return{primaryWithCoord:{actualRow:d,actualColumn:c,isMerged:!1,isMergedMainCell:!1,startY:m,endY:g,startX:h,endX:f,mergeInfo:S},rangeWithCoord:S}}},N.SelectionRenderService=la([Rn(0,P.Inject(a.ThemeService)),Rn(1,C.IShortcutService),Rn(2,P.Inject(N.SheetSkeletonManagerService)),Rn(3,P.Inject(P.Injector))],N.SelectionRenderService);const Ie=P.createIdentifier("deprecated.univer.sheet.selection-render-service");var ca=Object.defineProperty,da=Object.getOwnPropertyDescriptor,ua=(i,t,e,n)=>{for(var o=n>1?void 0:n?da(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ca(t,e,o),o},Ft=(i,t)=>(e,n)=>t(e,n,i);const ha=1e4,Wt=P.createIdentifier("univer.mark-selection-service");N.MarkSelectionService=class extends a.Disposable{constructor(e,n,o,r,s){super();I(this,"_shapeMap",new Map);this._currentService=e,this._renderManagerService=n,this._selectionRenderService=o,this._sheetSkeletonManagerService=r,this._themeService=s}addShape(e,n=[],o=ha){const r=this._currentService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet().getSheetId(),l=a.Tools.generateRandomId();return this._shapeMap.set(l,{selection:e,subUnitId:s,unitId:r.getUnitId(),zIndex:o,control:null,exits:n}),this.refreshShapes(),l}refreshShapes(){const e=this._currentService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=this._currentService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId();this._shapeMap.forEach(o=>{var M;const{unitId:r,subUnitId:s,selection:l,control:d,zIndex:c}=o;if(d&&d.dispose(),r!==e||s!==n)return;const{style:u}=l,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:f}=this._selectionRenderService.convertSelectionRangeToData(l),g=(M=this._sheetSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(!h||!g)return;const{rowHeaderWidth:S,columnHeaderHeight:p}=g,R=new In(h,c,!1,this._themeService);R.update(m,S,p,u,f),o.control=R})}getShapeMap(){return this._shapeMap}removeShape(e){const n=this._shapeMap.get(e);if(!n)return;const{control:o}=n;o&&o.dispose(),this._shapeMap.delete(e)}removeAllShapes(){for(const e of this._shapeMap.values()){const{control:n}=e;n&&n.dispose()}this._shapeMap.clear()}},N.MarkSelectionService=ua([Ft(0,a.IUniverInstanceService),Ft(1,w.IRenderManagerService),Ft(2,Ie),Ft(3,P.Inject(N.SheetSkeletonManagerService)),Ft(4,P.Inject(a.ThemeService))],N.MarkSelectionService);function vt(i,t,e,n){const o=t.get(a.IUniverInstanceService),r=e?o.getUnit(e,a.UniverInstanceType.UNIVER_SHEET):o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=n?r==null?void 0:r.getSheetBySheetId(n):r==null?void 0:r.getActiveSheet();if(!s)return null;const{startRow:l,endRow:d,startColumn:c,endColumn:u}=i,h=[],m=[];for(let f=l;f<=d;f++)s.getRowFiltered(f)||h.push(f);for(let f=c;f<=u;f++)m.push(f);return{rows:h,cols:m}}function lt(i){const{rows:t,cols:e}=i;return{startRow:t[0],endRow:t[t.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function jt(i){let t=[],e=[];const n=[];return i.forEach(o=>{t.push(...o.rows),e.push(...o.cols)}),t=Array.from(new Set(t)).sort((o,r)=>o-r),e=Array.from(new Set(e)).sort((o,r)=>o-r),i.forEach(o=>{n.push({startRow:t.findIndex(r=>r===o.rows[0]),endRow:t.findIndex(r=>r===o.rows[o.rows.length-1]),startColumn:e.findIndex(r=>r===o.cols[0]),endColumn:e.findIndex(r=>r===o.cols[o.cols.length-1])})}),{ranges:n,mapFunc:(o,r)=>({row:t[o],col:e[r]})}}function ma(i){const t=new a.ObjectMatrix;return i.forEach(e=>{const{rows:n,cols:o}=e;n.forEach(r=>{o.forEach(s=>{t.setValue(r,s,{v:null,p:null,f:null,si:null})})})}),t.getData()}const fa=10,ga=6;function Sa(){return a.Tools.generateRandomId(ga)}function _a(i){const t=i.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class pa{constructor(){I(this,"_cache",new a.LRUMap(fa))}set(t,e){this._cache.set(t,e)}get(t){return this._cache.get(t)}del(t){this._cache.delete(t)}clear(){this._cache.clear()}}function Po(i,t){const e=t!=null?t:i.style,n={},o=i.tagName.toLowerCase();switch(o){case"b":case"em":case"strong":{n.bl=a.BooleanNumber.TRUE;break}case"s":{n.st={s:a.BooleanNumber.TRUE};break}case"u":{n.ul={s:a.BooleanNumber.TRUE};break}case"i":{n.it=a.BooleanNumber.TRUE;break}case"sub":case"sup":{n.va=o==="sup"?a.BaselineOffset.SUPERSCRIPT:a.BaselineOffset.SUBSCRIPT;break}}return va(e,n),n}function va(i,t){for(let e=0;e<i.length;e++){const n=i[e],o=i.getPropertyValue(n);switch(n){case"font-family":{t.ff=o;break}case"font-size":{const r=Number.parseInt(o);if(!Number.isNaN(r)){if(o.endsWith("pt"))t.fs=r;else if(o.endsWith("px")){const s=r*.75;t.fs=s}}break}case"font-style":{o==="italic"&&(t.it=a.BooleanNumber.TRUE);break}case"font-weight":{(Number(o)>400||o==="bold")&&(t.bl=a.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(o)?t.ul={s:a.BooleanNumber.TRUE}:/overline/.test(o)?t.ol={s:a.BooleanNumber.TRUE}:/line-through/.test(o)&&(t.st={s:a.BooleanNumber.TRUE});break}case"color":{const r=new a.ColorKit(o);r.isValid&&(t.cl={rgb:r.toRgbString()});break}case"background-color":{const r=new a.ColorKit(o),s=r.isValid?r.toRgbString():"";s!==C.DEFAULT_BACKGROUND_COLOR_RGB&&s!==C.DEFAULT_BACKGROUND_COLOR_RGBA&&(t.bg={rgb:r.toRgbString()});break}}}}function Ca(i){const t=new DOMParser,e=`<x-univer id="univer-root">${i}</x-univer>`;return t.parseFromString(e,"text/html").querySelector("#univer-root")}function Ii(i,t){const e=[];for(let n=0,o=i.length;n<o;n++)i[n]===a.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:n});if(t)for(const n of e)t.bullet&&(n.bullet=a.Tools.deepClone(t.bullet)),t.paragraphStyle&&(n.paragraphStyle=a.Tools.deepClone(t.paragraphStyle));return e}const Ia=["color_color","background_background","font-size_fontSize","text-align_textAlign","vertical-align_verticalAlign","font-weight_fontWeight","font-style_fontStyle","font-family_fontFamily","text-decoration_textDecoration","white-space_whiteSpace","word-wrap_wordWrap"],Ra=["border-left_borderLeft","border-right_borderRight","border-top_borderTop","border-bottom_borderBottom"];function Ho(i,t){const e=i.tagName.toLowerCase();return typeof t=="string"?e===t:Array.isArray(t)?t.some(n=>n===e):t(i)}function Ma(i){i.style.display="none",i.style.width="0",i.style.height="0",i.setAttribute("tabindex","-1"),i.setAttribute("aria-hidden","true"),i.setAttribute("title","hidden iframe")}const mi=class mi{constructor(t){I(this,"styleCache",new Map);I(this,"styleRules",[]);I(this,"afterProcessRules",[]);I(this,"htmlElement");I(this,"getCurrentSkeleton");this.getCurrentSkeleton=t.getCurrentSkeleton,this.htmlElement=document.createElement("iframe"),this.htmlElement.style.display="none",document.body.appendChild(this.htmlElement),Ma(this.htmlElement)}static use(t){if(this.pluginList.includes(t))throw new Error(`Univer paste plugin ${t.name} already added`);this.pluginList.push(t)}convert(t){this.htmlElement.contentDocument&&(this.htmlElement.contentDocument.open(),this.htmlElement.contentDocument.write(t),this.htmlElement.contentDocument.close()),t=t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style[\s\S]*?<\/style>/g,"");const e=mi.pluginList.find(f=>f.checkPasteType(t));e&&(this.styleRules=[...e.stylesRules],this.afterProcessRules=[...e.afterProcessRules]);const n=new a.ObjectMatrix,o=Ca(t),r={dataStream:"",textRuns:[]},s=[],l=[],d=t.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi),c=[];this.process(null,o==null?void 0:o.childNodes,r,c);const{paragraphs:u,dataStream:h,textRuns:m}=r;if(u){const f=u.map(g=>g.startIndex+1);f.unshift(0);for(let g=0;g<f.length;g++){let S;g===f.length-1?S=`${h.substring(f[g])}\r
|
|
2
2
|
`:S=`${h.substring(f[g],f[g+1]-1)}\r
|
|
3
3
|
`;const p=[];m==null||m.forEach(M=>{M.st>=f[g]&&M.ed<=f[g+1]&&p.push({st:M.st-f[g],ed:M.ed-f[g],ts:M.ts})});const R=this._generateDocumentDataModelSnapshot({body:{dataStream:S,textRuns:p,paragraphs:Ii(S)}});n.setValue(n.getLength(),0,{v:S,p:R}),s.push({})}}else if(h){const f=`${h}\r
|
|
4
|
-
`,g={dataStream:f,textRuns:m,paragraphs:Ii(f)},S=this._generateDocumentDataModelSnapshot({body:g});n.setValue(0,0,{v:h,p:S}),s.push({})}return d&&d.forEach(f=>{const g=n.getDataRange().endRow+1,{cellMatrix:S,rowProperties:p,colProperties:R}=this._parseTable(f);S&&S.forValue((M,
|
|
5
|
-
`,u={...d,body:{dataStream:c,textRuns:s.textRuns,paragraphs:Ii(c)}};l==null||l.reset(u),n=l==null?void 0:l.getSnapshot(),e=s.dataStream}else e=
|
|
6
|
-
<tbody>${l.join("")}</tbody></table>`}}const La=(i,t,e=!1)=>{const n=h=>h.endRow-h.startRow+1,o=h=>h.endColumn-h.startColumn+1,r=n(t)%n(i),s=o(t)%o(i),l={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:o(i)-1},d=Math.floor(n(t)/n(i)),c=Math.floor(o(t)/o(i)),u=[];if(!r&&!s)for(let h=1;h<=d;h++)for(let m=1;m<=c;m++){const f=n(i)*(h-1),g=o(i)*(m-1),S={startRow:f+t.startRow,endRow:f+t.startRow,startColumn:g+t.startColumn,endColumn:g+t.startColumn};u.push({repeatRelativeRange:l,startRange:S})}else if(!r&&s&&!e)for(let h=1;h<=d;h++){const m=n(i)*(h-1),f=0,g={startRow:m+t.startRow,endRow:m+t.startRow,startColumn:f+t.startColumn,endColumn:f+t.startColumn};u.push({repeatRelativeRange:l,startRange:g})}else if(r&&!s&&!e)for(let h=1;h<=c;h++){const f=o(i)*(h-1),g={startRow:0+t.startRow,endRow:0+t.startRow,startColumn:f+t.startColumn,endColumn:f+t.startColumn};u.push({repeatRelativeRange:l,startRange:g})}else{const h={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};async function Ua(i){return i?/<td[^>]*class=".*?xl.*?"[^>]*>.*?<\/td>/.test(i):!1}function Va(...i){if(i.length===1)return i[0];const t=new a.ObjectMatrix;return i.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((o,r,s)=>{t.setValue(o,r,{...t.getValue(o,r),...s})})}),t.getMatrix()}function Ba(i,t){return i.id===t.id&&i.params.unitId===t.params.unitId&&i.params.subUnitId===t.params.subUnitId}function bi(i){const t=[];for(let e=0;e<i.length;){let n=1;if(i[e].id===_.SetRangeValuesMutation.id){const o=i[e],r=[o];for(;e+n<i.length&&Ba(o,i[e+n]);)r.push(i[e+n]),n+=1;const s=Va(...r.map(l=>l.params.cellValue||{}));t.push({...o,params:{...o.params,cellValue:s}})}else t.push(i[e]);e+=n}return t}function Ti(i,t){const{startRow:e,endRow:n,startColumn:o,endColumn:r}=i;for(let s=e;s<=n;s++)for(let l=o;l<=r;l++)if(t.rows.includes(s)&&t.cols.includes(l))return!0}function ko(i,t){const{startRow:e,endRow:n,startColumn:o,endColumn:r}=t;for(let s=e;s<=n;s++)if(!i.rows.includes(s))return!1;for(let s=o;s<=r;s++)if(!i.cols.includes(s))return!1;return!0}var ka=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,Wa=(i,t,e,n)=>{for(var o=n>1?void 0:n?Fa(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ka(t,e,o),o},Re=(i,t)=>(e,n)=>t(e,n,i);const Se={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};Ct.use(gi.PastePluginWord),Ct.use(gi.PastePluginLark),Ct.use(gi.PastePluginUniver);const It=P.createIdentifier("sheet.clipboard-service");N.SheetClipboardService=class extends a.Disposable{constructor(e,n,o,r,s,l,d,c,u,h,m,f,g){super();I(this,"_clipboardHooks",[]);I(this,"_clipboardHooks$",new k.BehaviorSubject([]));I(this,"clipboardHooks$",this._clipboardHooks$.asObservable());I(this,"_htmlToUSM");I(this,"_usmToHtml");I(this,"_copyContentCache");I(this,"_copyMarkId",null);this._logService=e,this._univerInstanceService=n,this._selectionManagerService=o,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=l,this._markSelectionService=d,this._sheetSkeletonManagerService=c,this._notificationService=u,this._platformService=h,this._localeService=m,this._errorService=f,this._injector=g,this._htmlToUSM=new Ct({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new Ha,this._copyContentCache=new pa,this.disposeWithMe(this._htmlToUSM)}copyContentCache(){return this._copyContentCache}async copy(e=nt.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=o.getActiveSheet(),s=this._clipboardHooks;s.forEach(g=>{var S;return(S=g.onBeforeCopy)==null?void 0:S.call(g,o.getUnitId(),r.getSheetId(),n.range)});const l=this._generateCopyContent(o.getUnitId(),r.getSheetId(),n.range,s);if(!l)return!1;const{html:d,plain:c,matrixFragment:u,copyId:h,discreteRange:m}=l;this._copyContentCache.set(h,{unitId:o.getUnitId(),subUnitId:r.getSheetId(),range:m,matrix:u,copyType:e}),await this._clipboardInterfaceService.write(c,d),this._markSelectionService.removeAllShapes();const f=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:f}),s.forEach(g=>{var S;return(S=g.onAfterCopy)==null?void 0:S.call(g)}),!0}async cut(){return this.copy(nt.CUT)}async paste(e,n=Se.DEFAULT_PASTE){const o=e.types,r=o.indexOf(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(l=>l&&l.text()):"",s=o.indexOf(C.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.HTML_CLIPBOARD_MIME_TYPE).then(l=>l&&l.text()):"";return s?this._platformService.isWindows&&await Ua(s)?(this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),!1):this._pasteHTML(s,n):r?this._pastePlainText(r,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}legacyPaste(e,n){return e?this._pasteHTML(e,Se.DEFAULT_PASTE):n?this._pastePlainText(n,Se.DEFAULT_PASTE):Promise.resolve(!1)}addClipboardHook(e){if(this._clipboardHooks.findIndex(o=>o.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(o=>{const r=o.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const o=this._clipboardHooks.indexOf(e);o>-1&&(this._clipboardHooks.splice(o,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,n,o,r){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(n);if(!s||!l)return null;const d=r.reduce((b,w)=>{var O;const y=(O=w.getFilteredOutRows)==null?void 0:O.call(w,o);return y==null||y.forEach(x=>b.add(x)),b},new Set),{startColumn:c,startRow:u,endColumn:h,endRow:m}=o,f=l.getMatrixWithMergedCells(u,c,m,h,!0),g=new a.ObjectMatrix;let S=u;const p={rows:[],cols:[]};for(let b=u;b<=m;b++)if(!d.has(b)){p.rows.push(b);for(let w=c;w<=h;w++){const y=f.getValue(b,w);y?g.setValue(S-u,w-c,{...Fo(),...a.Tools.deepClone(y)}):g.setValue(S-u,w-c,Fo())}S+=1}for(let b=c;b<=h;b++)p.cols.push(b);let R=this._usmToHtml.convert(f,o,r);const M=ja(g),E=Sa();return R=R.replace(/(<[a-z]+)/,(b,w)=>`${w} data-copy-id="${E}"`),{copyId:E,plain:M,html:R,matrixFragment:g,discreteRange:p}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(e,n){const o=this._getPastingTarget();if(!o.selection)return!1;const r={get:this._injector.get.bind(this._injector)},s=vt(o.selection.range,r,o.unitId,o.subUnitId);if(!s)return!1;const{unitId:l,subUnitId:d}=o,c=this._clipboardHooks,u=[];if(c.some(S=>{var p;return u.push(S)&&((p=S.onBeforePaste)==null?void 0:p.call(S,{unitId:l,subUnitId:d,range:s}))===!1}))return u.forEach(S=>{var p;return(p=S.onAfterPaste)==null?void 0:p.call(S,!1)}),!1;const m=[],f=[];u.forEach(S=>{var R;const p=(R=S.onPastePlainText)==null?void 0:R.call(S,{unitId:l,subUnitId:d,range:s},e,{pasteType:n});p&&(m.push(...p.redos),f.push(...p.undos))});const g=m.every(S=>this._commandService.executeCommand(S.id,S.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:f,redoMutations:m}),g}async _pasteHTML(e,n){const o=_a(e);return o&&this._copyContentCache.get(o)?this._pasteInternal(o,n):this._pasteExternal(e,n)}async _pasteExternal(e,n){var u;const{rowProperties:o,colProperties:r,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const l=this._getPastedRange(s);if(!l)return!1;const d=(u=this._univerInstanceService.getUniverSheetInstance(l.unitId))==null?void 0:u.getSheetBySheetId(l.subUnitId);if(!d)return!1;const c=d==null?void 0:d.getMergeData();return c&&c.some(m=>Ti(m,l.pastedRange)&&!ko(l.pastedRange,m))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:o,colProperties:r,cellMatrix:s},l,n)}async _pasteInternal(e,n){var b,w;const o=a.Tools.deepClone(this._copyContentCache.get(e)),{range:r,matrix:s,unitId:l,subUnitId:d}=o||{};if(!s||!o||!r||!l||!d||!s||!o)return!1;const c=(b=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:b.getStyles();s.forValue((y,O,x)=>{if(typeof x.s=="string"){const D=a.Tools.deepClone(x);D.s=c==null?void 0:c.getStyleByCell(x),s.setValue(y,O,D)}});const u=this._getPastedRange(s);if(!u)return!1;const h=(w=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:w.getSheetBySheetId(u.subUnitId);if(!h)return!1;const m=h==null?void 0:h.getMergeData();if(m&&m.some(O=>Ti(O,u.pastedRange)&&!ko(u.pastedRange,O)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const f=h.getColumnManager(),g=h.getRowManager(),S=h.getConfig().defaultColumnWidth,p=h.getConfig().defaultRowHeight,R=[],M=[];if(r.cols.forEach(y=>{const O=f.getColumnOrCreate(y);R.push({width:`${O.w||S}`})}),r.rows.forEach(y=>{const O=g.getRowOrCreate(y);M.push({height:`${O.ah||O.h||p}`})}),o.copyType===nt.CUT){const y=u.pastedRange.rows[0],O=r.rows[r.rows.length-1]-r.rows[0]+y;u.pastedRange.rows=Array.from(new Array(O+1).keys()).slice(y)}const E=this._pasteUSM({cellMatrix:s,colProperties:R,rowProperties:M},u,n,{range:r,unitId:o.unitId,subUnitId:o.subUnitId,copyType:o.copyType,copyId:e});return o.copyType===nt.CUT&&(this._copyContentCache.set(e,{...o,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),E}_pasteUSM(e,n,o,r){const{rowProperties:s,colProperties:l,cellMatrix:d}=e,{unitId:c,subUnitId:u,pastedRange:h}=n,m=h.cols.length,f=this._clipboardHooks,g=[];if(f.some(O=>{var x;return g.push(O)&&((x=O.onBeforePaste)==null?void 0:x.call(O,{unitId:c,subUnitId:u,range:h}))===!1}))return g.forEach(O=>{var x;return(x=O.onAfterPaste)==null?void 0:x.call(O,!1)}),!1;if(!d)return!1;const p=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,R={copyType:(r==null?void 0:r.copyType)||nt.COPY,copyId:r==null?void 0:r.copyId,pasteType:o};let M=[],E=[];g.filter(O=>!O.specialPasteInfo&&O.id!==Se.DEFAULT_PASTE||o===O.id).forEach(O=>{var W,A,H;if(s){const B=(W=O.onPasteRows)==null?void 0:W.call(O,{range:h,unitId:c,subUnitId:u},s,{pasteType:o});B&&(M.push(...B.redos),E.push(...B.undos))}const x=(A=O.onPasteColumns)==null?void 0:A.call(O,{range:h,unitId:c,subUnitId:u},l||new Array(m).map(()=>({})),{pasteType:o});x&&(M.push(...x.redos),E.push(...x.undos));const D=(H=O.onPasteCells)==null?void 0:H.call(O,p,{range:h,unitId:c,subUnitId:u},d,R);D&&(M.push(...D.redos),E.push(...D.undos))});const w=this._getSetSelectionOperation(c,u,h,d);w&&M.push(w),M=bi(M),E=bi(E),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:E,redoMutationsInfo:M});const y=M.every(O=>this._commandService.executeCommand(O.id,O.params));return y&&this._undoRedoService.pushUndoRedo({unitID:c,undoMutations:E,redoMutations:M}),y}_getSetSelectionOperation(e,n,o,r){var E;const s=(E=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:E.getSheetBySheetId(n);if(!s)return null;const{rows:l,cols:d}=o,c=l[0],u=d[0],h=l[l.length-1],m=d[d.length-1],f={startRow:c,endRow:c,startColumn:u,endColumn:u},g=_.getPrimaryForRange(f,s),S=r.getValue(0,0),p=(S==null?void 0:S.rowSpan)||1,R=(S==null?void 0:S.colSpan)||1;if(p>1||R>1){const b={startRow:c,endRow:c+p-1,startColumn:u,endColumn:u+R-1};g.startRow=b.startRow,g.endRow=b.endRow,g.startColumn=b.startColumn,g.endColumn=b.endColumn,g.isMerged=!0,g.isMergedMainCell=!0}const M={unitId:e,subUnitId:n,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:c,endRow:h,startColumn:u,endColumn:m},primary:g,style:null}]};return{id:_.SetSelectionsOperation.id,params:M}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),o=this._selectionManagerService.getLast();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),selection:o}}_transformPastedData(e,n,o){const r=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:d}=r;if(!s)return null;const c={get:this._injector.get.bind(this._injector)},u=vt(s.range,c,l,d);if(!u)return null;const{ranges:[h],mapFunc:m}=jt([u]),{startRow:f,startColumn:g,endRow:S,endColumn:p}=h,R=S-f+1,M=p-g+1,E=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),b=E==null?void 0:E.getActiveSheet();if(!b)return null;const y=b.getMergeData().filter(H=>u.rows.includes(H.startRow)&&u.cols.includes(H.startColumn)),O=y[0];let x=0,D=0,W=0,A=0;if(O&&(x=O.startRow,D=O.startColumn,W=O.endRow,A=O.endColumn),R%e===0&&M%n===0)if(y.length>0&&(R!==e||M!==n))if(x===u.rows[0]&&D===u.cols[0]&&W===u.rows[R-1]&&A===u.cols[M-1])if(Ga(o))for(let B=0;B<R;B++)for(let z=0;z<M;z++){const Y=o.getValue(B%e,z%n);Y&&o.setValue(B,z,Y)}else o.forValue((B,z,Y)=>{Y.s=null,delete Y.colSpan,delete Y.rowSpan});else for(let H=0;H<R;H++)for(let B=0;B<M;B++){const z=o.getValue(H%e,B%n);z&&o.setValue(H,B,z)}else for(let H=0;H<R;H++)for(let B=0;B<M;B++){const z=o.getValue(H%e,B%n);z&&o.setValue(H,B,z)}else if(y.length>0){const{row:H,col:B}=m(f,g);if(this._topLeftCellsMatch(e,n,{topRow:H,leftCol:B})){const Y=this._expandOrShrinkRowsCols(l,d,u,n,e);u.rows=Y.rows,u.cols=Y.cols}else{if(S>O.endRow||p>O.endColumn)return null;o.forValue((Y,Q,J)=>{J.s=null,delete J.colSpan,delete J.rowSpan})}}else{const H=this._expandOrShrinkRowsCols(l,d,u,n,e);u.rows=H.rows,u.cols=H.cols}return{pastedRange:u,unitId:l,subUnitId:d}}_getPastedRange(e){var b;const n=this._getPastingTarget(),{selection:o,unitId:r,subUnitId:s}=n;if(!o)return null;const l={get:this._injector.get.bind(this._injector)},d=vt(o.range,l,r,s);if(!d)return null;const{startColumn:c,endColumn:u,startRow:h,endRow:m}=e.getDataRange(),f=m-h+1,g=u-c+1,S=d.rows.length,p=d.cols.length,R=(b=this._univerInstanceService.getUniverSheetInstance(r))==null?void 0:b.getSheetBySheetId(s);if(!R)return null;const M=R==null?void 0:R.getMergeData();if(S%f===0&&p%g===0&&!(M==null?void 0:M.some(y=>Ti(y,d)))){for(let y=0;y<S;y++)for(let O=0;O<p;O++){const x=e.getValue(y%f,O%g);x&&e.setValue(y,O,x)}return{pastedRange:d,unitId:r,subUnitId:s}}const E=this._expandOrShrinkRowsCols(r,s,d,g,f);return d.rows=E.rows,d.cols=E.cols,{pastedRange:d,unitId:r,subUnitId:s}}_expandOrShrinkRowsCols(e,n,o,r,s){const{rows:l,cols:d}=o,c=this._univerInstanceService.getUniverSheetInstance(e),u=c==null?void 0:c.getSheetBySheetId(n);let h,m;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let f=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(f)||h.push(f),f++}if(d.length>=r)m=d.slice(0,r);else{m=d.slice(0);let f=d[d.length-1]+1;for(;m.length<r;)m.push(f),f++}return{rows:h,cols:m}}_topLeftCellsMatch(e,n,o){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r==null?void 0:r.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:d}=o,c=Xa(l+e-1,d,d+n-1,s),u=$a(d+n-1,l,l+e-1,s);return!c&&!u}},N.SheetClipboardService=Wa([Re(0,a.ILogService),Re(1,a.IUniverInstanceService),Re(2,P.Inject(_.SelectionManagerService)),Re(3,C.IClipboardInterfaceService),Re(4,a.IUndoRedoService),Re(5,a.ICommandService),Re(6,Wt),Re(7,P.Inject(N.SheetSkeletonManagerService)),Re(8,C.INotificationService),Re(9,C.IPlatformService),Re(10,P.Inject(a.LocaleService)),Re(11,P.Inject(a.ErrorService)),Re(12,P.Inject(P.Injector))],N.SheetClipboardService);function ja(i){let t="";const e=i.getLength();return i.forRow((n,o)=>{const r=[];o.forEach(s=>{const l=i.getValue(n,s);if(l){const d=za(l);r.push(d)}}),t+=r.join(" "),n!==e-1&&(t+=`
|
|
7
|
-
`)}),t}function za(i){const t=a.extractPureTextFromCell(i);return Ya((t==null?void 0:t.toString())||"")}const Ya=i=>i.replace(/&/g,"&").replace(/\uFEFF/g,"").replace(/</g,"<").replace(/>/g,">");function Xa(i,t,e,n){return n.getMergeData().some(o=>o.startRow<=i&&i<o.endRow&&t<=o.startColumn&&o.startColumn<=e)}function $a(i,t,e,n){return n.getMergeData().some(o=>o.startColumn<=i&&i<o.endColumn&&t<=o.startRow&&o.startRow<=e)}function Ga(i){let t=0;return i.forValue((e,n,o)=>{if(o&&t++,t>1)return!1}),t>1}function Fo(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Ei=998,Wo={id:C.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Ei,preconditions:pi,handler:async i=>i.get(It).copy()},Za={id:C.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Ei,preconditions:pi,handler:async i=>i.get(It).cut()},Rt={id:C.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Ei,preconditions:pi,handler:async(i,t)=>{const n=await i.get(C.IClipboardInterfaceService).read(),o=i.get(It);return n.length!==0?o.paste(n[0],t==null?void 0:t.value):!1}},jo={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_VALUE})},zo={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_FORMAT})},Yo={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_COL_WIDTH})},Xo={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_BESIDES_BORDER})};var Mn=(i=>(i.MergeAll="mergeAll",i.MergeVertical="mergeVertical",i.MergeHorizontal="mergeHorizontal",i))(Mn||{});function it(i,t,e,n,o=!0,r=1,s=!0){let l={...i};n==null&&(n={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let d;switch(t){case a.Direction.UP:for(d=i.startRow-r;d>-1&&!e.getRowVisible(d);)d-=1;d>=n.startRow?(l.startRow=d,l.endRow=d):s&&(l.startRow=n.endRow,l.endRow=n.endRow,o&&(l=it(l,a.Direction.LEFT,e,n,!1)));break;case a.Direction.DOWN:for(d=i.endRow+r;d<e.getRowCount()&&!e.getRowVisible(d);)d+=1;d<=n.endRow?(l.startRow=d,l.endRow=d):s&&(l.startRow=n.startRow,l.endRow=n.startRow,o&&(l=it(l,a.Direction.RIGHT,e,n,!1)));break;case a.Direction.LEFT:for(d=i.startColumn-r;d>-1&&!e.getColVisible(d);)d-=1;d>=n.startColumn?(l.startColumn=d,l.endColumn=d):s&&(l.startColumn=n.endColumn,l.endColumn=n.endColumn,o&&(l=it(l,a.Direction.UP,e,n,!1)));break;case a.Direction.RIGHT:for(d=i.endColumn+r;d<e.getColumnCount()&&!e.getColVisible(d);)d+=1;d<=n.endColumn?(l.startColumn=d,l.endColumn=d):s&&(l.startColumn=n.startColumn,l.endColumn=n.startColumn,o&&(l=it(l,a.Direction.DOWN,e,n,!1)));break}return l}function wi(i,t,e){const n={...i},{startRow:o,startColumn:r,endRow:s,endColumn:l}=zt(i,t,e);let d=Yt(e,o,r,s,l).hasValue,c=!0,u=!0;for(;u;){if(a.Direction.UP===t){let h=n.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,h,n.startColumn,h,n.endColumn);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue(S=>{g=Math.min(S,g)}),n.startRow=g}else n.startRow=h;if(n.endRow=n.startRow,!d&&m){u=!1;break}d=m,c=!1}}if(a.Direction.DOWN===t){let h=n.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,h,n.startColumn,h,n.endColumn);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue((S,p,R)=>{g=Math.max(S+(R.rowSpan||1)-1,g)}),n.endRow=g}else n.endRow=h;if(n.startRow=n.endRow,!d&&m){u=!1;break}d=m,c=!1}}if(a.Direction.LEFT===t){let h=n.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,n.startRow,h,n.endRow,h);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue((S,p)=>{g=Math.min(p,g)}),n.startColumn=g}else n.startColumn=h;if(n.endColumn=n.startColumn,!d&&m){u=!1;break}d=m,c=!1}}if(a.Direction.RIGHT===t){let h=n.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,n.startRow,h,n.endRow,h);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue((S,p,R)=>{g=Math.max(p+(R.colSpan||1)-1,g)}),n.endColumn=g}else n.endColumn=h;if(n.startColumn=n.endColumn,!d&&m){u=!1;break}d=m,c=!1}}}return _.alignToMergedCellsBorders(n,e,!0)}function $o(i,t,e){return it(i,t,e,void 0,!1,1,!1)}function Ka(i,t,e){const n=wi(i,t,e);return _.alignToMergedCellsBorders(a.Rectangle.union(n,i),e,!0)}function Qa(i,t,e){const n=$o(i,t,e),o={startRow:Math.min(i.startRow,n.startRow),startColumn:Math.min(i.startColumn,n.startColumn),endRow:Math.max(i.endRow,n.endRow),endColumn:Math.max(i.endColumn,n.endColumn)};return _.alignToMergedCellsBorders(a.Rectangle.union(i,o),e)}function Ja(i,t,e,n){const o=a.getReverseDirection(e),r=wi(zt(i,o,n),e,n);return e===a.Direction.UP&&r.startRow<=i.startRow?_.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===a.Direction.DOWN&&r.endRow>=i.endRow?_.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===a.Direction.LEFT&&r.startColumn<=i.startColumn?_.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):e===a.Direction.RIGHT&&r.endColumn>=i.endColumn?_.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):a.Rectangle.union(a.Rectangle.clone(t),r)}function qa(i,t,e){const n=a.getReverseDirection(t),o=zt(i,n,e),r=zt(i,t,e),s=$o(o,t,e);return _.alignToMergedCellsBorders(a.Rectangle.union(r,s),e,!1)}function Go(i,t,e){const{left:n,right:o,up:r,down:s}=t,l=e.getMaxRows(),d=e.getMaxColumns();let c=!0;const u={...i};for(;c;){if(c=!1,r&&u.startRow!==0){const h=u.startRow-1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((f,g,S)=>{Xt(S)&&(u.startRow=Math.min(f,u.startRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),c=!0)})}if(s&&u.endRow!==l-1){const h=u.endRow+1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((f,g,S)=>{Xt(S)&&(u.endRow=Math.max(f+(S.rowSpan!==void 0?S.rowSpan-1:0),u.endRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),c=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((f,g,S)=>{Xt(S)&&(u.startColumn=Math.min(g,u.startColumn),u.startRow=Math.min(f,u.startRow),u.endRow=Math.max(f,u.endRow),c=!0)})}if(o&&u.endColumn!==d-1){const h=u.endColumn+1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((f,g,S)=>{Xt(S)&&(u.endColumn=Math.max(g+(S.colSpan!==void 0?S.colSpan-1:0),u.endColumn),u.startRow=Math.min(f,u.startRow),u.endRow=Math.max(f,u.endRow),c=!0)})}}return u}function Zo(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function zt(i,t,e){let n;switch(t){case a.Direction.UP:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.startRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.DOWN:n={startRow:i.endRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.LEFT:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.startColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.RIGHT:n={startRow:i.startRow,startColumn:i.endColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return _.alignToMergedCellsBorders(n,e,!1)}function Yt(i,t,e,n,o){let r=!1;const s=i.getMatrixWithMergedCells(t,e,n,o).forValue((l,d,c)=>{if(Xt(c))return r=!0,!1});return{hasValue:r,matrix:s}}function yi(i,t,e){const n=a.Rectangle.clone(i);if(t==null)return n;switch(e){case a.Direction.UP:case a.Direction.DOWN:n.startColumn=n.endColumn=t.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:n.startRow=n.endRow=t.actualRow;break}return n}function el(i,t,e){const{primary:n,range:o}=i,r=a.Rectangle.clone(o);switch(t){case a.Direction.UP:case a.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=zt(r,t,e);switch(t){case a.Direction.DOWN:return o.startRow<s.startRow;case a.Direction.UP:return o.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<o.endColumn;case a.Direction.RIGHT:return s.startColumn>o.startColumn}}function Ko(i,t){let e=i[0].startRow,n=i[0].endRow;i.forEach(r=>{const{startRow:s,endRow:l}=r;e=Math.min(e,s),n=Math.max(n,l)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startRow:s,endRow:l}=r;for(let d=Math.max(s,e);d<=Math.min(l,n);d++)o[d-e]=!0}),i.every(r=>{const{startRow:s,endRow:l}=r;for(let d=s;d<=l;d++)if(!o[d-e])return!1;return!0})}function Qo(i,t){let e=i[0].startColumn,n=i[0].endColumn;i.forEach(r=>{const{startColumn:s,endColumn:l}=r;e=Math.min(e,s),n=Math.max(n,l)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startColumn:s,endColumn:l}=r;for(let d=Math.max(s,e);d<=Math.min(l,n);d++)o[d-e]=!0}),i.every(r=>{const{startColumn:s,endColumn:l}=r;for(let d=s;d<=l;d++)if(!o[d-e])return!1;return!0})}function Oi(i,t){return t?i==="mergeAll"?t.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):i==="mergeVertical"?t.filter(e=>e.startRow!==e.endRow):i==="mergeHorizontal"?t.filter(e=>e.startColumn!==e.endColumn):t:null}function Xt(i){return i.v!==void 0&&i.v!==null&&i.v!==""||i.p!==void 0}var tl=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,il=(i,t,e,n)=>{for(var o=n>1?void 0:n?nl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&tl(t,e,o),o},Jo=(i,t)=>(e,n)=>t(e,n,i);let $t=class{constructor(i,t){I(this,"_current",null);I(this,"_shortcutParam",[]);this._univerInstanceService=i,this._localeService=t}dispose(){this._shortcutParam=[]}getCurrentBySearch(i){return this._getCurrentBySearch(i)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(i){const t=this._getCurrentBySearch({unitId:i.unitId,sheetId:i.sheetId,keycode:i.keycode});if(t!=null){const e=this._shortcutParam.indexOf(t);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(i),t}remove(i){if(i==null)return;const t=this._getCurrentBySearch(i);if(t==null)return;const e=this._shortcutParam.indexOf(t);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(i){return i==null?void 0:this._shortcutParam.find(e=>e.unitId===i.unitId&&e.sheetId===i.sheetId&&e.keycode===i.keycode)}};$t=il([Jo(0,a.IUniverInstanceService),Jo(1,P.Inject(a.LocaleService))],$t);var Fe=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(Fe||{});const Ee={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:o}=e,r=i.get(_.SelectionManagerService).getLast();if(!r)return!1;const{direction:s,jumpOver:l}=t,{range:d,primary:c}=r,u=yi(d,c,s),h=l===1?wi(u,s,o):it(u,s,o),m=_.getCellAtRowCol(h.startRow,h.startColumn,o);return a.Rectangle.equals(m,u)?!1:(i.get($t).remove({unitId:n.getUnitId(),sheetId:o.getSheetId(),keycode:C.KeyCode.TAB}),i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:o.getSheetId(),pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:a.Rectangle.clone(m),primary:{startRow:m.startRow,startColumn:m.startColumn,endRow:m.endRow,endColumn:m.endColumn,actualRow:h.startRow,actualColumn:h.startColumn,isMerged:m.isMerged,isMergedMainCell:m.startRow===h.startRow&&m.startColumn===h.startColumn}}]}))}},ct={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:o}=e,r=i.get(_.SelectionManagerService).getLast();if(!r)return!1;const s=n.getUnitId(),l=o.getSheetId();if(!r)return!1;const{direction:d,keycode:c}=t,{range:u,primary:h}=r;let m=yi(u,h,d);const f=i.get($t),g=f.getCurrentBySearch({unitId:s,sheetId:l,keycode:C.KeyCode.TAB});let S;const{startRow:p,endRow:R,startColumn:M,endColumn:E}=u;if(a.Rectangle.equals(u,h)){if(c===C.KeyCode.TAB)g==null&&f.addOrUpdate({unitId:s,sheetId:l,keycode:C.KeyCode.TAB,selection:r});else{const y=g==null?void 0:g.selection;if(y!=null){const{range:O,primary:x}=y;m=yi(O,x,d)}f.remove({unitId:s,sheetId:l,keycode:C.KeyCode.TAB})}const b=it(m,d,o),w=_.getCellAtRowCol(b.startRow,b.startColumn,o);if(a.Rectangle.equals(w,m))return!1;S={range:a.Rectangle.clone(w),primary:{startRow:w.startRow,startColumn:w.startColumn,endRow:w.endRow,endColumn:w.endColumn,actualRow:b.startRow,actualColumn:b.startColumn,isMerged:w.isMerged,isMergedMainCell:w.startRow===b.startRow&&w.startColumn===b.startColumn}}}else{f.remove({unitId:s,sheetId:l,keycode:C.KeyCode.TAB});const b=a.Tools.deepClone(h),w=it({startRow:b.startRow,startColumn:b.startColumn,endRow:b.endRow,endColumn:b.endColumn},d,o,{startRow:p,endRow:R,startColumn:M,endColumn:E}),y=_.getCellAtRowCol(w.startRow,w.startColumn,o);S={range:a.Rectangle.clone(u),primary:{startRow:y.startRow,startColumn:y.startColumn,endRow:y.endRow,endColumn:y.endColumn,actualRow:w.startRow,actualColumn:w.startColumn,isMerged:y.isMerged,isMergedMainCell:y.startRow===w.startRow&&y.startColumn===w.startColumn}}}return i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:s,subUnitId:l,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[S]})}},He={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:n,unitId:o,subUnitId:r}=e,s=i.get(_.SelectionManagerService).getLast();if(!s)return!1;const{range:l,primary:d}=s,{jumpOver:c,direction:u}=t,m=el(s,u,n)?c===1?Ja(l,{...a.Rectangle.clone(d),rangeType:a.RANGE_TYPE.NORMAL},u,n):qa(l,u,n):c===1?Ka(l,u,n):Qa(l,u,n);return a.Rectangle.equals(m,l)?!1:i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:o,subUnitId:r,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:m,primary:d}]})}};let We=[],Ni="";const qo={id:"sheet.command.select-all",type:a.CommandType.COMMAND,onDispose(){We=[],Ni=""},handler:async(i,t={expandToGapFirst:!0,loop:!1})=>{const e=i.get(_.SelectionManagerService).getLast(),n=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!n)return!1;const{worksheet:o,unitId:r,subUnitId:s}=n;if(!e||!o)return!1;const l=`${r}|${s}`;l!==Ni&&(We=[],Ni=l);const d=o.getMaxRows(),c=o.getMaxColumns(),{expandToGapFirst:u,loop:h}=t,{range:m,primary:f}=e,g=m.endColumn===c-1&&m.endRow===d-1&&m.startRow===0&&m.startColumn===0;We.some(p=>a.Rectangle.equals(p,m))||(We=[],We.push(m));let S;if(g)if(h){if(We.findIndex(R=>a.Rectangle.equals(R,m))!==We.length-1)return!1;S=We[0]}else return!1;else u?(S=Go(m,{left:!0,right:!0,up:!0,down:!0},o),a.Rectangle.equals(S,m)&&(S=Zo(o))):S=Zo(o);return We.some(p=>a.Rectangle.equals(p,S))||We.push(S),i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:r,subUnitId:s,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:S,primary:f}]})}};var ol=Object.defineProperty,rl=Object.getOwnPropertyDescriptor,sl=(i,t,e,n)=>{for(var o=n>1?void 0:n?rl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ol(t,e,o),o},Gt=(i,t)=>(e,n)=>t(e,n,i);const al=a.createInterceptorKey("BEFORE_CELL_EDIT"),ll=a.createInterceptorKey("AFTER_CELL_EDIT"),cl=a.createInterceptorKey("AFTER_CELL_EDIT_ASYNC");N.EditorBridgeService=class extends a.Disposable{constructor(e,n,o,r,s){super();I(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);I(this,"_isForceKeepVisible",!1);I(this,"_editorIsDirty",!1);I(this,"_visible",{visible:!1,eventType:T.DeviceInputEventType.Dblclick});I(this,"_currentEditCell",null);I(this,"_currentEditCellState",null);I(this,"_currentEditCellState$",new k.BehaviorSubject(null));I(this,"currentEditCellState$",this._currentEditCellState$.asObservable());I(this,"_visible$",new k.BehaviorSubject(this._visible));I(this,"visible$",this._visible$.asObservable());I(this,"_afterVisible$",new k.BehaviorSubject(this._visible));I(this,"afterVisible$",this._afterVisible$.asObservable());I(this,"interceptor",new a.InterceptorManager({BEFORE_CELL_EDIT:al,AFTER_CELL_EDIT:ll,AFTER_CELL_EDIT_ASYNC:cl}));this._sheetSkeletonManagerService=e,this._selectionRenderService=n,this._themeService=o,this._univerInstanceService=r,this._editorService=s,this.disposeWithMe(a.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:l=>l}))),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:l=>l}))),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,{priority:-1,handler:l=>l})))}refreshEditCellState(){const e=this.getLatestEditCellState();this._currentEditCellState=e,this._currentEditCellState$.next(e)}setEditCell(e){this._currentEditCell=e;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var A,H;const e=this._currentEditCell;if(e==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:o}=n,{primary:r,unitId:s,sheetId:l,scene:d,engine:c}=e,{startRow:u,startColumn:h}=r,m=this._selectionRenderService.convertCellRangeToInfo(r);if(m==null)return;const f=a.makeCellToSelection(m);if(f==null)return;const g=T.getCanvasOffsetByEngine(c);let{startX:S,startY:p,endX:R,endY:M}=f;const{scaleX:E,scaleY:b}=d.getAncestorScale();d.getPrecisionScale();const w=d.getScrollXY(this._selectionRenderService.getViewPort());S=o.convertTransformToOffsetX(S,E,w),p=o.convertTransformToOffsetY(p,b,w),R=o.convertTransformToOffsetX(R,E,w),M=o.convertTransformToOffsetY(M,b,w);const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),O=y.getActiveSheet(),x={workbook:y,worksheet:O,unitId:y.getUnitId(),subUnitId:O.getSheetId(),row:u,col:h},D=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(O.getCell(u,h),x);let W=D&&o.getCellDocumentModelWithFormula(D);if(!W||W.documentModel==null){const B=o.getBlankCellDocumentModel(D);if(W!=null){const{verticalAlign:z,horizontalAlign:Y,wrapStrategy:Q,textRotation:J,fill:X}=W,{centerAngle:q,vertexAngle:L}=T.convertTextRotation(J);B.documentModel.documentStyle.renderConfig={verticalAlign:z,horizontalAlign:Y,wrapStrategy:Q,background:{rgb:X},centerAngle:q,vertexAngle:L}}W=B}if((A=W.documentModel)==null||A.setZoomRatio(Math.max(E,b)),(D==null?void 0:D.isInArrayFormulaRange)===!0){const B=(H=W.documentModel)==null?void 0:H.getBody();B&&(B.textRuns=[{st:0,ed:B.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return this._editorService.setOperationSheetUnitId(s),this._editorService.setOperationSheetSubUnitId(l),{position:{startX:S,startY:p,endX:R,endY:M},scaleX:E,scaleY:b,canvasOffset:g,row:u,column:h,unitId:s,sheetId:l,documentLayoutObject:W,editorUnitId:this._editorUnitId,isInArrayFormulaRange:D==null?void 0:D.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}},N.EditorBridgeService=sl([Gt(0,P.Inject(N.SheetSkeletonManagerService)),Gt(1,Ie),Gt(2,P.Inject(a.ThemeService)),Gt(3,a.IUniverInstanceService),Gt(4,C.IEditorService)],N.EditorBridgeService);const we=P.createIdentifier("univer.sheet-editor-bridge.service"),ye={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(we);return t==null?!1:(e.changeVisible(t),!0)}},xi={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(i,t)=>(i.get(a.ICommandService).syncExecuteCommand(ye.id,t),!0)},Zt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0};class $e{constructor(){I(this,"_scrollInfo",new Map);I(this,"_scrollInfo$",new k.BehaviorSubject(null));I(this,"scrollInfo$",this._scrollInfo$.asObservable());I(this,"_currentScroll",null)}dispose(){this._scrollInfo$.complete()}setCurrentScroll(t){this._currentScroll=t,this._refresh(t)}getScrollByParam(t){return this._getCurrentScroll(t)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t})}addOrReplaceNoRefresh(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t},!1)}addOrReplaceByParam(t){this._addByParam(t)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(t,e=!0){const{unitId:n,sheetId:o,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:l,offsetY:d}=t;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(o,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:l,offsetY:d}),e===!0&&this._refresh({unitId:n,sheetId:o})}_clearByParam(t){this._addByParam({...t,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(t)}_getCurrentScroll(t){var o;if(t==null)return;const{unitId:e,sheetId:n}=t;return(o=this._scrollInfo.get(e))==null?void 0:o.get(n)}_refresh(t){this._scrollInfo$.next(this._getCurrentScroll(t))}}const ot={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(i,t)=>{if(t==null)return!1;const e=i.get($e),r=i.get(a.IUniverInstanceService).getUniverSheetInstance(t.unitId).getSheetBySheetId(t.sheetId),{xSplit:s,ySplit:l}=r.getConfig().freeze;return e.addOrReplaceByParam({...t,sheetViewStartRow:t.sheetViewStartRow-l,sheetViewStartColumn:t.sheetViewStartColumn-s}),!0}},Kt={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(i,t={offsetX:0,offsetY:0})=>{const e=i.get(a.ICommandService),n=i.get($e),o=i.get(a.IUniverInstanceService),r=_.getSheetCommandTarget(o);if(!r)return!1;const{unitId:s,subUnitId:l,worksheet:d}=r,{xSplit:c,ySplit:u}=d.getConfig().freeze,h=n.getCurrentScroll(),{offsetX:m=0,offsetY:f=0}=t||{},{sheetViewStartRow:g=0,sheetViewStartColumn:S=0,offsetX:p=0,offsetY:R=0}=h||{};return e.executeCommand(ot.id,{unitId:s,sheetId:l,sheetViewStartRow:g+u,sheetViewStartColumn:S+c,offsetX:p+m,offsetY:R+f})}},dt={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(i,t)=>{if(!t)return!1;const e=i.get(a.IUniverInstanceService),n=i.get($e),o=_.getSheetCommandTarget(e);if(!o)return!1;const{workbook:r,worksheet:s}=o,l=n.getCurrentScroll();if(!s)return!1;const{sheetViewStartRow:d,sheetViewStartColumn:c,offsetX:u,offsetY:h}=t,{sheetViewStartColumn:m,sheetViewStartRow:f,offsetX:g,offsetY:S}=l||{},{xSplit:p,ySplit:R}=s.getConfig().freeze;return i.get(a.ICommandService).syncExecuteCommand(ot.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:d!=null?d:(f!=null?f:0)+R,sheetViewStartColumn:c!=null?c:(m!=null?m:0)+p,offsetX:u!=null?u:g,offsetY:h!=null?h:S})}},er={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(i,t)=>i.get(N.ScrollController).scrollToRange(t.range)},dl={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async i=>{const t=i.get(a.IUniverInstanceService),e=_.getSheetCommandTarget(t);if(!e)return!1;const{subUnitId:n,unitId:o}=e;return i.get(a.ICommandService).executeCommand(ot.id,{unitId:o,sheetId:n,sheetViewStartRow:0,sheetViewStartColumn:0})}};function ul(i){return typeof i.isMainScene>"u"}function Me(i,t){const e=i instanceof a.Workbook?i:i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const n=e.getUnitId();let o,r,s,l;if(ul(t)){const m=t.getRenderById(n);if(m==null)return null;o=m.components,o=m.components,r=m.mainComponent,s=m.scene,l=m.engine}else o=t.components,r=t.mainComponent,s=t.scene,l=t.engine;if(!o||!r)return null;const d=r,c=o.get(me.ROW),u=o.get(me.COLUMN),h=o.get(me.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:c,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function Ai(i,t,e,n){const{startX:o,startY:r,endX:s,endY:l}=n.getCellByIndex(i,t);return{startX:o,startY:r,endX:s,endY:l}}function Mt(i,t,e,n,o){const r=e.getRelativeCoord(T.Vector2.FromArray([i,t])),{x:s,y:l}=r,d=e.getScrollXYByRelativeCoords(r,o),{scaleX:c,scaleY:u}=e.getAncestorScale(),h=n.getCellPositionByOffset(s,l,c,u,d),{row:m,column:f}=h,g=n.getNoMergeCellPositionByIndex(m,f),{startX:S,startY:p,endX:R,endY:M}=g;return{startX:S,startY:p,endX:R,endY:M,row:m,column:f}}function bn(i,t,e,n){const o=e.getRelativeCoord(T.Vector2.FromArray([i,t])),r=e.getViewport(j.VIEW_MAIN),s=e.getScrollXYByRelativeCoords(o,r),{scaleX:l,scaleY:d}=e.getAncestorScale(),{x:c,y:u}=s,h=i/l+c,m=t/d+u;return{x:h,y:m}}var hl=Object.defineProperty,ml=Object.getOwnPropertyDescriptor,fl=(i,t,e,n)=>{for(var o=n>1?void 0:n?ml(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&hl(t,e,o),o},bt=(i,t)=>(e,n)=>t(e,n,i);const gl=[Ee.id,ct.id];N.ScrollController=class extends a.Disposable{constructor(t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._commandService=n,this._renderManagerService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._init()}scrollToRange(t){const{startRow:e,startColumn:n}=t;return this._scrollToCell(e,n)}_init(){this._initCommandListener(),this._initScrollEventListener(),this._scrollSubscribeBinding(),this._initSkeletonListener()}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(gl.includes(t.id))this._scrollToSelection();else if(t.id===_.ScrollToCellOperation.id){const e=t.params;this._scrollToSelectionByDirection(e)}else if(t.id===He.id){const e=t.params;this._scrollToSelectionForExpand(e)}}))}_scrollToSelectionForExpand(t){setTimeout(()=>{const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:d,startColumn:c,endRow:u,endColumn:h}=l;let m=0,f=0;n>d?m=r:r<u?m=n:m=d,o>c?f=s:s<h?f=o:f=c,t.direction===a.Direction.DOWN?m=r:t.direction===a.Direction.UP?m=n:t.direction===a.Direction.RIGHT?f=s:t.direction===a.Direction.LEFT&&(f=o),this._scrollToCell(m,f)},0)}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_initScrollEventListener(){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene;if(t==null)return;const e=t.getViewport(j.VIEW_MAIN);this.disposeWithMe(a.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(o=>{var f;const r=(f=this._sheetSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:l=0,actualScrollY:d=0}=o,{row:c,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(l,d);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:u,offsetX:m,offsetY:h})}))),this.disposeWithMe(a.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(o=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:l=0,actualScrollY:d=0}=o,c=this._getFreeze(),{row:u,column:h,rowOffset:m,columnOffset:f}=r.getDecomposedOffset(l,d);this._commandService.executeCommand(dt.id,{sheetViewStartRow:u+((c==null?void 0:c.ySplit)||0),sheetViewStartColumn:h+((c==null?void 0:c.xSplit)||0),offsetX:f,offsetY:m})})))}_scrollSubscribeBinding(){this.disposeWithMe(a.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(t=>{var S;const e=(S=this._sheetSkeletonManagerService.getCurrent())==null?void 0:S.skeleton,n=this._getSheetObject();if(e==null||n==null)return;const o=n.scene;n.scene.getAncestorScale();const r=o.getViewport(j.VIEW_MAIN);if(r==null)return;if(t==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:s,sheetViewStartColumn:l,offsetX:d,offsetY:c}=t,{startX:u,startY:h}=e.getCellByIndexWithNoHeader(s,l),m=u+d,f=h+c,g=r.getBarScroll(m,f);r.scrollTo(g)})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e,sheetId:n}=t;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(t),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:n}))})))}_updateSceneSize(t){var c;if(t==null)return;const{skeleton:e,unitId:n}=t,o=(c=this._renderManagerService.getRenderById(n))==null?void 0:c.scene;if(e==null||o==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:d}=e;o==null||o.transformByState({width:l+s,height:d+r})}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_scrollToSelectionByDirection(t){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;let l=0,d=0;const{startRow:c,startColumn:u,endRow:h,endColumn:m}=t;c>=n&&(l=h),h<=r&&(l=c),u>=o&&(d=m),m<=s&&(d=u),this._scrollToCell(l,d)}_scrollToSelection(t=!0){const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,actualRow:r,actualColumn:s}=e.primary,l=t?r:n,d=t?s:o;this._scrollToCell(l,d)}_getViewportBounding(){var r,s;const t=(r=this._getSheetObject())==null?void 0:r.scene;if(t==null)return;const e=t.getViewport(j.VIEW_MAIN);if(e==null)return;const n=(s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton;if(n==null)return;const o=e.getBounding();return n.getRowColumnSegment(o)}_scrollToCell(t,e){var O,x,D,W;const{rowHeightAccumulation:n,columnWidthAccumulation:o}=(x=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton)!=null?x:{};if(n==null||o==null)return!1;const r=(D=this._getSheetObject())==null?void 0:D.scene;if(r==null)return!1;const s=r.getViewport(j.VIEW_MAIN);if(s==null||this._getSheetObject()==null||((W=this._sheetSkeletonManagerService.getCurrent())==null?void 0:W.skeleton)==null)return!1;const c=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet(),{startColumn:u,startRow:h,ySplit:m,xSplit:f}=c.getFreeze(),g=this._getViewportBounding();if(g==null)return!1;const{startRow:S,startColumn:p,endRow:R,endColumn:M}=g;let E,b;if(t>=h&&e>=u-f&&(t<=S&&(E=t),t>=R)){const A=n[t]-s.height;for(let H=S;H<=t;H++)if(n[H]>=A){E=H+1;break}}if(e>=u&&t>=h-m&&(e<=p&&(b=e),e>=M)){const A=o[e]-s.width;for(let H=p;H<=e;H++)if(o[H]>=A){b=H+1;break}}if(E===void 0&&b===void 0)return!1;const{offsetX:w,offsetY:y}=this._scrollManagerService.getCurrentScroll()||{};return this._commandService.syncExecuteCommand(dt.id,{sheetViewStartRow:E,sheetViewStartColumn:b,offsetX:b===void 0?w:0,offsetY:E===void 0?y:0})}},N.ScrollController=fl([a.OnLifecycle(a.LifecycleStages.Rendered,N.ScrollController),bt(0,P.Inject(N.SheetSkeletonManagerService)),bt(1,a.IUniverInstanceService),bt(2,a.ICommandService),bt(3,T.IRenderManagerService),bt(4,P.Inject(_.SelectionManagerService)),bt(5,P.Inject($e))],N.ScrollController);function Sl(i){return i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.switchMap(t=>t?t.activeSheet$.pipe(k.map(e=>e?{workbook:t,worksheet:e}:null)):k.of(null)))}function _e(i,t,e){return Sl(i).pipe(k.switchMap(n=>n?e(n):k.of(t)))}var _l=Object.defineProperty,pl=Object.getOwnPropertyDescriptor,vl=(i,t,e,n)=>{for(var o=n>1?void 0:n?pl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&_l(t,e,o),o},Qt=(i,t)=>(e,n)=>t(e,n,i);N.SheetRenderController=class extends a.RxDisposable{constructor(e,n,o,r,s){super();I(this,"_skeletonChangeMutations",new Set);this._sheetSkeletonManagerService=e,this._contextService=n,this._univerInstanceService=o,this._renderManagerService=r,this._commandService=s,this._init()}registerSkeletonChangingMutations(e){if(this._skeletonChangeMutations.has(e))throw new Error(`[SheetRenderController]: the mutationId ${e} has already been registered!`);return this._skeletonChangeMutations.add(e),a.toDisposable(()=>this._skeletonChangeMutations.delete(e))}_init(){this._initialRenderRefresh(),this._initSheetDisposeListener(),this._initCommandListener(),this._initContextListener()}_initialRenderRefresh(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:n,unitId:o,sheetId:r}=e,s=this._univerInstanceService.getUniverSheetInstance(o),l=s==null?void 0:s.getSheetBySheetId(r);if(s==null||l==null)return;const d=this._renderManagerService.getRenderById(o);if(d==null)return;const{mainComponent:c,components:u}=d,h=c,m=u.get(me.ROW),f=u.get(me.COLUMN),g=u.get(me.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:p}=n;h==null||h.updateSkeleton(n),m==null||m.updateSkeleton(n),f==null||f.updateSkeleton(n),g==null||g.transformByState({width:S,height:p})}))}_initSheetDisposeListener(){this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(e=>{const n=e.getUnitId();this._sheetSkeletonManagerService.removeSkeleton({unitId:n})})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var r,s;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return;const o=n.getUnitId();if(_.COMMAND_LISTENER_SKELETON_CHANGE.includes(e.id)||this._skeletonChangeMutations.has(e.id)){const l=n.getActiveSheet(),d=l.getSheetId(),c=e.params,{unitId:u,subUnitId:h}=c;if(!(u===n.getUnitId()&&h===l.getSheetId()))return;e.id!==_.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:u,sheetId:d,commandId:e.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:u,sheetId:d,commandId:e.id})}else _.COMMAND_LISTENER_VALUE_CHANGE.includes(e.id)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&((s=(r=this._renderManagerService.getRenderById(o))==null?void 0:r.mainComponent)==null||s.makeDirty())}))}_initContextListener(){this._contextService.subscribeContextValue$(T.RENDER_RAW_FORMULA_KEY).pipe(k.distinctUntilChanged(),k.takeUntil(this.dispose$)).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof T.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})})}},N.SheetRenderController=vl([a.OnLifecycle(a.LifecycleStages.Ready,N.SheetRenderController),Qt(0,P.Inject(N.SheetSkeletonManagerService)),Qt(1,a.IContextService),Qt(2,a.IUniverInstanceService),Qt(3,T.IRenderManagerService),Qt(4,a.ICommandService)],N.SheetRenderController);const Le={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(a.IUniverInstanceService).getUniverSheetInstance(t.unitId),n=e==null?void 0:e.getSheetBySheetId(t.subUnitId);return n==null?!1:(n.getConfig().zoomRatio=t.zoomRatio,!0)}};var Tt=(i=>(i.Append="APPEND",i.Default="DEFAULT",i.Only="ONLY",i))(Tt||{}),ce=(i=>(i.NUMBER="number",i.DATE="date",i.EXTEND_NUMBER="extendNumber",i.CHN_NUMBER="chnNumber",i.CHN_WEEK2="chnWeek2",i.CHN_WEEK3="chnWeek3",i.LOOP_SERIES="loopSeries",i.FORMULA="formula",i.OTHER="other",i))(ce||{}),oe=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(oe||{});const Cl={type:ce.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||(i==null?void 0:i.t)===a.CellValueType.NUMBER,isContinue:(i,t)=>i.type===ce.NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{const{data:n}=i;return e===a.Direction.LEFT||e===a.Direction.UP?(n.reverse(),Mo(n,t,e).reverse()):Mo(n,t,e)}}},tr={type:ce.OTHER,priority:0,match:()=>!0,isContinue:(i,t)=>i.type===ce.OTHER},Il={type:ce.EXTEND_NUMBER,priority:900,match:i=>vn(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,t)=>{var e;if(i.type===ce.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:o}=vn(`${(e=i.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=vn(`${t==null?void 0:t.v}`||"");if(n===r&&o===s)return!0}return!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var l;const{data:n}=i,o=e===a.Direction.UP||e===a.Direction.LEFT;let r;if(n.length===1)return r=o?-1:1,Oe(bo(n,t,r),o);const s=[];for(let d=0;d<n.length;d++){const c=`${(l=n[d])==null?void 0:l.v}`;c&&s.push(Number(vn(c).matchTxt))}return o&&(n.reverse(),s.reverse()),Vt(s)?(r=s[1]-s[0],Oe(bo(n,t,r),o)):at(n,t)}}},Rl={type:ce.CHN_NUMBER,priority:830,match:i=>!!Bs(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===ce.CHN_NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var d,c,u;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP;if(n.length===1){const h=`${(d=n[0])==null?void 0:d.v}`;let m;return o?m=-1:m=1,h&&(h==="日"||Xe(h)<7)?Oe(pt(n,t,m),o):Oe(To(n,t,m),o)}let r=!1;for(let h=0;h<n.length;h++)if(((c=n[h])==null?void 0:c.v)==="日"){r=!0;break}const s=[];let l=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(l++,s.push(l*7)):r&&Xe(m)>0&&Xe(m)<7?s.push(Xe(m)+l*7):s.push(Xe(m))}if(o&&(n.reverse(),s.reverse()),Vt(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return Oe(pt(n,t,m),o)}const h=s[1]-s[0];return Oe(To(n,t,h),o)}return at(n,t)}}},Ml={type:ce.CHN_WEEK2,priority:820,match:i=>!!ks(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===ce.CHN_WEEK2,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var l;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP;if(n.length===1){let d;return o?d=-1:d=1,Oe(pt(n,t,d,1),o)}const r=[];let s=0;for(let d=0;d<n.length;d++){const c=`${(l=n[d])==null?void 0:l.v}`,u=c==null?void 0:c.substr(c.length-1,1);c==="周日"?d===0?r.push(0):(s++,r.push(s*7)):r.push(Xe(u)+s*7)}if(o&&(n.reverse(),r.reverse()),Vt(r)){const d=r[1]-r[0];return Oe(pt(n,t,d,1),o)}return at(n,t)}}},bl={type:ce.CHN_WEEK3,priority:810,match:i=>Fs(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===ce.CHN_WEEK3,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var l;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP;if(n.length===1){let d;return o?d=-1:d=1,Oe(pt(n,t,d,2),o)}const r=[];let s=0;for(let d=0;d<n.length;d++){const c=`${(l=n[d])==null?void 0:l.v}`;if(c){const u=c.substr(c.length-1,1);c==="星期日"?d===0?r.push(0):(s++,r.push(s*7)):r.push(Xe(u)+s*7)}}if(o&&(n.reverse(),r.reverse()),Vt(r)){const d=r[1]-r[0];return Oe(pt(n,t,d,2),o)}return at(n,t)}}},Tl={type:ce.LOOP_SERIES,priority:800,match:i=>Gs(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>{var e;return i.type===ce.LOOP_SERIES?_i(`${(e=i.cellData)==null?void 0:e.v}`||"").name===_i(`${t==null?void 0:t.v}`||"").name:!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var d,c;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP,{series:r}=_i(`${(d=n[0])==null?void 0:d.v}`||"");if(n.length===1){let u;return o?u=-1:u=1,Oe(Eo(n,t,u,r),o)}const s=[];let l=0;for(let u=0;u<n.length;u++){const h=`${(c=n[u])==null?void 0:c.v}`;h&&(h===r[0]?u===0?s.push(0):(l++,s.push(l*r.length)):s.push(r.indexOf(h)+l*7))}if(o&&(n.reverse(),s.reverse()),Vt(s)){const u=s[1]-s[0];return Oe(Eo(n,t,u,r),o)}return at(n,t)}}};function Oe(i,t){return t?i.reverse():i}var El=Object.defineProperty,wl=Object.getOwnPropertyDescriptor,yl=(i,t,e,n)=>{for(var o=n>1?void 0:n?wl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&El(t,e,o),o},Di=(i,t)=>(e,n)=>t(e,n,i);N.AutoFillService=class extends a.Disposable{constructor(e,n,o){super();I(this,"_rules",[]);I(this,"_hooks",[]);I(this,"_applyType$",new k.BehaviorSubject(oe.SERIES));I(this,"_isFillingStyle",!0);I(this,"_autoFillLocation$",new k.BehaviorSubject(null));I(this,"autoFillLocation$",this._autoFillLocation$.asObservable());I(this,"_showMenu$",new k.BehaviorSubject(!1));I(this,"showMenu$",this._showMenu$.asObservable());I(this,"_direction",a.Direction.DOWN);I(this,"applyType$",this._applyType$.asObservable());I(this,"_menu$",new k.BehaviorSubject([{label:"autoFill.copy",value:oe.COPY,disable:!1},{label:"autoFill.series",value:oe.SERIES,disable:!1},{label:"autoFill.formatOnly",value:oe.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:oe.NO_FORMAT,disable:!1}]));I(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=e,this._univerInstanceService=n,this._selectionManagerService=o,this._init()}_init(){this._rules=[Cl,Il,Rl,Ml,bl,Tl,tr].sort((e,n)=>n.priority-e.priority),this._isFillingStyle=!0}getOneByPriority(e){return e.length<=0?[]:[e.reduce((o,r)=>(r.priority||0)>(o.priority||0)?r:o,e[0])]}addHook(e){if(this._hooks.find(n=>n.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=Tt.Append),this._hooks.push(e),a.toDisposable(()=>{const n=this._hooks.findIndex(o=>o===e);n>-1&&this._hooks.splice(n,1)})}registerRule(e){if(this._rules.find(o=>o.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const n=this._rules.findIndex(o=>o.priority<e.priority);this._rules.splice(n===-1?this._rules.length:n,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:n,unitId:o,subUnitId:r}=this.autoFillLocation||{};if(!e||!n||!o||!r)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:n,unitId:o,subUnitId:r},this._direction,this.applyType))}),l=s.filter(u=>u.type===Tt.Only);if(l.length>0)return this.getOneByPriority(l);const d=this.getOneByPriority(s.filter(u=>u.type===Tt.Default)),c=s.filter(u=>u.type===Tt.Append)||[];return[...d,...c]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,n){this._menu$.next(this._menu$.getValue().map(o=>o.value===e?{...o,disable:n}:o))}setShowMenu(e){this._showMenu$.next(e)}},N.AutoFillService=yl([a.OnLifecycle(a.LifecycleStages.Rendered,N.AutoFillService),Di(0,P.Inject(_.SheetInterceptorService)),Di(1,P.Inject(a.IUniverInstanceService)),Di(2,P.Inject(_.SelectionManagerService))],N.AutoFillService);const Jt=P.createIdentifier("univer.auto-fill-service");var Ol=Object.defineProperty,Nl=Object.getOwnPropertyDescriptor,xl=(i,t,e,n)=>{for(var o=n>1?void 0:n?Nl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ol(t,e,o),o},Ge=(i,t)=>(e,n)=>t(e,n,i);N.AutoFillController=class extends a.Disposable{constructor(e,n,o,r,s,l,d,c,u){super();I(this,"_beforeApplyData",[]);I(this,"_copyData",[]);I(this,"_defaultHook");this._univerInstanceService=e,this._selectionRenderService=n,this._commandService=o,this._undoRedoService=r,this._autoFillService=s,this._editorBridgeService=l,this._sheetInterceptorService=d,this._selectionManagerService=c,this._injector=u,this._defaultHook={id:"default",type:Tt.Default,priority:0,onBeforeFillData:(h,m)=>{this._presetAndCacheData(h,m)},onFillData:(h,m,f)=>this._fillData(h,m,f)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[wo,Cn].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initDefaultHook(){this._autoFillService.addHook(this._defaultHook)}_onSelectionControlFillChanged(){const e=new a.DisposableCollection,n=o=>{const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return;o.dispose(),this._selectionRenderService.getCurrentControls().forEach(l=>{o.add(a.toDisposable(l.selectionFilled$.subscribe(d=>{if(d==null||d.startColumn===-1||d.startRow===-1||d.endColumn===-1||d.endRow===-1)return;const c={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow},u={startColumn:d.startColumn,endColumn:d.endColumn,startRow:d.startRow,endRow:d.endRow};this._triggerAutoFill(c,u)}))),o.add(a.toDisposable(l.fillControl.onDblclickObserver.add(()=>{const d={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow};this._handleDbClickFill(d)}))),o.add(a.toDisposable(l.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:T.DeviceInputEventType.PointerDown})})))})};n(e),this.disposeWithMe(this._commandService.onCommandExecuted(o=>{o.id===_.SetSelectionsOperation.id&&n(e)}))}_onApplyTypeChanged(){this.disposeWithMe(a.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(e,n){var f;if(e.startColumn===n.startColumn&&e.startRow===n.startRow&&e.endColumn===n.endColumn&&e.endRow===n.endRow)return;if(n.endColumn<e.endColumn&&n.endColumn>e.startColumn){this._commandService.executeCommand(Cn.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:e.endColumn},selectionRange:n});return}if(n.endRow<e.endRow&&n.endRow>e.startRow){this._commandService.executeCommand(Cn.id,{clearRange:{startRow:n.endRow+1,endRow:e.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const o={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<e.startRow)r=a.Direction.UP,o.endRow=e.startRow-1;else if(n.endRow>e.endRow)r=a.Direction.DOWN,o.startRow=e.endRow+1;else if(n.startColumn<e.startColumn)r=a.Direction.LEFT,o.endColumn=e.startColumn-1;else if(n.endColumn>e.endColumn)r=a.Direction.RIGHT,o.startColumn=e.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._autoFillService.direction=r;const c={get:this._injector.get.bind(this._injector)},u=vt(e,c),h=vt(o,c);if(!u||!h)return;this._autoFillService.autoFillLocation={source:u,target:h,unitId:l,subUnitId:d},this._autoFillService.getActiveHooks().forEach(g=>{var S;(S=g==null?void 0:g.onBeforeFillData)==null||S.call(g,{source:u,target:h,unitId:l,subUnitId:d},r)}),(f=this._autoFillService.menu.find(g=>g.value===oe.SERIES))!=null&&f.disable?this._autoFillService.applyType=oe.COPY:this._autoFillService.applyType=oe.SERIES}_handleDbClickFill(e){const n=this._detectFillRange(e);n.endRow<=e.endRow||this._triggerAutoFill(e,n)}_detectFillRange(e){var m,f,g,S,p,R;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,l=(m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet();if(!l)return e;const d=l.getCellMatrix(),c=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=o;if(r>0&&((f=d.getValue(n,r-1))==null?void 0:f.v)!=null){let M=n;for(;((g=d.getValue(M,r-1))==null?void 0:g.v)!=null&&M<c;)M+=1;h=M-1}else if(s<u&&((S=d.getValue(o,s+1))==null?void 0:S.v)!=null){let M=n;for(;((p=d.getValue(M,s+1))==null?void 0:p.v)!=null&&M<c;)M+=1;h=M-1}for(let M=o+1;M<=h;M++)for(let E=r;E<=s;E++)if(((R=d.getValue(M,E))==null?void 0:R.v)!=null){h=M-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFillData(){var f,g;const{source:e,target:n,unitId:o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId()}=this._autoFillService.autoFillLocation||{},s=this._autoFillService.direction;if(!e||!n)return;const l=a.Rectangle.union(lt(e),lt(n)),d=this._autoFillService.applyType,c=this._autoFillService.getActiveHooks();this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,{selections:[{primary:{...(g=(f=this._selectionManagerService.getLast())==null?void 0:f.primary)!=null?g:l},range:{...l,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:r});const u=[],h=[];c.forEach(S=>{var M;const{undos:p,redos:R}=((M=S.onFillData)==null?void 0:M.call(S,{source:e,target:n,unitId:o,subUnitId:r},s,d))||{};p&&u.push(...p),R&&h.push(...R)}),h.every(S=>this._commandService.syncExecuteCommand(S.id,S.params))&&this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:u,redoMutations:h}),c.forEach(S=>{var p;(p=S.onAfterFillData)==null||p.call(S,{source:e,target:n,unitId:o,subUnitId:r},s,d)}),this._autoFillService.setShowMenu(!0)}_getApplyData(e,n,o,r,s,l=!0){const d=[],c=Math.floor(o/n),u=o%n,h=this._autoFillService.getRules();if(!l&&s===oe.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(f=>{m[f.type]=[]}),h.forEach(f=>{const{type:g,applyFunctions:S={}}=f,p=e[g];p&&p.forEach(R=>{const M=Ws(R.index,u),E=R.index.length*c+M,b=this._applyFunctions(R,E,r,s,S,e),w=js(n,o,R.index);m[g].push({data:b,index:w})})});for(let f=0;f<o;f++)h.forEach(g=>{const{type:S}=g,p=m[S];for(let R=0;R<p.length;R++)f in p[R].index&&d.push(p[R].data[p[R].index[f]])});return d}_applyFunctions(e,n,o,r,s,l){const{data:d}=e,c=o===a.Direction.UP||o===a.Direction.LEFT;if(r===oe.COPY){const u=s==null?void 0:s[oe.COPY];return u?u(e,n,o,l):(c&&d.reverse(),at(d,n))}if(r===oe.SERIES){const u=s==null?void 0:s[oe.SERIES];return u?u(e,n,o,l):(c&&d.reverse(),s!=null&&s[oe.COPY]?s[oe.COPY](e,n,o,l):at(d,n))}if(r===oe.ONLY_FORMAT){const u=s==null?void 0:s[oe.ONLY_FORMAT];return u?u(e,n,o,l):zs(d,n)}}_getCopyData(e,n){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),r=this._autoFillService.getRules(),s=[],l=n===a.Direction.DOWN||n===a.Direction.UP;let d,c;return l?(d=e.cols,c=e.rows):(d=e.rows,c=e.cols),d.forEach(u=>{const h=this._getEmptyCopyDataPiece(),m={type:void 0,cellData:void 0};c.forEach(f=>{let g;l?g=o.getValue(f,u):g=o.getValue(u,f);const{type:S,isContinue:p}=r.find(R=>R.match(g))||tr;if(p(m,g)){const R=h[S],M=R[R.length-1];M.data.push(g),M.index.push(f-c[0])}else{const R=h[S];R?R.push({data:[g],index:[f-c[0]]}):h[S]=[{data:[g],index:[f-c[0]]}]}m.type=S,m.cellData=g}),s.push(h)}),s}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(n=>{e[n.type]=[]}),e}_getMergeApplyData(e,n,o,r){const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),l=[];for(let d=e.startRow;d<=e.endRow;d++)for(let c=e.startColumn;c<=e.endColumn;c++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:f,endColumn:g}=T.getCellInfoInMergeData(d,c,s);if(u){if(o===a.Direction.DOWN){let S=h+r,p=f+r;for(;p<=n.endRow;)l.push({startRow:S,startColumn:m,endRow:p,endColumn:g}),S+=r,p+=r}else if(o===a.Direction.UP){let S=h-r,p=f-r;for(;S>=n.startRow;)l.push({startRow:S,startColumn:m,endRow:p,endColumn:g}),S-=r,p-=r}else if(o===a.Direction.RIGHT){let S=m+r,p=g+r;for(;p<=n.endColumn;)l.push({startRow:h,startColumn:S,endRow:f,endColumn:p}),S+=r,p+=r}else if(o===a.Direction.LEFT){let S=m-r,p=g-r;for(;S>=n.startColumn;)l.push({startRow:h,startColumn:S,endRow:f,endColumn:p}),S-=r,p-=r}}}return l}_presetAndCacheData(e,n){const{source:o,target:r}=e,s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),l=[];r.rows.forEach(d=>{const c=[];r.cols.forEach(u=>{c.push(a.Tools.deepClone(s.getValue(d,u)))}),l.push(c)}),this._beforeApplyData=l,this._copyData=this._getCopyData(o,n),this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(oe.SERIES,!1):this._autoFillService.setDisableApplyType(oe.SERIES,!0)}_fillData(e,n,o){var X,q;const r=[],s=[];let l=!0;o===oe.NO_FORMAT&&(l=!1,o=oe.SERIES);const{source:d,target:c,unitId:u,subUnitId:h}=e;if(!d||!c||n==null)return{undos:r,redos:s};const m=lt(d),f=lt(c),{cols:g,rows:S}=c,{cols:p,rows:R}=d,M=this._copyData;let E;n===a.Direction.DOWN||n===a.Direction.UP?E=R.length:E=p.length;const b=[];if(n===a.Direction.DOWN||n===a.Direction.UP){const L=S.length,U=[];g.forEach((F,$)=>{const Z=M[$],ee=this._getApplyData(Z,E,L,n,o,l);U.push(ee)});for(let F=0;F<U[0].length;F++){const $=[];for(let Z=0;Z<U.length;Z++)$.push({s:null,...U[Z][F]});b.push($)}}else{const L=g.length;S.forEach((U,F)=>{const $=M[F],Z=this._getApplyData($,E,L,n,o,l),ee=[];for(let ne=0;ne<Z.length;ne++)ee.push({s:null,...Z[ne]});b.push(ee)})}let w=[];const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();l?(w=this._getMergeApplyData(m,f,n,E),b.forEach(L=>{L.forEach(U=>{U&&y&&y&&(U.s=y.getStyleByCell(U))})})):b.forEach((L,U)=>{L.forEach((F,$)=>{F&&y&&(F.s=y.getStyleByCell(this._beforeApplyData[U][$])||null)})}),o===oe.ONLY_FORMAT&&b.forEach((L,U)=>{L.forEach((F,$)=>{if(F){const Z=this._beforeApplyData[U][$]||{};F.f=Z.f,F.si=Z.si,F.t=Z.t,F.v=Z.v}})});const O={get:this._injector.get.bind(this._injector)},x=[],D=(q=(X=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:X.getSheetBySheetId(h))==null?void 0:q.getMergeData();D&&D.forEach(L=>{a.Rectangle.intersects(L,f)&&x.push(L)});const W={unitId:u,subUnitId:h,ranges:x},A=_.RemoveMergeUndoMutationFactory(O,W);s.push({id:_.RemoveWorksheetMergeMutation.id,params:W}),r.push({id:_.AddWorksheetMergeMutation.id,params:A});const H={subUnitId:h,unitId:u,cellValue:ma([c])},B=_.SetRangeValuesUndoMutationFactory(O,H),z=this._sheetInterceptorService.onCommandExecute({id:_.ClearSelectionContentCommand.id});s.push({id:_.SetRangeValuesMutation.id,params:H},...z.redos),r.push(...z.undos,{id:_.SetRangeValuesMutation.id,params:B});const Y=new a.ObjectMatrix;S.forEach((L,U)=>{g.forEach((F,$)=>{b[U][$]&&Y.setValue(L,F,b[U][$])})});const Q={subUnitId:h,unitId:u,cellValue:Y.getMatrix()},J=_.SetRangeValuesUndoMutationFactory(O,Q);if(r.push({id:_.SetRangeValuesMutation.id,params:J}),s.push({id:_.SetRangeValuesMutation.id,params:Q}),w!=null&&w.length){const L=_.getAddMergeMutationRangeByType(w),U={unitId:u,subUnitId:h,ranges:L},F=_.AddMergeUndoMutationFactory(O,U);r.push({id:_.RemoveWorksheetMergeMutation.id,params:F}),s.push({id:_.AddWorksheetMergeMutation.id,params:U})}return{undos:r,redos:s}}_hasSeries(e){return e.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![ce.OTHER,ce.FORMULA].includes(r))}))}},N.AutoFillController=xl([a.OnLifecycle(a.LifecycleStages.Steady,N.AutoFillController),Ge(0,a.IUniverInstanceService),Ge(1,Ie),Ge(2,a.ICommandService),Ge(3,a.IUndoRedoService),Ge(4,Jt),Ge(5,we),Ge(6,P.Inject(_.SheetInterceptorService)),Ge(7,P.Inject(_.SelectionManagerService)),Ge(8,P.Inject(P.Injector))],N.AutoFillController);var Al=Object.defineProperty,Dl=Object.getOwnPropertyDescriptor,Pl=(i,t,e,n)=>{for(var o=n>1?void 0:n?Dl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Al(t,e,o),o},Pi=(i,t)=>(e,n)=>t(e,n,i);N.CellCustomRenderController=class extends a.Disposable{constructor(e,n,o){super();I(this,"_enterActiveRender");this._sheetSkeletonManagerService=e,this._renderManagerService=n,this._univerInstanceService=o,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection;this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{if(e.dispose(),n){const o=n.getUnitId(),r=this._renderManagerService.getRenderById(n.getUnitId());if(r&&r.mainComponent){const s=r.mainComponent,l=u=>{var Q;const h=(Q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Q.skeleton,{offsetX:m,offsetY:f}=u,g=r.scene,S=n.getActiveSheet(),p=g.getActiveViewportByCoord(T.Vector2.FromArray([m,f]));if(!p)return;const{scaleX:R,scaleY:M}=g.getAncestorScale(),E={x:p.actualScrollX,y:p.actualScrollY},b=h.getCellPositionByOffset(m,f,R,M,E),w=h.mergeData.find(J=>{const{startColumn:X,startRow:q,endColumn:L,endRow:U}=J;return b.row>=q&&b.column>=X&&b.row<=U&&b.column<=L}),y={actualRow:w?w.startRow:b.row,actualCol:w?w.startColumn:b.column,mergeCell:w,row:b.row,col:b.column};if(!y||!h)return;const O=S.getCell(y.actualRow,y.actualCol);if(!O)return;const x=O.customRender;if(!(x!=null&&x.length))return;const D=y.actualRow,W=y.actualCol,A=x.sort(a.sortRules),H=n.getActiveSheet().getSheetId(),B={data:O,style:h.getsStyles().getStyleByCell(O),primaryWithCoord:h.getCellByIndex(y.actualRow,y.actualCol),unitId:o,subUnitId:H,row:D,col:W},z={x:E.x+m/R,y:E.y+f/M},Y=A.find(J=>{var X;return(X=J.isHit)==null?void 0:X.call(J,z,B)});if(Y)return[Y,B]},d=s.onPointerDownObserver.add(u=>{var m;const h=l(u);if(h){const[f,g]=h;(m=f.onPointerDown)==null||m.call(f,g,u)}}),c=s.onPointerMoveObserver.add(u=>{var m,f,g,S;const h=l(u);if(h){const[p,R]=h;this._enterActiveRender?this._enterActiveRender.render!==p&&((f=(m=this._enterActiveRender.render).onPointerLeave)==null||f.call(m,this._enterActiveRender.cellContext,u),this._enterActiveRender={render:p,cellContext:R},(g=p.onPointerEnter)==null||g.call(p,R,u)):(this._enterActiveRender={render:p,cellContext:R},(S=p.onPointerEnter)==null||S.call(p,R,u))}});d&&e.add(d),c&&e.add(c)}}}),this.disposeWithMe(e)}},N.CellCustomRenderController=Pl([a.OnLifecycle(a.LifecycleStages.Rendered,N.CellCustomRenderController),Pi(0,P.Inject(N.SheetSkeletonManagerService)),Pi(1,T.IRenderManagerService),Pi(2,a.IUniverInstanceService)],N.CellCustomRenderController);const nr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async i=>{var d;const e=(d=i.get(_.SelectionManagerService).getSelections())==null?void 0:d.map(c=>c.range);if(!(e!=null&&e.length))return!1;const n=i.get(a.ICommandService),o=i.get(a.IUniverInstanceService),r=_.getSheetCommandTarget(o);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleRows();if(Ko(l,e)){const c=i.get(C.IConfirmService),u=i.get(a.LocaleService);return await c.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await n.executeCommand(_.SetRowHiddenCommand.id),!0}},ir={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async i=>{var d;const e=(d=i.get(_.SelectionManagerService).getSelections())==null?void 0:d.map(c=>c.range);if(!(e!=null&&e.length))return!1;const n=i.get(a.ICommandService),o=i.get(a.IUniverInstanceService),r=_.getSheetCommandTarget(o);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleCols();if(Qo(l,e)){const c=i.get(C.IConfirmService),u=i.get(a.LocaleService);return await c.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await n.executeCommand(_.SetColHiddenCommand.id),!0}},Hi={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatBoldCommand.id):t.executeCommand(_.SetBoldCommand.id)}},Li={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatItalicCommand.id):t.executeCommand(_.SetItalicCommand.id)}},Ui={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatUnderlineCommand.id):t.executeCommand(_.SetUnderlineCommand.id)}},Vi={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatStrikethroughCommand.id):t.executeCommand(_.SetStrikeThroughCommand.id)}},Hl={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSubscriptCommand.id):!1}},Ll={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSuperscriptCommand.id):!1}},or={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,t)=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontSizeCommand.id,t):e.executeCommand(_.SetFontSizeCommand.id,t)}},rr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,t)=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontFamilyCommand.id,t):e.executeCommand(_.SetFontFamilyCommand.id,t)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,t)=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatTextColorCommand.id,t):e.executeCommand(_.SetTextColorCommand.id,t)}};function sr(i,t){return t.some(e=>Ul(i,e))}function Ul(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o);let l=!1;return s.forValue((d,c,u)=>{if(u&&(d!==e||c!==n)&&i.cellHasValue(u))return l=!0,!1}),l}function ar(i,t,e,n){const o=[],r=[],s=e.getSheetId();return n.forEach(l=>{const d=Vl(e,l),c={unitId:t,subUnitId:s,cellValue:d.getData()},u=_.SetRangeValuesUndoMutationFactory(i,c);o.push({id:_.SetRangeValuesMutation.id,params:u}),r.push({id:_.SetRangeValuesMutation.id,params:c})}),{undos:o,redos:r}}function Vl(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o),l=new a.ObjectMatrix;return s.forValue((d,c,u)=>{u&&(d!==e||c!==n)&&l.setValue(d,c,null)}),l}function Bl(i,t,e,n){const o=e.getActiveViewportByCoord(T.Vector2.FromArray([i,t]));if(!o)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),l={x:o.actualScrollX,y:o.actualScrollY},d=n.getCellPositionByOffset(i,t,r,s,l),c=n.mergeData.find(h=>{const{startColumn:m,startRow:f,endColumn:g,endRow:S}=h;return d.row>=f&&d.column>=m&&d.row<=S&&d.column<=g});return{actualRow:c?c.startRow:d.row,actualCol:c?c.startColumn:d.column,mergeCell:c,row:d.row,col:d.column}}function kl(i,t,e,n){const o=n.getFreeze();if(!o||o.startRow<=0&&o.startColumn<=0||i>o.startRow&&t>o.startColumn)return e.getViewport(j.VIEW_MAIN);if(i<=o.startRow&&t<=o.startColumn)return e.getViewport(j.VIEW_MAIN_LEFT_TOP);if(i<=o.startRow&&t>o.startColumn)return e.getViewport(j.VIEW_MAIN_TOP);if(i>o.startRow&&t<=o.startColumn)return e.getViewport(j.VIEW_MAIN_LEFT)}function Fl(i,t,e,n){const o=lr(i.left,i.top,t,e,n),r=lr(i.right,i.bottom,t,e,n);return{left:o.x,top:o.y,right:r.x,bottom:r.y}}function lr(i,t,e,n,o){const{scaleX:r,scaleY:s}=e.getAncestorScale(),l=e.getViewport(j.VIEW_MAIN);if(!l)return{x:i,y:t};const d=o.getFreeze(),{startColumn:c,startRow:u,xSplit:h,ySplit:m}=d,f=n.getNoMergeCellPositionByIndexWithNoHeader(u-m,c-h),g=n.getNoMergeCellPositionByIndexWithNoHeader(u,c),{rowHeaderWidth:S,columnHeaderHeight:p}=n,R=g.startX-f.startX,M=g.startY-f.startY,{top:E,left:b,actualScrollX:w,actualScrollY:y}=l;let O;i>b?O=(i-w)*r:O=(R+S-(b-i))*r;let x;return t>E?x=(t-y)*s:x=(M+p-(E-t))*r,{x:O,y:x}}var Wl=Object.defineProperty,jl=Object.getOwnPropertyDescriptor,zl=(i,t,e,n)=>{for(var o=n>1?void 0:n?jl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Wl(t,e,o),o},Bi=(i,t)=>(e,n)=>t(e,n,i),Ue=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(Ue||{});const Et=P.createIdentifier("univer.format-painter-service");let ki=class extends a.Disposable{constructor(t,e,n){super();I(this,"status$");I(this,"_selectionFormat");I(this,"_markId",null);I(this,"_status$");this._selectionManagerService=t,this._univerInstanceService=e,this._markSelectionService=n,this._status$=new k.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}setStatus(t){t!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(t),this._status$.next(t)}getStatus(){return this._status$.getValue()}_updateRangeMark(t){if(this._markSelectionService.removeAllShapes(),this._markId=null,t!==0){const e=this._selectionManagerService.getLast();if(e){const n=this._selectionManagerService.createCopyPasteSelection();t===2?this._markId=this._markSelectionService.addShape({...e,style:n}):this._markId=this._markSelectionService.addShape({...e,style:n},[_.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const t=this._selectionManagerService.getLast(),e=t==null?void 0:t.range;if(!e)return;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=(l==null?void 0:l.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),h=l.getStyles(),m=new a.ObjectMatrix;this._selectionFormat.merges=[];for(let f=n;f<=o;f++)for(let g=r;g<=s;g++){const S=c.getValue(f,g);m.setValue(f,g,h.getStyleByCell(S)||{});const{isMergedMainCell:p,...R}=T.getCellInfoInMergeData(f,g,u);p&&this._selectionFormat.merges.push({startRow:R.startRow,startColumn:R.startColumn,endRow:R.endRow,endColumn:R.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};ki=zl([Bi(0,P.Inject(_.SelectionManagerService)),Bi(1,a.IUniverInstanceService),Bi(2,Wt)],ki);const Fi={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(i,t)=>t?(i.get(Et).setStatus(t.status),!0):!1},cr={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const e=i.get(Et).getStatus();let n;return e!==Ue.OFF?n=Ue.OFF:n=Ue.INFINITE,i.get(a.ICommandService).executeCommand(Fi.id,{status:n})}},Wi={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const e=i.get(Et).getStatus();let n;return e!==Ue.OFF?n=Ue.OFF:n=Ue.ONCE,i.get(a.ICommandService).executeCommand(Fi.id,{status:n})}},dr={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,t)=>{const e=i.get(a.ICommandService),n=i.get(a.IUndoRedoService),o=i.get(a.IUniverInstanceService),r=i.get(_.SelectionManagerService),s=i.get(_.SheetInterceptorService),l=_.getSheetCommandTarget(o,t);if(!l)return!1;const{worksheet:d,unitId:c,subUnitId:u}=l,h=i.get(_.SheetPermissionService),{styleValues:m,styleRange:f,mergeRanges:g}=t;if(!h.getSheetEditable(c,u))return!1;const S=f?[f]:r.getSelectionRanges();if(!S||!S.length)return!1;const p=new a.ObjectMatrix;let R;if(a.Tools.isArray(m))for(let Q=0;Q<S.length;Q++){const{startRow:J,startColumn:X,endRow:q,endColumn:L}=S[Q];for(let U=0;U<=q-J;U++)for(let F=0;F<=L-X;F++)p.setValue(U+J,F+X,m[U][F])}else if(a.isICellData(m))for(let Q=0;Q<S.length;Q++){const{startRow:J,startColumn:X}=S[Q];p.setValue(J,X,m)}else R=m;const M={subUnitId:u,unitId:c,cellValue:R!=null?R:p.getMatrix()},E=_.SetRangeValuesUndoMutationFactory(i,M),b=e.syncExecuteCommand(_.SetRangeValuesMutation.id,M),{undos:w,redos:y}=s.onCommandExecute({id:_.SetRangeValuesCommand.id,params:{...M,range:S}}),O=_.getAddMergeMutationRangeByType(g),x=[],D=[],W=sr(d,O),A={unitId:c,subUnitId:u,ranges:O},H={unitId:c,subUnitId:u,ranges:O};x.push({id:_.RemoveWorksheetMergeMutation.id,params:A}),x.push({id:_.AddWorksheetMergeMutation.id,params:H});const B=_.RemoveMergeUndoMutationFactory(i,A),z=_.AddMergeUndoMutationFactory(i,H);if(D.push({id:_.RemoveWorksheetMergeMutation.id,params:z}),D.push({id:_.AddWorksheetMergeMutation.id,params:B}),W){const Q=ar(i,c,d,O);x.unshift(...Q.redos),D.push(...Q.undos)}const Y=await a.sequenceExecute([...y,...x],e);return b&&Y.result?(n.pushUndoRedo({unitID:c,undoMutations:[{id:_.SetRangeValuesMutation.id,params:E},...w,...D],redoMutations:[{id:_.SetRangeValuesMutation.id,params:M},...y,...x]}),!0):!1}},En={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,t)=>{const{type:e}=t||{},n=i.get(a.IUniverInstanceService),o=i.get(a.IUndoRedoService),r=_.getSheetCommandTarget(n);if(!r)return!1;const{unitId:s,subUnitId:l}=r,d=i.get(a.ICommandService),u=i.get(_.SelectionManagerService).getSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:m}=h,f=i.get($e),{sheetViewStartRow:g=0,sheetViewStartColumn:S=0}=f.getCurrentScroll()||{};let p,R,M,E;const{startRow:b,startColumn:w,rangeType:y}=m;if(y===a.RANGE_TYPE.ROW||e===1)p=b,M=b-g,R=-1,E=0;else if(y===a.RANGE_TYPE.COLUMN||e===2)p=-1,M=0,R=w,E=w-S;else if(y===a.RANGE_TYPE.NORMAL)p=b,M=b-g,R=w,E=w-S;else return!1;const O={unitId:s,subUnitId:l,startRow:p,startColumn:R,xSplit:R>0?Math.max(1,E):E,ySplit:p>0?Math.max(1,M):M},x=_.SetFrozenMutationFactory(i,O);return d.syncExecuteCommand(_.SetFrozenMutation.id,O)&&o.pushUndoRedo({unitID:s,undoMutations:[{id:_.SetFrozenMutation.id,params:x}],redoMutations:[{id:_.SetFrozenMutation.id,params:O}]}),!0}},ur={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(a.ICommandService).executeCommand(En.id,{type:1}),!0)},hr={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(a.ICommandService).executeCommand(En.id,{type:2}),!0)},mr={type:a.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(a.IUndoRedoService),o=_.getSheetCommandTarget(e);if(!o)return!1;const{unitId:r,subUnitId:s}=o,l={unitId:r,subUnitId:s,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},d=_.SetFrozenMutationFactory(i,l);return t.syncExecuteCommand(_.SetFrozenMutation.id,l)&&n.pushUndoRedo({unitID:r,undoMutations:[{id:_.SetFrozenMutation.id,params:d}],redoMutations:[{id:_.SetFrozenMutation.id,params:l}]}),!0}},wt="UI_PLUGIN_SHEETS",wn=`${wt}_COLOR_PICKER_COMPONENT`,fr=`${wt}_FONT_FAMILY_COMPONENT`,gr=`${wt}_FONT_FAMILY_ITEM_COMPONENT`,Sr=`${wt}_FONT_SIZE_COMPONENT`,ji=`${wt}_MENU_ITEM_INPUT_COMPONENT`;var _r={exports:{}},yn={};/**
|
|
4
|
+
`,g={dataStream:f,textRuns:m,paragraphs:Ii(f)},S=this._generateDocumentDataModelSnapshot({body:g});n.setValue(0,0,{v:h,p:S}),s.push({})}return d&&d.forEach(f=>{const g=n.getDataRange().endRow+1,{cellMatrix:S,rowProperties:p,colProperties:R}=this._parseTable(f);S&&S.forValue((M,T,b)=>{n.setValue(g+M,T,b)}),R&&l.push(...R),s.push(...p)}),{rowProperties:s,colProperties:l,cellMatrix:n}}_parseTable(t){var s,l;const e=new a.ObjectMatrix,n=(s=Ta(t))!=null?s:[],{rowProperties:o=[]}=ba(t),r=Ea(this.htmlElement,(l=this.getCurrentSkeleton())==null?void 0:l.skeleton);return r&&r.forValue((d,c,u)=>{var f,g,S,p,R,M,T,b,E,y,O,x,D,W,A,H,B,z,X,Q,J,$,ee,L;let h=C.handleStringToStyle(void 0,u.style);if((p=(S=(g=(f=u==null?void 0:u.richTextParma)==null?void 0:f.p)==null?void 0:g.body)==null?void 0:S.textRuns)!=null&&p.length){const U=(M=(R=u==null?void 0:u.richTextParma)==null?void 0:R.v)==null?void 0:M.length;for(let F=0;F<((y=(E=(b=(T=u==null?void 0:u.richTextParma)==null?void 0:T.p)==null?void 0:b.body)==null?void 0:E.textRuns)==null?void 0:y.length);F++){const Y=(D=(x=(O=u==null?void 0:u.richTextParma)==null?void 0:O.p)==null?void 0:x.body)==null?void 0:D.textRuns[F];Y.st===0&&Y.ed===U&&(h={...Y.ts,...h},(H=(A=(W=u==null?void 0:u.richTextParma)==null?void 0:W.p)==null?void 0:A.body)==null||H.textRuns.splice(F,1),F--)}((Q=(X=(z=(B=u==null?void 0:u.richTextParma)==null?void 0:B.p)==null?void 0:z.body)==null?void 0:X.textRuns)==null?void 0:Q.length)===0&&(u.content=(J=u==null?void 0:u.richTextParma)==null?void 0:J.v,delete u.richTextParma)}const m=(L=(ee=($=u==null?void 0:u.richTextParma)==null?void 0:$.p)==null?void 0:ee.body)!=null&&L.textRuns?{v:u.richTextParma.v,p:u.richTextParma.p,s:h,rowSpan:u.rowSpan,colSpan:u.colSpan}:{v:u.content,s:h,rowSpan:u.rowSpan,colSpan:u.colSpan};e.setValue(d,c,m)}),{rowProperties:o,colProperties:n,cellMatrix:e}}_generateDocumentDataModelSnapshot(t){var l;const e=this.getCurrentSkeleton();if(e==null)return null;const{skeleton:n}=e,o=(l=n.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...o==null?void 0:o.getSnapshot(),...t};return o==null||o.reset(s),o==null?void 0:o.getSnapshot()}process(t,e,n,o){var r,s;for(const l of e)if(l.nodeName.toLowerCase()==="table")o.push({index:((r=n==null?void 0:n.paragraphs)==null?void 0:r.length)||0});else if(l.nodeType===Node.TEXT_NODE){const d=(s=l.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let c;t&&this.styleCache.has(t)&&(c=this.styleCache.get(t));const u={dataStream:"",textRuns:[]};n.dataStream+=d,u.dataStream+=d,c&&Object.getOwnPropertyNames(c).length&&(n.textRuns.push({st:n.dataStream.length-d.length,ed:n.dataStream.length,ts:c}),u.textRuns.push({st:n.dataStream.length-d.length,ed:n.dataStream.length,ts:c}))}else if(l.nodeType===Node.ELEMENT_NODE){if(l.nodeName==="STYLE")continue;const d=t?this.styleCache.get(t):{},c=this.styleRules.find(({filter:f})=>Ho(l,f)),u=c?c.getStyle(l):Po(l);this.styleCache.set(l,{...d,...u});const{childNodes:h}=l;this.process(l,h,n,o);const m=this.afterProcessRules.find(({filter:f})=>Ho(l,f));m&&m.handler(n,l)}}dispose(){document.body.removeChild(this.htmlElement)}};I(mi,"pluginList",[]);let Ct=mi;function ba(i){const t=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=i.matchAll(t);if(!e)return{rowProperties:[],rowCount:0};const o=Array.from(e).map(r=>Lo(r[1]));return{rowProperties:o,rowCount:o.length}}function Lo(i){if(!i)return{};const t={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let n;for(;(n=e.exec(i))!==null;){const[,o,,r,s]=n,l=r!==void 0?r:s;t[o]=l}return t}function Ta(i){const t=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=i.match(t),n=/<col([\s\S]*?)>/g;let o;return e!=null&&e[2]?o=e[2].matchAll(n):o=i.matchAll(n),o?Array.from(o).map(r=>Lo(r[1])):null}function wa(i){const t={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return i.replace(/<|>|&|"|'| |<br>/g,e=>t[e])}function ge(i,t){if(!i)return"";const e=/border(-top|-right|-bottom|-left)?\s*:\s*([^;]+);/g,n={},o=i.replace(e,(s,l,d)=>{const c=`border${l||""}`;return n[c]=d.trim(),""});let r=t.map(s=>s==="border"&&n[s]?`border: ${n[s]};`:n[s]?`${s}: ${n[s]};`:"").filter(s=>s).join(" ");return r+=` ${o.trim()}`,r.trim()}function Ea(i,t){var r,s,l;const e=new a.ObjectMatrix,n=(r=i.contentDocument)==null?void 0:r.querySelector("table");if(!n)return e;const o=n==null?void 0:n.querySelectorAll("tr");for(let d=0;d<o.length;d++){const u=o[d].querySelectorAll("td, th");let h=0;for(let m=0;m<u.length;){const f=u[m];let g="";const S=Number(f.getAttribute("rowSpan"))||1,p=Number(f.getAttribute("colSpan"))||1;if(g=ya(f),S>1&&p>1&&!g.includes("border-top")&&!g.includes("border-left")){const b=Vo((s=e.getValue(d-1,m))==null?void 0:s.style,"border-bottom"),E=Vo((l=e.getValue(d,m-1))==null?void 0:l.style,"border-right");b&&(g+=`border-top:${b};`),E&&(g+=`border-left:${E};`)}const{cellText:R,cellRichStyle:M}=Oa(f,t),T=S>1||p>1?{rowSpan:S,colSpan:p,content:R,style:g,richTextParma:{p:M,v:R}}:{content:R,style:g,richTextParma:{p:M,v:R}};if(e.getValue(d,h)){h+=1;continue}else S>1||p>1?Na(e,g,T,{colSpan:p,rowSpan:S,rowIndex:d,colIndex:m,colSetValueIndex:h}):e.setValue(d,h,T),h+=p,m++}}return e}function Uo(i,t,e,n=new Map){var o;for(const r of t)if(r.nodeType===Node.TEXT_NODE){const s=(o=r.nodeValue)==null?void 0:o.replace(/[\r\n]/g,"");let l;i&&n.has(i)&&(l=n.get(i)),e.dataStream+=s,l&&Object.getOwnPropertyNames(l).length&&e.textRuns.push({st:e.dataStream.length-s.length,ed:e.dataStream.length,ts:l})}else{if(r.nodeType===Node.COMMENT_NODE||r.nodeName==="STYLE")continue;if(r.nodeType===Node.ELEMENT_NODE){const s=i?n.get(i):{},l=getComputedStyle(r),d=Po(r,l);n.set(r,{...s,...d});const{childNodes:c}=r;Uo(r,c,e,n)}}}function Vo(i,t){if(!i||!t)return null;const e=new RegExp(`(${t}\\s*:\\s*[^;]+);`,"i"),n=i.match(e);return n?n[1]:null}function ya(i){let t="";const e=i.getAttribute("class"),n=getComputedStyle(i);if(e)Ia.forEach(o=>{const[r,s]=o.split("_"),l=n.getPropertyValue(r)||n[s];l&&(t+=`${r}:${l};`)});else{const r=/<\w+\s+[^>]*?style="([^"]*)"/gi.exec(i.outerHTML);r!=null&&r[1]&&(t=r[1])}return Ra.forEach(o=>{const[r,s]=o.split("_"),l=n.getPropertyValue(r)||n[s];l&&(t+=`${r}:${l};`)}),t}function Oa(i,t){var r;let e="",n;if(/<[^>]+>/.test(i.innerHTML)&&t){const s={dataStream:"",textRuns:[]};Uo(null,i.childNodes,s);const l=(r=t.getBlankCellDocumentModel())==null?void 0:r.documentModel,d=l==null?void 0:l.getSnapshot(),c=`${s.dataStream}\r
|
|
5
|
+
`,u={...d,body:{dataStream:c,textRuns:s.textRuns,paragraphs:Ii(c)}};l==null||l.reset(u),n=l==null?void 0:l.getSnapshot(),e=s.dataStream}else e=wa(i.innerHTML.replace(/[\r\n]/g,""));return{cellText:e,cellRichStyle:n}}function Na(i,t,e,n){const{rowSpan:o,colSpan:r,rowIndex:s,colSetValueIndex:l}=n;if(o===1){for(let d=l;d<l+r;d++)i.setValue(s,d,{style:ge(t,["border-top","border-bottom"])});i.setValue(s,l+r-1,{style:ge(t,["border-top","border-bottom","border-right"])}),i.setValue(s,l,{...e,style:ge(t,["border-top","border-bottom","border-left"])})}else if(r===1){for(let d=s;d<s+o;d++)i.setValue(d,l,{style:ge(t,["border-left","border-right"])});i.setValue(s+o-1,l,{style:ge(t,["border-left","border-right","border-bottom"])}),i.setValue(s,l,{...e,style:ge(t,["border-left","border-right","border-top"])})}else{for(let d=l;d<l+r;d++)i.setValue(s,d,{style:ge(t,["border-top"])}),i.setValue(s+o-1,d,{style:ge(t,["border-bottom"])});for(let d=s;d<s+o;d++)i.setValue(d,l,{style:ge(t,["border-left"])}),i.setValue(d,l+r-1,{style:ge(t,["border-right"])});i.setValue(s+o-1,l,{style:ge(t,["border-left","border-bottom"])}),i.setValue(s,l+r-1,{style:ge(t,["border-right","border-top"])}),i.setValue(s+o-1,l+r-1,{style:ge(t,["border-right","border-bottom"])}),i.setValue(s,l,{...e,style:ge(t,["border-top","border-left"])});for(let d=s;d<s+o;d++)for(let c=l;c<l+r;c++)i.getValue(d,c)||i.setValue(d,c,{style:ge(t,[])})}}var nt=(i=>(i.COPY="COPY",i.CUT="CUT",i))(nt||{});function xa(i,t,e,n,o){const r=e.map(c=>{var u;return(u=c.onCopyRow)==null?void 0:u.call(c,i)}).filter(c=>!!c),s=Ri(r),l=Mi(s),d=t.map(c=>{if(!o.has(`${i}-${c}`)){const u=n.getValue(i,c);if(u!=null&&u.rowSpan&&(u!=null&&u.colSpan))for(let h=i;h<i+u.rowSpan;h++)for(let m=c;m<c+u.colSpan;m++)o.add(`${h}-${m}`);return Aa(i,c,e,n)}return null}).filter(c=>!!c).join("");return`<tr${l}>${d}</tr>`}function Aa(i,t,e,n){const o=n.getValue(i,t),r=e.map(c=>{var u;return(u=c.onCopyCellStyle)==null?void 0:u.call(c,i,t,o==null?void 0:o.rowSpan,o==null?void 0:o.colSpan)}).filter(c=>!!c),s=Ri(r),l=Mi(s),d=e.reduce((c,u)=>{var h;return c||((h=u.onCopyCellContent)==null?void 0:h.call(u,i,t))||""},"");return`<td${l}>${d}</td>`}function Da(i,t){return`<colgroup>${i.map(n=>{const o=t.map(l=>{var d;return(d=l.onCopyColumn)==null?void 0:d.call(l,n)}).filter(l=>!!l),r=Ri(o);return`<col ${Mi(r)}>`}).join("")}</colgroup>`}function Ri(i){return i.reduce((t,e)=>(Object.keys(e).forEach(o=>{t[o]?t[o]+=`;${e[o]}`:t[o]=e[o]}),t),{})}function Mi(i){return Object.keys(i).reduce((t,e)=>(t+=` ${e}="${i[e]}"`,t),"")}function Pa(i,t){const e=[];for(let n=i;n<=t;n++)e.push(n);return e}class Ha{convert(t,e,n){const{startColumn:o,endColumn:r}=e,s=Da(Pa(o,r),n),l=[],d=new Set,{startRow:c,endRow:u,startColumn:h,endColumn:m}=t.getDataRange();for(let g=c;g<=u;g++){const S=Array.from({length:m-h+1},(p,R)=>h+R);l.push(xa(g,S,n,t,d))}return`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
|
|
6
|
+
<tbody>${l.join("")}</tbody></table>`}}const La=(i,t,e=!1)=>{const n=h=>h.endRow-h.startRow+1,o=h=>h.endColumn-h.startColumn+1,r=n(t)%n(i),s=o(t)%o(i),l={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:o(i)-1},d=Math.floor(n(t)/n(i)),c=Math.floor(o(t)/o(i)),u=[];if(!r&&!s)for(let h=1;h<=d;h++)for(let m=1;m<=c;m++){const f=n(i)*(h-1),g=o(i)*(m-1),S={startRow:f+t.startRow,endRow:f+t.startRow,startColumn:g+t.startColumn,endColumn:g+t.startColumn};u.push({repeatRelativeRange:l,startRange:S})}else if(!r&&s&&!e)for(let h=1;h<=d;h++){const m=n(i)*(h-1),f=0,g={startRow:m+t.startRow,endRow:m+t.startRow,startColumn:f+t.startColumn,endColumn:f+t.startColumn};u.push({repeatRelativeRange:l,startRange:g})}else if(r&&!s&&!e)for(let h=1;h<=c;h++){const f=o(i)*(h-1),g={startRow:0+t.startRow,endRow:0+t.startRow,startColumn:f+t.startColumn,endColumn:f+t.startColumn};u.push({repeatRelativeRange:l,startRange:g})}else{const h={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};async function Ua(i){return i?/<td[^>]*class=".*?xl.*?"[^>]*>.*?<\/td>/.test(i):!1}function Va(...i){if(i.length===1)return i[0];const t=new a.ObjectMatrix;return i.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((o,r,s)=>{t.setValue(o,r,{...t.getValue(o,r),...s})})}),t.getMatrix()}function Ba(i,t){return i.id===t.id&&i.params.unitId===t.params.unitId&&i.params.subUnitId===t.params.subUnitId}function bi(i){const t=[];for(let e=0;e<i.length;){let n=1;if(i[e].id===_.SetRangeValuesMutation.id){const o=i[e],r=[o];for(;e+n<i.length&&Ba(o,i[e+n]);)r.push(i[e+n]),n+=1;const s=Va(...r.map(l=>l.params.cellValue||{}));t.push({...o,params:{...o.params,cellValue:s}})}else t.push(i[e]);e+=n}return t}function Ti(i,t){const{startRow:e,endRow:n,startColumn:o,endColumn:r}=i;for(let s=e;s<=n;s++)for(let l=o;l<=r;l++)if(t.rows.includes(s)&&t.cols.includes(l))return!0}function Bo(i,t){const{startRow:e,endRow:n,startColumn:o,endColumn:r}=t;for(let s=e;s<=n;s++)if(!i.rows.includes(s))return!1;for(let s=o;s<=r;s++)if(!i.cols.includes(s))return!1;return!0}var ka=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,Wa=(i,t,e,n)=>{for(var o=n>1?void 0:n?Fa(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ka(t,e,o),o},Re=(i,t)=>(e,n)=>t(e,n,i);const Se={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};Ct.use(gi.PastePluginWord),Ct.use(gi.PastePluginLark),Ct.use(gi.PastePluginUniver);const It=P.createIdentifier("sheet.clipboard-service");N.SheetClipboardService=class extends a.Disposable{constructor(e,n,o,r,s,l,d,c,u,h,m,f,g){super();I(this,"_clipboardHooks",[]);I(this,"_clipboardHooks$",new k.BehaviorSubject([]));I(this,"clipboardHooks$",this._clipboardHooks$.asObservable());I(this,"_htmlToUSM");I(this,"_usmToHtml");I(this,"_copyContentCache");I(this,"_copyMarkId",null);this._logService=e,this._univerInstanceService=n,this._selectionManagerService=o,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=l,this._markSelectionService=d,this._sheetSkeletonManagerService=c,this._notificationService=u,this._platformService=h,this._localeService=m,this._errorService=f,this._injector=g,this._htmlToUSM=new Ct({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new Ha,this._copyContentCache=new pa,this.disposeWithMe(this._htmlToUSM)}copyContentCache(){return this._copyContentCache}async copy(e=nt.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=o.getActiveSheet(),s=this._clipboardHooks;s.forEach(g=>{var S;return(S=g.onBeforeCopy)==null?void 0:S.call(g,o.getUnitId(),r.getSheetId(),n.range)});const l=this._generateCopyContent(o.getUnitId(),r.getSheetId(),n.range,s);if(!l)return!1;const{html:d,plain:c,matrixFragment:u,copyId:h,discreteRange:m}=l;this._copyContentCache.set(h,{unitId:o.getUnitId(),subUnitId:r.getSheetId(),range:m,matrix:u,copyType:e}),await this._clipboardInterfaceService.write(c,d),this._markSelectionService.removeAllShapes();const f=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:f}),s.forEach(g=>{var S;return(S=g.onAfterCopy)==null?void 0:S.call(g)}),!0}async cut(){return this.copy(nt.CUT)}async paste(e,n=Se.DEFAULT_PASTE){const o=e.types,r=o.indexOf(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(l=>l&&l.text()):"",s=o.indexOf(C.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(C.HTML_CLIPBOARD_MIME_TYPE).then(l=>l&&l.text()):"";return s?this._platformService.isWindows&&await Ua(s)?(this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),!1):this._pasteHTML(s,n):r?this._pastePlainText(r,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}legacyPaste(e,n){return e?this._pasteHTML(e,Se.DEFAULT_PASTE):n?this._pastePlainText(n,Se.DEFAULT_PASTE):Promise.resolve(!1)}addClipboardHook(e){if(this._clipboardHooks.findIndex(o=>o.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(o=>{const r=o.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const o=this._clipboardHooks.indexOf(e);o>-1&&(this._clipboardHooks.splice(o,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,n,o,r){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(n);if(!s||!l)return null;const d=r.reduce((b,E)=>{var O;const y=(O=E.getFilteredOutRows)==null?void 0:O.call(E,o);return y==null||y.forEach(x=>b.add(x)),b},new Set),{startColumn:c,startRow:u,endColumn:h,endRow:m}=o,f=l.getMatrixWithMergedCells(u,c,m,h,!0),g=new a.ObjectMatrix;let S=u;const p={rows:[],cols:[]};for(let b=u;b<=m;b++)if(!d.has(b)){p.rows.push(b);for(let E=c;E<=h;E++){const y=f.getValue(b,E);y?g.setValue(S-u,E-c,{...ko(),...a.Tools.deepClone(y)}):g.setValue(S-u,E-c,ko())}S+=1}for(let b=c;b<=h;b++)p.cols.push(b);let R=this._usmToHtml.convert(f,o,r);const M=ja(g),T=Sa();return R=R.replace(/(<[a-z]+)/,(b,E)=>`${E} data-copy-id="${T}"`),{copyId:T,plain:M,html:R,matrixFragment:g,discreteRange:p}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(e,n){const o=this._getPastingTarget();if(!o.selection)return!1;const r={get:this._injector.get.bind(this._injector)},s=vt(o.selection.range,r,o.unitId,o.subUnitId);if(!s)return!1;const{unitId:l,subUnitId:d}=o,c=this._clipboardHooks,u=[];if(c.some(S=>{var p;return u.push(S)&&((p=S.onBeforePaste)==null?void 0:p.call(S,{unitId:l,subUnitId:d,range:s}))===!1}))return u.forEach(S=>{var p;return(p=S.onAfterPaste)==null?void 0:p.call(S,!1)}),!1;const m=[],f=[];u.forEach(S=>{var R;const p=(R=S.onPastePlainText)==null?void 0:R.call(S,{unitId:l,subUnitId:d,range:s},e,{pasteType:n});p&&(m.push(...p.redos),f.push(...p.undos))});const g=m.every(S=>this._commandService.executeCommand(S.id,S.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:f,redoMutations:m}),g}async _pasteHTML(e,n){const o=_a(e);return o&&this._copyContentCache.get(o)?this._pasteInternal(o,n):this._pasteExternal(e,n)}async _pasteExternal(e,n){var u;const{rowProperties:o,colProperties:r,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const l=this._getPastedRange(s);if(!l)return!1;const d=(u=this._univerInstanceService.getUniverSheetInstance(l.unitId))==null?void 0:u.getSheetBySheetId(l.subUnitId);if(!d)return!1;const c=d==null?void 0:d.getMergeData();return c&&c.some(m=>Ti(m,l.pastedRange)&&!Bo(l.pastedRange,m))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:o,colProperties:r,cellMatrix:s},l,n)}async _pasteInternal(e,n){var b,E;const o=a.Tools.deepClone(this._copyContentCache.get(e)),{range:r,matrix:s,unitId:l,subUnitId:d}=o||{};if(!s||!o||!r||!l||!d||!s||!o)return!1;const c=(b=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:b.getStyles();s.forValue((y,O,x)=>{if(typeof x.s=="string"){const D=a.Tools.deepClone(x);D.s=c==null?void 0:c.getStyleByCell(x),s.setValue(y,O,D)}});const u=this._getPastedRange(s);if(!u)return!1;const h=(E=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:E.getSheetBySheetId(u.subUnitId);if(!h)return!1;const m=h==null?void 0:h.getMergeData();if(m&&m.some(O=>Ti(O,u.pastedRange)&&!Bo(u.pastedRange,O)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const f=h.getColumnManager(),g=h.getRowManager(),S=h.getConfig().defaultColumnWidth,p=h.getConfig().defaultRowHeight,R=[],M=[];if(r.cols.forEach(y=>{const O=f.getColumnOrCreate(y);R.push({width:`${O.w||S}`})}),r.rows.forEach(y=>{const O=g.getRowOrCreate(y);M.push({height:`${O.ah||O.h||p}`})}),o.copyType===nt.CUT){const y=u.pastedRange.rows[0],O=r.rows[r.rows.length-1]-r.rows[0]+y;u.pastedRange.rows=Array.from(new Array(O+1).keys()).slice(y)}const T=this._pasteUSM({cellMatrix:s,colProperties:R,rowProperties:M},u,n,{range:r,unitId:o.unitId,subUnitId:o.subUnitId,copyType:o.copyType,copyId:e});return o.copyType===nt.CUT&&(this._copyContentCache.set(e,{...o,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),T}_pasteUSM(e,n,o,r){const{rowProperties:s,colProperties:l,cellMatrix:d}=e,{unitId:c,subUnitId:u,pastedRange:h}=n,m=h.cols.length,f=this._clipboardHooks,g=[];if(f.some(O=>{var x;return g.push(O)&&((x=O.onBeforePaste)==null?void 0:x.call(O,{unitId:c,subUnitId:u,range:h}))===!1}))return g.forEach(O=>{var x;return(x=O.onAfterPaste)==null?void 0:x.call(O,!1)}),!1;if(!d)return!1;const p=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,R={copyType:(r==null?void 0:r.copyType)||nt.COPY,copyId:r==null?void 0:r.copyId,pasteType:o};let M=[],T=[];g.filter(O=>!O.specialPasteInfo&&O.id!==Se.DEFAULT_PASTE||o===O.id).forEach(O=>{var W,A,H;if(s){const B=(W=O.onPasteRows)==null?void 0:W.call(O,{range:h,unitId:c,subUnitId:u},s,{pasteType:o});B&&(M.push(...B.redos),T.push(...B.undos))}const x=(A=O.onPasteColumns)==null?void 0:A.call(O,{range:h,unitId:c,subUnitId:u},l||new Array(m).map(()=>({})),{pasteType:o});x&&(M.push(...x.redos),T.push(...x.undos));const D=(H=O.onPasteCells)==null?void 0:H.call(O,p,{range:h,unitId:c,subUnitId:u},d,R);D&&(M.push(...D.redos),T.push(...D.undos))});const E=this._getSetSelectionOperation(c,u,h,d);E&&M.push(E),M=bi(M),T=bi(T),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:T,redoMutationsInfo:M});const y=M.every(O=>this._commandService.executeCommand(O.id,O.params));return y&&this._undoRedoService.pushUndoRedo({unitID:c,undoMutations:T,redoMutations:M}),y}_getSetSelectionOperation(e,n,o,r){var T;const s=(T=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:T.getSheetBySheetId(n);if(!s)return null;const{rows:l,cols:d}=o,c=l[0],u=d[0],h=l[l.length-1],m=d[d.length-1],f={startRow:c,endRow:c,startColumn:u,endColumn:u},g=_.getPrimaryForRange(f,s),S=r.getValue(0,0),p=(S==null?void 0:S.rowSpan)||1,R=(S==null?void 0:S.colSpan)||1;if(p>1||R>1){const b={startRow:c,endRow:c+p-1,startColumn:u,endColumn:u+R-1};g.startRow=b.startRow,g.endRow=b.endRow,g.startColumn=b.startColumn,g.endColumn=b.endColumn,g.isMerged=!0,g.isMergedMainCell=!0}const M={unitId:e,subUnitId:n,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:c,endRow:h,startColumn:u,endColumn:m},primary:g,style:null}]};return{id:_.SetSelectionsOperation.id,params:M}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),o=this._selectionManagerService.getLast();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),selection:o}}_transformPastedData(e,n,o){const r=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:d}=r;if(!s)return null;const c={get:this._injector.get.bind(this._injector)},u=vt(s.range,c,l,d);if(!u)return null;const{ranges:[h],mapFunc:m}=jt([u]),{startRow:f,startColumn:g,endRow:S,endColumn:p}=h,R=S-f+1,M=p-g+1,T=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),b=T==null?void 0:T.getActiveSheet();if(!b)return null;const y=b.getMergeData().filter(H=>u.rows.includes(H.startRow)&&u.cols.includes(H.startColumn)),O=y[0];let x=0,D=0,W=0,A=0;if(O&&(x=O.startRow,D=O.startColumn,W=O.endRow,A=O.endColumn),R%e===0&&M%n===0)if(y.length>0&&(R!==e||M!==n))if(x===u.rows[0]&&D===u.cols[0]&&W===u.rows[R-1]&&A===u.cols[M-1])if(Ga(o))for(let B=0;B<R;B++)for(let z=0;z<M;z++){const X=o.getValue(B%e,z%n);X&&o.setValue(B,z,X)}else o.forValue((B,z,X)=>{X.s=null,delete X.colSpan,delete X.rowSpan});else for(let H=0;H<R;H++)for(let B=0;B<M;B++){const z=o.getValue(H%e,B%n);z&&o.setValue(H,B,z)}else for(let H=0;H<R;H++)for(let B=0;B<M;B++){const z=o.getValue(H%e,B%n);z&&o.setValue(H,B,z)}else if(y.length>0){const{row:H,col:B}=m(f,g);if(this._topLeftCellsMatch(e,n,{topRow:H,leftCol:B})){const X=this._expandOrShrinkRowsCols(l,d,u,n,e);u.rows=X.rows,u.cols=X.cols}else{if(S>O.endRow||p>O.endColumn)return null;o.forValue((X,Q,J)=>{J.s=null,delete J.colSpan,delete J.rowSpan})}}else{const H=this._expandOrShrinkRowsCols(l,d,u,n,e);u.rows=H.rows,u.cols=H.cols}return{pastedRange:u,unitId:l,subUnitId:d}}_getPastedRange(e){var b;const n=this._getPastingTarget(),{selection:o,unitId:r,subUnitId:s}=n;if(!o)return null;const l={get:this._injector.get.bind(this._injector)},d=vt(o.range,l,r,s);if(!d)return null;const{startColumn:c,endColumn:u,startRow:h,endRow:m}=e.getDataRange(),f=m-h+1,g=u-c+1,S=d.rows.length,p=d.cols.length,R=(b=this._univerInstanceService.getUniverSheetInstance(r))==null?void 0:b.getSheetBySheetId(s);if(!R)return null;const M=R==null?void 0:R.getMergeData();if(S%f===0&&p%g===0&&!(M==null?void 0:M.some(y=>Ti(y,d)))){for(let y=0;y<S;y++)for(let O=0;O<p;O++){const x=e.getValue(y%f,O%g);x&&e.setValue(y,O,x)}return{pastedRange:d,unitId:r,subUnitId:s}}const T=this._expandOrShrinkRowsCols(r,s,d,g,f);return d.rows=T.rows,d.cols=T.cols,{pastedRange:d,unitId:r,subUnitId:s}}_expandOrShrinkRowsCols(e,n,o,r,s){const{rows:l,cols:d}=o,c=this._univerInstanceService.getUniverSheetInstance(e),u=c==null?void 0:c.getSheetBySheetId(n);let h,m;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let f=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(f)||h.push(f),f++}if(d.length>=r)m=d.slice(0,r);else{m=d.slice(0);let f=d[d.length-1]+1;for(;m.length<r;)m.push(f),f++}return{rows:h,cols:m}}_topLeftCellsMatch(e,n,o){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r==null?void 0:r.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:d}=o,c=Xa(l+e-1,d,d+n-1,s),u=$a(d+n-1,l,l+e-1,s);return!c&&!u}},N.SheetClipboardService=Wa([Re(0,a.ILogService),Re(1,a.IUniverInstanceService),Re(2,P.Inject(_.SelectionManagerService)),Re(3,C.IClipboardInterfaceService),Re(4,a.IUndoRedoService),Re(5,a.ICommandService),Re(6,Wt),Re(7,P.Inject(N.SheetSkeletonManagerService)),Re(8,C.INotificationService),Re(9,C.IPlatformService),Re(10,P.Inject(a.LocaleService)),Re(11,P.Inject(a.ErrorService)),Re(12,P.Inject(P.Injector))],N.SheetClipboardService);function ja(i){let t="";const e=i.getLength();return i.forRow((n,o)=>{const r=[];o.forEach(s=>{const l=i.getValue(n,s);if(l){const d=za(l);r.push(d)}}),t+=r.join(" "),n!==e-1&&(t+=`
|
|
7
|
+
`)}),t}function za(i){const t=a.extractPureTextFromCell(i);return Ya((t==null?void 0:t.toString())||"")}const Ya=i=>i.replace(/&/g,"&").replace(/\uFEFF/g,"").replace(/</g,"<").replace(/>/g,">");function Xa(i,t,e,n){return n.getMergeData().some(o=>o.startRow<=i&&i<o.endRow&&t<=o.startColumn&&o.startColumn<=e)}function $a(i,t,e,n){return n.getMergeData().some(o=>o.startColumn<=i&&i<o.endColumn&&t<=o.startRow&&o.startRow<=e)}function Ga(i){let t=0;return i.forValue((e,n,o)=>{if(o&&t++,t>1)return!1}),t>1}function ko(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const wi=998,Fo={id:C.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:wi,preconditions:pi,handler:async i=>i.get(It).copy()},Za={id:C.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:wi,preconditions:pi,handler:async i=>i.get(It).cut()},Rt={id:C.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:wi,preconditions:pi,handler:async(i,t)=>{const n=await i.get(C.IClipboardInterfaceService).read(),o=i.get(It);return n.length!==0?o.paste(n[0],t==null?void 0:t.value):!1}},Wo={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_VALUE})},jo={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_FORMAT})},zo={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_COL_WIDTH})},Yo={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async i=>i.get(a.ICommandService).executeCommand(Rt.id,{value:Se.SPECIAL_PASTE_BESIDES_BORDER})};var Mn=(i=>(i.MergeAll="mergeAll",i.MergeVertical="mergeVertical",i.MergeHorizontal="mergeHorizontal",i))(Mn||{});function it(i,t,e,n,o=!0,r=1,s=!0){let l={...i};n==null&&(n={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let d;switch(t){case a.Direction.UP:for(d=i.startRow-r;d>-1&&!e.getRowVisible(d);)d-=1;d>=n.startRow?(l.startRow=d,l.endRow=d):s&&(l.startRow=n.endRow,l.endRow=n.endRow,o&&(l=it(l,a.Direction.LEFT,e,n,!1)));break;case a.Direction.DOWN:for(d=i.endRow+r;d<e.getRowCount()&&!e.getRowVisible(d);)d+=1;d<=n.endRow?(l.startRow=d,l.endRow=d):s&&(l.startRow=n.startRow,l.endRow=n.startRow,o&&(l=it(l,a.Direction.RIGHT,e,n,!1)));break;case a.Direction.LEFT:for(d=i.startColumn-r;d>-1&&!e.getColVisible(d);)d-=1;d>=n.startColumn?(l.startColumn=d,l.endColumn=d):s&&(l.startColumn=n.endColumn,l.endColumn=n.endColumn,o&&(l=it(l,a.Direction.UP,e,n,!1)));break;case a.Direction.RIGHT:for(d=i.endColumn+r;d<e.getColumnCount()&&!e.getColVisible(d);)d+=1;d<=n.endColumn?(l.startColumn=d,l.endColumn=d):s&&(l.startColumn=n.startColumn,l.endColumn=n.startColumn,o&&(l=it(l,a.Direction.DOWN,e,n,!1)));break}return l}function Ei(i,t,e){const n={...i},{startRow:o,startColumn:r,endRow:s,endColumn:l}=zt(i,t,e);let d=Yt(e,o,r,s,l).hasValue,c=!0,u=!0;for(;u;){if(a.Direction.UP===t){let h=n.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,h,n.startColumn,h,n.endColumn);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue(S=>{g=Math.min(S,g)}),n.startRow=g}else n.startRow=h;if(n.endRow=n.startRow,!d&&m){u=!1;break}d=m,c=!1}}if(a.Direction.DOWN===t){let h=n.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,h,n.startColumn,h,n.endColumn);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue((S,p,R)=>{g=Math.max(S+(R.rowSpan||1)-1,g)}),n.endRow=g}else n.endRow=h;if(n.startRow=n.endRow,!d&&m){u=!1;break}d=m,c=!1}}if(a.Direction.LEFT===t){let h=n.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,n.startRow,h,n.endRow,h);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue((S,p)=>{g=Math.min(p,g)}),n.startColumn=g}else n.startColumn=h;if(n.endColumn=n.startColumn,!d&&m){u=!1;break}d=m,c=!1}}if(a.Direction.RIGHT===t){let h=n.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:m,matrix:f}=Yt(e,n.startRow,h,n.endRow,h);if(d&&!m&&!c){u=!1;break}else{if(f.getLength()!==0){let g=h;f.forValue((S,p,R)=>{g=Math.max(p+(R.colSpan||1)-1,g)}),n.endColumn=g}else n.endColumn=h;if(n.startColumn=n.endColumn,!d&&m){u=!1;break}d=m,c=!1}}}return _.alignToMergedCellsBorders(n,e,!0)}function Xo(i,t,e){return it(i,t,e,void 0,!1,1,!1)}function Ka(i,t,e){const n=Ei(i,t,e);return _.alignToMergedCellsBorders(a.Rectangle.union(n,i),e,!0)}function Qa(i,t,e){const n=Xo(i,t,e),o={startRow:Math.min(i.startRow,n.startRow),startColumn:Math.min(i.startColumn,n.startColumn),endRow:Math.max(i.endRow,n.endRow),endColumn:Math.max(i.endColumn,n.endColumn)};return _.alignToMergedCellsBorders(a.Rectangle.union(i,o),e)}function Ja(i,t,e,n){const o=a.getReverseDirection(e),r=Ei(zt(i,o,n),e,n);return e===a.Direction.UP&&r.startRow<=i.startRow?_.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===a.Direction.DOWN&&r.endRow>=i.endRow?_.alignToMergedCellsBorders({...t,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):e===a.Direction.LEFT&&r.startColumn<=i.startColumn?_.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):e===a.Direction.RIGHT&&r.endColumn>=i.endColumn?_.alignToMergedCellsBorders({...t,startRow:i.startRow,endRow:i.endRow},n,!0):a.Rectangle.union(a.Rectangle.clone(t),r)}function qa(i,t,e){const n=a.getReverseDirection(t),o=zt(i,n,e),r=zt(i,t,e),s=Xo(o,t,e);return _.alignToMergedCellsBorders(a.Rectangle.union(r,s),e,!1)}function $o(i,t,e){const{left:n,right:o,up:r,down:s}=t,l=e.getMaxRows(),d=e.getMaxColumns();let c=!0;const u={...i};for(;c;){if(c=!1,r&&u.startRow!==0){const h=u.startRow-1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((f,g,S)=>{Xt(S)&&(u.startRow=Math.min(f,u.startRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),c=!0)})}if(s&&u.endRow!==l-1){const h=u.endRow+1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((f,g,S)=>{Xt(S)&&(u.endRow=Math.max(f+(S.rowSpan!==void 0?S.rowSpan-1:0),u.endRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),c=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((f,g,S)=>{Xt(S)&&(u.startColumn=Math.min(g,u.startColumn),u.startRow=Math.min(f,u.startRow),u.endRow=Math.max(f,u.endRow),c=!0)})}if(o&&u.endColumn!==d-1){const h=u.endColumn+1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((f,g,S)=>{Xt(S)&&(u.endColumn=Math.max(g+(S.colSpan!==void 0?S.colSpan-1:0),u.endColumn),u.startRow=Math.min(f,u.startRow),u.endRow=Math.max(f,u.endRow),c=!0)})}}return u}function Go(i){return{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL}}function zt(i,t,e){let n;switch(t){case a.Direction.UP:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.startRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.DOWN:n={startRow:i.endRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.LEFT:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.startColumn,rangeType:a.RANGE_TYPE.NORMAL};break;case a.Direction.RIGHT:n={startRow:i.startRow,startColumn:i.endColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:a.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return _.alignToMergedCellsBorders(n,e,!1)}function Yt(i,t,e,n,o){let r=!1;const s=i.getMatrixWithMergedCells(t,e,n,o).forValue((l,d,c)=>{if(Xt(c))return r=!0,!1});return{hasValue:r,matrix:s}}function yi(i,t,e){const n=a.Rectangle.clone(i);if(t==null)return n;switch(e){case a.Direction.UP:case a.Direction.DOWN:n.startColumn=n.endColumn=t.actualColumn;break;case a.Direction.LEFT:case a.Direction.RIGHT:n.startRow=n.endRow=t.actualRow;break}return n}function el(i,t,e){const{primary:n,range:o}=i,r=a.Rectangle.clone(o);switch(t){case a.Direction.UP:case a.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case a.Direction.LEFT:case a.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=zt(r,t,e);switch(t){case a.Direction.DOWN:return o.startRow<s.startRow;case a.Direction.UP:return o.endRow>s.endRow;case a.Direction.LEFT:return s.endColumn<o.endColumn;case a.Direction.RIGHT:return s.startColumn>o.startColumn}}function Zo(i,t){let e=i[0].startRow,n=i[0].endRow;i.forEach(r=>{const{startRow:s,endRow:l}=r;e=Math.min(e,s),n=Math.max(n,l)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startRow:s,endRow:l}=r;for(let d=Math.max(s,e);d<=Math.min(l,n);d++)o[d-e]=!0}),i.every(r=>{const{startRow:s,endRow:l}=r;for(let d=s;d<=l;d++)if(!o[d-e])return!1;return!0})}function Ko(i,t){let e=i[0].startColumn,n=i[0].endColumn;i.forEach(r=>{const{startColumn:s,endColumn:l}=r;e=Math.min(e,s),n=Math.max(n,l)});const o=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startColumn:s,endColumn:l}=r;for(let d=Math.max(s,e);d<=Math.min(l,n);d++)o[d-e]=!0}),i.every(r=>{const{startColumn:s,endColumn:l}=r;for(let d=s;d<=l;d++)if(!o[d-e])return!1;return!0})}function Oi(i,t){return t?i==="mergeAll"?t.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):i==="mergeVertical"?t.filter(e=>e.startRow!==e.endRow):i==="mergeHorizontal"?t.filter(e=>e.startColumn!==e.endColumn):t:null}function Xt(i){return i.v!==void 0&&i.v!==null&&i.v!==""||i.p!==void 0}var tl=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,il=(i,t,e,n)=>{for(var o=n>1?void 0:n?nl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&tl(t,e,o),o},Qo=(i,t)=>(e,n)=>t(e,n,i);let $t=class{constructor(i,t){I(this,"_current",null);I(this,"_shortcutParam",[]);this._univerInstanceService=i,this._localeService=t}dispose(){this._shortcutParam=[]}getCurrentBySearch(i){return this._getCurrentBySearch(i)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(i){const t=this._getCurrentBySearch({unitId:i.unitId,sheetId:i.sheetId,keycode:i.keycode});if(t!=null){const e=this._shortcutParam.indexOf(t);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(i),t}remove(i){if(i==null)return;const t=this._getCurrentBySearch(i);if(t==null)return;const e=this._shortcutParam.indexOf(t);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(i){return i==null?void 0:this._shortcutParam.find(e=>e.unitId===i.unitId&&e.sheetId===i.sheetId&&e.keycode===i.keycode)}};$t=il([Qo(0,a.IUniverInstanceService),Qo(1,P.Inject(a.LocaleService))],$t);var Fe=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(Fe||{});const we={id:"sheet.command.move-selection",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:o}=e,r=i.get(_.SelectionManagerService).getLast();if(!r)return!1;const{direction:s,jumpOver:l}=t,{range:d,primary:c}=r,u=yi(d,c,s),h=l===1?Ei(u,s,o):it(u,s,o),m=_.getCellAtRowCol(h.startRow,h.startColumn,o);return a.Rectangle.equals(m,u)?!1:(i.get($t).remove({unitId:n.getUnitId(),sheetId:o.getSheetId(),keycode:C.KeyCode.TAB}),i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:o.getSheetId(),pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:a.Rectangle.clone(m),primary:{startRow:m.startRow,startColumn:m.startColumn,endRow:m.endRow,endColumn:m.endColumn,actualRow:h.startRow,actualColumn:h.startColumn,isMerged:m.isMerged,isMergedMainCell:m.startRow===h.startRow&&m.startColumn===h.startColumn}}]}))}},ct={id:"sheet.command.move-selection-enter-tab",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:o}=e,r=i.get(_.SelectionManagerService).getLast();if(!r)return!1;const s=n.getUnitId(),l=o.getSheetId();if(!r)return!1;const{direction:d,keycode:c}=t,{range:u,primary:h}=r;let m=yi(u,h,d);const f=i.get($t),g=f.getCurrentBySearch({unitId:s,sheetId:l,keycode:C.KeyCode.TAB});let S;const{startRow:p,endRow:R,startColumn:M,endColumn:T}=u;if(a.Rectangle.equals(u,h)){if(c===C.KeyCode.TAB)g==null&&f.addOrUpdate({unitId:s,sheetId:l,keycode:C.KeyCode.TAB,selection:r});else{const y=g==null?void 0:g.selection;if(y!=null){const{range:O,primary:x}=y;m=yi(O,x,d)}f.remove({unitId:s,sheetId:l,keycode:C.KeyCode.TAB})}const b=it(m,d,o),E=_.getCellAtRowCol(b.startRow,b.startColumn,o);if(a.Rectangle.equals(E,m))return!1;S={range:a.Rectangle.clone(E),primary:{startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn,actualRow:b.startRow,actualColumn:b.startColumn,isMerged:E.isMerged,isMergedMainCell:E.startRow===b.startRow&&E.startColumn===b.startColumn}}}else{f.remove({unitId:s,sheetId:l,keycode:C.KeyCode.TAB});const b=a.Tools.deepClone(h),E=it({startRow:b.startRow,startColumn:b.startColumn,endRow:b.endRow,endColumn:b.endColumn},d,o,{startRow:p,endRow:R,startColumn:M,endColumn:T}),y=_.getCellAtRowCol(E.startRow,E.startColumn,o);S={range:a.Rectangle.clone(u),primary:{startRow:y.startRow,startColumn:y.startColumn,endRow:y.endRow,endColumn:y.endColumn,actualRow:E.startRow,actualColumn:E.startColumn,isMerged:y.isMerged,isMergedMainCell:y.startRow===E.startRow&&y.startColumn===E.startColumn}}}return i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:s,subUnitId:l,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[S]})}},He={id:"sheet.command.expand-selection",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!e)return!1;const{worksheet:n,unitId:o,subUnitId:r}=e,s=i.get(_.SelectionManagerService).getLast();if(!s)return!1;const{range:l,primary:d}=s,{jumpOver:c,direction:u}=t,m=el(s,u,n)?c===1?Ja(l,{...a.Rectangle.clone(d),rangeType:a.RANGE_TYPE.NORMAL},u,n):qa(l,u,n):c===1?Ka(l,u,n):Qa(l,u,n);return a.Rectangle.equals(m,l)?!1:i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:o,subUnitId:r,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:m,primary:d}]})}};let We=[],Ni="";const Jo={id:"sheet.command.select-all",type:a.CommandType.COMMAND,onDispose(){We=[],Ni=""},handler:async(i,t={expandToGapFirst:!0,loop:!1})=>{const e=i.get(_.SelectionManagerService).getLast(),n=_.getSheetCommandTarget(i.get(a.IUniverInstanceService));if(!n)return!1;const{worksheet:o,unitId:r,subUnitId:s}=n;if(!e||!o)return!1;const l=`${r}|${s}`;l!==Ni&&(We=[],Ni=l);const d=o.getMaxRows(),c=o.getMaxColumns(),{expandToGapFirst:u,loop:h}=t,{range:m,primary:f}=e,g=m.endColumn===c-1&&m.endRow===d-1&&m.startRow===0&&m.startColumn===0;We.some(p=>a.Rectangle.equals(p,m))||(We=[],We.push(m));let S;if(g)if(h){if(We.findIndex(R=>a.Rectangle.equals(R,m))!==We.length-1)return!1;S=We[0]}else return!1;else u?(S=$o(m,{left:!0,right:!0,up:!0,down:!0},o),a.Rectangle.equals(S,m)&&(S=Go(o))):S=Go(o);return We.some(p=>a.Rectangle.equals(p,S))||We.push(S),i.get(a.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:r,subUnitId:s,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:S,primary:f}]})}};var ol=Object.defineProperty,rl=Object.getOwnPropertyDescriptor,sl=(i,t,e,n)=>{for(var o=n>1?void 0:n?rl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ol(t,e,o),o},Gt=(i,t)=>(e,n)=>t(e,n,i);const al=a.createInterceptorKey("BEFORE_CELL_EDIT"),ll=a.createInterceptorKey("AFTER_CELL_EDIT"),cl=a.createInterceptorKey("AFTER_CELL_EDIT_ASYNC");N.EditorBridgeService=class extends a.Disposable{constructor(e,n,o,r,s){super();I(this,"_editorUnitId",a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);I(this,"_isForceKeepVisible",!1);I(this,"_editorIsDirty",!1);I(this,"_visible",{visible:!1,eventType:w.DeviceInputEventType.Dblclick});I(this,"_currentEditCell",null);I(this,"_currentEditCellState",null);I(this,"_currentEditCellState$",new k.BehaviorSubject(null));I(this,"currentEditCellState$",this._currentEditCellState$.asObservable());I(this,"_visible$",new k.BehaviorSubject(this._visible));I(this,"visible$",this._visible$.asObservable());I(this,"_afterVisible$",new k.BehaviorSubject(this._visible));I(this,"afterVisible$",this._afterVisible$.asObservable());I(this,"interceptor",new a.InterceptorManager({BEFORE_CELL_EDIT:al,AFTER_CELL_EDIT:ll,AFTER_CELL_EDIT_ASYNC:cl}));this._sheetSkeletonManagerService=e,this._selectionRenderService=n,this._themeService=o,this._univerInstanceService=r,this._editorService=s,this.disposeWithMe(a.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:l=>l}))),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:l=>l}))),this.disposeWithMe(a.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,{priority:-1,handler:l=>l})))}refreshEditCellState(){const e=this.getLatestEditCellState();this._currentEditCellState=e,this._currentEditCellState$.next(e)}setEditCell(e){this._currentEditCell=e;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var A,H;const e=this._currentEditCell;if(e==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:o}=n,{primary:r,unitId:s,sheetId:l,scene:d,engine:c}=e,{startRow:u,startColumn:h}=r,m=this._selectionRenderService.convertCellRangeToInfo(r);if(m==null)return;const f=a.makeCellToSelection(m);if(f==null)return;const g=w.getCanvasOffsetByEngine(c);let{startX:S,startY:p,endX:R,endY:M}=f;const{scaleX:T,scaleY:b}=d.getAncestorScale();d.getPrecisionScale();const E=d.getScrollXY(this._selectionRenderService.getViewPort());S=o.convertTransformToOffsetX(S,T,E),p=o.convertTransformToOffsetY(p,b,E),R=o.convertTransformToOffsetX(R,T,E),M=o.convertTransformToOffsetY(M,b,E);const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),O=y.getActiveSheet(),x={workbook:y,worksheet:O,unitId:y.getUnitId(),subUnitId:O.getSheetId(),row:u,col:h},D=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(O.getCell(u,h),x);let W=D&&o.getCellDocumentModelWithFormula(D);if(!W||W.documentModel==null){const B=o.getBlankCellDocumentModel(D);if(W!=null){const{verticalAlign:z,horizontalAlign:X,wrapStrategy:Q,textRotation:J,fill:$}=W,{centerAngle:ee,vertexAngle:L}=w.convertTextRotation(J);B.documentModel.documentStyle.renderConfig={verticalAlign:z,horizontalAlign:X,wrapStrategy:Q,background:{rgb:$},centerAngle:ee,vertexAngle:L}}W=B}if((A=W.documentModel)==null||A.setZoomRatio(Math.max(T,b)),(D==null?void 0:D.isInArrayFormulaRange)===!0){const B=(H=W.documentModel)==null?void 0:H.getBody();B&&(B.textRuns=[{st:0,ed:B.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return this._editorService.setOperationSheetUnitId(s),this._editorService.setOperationSheetSubUnitId(l),{position:{startX:S,startY:p,endX:R,endY:M},scaleX:T,scaleY:b,canvasOffset:g,row:u,column:h,unitId:s,sheetId:l,documentLayoutObject:W,editorUnitId:this._editorUnitId,isInArrayFormulaRange:D==null?void 0:D.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}},N.EditorBridgeService=sl([Gt(0,P.Inject(N.SheetSkeletonManagerService)),Gt(1,Ie),Gt(2,P.Inject(a.ThemeService)),Gt(3,a.IUniverInstanceService),Gt(4,C.IEditorService)],N.EditorBridgeService);const Ee=P.createIdentifier("univer.sheet-editor-bridge.service"),ye={id:"sheet.operation.set-cell-edit-visible",type:a.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(Ee);return t==null?!1:(e.changeVisible(t),!0)}},xi={id:"sheet.operation.set-cell-edit-visible-f2",type:a.CommandType.OPERATION,handler:(i,t)=>(i.get(a.ICommandService).syncExecuteCommand(ye.id,t),!0)},Zt={id:"sheet.operation.set-cell-edit-visible-arrow",type:a.CommandType.OPERATION,handler:()=>!0};class $e{constructor(){I(this,"_scrollInfo",new Map);I(this,"_scrollInfo$",new k.BehaviorSubject(null));I(this,"scrollInfo$",this._scrollInfo$.asObservable());I(this,"_currentScroll",null)}dispose(){this._scrollInfo$.complete()}setCurrentScroll(t){this._currentScroll=t,this._refresh(t)}getScrollByParam(t){return this._getCurrentScroll(t)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t})}addOrReplaceNoRefresh(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t},!1)}addOrReplaceByParam(t){this._addByParam(t)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(t,e=!0){const{unitId:n,sheetId:o,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:l,offsetY:d}=t;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(o,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:l,offsetY:d}),e===!0&&this._refresh({unitId:n,sheetId:o})}_clearByParam(t){this._addByParam({...t,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(t)}_getCurrentScroll(t){var o;if(t==null)return;const{unitId:e,sheetId:n}=t;return(o=this._scrollInfo.get(e))==null?void 0:o.get(n)}_refresh(t){this._scrollInfo$.next(this._getCurrentScroll(t))}}const ot={id:"sheet.operation.set-scroll",type:a.CommandType.OPERATION,handler:(i,t)=>{if(t==null)return!1;const e=i.get($e),r=i.get(a.IUniverInstanceService).getUniverSheetInstance(t.unitId).getSheetBySheetId(t.sheetId),{xSplit:s,ySplit:l}=r.getConfig().freeze;return e.addOrReplaceByParam({...t,sheetViewStartRow:t.sheetViewStartRow-l,sheetViewStartColumn:t.sheetViewStartColumn-s}),!0}},Kt={id:"sheet.command.set-scroll-relative",type:a.CommandType.COMMAND,handler:async(i,t={offsetX:0,offsetY:0})=>{const e=i.get(a.ICommandService),n=i.get($e),o=i.get(a.IUniverInstanceService),r=_.getSheetCommandTarget(o);if(!r)return!1;const{unitId:s,subUnitId:l,worksheet:d}=r,{xSplit:c,ySplit:u}=d.getConfig().freeze,h=n.getCurrentScroll(),{offsetX:m=0,offsetY:f=0}=t||{},{sheetViewStartRow:g=0,sheetViewStartColumn:S=0,offsetX:p=0,offsetY:R=0}=h||{};return e.executeCommand(ot.id,{unitId:s,sheetId:l,sheetViewStartRow:g+u,sheetViewStartColumn:S+c,offsetX:p+m,offsetY:R+f})}},dt={id:"sheet.command.scroll-view",type:a.CommandType.COMMAND,handler:(i,t)=>{if(!t)return!1;const e=i.get(a.IUniverInstanceService),n=i.get($e),o=_.getSheetCommandTarget(e);if(!o)return!1;const{workbook:r,worksheet:s}=o,l=n.getCurrentScroll();if(!s)return!1;const{sheetViewStartRow:d,sheetViewStartColumn:c,offsetX:u,offsetY:h}=t,{sheetViewStartColumn:m,sheetViewStartRow:f,offsetX:g,offsetY:S}=l||{},{xSplit:p,ySplit:R}=s.getConfig().freeze;return i.get(a.ICommandService).syncExecuteCommand(ot.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:d!=null?d:(f!=null?f:0)+R,sheetViewStartColumn:c!=null?c:(m!=null?m:0)+p,offsetX:u!=null?u:g,offsetY:h!=null?h:S})}},qo={id:"sheet.command.scroll-to-cell",type:a.CommandType.COMMAND,handler:(i,t)=>i.get(N.ScrollController).scrollToRange(t.range)},dl={id:"sheet.command.scroll-view-reset",type:a.CommandType.COMMAND,handler:async i=>{const t=i.get(a.IUniverInstanceService),e=_.getSheetCommandTarget(t);if(!e)return!1;const{subUnitId:n,unitId:o}=e;return i.get(a.ICommandService).executeCommand(ot.id,{unitId:o,sheetId:n,sheetViewStartRow:0,sheetViewStartColumn:0})}};function ul(i){return typeof i.isMainScene>"u"}function Me(i,t){const e=i instanceof a.Workbook?i:i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const n=e.getUnitId();let o,r,s,l;if(ul(t)){const m=t.getRenderById(n);if(m==null)return null;o=m.components,o=m.components,r=m.mainComponent,s=m.scene,l=m.engine}else o=t.components,r=t.mainComponent,s=t.scene,l=t.engine;if(!o||!r)return null;const d=r,c=o.get(me.ROW),u=o.get(me.COLUMN),h=o.get(me.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:c,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:l}}function Ai(i,t,e,n){const{startX:o,startY:r,endX:s,endY:l}=n.getCellByIndex(i,t);return{startX:o,startY:r,endX:s,endY:l}}function Mt(i,t,e,n,o){const r=e.getRelativeCoord(w.Vector2.FromArray([i,t])),{x:s,y:l}=r,d=e.getScrollXYByRelativeCoords(r,o),{scaleX:c,scaleY:u}=e.getAncestorScale(),h=n.getCellPositionByOffset(s,l,c,u,d),{row:m,column:f}=h,g=n.getNoMergeCellPositionByIndex(m,f),{startX:S,startY:p,endX:R,endY:M}=g;return{startX:S,startY:p,endX:R,endY:M,row:m,column:f}}function bn(i,t,e,n){const o=e.getRelativeCoord(w.Vector2.FromArray([i,t])),r=e.getViewport(j.VIEW_MAIN),s=e.getScrollXYByRelativeCoords(o,r),{scaleX:l,scaleY:d}=e.getAncestorScale(),{x:c,y:u}=s,h=i/l+c,m=t/d+u;return{x:h,y:m}}var hl=Object.defineProperty,ml=Object.getOwnPropertyDescriptor,fl=(i,t,e,n)=>{for(var o=n>1?void 0:n?ml(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&hl(t,e,o),o},bt=(i,t)=>(e,n)=>t(e,n,i);const gl=[we.id,ct.id];N.ScrollController=class extends a.Disposable{constructor(t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._commandService=n,this._renderManagerService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._init()}scrollToRange(t){const{startRow:e,startColumn:n}=t;return this._scrollToCell(e,n)}_init(){this._initCommandListener(),this._initScrollEventListener(),this._scrollSubscribeBinding(),this._initSkeletonListener()}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(gl.includes(t.id))this._scrollToSelection();else if(t.id===_.ScrollToCellOperation.id){const e=t.params;this._scrollToSelectionByDirection(e)}else if(t.id===He.id){const e=t.params;this._scrollToSelectionForExpand(e)}}))}_scrollToSelectionForExpand(t){setTimeout(()=>{const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e.range,l=this._getViewportBounding();if(l==null)return;const{startRow:d,startColumn:c,endRow:u,endColumn:h}=l;let m=0,f=0;n>d?m=r:r<u?m=n:m=d,o>c?f=s:s<h?f=o:f=c,t.direction===a.Direction.DOWN?m=r:t.direction===a.Direction.UP?m=n:t.direction===a.Direction.RIGHT?f=s:t.direction===a.Direction.LEFT&&(f=o),this._scrollToCell(m,f)},0)}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_initScrollEventListener(){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene;if(t==null)return;const e=t.getViewport(j.VIEW_MAIN);this.disposeWithMe(a.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(o=>{var f;const r=(f=this._sheetSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:l=0,actualScrollY:d=0}=o,{row:c,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(l,d);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:u,offsetX:m,offsetY:h})}))),this.disposeWithMe(a.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(o=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||o.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:l=0,actualScrollY:d=0}=o,c=this._getFreeze(),{row:u,column:h,rowOffset:m,columnOffset:f}=r.getDecomposedOffset(l,d);this._commandService.executeCommand(dt.id,{sheetViewStartRow:u+((c==null?void 0:c.ySplit)||0),sheetViewStartColumn:h+((c==null?void 0:c.xSplit)||0),offsetX:f,offsetY:m})})))}_scrollSubscribeBinding(){this.disposeWithMe(a.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(t=>{var S;const e=(S=this._sheetSkeletonManagerService.getCurrent())==null?void 0:S.skeleton,n=this._getSheetObject();if(e==null||n==null)return;const o=n.scene;n.scene.getAncestorScale();const r=o.getViewport(j.VIEW_MAIN);if(r==null)return;if(t==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:s,sheetViewStartColumn:l,offsetX:d,offsetY:c}=t,{startX:u,startY:h}=e.getCellByIndexWithNoHeader(s,l),m=u+d,f=h+c,g=r.getBarScroll(m,f);r.scrollTo(g)})))}_initSkeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e,sheetId:n}=t;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(t),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:n}))})))}_updateSceneSize(t){var c;if(t==null)return;const{skeleton:e,unitId:n}=t,o=(c=this._renderManagerService.getRenderById(n))==null?void 0:c.scene;if(e==null||o==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:d}=e;o==null||o.transformByState({width:l+s,height:d+r})}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_scrollToSelectionByDirection(t){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:n,startColumn:o,endRow:r,endColumn:s}=e;let l=0,d=0;const{startRow:c,startColumn:u,endRow:h,endColumn:m}=t;c>=n&&(l=h),h<=r&&(l=c),u>=o&&(d=m),m<=s&&(d=u),this._scrollToCell(l,d)}_scrollToSelection(t=!0){const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:o,actualRow:r,actualColumn:s}=e.primary,l=t?r:n,d=t?s:o;this._scrollToCell(l,d)}_getViewportBounding(){var r,s;const t=(r=this._getSheetObject())==null?void 0:r.scene;if(t==null)return;const e=t.getViewport(j.VIEW_MAIN);if(e==null)return;const n=(s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton;if(n==null)return;const o=e.getBounding();return n.getRowColumnSegment(o)}_scrollToCell(t,e){var O,x,D,W;const{rowHeightAccumulation:n,columnWidthAccumulation:o}=(x=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton)!=null?x:{};if(n==null||o==null)return!1;const r=(D=this._getSheetObject())==null?void 0:D.scene;if(r==null)return!1;const s=r.getViewport(j.VIEW_MAIN);if(s==null||this._getSheetObject()==null||((W=this._sheetSkeletonManagerService.getCurrent())==null?void 0:W.skeleton)==null)return!1;const c=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet(),{startColumn:u,startRow:h,ySplit:m,xSplit:f}=c.getFreeze(),g=this._getViewportBounding();if(g==null)return!1;const{startRow:S,startColumn:p,endRow:R,endColumn:M}=g;let T,b;if(t>=h&&e>=u-f&&(t<=S&&(T=t),t>=R)){const A=n[t]-s.height;for(let H=S;H<=t;H++)if(n[H]>=A){T=H+1;break}}if(e>=u&&t>=h-m&&(e<=p&&(b=e),e>=M)){const A=o[e]-s.width;for(let H=p;H<=e;H++)if(o[H]>=A){b=H+1;break}}if(T===void 0&&b===void 0)return!1;const{offsetX:E,offsetY:y}=this._scrollManagerService.getCurrentScroll()||{};return this._commandService.syncExecuteCommand(dt.id,{sheetViewStartRow:T,sheetViewStartColumn:b,offsetX:b===void 0?E:0,offsetY:T===void 0?y:0})}},N.ScrollController=fl([a.OnLifecycle(a.LifecycleStages.Rendered,N.ScrollController),bt(0,P.Inject(N.SheetSkeletonManagerService)),bt(1,a.IUniverInstanceService),bt(2,a.ICommandService),bt(3,w.IRenderManagerService),bt(4,P.Inject(_.SelectionManagerService)),bt(5,P.Inject($e))],N.ScrollController);function Sl(i){return i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.switchMap(t=>t?t.activeSheet$.pipe(k.map(e=>e?{workbook:t,worksheet:e}:null)):k.of(null)))}function _e(i,t,e){return Sl(i).pipe(k.switchMap(n=>n?e(n):k.of(t)))}var _l=Object.defineProperty,pl=Object.getOwnPropertyDescriptor,vl=(i,t,e,n)=>{for(var o=n>1?void 0:n?pl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&_l(t,e,o),o},Qt=(i,t)=>(e,n)=>t(e,n,i);N.SheetRenderController=class extends a.RxDisposable{constructor(e,n,o,r,s){super();I(this,"_skeletonChangeMutations",new Set);this._sheetSkeletonManagerService=e,this._contextService=n,this._univerInstanceService=o,this._renderManagerService=r,this._commandService=s,this._init()}registerSkeletonChangingMutations(e){if(this._skeletonChangeMutations.has(e))throw new Error(`[SheetRenderController]: the mutationId ${e} has already been registered!`);return this._skeletonChangeMutations.add(e),a.toDisposable(()=>this._skeletonChangeMutations.delete(e))}_init(){this._initialRenderRefresh(),this._initSheetDisposeListener(),this._initCommandListener(),this._initContextListener()}_initialRenderRefresh(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:n,unitId:o,sheetId:r}=e,s=this._univerInstanceService.getUniverSheetInstance(o),l=s==null?void 0:s.getSheetBySheetId(r);if(s==null||l==null)return;const d=this._renderManagerService.getRenderById(o);if(d==null)return;const{mainComponent:c,components:u}=d,h=c,m=u.get(me.ROW),f=u.get(me.COLUMN),g=u.get(me.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:p}=n;h==null||h.updateSkeleton(n),m==null||m.updateSkeleton(n),f==null||f.updateSkeleton(n),g==null||g.transformByState({width:S,height:p})}))}_initSheetDisposeListener(){this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(e=>{const n=e.getUnitId();this._sheetSkeletonManagerService.removeSkeleton({unitId:n})})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var r,s;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return;const o=n.getUnitId();if(_.COMMAND_LISTENER_SKELETON_CHANGE.includes(e.id)||this._skeletonChangeMutations.has(e.id)){const l=n.getActiveSheet(),d=l.getSheetId(),c=e.params,{unitId:u,subUnitId:h}=c;if(!(u===n.getUnitId()&&h===l.getSheetId()))return;e.id!==_.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:u,sheetId:d,commandId:e.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:u,sheetId:d,commandId:e.id})}else _.COMMAND_LISTENER_VALUE_CHANGE.includes(e.id)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&((s=(r=this._renderManagerService.getRenderById(o))==null?void 0:r.mainComponent)==null||s.makeDirty())}))}_initContextListener(){this._contextService.subscribeContextValue$(w.RENDER_RAW_FORMULA_KEY).pipe(k.distinctUntilChanged(),k.takeUntil(this.dispose$)).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof w.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})})}},N.SheetRenderController=vl([a.OnLifecycle(a.LifecycleStages.Ready,N.SheetRenderController),Qt(0,P.Inject(N.SheetSkeletonManagerService)),Qt(1,a.IContextService),Qt(2,a.IUniverInstanceService),Qt(3,w.IRenderManagerService),Qt(4,a.ICommandService)],N.SheetRenderController);const Le={id:"sheet.operation.set-zoom-ratio",type:a.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(a.IUniverInstanceService).getUniverSheetInstance(t.unitId),n=e==null?void 0:e.getSheetBySheetId(t.subUnitId);return n==null?!1:(n.getConfig().zoomRatio=t.zoomRatio,!0)}};var Tt=(i=>(i.Append="APPEND",i.Default="DEFAULT",i.Only="ONLY",i))(Tt||{}),ce=(i=>(i.NUMBER="number",i.DATE="date",i.EXTEND_NUMBER="extendNumber",i.CHN_NUMBER="chnNumber",i.CHN_WEEK2="chnWeek2",i.CHN_WEEK3="chnWeek3",i.LOOP_SERIES="loopSeries",i.FORMULA="formula",i.OTHER="other",i))(ce||{}),oe=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(oe||{});const Cl={type:ce.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||(i==null?void 0:i.t)===a.CellValueType.NUMBER,isContinue:(i,t)=>i.type===ce.NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{const{data:n}=i;return e===a.Direction.LEFT||e===a.Direction.UP?(n.reverse(),Ro(n,t,e).reverse()):Ro(n,t,e)}}},er={type:ce.OTHER,priority:0,match:()=>!0,isContinue:(i,t)=>i.type===ce.OTHER},Il={type:ce.EXTEND_NUMBER,priority:900,match:i=>vn(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,t)=>{var e;if(i.type===ce.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:o}=vn(`${(e=i.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=vn(`${t==null?void 0:t.v}`||"");if(n===r&&o===s)return!0}return!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var l;const{data:n}=i,o=e===a.Direction.UP||e===a.Direction.LEFT;let r;if(n.length===1)return r=o?-1:1,Oe(Mo(n,t,r),o);const s=[];for(let d=0;d<n.length;d++){const c=`${(l=n[d])==null?void 0:l.v}`;c&&s.push(Number(vn(c).matchTxt))}return o&&(n.reverse(),s.reverse()),Vt(s)?(r=s[1]-s[0],Oe(Mo(n,t,r),o)):at(n,t)}}},Rl={type:ce.CHN_NUMBER,priority:830,match:i=>!!Bs(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===ce.CHN_NUMBER,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var d,c,u;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP;if(n.length===1){const h=`${(d=n[0])==null?void 0:d.v}`;let m;return o?m=-1:m=1,h&&(h==="日"||Xe(h)<7)?Oe(pt(n,t,m),o):Oe(bo(n,t,m),o)}let r=!1;for(let h=0;h<n.length;h++)if(((c=n[h])==null?void 0:c.v)==="日"){r=!0;break}const s=[];let l=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(l++,s.push(l*7)):r&&Xe(m)>0&&Xe(m)<7?s.push(Xe(m)+l*7):s.push(Xe(m))}if(o&&(n.reverse(),s.reverse()),Vt(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return Oe(pt(n,t,m),o)}const h=s[1]-s[0];return Oe(bo(n,t,h),o)}return at(n,t)}}},Ml={type:ce.CHN_WEEK2,priority:820,match:i=>!!ks(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===ce.CHN_WEEK2,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var l;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP;if(n.length===1){let d;return o?d=-1:d=1,Oe(pt(n,t,d,1),o)}const r=[];let s=0;for(let d=0;d<n.length;d++){const c=`${(l=n[d])==null?void 0:l.v}`,u=c==null?void 0:c.substr(c.length-1,1);c==="周日"?d===0?r.push(0):(s++,r.push(s*7)):r.push(Xe(u)+s*7)}if(o&&(n.reverse(),r.reverse()),Vt(r)){const d=r[1]-r[0];return Oe(pt(n,t,d,1),o)}return at(n,t)}}},bl={type:ce.CHN_WEEK3,priority:810,match:i=>Fs(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>i.type===ce.CHN_WEEK3,applyFunctions:{[oe.SERIES]:(i,t,e)=>{var l;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP;if(n.length===1){let d;return o?d=-1:d=1,Oe(pt(n,t,d,2),o)}const r=[];let s=0;for(let d=0;d<n.length;d++){const c=`${(l=n[d])==null?void 0:l.v}`;if(c){const u=c.substr(c.length-1,1);c==="星期日"?d===0?r.push(0):(s++,r.push(s*7)):r.push(Xe(u)+s*7)}}if(o&&(n.reverse(),r.reverse()),Vt(r)){const d=r[1]-r[0];return Oe(pt(n,t,d,2),o)}return at(n,t)}}},Tl={type:ce.LOOP_SERIES,priority:800,match:i=>Gs(`${i==null?void 0:i.v}`||""),isContinue:(i,t)=>{var e;return i.type===ce.LOOP_SERIES?_i(`${(e=i.cellData)==null?void 0:e.v}`||"").name===_i(`${t==null?void 0:t.v}`||"").name:!1},applyFunctions:{[oe.SERIES]:(i,t,e)=>{var d,c;const{data:n}=i,o=e===a.Direction.LEFT||e===a.Direction.UP,{series:r}=_i(`${(d=n[0])==null?void 0:d.v}`||"");if(n.length===1){let u;return o?u=-1:u=1,Oe(To(n,t,u,r),o)}const s=[];let l=0;for(let u=0;u<n.length;u++){const h=`${(c=n[u])==null?void 0:c.v}`;h&&(h===r[0]?u===0?s.push(0):(l++,s.push(l*r.length)):s.push(r.indexOf(h)+l*7))}if(o&&(n.reverse(),s.reverse()),Vt(s)){const u=s[1]-s[0];return Oe(To(n,t,u,r),o)}return at(n,t)}}};function Oe(i,t){return t?i.reverse():i}var wl=Object.defineProperty,El=Object.getOwnPropertyDescriptor,yl=(i,t,e,n)=>{for(var o=n>1?void 0:n?El(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&wl(t,e,o),o},Di=(i,t)=>(e,n)=>t(e,n,i);N.AutoFillService=class extends a.Disposable{constructor(e,n,o){super();I(this,"_rules",[]);I(this,"_hooks",[]);I(this,"_applyType$",new k.BehaviorSubject(oe.SERIES));I(this,"_isFillingStyle",!0);I(this,"_autoFillLocation$",new k.BehaviorSubject(null));I(this,"autoFillLocation$",this._autoFillLocation$.asObservable());I(this,"_showMenu$",new k.BehaviorSubject(!1));I(this,"showMenu$",this._showMenu$.asObservable());I(this,"_direction",a.Direction.DOWN);I(this,"applyType$",this._applyType$.asObservable());I(this,"_menu$",new k.BehaviorSubject([{label:"autoFill.copy",value:oe.COPY,disable:!1},{label:"autoFill.series",value:oe.SERIES,disable:!1},{label:"autoFill.formatOnly",value:oe.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:oe.NO_FORMAT,disable:!1}]));I(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=e,this._univerInstanceService=n,this._selectionManagerService=o,this._init()}_init(){this._rules=[Cl,Il,Rl,Ml,bl,Tl,er].sort((e,n)=>n.priority-e.priority),this._isFillingStyle=!0}getOneByPriority(e){return e.length<=0?[]:[e.reduce((o,r)=>(r.priority||0)>(o.priority||0)?r:o,e[0])]}addHook(e){if(this._hooks.find(n=>n.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=Tt.Append),this._hooks.push(e),a.toDisposable(()=>{const n=this._hooks.findIndex(o=>o===e);n>-1&&this._hooks.splice(n,1)})}registerRule(e){if(this._rules.find(o=>o.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const n=this._rules.findIndex(o=>o.priority<e.priority);this._rules.splice(n===-1?this._rules.length:n,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:n,unitId:o,subUnitId:r}=this.autoFillLocation||{};if(!e||!n||!o||!r)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:n,unitId:o,subUnitId:r},this._direction,this.applyType))}),l=s.filter(u=>u.type===Tt.Only);if(l.length>0)return this.getOneByPriority(l);const d=this.getOneByPriority(s.filter(u=>u.type===Tt.Default)),c=s.filter(u=>u.type===Tt.Append)||[];return[...d,...c]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,n){this._menu$.next(this._menu$.getValue().map(o=>o.value===e?{...o,disable:n}:o))}setShowMenu(e){this._showMenu$.next(e)}},N.AutoFillService=yl([a.OnLifecycle(a.LifecycleStages.Rendered,N.AutoFillService),Di(0,P.Inject(_.SheetInterceptorService)),Di(1,P.Inject(a.IUniverInstanceService)),Di(2,P.Inject(_.SelectionManagerService))],N.AutoFillService);const Jt=P.createIdentifier("univer.auto-fill-service");var Ol=Object.defineProperty,Nl=Object.getOwnPropertyDescriptor,xl=(i,t,e,n)=>{for(var o=n>1?void 0:n?Nl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ol(t,e,o),o},Ge=(i,t)=>(e,n)=>t(e,n,i);N.AutoFillController=class extends a.Disposable{constructor(e,n,o,r,s,l,d,c,u){super();I(this,"_beforeApplyData",[]);I(this,"_copyData",[]);I(this,"_defaultHook");this._univerInstanceService=e,this._selectionRenderService=n,this._commandService=o,this._undoRedoService=r,this._autoFillService=s,this._editorBridgeService=l,this._sheetInterceptorService=d,this._selectionManagerService=c,this._injector=u,this._defaultHook={id:"default",type:Tt.Default,priority:0,onBeforeFillData:(h,m)=>{this._presetAndCacheData(h,m)},onFillData:(h,m,f)=>this._fillData(h,m,f)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[wo,Cn].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initDefaultHook(){this._autoFillService.addHook(this._defaultHook)}_onSelectionControlFillChanged(){const e=new a.DisposableCollection,n=o=>{const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return;o.dispose(),this._selectionRenderService.getCurrentControls().forEach(l=>{o.add(a.toDisposable(l.selectionFilled$.subscribe(d=>{if(d==null||d.startColumn===-1||d.startRow===-1||d.endColumn===-1||d.endRow===-1)return;const c={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow},u={startColumn:d.startColumn,endColumn:d.endColumn,startRow:d.startRow,endRow:d.endRow};this._triggerAutoFill(c,u)}))),o.add(a.toDisposable(l.fillControl.onDblclickObserver.add(()=>{const d={startColumn:l.model.startColumn,endColumn:l.model.endColumn,startRow:l.model.startRow,endRow:l.model.endRow};this._handleDbClickFill(d)}))),o.add(a.toDisposable(l.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})})))})};n(e),this.disposeWithMe(this._commandService.onCommandExecuted(o=>{o.id===_.SetSelectionsOperation.id&&n(e)}))}_onApplyTypeChanged(){this.disposeWithMe(a.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(e,n){var f;if(e.startColumn===n.startColumn&&e.startRow===n.startRow&&e.endColumn===n.endColumn&&e.endRow===n.endRow)return;if(n.endColumn<e.endColumn&&n.endColumn>e.startColumn){this._commandService.executeCommand(Cn.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:e.endColumn},selectionRange:n});return}if(n.endRow<e.endRow&&n.endRow>e.startRow){this._commandService.executeCommand(Cn.id,{clearRange:{startRow:n.endRow+1,endRow:e.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const o={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<e.startRow)r=a.Direction.UP,o.endRow=e.startRow-1;else if(n.endRow>e.endRow)r=a.Direction.DOWN,o.startRow=e.endRow+1;else if(n.startColumn<e.startColumn)r=a.Direction.LEFT,o.endColumn=e.startColumn-1;else if(n.endColumn>e.endColumn)r=a.Direction.RIGHT,o.startColumn=e.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._autoFillService.direction=r;const c={get:this._injector.get.bind(this._injector)},u=vt(e,c),h=vt(o,c);if(!u||!h)return;this._autoFillService.autoFillLocation={source:u,target:h,unitId:l,subUnitId:d},this._autoFillService.getActiveHooks().forEach(g=>{var S;(S=g==null?void 0:g.onBeforeFillData)==null||S.call(g,{source:u,target:h,unitId:l,subUnitId:d},r)}),(f=this._autoFillService.menu.find(g=>g.value===oe.SERIES))!=null&&f.disable?this._autoFillService.applyType=oe.COPY:this._autoFillService.applyType=oe.SERIES}_handleDbClickFill(e){const n=this._detectFillRange(e);n.endRow<=e.endRow||this._triggerAutoFill(e,n)}_detectFillRange(e){var m,f,g,S,p,R;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,l=(m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet();if(!l)return e;const d=l.getCellMatrix(),c=l.getMaxRows()-1,u=l.getMaxColumns()-1;let h=o;if(r>0&&((f=d.getValue(n,r-1))==null?void 0:f.v)!=null){let M=n;for(;((g=d.getValue(M,r-1))==null?void 0:g.v)!=null&&M<c;)M+=1;h=M-1}else if(s<u&&((S=d.getValue(o,s+1))==null?void 0:S.v)!=null){let M=n;for(;((p=d.getValue(M,s+1))==null?void 0:p.v)!=null&&M<c;)M+=1;h=M-1}for(let M=o+1;M<=h;M++)for(let T=r;T<=s;T++)if(((R=d.getValue(M,T))==null?void 0:R.v)!=null){h=M-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFillData(){var f,g;const{source:e,target:n,unitId:o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId()}=this._autoFillService.autoFillLocation||{},s=this._autoFillService.direction;if(!e||!n)return;const l=a.Rectangle.union(lt(e),lt(n)),d=this._autoFillService.applyType,c=this._autoFillService.getActiveHooks();this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,{selections:[{primary:{...(g=(f=this._selectionManagerService.getLast())==null?void 0:f.primary)!=null?g:l},range:{...l,rangeType:a.RANGE_TYPE.NORMAL}}],unitId:o,subUnitId:r});const u=[],h=[];c.forEach(S=>{var M;const{undos:p,redos:R}=((M=S.onFillData)==null?void 0:M.call(S,{source:e,target:n,unitId:o,subUnitId:r},s,d))||{};p&&u.push(...p),R&&h.push(...R)}),h.every(S=>this._commandService.syncExecuteCommand(S.id,S.params))&&this._undoRedoService.pushUndoRedo({unitID:o,undoMutations:u,redoMutations:h}),c.forEach(S=>{var p;(p=S.onAfterFillData)==null||p.call(S,{source:e,target:n,unitId:o,subUnitId:r},s,d)}),this._autoFillService.setShowMenu(!0)}_getApplyData(e,n,o,r,s,l=!0){const d=[],c=Math.floor(o/n),u=o%n,h=this._autoFillService.getRules();if(!l&&s===oe.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(f=>{m[f.type]=[]}),h.forEach(f=>{const{type:g,applyFunctions:S={}}=f,p=e[g];p&&p.forEach(R=>{const M=Ws(R.index,u),T=R.index.length*c+M,b=this._applyFunctions(R,T,r,s,S,e),E=js(n,o,R.index);m[g].push({data:b,index:E})})});for(let f=0;f<o;f++)h.forEach(g=>{const{type:S}=g,p=m[S];for(let R=0;R<p.length;R++)f in p[R].index&&d.push(p[R].data[p[R].index[f]])});return d}_applyFunctions(e,n,o,r,s,l){const{data:d}=e,c=o===a.Direction.UP||o===a.Direction.LEFT;if(r===oe.COPY){const u=s==null?void 0:s[oe.COPY];return u?u(e,n,o,l):(c&&d.reverse(),at(d,n))}if(r===oe.SERIES){const u=s==null?void 0:s[oe.SERIES];return u?u(e,n,o,l):(c&&d.reverse(),s!=null&&s[oe.COPY]?s[oe.COPY](e,n,o,l):at(d,n))}if(r===oe.ONLY_FORMAT){const u=s==null?void 0:s[oe.ONLY_FORMAT];return u?u(e,n,o,l):zs(d,n)}}_getCopyData(e,n){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),r=this._autoFillService.getRules(),s=[],l=n===a.Direction.DOWN||n===a.Direction.UP;let d,c;return l?(d=e.cols,c=e.rows):(d=e.rows,c=e.cols),d.forEach(u=>{const h=this._getEmptyCopyDataPiece(),m={type:void 0,cellData:void 0};c.forEach(f=>{let g;l?g=o.getValue(f,u):g=o.getValue(u,f);const{type:S,isContinue:p}=r.find(R=>R.match(g))||er;if(p(m,g)){const R=h[S],M=R[R.length-1];M.data.push(g),M.index.push(f-c[0])}else{const R=h[S];R?R.push({data:[g],index:[f-c[0]]}):h[S]=[{data:[g],index:[f-c[0]]}]}m.type=S,m.cellData=g}),s.push(h)}),s}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(n=>{e[n.type]=[]}),e}_getMergeApplyData(e,n,o,r){const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),l=[];for(let d=e.startRow;d<=e.endRow;d++)for(let c=e.startColumn;c<=e.endColumn;c++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:f,endColumn:g}=w.getCellInfoInMergeData(d,c,s);if(u){if(o===a.Direction.DOWN){let S=h+r,p=f+r;for(;p<=n.endRow;)l.push({startRow:S,startColumn:m,endRow:p,endColumn:g}),S+=r,p+=r}else if(o===a.Direction.UP){let S=h-r,p=f-r;for(;S>=n.startRow;)l.push({startRow:S,startColumn:m,endRow:p,endColumn:g}),S-=r,p-=r}else if(o===a.Direction.RIGHT){let S=m+r,p=g+r;for(;p<=n.endColumn;)l.push({startRow:h,startColumn:S,endRow:f,endColumn:p}),S+=r,p+=r}else if(o===a.Direction.LEFT){let S=m-r,p=g-r;for(;S>=n.startColumn;)l.push({startRow:h,startColumn:S,endRow:f,endColumn:p}),S-=r,p-=r}}}return l}_presetAndCacheData(e,n){const{source:o,target:r}=e,s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),l=[];r.rows.forEach(d=>{const c=[];r.cols.forEach(u=>{c.push(a.Tools.deepClone(s.getValue(d,u)))}),l.push(c)}),this._beforeApplyData=l,this._copyData=this._getCopyData(o,n),this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(oe.SERIES,!1):this._autoFillService.setDisableApplyType(oe.SERIES,!0)}_fillData(e,n,o){var $,ee;const r=[],s=[];let l=!0;o===oe.NO_FORMAT&&(l=!1,o=oe.SERIES);const{source:d,target:c,unitId:u,subUnitId:h}=e;if(!d||!c||n==null)return{undos:r,redos:s};const m=lt(d),f=lt(c),{cols:g,rows:S}=c,{cols:p,rows:R}=d,M=this._copyData;let T;n===a.Direction.DOWN||n===a.Direction.UP?T=R.length:T=p.length;const b=[];if(n===a.Direction.DOWN||n===a.Direction.UP){const L=S.length,U=[];g.forEach((F,Y)=>{const G=M[Y],te=this._getApplyData(G,T,L,n,o,l);U.push(te)});for(let F=0;F<U[0].length;F++){const Y=[];for(let G=0;G<U.length;G++)Y.push({s:null,...U[G][F]});b.push(Y)}}else{const L=g.length;S.forEach((U,F)=>{const Y=M[F],G=this._getApplyData(Y,T,L,n,o,l),te=[];for(let ne=0;ne<G.length;ne++)te.push({s:null,...G[ne]});b.push(te)})}let E=[];const y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getStyles();l?(E=this._getMergeApplyData(m,f,n,T),b.forEach(L=>{L.forEach(U=>{U&&y&&y&&(U.s=y.getStyleByCell(U))})})):b.forEach((L,U)=>{L.forEach((F,Y)=>{F&&y&&(F.s=y.getStyleByCell(this._beforeApplyData[U][Y])||null)})}),o===oe.ONLY_FORMAT&&b.forEach((L,U)=>{L.forEach((F,Y)=>{if(F){const G=this._beforeApplyData[U][Y]||{};F.f=G.f,F.si=G.si,F.t=G.t,F.v=G.v}})});const O={get:this._injector.get.bind(this._injector)},x=[],D=(ee=($=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:$.getSheetBySheetId(h))==null?void 0:ee.getMergeData();D&&D.forEach(L=>{a.Rectangle.intersects(L,f)&&x.push(L)});const W={unitId:u,subUnitId:h,ranges:x},A=_.RemoveMergeUndoMutationFactory(O,W);s.push({id:_.RemoveWorksheetMergeMutation.id,params:W}),r.push({id:_.AddWorksheetMergeMutation.id,params:A});const H={subUnitId:h,unitId:u,cellValue:ma([c])},B=_.SetRangeValuesUndoMutationFactory(O,H),z=this._sheetInterceptorService.onCommandExecute({id:_.ClearSelectionContentCommand.id});s.push({id:_.SetRangeValuesMutation.id,params:H},...z.redos),r.push(...z.undos,{id:_.SetRangeValuesMutation.id,params:B});const X=new a.ObjectMatrix;S.forEach((L,U)=>{g.forEach((F,Y)=>{b[U][Y]&&X.setValue(L,F,b[U][Y])})});const Q={subUnitId:h,unitId:u,cellValue:X.getMatrix()},J=_.SetRangeValuesUndoMutationFactory(O,Q);if(r.push({id:_.SetRangeValuesMutation.id,params:J}),s.push({id:_.SetRangeValuesMutation.id,params:Q}),E!=null&&E.length){const L=_.getAddMergeMutationRangeByType(E),U={unitId:u,subUnitId:h,ranges:L},F=_.AddMergeUndoMutationFactory(O,U);r.push({id:_.RemoveWorksheetMergeMutation.id,params:F}),s.push({id:_.AddWorksheetMergeMutation.id,params:U})}return{undos:r,redos:s}}_hasSeries(e){return e.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![ce.OTHER,ce.FORMULA].includes(r))}))}},N.AutoFillController=xl([a.OnLifecycle(a.LifecycleStages.Steady,N.AutoFillController),Ge(0,a.IUniverInstanceService),Ge(1,Ie),Ge(2,a.ICommandService),Ge(3,a.IUndoRedoService),Ge(4,Jt),Ge(5,Ee),Ge(6,P.Inject(_.SheetInterceptorService)),Ge(7,P.Inject(_.SelectionManagerService)),Ge(8,P.Inject(P.Injector))],N.AutoFillController);var Al=Object.defineProperty,Dl=Object.getOwnPropertyDescriptor,Pl=(i,t,e,n)=>{for(var o=n>1?void 0:n?Dl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Al(t,e,o),o},Pi=(i,t)=>(e,n)=>t(e,n,i);N.CellCustomRenderController=class extends a.Disposable{constructor(e,n,o){super();I(this,"_enterActiveRender");this._sheetSkeletonManagerService=e,this._renderManagerService=n,this._univerInstanceService=o,this._initEventBinding()}_initEventBinding(){const e=new a.DisposableCollection;this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{if(e.dispose(),n){const o=n.getUnitId(),r=this._renderManagerService.getRenderById(n.getUnitId());if(r&&r.mainComponent){const s=r.mainComponent,l=u=>{var Q;const h=(Q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Q.skeleton,{offsetX:m,offsetY:f}=u,g=r.scene,S=n.getActiveSheet(),p=g.getActiveViewportByCoord(w.Vector2.FromArray([m,f]));if(!p)return;const{scaleX:R,scaleY:M}=g.getAncestorScale(),T={x:p.actualScrollX,y:p.actualScrollY},b=h.getCellPositionByOffset(m,f,R,M,T),E=h.mergeData.find(J=>{const{startColumn:$,startRow:ee,endColumn:L,endRow:U}=J;return b.row>=ee&&b.column>=$&&b.row<=U&&b.column<=L}),y={actualRow:E?E.startRow:b.row,actualCol:E?E.startColumn:b.column,mergeCell:E,row:b.row,col:b.column};if(!y||!h)return;const O=S.getCell(y.actualRow,y.actualCol);if(!O)return;const x=O.customRender;if(!(x!=null&&x.length))return;const D=y.actualRow,W=y.actualCol,A=x.sort(a.sortRules),H=n.getActiveSheet().getSheetId(),B={data:O,style:h.getsStyles().getStyleByCell(O),primaryWithCoord:h.getCellByIndex(y.actualRow,y.actualCol),unitId:o,subUnitId:H,row:D,col:W},z={x:T.x+m/R,y:T.y+f/M},X=A.find(J=>{var $;return($=J.isHit)==null?void 0:$.call(J,z,B)});if(X)return[X,B]},d=s.onPointerDownObserver.add(u=>{var m;const h=l(u);if(h){const[f,g]=h;(m=f.onPointerDown)==null||m.call(f,g,u)}}),c=s.onPointerMoveObserver.add(u=>{var m,f,g,S;const h=l(u);if(h){const[p,R]=h;this._enterActiveRender?this._enterActiveRender.render!==p&&((f=(m=this._enterActiveRender.render).onPointerLeave)==null||f.call(m,this._enterActiveRender.cellContext,u),this._enterActiveRender={render:p,cellContext:R},(g=p.onPointerEnter)==null||g.call(p,R,u)):(this._enterActiveRender={render:p,cellContext:R},(S=p.onPointerEnter)==null||S.call(p,R,u))}});d&&e.add(d),c&&e.add(c)}}}),this.disposeWithMe(e)}},N.CellCustomRenderController=Pl([a.OnLifecycle(a.LifecycleStages.Rendered,N.CellCustomRenderController),Pi(0,P.Inject(N.SheetSkeletonManagerService)),Pi(1,w.IRenderManagerService),Pi(2,a.IUniverInstanceService)],N.CellCustomRenderController);const tr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async i=>{var d;const e=(d=i.get(_.SelectionManagerService).getSelections())==null?void 0:d.map(c=>c.range);if(!(e!=null&&e.length))return!1;const n=i.get(a.ICommandService),o=i.get(a.IUniverInstanceService),r=_.getSheetCommandTarget(o);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleRows();if(Zo(l,e)){const c=i.get(C.IConfirmService),u=i.get(a.LocaleService);return await c.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await n.executeCommand(_.SetRowHiddenCommand.id),!0}},nr={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async i=>{var d;const e=(d=i.get(_.SelectionManagerService).getSelections())==null?void 0:d.map(c=>c.range);if(!(e!=null&&e.length))return!1;const n=i.get(a.ICommandService),o=i.get(a.IUniverInstanceService),r=_.getSheetCommandTarget(o);if(!r)return!1;const{worksheet:s}=r,l=s.getVisibleCols();if(Ko(l,e)){const c=i.get(C.IConfirmService),u=i.get(a.LocaleService);return await c.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await n.executeCommand(_.SetColHiddenCommand.id),!0}},Hi={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(q.SetInlineFormatBoldCommand.id):t.executeCommand(_.SetBoldCommand.id)}},Li={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(q.SetInlineFormatItalicCommand.id):t.executeCommand(_.SetItalicCommand.id)}},Ui={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(q.SetInlineFormatUnderlineCommand.id):t.executeCommand(_.SetUnderlineCommand.id)}},Vi={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(q.SetInlineFormatStrikethroughCommand.id):t.executeCommand(_.SetStrikeThroughCommand.id)}},Hl={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(q.SetInlineFormatSubscriptCommand.id):!1}},Ll={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const t=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?t.executeCommand(q.SetInlineFormatSuperscriptCommand.id):!1}},ir={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,t)=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatFontSizeCommand.id,t):e.executeCommand(_.SetFontSizeCommand.id,t)}},or={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,t)=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatFontFamilyCommand.id,t):e.executeCommand(_.SetFontFamilyCommand.id,t)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,t)=>{const e=i.get(a.ICommandService);return i.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatTextColorCommand.id,t):e.executeCommand(_.SetTextColorCommand.id,t)}};function rr(i,t){return t.some(e=>Ul(i,e))}function Ul(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o);let l=!1;return s.forValue((d,c,u)=>{if(u&&(d!==e||c!==n)&&i.cellHasValue(u))return l=!0,!1}),l}function sr(i,t,e,n){const o=[],r=[],s=e.getSheetId();return n.forEach(l=>{const d=Vl(e,l),c={unitId:t,subUnitId:s,cellValue:d.getData()},u=_.SetRangeValuesUndoMutationFactory(i,c);o.push({id:_.SetRangeValuesMutation.id,params:u}),r.push({id:_.SetRangeValuesMutation.id,params:c})}),{undos:o,redos:r}}function Vl(i,t){const{startRow:e,startColumn:n,endColumn:o,endRow:r}=t,s=i.getMatrixWithMergedCells(e,n,r,o),l=new a.ObjectMatrix;return s.forValue((d,c,u)=>{u&&(d!==e||c!==n)&&l.setValue(d,c,null)}),l}function Bl(i,t,e,n){const o=e.getActiveViewportByCoord(w.Vector2.FromArray([i,t]));if(!o)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),l={x:o.actualScrollX,y:o.actualScrollY},d=n.getCellPositionByOffset(i,t,r,s,l),c=n.mergeData.find(h=>{const{startColumn:m,startRow:f,endColumn:g,endRow:S}=h;return d.row>=f&&d.column>=m&&d.row<=S&&d.column<=g});return{actualRow:c?c.startRow:d.row,actualCol:c?c.startColumn:d.column,mergeCell:c,row:d.row,col:d.column}}function kl(i,t,e,n){const o=n.getFreeze();if(!o||o.startRow<=0&&o.startColumn<=0||i>o.startRow&&t>o.startColumn)return e.getViewport(j.VIEW_MAIN);if(i<=o.startRow&&t<=o.startColumn)return e.getViewport(j.VIEW_MAIN_LEFT_TOP);if(i<=o.startRow&&t>o.startColumn)return e.getViewport(j.VIEW_MAIN_TOP);if(i>o.startRow&&t<=o.startColumn)return e.getViewport(j.VIEW_MAIN_LEFT)}function Fl(i,t,e,n){const o=ar(i.left,i.top,t,e,n),r=ar(i.right,i.bottom,t,e,n);return{left:o.x,top:o.y,right:r.x,bottom:r.y}}function ar(i,t,e,n,o){const{scaleX:r,scaleY:s}=e.getAncestorScale(),l=e.getViewport(j.VIEW_MAIN);if(!l)return{x:i,y:t};const d=o.getFreeze(),{startColumn:c,startRow:u,xSplit:h,ySplit:m}=d,f=n.getNoMergeCellPositionByIndexWithNoHeader(u-m,c-h),g=n.getNoMergeCellPositionByIndexWithNoHeader(u,c),{rowHeaderWidth:S,columnHeaderHeight:p}=n,R=g.startX-f.startX,M=g.startY-f.startY,{top:T,left:b,actualScrollX:E,actualScrollY:y}=l;let O;i>b?O=(i-E)*r:O=(R+S-(b-i))*r;let x;return t>T?x=(t-y)*s:x=(M+p-(T-t))*r,{x:O,y:x}}var Wl=Object.defineProperty,jl=Object.getOwnPropertyDescriptor,zl=(i,t,e,n)=>{for(var o=n>1?void 0:n?jl(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Wl(t,e,o),o},Bi=(i,t)=>(e,n)=>t(e,n,i),Ue=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(Ue||{});const wt=P.createIdentifier("univer.format-painter-service");let ki=class extends a.Disposable{constructor(t,e,n){super();I(this,"status$");I(this,"_selectionFormat");I(this,"_markId",null);I(this,"_status$");this._selectionManagerService=t,this._univerInstanceService=e,this._markSelectionService=n,this._status$=new k.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}setStatus(t){t!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(t),this._status$.next(t)}getStatus(){return this._status$.getValue()}_updateRangeMark(t){if(this._markSelectionService.removeAllShapes(),this._markId=null,t!==0){const e=this._selectionManagerService.getLast();if(e){const n=this._selectionManagerService.createCopyPasteSelection();t===2?this._markId=this._markSelectionService.addShape({...e,style:n}):this._markId=this._markSelectionService.addShape({...e,style:n},[_.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const t=this._selectionManagerService.getLast(),e=t==null?void 0:t.range;if(!e)return;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=e,l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=(l==null?void 0:l.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),h=l.getStyles(),m=new a.ObjectMatrix;this._selectionFormat.merges=[];for(let f=n;f<=o;f++)for(let g=r;g<=s;g++){const S=c.getValue(f,g);m.setValue(f,g,h.getStyleByCell(S)||{});const{isMergedMainCell:p,...R}=w.getCellInfoInMergeData(f,g,u);p&&this._selectionFormat.merges.push({startRow:R.startRow,startColumn:R.startColumn,endRow:R.endRow,endColumn:R.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};ki=zl([Bi(0,P.Inject(_.SelectionManagerService)),Bi(1,a.IUniverInstanceService),Bi(2,Wt)],ki);const Fi={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(i,t)=>t?(i.get(wt).setStatus(t.status),!0):!1},lr={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const e=i.get(wt).getStatus();let n;return e!==Ue.OFF?n=Ue.OFF:n=Ue.INFINITE,i.get(a.ICommandService).executeCommand(Fi.id,{status:n})}},Wi={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const e=i.get(wt).getStatus();let n;return e!==Ue.OFF?n=Ue.OFF:n=Ue.ONCE,i.get(a.ICommandService).executeCommand(Fi.id,{status:n})}},cr={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,t)=>{const e=i.get(a.ICommandService),n=i.get(a.IUndoRedoService),o=i.get(a.IUniverInstanceService),r=i.get(_.SelectionManagerService),s=i.get(_.SheetInterceptorService),l=_.getSheetCommandTarget(o,t);if(!l)return!1;const{worksheet:d,unitId:c,subUnitId:u}=l,h=i.get(_.SheetPermissionService),{styleValues:m,styleRange:f,mergeRanges:g}=t;if(!h.getSheetEditable(c,u))return!1;const S=f?[f]:r.getSelectionRanges();if(!S||!S.length)return!1;const p=new a.ObjectMatrix;let R;if(a.Tools.isArray(m))for(let Q=0;Q<S.length;Q++){const{startRow:J,startColumn:$,endRow:ee,endColumn:L}=S[Q];for(let U=0;U<=ee-J;U++)for(let F=0;F<=L-$;F++)p.setValue(U+J,F+$,m[U][F])}else if(a.isICellData(m))for(let Q=0;Q<S.length;Q++){const{startRow:J,startColumn:$}=S[Q];p.setValue(J,$,m)}else R=m;const M={subUnitId:u,unitId:c,cellValue:R!=null?R:p.getMatrix()},T=_.SetRangeValuesUndoMutationFactory(i,M),b=e.syncExecuteCommand(_.SetRangeValuesMutation.id,M),{undos:E,redos:y}=s.onCommandExecute({id:_.SetRangeValuesCommand.id,params:{...M,range:S}}),O=_.getAddMergeMutationRangeByType(g),x=[],D=[],W=rr(d,O),A={unitId:c,subUnitId:u,ranges:O},H={unitId:c,subUnitId:u,ranges:O};x.push({id:_.RemoveWorksheetMergeMutation.id,params:A}),x.push({id:_.AddWorksheetMergeMutation.id,params:H});const B=_.RemoveMergeUndoMutationFactory(i,A),z=_.AddMergeUndoMutationFactory(i,H);if(D.push({id:_.RemoveWorksheetMergeMutation.id,params:z}),D.push({id:_.AddWorksheetMergeMutation.id,params:B}),W){const Q=sr(i,c,d,O);x.unshift(...Q.redos),D.push(...Q.undos)}const X=await a.sequenceExecute([...y,...x],e);return b&&X.result?(n.pushUndoRedo({unitID:c,undoMutations:[{id:_.SetRangeValuesMutation.id,params:T},...E,...D],redoMutations:[{id:_.SetRangeValuesMutation.id,params:M},...y,...x]}),!0):!1}},wn={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,t)=>{const{type:e}=t||{},n=i.get(a.IUniverInstanceService),o=i.get(a.IUndoRedoService),r=_.getSheetCommandTarget(n);if(!r)return!1;const{unitId:s,subUnitId:l}=r,d=i.get(a.ICommandService),u=i.get(_.SelectionManagerService).getSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:m}=h,f=i.get($e),{sheetViewStartRow:g=0,sheetViewStartColumn:S=0}=f.getCurrentScroll()||{};let p,R,M,T;const{startRow:b,startColumn:E,rangeType:y}=m;if(y===a.RANGE_TYPE.ROW||e===1)p=b,M=b-g,R=-1,T=0;else if(y===a.RANGE_TYPE.COLUMN||e===2)p=-1,M=0,R=E,T=E-S;else if(y===a.RANGE_TYPE.NORMAL)p=b,M=b-g,R=E,T=E-S;else return!1;const O={unitId:s,subUnitId:l,startRow:p,startColumn:R,xSplit:R>0?Math.max(1,T):T,ySplit:p>0?Math.max(1,M):M},x=_.SetFrozenMutationFactory(i,O);return d.syncExecuteCommand(_.SetFrozenMutation.id,O)&&o.pushUndoRedo({unitID:s,undoMutations:[{id:_.SetFrozenMutation.id,params:x}],redoMutations:[{id:_.SetFrozenMutation.id,params:O}]}),!0}},dr={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(a.ICommandService).executeCommand(wn.id,{type:1}),!0)},ur={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(a.ICommandService).executeCommand(wn.id,{type:2}),!0)},hr={type:a.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(a.IUndoRedoService),o=_.getSheetCommandTarget(e);if(!o)return!1;const{unitId:r,subUnitId:s}=o,l={unitId:r,subUnitId:s,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},d=_.SetFrozenMutationFactory(i,l);return t.syncExecuteCommand(_.SetFrozenMutation.id,l)&&n.pushUndoRedo({unitID:r,undoMutations:[{id:_.SetFrozenMutation.id,params:d}],redoMutations:[{id:_.SetFrozenMutation.id,params:l}]}),!0}},Et="UI_PLUGIN_SHEETS",En=`${Et}_COLOR_PICKER_COMPONENT`,mr=`${Et}_FONT_FAMILY_COMPONENT`,fr=`${Et}_FONT_FAMILY_ITEM_COMPONENT`,gr=`${Et}_FONT_SIZE_COMPONENT`,ji=`${Et}_MENU_ITEM_INPUT_COMPONENT`;var Sr={exports:{}},yn={};/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.min.js
|
|
10
10
|
*
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
*
|
|
13
13
|
* This source code is licensed under the MIT license found in the
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/var Yl=V,Xl=Symbol.for("react.element"),$l=Symbol.for("react.fragment"),Gl=Object.prototype.hasOwnProperty,Zl=Yl.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Kl={key:!0,ref:!0,__self:!0,__source:!0};function pr(i,t,e){var n,o={},r=null,s=null;e!==void 0&&(r=""+e),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)Gl.call(t,n)&&!Kl.hasOwnProperty(n)&&(o[n]=t[n]);if(i&&i.defaultProps)for(n in t=i.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:Xl,type:i,key:r,ref:s,props:o,_owner:Zl.current}}yn.Fragment=$l,yn.jsx=pr,yn.jsxs=pr,_r.exports=yn;var v=_r.exports;const zi={sheetsUiContextMenuInput:"univer-sheets-ui-context-menu-input",sheetsUiContextMenuInputContainer:"univer-sheets-ui-context-menu-input-container",sheetsUiContextMenuInputNumber:"univer-sheets-ui-context-menu-input-number"},Ql=i=>{const{prefix:t,suffix:e,value:n,onChange:o,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=i,l=G.useDependency(a.LocaleService),[d,c]=V.useState(),u=m=>{var f;c(m==null?void 0:m.toString()),o((f=m==null?void 0:m.toString())!=null?f:"")};V.useEffect(()=>{c(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return v.jsxs("div",{className:zi.sheetsUiContextMenuInput,children:[l.t(t),v.jsx("span",{className:zi.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:v.jsx(re.InputNumber,{className:zi.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:h,onChange:u,min:r,max:s})}),l.t(e)]})};var le=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(le||{});function Jl(i){const t=i.get(Et);return{id:Wi.id,subId:cr.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[C.MenuPosition.TOOLBAR_START],activated$:new k.Observable(e=>{let n=!1;const o=t.status$.subscribe(r=>{n=r!==Ue.OFF,e.next(n)});return e.next(n),()=>{o.unsubscribe()}}),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}function ql(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(a.IContextService),o=i.get(_.SelectionManagerService);return{id:Hi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=o.getLast())==null?void 0:f.primary;let p=a.FontWeight.NORMAL;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getFontWeight()}s.next(p===a.FontWeight.BOLD)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&n.getContextValue(a.EDITOR_ACTIVATED)&&n.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.bl;s.next(p===a.BooleanNumber.TRUE)}}),d=(u=o.getLast())==null?void 0:u.primary;if(!r){s.next(!1);return}let c=a.FontWeight.NORMAL;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getFontWeight()}return s.next(c===a.FontWeight.BOLD),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function ec(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService);return{id:Li.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=n.getLast())==null?void 0:f.primary;let p=a.FontItalic.NORMAL;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getFontStyle()}s.next(p===a.FontItalic.ITALIC)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.it;s.next(p===a.BooleanNumber.TRUE)}}),d=(u=n.getLast())==null?void 0:u.primary;let c=a.FontItalic.NORMAL;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getFontStyle()}return s.next(c===a.FontItalic.ITALIC),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function tc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService);return{id:Ui.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=n.getLast())==null?void 0:f.primary;let p;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getUnderline()}s.next(!!(p&&p.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.ul;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),d=(u=n.getLast())==null?void 0:u.primary;let c;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getUnderline()}return s.next(!!(c&&c.s)),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function nc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService);return{id:Vi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=n.getLast())==null?void 0:f.primary;let p;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getStrikeThrough()}s.next(!!(p&&p.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.st;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),d=(u=n.getLast())==null?void 0:u.primary;let c;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getStrikeThrough()}return s.next(!!(c&&c.s)),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function ic(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=C.FONT_FAMILY_LIST[0].value;return{id:rr.id,tooltip:"toolbar.font",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,label:fr,positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_FAMILY_LIST.map(r=>({label:{name:gr,hoverable:!0},value:r.value})),disabled$:_.getCurrentSheetDisabled$(i),value$:_e(e,o,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var S;const m=h.id;if(m!==_.SetRangeValuesMutation.id&&m!==_.SetSelectionsOperation.id&&m!==_.SetWorksheetActiveOperation.id)return;const f=(S=n.getLast())==null?void 0:S.primary;let g;if(f!=null){const p=r.getRange(f.startRow,f.startColumn);g=p==null?void 0:p.getFontFamily()}s.next(g!=null?g:o)}),d=(u=n.getLast())==null?void 0:u.primary;let c;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getFontFamily()}return s.next(c!=null?c:o),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function oc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService),r=_.getCurrentSheetDisabled$(i),s=11;return{id:or.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Sr,props:{min:1,max:400,disabled$:r}},positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_SIZE_LIST,disabled$:r,value$:_e(e,s,({worksheet:l})=>new k.Observable(d=>{var m;const c=t.onCommandExecuted(f=>{var S,p;const g=f.id;if(g===_.SetRangeValuesMutation.id||g===_.SetSelectionsOperation.id||g===_.SetWorksheetActiveOperation.id){const R=(S=n.getLast())==null?void 0:S.primary;let M;if(R!=null){const E=l.getRange(R.startRow,R.startColumn);M=E==null?void 0:E.getFontSize()}d.next(M!=null?M:s)}if((g===te.SetTextSelectionsOperation.id||g===te.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const R=en(i);if(R==null)return;const M=(p=R.ts)==null?void 0:p.fs;d.next(M!=null?M:s)}}),u=(m=n.getLast())==null?void 0:m.primary;let h;if(u!=null){const f=l.getRange(u.startRow,u.startColumn);h=f==null?void 0:f.getFontSize()}return d.next(h!=null?h:s),c.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function rc(i){return{id:_.ResetTextColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:Tn.id,disabled$:_.getCurrentSheetDisabled$(i)}}function sc(i){const t=i.get(a.ICommandService),e=i.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:[{label:{name:wn,hoverable:!1}}],value$:new k.Observable(n=>{const o=e.getCurrentTheme().textColor,r=t.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;n.next(l!=null?l:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}function ac(i){return{id:_.ResetBackgroundColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:_.SetBackgroundColorCommand.id,disabled$:_.getCurrentSheetDisabled$(i)}}function lc(i){const t=i.get(a.ICommandService),e=i.get(a.ThemeService);return{id:_.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:wn,hoverable:!1}}],value$:new k.Observable(n=>{const o=e.getCurrentTheme().primaryColor,r=t.onCommandExecuted(s=>{if(s.id===_.SetBackgroundColorCommand.id){const l=s.params.value;n.next(l!=null?l:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const vr=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function cc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService);return{id:_.SetHorizontalTextAlignCommand.id,icon:vr[0].icon,positions:[C.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:vr,value$:_e(t,a.HorizontalAlign.LEFT,({worksheet:n})=>new k.Observable(o=>{var d;const r=i.get(a.ICommandService).onCommandExecuted(c=>{var f;const u=c.id;if(u!==_.SetHorizontalTextAlignCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(f=e.getLast())==null?void 0:f.primary;let m;if(h!=null){const g=n.getRange(h.startRow,h.startColumn);m=g==null?void 0:g.getHorizontalAlignment()}o.next(m!=null?m:a.HorizontalAlign.LEFT)}),s=(d=e.getLast())==null?void 0:d.primary;let l;if(s!=null){const c=n.getRange(s.startRow,s.startColumn);l=c==null?void 0:c.getHorizontalAlignment()}return o.next(l!=null?l:a.HorizontalAlign.LEFT),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const Cr=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function dc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService);return{id:_.SetVerticalTextAlignCommand.id,icon:Cr[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:Cr,value$:_e(t,a.VerticalAlign.TOP,({worksheet:n})=>new k.Observable(o=>{var d;const r=i.get(a.ICommandService).onCommandExecuted(c=>{var f;const u=c.id;if(u!==_.SetVerticalTextAlignCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(f=e.getLast())==null?void 0:f.primary;let m;if(h!=null){const g=n.getRange(h.startRow,h.startColumn);m=g==null?void 0:g.getVerticalAlignment()}o.next(m!=null?m:a.VerticalAlign.TOP)}),s=(d=e.getLast())==null?void 0:d.primary;let l;if(s!=null){const c=n.getRange(s.startRow,s.startColumn);l=c==null?void 0:c.getVerticalAlignment()}return o.next(l!=null?l:a.VerticalAlign.TOP),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const Ir=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function uc(i){const t=i.get(_.SelectionManagerService),e=i.get(a.IUniverInstanceService);return{id:_.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Ir[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:Ir,value$:_e(e,a.WrapStrategy.OVERFLOW,({worksheet:n})=>new k.Observable(o=>{var d;const r=i.get(a.ICommandService).onCommandExecuted(c=>{var f;const u=c.id;if(u!==_.SetTextWrapCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(f=t.getLast())==null?void 0:f.primary;let m;if(h!=null){const g=n.getRange(h.startRow,h.startColumn);m=g==null?void 0:g.getWrapStrategy()}o.next(m!=null?m:a.WrapStrategy.OVERFLOW)}),s=(d=t.getLast())==null?void 0:d.primary;let l;if(s!=null){const c=n.getRange(s.startRow,s.startColumn);l=c==null?void 0:c.getWrapStrategy()}return o.next(l!=null?l:a.WrapStrategy.OVERFLOW),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const Rr=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function hc(i){const t=i.get(_.SelectionManagerService),e=i.get(a.IUniverInstanceService);return{id:_.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Rr[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:Rr,positions:[C.MenuPosition.TOOLBAR_START],value$:_e(e,0,({worksheet:n})=>new k.Observable(o=>{var d,c;const r=i.get(a.ICommandService).onCommandExecuted(u=>{var g,S;const h=u.id;if(h!==_.SetTextRotationCommand.id&&h!==_.SetSelectionsOperation.id&&h!==_.SetWorksheetActiveOperation.id)return;const m=(g=t.getLast())==null?void 0:g.primary;let f;if(m!=null){const p=n.getRange(m.startRow,m.startColumn);f=p==null?void 0:p.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((S=f&&f.a)!=null?S:0)}),s=(d=t.getLast())==null?void 0:d.primary;let l;if(s!=null){const u=n.getRange(s.startRow,s.startColumn);l=u==null?void 0:u.getTextRotation()}return(l==null?void 0:l.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((c=l&&l.a)!=null?c:0),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}function yt(i){return new k.Observable(t=>t.next(!i.get(C.IClipboardInterfaceService).supportClipboard))}function mc(){return{id:C.CopyCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function fc(i){return{id:C.PasteCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:yt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const Ot="sheet.menu.paste-special";function gc(i){return{id:Ot,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",disabled$:yt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Sc(i){return{id:jo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[Ot],disabled$:yt(i)}}function _c(i){return{id:zo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[Ot],disabled$:yt(i)}}function pc(i){return{id:Yo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[Ot],disabled$:yt(i)}}function vc(i){return{id:Xo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[Ot],disabled$:yt(i)}}function Cc(){return{id:_.SetWorksheetRowIsAutoHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const qt="sheet.menu.sheet-frozen";function Ic(){return{id:qt,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[C.MenuPosition.CONTEXT_MENU]}}const Yi="sheet.header-menu.sheet-frozen";function Rc(){return{id:Yi,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function Mc(){return{id:En.id,type:C.MenuItemType.BUTTON,positions:[qt,Yi],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function bc(){return{id:ur.id,type:C.MenuItemType.BUTTON,positions:[qt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function Tc(){return{id:hr.id,type:C.MenuItemType.BUTTON,positions:[qt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function Ec(){return{id:mr.id,type:C.MenuItemType.BUTTON,positions:[qt,Yi],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function wc(){return{id:nr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function yc(){return{id:ir.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function Oc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService),n=i.get(a.ICommandService),o=[_.SetSelectionsOperation,_.SetRowHiddenMutation,_.SetRowVisibleMutation].map(r=>r.id);return{id:_.SetSelectedRowsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:_e(t,!0,({worksheet:r})=>new k.Observable(s=>{function l(){var u;const c=(u=e.getSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(c!=null&&c.some(h=>{for(let m=h.startRow;m<=h.endRow;m++)if(!r.getRowRawVisible(m))return!0;return!1}))}const d=n.onCommandExecuted(c=>{o.findIndex(u=>u===c.id)!==-1&&s.next(!l())});return s.next(!l()),()=>d.dispose()}))}}function Nc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService),n=i.get(a.ICommandService),o=[_.SetSelectionsOperation,_.SetColHiddenMutation,_.SetColVisibleMutation].map(r=>r.id);return{id:_.SetSelectedColsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:_e(t,!0,({worksheet:r})=>new k.Observable(s=>{function l(){var u;const c=(u=e.getSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!c||c.length===0?!1:!!c.some(h=>{for(let m=h.startColumn;m<=h.endColumn;m++)if(!r.getColVisible(m))return!0;return!1})}const d=n.onCommandExecuted(c=>{o.findIndex(u=>u===c.id)!==-1&&s.next(!l())});return s.next(!l()),()=>d.dispose()}))}}function xc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService);return{id:_.SetRowHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:ji,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:_e(e,0,({worksheet:o})=>new k.Observable(r=>{function s(){var u;const d=(u=n.getLast())==null?void 0:u.primary,c=d?o.getRowHeight(d.startRow):0;r.next(c)}const l=t.onCommandExecuted(d=>{const c=d.id;if(c===_.SetRangeValuesMutation.id||c===_.SetSelectionsOperation.id)return s()});return s(),l.dispose}))}}function Ac(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService);return{id:_.SetColWidthCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:ji,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:_e(e,0,({worksheet:o})=>new k.Observable(r=>{function s(){var u;const d=(u=n.getLast())==null?void 0:u.primary;let c=0;d!=null&&(c=o.getColumnWidth(d.startColumn)),r.next(c)}const l=t.onCommandExecuted(d=>{const c=d.id;if(c===_.SetRangeValuesMutation.id||c===_.SetSelectionsOperation.id)return s()});return s(),l.dispose}))}}function en(i){var d;const t=i.get(a.IUniverInstanceService),e=i.get(te.TextSelectionManagerService),n=t.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),o=e.getActiveRange();if(n==null||o==null)return null;const r=(d=n.getBody())==null?void 0:d.textRuns;if(r==null)return;const{startOffset:s}=o;return r.find(({st:c,ed:u})=>s>=c&&s<=u)}const Dc={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormatting:"Conditional formatting",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging",waring:"Waring",dismantleMergeCellWaring:"This will cause some merged cells to be split. Do you want to continue?"}},filter:{confirm:{error:"There was a problem",notAllowedToInsertRange:"Not allowed to move cells here until filter is cleared"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor",deleteAllRowsAlert:"You can't delete all the rows on the sheet",deleteAllColumnsAlert:"You can't delete all the columns on the sheet",hideAllRowsAlert:"You can't hide all the rows on the sheet",hideAllColumnsAlert:"You can't hide all the columns on the sheet"},info:{tooltip:"Tooltip",error:"Error",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total}, ${totalPage} page, current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total}, ${totalPage} page, All data displayed",problem:"There was a problem",forceStringInfo:"Number stored as text"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells",overlappingMergedCells:"The paste area overlaps with merged cells"},shortCutNotify:{title:"Kindly paste using keyboard shortcuts.",useShortCutInstead:"Detected Excel content. Use keyboard shortcut to paste."}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit",definedName:{managerTitle:"Manager named",managerDescription:"Create a defined name by selecting cells or formulas, and entering the desired name into the text box.",addButton:"Add a defined name",featureTitle:"Defined names",ratioRange:"Range",ratioFormula:"Formula",confirm:"Confirm",cancel:"Cancel",scopeWorkbook:"Workbook",inputNamePlaceholder:"Please enter a name(No space allowed)",inputCommentPlaceholder:"Please enter a comment",inputRangePlaceholder:"Please input range(No space allowed)",inputFormulaPlaceholder:"Please input a formula(No space allowed)",nameEmpty:"Name cannot be empty",nameDuplicate:"Name already exists",formulaOrRefStringEmpty:"Formula or reference string cannot be empty",formulaOrRefStringInvalid:"Invalid formula or reference string",defaultName:"DefinedName",updateButton:"Update",deleteButton:"Delete",deleteConfirmText:"Are you sure you want to delete this defined name?",nameConflict:"The name conflicts with the function name",nameInvalid:"The name is invalid",nameSheetConflict:"The name conflicts with the sheet name"}},Mr={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalFormatting:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并",waring:"警告",dismantleMergeCellWaring:"此操作会导致一些合并单元格被拆散,是否继续?"}},filter:{confirm:{error:"出现了一个问题",notAllowedToInsertRange:"要移动这些单元格,请清除该区域的筛选器"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
|
|
16
|
-
[ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑",deleteAllRowsAlert:"您无法删除工作表上的所有行",deleteAllColumnsAlert:"您无法删除工作表上的所有列",hideAllRowsAlert:"您无法隐藏工作表上的所有行",hideAllColumnsAlert:"您无法隐藏工作表上的所有列"},info:{tooltip:"提示",error:"错误",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据",problem:"出现了一个问题",forceStringInfo:"以文本形式存储的数字"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数",overlappingMergedCells:"粘贴区域与合并单元格重叠"},shortCutNotify:{title:"请使用快捷键粘贴",useShortCutInstead:"检测到 Excel 内容,请使用快捷键粘贴"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格",definedName:{managerTitle:"名称管理器",managerDescription:"通过选择单元格或公式,并在文本框中输入您想要的名称来创建一个定义名称。",addButton:"新建名称",featureTitle:"定义名称",ratioRange:"范围",ratioFormula:"公式",confirm:"确认",cancel:"取消",scopeWorkbook:"工作簿",inputNamePlaceholder:"请输入名称(必填)",inputCommentPlaceholder:"请输入备注",inputRangePlaceholder:"请输入范围(必填)",inputFormulaPlaceholder:"请输入公式(必填)",nameEmpty:"名称不能为空",nameDuplicate:"名称重复",formulaOrRefStringEmpty:"公式或引用字符串不能为空",formulaOrRefStringInvalid:"公式或引用字符串无效",defaultName:"DefinedName",updateButton:"修改",deleteButton:"删除",deleteConfirmText:"确定删除定义名称?",nameConflict:"与函数名称冲突",nameInvalid:"名称不包含空格或不允许的字符",nameSheetConflict:"名称与工作表名称冲突"}};class br{constructor(){I(this,"_state",null);I(this,"_rect",null);I(this,"_state$",new k.BehaviorSubject(null));I(this,"state$",this._state$.asObservable());I(this,"_rect$",new k.BehaviorSubject(null));I(this,"rect$",this._rect$.asObservable());I(this,"_focus",!1);I(this,"_focus$",new k.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(t){this._state=t,this._refresh(t)}getRect(){return this._rect}setRect(t){this._rect=t,this._rect$.next(t)}getState(){return this._state}setFocus(t=!1){this._focus=t,this._focus$.next(t)}_refresh(t){this._state$.next(t)}}const tn=P.createIdentifier("univer.sheet-cell-editor-manager.service");class Pc{constructor(){I(this,"_position",null);I(this,"_position$",new k.BehaviorSubject(null));I(this,"position$",this._position$.asObservable());I(this,"_focus",!1);I(this,"_focus$",new k.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable());I(this,"_fxBtnClick$",new k.Subject);I(this,"fxBtnClick$",this._fxBtnClick$.asObservable());I(this,"_foldBtnStatus$",new k.Subject);I(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}setFocus(t=!1){this._focus=t,this._focus$.next(t)}handleFxBtnClick(t){this._fxBtnClick$.next(t)}handleFoldBtnClick(t){this._foldBtnStatus$.next(t)}_refresh(t){this._position$.next(t)}}const On=P.createIdentifier("univer.sheet-formula-editor-manager.service");var Hc=Object.defineProperty,Lc=Object.getOwnPropertyDescriptor,Uc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Lc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Hc(t,e,o),o},Tr=(i,t)=>(e,n)=>t(e,n,i);let Nn=class extends a.Disposable{constructor(t,e){super();I(this,"_previousSheetIndex",-1);this._commandService=t,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===_.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,o)=>{if(n.id===_.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===_.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(o!=null&&o.fromCollab)){if(n.id===_.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===_.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o||o.getActiveSheet().getSheetId()!==n)return;const s=o.getActiveSheetIndex(),l=Er(o,s);this._switchToNextSheet(e,l)}_beforeAdjustActiveSheetOnRemoveSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o)return;const r=o.getSheetBySheetId(n);r&&(this._previousSheetIndex=o.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(t){if(this._previousSheetIndex===-1)return;const{unitId:e}=t.params,n=this._univerInstanceService.getUniverSheetInstance(e);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,l=Er(n,s);this._switchToNextSheet(e,l)}_adjustActiveSheetOnInsertSheet(t){const{unitId:e,sheet:n}=t.params;this._switchToNextSheet(e,n.id)}_adjustActiveSheetOnShowSheet(t){const{unitId:e,subUnitId:n}=t.params;this._switchToNextSheet(e,n)}_switchToNextSheet(t,e){this._commandService.executeCommand(_.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:e})}};Nn=Uc([a.OnLifecycle(a.LifecycleStages.Ready,Nn),Tr(0,a.ICommandService),Tr(1,a.IUniverInstanceService)],Nn);function Er(i,t){const e=i.getSheetSize();for(let n=t;n>-1;n--){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}for(let n=t;n<e;n++){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var Vc=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,kc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Vc(t,e,o),o},nn=(i,t)=>(e,n)=>t(e,n,i);let xn=class{constructor(i,t,e,n,o){this._injector=i,this._sheetInterceptorService=t,this._selectionManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:t,_sheetSkeletonManagerService:e,_injector:n}=this,{skeleton:o}=e.getCurrent(),r=o.calculateAutoHeightInRange(i),s=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getUnitId(),c={subUnitId:s.getActiveSheet().getSheetId(),unitId:l,rowsAutoHeightInfo:r},u=_.SetWorksheetRowAutoHeightMutationFactory(n,c);return{undos:[{id:_.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:_.SetWorksheetRowAutoHeightMutation.id,params:c}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:t}=this;i.interceptCommand({getMutations:e=>e.id!==_.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.range)}),i.interceptCommand({getMutations:e=>e.id!==_.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.ranges)}),i.interceptCommand({getMutations:e=>{var r;if(e.id!==_.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((r=e.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const o=t.getSelectionRanges();return o!=null&&o.length?this._getUndoRedoParamsOfAutoHeight(o):{redos:[],undos:[]}}})}};xn=kc([a.OnLifecycle(a.LifecycleStages.Ready,xn),nn(0,P.Inject(P.Injector)),nn(1,P.Inject(_.SheetInterceptorService)),nn(2,P.Inject(_.SelectionManagerService)),nn(3,P.Inject(a.IUniverInstanceService)),nn(4,P.Inject(N.SheetSkeletonManagerService))],xn);function Fc(i,t,e,n,o){const r=[],s=[];if(n.copyType===nt.CUT){const{undos:l,redos:d}=Wc(i,t,o);r.push(...d),s.push(...l)}else{const{undos:l,redos:d}=Or(t,e,o);r.push(...d),s.push(...l);const{undos:c,redos:u}=wr(t,i,e,o);r.push(...u),s.push(...c);const{undos:h,redos:m}=yr(t,e,o);r.push(...m),s.push(...h);const{undos:f,redos:g}=Xi(t,e,o);r.push(...g),s.push(...f)}return{undos:s,redos:r}}function Wc(i,t,e){let n=[],o=[];const{range:r,subUnitId:s,unitId:l}=i,{range:d,subUnitId:c}=t,u=d?lt(d):null,h=r?lt(r):null;if(h&&u){const m=e.get(a.IUniverInstanceService),f=e.get(_.SheetInterceptorService),g=m.getUniverSheetInstance(l),S=g==null?void 0:g.getSheetBySheetId(s),p=g==null?void 0:g.getSheetBySheetId(c);if(S&&p){const R=new a.ObjectMatrix,M=new a.ObjectMatrix,E=S.getCellMatrix(),b=p.getCellMatrix();a.Range.foreach(h,(X,q)=>{R.setValue(X,q,a.Tools.deepClone(E.getValue(X,q))),M.setValue(X,q,null)});const w=new a.ObjectMatrix;a.Range.foreach(u,(X,q)=>{w.setValue(X,q,a.Tools.deepClone(b.getValue(X,q)))});const y=new a.ObjectMatrix;a.Range.foreach(h,(X,q)=>{const L=a.cellToRange(X,q),U=a.Rectangle.getRelativeRange(L,h),F=a.Rectangle.getPositionRange(U,u);y.setValue(F.startRow,F.startColumn,E.getValue(X,q))});const O={from:{value:M.getMatrix(),subUnitId:s},to:{value:y.getMatrix(),subUnitId:c},unitId:l},x={from:{value:R.getMatrix(),subUnitId:s},to:{value:w.getMatrix(),subUnitId:c},unitId:l},D=f.onCommandExecute({id:_.MoveRangeCommand.id,params:{toRange:u,fromRange:h}}),W=S.getMergeData(),A=p.getMergeData(),H=W.filter(X=>a.Rectangle.intersects(X,h)),B=A.filter(X=>a.Rectangle.intersects(X,u)),z=H.map(X=>a.Rectangle.getRelativeRange(X,h)).map(X=>a.Rectangle.getPositionRange(X,u)),Y=_.getAddMergeMutationRangeByType(z).filter(X=>!A.some(q=>a.Rectangle.equals(X,q))),Q=[{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:H}},{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:B}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:c,ranges:Y}}],J=[{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:c,ranges:Y}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:c,ranges:B}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:H}}];n=[{id:_.MoveRangeMutation.id,params:O},...D.redos,...Q,{id:_.SetSelectionsOperation.id,params:{unitId:l,subUnitId:c,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u}]}}],o=[{id:_.MoveRangeMutation.id,params:x},...D.undos,...J,{id:_.SetSelectionsOperation.id,params:{unitId:l,sheetId:s,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:h}]}}]}}return{undos:o,redos:n}}function wr(i,t,e,n){const{unitId:o,subUnitId:r,range:s}=i,l=[],d=[],{mapFunc:c}=jt([s]),u=new a.ObjectMatrix;e.forValue((f,g,S)=>{var M;if(!S.p&&S.v&&!t){const E=String(S.v),b=Sn.parseDate(E)||Sn.parseTime(E)||Sn.parseNumber(E);b!=null&&b.v&&typeof b.v=="number"&&(S.v=b.v)}const{row:p,col:R}=c(f,g);(M=S.p)!=null&&M.body?u.setValue(p,R,a.Tools.deepClone({p:S.p,v:S.v})):u.setValue(p,R,a.Tools.deepClone({v:S.v}))});const h={unitId:o,subUnitId:r,cellValue:a.Tools.deepClone(u.getMatrix())};l.push({id:_.SetRangeValuesMutation.id,params:h});const m=_.SetRangeValuesUndoMutationFactory(n,h);return d.push({id:_.SetRangeValuesMutation.id,params:m}),{undos:d,redos:l}}function yr(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:l}=i,d=new a.ObjectMatrix,{mapFunc:c}=jt([l]);t.forValue((m,f,g)=>{var M;const S={s:g.s};(M=g.p)!=null&&M.body&&(S.p=g.p);const{row:p,col:R}=c(m,f);d.setValue(p,R,S)});const u={unitId:r,subUnitId:s,cellValue:a.Tools.deepClone(d.getMatrix())};n.push({id:_.SetRangeValuesMutation.id,params:u});const h=_.SetRangeValuesUndoMutationFactory(e,u);return o.push({id:_.SetRangeValuesMutation.id,params:h}),{undos:o,redos:n}}function Or(i,t,e){const n=[],o=[],r=new a.ObjectMatrix,{unitId:s,subUnitId:l,range:d}=i,{mapFunc:c}=jt([d]);if(t.forValue((u,h,m)=>{if(m.s){const{row:f,col:g}=c(u,h);r.setValue(f,g,{s:null})}}),r.getLength()>0){const u={subUnitId:l,unitId:s,cellValue:a.Tools.deepClone(r.getMatrix())};n.push({id:_.SetRangeValuesMutation.id,params:u});const h=_.SetRangeValuesUndoMutationFactory(e,u);o.push({id:_.SetRangeValuesMutation.id,params:h})}return{undos:o,redos:n}}function Xi(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:l}=i,{startColumn:d,startRow:c,endColumn:u,endRow:h}=lt(l),m=[];t.forValue((M,E,b)=>{if(b.rowSpan&&b.rowSpan>1){const w=b.colSpan||1,y={startRow:c+M,endRow:c+M+b.rowSpan-1,startColumn:d+E,endColumn:d+E+w-1};m.push(y)}else if(b.colSpan&&b.colSpan>1){const w=b.rowSpan||1,y={startRow:c+M,endRow:c+M+w-1,startColumn:d+E,endColumn:d+E+b.colSpan-1};m.push(y)}});const g=e.get(a.IUniverInstanceService).getUniverSheetInstance(r),S=g==null?void 0:g.getSheetBySheetId(s);if(g&&S){const E=S.getMergeData().filter(y=>a.Rectangle.intersects({startRow:c,startColumn:d,endRow:h,endColumn:u},y)),b={unitId:r,subUnitId:s,ranges:E};n.push({id:_.RemoveWorksheetMergeMutation.id,params:b});const w=_.RemoveMergeUndoMutationFactory(e,b);o.push({id:_.AddWorksheetMergeMutation.id,params:w})}const p={unitId:r,subUnitId:s,ranges:m};m.length>0&&n.push({id:_.AddWorksheetMergeMutation.id,params:p});const R=_.AddMergeUndoMutationFactory(e,p);return m.length>0&&o.push({id:_.RemoveWorksheetMergeMutation.id,params:R}),{undos:o,redos:n}}function jc(i){let t=i.replace(/(\r\n|\n)/g,"\r");t.endsWith(`\r
|
|
15
|
+
*/var Yl=V,Xl=Symbol.for("react.element"),$l=Symbol.for("react.fragment"),Gl=Object.prototype.hasOwnProperty,Zl=Yl.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Kl={key:!0,ref:!0,__self:!0,__source:!0};function _r(i,t,e){var n,o={},r=null,s=null;e!==void 0&&(r=""+e),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)Gl.call(t,n)&&!Kl.hasOwnProperty(n)&&(o[n]=t[n]);if(i&&i.defaultProps)for(n in t=i.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:Xl,type:i,key:r,ref:s,props:o,_owner:Zl.current}}yn.Fragment=$l,yn.jsx=_r,yn.jsxs=_r,Sr.exports=yn;var v=Sr.exports;const zi={sheetsUiContextMenuInput:"univer-sheets-ui-context-menu-input",sheetsUiContextMenuInputContainer:"univer-sheets-ui-context-menu-input-container",sheetsUiContextMenuInputNumber:"univer-sheets-ui-context-menu-input-number"},Ql=i=>{const{prefix:t,suffix:e,value:n,onChange:o,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=i,l=Z.useDependency(a.LocaleService),[d,c]=V.useState(),u=m=>{var f;c(m==null?void 0:m.toString()),o((f=m==null?void 0:m.toString())!=null?f:"")};V.useEffect(()=>{c(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return v.jsxs("div",{className:zi.sheetsUiContextMenuInput,children:[l.t(t),v.jsx("span",{className:zi.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:v.jsx(re.InputNumber,{className:zi.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:h,onChange:u,min:r,max:s})}),l.t(e)]})};var le=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(le||{});function Jl(i){const t=i.get(wt);return{id:Wi.id,subId:lr.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[C.MenuPosition.TOOLBAR_START],activated$:new k.Observable(e=>{let n=!1;const o=t.status$.subscribe(r=>{n=r!==Ue.OFF,e.next(n)});return e.next(n),()=>{o.unsubscribe()}}),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}function ql(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(a.IContextService),o=i.get(_.SelectionManagerService);return{id:Hi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=o.getLast())==null?void 0:f.primary;let p=a.FontWeight.NORMAL;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getFontWeight()}s.next(p===a.FontWeight.BOLD)}if((m===q.SetTextSelectionsOperation.id||m===q.SetInlineFormatCommand.id)&&n.getContextValue(a.EDITOR_ACTIVATED)&&n.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.bl;s.next(p===a.BooleanNumber.TRUE)}}),d=(u=o.getLast())==null?void 0:u.primary;if(!r){s.next(!1);return}let c=a.FontWeight.NORMAL;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getFontWeight()}return s.next(c===a.FontWeight.BOLD),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function ec(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService);return{id:Li.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=n.getLast())==null?void 0:f.primary;let p=a.FontItalic.NORMAL;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getFontStyle()}s.next(p===a.FontItalic.ITALIC)}if((m===q.SetTextSelectionsOperation.id||m===q.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.it;s.next(p===a.BooleanNumber.TRUE)}}),d=(u=n.getLast())==null?void 0:u.primary;let c=a.FontItalic.NORMAL;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getFontStyle()}return s.next(c===a.FontItalic.ITALIC),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function tc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService);return{id:Ui.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=n.getLast())==null?void 0:f.primary;let p;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getUnderline()}s.next(!!(p&&p.s))}if((m===q.SetTextSelectionsOperation.id||m===q.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.ul;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),d=(u=n.getLast())==null?void 0:u.primary;let c;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getUnderline()}return s.next(!!(c&&c.s)),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function nc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService);return{id:Vi.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[C.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(i),activated$:_e(e,!1,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var f,g;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(f=n.getLast())==null?void 0:f.primary;let p;if(S!=null){const R=r.getRange(S.startRow,S.startColumn);p=R==null?void 0:R.getStrikeThrough()}s.next(!!(p&&p.s))}if((m===q.SetTextSelectionsOperation.id||m===q.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const S=en(i);if(S==null)return;const p=(g=S.ts)==null?void 0:g.st;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),d=(u=n.getLast())==null?void 0:u.primary;let c;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getStrikeThrough()}return s.next(!!(c&&c.s)),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function ic(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=C.FONT_FAMILY_LIST[0].value;return{id:or.id,tooltip:"toolbar.font",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,label:mr,positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_FAMILY_LIST.map(r=>({label:{name:fr,hoverable:!0},value:r.value})),disabled$:_.getCurrentSheetDisabled$(i),value$:_e(e,o,({worksheet:r})=>new k.Observable(s=>{var u;const l=t.onCommandExecuted(h=>{var S;const m=h.id;if(m!==_.SetRangeValuesMutation.id&&m!==_.SetSelectionsOperation.id&&m!==_.SetWorksheetActiveOperation.id)return;const f=(S=n.getLast())==null?void 0:S.primary;let g;if(f!=null){const p=r.getRange(f.startRow,f.startColumn);g=p==null?void 0:p.getFontFamily()}s.next(g!=null?g:o)}),d=(u=n.getLast())==null?void 0:u.primary;let c;if(d!=null){const h=r.getRange(d.startRow,d.startColumn);c=h==null?void 0:h.getFontFamily()}return s.next(c!=null?c:o),l.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function oc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService),o=i.get(a.IContextService),r=_.getCurrentSheetDisabled$(i),s=11;return{id:ir.id,group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:gr,props:{min:1,max:400,disabled$:r}},positions:[C.MenuPosition.TOOLBAR_START],selections:C.FONT_SIZE_LIST,disabled$:r,value$:_e(e,s,({worksheet:l})=>new k.Observable(d=>{var m;const c=t.onCommandExecuted(f=>{var S,p;const g=f.id;if(g===_.SetRangeValuesMutation.id||g===_.SetSelectionsOperation.id||g===_.SetWorksheetActiveOperation.id){const R=(S=n.getLast())==null?void 0:S.primary;let M;if(R!=null){const T=l.getRange(R.startRow,R.startColumn);M=T==null?void 0:T.getFontSize()}d.next(M!=null?M:s)}if((g===q.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&o.getContextValue(a.EDITOR_ACTIVATED)&&o.getContextValue(a.FOCUSING_SHEET)){const R=en(i);if(R==null)return;const M=(p=R.ts)==null?void 0:p.fs;d.next(M!=null?M:s)}}),u=(m=n.getLast())==null?void 0:m.primary;let h;if(u!=null){const f=l.getRange(u.startRow,u.startColumn);h=f==null?void 0:f.getFontSize()}return d.next(h!=null?h:s),c.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}function rc(i){return{id:_.ResetTextColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:Tn.id,disabled$:_.getCurrentSheetDisabled$(i)}}function sc(i){const t=i.get(a.ICommandService),e=i.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:[{label:{name:En,hoverable:!1}}],value$:new k.Observable(n=>{const o=e.getCurrentTheme().textColor,r=t.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;n.next(l!=null?l:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}function ac(i){return{id:_.ResetBackgroundColorCommand.id,type:C.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:_.SetBackgroundColorCommand.id,disabled$:_.getCurrentSheetDisabled$(i)}}function lc(i){const t=i.get(a.ICommandService),e=i.get(a.ThemeService);return{id:_.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:C.MenuGroup.TOOLBAR_FORMAT,type:C.MenuItemType.BUTTON_SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:En,hoverable:!1}}],value$:new k.Observable(n=>{const o=e.getCurrentTheme().primaryColor,r=t.onCommandExecuted(s=>{if(s.id===_.SetBackgroundColorCommand.id){const l=s.params.value;n.next(l!=null?l:o)}});return n.next(o),r.dispose}),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const pr=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function cc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService);return{id:_.SetHorizontalTextAlignCommand.id,icon:pr[0].icon,positions:[C.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:pr,value$:_e(t,a.HorizontalAlign.LEFT,({worksheet:n})=>new k.Observable(o=>{var d;const r=i.get(a.ICommandService).onCommandExecuted(c=>{var f;const u=c.id;if(u!==_.SetHorizontalTextAlignCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(f=e.getLast())==null?void 0:f.primary;let m;if(h!=null){const g=n.getRange(h.startRow,h.startColumn);m=g==null?void 0:g.getHorizontalAlignment()}o.next(m!=null?m:a.HorizontalAlign.LEFT)}),s=(d=e.getLast())==null?void 0:d.primary;let l;if(s!=null){const c=n.getRange(s.startRow,s.startColumn);l=c==null?void 0:c.getHorizontalAlignment()}return o.next(l!=null?l:a.HorizontalAlign.LEFT),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const vr=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function dc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService);return{id:_.SetVerticalTextAlignCommand.id,icon:vr[2].icon,tooltip:"toolbar.verticalAlignMode.main",group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:vr,value$:_e(t,a.VerticalAlign.BOTTOM,({worksheet:n})=>new k.Observable(o=>{var d;const r=i.get(a.ICommandService).onCommandExecuted(c=>{var f;const u=c.id;if(u!==_.SetVerticalTextAlignCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(f=e.getLast())==null?void 0:f.primary;let m;if(h!=null){const g=n.getRange(h.startRow,h.startColumn);m=g==null?void 0:g.getVerticalAlignment()}o.next(m!=null?m:a.VerticalAlign.BOTTOM)}),s=(d=e.getLast())==null?void 0:d.primary;let l;if(s!=null){const c=n.getRange(s.startRow,s.startColumn);l=c==null?void 0:c.getVerticalAlignment()}return o.next(l!=null?l:a.VerticalAlign.BOTTOM),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const Cr=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function uc(i){const t=i.get(_.SelectionManagerService),e=i.get(a.IUniverInstanceService);return{id:_.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Cr[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,positions:[C.MenuPosition.TOOLBAR_START],selections:Cr,value$:_e(e,a.WrapStrategy.OVERFLOW,({worksheet:n})=>new k.Observable(o=>{var d;const r=i.get(a.ICommandService).onCommandExecuted(c=>{var f;const u=c.id;if(u!==_.SetTextWrapCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(f=t.getLast())==null?void 0:f.primary;let m;if(h!=null){const g=n.getRange(h.startRow,h.startColumn);m=g==null?void 0:g.getWrapStrategy()}o.next(m!=null?m:a.WrapStrategy.OVERFLOW)}),s=(d=t.getLast())==null?void 0:d.primary;let l;if(s!=null){const c=n.getRange(s.startRow,s.startColumn);l=c==null?void 0:c.getWrapStrategy()}return o.next(l!=null?l:a.WrapStrategy.OVERFLOW),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}const Ir=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function hc(i){const t=i.get(_.SelectionManagerService),e=i.get(a.IUniverInstanceService);return{id:_.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Ir[0].icon,group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SELECTOR,selections:Ir,positions:[C.MenuPosition.TOOLBAR_START],value$:_e(e,0,({worksheet:n})=>new k.Observable(o=>{var d,c;const r=i.get(a.ICommandService).onCommandExecuted(u=>{var g,S;const h=u.id;if(h!==_.SetTextRotationCommand.id&&h!==_.SetSelectionsOperation.id&&h!==_.SetWorksheetActiveOperation.id)return;const m=(g=t.getLast())==null?void 0:g.primary;let f;if(m!=null){const p=n.getRange(m.startRow,m.startColumn);f=p==null?void 0:p.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((S=f&&f.a)!=null?S:0)}),s=(d=t.getLast())==null?void 0:d.primary;let l;if(s!=null){const u=n.getRange(s.startRow,s.startColumn);l=u==null?void 0:u.getTextRotation()}return(l==null?void 0:l.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((c=l&&l.a)!=null?c:0),r.dispose})),hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(i)}}function yt(i){return new k.Observable(t=>t.next(!i.get(C.IClipboardInterfaceService).supportClipboard))}function mc(){return{id:C.CopyCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function fc(i){return{id:C.PasteCommand.id,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:yt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const Ot="sheet.menu.paste-special";function gc(i){return{id:Ot,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",disabled$:yt(i),positions:[C.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Sc(i){return{id:Wo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[Ot],disabled$:yt(i)}}function _c(i){return{id:jo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[Ot],disabled$:yt(i)}}function pc(i){return{id:zo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[Ot],disabled$:yt(i)}}function vc(i){return{id:Yo.id,type:C.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[Ot],disabled$:yt(i)}}function Cc(){return{id:_.SetWorksheetRowIsAutoHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const qt="sheet.menu.sheet-frozen";function Ic(){return{id:qt,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[C.MenuPosition.CONTEXT_MENU]}}const Yi="sheet.header-menu.sheet-frozen";function Rc(){return{id:Yi,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function Mc(){return{id:wn.id,type:C.MenuItemType.BUTTON,positions:[qt,Yi],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function bc(){return{id:dr.id,type:C.MenuItemType.BUTTON,positions:[qt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function Tc(){return{id:ur.id,type:C.MenuItemType.BUTTON,positions:[qt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function wc(){return{id:hr.id,type:C.MenuItemType.BUTTON,positions:[qt,Yi],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function Ec(){return{id:tr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function yc(){return{id:nr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function Oc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService),n=i.get(a.ICommandService),o=[_.SetSelectionsOperation,_.SetRowHiddenMutation,_.SetRowVisibleMutation].map(r=>r.id);return{id:_.SetSelectedRowsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:_e(t,!0,({worksheet:r})=>new k.Observable(s=>{function l(){var u;const c=(u=e.getSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(c!=null&&c.some(h=>{for(let m=h.startRow;m<=h.endRow;m++)if(!r.getRowRawVisible(m))return!0;return!1}))}const d=n.onCommandExecuted(c=>{o.findIndex(u=>u===c.id)!==-1&&s.next(!l())});return s.next(!l()),()=>d.dispose()}))}}function Nc(i){const t=i.get(a.IUniverInstanceService),e=i.get(_.SelectionManagerService),n=i.get(a.ICommandService),o=[_.SetSelectionsOperation,_.SetColHiddenMutation,_.SetColVisibleMutation].map(r=>r.id);return{id:_.SetSelectedColsVisibleCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:_e(t,!0,({worksheet:r})=>new k.Observable(s=>{function l(){var u;const c=(u=e.getSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!c||c.length===0?!1:!!c.some(h=>{for(let m=h.startColumn;m<=h.endColumn;m++)if(!r.getColVisible(m))return!0;return!1})}const d=n.onCommandExecuted(c=>{o.findIndex(u=>u===c.id)!==-1&&s.next(!l())});return s.next(!l()),()=>d.dispose()}))}}function xc(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService);return{id:_.SetRowHeightCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:ji,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:_e(e,0,({worksheet:o})=>new k.Observable(r=>{function s(){var u;const d=(u=n.getLast())==null?void 0:u.primary,c=d?o.getRowHeight(d.startRow):0;r.next(c)}const l=t.onCommandExecuted(d=>{const c=d.id;if(c===_.SetRangeValuesMutation.id||c===_.SetSelectionsOperation.id||c===_.SetWorksheetRowIsAutoHeightMutation.id)return s()});return s(),l.dispose}))}}function Ac(i){const t=i.get(a.ICommandService),e=i.get(a.IUniverInstanceService),n=i.get(_.SelectionManagerService);return{id:_.SetColWidthCommand.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:ji,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:_e(e,0,({worksheet:o})=>new k.Observable(r=>{function s(){var u;const d=(u=n.getLast())==null?void 0:u.primary;let c=0;d!=null&&(c=o.getColumnWidth(d.startColumn)),r.next(c)}const l=t.onCommandExecuted(d=>{const c=d.id;if(c===_.SetRangeValuesMutation.id||c===_.SetSelectionsOperation.id||c===_.SetWorksheetColWidthMutation.id)return s()});return s(),l.dispose}))}}function en(i){var d;const t=i.get(a.IUniverInstanceService),e=i.get(q.TextSelectionManagerService),n=t.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),o=e.getActiveRange();if(n==null||o==null)return null;const r=(d=n.getBody())==null?void 0:d.textRuns;if(r==null)return;const{startOffset:s}=o;return r.find(({st:c,ed:u})=>s>=c&&s<=u)}const Dc={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormatting:"Conditional formatting",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging",waring:"Waring",dismantleMergeCellWaring:"This will cause some merged cells to be split. Do you want to continue?"}},filter:{confirm:{error:"There was a problem",notAllowedToInsertRange:"Not allowed to move cells here until filter is cleared"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor",deleteAllRowsAlert:"You can't delete all the rows on the sheet",deleteAllColumnsAlert:"You can't delete all the columns on the sheet",hideAllRowsAlert:"You can't hide all the rows on the sheet",hideAllColumnsAlert:"You can't hide all the columns on the sheet"},info:{tooltip:"Tooltip",error:"Error",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total}, ${totalPage} page, current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total}, ${totalPage} page, All data displayed",problem:"There was a problem",forceStringInfo:"Number stored as text"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells",overlappingMergedCells:"The paste area overlaps with merged cells"},shortCutNotify:{title:"Kindly paste using keyboard shortcuts.",useShortCutInstead:"Detected Excel content. Use keyboard shortcut to paste."}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit",definedName:{managerTitle:"Manager named",managerDescription:"Create a defined name by selecting cells or formulas, and entering the desired name into the text box.",addButton:"Add a defined name",featureTitle:"Defined names",ratioRange:"Range",ratioFormula:"Formula",confirm:"Confirm",cancel:"Cancel",scopeWorkbook:"Workbook",inputNamePlaceholder:"Please enter a name(No space allowed)",inputCommentPlaceholder:"Please enter a comment",inputRangePlaceholder:"Please input range(No space allowed)",inputFormulaPlaceholder:"Please input a formula(No space allowed)",nameEmpty:"Name cannot be empty",nameDuplicate:"Name already exists",formulaOrRefStringEmpty:"Formula or reference string cannot be empty",formulaOrRefStringInvalid:"Invalid formula or reference string",defaultName:"DefinedName",updateButton:"Update",deleteButton:"Delete",deleteConfirmText:"Are you sure you want to delete this defined name?",nameConflict:"The name conflicts with the function name",nameInvalid:"The name is invalid",nameSheetConflict:"The name conflicts with the sheet name"}},Rr={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalFormatting:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并",waring:"警告",dismantleMergeCellWaring:"此操作会导致一些合并单元格被拆散,是否继续?"}},filter:{confirm:{error:"出现了一个问题",notAllowedToInsertRange:"要移动这些单元格,请清除该区域的筛选器"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
|
|
16
|
+
[ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑",deleteAllRowsAlert:"您无法删除工作表上的所有行",deleteAllColumnsAlert:"您无法删除工作表上的所有列",hideAllRowsAlert:"您无法隐藏工作表上的所有行",hideAllColumnsAlert:"您无法隐藏工作表上的所有列"},info:{tooltip:"提示",error:"错误",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据",problem:"出现了一个问题",forceStringInfo:"以文本形式存储的数字"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数",overlappingMergedCells:"粘贴区域与合并单元格重叠"},shortCutNotify:{title:"请使用快捷键粘贴",useShortCutInstead:"检测到 Excel 内容,请使用快捷键粘贴"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格",definedName:{managerTitle:"名称管理器",managerDescription:"通过选择单元格或公式,并在文本框中输入您想要的名称来创建一个定义名称。",addButton:"新建名称",featureTitle:"定义名称",ratioRange:"范围",ratioFormula:"公式",confirm:"确认",cancel:"取消",scopeWorkbook:"工作簿",inputNamePlaceholder:"请输入名称(必填)",inputCommentPlaceholder:"请输入备注",inputRangePlaceholder:"请输入范围(必填)",inputFormulaPlaceholder:"请输入公式(必填)",nameEmpty:"名称不能为空",nameDuplicate:"名称重复",formulaOrRefStringEmpty:"公式或引用字符串不能为空",formulaOrRefStringInvalid:"公式或引用字符串无效",defaultName:"DefinedName",updateButton:"修改",deleteButton:"删除",deleteConfirmText:"确定删除定义名称?",nameConflict:"与函数名称冲突",nameInvalid:"名称不包含空格或不允许的字符",nameSheetConflict:"名称与工作表名称冲突"}};class Mr{constructor(){I(this,"_state",null);I(this,"_rect",null);I(this,"_state$",new k.BehaviorSubject(null));I(this,"state$",this._state$.asObservable());I(this,"_rect$",new k.BehaviorSubject(null));I(this,"rect$",this._rect$.asObservable());I(this,"_focus",!1);I(this,"_focus$",new k.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(t){this._state=t,this._refresh(t)}getRect(){return this._rect}setRect(t){this._rect=t,this._rect$.next(t)}getState(){return this._state}setFocus(t=!1){this._focus=t,this._focus$.next(t)}_refresh(t){this._state$.next(t)}}const tn=P.createIdentifier("univer.sheet-cell-editor-manager.service");class Pc{constructor(){I(this,"_position",null);I(this,"_position$",new k.BehaviorSubject(null));I(this,"position$",this._position$.asObservable());I(this,"_focus",!1);I(this,"_focus$",new k.BehaviorSubject(this._focus));I(this,"focus$",this._focus$.asObservable());I(this,"_fxBtnClick$",new k.Subject);I(this,"fxBtnClick$",this._fxBtnClick$.asObservable());I(this,"_foldBtnStatus$",new k.Subject);I(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}setFocus(t=!1){this._focus=t,this._focus$.next(t)}handleFxBtnClick(t){this._fxBtnClick$.next(t)}handleFoldBtnClick(t){this._foldBtnStatus$.next(t)}_refresh(t){this._position$.next(t)}}const On=P.createIdentifier("univer.sheet-formula-editor-manager.service");var Hc=Object.defineProperty,Lc=Object.getOwnPropertyDescriptor,Uc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Lc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Hc(t,e,o),o},br=(i,t)=>(e,n)=>t(e,n,i);let Nn=class extends a.Disposable{constructor(t,e){super();I(this,"_previousSheetIndex",-1);this._commandService=t,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===_.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,o)=>{if(n.id===_.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===_.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(o!=null&&o.fromCollab)){if(n.id===_.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===_.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o||o.getActiveSheet().getSheetId()!==n)return;const s=o.getActiveSheetIndex(),l=Tr(o,s);this._switchToNextSheet(e,l)}_beforeAdjustActiveSheetOnRemoveSheet(t){const{unitId:e,subUnitId:n}=t.params,o=this._univerInstanceService.getUniverSheetInstance(e);if(!o)return;const r=o.getSheetBySheetId(n);r&&(this._previousSheetIndex=o.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(t){if(this._previousSheetIndex===-1)return;const{unitId:e}=t.params,n=this._univerInstanceService.getUniverSheetInstance(e);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,l=Tr(n,s);this._switchToNextSheet(e,l)}_adjustActiveSheetOnInsertSheet(t){const{unitId:e,sheet:n}=t.params;this._switchToNextSheet(e,n.id)}_adjustActiveSheetOnShowSheet(t){const{unitId:e,subUnitId:n}=t.params;this._switchToNextSheet(e,n)}_switchToNextSheet(t,e){this._commandService.executeCommand(_.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:e})}};Nn=Uc([a.OnLifecycle(a.LifecycleStages.Ready,Nn),br(0,a.ICommandService),br(1,a.IUniverInstanceService)],Nn);function Tr(i,t){const e=i.getSheetSize();for(let n=t;n>-1;n--){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}for(let n=t;n<e;n++){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var Vc=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,kc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Vc(t,e,o),o},nn=(i,t)=>(e,n)=>t(e,n,i);let xn=class{constructor(i,t,e,n,o){this._injector=i,this._sheetInterceptorService=t,this._selectionManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:t,_sheetSkeletonManagerService:e,_injector:n}=this,{skeleton:o}=e.getCurrent(),r=o.calculateAutoHeightInRange(i),s=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getUnitId(),c={subUnitId:s.getActiveSheet().getSheetId(),unitId:l,rowsAutoHeightInfo:r},u=_.SetWorksheetRowAutoHeightMutationFactory(n,c);return{undos:[{id:_.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:_.SetWorksheetRowAutoHeightMutation.id,params:c}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:t}=this;i.interceptCommand({getMutations:e=>e.id!==_.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.range)}),i.interceptCommand({getMutations:e=>e.id!==_.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(e.params.ranges)}),i.interceptCommand({getMutations:e=>{var r;if(e.id!==_.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((r=e.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const o=t.getSelectionRanges();return o!=null&&o.length?this._getUndoRedoParamsOfAutoHeight(o):{redos:[],undos:[]}}})}};xn=kc([a.OnLifecycle(a.LifecycleStages.Ready,xn),nn(0,P.Inject(P.Injector)),nn(1,P.Inject(_.SheetInterceptorService)),nn(2,P.Inject(_.SelectionManagerService)),nn(3,P.Inject(a.IUniverInstanceService)),nn(4,P.Inject(N.SheetSkeletonManagerService))],xn);function Fc(i,t,e,n,o){const r=[],s=[];if(n.copyType===nt.CUT){const{undos:l,redos:d}=Wc(i,t,o);r.push(...d),s.push(...l)}else{const{undos:l,redos:d}=yr(t,e,o);r.push(...d),s.push(...l);const{undos:c,redos:u}=wr(t,i,e,o);r.push(...u),s.push(...c);const{undos:h,redos:m}=Er(t,e,o);r.push(...m),s.push(...h);const{undos:f,redos:g}=Xi(t,e,o);r.push(...g),s.push(...f)}return{undos:s,redos:r}}function Wc(i,t,e){let n=[],o=[];const{range:r,subUnitId:s,unitId:l}=i,{range:d,subUnitId:c}=t,u=d?lt(d):null,h=r?lt(r):null;if(h&&u){const m=e.get(a.IUniverInstanceService),f=e.get(_.SheetInterceptorService),g=m.getUniverSheetInstance(l),S=g==null?void 0:g.getSheetBySheetId(s),p=g==null?void 0:g.getSheetBySheetId(c);if(S&&p){const R=new a.ObjectMatrix,M=new a.ObjectMatrix,T=S.getCellMatrix(),b=p.getCellMatrix();a.Range.foreach(h,($,ee)=>{R.setValue($,ee,a.Tools.deepClone(T.getValue($,ee))),M.setValue($,ee,null)});const E=new a.ObjectMatrix;a.Range.foreach(u,($,ee)=>{E.setValue($,ee,a.Tools.deepClone(b.getValue($,ee)))});const y=new a.ObjectMatrix;a.Range.foreach(h,($,ee)=>{const L=a.cellToRange($,ee),U=a.Rectangle.getRelativeRange(L,h),F=a.Rectangle.getPositionRange(U,u);y.setValue(F.startRow,F.startColumn,T.getValue($,ee))});const O={from:{value:M.getMatrix(),subUnitId:s},to:{value:y.getMatrix(),subUnitId:c},unitId:l},x={from:{value:R.getMatrix(),subUnitId:s},to:{value:E.getMatrix(),subUnitId:c},unitId:l},D=f.onCommandExecute({id:_.MoveRangeCommand.id,params:{toRange:u,fromRange:h}}),W=S.getMergeData(),A=p.getMergeData(),H=W.filter($=>a.Rectangle.intersects($,h)),B=A.filter($=>a.Rectangle.intersects($,u)),z=H.map($=>a.Rectangle.getRelativeRange($,h)).map($=>a.Rectangle.getPositionRange($,u)),X=_.getAddMergeMutationRangeByType(z).filter($=>!A.some(ee=>a.Rectangle.equals($,ee))),Q=[{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:H}},{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:B}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:c,ranges:X}}],J=[{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:c,ranges:X}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:c,ranges:B}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:H}}];n=[{id:_.MoveRangeMutation.id,params:O},...D.redos,...Q,{id:_.SetSelectionsOperation.id,params:{unitId:l,subUnitId:c,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u}]}}],o=[{id:_.MoveRangeMutation.id,params:x},...D.undos,...J,{id:_.SetSelectionsOperation.id,params:{unitId:l,sheetId:s,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:h}]}}]}}return{undos:o,redos:n}}function wr(i,t,e,n){const{unitId:o,subUnitId:r,range:s}=i,l=[],d=[],{mapFunc:c}=jt([s]),u=new a.ObjectMatrix;e.forValue((f,g,S)=>{var M;if(!S.p&&S.v&&!t){const T=String(S.v),b=Sn.parseDate(T)||Sn.parseTime(T)||Sn.parseNumber(T);b!=null&&b.v&&typeof b.v=="number"&&(S.v=b.v)}const{row:p,col:R}=c(f,g);(M=S.p)!=null&&M.body?u.setValue(p,R,a.Tools.deepClone({p:S.p,v:S.v})):u.setValue(p,R,a.Tools.deepClone({v:S.v}))});const h={unitId:o,subUnitId:r,cellValue:a.Tools.deepClone(u.getMatrix())};l.push({id:_.SetRangeValuesMutation.id,params:h});const m=_.SetRangeValuesUndoMutationFactory(n,h);return d.push({id:_.SetRangeValuesMutation.id,params:m}),{undos:d,redos:l}}function Er(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:l}=i,d=new a.ObjectMatrix,{mapFunc:c}=jt([l]);t.forValue((m,f,g)=>{var M;const S={s:g.s};(M=g.p)!=null&&M.body&&(S.p=g.p);const{row:p,col:R}=c(m,f);d.setValue(p,R,S)});const u={unitId:r,subUnitId:s,cellValue:a.Tools.deepClone(d.getMatrix())};n.push({id:_.SetRangeValuesMutation.id,params:u});const h=_.SetRangeValuesUndoMutationFactory(e,u);return o.push({id:_.SetRangeValuesMutation.id,params:h}),{undos:o,redos:n}}function yr(i,t,e){const n=[],o=[],r=new a.ObjectMatrix,{unitId:s,subUnitId:l,range:d}=i,{mapFunc:c}=jt([d]);if(t.forValue((u,h,m)=>{if(m.s){const{row:f,col:g}=c(u,h);r.setValue(f,g,{s:null})}}),r.getLength()>0){const u={subUnitId:l,unitId:s,cellValue:a.Tools.deepClone(r.getMatrix())};n.push({id:_.SetRangeValuesMutation.id,params:u});const h=_.SetRangeValuesUndoMutationFactory(e,u);o.push({id:_.SetRangeValuesMutation.id,params:h})}return{undos:o,redos:n}}function Xi(i,t,e){const n=[],o=[],{unitId:r,subUnitId:s,range:l}=i,{startColumn:d,startRow:c,endColumn:u,endRow:h}=lt(l),m=[];t.forValue((M,T,b)=>{if(b.rowSpan&&b.rowSpan>1){const E=b.colSpan||1,y={startRow:c+M,endRow:c+M+b.rowSpan-1,startColumn:d+T,endColumn:d+T+E-1};m.push(y)}else if(b.colSpan&&b.colSpan>1){const E=b.rowSpan||1,y={startRow:c+M,endRow:c+M+E-1,startColumn:d+T,endColumn:d+T+b.colSpan-1};m.push(y)}});const g=e.get(a.IUniverInstanceService).getUniverSheetInstance(r),S=g==null?void 0:g.getSheetBySheetId(s);if(g&&S){const T=S.getMergeData().filter(y=>a.Rectangle.intersects({startRow:c,startColumn:d,endRow:h,endColumn:u},y)),b={unitId:r,subUnitId:s,ranges:T};n.push({id:_.RemoveWorksheetMergeMutation.id,params:b});const E=_.RemoveMergeUndoMutationFactory(e,b);o.push({id:_.AddWorksheetMergeMutation.id,params:E})}const p={unitId:r,subUnitId:s,ranges:m};m.length>0&&n.push({id:_.AddWorksheetMergeMutation.id,params:p});const R=_.AddMergeUndoMutationFactory(e,p);return m.length>0&&o.push({id:_.RemoveWorksheetMergeMutation.id,params:R}),{undos:o,redos:n}}function jc(i){let t=i.replace(/(\r\n|\n)/g,"\r");t.endsWith(`\r
|
|
17
17
|
`)||(t+=`\r
|
|
18
18
|
`);const e=[];for(let n=0;n<t.length;n++)t[n]==="\r"&&e.push({startIndex:n});return{dataStream:t,paragraphs:e,sectionBreaks:[{startIndex:t.indexOf(`
|
|
19
|
-
`)}]}}var zc=Object.defineProperty,Yc=Object.getOwnPropertyDescriptor,Xc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Yc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&zc(t,e,o),o},Ve=(i,t)=>(e,n)=>t(e,n,i);let An=class extends a.RxDisposable{constructor(i,t,e,n,o,r,s,l,d,c,u){var h;super(),this._injector=i,this._currentUniverSheet=t,this._commandService=e,this._contextService=n,this._configService=o,this._sheetClipboardService=r,this._clipboardInterfaceService=s,this._messageService=l,this._sheetSkeletonManagerService=d,this._localService=c,this._textSelectionRenderManager=u,this._init(),(h=this._textSelectionRenderManager)==null||h.onPaste$.pipe(k.takeUntil(this.dispose$)).subscribe(m=>{var p,R;if(!ie(this._contextService))return;m.event.preventDefault();const f=m.event,g=(p=f.clipboardData)==null?void 0:p.getData("text/html"),S=(R=f.clipboardData)==null?void 0:R.getData("text/plain");this._sheetClipboardService.legacyPaste(g,S)})}_init(){[Wo,Za,Rt].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t))),[jo,zo,Yo,Xo].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(t=>this._sheetClipboardService.addClipboardHook(t));this.disposeWithMe({dispose:()=>i.forEach(t=>t.dispose())})}_initCopyingHooks(){const i=this;let t=null;return{id:Se.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(e,n){t=i._getWorksheet(e,n)},onCopyCellContent(e,n){var s,l,d,c;const o=t.getCell(e,n);return(l=(s=o==null?void 0:o.p)==null?void 0:s.body)!=null&&l.paragraphs||(c=(d=o==null?void 0:o.p)==null?void 0:d.body)!=null&&c.textRuns?a.convertBodyToHtml(o.p.body):o?a.extractPureTextFromCell(o):""},onCopyCellStyle:(e,n,o,r)=>{const s={};(o||r)&&(s.rowspan=`${o||1}`,s.colspan=`${r||1}`);const l=t.getRange(e,n),d=t.getMergedCell(e,n),c=l.getTextStyle();let u="";if(c&&(u=a.handleStyleToString(c)),d){const h=d.endRow,m=d.endColumn,g=t.getRange(h,m).getTextStyle();if(g){const S=a.handleStyleToString(g);u?u+=S?`;${S}`:"":u=S}}return u&&(s.style=u),s},onCopyColumn(e){return{width:`${t.getColumnWidth(e)}`}},onCopyRow(e){return{style:`height: ${t.getRowHeight(e)}px;`}},onAfterCopy(){t=null},getFilteredOutRows(e){var l;const{startRow:n,endRow:o}=e,r=(l=i._currentUniverSheet.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getActiveSheet(),s=[];if(!r)return s;for(let d=n;d<=o;d++)r.getRowFiltered(d)&&s.push(d);return s}}}_initPastingHook(){const i=this;let t=null,e=null,n=null;return{id:Se.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:o,subUnitId:r,range:s}){n=i._getWorksheet(o,r),t=o,e=r;const l=i._configService.getConfig(_.MAX_CELL_PER_SHEET_KEY),d=s.rows[s.rows.length-1],c=s.cols[s.cols.length-1];return l&&d*c>l?(i._messageService.show({type:re.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,r){const{range:s}=o,l=[],d=[],c=n.getMaxRows(),u=s.rows[s.rows.length-1]-c,h=r.length-u,m=n.getRowManager();if(u>0){const p={};r.slice(h).forEach((M,E)=>{const{style:b,height:w}=M||{};if(b){const y=b.split(";");let O=a.DEFAULT_WORKSHEET_ROW_HEIGHT;y.find(x=>{x=x.toLowerCase();const D=C.textTrim(x.substr(0,x.indexOf(":"))),W=C.textTrim(x.substr(x.indexOf(":")+1));return D==="height"?(W.endsWith("pt")?O=T.ptToPx(Number.parseFloat(W)):O=Number.parseFloat(W),!0):!1}),p[E]={h:O,hd:a.BooleanNumber.FALSE}}else w&&(p[E]={h:Number.parseFloat(w),hd:a.BooleanNumber.FALSE})});const R={unitId:t,subUnitId:e,range:{startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1],endRow:s.rows[s.rows.length-1],startRow:c},rowInfo:p};l.push({id:_.InsertRowMutation.id,params:R})}const f={},g={};r.slice(0,h).forEach((p,R)=>{var b,w;const{style:M,height:E}=p;if(M){const y=M.split(";");let O=a.DEFAULT_WORKSHEET_ROW_HEIGHT;y.find(x=>{x=x.toLowerCase();const D=C.textTrim(x.substr(0,x.indexOf(":"))),W=C.textTrim(x.substr(x.indexOf(":")+1));return D==="height"?(W.endsWith("pt")?O=T.ptToPx(Number.parseFloat(W)):O=Number.parseFloat(W),!0):!1}),f[R+s.rows[0]]=O}else if(E){const y=m.getRow(s.rows[0]+R),O=Number.parseFloat(E);if(y){const{h:x=a.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:D=0}=y,W=Math.max(x,D);O>W&&(f[R+s.rows[0]]=O,g[R+s.rows[0]]=W)}else f[R+s.rows[0]]=O,g[R+s.rows[0]]=(w=(b=m.getRow(s.rows[0]+R))==null?void 0:b.h)!=null?w:a.DEFAULT_WORKSHEET_ROW_HEIGHT}});const S={unitId:t,subUnitId:e,ranges:[{startRow:s.rows[0],endRow:Math.min(s.rows[s.rows.length-1],c),startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1]}],rowHeight:f};return l.push({id:_.SetWorksheetRowHeightMutation.id,params:S}),d.push({id:_.SetWorksheetRowHeightMutation.id,params:{...S,rowHeight:20}}),{redos:l,undos:d}},onPasteColumns(o,r,s){var g;const{range:l}=o,d=[],c=n.getMaxColumns(),u=l.cols[l.cols.length-1]-c,h=r.length-u,m=(g=i._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?g:a.DEFAULT_WORKSHEET_COLUMN_WIDTH;if(u>0){const S={unitId:t,subUnitId:e,range:{startRow:l.rows[0],endRow:l.rows[l.rows.length-1],endColumn:l.cols[l.cols.length-1],startColumn:c},colInfo:r.slice(h).map(p=>({w:p.width?+p.width:m,hd:a.BooleanNumber.FALSE}))};d.push({id:_.InsertColMutation.id,params:S})}const f={unitId:t,subUnitId:e,ranges:[{startRow:l.rows[0],endRow:l.rows[l.rows.length-1],startColumn:l.cols[0],endColumn:Math.min(l.cols[l.cols.length-1],c)}],colWidth:r.slice(0,h).map(S=>S.width?+S.width:m)};return d.push({id:_.SetWorksheetColWidthMutation.id,params:f}),{redos:d,undos:[]}},onPastePlainText(o,r,s){return i._onPastePlainText(o,r,s)},onPasteCells(o,r,s,l){return i._onPasteCells(o,r,s,l)},onAfterPaste(o){n=null}}}_generateDocumentDataModelSnapshot(i){var s;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null)return null;const{skeleton:e}=t,n=(s=e.getBlankCellDocumentModel())==null?void 0:s.documentModel,r={...n==null?void 0:n.getSnapshot(),...i};return n==null||n.reset(r),n==null?void 0:n.getSnapshot()}_onPastePlainText(i,t,e){const{range:n,unitId:o,subUnitId:r}=i;let s;if(/\r|\n/.test(t)){const d=jc(t),c=this._generateDocumentDataModelSnapshot({body:d});s={[n.rows[0]]:{[n.cols[0]]:{p:c}}}}else a.isFormulaString(t)?s={[n.rows[0]]:{[n.cols[0]]:{f:t}}}:s={[n.rows[0]]:{[n.cols[0]]:{v:t}}};const l={unitId:o,subUnitId:r,cellValue:s};return{redos:[{id:_.SetRangeValuesMutation.id,params:l}],undos:[{id:_.SetRangeValuesMutation.id,params:_.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}_onPasteCells(i,t,e,n){const o={get:this._injector.get.bind(this._injector)};return Fc(i,t,e,n,o)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},t=this,e={id:Se.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,l,d)=>wr(l,s,d,i)},n={id:Se.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,l,d){const c=[],u=[],{undos:h,redos:m}=Or(l,d,i);c.push(...m),u.push(...h);const{undos:f,redos:g}=Xi(l,d,i);c.push(...g),u.push(...f);const{undos:S,redos:p}=yr(l,d,i);return c.push(...p),u.push(...S),{undos:u,redos:c}}},o={id:Se.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,l,d){var b;const c=t._currentUniverSheet.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=c.getUnitId(),h=c.getActiveSheet().getSheetId(),m=[],f=t._getWorksheet(u,h),{range:g}=s,S=f.getMaxColumns(),p=g.cols[g.cols.length-1]-S,R=l.length-p,M=(b=t._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?b:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,E={unitId:u,subUnitId:h,ranges:[{startRow:g.rows[0],endRow:Math.min(g.cols[g.cols.length-1],S),startColumn:g.cols[0],endColumn:g.cols[g.cols.length-1]}],colWidth:l.slice(0,R).map(w=>w.width?+w.width:M)};return m.push({id:_.SetWorksheetColWidthMutation.id,params:E}),m.push({id:_.SetWorksheetColWidthMutation.id,params:E}),{redos:m,undos:[]}}},r={id:Se.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,l,d,c){t._currentUniverSheet.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);const u=[],h=[],{range:m,unitId:f,subUnitId:g}=l,S=new a.ObjectMatrix;d.forValue((b,w,y)=>{const O=y.s;typeof O=="object"&&S.setValue(m.rows[b],m.cols[w],{s:{...O,bd:void 0},v:y.v})});const p={unitId:f,subUnitId:g,cellValue:S.getData()};u.push({id:_.SetRangeValuesMutation.id,params:p});const R=_.SetRangeValuesUndoMutationFactory(i,p);h.push({id:_.SetRangeValuesMutation.id,params:R});const{undos:M,redos:E}=Xi(l,d,i);return h.push(...M),u.push(...E),{redos:u,undos:h}}};return[e,n,o,r]}_getWorksheet(i,t){var n;const e=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(t);if(!e)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${t}.`);return e}};An=Xc([a.OnLifecycle(a.LifecycleStages.Steady,An),Ve(0,P.Inject(P.Injector)),Ve(1,a.IUniverInstanceService),Ve(2,a.ICommandService),Ve(3,a.IContextService),Ve(4,a.IConfigService),Ve(5,It),Ve(6,C.IClipboardInterfaceService),Ve(7,C.IMessageService),Ve(8,P.Inject(N.SheetSkeletonManagerService)),Ve(9,P.Inject(a.LocaleService)),Ve(10,P.Optional(T.ITextSelectionRenderManager))],An);var $c=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,Zc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Gc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&$c(t,e,o),o},on=(i,t)=>(e,n)=>t(e,n,i);let Dn=class extends a.Disposable{constructor(i,t,e,n,o){super(),this._univerInstanceService=i,this._contextMenuService=t,this._renderManagerService=e,this._selectionManagerService=n,this._selectionRenderService=o,this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(r=>{r&&this._addListeners()})}_addListeners(){const i=Me(this._univerInstanceService,this._renderManagerService);if(!i)return;const t=i.spreadsheet.onPointerDownObserver,e=t.add(l=>{if(l.button===2){const d=this._selectionManagerService.getSelections(),c=d==null?void 0:d[0];if(!c)return;const u=c.range.rangeType,h=this._selectionRenderService.convertSelectionRangeToData(c).rangeWithCoord,m=()=>{if(!h)return!1;const g=l.offsetX,S=l.offsetY;switch(u){case a.RANGE_TYPE.ROW:return h.startY<=S&&h.endY>=S;case a.RANGE_TYPE.COLUMN:return h.startX<=g&&h.endX>=g;default:return h.startX<=g&&h.endX>=g&&h.startY<=S&&h.endY>=S}},f=g=>{this._contextMenuService.triggerContextMenu(l,g)};m()?u===a.RANGE_TYPE.COLUMN?f(le.COL_HEADER_CONTEXT_MENU):u===a.RANGE_TYPE.ROW?f(le.ROW_HEADER_CONTEXT_MENU):f(C.MenuPosition.CONTEXT_MENU):f(C.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(a.toDisposable(()=>t.remove(e)));const o=i.spreadsheetRowHeader.onPointerDownObserver.add(l=>{l.button===2&&this._contextMenuService.triggerContextMenu(l,le.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(a.toDisposable(()=>t.remove(o)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(l=>{l.button===2&&this._contextMenuService.triggerContextMenu(l,le.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(a.toDisposable(()=>t.remove(s)))}};Dn=Zc([a.OnLifecycle(a.LifecycleStages.Rendered,Dn),on(0,a.IUniverInstanceService),on(1,C.IContextMenuService),on(2,T.IRenderManagerService),on(3,P.Inject(_.SelectionManagerService)),on(4,Ie)],Dn);var Kc=Object.defineProperty,Qc=Object.getOwnPropertyDescriptor,Jc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Qc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Kc(t,e,o),o},$i=(i,t)=>(e,n)=>t(e,n,i);let Pn=class extends a.RxDisposable{constructor(i,t,e){super(),this._univerInstanceService=i,this._renderManagerService=t,this._undoRedoService=e,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_DOC).pipe(k.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;i.getUnitId()!==a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const i={};this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(t=>{const e=t.getConfig();i[t.getSheetId()]={cellData:new a.ObjectMatrix(e.cellData),rowCount:e.rowCount,columnCount:e.columnCount,rowData:e.rowData,columnData:e.columnData}})}_commandExecutedListener(){}_getDocObject(){return te.getDocObject(this._univerInstanceService,this._renderManagerService)}};Pn=Jc([a.OnLifecycle(a.LifecycleStages.Rendered,Pn),$i(0,a.IUniverInstanceService),$i(1,T.IRenderManagerService),$i(2,P.Inject(a.IUndoRedoService))],Pn);const Nr=[C.KeyCode.ARROW_DOWN,C.KeyCode.ARROW_UP,C.KeyCode.ARROW_LEFT,C.KeyCode.ARROW_RIGHT],qc=[C.KeyCode.ENTER,C.KeyCode.TAB,...Nr];function ed(){const i=[];for(const t of Nr)i.push({id:Zt.id,binding:t,preconditions:e=>kt(e),staticParameters:{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:t,isShift:!1}}),i.push({id:Zt.id,binding:t|C.MetaKeys.SHIFT,preconditions:e=>kt(e),staticParameters:{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:t,isShift:!0}});return i}const td={id:xi.id,binding:C.KeyCode.F2,description:"shortcut.sheet.start-editing",group:"4_sheet-edit",preconditions:ie,staticParameters:{visible:!0,eventType:T.DeviceInputEventType.Keyboard,keycode:C.KeyCode.F2}},nd={id:ye.id,binding:C.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>kt(i),staticParameters:{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ENTER}},id={id:ye.id,binding:C.KeyCode.TAB,preconditions:i=>kt(i),staticParameters:{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:C.KeyCode.TAB}},od={id:ye.id,binding:C.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>kt(i),staticParameters:{visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC}},rd={id:te.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>Qs(i),binding:C.KeyCode.ENTER|C.MetaKeys.ALT},sd={id:te.DeleteLeftCommand.id,preconditions:i=>Js(i)||Oo(i),binding:C.KeyCode.BACKSPACE},ad={id:ye.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>ie(i)&&!Oo(i),binding:C.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:T.DeviceInputEventType.Keyboard,keycode:C.KeyCode.BACKSPACE}};function ld(i){return i.startsWith("'")}function cd(i){return i.slice(1)}var dd=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,hd=(i,t,e,n)=>{for(var o=n>1?void 0:n?ud(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&dd(t,e,o),o},je=(i,t)=>(e,n)=>t(e,n,i);function md(i){const{textRuns:t=[],paragraphs:e=[]}=i;return t.some(n=>n.ts&&!a.Tools.isEmptyObject(n.ts))||e.some(n=>n.bullet)||e.length>=2}let Hn=class extends a.Disposable{constructor(t,e,n,o,r,s,l,d,c,u){super();I(this,"_cursorChangeObservers");I(this,"_editorVisiblePrevious",!1);I(this,"_cursorChange",0);this._univerInstanceService=t,this._renderManagerService=e,this._commandService=n,this._editorBridgeService=o,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=l,this._undoRedoService=d,this._selectionManagerService=c,this._editorService=u,this._initialize(),this._commandExecutedListener()}dispose(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;e.onPointerDownObserver.remove(this._cursorChangeObservers),super.dispose()}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(async t=>{const{visible:e,keycode:n,eventType:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!0){this._cursorChange=o===T.DeviceInputEventType.PointerDown?2:1;return}this._cursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:l,sheetId:d,pluginName:c}=s;if(this._exitInput(t),n===C.KeyCode.ESC){r&&this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,{unitId:l,subUnitId:d,pluginName:c,selections:r});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:f,column:g,documentLayoutObject:S}=u;if(this._editorBridgeService.getEditorDirty()===!1){this._moveCursor(n);return}const R=this._univerInstanceService.getUniverSheetInstance(h),M=R==null?void 0:R.getSheetBySheetId(m);if(M==null)return;const E=fd(M.getCellRaw(f,g)||{},S,this._lexerTreeBuilder);if(E==null){this._moveCursor(n);return}const b={subUnitId:m,unitId:h,workbook:R,worksheet:M,row:f,col:g};l===h&&m!==d&&this._editorBridgeService.isForceKeepVisible()&&this._commandService.executeCommand(_.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h}),this._selectionManagerService.refreshSelection();const w=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(E,b),y=await this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC)(Promise.resolve(w),b);this._commandService.executeCommand(_.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:f,startColumn:g,endRow:f,endColumn:g},value:y}),this._moveCursor(n)}))}_exitInput(t){this._contextService.setContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(a.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:t.visible});const e=this._editorBridgeService.getCurrentEditorId();e==null||!this._editorService.isSheetEditor(e)||(this._undoRedoService.clearUndoRedo(e),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(t){if(t==null||!qc.includes(t))return;let e=a.Direction.LEFT;switch(t){case C.KeyCode.ENTER:e=a.Direction.DOWN;break;case C.KeyCode.TAB:e=a.Direction.RIGHT;break;case C.KeyCode.ARROW_DOWN:e=a.Direction.DOWN;break;case C.KeyCode.ARROW_UP:e=a.Direction.UP;break;case C.KeyCode.ARROW_LEFT:e=a.Direction.LEFT;break;case C.KeyCode.ARROW_RIGHT:e=a.Direction.RIGHT;break}t===C.KeyCode.ENTER||t===C.KeyCode.TAB?this._commandService.executeCommand(ct.id,{keycode:t,direction:e}):this._commandService.executeCommand(Ee.id,{direction:e})}_cursorStateListener(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;this.disposeWithMe(a.toDisposable(e.onPointerDownObserver.add(()=>{this._cursorChange===1&&(this._cursorChange=2)})))}_commandExecutedListener(){const t=[Zt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{keycode:o,isShift:r}=n;if(o!=null&&(this._cursorChange===2||this._contextService.getContextValue(a.FOCUSING_FORMULA_EDITOR))){this._moveInEditor(o,r);return}this._editorBridgeService.changeVisible(n)}e.id===xi.id&&(this._cursorChange=2)}))}_moveInEditor(t,e){let n=a.Direction.LEFT;t===C.KeyCode.ARROW_DOWN?n=a.Direction.DOWN:t===C.KeyCode.ARROW_UP?n=a.Direction.UP:t===C.KeyCode.ARROW_RIGHT&&(n=a.Direction.RIGHT),e?this._commandService.executeCommand(te.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(te.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return _n(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Hn=hd([a.OnLifecycle(a.LifecycleStages.Rendered,Hn),je(0,a.IUniverInstanceService),je(1,T.IRenderManagerService),je(2,a.ICommandService),je(3,we),je(4,a.IContextService),je(5,tn),je(6,P.Inject(K.LexerTreeBuilder)),je(7,a.IUndoRedoService),je(8,P.Inject(_.SelectionManagerService)),je(9,C.IEditorService)],Hn);function fd(i,t,e){i=a.Tools.deepClone(i);const{documentModel:n}=t;if(n==null)return null;const o=n.getSnapshot(),{body:r}=o;if(r==null)return null;i.t=void 0;const s=r.dataStream;let d=s.substring(s.length-2,s.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?s.substring(0,s.length-2):s;if(a.isFormulaString(d)){if(i.f===d)return null;const c=e.checkIfAddBracket(d);for(let u=0;u<c;u++)d+=K.matchToken.CLOSE_BRACKET;i.f=d,i.v=null,i.p=null}else if(ld(d)){const c=cd(d);i.v=c,i.f=null,i.si=null,i.p=null,i.t=a.CellValueType.FORCE_STRING}else if(md(r))r.dataStream===`\r
|
|
20
|
-
`?(i.v="",i.f=null,i.si=null,i.p=null):(i.p=o,i.v=null,i.f=null,i.si=null);else{if((d===i.v||d===""&&i.v==null)&&i.p==null)return null;i.v=d,i.f=null,i.si=null,i.p=null}return i}var gd=Object.defineProperty,Sd=Object.getOwnPropertyDescriptor,_d=(i,t,e,n)=>{for(var o=n>1?void 0:n?Sd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&gd(t,e,o),o},ze=(i,t)=>(e,n)=>t(e,n,i);let Ln=class extends a.RxDisposable{constructor(t,e,n,o,r,s,l,d,c,u){super();I(this,"_loadedMap",new WeakSet);this._univerInstanceService=t,this._renderManagerService=e,this._editorBridgeService=n,this._commandService=o,this._contextService=r,this._formulaEditorManagerService=s,this._undoRedoService=l,this._docSkeletonManagerService=d,this._docViewModelManagerService=c,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._listenFoldBtnClick(),this._renderManagerService.currentRender$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._create(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._textSelectionManagerService.textSelection$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const{unitId:e}=t;e!==a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_create(t){if(t!==a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&(this._loadedMap.has(n)||(this._initialMain(t),this._loadedMap.add(n)))}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(k.takeUntil(this.dispose$)).subscribe(()=>{var e;if(this._contextService.getContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(a.EDITOR_ACTIVATED)){this._univerInstanceService.setCurrentUnitForType(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:
|
|
21
|
-
`,o=[{startIndex:0}]):t.isInArrayFormulaRange===!0&&(r=(e==null?void 0:e.textRuns)||[]),this._syncContentAndRender(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,o,r),this._autoScroll())}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,C.SetEditorResizeOperation.id],e=[a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s;if(t.includes(o.id)){const l=o.params,{unitId:d}=l;if(e.includes(d)){const c=this._univerInstanceService.getUniverDocInstance(d),u=(r=c==null?void 0:c.getBody())==null?void 0:r.dataStream,h=(s=c==null?void 0:c.getBody())==null?void 0:s.paragraphs,m=d===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(u==null||h==null)return;this._syncContentAndRender(m,u,h),this._autoScroll()}}}));const n=[_.SetRangeValuesMutation.id,_.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s,l,d,c;if(n.includes(o.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:f}=u;if(o.id===_.SetRangeValuesMutation.id&&o.params?(s=(r=o.params.cellValue)==null?void 0:r[m])!=null&&s[f]&&(h=!0):o.id===_.MoveRangeMutation.id&&o.params&&(d=(l=o.params.to.value)==null?void 0:l[m])!=null&&d[f]&&(h=!0),h){const g=(c=u.documentLayoutObject.documentModel)==null?void 0:c.getBody();if(g==null)return;const{dataStream:S,paragraphs:p=[]}=g;this._syncContentAndRender(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,S,p),this._autoScroll()}}}))}_syncContentAndRender(t,e,n,o=[]){var h;const r=[a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),l=this._univerInstanceService.getUniverDocInstance(t),d=this._docViewModelManagerService.getViewModel(t);if(l==null||d==null||s==null)return;l.getBody().dataStream=e,l.getBody().paragraphs=this._clearParagraph(n),t===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(l.getBody().textRuns=[]),o.length>0&&(l.getBody().textRuns=o),d.reset(l);const{skeleton:c}=s,u=this._renderManagerService.getRenderById(t);u!=null&&(c.calculate(),r.includes(t)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(t){const e=a.Tools.deepClone(t);for(const n of e)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=a.HorizontalAlign.UNSPECIFIED);return e}_autoScroll(){var g,S;const t=(g=this._docSkeletonManagerService.getSkeletonByUnitId(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:g.skeleton,e=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),o=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||e==null||n==null||o==null)return;const{marginTop:r=0,marginBottom:s=0}=o.getSnapshot().documentStyle,{scene:l,mainComponent:d}=n;let{actualHeight:c}=t.getActualSize();c+=r+s;const{width:u,height:h}=e,m=l.getViewport(te.VIEWPORT_KEY.VIEW_MAIN);let f=m==null?void 0:m.getScrollBar();l.transformByState({width:u,height:c}),d==null||d.resize(u,c),c>h?f==null?m&&new T.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(f=null,m==null||m.scrollTo({x:0,y:0}),(S=m==null?void 0:m.getScrollBar())==null||S.dispose())}};Ln=_d([a.OnLifecycle(a.LifecycleStages.Steady,Ln),ze(0,a.IUniverInstanceService),ze(1,T.IRenderManagerService),ze(2,we),ze(3,a.ICommandService),ze(4,a.IContextService),ze(5,On),ze(6,a.IUndoRedoService),ze(7,P.Inject(te.DocSkeletonManagerService)),ze(8,P.Inject(te.DocViewModelManagerService)),ze(9,P.Inject(te.TextSelectionManagerService))],Ln);const xr={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container"};var pd=Object.defineProperty,vd=Object.getOwnPropertyDescriptor,Cd=(i,t,e,n)=>{for(var o=n>1?void 0:n?vd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&pd(t,e,o),o},Ne=(i,t)=>(e,n)=>t(e,n,i);const Ar=-1e3,Dr=5,Id=2;let Un=class extends a.Disposable{constructor(t,e,n,o,r,s,l,d,c,u,h,m){super();I(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=t,this._docViewModelManagerService=e,this._contextService=n,this._univerInstanceService=o,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=l,this._textSelectionRenderManager=d,this._textSelectionManagerService=c,this._commandService=u,this._localService=h,this._editorService=m,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const t=this._getEditorObject();t!=null&&this.disposeWithMe(a.toDisposable(t.document.onPointerDownObserver.add(()=>{var e;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),o=this._editorBridgeService.getCurrentEditorId();if(n==null||o==null||!this._editorService.isSheetEditor(o))return;const r=(e=this._docSkeletonManagerService.getSkeletonByUnitId(o))==null?void 0:e.skeleton;if(r==null)return;const{position:s,documentLayoutObject:l,canvasOffset:d,scaleX:c,scaleY:u}=n;this._fitTextSize(s,d,r,l,c,u)}})))}_initialCursorSync(){this.disposeWithMe(this._cellEditorManagerService.focus$.pipe(k.filter(t=>!!t)).subscribe(()=>{this._textSelectionRenderManager.sync()}))}_initialEditFocusListener(){this.disposeWithMe(this._editorBridgeService.currentEditCellState$.subscribe(t=>{if(t==null||this._editorBridgeService.isForceKeepVisible())return;const{position:e,documentLayoutObject:n,scaleX:o,editorUnitId:r}=t;if(this._getEditorObject()==null)return;const{startX:l,endX:d}=e,{textRotation:c,wrapStrategy:u,documentModel:h}=n,{vertexAngle:m}=T.convertTextRotation(c);h.updateDocumentId(r),u===a.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((d-l)/o),this._univerInstanceService.changeDoc(r,h),this._contextService.setContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Ar,Ar)}))}_fitTextSize(t,e,n,o,r=1,s=1){const{startX:l,startY:d,endX:c,endY:u}=t,h=o.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:f}=this._predictingSize(t,e,n,o,r,s),{verticalAlign:g,paddingData:S,fill:p}=o;let R=c-l,M=u-d;if(R<m&&(R=m),M<f)M=f,h.updateDocumentDataMargin(S);else{let E=0;g===a.VerticalAlign.MIDDLE?E=(M-f)/2/s:g===a.VerticalAlign.TOP?E=S.t||0:E=(M-f)/s-(S.b||0),E=E<(S.t||0)?S.t||0:E,h.updateDocumentDataMargin({t:E})}n.calculate(),this._editAreaProcessing(R,M,t,e,p,r,s)}_predictingSize(t,e,n,o,r=1,s=1){const{startX:l,endX:d}=t,{textRotation:c,wrapStrategy:u}=o,h=o.documentModel,{vertexAngle:m}=T.convertTextRotation(c),f=document.body.clientWidth;if(u===a.WrapStrategy.WRAP&&m===0){const{actualWidth:p,actualHeight:R}=n.getActualSize();return{actualWidth:p*r,actualHeight:R*s}}h==null||h.updateDocumentDataPageSize((f-l-e.left)/r),n.calculate();const g=n.getActualSize();let S=d-l;return S<g.actualWidth*r+Dr*r&&(S=g.actualWidth*r+Dr*r),h==null||h.updateDocumentDataPageSize(S/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:a.HorizontalAlign.UNSPECIFIED,cellValueType:void 0}),{actualWidth:S,actualHeight:g.actualHeight*s}}_editAreaProcessing(t,e,n,o,r,s=1,l=1){var w;const d=this._getEditorObject();if(d==null)return;let{startX:c,startY:u}=n;const{document:h,scene:m,engine:f}=d,g=m.getViewport(te.VIEWPORT_KEY.VIEW_MAIN),S=document.body.clientHeight-u-Number.parseFloat(xr.sheetFooterBarHeight)-o.top-Id*2,p=document.body.clientWidth-c-o.left;let R=e,M=g==null?void 0:g.getScrollBar();R>S?(R=S,M==null?g&&new T.ScrollBar(g,{enableHorizontal:!1,barSize:8}):g==null||g.resetSizeAndScrollBar()):(M=null,(w=g==null?void 0:g.getScrollBar())==null||w.dispose()),t+=(M==null?void 0:M.barSize)||0,t>p&&(t=p),c-=T.FIX_ONE_PIXEL_BLUR_OFFSET,u-=T.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,t/s,e/l,r);const{scaleX:E,scaleY:b}=m.getPrecisionScale();m.transformByState({width:t/s,height:e/l,scaleX:s,scaleY:l}),h.resize(t/s,e/l),requestIdleCallback(()=>{f.resizeBySize(T.fixLineWidthByScale(t,E),T.fixLineWidthByScale(R,b))}),this._cellEditorManagerService.setState({startX:c,startY:u,endX:t+c,endY:R+u,show:!0})}_addBackground(t,e,n,o){const r="_backgroundRectHelperColor_",s=t.getObject(r);s==null&&o==null||(s==null?t.addObjects([new T.Rect(r,{width:e,height:n,fill:o,evented:!1})],te.DOCS_COMPONENT_MAIN_LAYER_INDEX):o==null?s.dispose():(s.setProps({fill:o}),s.transformByState({width:e,height:n})))}_initialStartEdit(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var w,y;const{visible:e,eventType:n,keycode:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!1){this._setOpenForCurrent(null,null);return}const r=this._editorBridgeService.getEditCellState();if(r==null)return;const{position:s,documentLayoutObject:l,canvasOffset:d,scaleX:c,scaleY:u,editorUnitId:h,unitId:m,sheetId:f,isInArrayFormulaRange:g=!1}=r,S=this._getEditorObject();if(S==null)return;this._setOpenForCurrent(m,f);const{document:p,scene:R}=S;this._contextService.setContextValue(a.EDITOR_ACTIVATED,!0);const{documentModel:M}=l,E=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(E==null||M==null)return;const{skeleton:b}=E;if(this._fitTextSize(s,d,b,l,c,u),n===T.DeviceInputEventType.Keyboard||n===T.DeviceInputEventType.Dblclick&&g){const O=a.Tools.deepClone(M.snapshot),x=this._docViewModelManagerService.getViewModel(h);if(x==null)return;this._resetBodyStyle(O.body,!!g),M.reset(O),x.reset(M),p.makeDirty(),(o===C.KeyCode.BACKSPACE||n===T.DeviceInputEventType.Dblclick)&&(b.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===T.DeviceInputEventType.Dblclick){const O=M.getBody().dataStream.length-2||0;(w=R.getViewport(te.VIEWPORT_KEY.VIEW_MAIN))==null||w.scrollTo({y:Number.POSITIVE_INFINITY}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O}])}(y=this._renderManagerService.getRenderById(m))==null||y.scene.resetCursor()}))}_resetBodyStyle(t,e=!1){t.dataStream=a.DEFAULT_EMPTY_DOCUMENT_VALUE,t.textRuns!=null&&(t.textRuns.length===1&&!e?(t.textRuns[0].st=0,t.textRuns[0].ed=1):t.textRuns=void 0),t.paragraphs!=null&&(t.paragraphs.length===1?t.paragraphs[0].startIndex=0:t.paragraphs=[{startIndex:0}]),t.sectionBreaks!=null&&(t.sectionBreaks=void 0),t.tables!=null&&(t.tables=void 0),t.customRanges!=null&&(t.customRanges=void 0),t.customBlocks!=null&&(t.customBlocks=void 0)}_initialKeyboardListener(){this.disposeWithMe(this._textSelectionRenderManager.onInputBefore$.subscribe(t=>{const e=this._contextService.getContextValue(a.FOCUSING_FORMULA_EDITOR),n=this._contextService.getContextValue(a.FOCUSING_SHEET),o=this._univerInstanceService.getCurrentUniverDocInstance().getUnitId();n&&!e&&this._editorService.isSheetEditor(o)&&this._showEditorByKeyboard(t)}))}_showEditorByKeyboard(t){if(t==null)return;const e=t.event;this._commandService.executeCommand(ye.id,{visible:!0,eventType:T.DeviceInputEventType.Keyboard,keycode:e.which})}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,C.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const o=e.params,{unitId:r}=o;if(!this._editorService.isSheetEditor(r))return;const s=this._editorBridgeService.getCurrentEditorId();if(s==null)return;this._editorBridgeService.changeEditorDirty(!0);const l=(n=this._docSkeletonManagerService.getSkeletonByUnitId(s))==null?void 0:n.skeleton;if(l==null)return;const d=this._editorBridgeService.getEditCellState();if(d==null)return;const{position:c,documentLayoutObject:u,canvasOffset:h,scaleX:m,scaleY:f}=d;this._fitTextSize(c,h,l,u,m,f)}}))}_setOpenForCurrent(t,e){const n=this._editorService.getAllEditor();for(const[o,r]of n)r.isSheetEditor()&&(r.setOpenForSheetUnitId(t),r.setOpenForSheetSubUnitId(e))}_getEditorObject(){return _n(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Un=Cd([a.OnLifecycle(a.LifecycleStages.Rendered,Un),Ne(0,P.Inject(te.DocSkeletonManagerService)),Ne(1,P.Inject(te.DocViewModelManagerService)),Ne(2,a.IContextService),Ne(3,a.IUniverInstanceService),Ne(4,T.IRenderManagerService),Ne(5,we),Ne(6,tn),Ne(7,T.ITextSelectionRenderManager),Ne(8,P.Inject(te.TextSelectionManagerService)),Ne(9,a.ICommandService),Ne(10,P.Inject(a.LocaleService)),Ne(11,C.IEditorService)],Un);const Vn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=i.get(a.IUniverInstanceService),n=_.getSheetCommandTarget(e);if(!n)return!1;const{worksheet:o,subUnitId:r,unitId:s}=n,{delta:l,reset:d}=t;let c=d?100:Math.round((o.getConfig().zoomRatio+l)*100);c=Math.max(vi[0],c),c=Math.min(vi[1],c);const u=c/100;return i.get(a.ICommandService).executeCommand(Le.id,{unitId:s,subUnitId:r,zoomRatio:u})}},Bn={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{unitId:e,subUnitId:n,zoomRatio:o}=t;return i.get(a.ICommandService).executeCommand(Le.id,{unitId:e,subUnitId:n,zoomRatio:o})}},Pr={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(i,t)=>(i.get(we).setEditCell(t),!0)};var Rd=Object.defineProperty,Md=Object.getOwnPropertyDescriptor,bd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Md(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Rd(t,e,o),o},Be=(i,t)=>(e,n)=>t(e,n,i);let kn=class extends a.RxDisposable{constructor(i,t,e,n,o,r,s,l,d,c,u){super(),this._injector=i,this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._layoutService=s,this._editorService=l,this._contextService=d,this._selectionManagerService=c,this._rangeSelectorService=u,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener(),this._initialChangeEditorListener(),this._initialRangeSelector()}_initSelectionChangeListener(){k.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(k.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const e=this._injector.get(T.ITextSelectionRenderManager,P.Quantity.OPTIONAL);if(!this._layoutService.checkCanvasIsFocused()&&e&&!e.hasFocus())return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null||i==null||i.length===0||i[i.length-1]==null)return;const{primary:o}=i[i.length-1];if(o==null)return;const r=this._getSheetObject();if(r==null)return;const{unitId:s,sheetId:l}=n,{scene:d,engine:c}=r;this._commandService.executeCommand(Pr.id,{scene:d,engine:c,primary:o,unitId:s,sheetId:l})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:t,spreadsheetColumnHeader:e,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:o}=i;t.onDblclickObserver.add(r=>{if(r.button===2)return;const s=this._selectionManagerService.getCurrent();(s==null?void 0:s.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&this._commandService.executeCommand(ye.id,{visible:!0,eventType:T.DeviceInputEventType.Dblclick})}),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),o.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_initialChangeEditorListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_DOC).subscribe(i=>{if(i==null)return;const t=i.getUnitId();this._editorService.isEditor(t)&&(this._editorService.isSheetEditor(t)?(this._contextService.setContextValue(a.FOCUSING_DOC,!1),this._contextService.setContextValue(a.FOCUSING_SHEET,!0)):(this._contextService.setContextValue(a.FOCUSING_SHEET,!1),this._contextService.setContextValue(a.FOCUSING_DOC,!0),this._hideEditor()))}))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(ye.id,{visible:!1,eventType:T.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_initialRangeSelector(){this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._selectionManagerService.selectionMoveStart$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._rangeSelectorService.openSelector$.subscribe(()=>{const i=this._selectionManagerService.getSelections(),{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i==null?void 0:i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));o&&this._rangeSelectorService.selectionChange(o)}))}_rangeSelector(i){if(!i)return;const{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));this._rangeSelectorService.selectionChange(o)}_getCurrentUnitIdAndSheetId(){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=i.getActiveSheet();return{unitId:i.getUnitId(),sheetId:t.getSheetId(),sheetName:t.getName()}}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_commandExecutedListener(){const i=_.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((t,e)=>{e!=null&&e.fromCollab||(t.id===_.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(t.id)&&this._hideEditor())})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===Bn.id&&this._editorBridgeService.refreshEditCellState()}))}};kn=bd([a.OnLifecycle(a.LifecycleStages.Rendered,kn),Be(0,P.Inject(P.Injector)),Be(1,P.Inject(N.SheetSkeletonManagerService)),Be(2,a.IUniverInstanceService),Be(3,a.ICommandService),Be(4,T.IRenderManagerService),Be(5,we),Be(6,C.ILayoutService),Be(7,C.IEditorService),Be(8,a.IContextService),Be(9,P.Inject(_.SelectionManagerService)),Be(10,C.IRangeSelectorService)],kn);var Td=Object.defineProperty,Ed=Object.getOwnPropertyDescriptor,wd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Ed(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Td(t,e,o),o},rn=(i,t)=>(e,n)=>t(e,n,i);let Fn=class extends a.Disposable{constructor(i,t,e,n,o){super(),this._commandService=i,this._formatPainterService=t,this._univerInstanceService=e,this._renderManagerService=n,this._selectionRenderService=o,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:t}=this._getSheetObject()||{};t&&(i!==Ue.OFF?t.setDefaultCursor(T.CURSOR_TYPE.CELL):t.setDefaultCursor(T.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(a.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{if(this._formatPainterService.getStatus()!==Ue.OFF){const{rangeWithCoord:t}=i[i.length-1];this._applyFormatPainter({startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}),this._formatPainterService.getStatus()===Ue.ONCE&&this._commandService.executeCommand(Wi.id)}})))}async _applyFormatPainter(i){const{styles:t,merges:e}=this._formatPainterService.getSelectionFormat(),n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=n.getUnitId(),r=n.getActiveSheet().getSheetId();if(!t)return;const{startRow:s,startColumn:l,endRow:d,endColumn:c}=t.getDataRange(),u=d-s+1,h=c-l+1,m=Array.from({length:i.endRow-i.startRow+1},()=>Array.from({length:i.endColumn-i.startColumn+1},()=>({}))),f=[];m.forEach((S,p)=>{S.forEach((R,M)=>{const E=p%u+s,b=M%h+l,w=t.getValue(E,b);w&&(m[p][M].s=w)})}),e.forEach(S=>{const p={startRow:S.startRow-s,startColumn:S.startColumn-l,endRow:S.endRow-s,endColumn:S.endColumn-l},R=Math.max(1,Math.floor((i.endRow-i.startRow+1)/u)),M=Math.max(1,Math.floor((i.endColumn-i.startColumn+1)/h));for(let E=0;E<R;E++)for(let b=0;b<M;b++)f.push({startRow:p.startRow+E*u+i.startRow,startColumn:p.startColumn+b*h+i.startColumn,endRow:p.endRow+E*u+i.startRow,endColumn:p.endColumn+b*h+i.startColumn})});const g={subUnitId:r,unitId:o,styleRange:i,styleValues:m,mergeRanges:f};await this._commandService.executeCommand(dr.id,g)}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}};Fn=wd([a.OnLifecycle(a.LifecycleStages.Rendered,Fn),rn(0,a.ICommandService),rn(1,Et),rn(2,a.IUniverInstanceService),rn(3,T.IRenderManagerService),rn(4,Ie)],Fn);var yd=Object.defineProperty,Od=Object.getOwnPropertyDescriptor,Nd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Od(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&yd(t,e,o),o},ut=(i,t)=>(e,n)=>t(e,n,i);const xd="__SpreadsheetFreezeRowMainName__",Ad="__SpreadsheetFreezeRowHeaderName__",Dd="__SpreadsheetFreezeColumnMainName__",Pd="__SpreadsheetFreezeColumnHeaderName__",Gi=4,Hd=.01;let Wn=class extends a.Disposable{constructor(t,e,n,o,r,s,l,d){super();I(this,"_rowFreezeHeaderRect");I(this,"_rowFreezeMainRect");I(this,"_columnFreezeHeaderRect");I(this,"_columnFreezeMainRect");I(this,"_freezeDownObservers",[]);I(this,"_freezeMoveObservers",[]);I(this,"_freezeLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_changeToRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToOffsetX",0);I(this,"_changeToOffsetY",0);I(this,"_activeViewport",null);I(this,"_freezeNormalHeaderColor","");I(this,"_freezeNormalMainColor","");I(this,"_freezeActiveColor","");I(this,"_freezeHoverColor","");I(this,"_lastFreeze");this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._selectionManagerService=o,this._scrollManagerService=r,this._themeService=s,this._sheetInterceptorService=l,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(t=0,e){var O;const n=e!=null?e:this._getFreeze();if(n==null)return null;const o=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton,{startRow:r,startColumn:s}=n,l=this._getPositionByIndex(r,s);if(l==null)return null;const d=this._getSheetObject(),c=d.engine,u=(c==null?void 0:c.width)||0,h=(c==null?void 0:c.height)||0,m=d.scene,{startX:f,startY:g}=l,{rowTotalHeight:S,columnTotalWidth:p,rowHeaderWidthAndMarginLeft:R,columnHeaderHeightAndMarginTop:M}=o,E=u>p+R?u:p+M,b=h>S+M?h:S+M;this._changeToRow=r,this._changeToColumn=s,this._changeToOffsetX=f,this._changeToOffsetY=g;const w=Math.max(m.scaleX,m.scaleY),y=Gi/(w<1?1:w);if(t===0){const x=y;this._rowFreezeHeaderRect=new T.Rect(Ad,{fill:this._freezeNormalHeaderColor,width:R,height:y,left:0,top:g-x,zIndex:3});let D=this._freezeNormalHeaderColor;(r===-1||r===0)&&(D=this._freezeNormalMainColor),this._rowFreezeMainRect=new T.Rect(xd,{fill:D,width:E*2,height:y,left:R,top:g-x,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],tt)}else{const x=y;this._columnFreezeHeaderRect=new T.Rect(Pd,{fill:this._freezeNormalHeaderColor,width:y,height:M,left:f-x,top:0,zIndex:3});let D=this._freezeNormalHeaderColor;(s===-1||s===0)&&(D=this._freezeNormalMainColor),this._columnFreezeMainRect=new T.Rect(Dd,{fill:D,width:y,height:b*2,left:f-x,top:M,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],tt)}this._eventBinding(t)}_eventBinding(t=0){let e=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;t===1&&(e=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:r}=o;this._freezeMoveObservers.push(e==null?void 0:e.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(T.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(T.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(e==null?void 0:e.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(e==null?void 0:e.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)}))}_getCurrentLastVisibleRow(){var h,m,f,g;const t=this._getSheetObject();if(t==null)return;const e=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(e==null)return;const n=t.scene,o=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(t.engine.height-e.columnHeaderHeight)/o,l=(m=r==null?void 0:r.sheetViewStartRow)!=null?m:0,d=l===0?-((f=r==null?void 0:r.offsetY)!=null?f:0):e.rowHeightAccumulation[l-1]-((g=r==null?void 0:r.offsetY)!=null?g:0);let c=0,u=!1;for(let S=l,p=e.rowHeightAccumulation.length;S<p;S++)if(e.rowHeightAccumulation[S]-d>s){c=S,u=!0;break}return u||(c=e.rowHeightAccumulation.length-1),c}_getActiveViewport(t){var n;const e=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return e&&e.find(o=>o.isHit(new T.Vector2(t.offsetX,t.offsetY)))||null}_freezeDown(t,e,n,o=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:l}=s;l.setCursor(T.CURSOR_TYPE.GRABBING),l.disableEvent();const d=this._getCurrentLastVisibleRow(),c=d===void 0?Number.POSITIVE_INFINITY:r.rowHeightAccumulation[d];this._activeViewport=null;const u=this._getFreeze();u&&(this._changeToColumn=u.startColumn,this._changeToRow=u.startRow),this._moveObserver=l.onPointerMoveObserver.add(m=>{var E,b,w,y;const f=this._getActiveViewport(m),{startX:g,startY:S,row:p,column:R}=Mt(m.offsetX,m.offsetY,l,r,f||void 0);l.setCursor(T.CURSOR_TYPE.GRABBING);const M=Gi/Math.max(l.scaleX,l.scaleY);o===0?((E=e.transformByState({top:Math.min(S,c)-M/2}))==null||E.setProps({fill:this._freezeActiveColor}),(b=n.transformByState({top:Math.min(S,c)-M/2}))==null||b.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=d===void 0?p:Math.min(p,d),this._changeToOffsetY=Math.min(S,c),this._activeViewport=f):((w=e.transformByState({left:g-M/2}))==null||w.setProps({fill:this._freezeActiveColor}),(y=n.transformByState({left:g-M/2}))==null||y.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=R,this._changeToOffsetX=g,this._activeViewport=f)}),this._upObserver=l.onPointerUpObserver.add(()=>{var x,D;l.resetCursor(),l.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:f}=r;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(e.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(e==null||e.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const g=Gi/Math.max(l.scaleX,l.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(e.transformByState({top:f-g}),n.transformByState({top:f-g})):(this._changeToColumn===0||this._changeToColumn===-1)&&(e.transformByState({left:m-g}),n.transformByState({left:m-g}));const S=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:p,sheetViewStartColumn:R}=S;if(R==null||p==null)return;const M=this._context.unit,E=M.getActiveSheet(),b=(x=E.getConfig())==null?void 0:x.freeze;let w=(b==null?void 0:b.xSplit)||0,y=(b==null?void 0:b.ySplit)||0;const O=(D=this._activeViewport)==null?void 0:D.viewPortKey;o===0&&(!O||O===j.VIEW_LEFT_TOP||O===j.VIEW_MAIN_LEFT_TOP||O===j.VIEW_MAIN_TOP||O===j.VIEW_ROW_TOP?y=this._changeToRow-(b.startRow-b.ySplit):y=this._changeToRow-p,y=y<0?0:y),o===1&&(!O||O===j.VIEW_LEFT_TOP||O===j.VIEW_MAIN_LEFT_TOP||O===j.VIEW_MAIN_LEFT||O===j.VIEW_COLUMN_LEFT?w=this._changeToColumn-(b.startColumn-b.xSplit):w=this._changeToColumn-R,w=w<0?0:w),this._commandService.executeCommand(_.SetFrozenCommand.id,{startRow:y===0?-1:this._changeToRow,startColumn:w===0?-1:this._changeToColumn,ySplit:y,xSplit:w,unitId:M.getUnitId(),subUnitId:E.getSheetId()})})}_getViewports(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t,n=e.getViewport(j.VIEW_COLUMN_LEFT),o=e.getViewport(j.VIEW_COLUMN_RIGHT),r=e.getViewport(j.VIEW_ROW_TOP),s=e.getViewport(j.VIEW_ROW_BOTTOM),l=e.getViewport(j.VIEW_LEFT_TOP),d=e.getViewport(j.VIEW_MAIN),c=e.getViewport(j.VIEW_MAIN_LEFT_TOP),u=e.getViewport(j.VIEW_MAIN_LEFT),h=e.getViewport(j.VIEW_MAIN_TOP);if(!(n==null||o==null||r==null||s==null||l==null||d==null||c==null||u==null||h==null))return{viewMain:d,viewMainLeftTop:c,viewMainLeft:u,viewMainTop:h,viewColumnLeft:n,viewColumnRight:o,viewRowTop:r,viewRowBottom:s,viewLeftTop:l}}_bindViewportScroll(){const t=this._getViewports();if(!t)return;const{viewMain:e,viewRowBottom:n,viewColumnRight:o,viewMainLeft:r,viewMainTop:s}=t;this.disposeWithMe(e.onScrollAfterObserver.add(l=>{const{scrollX:d,scrollY:c,actualScrollX:u,actualScrollY:h}=l;n.isActive&&n.updateScroll({scrollY:c,actualScrollY:h}),o.isActive&&o.updateScroll({scrollX:d,actualScrollX:u}),r.isActive&&r.updateScroll({scrollY:c,actualScrollY:h}),s.isActive&&s.updateScroll({scrollX:d,actualScrollX:u})}))}_updateViewport(t=-1,e=-1,n=0,o=0,r=3){var O;const s=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(s==null)return;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:d}=s,c=this._getViewports();if(!c)return;const{viewMain:u,viewMainLeftTop:h,viewMainLeft:m,viewMainTop:f,viewColumnLeft:g,viewColumnRight:S,viewRowTop:p,viewRowBottom:R,viewLeftTop:M}=c;S.resize({left:l,top:0,height:d,right:0}),R.resize({left:0,top:d,bottom:0,width:l}),M.resize({left:0,top:0,width:l,height:d});let E=!0,b=!0;h.enable(),(t===-1||t===0)&&(E=!1),(e===-1||e===0)&&(b=!1);const w=s.getNoMergeCellPositionByIndexWithNoHeader(t-n,e-o),y=s.getNoMergeCellPositionByIndexWithNoHeader(t,e);if(h.disable(),f.disable(),m.disable(),p.disable(),g.disable(),h.resetPadding(),f.resetPadding(),m.resetPadding(),p.resetPadding(),g.resetPadding(),E===!1&&b===!1)u.resize({left:l,top:d,bottom:0,right:0}),u.resetPadding();else if(E===!0&&b===!1){const x=y.startY-w.startY;u.resize({left:l,top:d+x,bottom:0,right:0}),u.setPadding({startY:w.startY,endY:y.startY,startX:0,endX:0}),r&2&&this._commandService.executeCommand(dt.id,{sheetViewStartRow:0,offsetY:0}),f.resize({left:l,top:d,height:x,right:0}),f.updateScroll({actualScrollY:w.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),p.resize({left:0,top:d,width:l,height:x}),p.updateScroll({actualScrollY:w.startY}),R.resize({left:0,top:d+x,bottom:0,width:l}),f.enable(),p.enable()}else if(E===!1&&b===!0){const x=y.startX-w.startX;u.resize({left:l+x,top:d,bottom:0,right:0}),u.setPadding({startX:w.startX,endX:y.startX,startY:0,endY:0}),r&1&&this._commandService.executeCommand(dt.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:l,top:d,width:x,bottom:0,right:0}),m.updateScroll({actualScrollX:w.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),g.resize({left:l,top:0,width:x,height:d}),g.updateScroll({actualScrollX:w.startX}),S.resize({left:l+x,top:0,height:d,right:0}),m.enable(),g.enable()}else{const x=y.startX-w.startX,D=y.startY-w.startY;u.resize({left:l+x,top:d+D,bottom:0,right:0}),u.setPadding({startY:w.startY,endY:y.startY,startX:w.startX,endX:y.startX}),r&&this._commandService.executeCommand(dt.id,{...r&1?{sheetViewStartColumn:0,offsetX:0}:null,...r&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:l,top:d+D,width:x,bottom:0}),m.updateScroll({actualScrollX:w.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),f.resize({left:l+x,top:d,height:D,right:0}),f.updateScroll({actualScrollY:w.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),h.resize({left:l,top:d,width:x,height:D}),h.updateScroll({actualScrollX:w.startX,actualScrollY:w.startY}),p.resize({left:0,top:d,width:l,height:D}),p.updateScroll({actualScrollY:w.startY}),R.resize({left:0,top:d+D,bottom:0,width:l}),g.resize({left:l,top:0,width:x,height:d}),g.updateScroll({actualScrollX:w.startX}),S.resize({left:l+x,top:0,height:d,right:0}),h.enable(),f.enable(),m.enable(),p.enable(),g.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{[_.SetWorksheetActiveOperation.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id].includes((t==null?void 0:t.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._context.unit.getActiveSheet().getConfig().freeze,{startRow:o=-1,startColumn:r=-1,ySplit:s=0,xSplit:l=0}=n;this._refreshFreeze(o,r,s,l,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(t=>{this._clearFreeze(),this._themeChange(t),this._refreshCurrent()}))}_themeChange(t){this._freezeNormalHeaderColor=t.grey400,this._freezeNormalMainColor=new a.ColorKit(t.grey400).setAlpha(Hd).toRgbString(),this._freezeActiveColor=t.primaryColor,this._freezeHoverColor=t.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{const e={redos:[],undos:[]},n=this._getFreeze();if(!n)return e;const o=r=>{const s=this._context.unit,l=s.getUnitId(),c=s.getActiveSheet().getSheetId();this._refreshFreeze(r.startRow,r.startColumn,r.ySplit,r.xSplit,0);const u={...r,unitId:l,subUnitId:c,resetScroll:!1},h=_.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:_.SetFrozenMutation.id,params:h}],redos:[{id:_.SetFrozenMutation.id,params:u}]}};if(t.id===_.InsertRowCommand.id){const s=t.params.range,l=s.endRow-s.startRow+1;if(s.startRow<=n.startRow){const d={...n,startRow:Math.max(1,n.startRow+l),ySplit:Math.max(1,n.ySplit+l)};return o(d)}}if(t.id===_.InsertColCommand.id){const s=t.params.range,l=s.endColumn-s.startColumn+1;if(s.startColumn<=n.startColumn){const d={...n,startColumn:Math.max(1,n.startColumn+l),xSplit:Math.max(1,n.xSplit+l)};return o(d)}}if(t.id===_.MoveColsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:l}}=t.params,d=r==null?void 0:r.filter(p=>p.range.rangeType===a.RANGE_TYPE.COLUMN&&p.range.startColumn<=s&&s<=p.range.endColumn);if(!(d!=null&&d.length))return e;const c=d[0].range,u={...c,startColumn:l,endColumn:l+c.endColumn-c.startColumn};if(!n||n.startColumn<=0||c.startColumn>=n.startColumn&&u.startColumn>=n.startColumn||c.startColumn===u.startColumn||c.endColumn<n.startColumn&&u.startColumn<n.startColumn)return e;const h=c.endColumn-c.startColumn+1,m=Math.max(Math.min(n.startColumn,c.endColumn+1)-c.startColumn,0);let f,g;u.startColumn>=n.startColumn?(f=Math.max(n.startColumn-m,1),g=Math.max(n.xSplit-m,1)):(f=n.startColumn+h-m,g=n.xSplit+h-m);const S={...n,startColumn:f,xSplit:g};return o(S)}if(t.id===_.MoveRowsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:l}}=t.params,d=r==null?void 0:r.filter(p=>p.range.rangeType===a.RANGE_TYPE.ROW&&p.range.startRow<=s&&s<=p.range.endRow);if(!(d!=null&&d.length))return e;const c=d[0].range,u={...c,startRow:l,endRow:l+c.endRow-c.startRow};if(!n||n.startRow<=0||c.startRow>=n.startRow&&u.startRow>=n.startRow||c.startRow===u.startRow||c.endRow<n.startRow&&u.startRow<n.startRow)return e;const h=c.endRow-c.startRow+1,m=Math.max(Math.min(n.startRow,c.endRow+1)-c.startRow,0);let f,g;u.startRow>=n.startRow?(f=Math.max(n.startRow-m,1),g=Math.max(n.ySplit-m,1)):(f=n.startRow+h-m,g=n.ySplit+h-m);const S={...n,startRow:f,ySplit:g};return o(S)}if(t.id===_.RemoveColCommand.id||t.id===_.RemoveRowCommand.id){const r=t.params,s=r.range;if(s.rangeType===a.RANGE_TYPE.COLUMN&&s.startColumn<n.startColumn){const l=Math.min(n.startColumn,s.endColumn+1)-s.startColumn,d={...n,startColumn:Math.max(1,n.startColumn-l),xSplit:Math.max(1,n.xSplit-l)};return o(d)}if(r.range.rangeType===a.RANGE_TYPE.ROW&&s.startRow<n.startRow){const l=Math.min(n.startRow,s.endRow+1)-s.startRow,d={...n,startRow:Math.max(1,n.startRow-l),ySplit:Math.max(1,n.ySplit-l)};return o(d)}}return e}}))}_commandExecutedListener(){const t=[_.SetFrozenMutation.id,Le.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=this._lastFreeze,o=this._context.unit,r=o.getActiveSheet(),s=e.params,{unitId:l,subUnitId:d}=s;if(!(l===o.getUnitId()&&d===r.getSheetId()))return;const c=r.getConfig().freeze;if(this._lastFreeze=c,c==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:f=0,xSplit:g=0}=c;(!n||n.startRow!==h||n.ySplit!==f)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==g)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,f,g,u)}else if(e.id===_.SetWorksheetRowHeightMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startRow<n.startRow)&&this._refreshCurrent()}else if(e.id===_.SetWorksheetColWidthMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startColumn<n.startColumn)&&this._refreshCurrent()}else if(e.id===_.SetWorksheetRowAutoHeightMutation.id){const n=e.params,o=this._getFreeze();if(o&&o.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<o.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}else if(e.id===_.SetColHiddenMutation.id||e.id===_.SetColVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startColumn>-1&&r.some(s=>s.startColumn<o.startColumn)&&this._refreshCurrent()}else if(e.id===_.SetRowHiddenMutation.id||e.id===_.SetRowVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startRow>-1&&r.some(s=>s.startRow<o.startRow)&&this._refreshCurrent()}}))}_zoomRefresh(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onTransformChangeObservable.add(n=>{n.type===T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._refreshCurrent()})}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,o,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(o=this._rowFreezeMainRect)==null||o.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(l=>{e.onPointerDownObserver.remove(l),e.onPointerMoveObserver.remove(l),e.onPointerLeaveObserver.remove(l)}),e.onPointerEnterObserver.remove(this._moveObserver),e.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(t,e){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrent())==null?void 0:d.skeleton,r=o==null?void 0:o.getNoMergeCellPositionByIndex(t,e);if(o==null)return;if(r!=null&&(!isNaN(r.endX)||!isNaN(r.endY)))return r;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:l}=o;return{startX:s,endX:s,startY:l,endY:l}}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_getSheetObject(){return Me(this._context.unit,this._context)}_refreshFreeze(t,e,n,o,r){var l;const s={startRow:t,startColumn:e,ySplit:n,xSplit:o};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(t,e,n,o,r),(l=this._getSheetObject())==null||l.spreadsheet.makeForceDirty()}};Wn=Nd([ut(1,P.Inject(N.SheetSkeletonManagerService)),ut(2,a.ICommandService),ut(3,P.Inject(_.SelectionManagerService)),ut(4,P.Inject($e)),ut(5,P.Inject(a.ThemeService)),ut(6,P.Inject(_.SheetInterceptorService)),ut(7,P.Inject(P.Injector))],Wn);var Zi=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(Zi||{});const Ld="rgba(0, 0, 0, 0.15)",Ze="rgb(0, 0, 0)",jn="rgb(255, 255, 255, 1)";class Ud extends T.Shape{constructor(e,n){super(e,n);I(this,"_size",12);I(this,"_iconRatio",.4);I(this,"_mode",0);this.setShapeProps(n)}setShapeProps(e){e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),this.transformByState({width:this._size,height:this._size})}_draw(e){this._mode===1&&T.Rect.drawWith(e,{width:this._size,height:this._size,radius:this._size,fill:Ld});const n=this._size*.5*this._iconRatio,o=Math.PI/180*60,r=n*Math.sin(o),s=n*Math.cos(o);T.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Ze})}}var Vd=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,kd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Vd(t,e,o),o},Nt=(i,t)=>(e,n)=>t(e,n,i);const Fd="__SpreadsheetHeaderMenuSHAPEControllerShape__",Wd="__SpreadsheetHeaderMenuMAINControllerShape__",jd="rgba(0, 0, 0, 0.1)";let zn=class extends a.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_hoverRect");I(this,"_hoverMenu");I(this,"_currentColumn",Number.POSITIVE_INFINITY);I(this,"_observers",[]);this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._renderManagerService=n,this._contextMenuService=o,this._commandService=r,this._selectionManagerService=s,this._initialize()}dispose(){var o,r;(o=this._hoverRect)==null||o.dispose(),(r=this._hoverMenu)==null||r.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerEnterObserver.remove(s),e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._hoverRect=new T.Rect(Fd,{fill:jd,evented:!1}),this._hoverMenu=new Ud(Wd,{zIndex:100,visible:!1}),e.addObjects([this._hoverRect,this._hoverMenu],tt),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:o}=e,r=t===0?o:n;this._observers.push(r==null?void 0:r.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var p,R,M;const l=(p=this._sheetSkeletonManagerService.getCurrent())==null?void 0:p.skeleton;if(l==null)return;const d=this._getSheetObject();if(d==null)return;const{rowHeaderWidth:c,columnHeaderHeight:u}=l,{startX:h,startY:m,endX:f,endY:g,column:S}=Mt(s.offsetX,s.offsetY,d.scene,l);if(t===0)(R=this._hoverRect)==null||R.transformByState({width:c,height:g-m,left:0,top:m});else{if(this._currentColumn=S,(M=this._hoverRect)==null||M.transformByState({width:f-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(f-h<u*2){this._hoverMenu.hide();return}const E=u*.8;this._hoverMenu.transformByState({left:f-u,top:u/2-E/2}),this._hoverMenu.setShapeProps({size:E}),this._hoverMenu.show()}})),this._observers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,l;(s=this._hoverRect)==null||s.hide(),(l=this._hoverMenu)==null||l.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Zi.HIGHLIGHT,visible:!0}),t.scene.setCursor(T.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Zi.NORMAL,visible:!1}),t.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(t=>{if(!this._getSheetObject())return;const n=this._currentColumn,o=this._selectionManagerService.getSelectionRanges();if(!!!(o!=null&&o.filter(s=>s.rangeType===a.RANGE_TYPE.COLUMN).find(s=>{const{startColumn:l,endColumn:d}=s;return n>=l&&n<=d}))){const s=this._getSelectionOnColumn(n);this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,s)}t.stopPropagation(),t.preventDefault(),this._contextMenuService.triggerContextMenu(t,le.COL_HEADER_CONTEXT_MENU)}))}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_getSelectionOnColumn(t){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:0,startColumn:t,endRow:n.getRowCount()-1,endColumn:t,rangeType:a.RANGE_TYPE.COLUMN},primary:{startRow:0,startColumn:t,endRow:0,endColumn:t,actualRow:0,actualColumn:t,isMerged:!1,isMergedMainCell:!1},style:null}]}}};zn=kd([a.OnLifecycle(a.LifecycleStages.Rendered,zn),Nt(0,P.Inject(N.SheetSkeletonManagerService)),Nt(1,a.IUniverInstanceService),Nt(2,T.IRenderManagerService),Nt(3,C.IContextMenuService),Nt(4,a.ICommandService),Nt(5,P.Inject(_.SelectionManagerService))],zn);var zd=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Xd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Yd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&zd(t,e,o),o},xt=(i,t)=>(e,n)=>t(e,n,i);const $d="__SpreadsheetHeaderMoveControllerBackground__",Gd="__SpreadsheetHeaderMoveControllerShapeLine__",Zd="rgba(0, 0, 0, 0.1)",Kd="rgb(119, 119, 119)",Qd=4;let Yn=class extends a.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_startOffsetX",Number.NEGATIVE_INFINITY);I(this,"_startOffsetY",Number.NEGATIVE_INFINITY);I(this,"_moveHelperBackgroundShape");I(this,"_moveHelperLineShape");I(this,"_sheetObject");I(this,"_rowOrColumnDownObservers",[]);I(this,"_rowOrColumnMoveObservers",[]);I(this,"_rowOrColumnLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_scrollTimer");I(this,"_changeFromColumn",-1);I(this,"_changeFromRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToRow",-1);this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._renderManagerService=n,this._commandService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._initialize()}dispose(){var r,s;(r=this._moveHelperBackgroundShape)==null||r.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n,scene:o}=t;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(l=>{e.onPointerDownObserver.remove(l),n.onPointerDownObserver.remove(l)}),o.onPointerMoveObserver.remove(this._moveObserver),o.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const t=this._getSheetObject();t!=null&&(this._sheetObject=t,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(t=0){const{spreadsheetColumnHeader:e,spreadsheetRowHeader:n,scene:o}=this._sheetObject,r=t===0?n:e;this._rowOrColumnMoveObservers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var h;const l=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(l==null)return;const{row:d,column:c}=Mt(s.offsetX,s.offsetY,o,l);if(this._checkInHeaderRange(t===0?d:c,t)===!1){o.resetCursor(),this._selectionRenderService.enableSelection();return}o.setCursor(T.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,l;(s=this._moveHelperBackgroundShape)==null||s.hide(),(l=this._moveHelperLineShape)==null||l.hide(),o.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var w;const l=(w=this._sheetSkeletonManagerService.getCurrent())==null?void 0:w.skeleton;if(l==null)return;const{offsetX:d,offsetY:c}=s,u=o.getRelativeCoord(T.Vector2.FromArray([d,c])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:f,column:g}=Mt(s.offsetX,s.offsetY,o,l);let S;t===0?(this._changeFromRow=f,S=T.ScrollTimerType.Y):(this._changeFromColumn=g,S=T.ScrollTimerType.X);const p=this._checkInHeaderRange(t===0?f:g,t);if(p===!1)return;const R=o.getScrollXYByRelativeCoords(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(T.CURSOR_TYPE.GRABBING),o.disableEvent();let M=!1,E;const b=()=>{if(M)return;E=T.ScrollTimer.create(o,S);const y=o.getViewport(j.VIEW_MAIN);E.startScroll(h,m,y),this._scrollTimer=E,M=!0};this._moveObserver=o.onPointerMoveObserver.add(y=>{b();const{offsetX:O,offsetY:x}=y,{x:D,y:W}=o.getRelativeCoord(T.Vector2.FromArray([O,x]));o.setCursor(T.CURSOR_TYPE.GRABBING),this._rowColumnMoving(D,W,p,R,t),E.scrolling(D,W,()=>{this._rowColumnMoving(D,W,p,R,t)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var O,x,D;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableEvent(),this._clearObserverEvent(),(O=this._scrollTimer)==null||O.dispose();const y=this._selectionManagerService.getSelections();if(t===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const A=(x=((y==null?void 0:y.filter(H=>H.range.rangeType===a.RANGE_TYPE.ROW&&H.range.startRow<=this._changeFromRow&&this._changeFromRow<=H.range.endRow))||[])[0])==null?void 0:x.range;A&&this._commandService.executeCommand(_.MoveRowsCommand.id,{fromRange:A,toRange:{...A,startRow:this._changeToRow,endRow:this._changeToRow+A.endRow-A.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const A=(D=((y==null?void 0:y.filter(H=>H.range.rangeType===a.RANGE_TYPE.COLUMN&&H.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=H.range.endColumn))||[])[0])==null?void 0:D.range;A&&this._commandService.executeCommand(_.MoveColsCommand.id,{fromRange:A,toRange:{...A,startColumn:this._changeToColumn,endColumn:this._changeToColumn+A.endColumn-A.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(t,e,n,o,r){var X,q,L,U,F,$,Z;const{scene:s}=this._sheetObject,l=(X=this._sheetSkeletonManagerService.getCurrent())==null?void 0:X.skeleton;if(l==null)return;const{rowHeaderWidth:d,columnHeaderHeight:c,rowTotalHeight:u,columnTotalWidth:h}=l,m=s.getScrollXY(s.getViewport(j.VIEW_MAIN)),{scaleX:f,scaleY:g}=s.getAncestorScale(),S=l.getCellPositionByOffset(t,e,f,g,m),{row:p,column:R}=S,M=l.getNoMergeCellPositionByIndex(p,R),{startX:E,startY:b,endX:w,endY:y}=M,O=this._selectionRenderService.convertRangeDataToSelection(n.range);if(O==null)return;const x=Math.max(f,f),{startX:D,endX:W,startY:A,endY:H,startRow:B,startColumn:z,endRow:Y,endColumn:Q}=O;r===0?(q=this._moveHelperBackgroundShape)==null||q.transformByState({height:H-A,width:h+d,left:0,top:A+(e-this._startOffsetY)/x+m.y-o.y}):(L=this._moveHelperBackgroundShape)==null||L.transformByState({height:u+c,width:W-D,left:D+(t-this._startOffsetX)/x+m.x-o.x,top:0}),(U=this._moveHelperBackgroundShape)==null||U.show();const J=Qd/x;if(r===0){let ee=0;if(p<=B)ee=b-J/2,this._changeToRow=p;else if(p>Y)ee=y-J/2,this._changeToRow=p+1;else return;(F=this._moveHelperLineShape)==null||F.transformByState({height:J,width:h,left:d,top:ee})}else{let ee=0;if(R<=z)ee=E-J/2,this._changeToColumn=R;else if(R>Q)ee=w-J/2,this._changeToColumn=R+1;else return;($=this._moveHelperLineShape)==null||$.transformByState({height:u,width:J,left:ee,top:c})}(Z=this._moveHelperLineShape)==null||Z.show()}_checkInHeaderRange(t,e=0){var l;const n=this._selectionManagerService.getSelections();if(((l=this._selectionManagerService.getCurrent())==null?void 0:l.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return!1;const r=n==null?void 0:n.find(d=>{const c=d.range,{startRow:u,endRow:h,startColumn:m,endColumn:f,rangeType:g}=c;return e===1?t>=m&&t<=f&&a.RANGE_TYPE.COLUMN===g:t>=u&&t<=h&&a.RANGE_TYPE.ROW===g}),s=r==null?void 0:r.range;return r==null||s==null||s.rangeType===a.RANGE_TYPE.ALL||s.rangeType===a.RANGE_TYPE.NORMAL||s.rangeType===a.RANGE_TYPE.ROW&&e!==0||s.rangeType===a.RANGE_TYPE.COLUMN&&e!==1?!1:r}_clearObserverEvent(){const{scene:t}=this._sheetObject;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:t}=this._sheetObject;this._moveHelperBackgroundShape=new T.Rect($d,{fill:Zd,evented:!1,zIndex:100}),this._moveHelperLineShape=new T.Rect(Gd,{fill:Kd,evented:!1,zIndex:100}),t.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],tt)}_disposeBackgroundAndLine(){var t,e;(t=this._moveHelperBackgroundShape)==null||t.dispose(),(e=this._moveHelperLineShape)==null||e.dispose()}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}};Yn=Xd([a.OnLifecycle(a.LifecycleStages.Rendered,Yn),xt(0,P.Inject(N.SheetSkeletonManagerService)),xt(1,a.IUniverInstanceService),xt(2,T.IRenderManagerService),xt(3,a.ICommandService),xt(4,Ie),xt(5,P.Inject(_.SelectionManagerService))],Yn);var Ki=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(Ki||{});const Jd="rgba(120, 120, 120, 0.01)",Qi="rgb(68, 71, 70)",sn=12,Ji=4;class Hr extends T.Shape{constructor(e,n){super(e,n);I(this,"_size",sn);I(this,"_color",Qi);I(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){let{width:n,height:o}=this,r=0,s=0;const l=this.getScene(),{scaleX:d,scaleY:c}=l.getAncestorScale(),u=Math.max(d,c),h=sn/u,m=Ji/u;this.mode===0?(n=m,r=h-m):(o=m,s=h-m),T.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:Jd}),T.Rect.drawWith(e,{width:n,height:o,fill:Qi,radius:m}),e.save(),e.transform(1,0,0,1,r,s),T.Rect.drawWith(e,{width:n,height:o,fill:Qi,radius:m}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:sn,height:this.size}):this.transformByState({width:this.size,height:sn}),this}}var qd=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,tu=(i,t,e,n)=>{for(var o=n>1?void 0:n?eu(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&qd(t,e,o),o},qi=(i,t)=>(e,n)=>t(e,n,i);const nu="__SpreadsheetHeaderResizeControllerShapeRow__",iu="__SpreadsheetHeaderResizeControllerShapeColumn__",Lr="__SpreadsheetHeaderResizeControllerShapeHelper__",Ur="rgb(199, 199, 199)",ou=2;let Xn=class extends a.Disposable{constructor(t,e,n,o){super();I(this,"_currentRow",0);I(this,"_currentColumn",0);I(this,"_rowResizeRect");I(this,"_columnResizeRect");I(this,"_observers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_resizeHelperShape");I(this,"_startOffsetX",Number.POSITIVE_INFINITY);I(this,"_startOffsetY",Number.POSITIVE_INFINITY);this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._editorBridgeService=o,this._init()}dispose(){var o,r;(o=this._rowResizeRect)==null||o.dispose(),this._rowResizeRect=null,(r=this._columnResizeRect)==null||r.dispose(),this._columnResizeRect=null;const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_init(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._rowResizeRect=new Hr(nu,{visible:!1,mode:Ki.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Hr(iu,{visible:!1,mode:Ki.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],tt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:o,scene:r}=e,s=t===0?n:o;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((l,d)=>{var O;const c=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(c==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=c,{startX:m,startY:f,endX:g,endY:S,row:p,column:R}=Mt(l.offsetX,l.offsetY,r,c),M=bn(l.offsetX,l.offsetY,r),{scaleX:E,scaleY:b}=r.getAncestorScale(),w=Math.max(E,b),y=sn/w;if(t===0){let x=f-y/2;if(M.y<=f+y/2&&M.y>=f)this._currentRow=p-1;else if(M.y>=S-y/2&&M.y<=S)this._currentRow=p,x=S-y/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const D=u/3;this._rowResizeRect.transformByState({left:u/2-D/2,top:x}),this._rowResizeRect.setShapeProps({size:D}),this._rowResizeRect.show()}else{let x=m-y/2;if(M.x<=m+y/2&&M.x>=m)this._currentColumn=R-1;else if(M.x>=g-y/2&&M.x<=g)this._currentColumn=R,x=g-y/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const D=h*.7;this._columnResizeRect.transformByState({left:x,top:h/2-D/2}),this._columnResizeRect.setShapeProps({size:D}),this._columnResizeRect.show()}})),this._observers.push(s==null?void 0:s.onPointerLeaveObserver.add((l,d)=>{var c,u;(c=this._rowResizeRect)==null||c.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(t=0){const e=this._getSheetObject(),{scene:n}=e,o=t===0?this._rowResizeRect:this._columnResizeRect;o!=null&&(this.disposeWithMe(a.toDisposable(o.onPointerEnterObserver.add(()=>{o!=null&&(o.show(),n.setCursor(t===0?T.CURSOR_TYPE.ROW_RESIZE:T.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(a.toDisposable(o.onPointerLeaveObserver.add(()=>{o!=null&&(o.hide(),n.resetCursor())}))),this.disposeWithMe(a.toDisposable(o.onPointerDownObserver.add((r,s)=>{var q,L,U,F,$,Z,ee;const l=(q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:q.skeleton;if(l==null)return;const d=this._getSheetObject(),{scene:c}=d,u=c.getEngine(),h=(u==null?void 0:u.height)||0,m=(u==null?void 0:u.width)||0,f=c.getViewport(j.VIEW_MAIN),g=(((U=(L=f==null?void 0:f.getScrollBar())==null?void 0:L.horizonBarRect)==null?void 0:U.height)||0)+10,S=((($=(F=f==null?void 0:f.getScrollBar())==null?void 0:F.verticalBarRect)==null?void 0:$.width)||0)+10,p=bn(r.offsetX,r.offsetY,c),{scaleX:R,scaleY:M}=c.getAncestorScale();this._startOffsetX=p.x,this._startOffsetY=p.y;const E=l.getOffsetByPositionX(this._currentColumn),b=l.getOffsetByPositionY(this._currentRow),w=l.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let y=!1,O=0,x=0;const{columnTotalWidth:D,rowHeaderWidth:W,rowTotalHeight:A,columnHeaderHeight:H}=l,B=m>D+W?m:D+W,z=h>A+H?h:A+H,Y=Math.max(R,M),Q=Ji/Y;t===0?this._resizeHelperShape=new T.Rect(Lr,{width:B,height:Q,fill:Ur,left:0,top:b-Q/2}):this._resizeHelperShape=new T.Rect(Lr,{width:Q,height:z,fill:Ur,left:E-Q/2,top:0});const J=((Z=this._columnResizeRect)==null?void 0:Z.left)||0,X=((ee=this._rowResizeRect)==null?void 0:ee.top)||0;c.addObject(this._resizeHelperShape,tt),c.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:T.DeviceInputEventType.PointerDown}),this._moveObserver=c.onPointerMoveObserver.add(ne=>{var qe,Ce,un,hn,mn,fn;const de=c.getRelativeCoord(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),fe=c.getScrollXYByRelativeCoords(de,f),be=bn(ne.offsetX,ne.offsetY,c),{x:Te,y:De}=be,{scaleX:Je,scaleY:ve}=c.getAncestorScale(),he=Math.max(Je,ve),se=Ji/he;O=Te-this._startOffsetX-se/2,x=De-this._startOffsetY-se/2,Math.abs(t===0?x:O)>=ou&&(y=!0),t===0?(x>h-g+fe.y-w.startY&&(x=h-g+fe.y-w.startY),x<-(w.endY-w.startY)+2&&(x=-(w.endY-w.startY)+2),y&&((qe=this._resizeHelperShape)==null||qe.transformByState({top:b+x}),(Ce=this._rowResizeRect)==null||Ce.transformByState({top:X+x+se/2}),(un=this._rowResizeRect)==null||un.show(),c.setCursor(T.CURSOR_TYPE.ROW_RESIZE))):(O>m-S+fe.x-w.startX&&(O=m-S+fe.x-w.startX),O<-(w.endX-w.startX)+2&&(O=-(w.endX-w.startX)+2),y&&((hn=this._resizeHelperShape)==null||hn.transformByState({left:E+O}),(mn=this._columnResizeRect)==null||mn.transformByState({left:J+O+se/2}),(fn=this._columnResizeRect)==null||fn.show(),c.setCursor(T.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=c.onPointerUpObserver.add(ne=>{var be,Te,De;const de=this._getSheetObject();if(de==null)return;this._clearObserverEvent(),(be=this._resizeHelperShape)==null||be.dispose(),this._resizeHelperShape=null;const{scene:fe}=de;fe.enableEvent(),y&&(fe.resetCursor(),(Te=this._rowResizeRect)==null||Te.hide(),(De=this._columnResizeRect)==null||De.hide(),t===0?this._commandService.executeCommand(_.DeltaRowHeightCommand.id,{deltaY:x,anchorRow:this._currentRow}):this._commandService.executeCommand(_.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(a.toDisposable(o.onDblclickObserver.add(()=>{var r;if(t===0){const s=this._getSheetObject(),{scene:l}=s;l.resetCursor(),this._commandService.executeCommand(_.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(r=this._rowResizeRect)==null||r.hide()}}))))}_clearObserverEvent(){const t=this._getSheetObject(),{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return Me(this._context.unit,this._context)}};Xn=tu([qi(1,P.Inject(N.SheetSkeletonManagerService)),qi(2,a.ICommandService),qi(3,we)],Xn);var eo=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(eo||{});const an=12,ru=.4;class Vr extends T.Shape{constructor(e,n,o){super(e,n);I(this,"_size",an);I(this,"_iconRatio",ru);I(this,"_hovered",!0);I(this,"_hasPrevious",!0);I(this,"_hasNext",!0);I(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>o==null?void 0:o())}setShapeProps(e){e.type!==void 0&&(this._unhideType=e.type),e.hovered!==void 0&&(this._hovered=e.hovered),e.hasPrevious!==void 0&&(this._hasPrevious=e.hasPrevious),e.hasNext!==void 0&&(this._hasNext=e.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(e){this._unhideType===0?this._drawOnRow(e):this._drawOnCol(e)}_drawOnRow(e){this._hovered&&(!this._hasNext||!this._hasPrevious?T.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:jn}):T.Rect.drawWith(e,{width:this._size,height:2*this._size,stroke:Ze,fill:jn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&T.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:Ze}),this._hasNext){const l=this._hasPrevious?3:1;T.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size*l/2+s},{x:this._size/2-s,y:this._size*l/2-r},{x:this._size/2+s,y:this._size*l/2-r}]],fill:Ze})}}_drawOnCol(e){this._hovered&&(!this._hasNext||!this._hasPrevious?T.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:jn}):T.Rect.drawWith(e,{width:2*this._size,height:this._size,stroke:Ze,fill:jn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&T.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:Ze}),this._hasNext){const l=this._hasPrevious?3:1;T.RegularPolygon.drawWith(e,{pointsGroup:[[{x:r+this._size*l/2,y:this._size/2},{x:-s+this._size*l/2,y:this._size/2-s},{x:-s+this._size*l/2,y:this._size/2+s}]],fill:Ze})}}}var su=Object.defineProperty,au=Object.getOwnPropertyDescriptor,lu=(i,t,e,n)=>{for(var o=n>1?void 0:n?au(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&su(t,e,o),o},Br=(i,t)=>(e,n)=>t(e,n,i);const kr="__SpreadsheetHeaderUnhideSHAPEControllerShape__",cu=[_.SetRowHiddenMutation.id,_.SetRowVisibleMutation.id,_.SetColHiddenMutation.id,_.SetColVisibleMutation.id];let to=class extends a.RxDisposable{constructor(t,e,n){super();I(this,"_shapes",{cols:[],rows:[]});this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._init()}get _workbook(){return this._context.unit}dispose(){super.dispose(),this._clearShapes()}_init(){let t="";this._context.unit.activeSheet$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(this._clearShapes(),!e){t="";return}t=e.getSheetId(),this._update(this._workbook,e)}),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!cu.includes(e.id)||!e.params||!e.params.unitId||e.params.subUnitId!==t)return;const n=this._workbook,o=n.getSheetBySheetId(e.params.subUnitId);o&&this._update(n,o)}))}_update(t,e){var m;const n=(m=this._sheetSkeletonManagerService.getUnitSkeleton(t.getUnitId(),e.getSheetId()))==null?void 0:m.skeleton;if(!n)return;const o=e.getHiddenRows(),r=e.getHiddenCols(),s=this._getSheetObject(),{scene:l}=s,d=e.getRowCount(),c=o.map(f=>{const{startRow:g,endRow:S}=f,p=Ai(g,0,l,n),R=g!==0,M=S!==d-1;return new Vr(kr,{type:eo.ROW,hovered:!1,hasPrevious:R,hasNext:M,top:p.startY-(R?an:0),left:p.startX-an},()=>this._commandService.executeCommand(_.SetSpecificRowsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[f]}))}),u=e.getColumnCount(),h=r.map(f=>{const{startColumn:g,endColumn:S}=f,p=Ai(0,g,l,n),R=g!==0,M=S!==u-1;return new Vr(kr,{type:eo.COLUMN,hovered:!1,hasPrevious:R,hasNext:M,top:20-an,left:p.startX-(R?an:0)},()=>this._commandService.executeCommand(_.SetSpecificColsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[f]}))});l.addObjects(h,xo),l.addObjects(c,xo),this._clearShapes(),this._shapes={cols:h,rows:c}}_clearShapes(){this._shapes.cols.forEach(t=>t.dispose()),this._shapes.rows.forEach(t=>t.dispose()),this._shapes={cols:[],rows:[]}}_getSheetObject(){return Me(this._workbook,this._context)}};to=lu([Br(1,P.Inject(N.SheetSkeletonManagerService)),Br(2,a.ICommandService)],to);var du=Object.defineProperty,uu=Object.getOwnPropertyDescriptor,hu=(i,t,e,n)=>{for(var o=n>1?void 0:n?uu(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&du(t,e,o),o},no=(i,t)=>(e,n)=>t(e,n,i);let $n=class extends a.Disposable{constructor(i,t,e){super(),this._markSelectionService=i,this._commandService=t,this._sheetSkeletonManagerService=e,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[ye.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{i.includes(t.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,o)=>{n.exits.includes(t.id)&&this._markSelectionService.removeShape(o)})}))}_addRefreshListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};$n=hu([a.OnLifecycle(a.LifecycleStages.Steady,$n),no(0,P.Inject(Wt)),no(1,a.ICommandService),no(2,P.Inject(N.SheetSkeletonManagerService))],$n);var mu=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,gu=(i,t,e,n)=>{for(var o=n>1?void 0:n?fu(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&mu(t,e,o),o},io=(i,t)=>(e,n)=>t(e,n,i);let Gn=class extends a.Disposable{constructor(t,e,n){super();I(this,"_initialize",()=>{const t=new a.DisposableCollection;this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{t.dispose();const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(o=>{t.add(a.toDisposable(o.selectionMoved$.subscribe(r=>{if(!r)return;const s=o.model.getRange(),l={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},d={startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn,rangeType:s.rangeType};if(l.startRow===d.startRow&&l.startColumn===d.startColumn||d.startRow<0||d.startColumn<0)return;const c={fromRange:l,toRange:d};this._commandService.executeCommand(_.MoveRangeCommand.id,c)})))})})))});this._selectionRenderService=t,this._selectionManagerService=e,this._commandService=n,this._initialize()}};Gn=gu([a.OnLifecycle(a.LifecycleStages.Steady,Gn),io(0,P.Inject(Ie)),io(1,P.Inject(_.SelectionManagerService)),io(2,P.Inject(a.ICommandService))],Gn);var Su=Object.defineProperty,_u=Object.getOwnPropertyDescriptor,pu=(i,t,e,n)=>{for(var o=n>1?void 0:n?_u(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Su(t,e,o),o},rt=(i,t)=>(e,n)=>t(e,n,i);let Zn=class extends a.Disposable{constructor(i,t,e,n,o,r,s,l){super(),this._sheetSkeletonManagerService=i,this._univerInstanceService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._themeService=s,this._definedNamesService=l,this._initialize()}_initialize(){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=i.getActiveSheet(),e=this._getSheetObject();if(e==null)return;this._initViewMainListener(e),this._initRowHeader(e),this._initColumnHeader(e),this._initLeftTop(e),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener(),this._initDefinedNameListener();const n=i.getUnitId(),o=t.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:o})}_initDefinedNameListener(){this.disposeWithMe(a.toDisposable(this._definedNamesService.focusRange$.subscribe(async i=>{if(i==null)return;const{unitId:t}=i;let{formulaOrRefString:e}=i;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(t!==n.getUnitId()||(e.substring(0,1)===K.operatorToken.EQUALS&&(e=e.substring(1)),!K.isReferenceStrings(e)))return;const r=await this._getSelections(n,t,e);this._selectionManagerService.replace(r),this._commandService.executeCommand(_.ScrollToCellOperation.id,r[0].range)})))}async _getSelections(i,t,e){const n=e.split(",");let o=i.getActiveSheet();const r=[];for(let s=0;s<n.length;s++){const l=n[s].trim(),d=K.deserializeRangeWithSheet(l.trim());if(s===0){const u=i.getSheetBySheetName(d.sheetName);u&&o.getSheetId()!==u.getSheetId()&&(o=u,await this._commandService.executeCommand(_.SetWorksheetActivateCommand.id,{subUnitId:o.getSheetId(),unitId:t}))}if(o.getName()!==d.sheetName)continue;let c=null;if(s===n.length-1){const u=d.range,{startRow:h,startColumn:m,endRow:f,endColumn:g}=u;c=_.getPrimaryForRange({startRow:h,startColumn:m,endRow:f,endColumn:g},o)}r.push({range:d.range,style:_.getNormalSelectionStyle(this._themeService),primary:c})}return r}_getActiveViewport(i){const t=this._getSheetObject();return t==null?void 0:t.scene.getActiveViewportByCoord(T.Vector2.FromArray([i.offsetX,i.offsetY]))}_initViewMainListener(i){const{spreadsheet:t}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(e,t.zIndex+1,a.RANGE_TYPE.NORMAL,this._getActiveViewport(e)),e.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(a.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),t=this._selectionManagerService.getCurrent();i==null||(t==null?void 0:t.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){const t=i.map(e=>{const n=this._selectionRenderService.convertSelectionRangeToData(e);return n.style=_.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(t)}_initRowHeader(i){const{spreadsheetRowHeader:t,spreadsheet:e}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,a.RANGE_TYPE.ROW,this._getActiveViewport(n),T.ScrollTimerType.Y),n.button!==2&&o.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:t,spreadsheet:e}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,a.RANGE_TYPE.COLUMN,this._getActiveViewport(n),T.ScrollTimerType.X),n.button!==2&&o.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:t}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{var l;const o=(l=this._sheetSkeletonManagerService.getCurrent())==null?void 0:l.skeleton;if(o==null)return;this._selectionRenderService.reset();const r=this._getAllRange(o),s=this._selectionRenderService.convertSelectionRangeToData(r);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),e.button!==2&&n.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null){for(const t of i){if(t==null)continue;const e=this._selectionRenderService.convertSelectionRangeToData(t);this._selectionRenderService.addControlToCurrentByRangeData(e)}this._syncDefinedNameRange(i)}}))),this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)}))),this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveStart$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)})))}_syncDefinedNameRange(i){if(i.length===0)return;const t=i[i.length-1],e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet();this._definedNamesService.setCurrentRange({range:t.range,unitId:e.getUnitId(),sheetId:n.getSheetId()})}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,_.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,_.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,_.SelectionMoveType.MOVE_END)})}_move(i,t){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),o=e.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(_.SetSelectionsOperation.id,{unitId:n,subUnitId:o,type:t,pluginName:(r==null?void 0:r.pluginName)||_.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>_.convertSelectionDataToRange(s))})}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_initCommandListener(){const i=[Le.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:t,sheetId:e,skeleton:n}=i,o=this._renderManagerService.getRenderById(t);if(o==null)return;const{scene:r}=o,s=r.getViewport(j.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,r,s);const l=this._selectionManagerService.getCurrent(),d=(l==null?void 0:l.pluginName)||_.NORMAL_SELECTION_PLUGIN_NAME;if((l==null?void 0:l.unitId)===t&&l.sheetId===e){const c=this._selectionManagerService.getSelections();c!=null&&this._refreshSelection(c)}else this._selectionManagerService.setCurrentSelection({pluginName:d,unitId:t,sheetId:e});d===_.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getAllRange(i){return{range:{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:this._getZeroRange(i).primary,style:null}}_getZeroRange(i){const t=i.mergeData;return _.transformCellDataToSelectionData(0,0,t)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};Zn=pu([a.OnLifecycle(a.LifecycleStages.Rendered,Zn),rt(0,P.Inject(N.SheetSkeletonManagerService)),rt(1,a.IUniverInstanceService),rt(2,a.ICommandService),rt(3,T.IRenderManagerService),rt(4,Ie),rt(5,P.Inject(_.SelectionManagerService)),rt(6,P.Inject(a.ThemeService)),rt(7,K.IDefinedNamesService)],Zn);const Ke={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,t)=>{const e=i.get(a.ICommandService),n=i.get(a.IUndoRedoService),o=i.get(a.IUniverInstanceService),r=i.get(C.IConfirmService),s=i.get(a.LocaleService),l=t.unitId,d=t.subUnitId,c=t.selections,u=_.getAddMergeMutationRangeByType(c,t.value),h=o.getUniverSheetInstance(l).getSheetBySheetId(d),m=[],f=[],g=sr(h,u);if(g&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const S={unitId:l,subUnitId:d,ranges:u},p={unitId:l,subUnitId:d,ranges:u},R=_.RemoveMergeUndoMutationFactory(i,S),M=_.AddMergeUndoMutationFactory(i,p);if(R.ranges.length>0&&m.push({id:_.RemoveWorksheetMergeMutation.id,params:R}),m.push({id:_.AddWorksheetMergeMutation.id,params:p}),f.push({id:_.RemoveWorksheetMergeMutation.id,params:M}),R.ranges.length>0&&f.push({id:_.AddWorksheetMergeMutation.id,params:R}),g){const y=ar(i,l,h,u);m.unshift(...y.redos),f.push(...y.undos)}const E=_.AddMergeRedoSelectionsOperationFactory(i,t,u);E&&m.push(E);const b=_.AddMergeUndoSelectionsOperationFactory(i,t);return b&&f.push(b),a.sequenceExecute(m,e).result?(n.pushUndoRedo({unitID:l,undoMutations:f,redoMutations:m}),!0):!1}},Fr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const t=i.get(a.ICommandService),n=i.get(_.SelectionManagerService).getSelectionRanges(),o=Oi(Mn.MergeAll,n);if(!(o!=null&&o.length))return!1;const s=i.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const d=s.getUnitId(),c=l.getSheetId();return t.executeCommand(Ke.id,{selections:o,unitId:d,subUnitId:c})}},Wr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const t=i.get(a.ICommandService),n=i.get(_.SelectionManagerService).getSelectionRanges(),o=Oi(Mn.MergeVertical,n);if(!(o!=null&&o.length))return!1;const s=i.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const d=s.getUnitId(),c=l.getSheetId();return t.executeCommand(Ke.id,{value:a.Dimension.COLUMNS,selections:o,unitId:d,subUnitId:c})}},jr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const t=i.get(a.ICommandService),n=i.get(_.SelectionManagerService).getSelectionRanges(),o=Oi(Mn.MergeHorizontal,n);if(!(o!=null&&o.length))return!1;const s=i.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const d=s.getUnitId(),c=l.getSheetId();return t.executeCommand(Ke.id,{value:a.Dimension.ROWS,selections:o,unitId:d,subUnitId:c})}},oo={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endColumn:d.getColumnCount()-1};const u=f=>f.endRow-f.startRow;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:oo.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.DeleteRangeMoveLeftCommand.id):!0}},Kn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endRow:d.getRowCount()-1};for(let f=c.startRow;f<=c.endRow;f++)if(d.getRowFiltered(f)&&await t.confirm({id:Kn.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const u=f=>f.endColumn-f.startColumn;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:Kn.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.DeleteRangeMoveUpCommand.id):!0}},Qn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endRow:d.getRowCount()-1};for(let f=c.startRow;f<=c.endRow;f++)if(d.getRowFiltered(f)&&await t.confirm({id:Qn.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const u=f=>f.endColumn-f.startColumn;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:Qn.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.InsertRangeMoveDownCommand.id):!0}},ro={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endColumn:d.getColumnCount()-1};const u=f=>f.endRow-f.startRow;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:ro.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.InsertRangeMoveRightCommand.id):!0}},zr={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(Jt);return e.applyType=t.type,!0}},Yr={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(i,t)=>{var c;const e=i.get(_.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(c=e.getLast())==null?void 0:c.range),!n)return!1;const o=i.get(a.ICommandService),r=i.get(a.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,d=l.getVisibleRows();if(Ko(d,[n])){const u=i.get(C.IConfirmService),h=i.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await o.executeCommand(_.RemoveRowCommand.id,{range:n}),!0}},Xr={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(i,t)=>{var c;const e=i.get(_.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(c=e.getLast())==null?void 0:c.range),!n)return!1;const o=i.get(a.ICommandService),r=i.get(a.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,d=l.getVisibleCols();if(Qo(d,[n])){const u=i.get(C.IConfirmService),h=i.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await o.executeCommand(_.RemoveColCommand.id,{range:n}),!0}},$r={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(i,t)=>{const{subUnitId:e}=t,n=i.get(C.IConfirmService),o=i.get(a.ICommandService),r=i.get(a.LocaleService);return await n.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await o.executeCommand(_.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},At=P.createIdentifier("univer.sheetbar-service");class vu extends a.Disposable{constructor(){super();I(this,"renameId$");I(this,"removeId$");I(this,"scroll$");I(this,"scrollX$");I(this,"addSheet$");I(this,"_renameId$");I(this,"_removeId$");I(this,"_scroll$");I(this,"_scrollX$");I(this,"_addSheet$");I(this,"_currentHandler",null);this._renameId$=new k.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new k.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new k.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new k.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new k.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,a.toDisposable(()=>{this._currentHandler=null})}}const Gr={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async i=>(i.get(At).triggerSheetBarMenu(),!0)},Zr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(i,t)=>{const e=i.get(At);return t&&e.setRenameId(t.subUnitId),!0}};var xe=function(){return xe=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(i[o]=t[o])}return i},xe.apply(this,arguments)},Cu=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(i);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(i,n[o])&&(e[n[o]]=i[n[o]]);return e},pe=V.forwardRef(function(i,t){var e=i.icon,n=i.id,o=i.className,r=i.extend,s=Cu(i,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=V.useRef("_".concat(Mu()));return Kr(e,"".concat(n),{defIds:e.defIds,idSuffix:d.current},xe({ref:t,className:l},s),r)});function Kr(i,t,e,n,o){return V.createElement(i.tag,xe(xe({key:t},Iu(i,e,o)),n),(Ru(i,e).children||[]).map(function(r,s){return Kr(r,"".concat(t,"-").concat(i.tag,"-").concat(s),e,void 0,o)}))}function Iu(i,t,e){var n=xe({},i.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var o=t.defIds;return!o||o.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],l=r[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ru(i,t){var e,n=t.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?xe(xe({},i),{children:i.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?xe(xe({},o),{attrs:xe(xe({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):i}function Mu(){return Math.random().toString(36).substring(2,8)}pe.displayName="UniverIcon";var bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qr=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"autofill",ref:t,icon:bu}))});Qr.displayName="Autofill";const Tu=Qr;var Eu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Jr=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"check-mark-single",ref:t,icon:Eu}))});Jr.displayName="CheckMarkSingle";const ln=Jr;var wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},qr=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"close-single",ref:t,icon:wu}))});qr.displayName="CloseSingle";const yu=qr;var Ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.22297.954345C1.3529.929358 1.51542.914795 1.7147.914795H6.85715C7.0561.914795 7.21986.929297 7.35152.959681 7.48737.991031 7.5967 1.04983 7.67995 1.13863 7.76349 1.22774 7.81571 1.34646 7.84615 1.48343L7.84671 1.48597C7.87164 1.62058 7.88612 1.79252 7.88612 2.00111V7.16269C7.88612 7.36211 7.87154 7.52439 7.84667 7.6587 7.82039 7.79533 7.76169 7.91004 7.67831 7.9934 7.59462 8.0771 7.48565 8.13006 7.35692 8.16096 7.22966 8.1915 7.06561 8.20599 6.87627 8.20599H1.7147C1.52177 8.20599 1.36349 8.19641 1.23252 8.17122 1.09967 8.14567.98914 8.09813.90398 8.0134.818184 7.93285.765734 7.8172.735395 7.68573.705177 7.55478.68573 7.38178.68573 7.16269V1.9581C.68573 1.7541.700286 1.58699.725186 1.45253.751461 1.31589.810166 1.20119.893537 1.11782.978617 1.03274 1.08895.98522 1.22033.954901L1.22297.954345zM2.02733 2.07424C1.95064 2.07854 1.91191 2.09755 1.89153 2.11849 1.86949 2.1517 1.85476 2.19738 1.85473 2.25901L1.86389 3.92571H3.72054V2.07424H2.02733zM4.8991 2.07901V3.92571H6.70756V2.20184C6.70756 2.15684 6.7041 2.12531 6.69899 2.10487 6.69675 2.09591 6.69467 2.09093 6.69349 2.08853 6.68344 2.08345 6.66389 2.07901 6.61819 2.07901H4.8991zM1.86466 5.08037L1.87384 6.90902C1.87384 6.95115 1.87723 6.98219 1.8825 7.00371 1.8864 7.01961 1.89067 7.02788 1.8933 7.03179 1.8933 7.03179 1.89686 7.03365 1.8996 7.03479 1.90589 7.03741 1.91476 7.04025 1.92666 7.04282 1.95062 7.04799 1.98341 7.05133 2.02535 7.05133H3.72532V5.08037H1.86466zM4.8991 5.08037V7.05133H6.55606C6.63148 7.05133 6.67174 7.04228 6.68909 7.03374 6.69039 7.03177 6.69349 7.02643 6.69691 7.01502 6.70311 6.99436 6.70756 6.96264 6.70756 6.91894V5.08037H4.8991zM8.65114 7.83368C8.78108 7.80869 8.94359 7.79413 9.14288 7.79413H14.2853C14.4843 7.79413 14.648 7.80863 14.7797 7.83902 14.9155 7.87037 15.0249 7.92916 15.1081 8.01797 15.1917 8.10707 15.2439 8.2258 15.2743 8.36277L15.2749 8.36531C15.2998 8.49991 15.3143 8.67185 15.3143 8.88045V14.042C15.3143 14.2414 15.2997 14.4037 15.2748 14.538 15.2486 14.6747 15.1899 14.7894 15.1065 14.8727 15.0228 14.9564 14.9138 15.0094 14.7851 15.0403 14.6578 15.0708 14.4938 15.0853 14.3044 15.0853H9.14288C8.94995 15.0853 8.79166 15.0757 8.6607 15.0506 8.52785 15.025 8.41732 14.9775 8.33216 14.8927 8.24636 14.8122 8.19391 14.6965 8.16358 14.5651 8.13336 14.4341 8.11391 14.2611 8.11391 14.042V8.83744C8.11391 8.63343 8.12847 8.46633 8.15337 8.33186 8.17964 8.19523 8.23835 8.08053 8.32172 7.99716 8.4068 7.91208 8.51713 7.86456 8.64851 7.83424L8.65114 7.83368zM9.45551 8.95357C9.37882 8.95788 9.34009 8.97689 9.3197 8.99782 9.29767 9.03103 9.28294 9.07672 9.28291 9.13834L9.29206 10.805H11.1487V8.95357H9.45551zM12.3273 8.95835V10.805H14.1357V9.08118C14.1357 9.03618 14.1323 9.00465 14.1272 8.98421 14.1249 8.97524 14.1228 8.97026 14.1217 8.96786 14.1116 8.96278 14.0921 8.95835 14.0464 8.95835H12.3273zM9.29283 11.9597L9.30202 13.7884C9.30202 13.8305 9.30541 13.8615 9.31068 13.883 9.31457 13.8989 9.31885 13.9072 9.32148 13.9111L9.32448 13.9127 9.32778 13.9141C9.33407 13.9167 9.34293 13.9196 9.35484 13.9222 9.3788 13.9273 9.41159 13.9307 9.45353 13.9307H11.1535V11.9597H9.29283zM12.3273 11.9597V13.9307H13.9842C14.0597 13.9307 14.0999 13.9216 14.1173 13.9131 14.1186 13.9111 14.1217 13.9058 14.1251 13.8944 14.1313 13.8737 14.1357 13.842 14.1357 13.7983V11.9597H12.3273z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.46247 2.15033C9.46247 1.74649 9.78985 1.41911 10.1937 1.41911H12.3873C13.5988 1.41911 14.581 2.40124 14.581 3.61276V5.80641C14.581 6.21025 14.2536 6.53762 13.8498 6.53762 13.4459 6.53762 13.1185 6.21025 13.1185 5.80641V3.61276C13.1185 3.20893 12.7912 2.88154 12.3873 2.88154H10.1937C9.78985 2.88154 9.46247 2.55417 9.46247 2.15033zM2.88154 10.1937C2.88154 9.78986 2.55416 9.46248 2.15032 9.46248 1.74648 9.46248 1.4191 9.78986 1.4191 10.1937V12.3873C1.4191 13.5988 2.40123 14.581 3.61275 14.581H5.8064C6.21024 14.581 6.53761 14.2536 6.53761 13.8498 6.53761 13.4459 6.21024 13.1186 5.8064 13.1186H3.61275C3.20892 13.1186 2.88154 12.7912 2.88154 12.3873V10.1937z"}}]}]},es=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"convert-single",ref:t,icon:Ou}))});es.displayName="ConvertSingle";const Nu=es;var xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.78662 6.17993C7.12169 6.17993 7.39331 6.45156 7.39331 6.78662V10.7301C7.39331 11.0652 7.12169 11.3368 6.78662 11.3368 6.45156 11.3368 6.17993 11.0652 6.17993 10.7301V6.78662C6.17993 6.45156 6.45156 6.17993 6.78662 6.17993zM9.82007 6.78662C9.82007 6.45156 9.54844 6.17993 9.21338 6.17993 8.87831 6.17993 8.60669 6.45156 8.60669 6.78662V10.7301C8.60669 11.0652 8.87831 11.3368 9.21338 11.3368 9.54844 11.3368 9.82007 11.0652 9.82007 10.7301V6.78662z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57094 1.32642C6.34938 1.32642 6.14544 1.44719 6.03894 1.64148L5.21395 3.14648H1.93311C1.59804 3.14648 1.32642 3.41811 1.32642 3.75317C1.32642 4.08824 1.59804 4.35986 1.93311 4.35986H2.84314V14.0669C2.84314 14.402 3.11476 14.6736 3.44983 14.6736H12.5502C12.8852 14.6736 13.1569 14.402 13.1569 14.0669V4.35986H14.0669C14.402 4.35986 14.6736 4.08824 14.6736 3.75317C14.6736 3.41811 14.402 3.14648 14.0669 3.14648H10.7895L9.98357 1.64602C9.87785 1.4492 9.67252 1.32642 9.44911 1.32642H6.57094ZM9.4122 3.14648L9.08632 2.53979H6.93024L6.59767 3.14648H9.4122ZM4.05652 4.35986V13.4602H11.9435V4.35986H4.05652Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ts=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"delete-single",ref:t,icon:xu}))});ts.displayName="DeleteSingle";const Au=ts;var Du={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]}]},ns=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"dropdown-single",ref:t,icon:Du}))});ns.displayName="DropdownSingle";const is=ns;var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0 0H16V16H0z",opacity:.01}},{tag:"path",attrs:{fill:"currentColor",d:"M8.09973 1.50049C4.51022 1.50049 1.59973 4.41098 1.59973 8.00049C1.59973 11.59 4.51022 14.5005 8.09973 14.5005C11.6892 14.5005 14.5997 11.59 14.5997 8.00049C14.5997 4.41098 11.6892 1.50049 8.09973 1.50049ZM10.4995 10.4701L9.5419 10.4657L8.09971 8.74643L6.65897 10.4643L5.69993 10.4686C5.63609 10.4686 5.58386 10.4179 5.58386 10.3526C5.58386 10.325 5.59402 10.2989 5.61143 10.2771L7.49904 8.02824L5.61143 5.7808C5.59402 5.75904 5.58386 5.73292 5.58386 5.70536C5.58386 5.64152 5.63609 5.58929 5.69993 5.58929L6.65897 5.59364L8.09971 7.31295L9.54045 5.59509L10.498 5.59074C10.5619 5.59074 10.6141 5.64152 10.6141 5.70681C10.6141 5.73438 10.604 5.76049 10.5865 5.78225L8.70183 8.02969L10.588 10.2786C10.6054 10.3003 10.6156 10.3265 10.6156 10.354C10.6156 10.4179 10.5633 10.4701 10.4995 10.4701Z",fillRule:"evenodd",clipRule:"evenodd"}}]},os=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"error-single",ref:t,icon:Pu}))});os.displayName="ErrorSingle";const rs=os;var Hu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.6905 4.78738C2.01709 4.61737 2.41966 4.7443 2.58967 5.07089C2.75217 5.38305 3.00913 5.69251 3.36183 5.98156C4.36103 6.80048 6.03866 7.37872 7.99833 7.37872C9.958 7.37872 11.6356 6.80049 12.6348 5.98157C12.9875 5.69251 13.2445 5.38304 13.407 5.0709C13.577 4.7443 13.9796 4.61737 14.3062 4.78737C14.6327 4.95738 14.7597 5.35995 14.5897 5.68654C14.329 6.18726 13.9448 6.63187 13.48 7.01281C13.4365 7.04842 13.3923 7.08356 13.3473 7.11821L14.8065 8.57746C15.0669 8.83781 15.0669 9.25992 14.8065 9.52027C14.5462 9.78062 14.124 9.78062 13.8637 9.52027L12.1741 7.83063C11.6495 8.08125 11.0697 8.28368 10.451 8.43104L10.9916 10.4486C11.0869 10.8042 10.8759 11.1698 10.5202 11.2651C10.1646 11.3604 9.79902 11.1493 9.70373 10.7937L9.13044 8.6541C8.7607 8.69234 8.38239 8.71205 7.99833 8.71205C7.61155 8.71205 7.2306 8.69206 6.85837 8.65329L6.28486 10.7937C6.18957 11.1494 5.82401 11.3604 5.46837 11.2651C5.11272 11.1698 4.90167 10.8043 4.99696 10.4486L5.53804 8.42923C4.92309 8.28224 4.34666 8.0808 3.82483 7.8317L2.13636 9.52018C1.87602 9.78053 1.45391 9.78053 1.19355 9.52018C0.933204 9.25983 0.933203 8.83772 1.19355 8.57737L2.65127 7.11965C2.60559 7.08453 2.56072 7.04892 2.51667 7.01281C2.05184 6.63186 1.66764 6.18725 1.40699 5.68655C1.23698 5.35996 1.36391 4.95739 1.6905 4.78738Z"}}]},ss=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"eyelash-single",ref:t,icon:Hu}))});ss.displayName="EyelashSingle";const Lu=ss;var Uu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.48334 4.89587C5.35517 4.89587 5.26008 4.777 5.28822 4.65196L5.37367 4.27223C5.47369 3.84311 5.65731 3.4768 5.93107 3.18085 6.23007 2.85761 6.67323 2.71538 7.21663 2.71538 7.41772 2.71538 7.63284 2.73908 7.86113 2.78378 7.88014 2.7875 7.89899 2.79139 7.91771 2.79543 8.12915 2.84113 8.35624 2.74611 8.43956 2.54647L8.66692 2.00173C8.75382 1.79351 8.65103 1.55537 8.43507 1.49007 8.40283 1.48032 8.36953 1.47045 8.33516 1.46047 8.0467 1.37763 7.70317 1.3335 7.29999 1.3335 6.2394 1.3335 5.44639 1.60069 4.89385 2.10573 4.32912 2.62202 3.92814 3.3605 3.70338 4.33753L2.25629 10.5523C2.18051 10.8899 2.08525 11.253 1.96769 11.6425 1.849 12.0347 1.70655 12.4208 1.54146 12.7986 1.37502 13.1773 1.18738 13.5375.978805 13.8784.912697 13.9865.8444 14.0896.773916 14.1876.684332 14.3122.753952 14.4944.905805 14.5167 1.5556 14.6123 2.23715 14.4376 2.60122 13.8909 2.74587 13.6737 2.88704 13.426 3.02434 13.1464 3.3856 12.411 3.72447 11.3716 4.03792 10.0188L4.88825 6.37667C4.90938 6.28616 4.99007 6.22214 5.08301 6.22214H7.04403C7.22895 6.22214 7.38976 6.09538 7.43296 5.91557L7.55939 5.3893C7.61982 5.13775 7.42917 4.89587 7.17046 4.89587H5.48334zM13.7403 5.0817L11.9317 7.33096 10.8281 5.13886C10.7615 4.99145 10.6146 4.89673 10.4529 4.89673H9.73214C9.4277 4.89673 9.22847 5.21561 9.36195 5.48923L10.8281 8.41635 8.21708 11.5106C7.98512 11.7771 8.17444 12.1929 8.5278 12.1929H9.10532C9.22597 12.1929 9.37975 12.1436 9.45801 12.0518L11.53 9.62616 12.5369 11.9223C12.5978 12.0844 12.7522 12.1929 12.9254 12.1929H13.7193C14.0023 12.1929 14.161 11.9788 14.0619 11.7137L12.592 8.64761C12.592 8.64761 14.8202 5.81675 15.0205 5.54025 15.2159 5.27062 15.0215 4.89673 14.6886 4.89673H14.0854C13.9467 4.89673 13.8525 4.9502 13.7403 5.0817z"}}]}]},as=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"fx-single",ref:t,icon:Uu}))});as.displayName="FxSingle";const Vu=as;var Bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.74717 2.0944C8.74717 1.68671 8.41279 1.3562 8.00032 1.3562C7.58785 1.3562 7.25347 1.68671 7.25347 2.0944V7.26186H2.02541C1.61294 7.26186 1.27856 7.59237 1.27856 8.00007C1.27856 8.40777 1.61294 8.73827 2.02541 8.73827H7.25347V13.9057C7.25347 14.3134 7.58785 14.6439 8.00032 14.6439C8.41279 14.6439 8.74717 14.3134 8.74717 13.9057V8.73827H13.975C14.3874 8.73827 14.7218 8.40777 14.7218 8.00007C14.7218 7.59237 14.3874 7.26186 13.975 7.26186H8.74717V2.0944Z"}}]}]},ls=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"increase-single",ref:t,icon:Bu}))});ls.displayName="IncreaseSingle";const cs=ls;var ku={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0.629584 3.99986C1.13729 3.4922 1.9604 3.49224 2.46806 3.99995L7.57569 9.10806C7.81 9.3424 8.18992 9.3424 8.42424 9.10808L13.5323 3.99998C14.04 3.4923 14.8631 3.4923 15.3708 3.99998C15.8785 4.50766 15.8785 5.33078 15.3708 5.83846L9.41415 11.7951C8.63307 12.5762 7.36669 12.5762 6.58565 11.7951L0.629497 5.83834C0.121839 5.33063 0.121879 4.50752 0.629584 3.99986Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},ds=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"more-down-single",ref:t,icon:ku}))});ds.displayName="MoreDownSingle";const Jn=ds;var Fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.45493 2.80093C5.74783 2.49409 6.2227 2.49409 6.5156 2.80093L11.0156 7.51523C11.3085 7.82207 11.3085 8.31956 11.0156 8.6264L6.44488 13.27C6.15199 13.5768 5.67711 13.5768 5.38422 13.27C5.09133 12.9631 5.09133 12.4656 5.38422 12.1588L9.28804 8.20898C9.36409 8.13203 9.36517 8.00855 9.29047 7.93029L5.45493 3.9121C5.16204 3.60526 5.16204 3.10777 5.45493 2.80093Z",fillRule:"evenodd",clipRule:"evenodd"}}]},us=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"more-single",ref:t,icon:Fu}))});us.displayName="MoreSingle";const hs=us;var Wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.69,y:12.25,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.74646 2.1642C7.34284 1.65121 6.85947 1.28205 6.38447 1.09593C5.86863 0.893787 5.15166 0.852126 4.70047 1.42917C4.29842 1.94344 4.33082 2.70249 4.57691 3.50395C4.68808 3.8661 4.86846 4.22254 5.12522 4.56617C5.13695 4.58185 5.14927 4.5968 5.16211 4.61102C5.17152 4.6214 5.18122 4.63139 5.19115 4.64096C5.20459 4.65393 5.21855 4.66618 5.23296 4.6777L3.5064 6.40422C3.26756 6.64306 3.26756 7.03033 3.5064 7.26919L7.23756 11.0004C7.47648 11.2392 7.86375 11.2392 8.1026 11.0004L12.8329 6.27001C13.0717 6.03117 13.0717 5.6439 12.8329 5.40505L9.10172 1.67387C8.86288 1.43503 8.47561 1.43503 8.23676 1.67387L7.74646 2.1642ZM7.46162 4.50638C7.47252 4.57574 7.48163 4.64652 7.4888 4.71868C7.52232 5.05481 7.82194 5.30013 8.15807 5.26661C8.4942 5.23311 8.73954 4.93345 8.70601 4.59732C8.65786 4.11463 8.54251 3.6666 8.37892 3.26169L8.66928 2.97135L11.5354 5.83753L10.6106 6.76237H4.87824L7.40802 4.2326C7.42885 4.32128 7.44684 4.41255 7.46162 4.50638ZM6.87284 3.03784C6.57441 2.62008 6.22261 2.34634 5.93815 2.23487C5.80233 2.18165 5.71528 2.17827 5.67638 2.18335C5.6725 2.18387 5.66929 2.18443 5.6666 2.18497L5.6619 2.18607C5.64166 2.21954 5.53594 2.45979 5.74626 3.1449C5.81241 3.36036 5.92262 3.58602 6.09307 3.81761L6.87284 3.03784Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.1932 11.5463C12.6454 11.5463 13.012 11.1797 13.012 10.7275C13.012 10.4475 12.6981 9.92821 12.459 9.5733C12.3299 9.38173 12.0564 9.38174 11.9274 9.57331C11.6883 9.92822 11.3744 10.4475 11.3744 10.7275C11.3744 11.1797 11.741 11.5463 12.1932 11.5463Z"}}]}]},ms=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"paint-bucket",ref:t,icon:Wu}))});ms.displayName="PaintBucket";const ju=ms;var zu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.40051 8.00049C1.40051 4.41098 4.311 1.50049 7.90051 1.50049C11.49 1.50049 14.4005 4.41098 14.4005 8.00049C14.4005 11.59 11.49 14.5005 7.90051 14.5005C4.311 14.5005 1.40051 11.59 1.40051 8.00049ZM7.31368 5.3379L7.56087 9.33424H8.24066L8.49816 5.3379L8.51876 4.12252H7.28278L7.31368 5.3379ZM7.07678 11.0646C7.07678 11.5693 7.44758 11.8783 7.90077 11.8783C8.35396 11.8783 8.72476 11.5693 8.72476 11.0646C8.72476 10.5805 8.35396 10.2612 7.90077 10.2612C7.44758 10.2612 7.07678 10.5805 7.07678 11.0646Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fs=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"warning-single",ref:t,icon:zu}))});fs.displayName="WarningSingle";const gs=fs,Yu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),v.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),v.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),v.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),v.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),v.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),v.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),v.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),v.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),v.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),v.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),v.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),v.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),v.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),v.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),v.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),v.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),v.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),v.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),v.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),v.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),v.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),v.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),v.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),v.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),v.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),v.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),Xu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),v.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),v.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),v.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),v.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),v.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),v.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),v.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),v.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),v.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),v.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),v.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),v.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),v.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),v.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),v.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),v.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),v.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),v.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),v.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),v.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),v.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),v.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),v.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),v.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),v.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),v.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),v.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),$u=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),v.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),v.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),v.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),v.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),v.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),v.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),v.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),v.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),v.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),v.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),v.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),v.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),v.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),v.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),v.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),v.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),v.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),v.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),v.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Gu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),v.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),v.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),v.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),v.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),v.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),v.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),v.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),v.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),v.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),v.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),v.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),v.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),v.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),v.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),v.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),v.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),v.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),v.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),v.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),v.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),v.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),v.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),v.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),v.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),v.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),v.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),v.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),v.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),v.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),v.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),v.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),v.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),v.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),v.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),v.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),v.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),v.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),v.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),v.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),v.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),v.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),v.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),v.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),v.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),v.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),v.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),v.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),Zu=()=>v.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),Ku=()=>v.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),v.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),v.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),v.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),v.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),v.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),v.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),v.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),v.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),v.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),v.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),v.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),v.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),v.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),v.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),v.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),v.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),v.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),Qu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),v.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),v.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),v.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),v.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),v.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),v.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),v.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),v.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),v.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),v.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),v.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),v.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),v.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),v.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),v.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),v.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),v.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),v.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),v.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),Ju=()=>v.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),v.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),v.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),v.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),v.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),v.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),v.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),v.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),v.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),v.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),v.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),v.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),v.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),v.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),v.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),v.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),v.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),v.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),v.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),v.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),qu=()=>v.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),Ss=()=>v.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function _s(i){const{type:t=a.BorderStyleTypes.THIN}=i;switch(t){case a.BorderStyleTypes.DASH_DOT:return v.jsx(Yu,{});case a.BorderStyleTypes.DASH_DOT_DOT:return v.jsx(Xu,{});case a.BorderStyleTypes.DASHED:return v.jsx($u,{});case a.BorderStyleTypes.HAIR:return v.jsx(Gu,{});case a.BorderStyleTypes.MEDIUM:return v.jsx(Zu,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return v.jsx(Ku,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return v.jsx(Qu,{});case a.BorderStyleTypes.MEDIUM_DASHED:return v.jsx(Ju,{});case a.BorderStyleTypes.THICK:return v.jsx(qu,{});case a.BorderStyleTypes.THIN:return v.jsx(Ss,{});default:return v.jsx(Ss,{})}}const ke={uiPluginSheetsBorderPanel:"univer-ui-plugin-sheets-border-panel",uiPluginSheetsBorderPanelPosition:"univer-ui-plugin-sheets-border-panel-position",uiPluginSheetsBorderPanelPositionItem:"univer-ui-plugin-sheets-border-panel-position-item",uiPluginSheetsBorderPanelPositionItemActive:"univer-ui-plugin-sheets-border-panel-position-item-active",uiPluginSheetsBorderPanelStyles:"univer-ui-plugin-sheets-border-panel-styles",uiPluginSheetsBorderPanelBoard:"univer-ui-plugin-sheets-border-panel-board",uiPluginSheetsBorderPanelButton:"univer-ui-plugin-sheets-border-panel-button",uiPluginSheetsBorderPanelMoreIcon:"univer-ui-plugin-sheets-border-panel-more-icon"},ps=`${wt}_BORDER_PANEL_COMPONENT`,vs=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],eh=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function th(i){var d;const t=G.useDependency(C.ComponentManager),e=G.useDependency(_.BorderStyleManagerService),{onChange:n,value:o}=i;function r(c,u){n==null||n({...o,[u]:c})}function s(c){const u=t.get(c);return u&&v.jsx(u,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function l(c){c.stopPropagation()}return v.jsxs("section",{className:ke.uiPluginSheetsBorderPanel,children:[v.jsx("div",{className:ke.uiPluginSheetsBorderPanelPosition,children:vs.map(c=>v.jsx("div",{className:e.getBorderInfo().type===c.value?`${ke.uiPluginSheetsBorderPanelPositionItemActive} ${ke.uiPluginSheetsBorderPanelPositionItem}`:ke.uiPluginSheetsBorderPanelPositionItem,onClick:u=>{u.stopPropagation(),r(c.value,"type")},children:s(c.icon)},c.value))}),v.jsxs("div",{className:ke.uiPluginSheetsBorderPanelStyles,children:[v.jsx("div",{children:v.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:v.jsx("section",{className:ke.uiPluginSheetsBorderPanelBoard,onClick:l,children:v.jsx(re.ColorPicker,{onChange:c=>r(c,"color")})}),children:v.jsxs("a",{className:ke.uiPluginSheetsBorderPanelButton,onClick:l,children:[v.jsx(ju,{extend:{colorChannel1:(d=o.color)!=null?d:"rgb(var(--primary-color))"}}),v.jsx("span",{className:ke.uiPluginSheetsBorderPanelMoreIcon,children:v.jsx(Jn,{})})]})})}),v.jsx("div",{children:v.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:v.jsx("section",{onClick:l,children:v.jsx(re.Menu,{children:eh.map(c=>v.jsx(re.MenuItem,{eventKey:c.value.toString(),onClick:()=>r(c.value,"style"),children:v.jsx(_s,{type:c.value})},c.value))})}),children:v.jsxs("a",{className:ke.uiPluginSheetsBorderPanelButton,onClick:l,children:[v.jsx(_s,{type:a.BorderStyleTypes.THIN}),v.jsx("span",{className:ke.uiPluginSheetsBorderPanelMoreIcon,children:v.jsx(Jn,{})})]})})})]})]})}const nh={countBar:"univer-count-bar"},ih=[50,80,100,130,150,170,200,400];function oh(){const i=G.useDependency(a.ICommandService),t=G.useDependency(a.IUniverInstanceService),e=V.useCallback(()=>{const s=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getZoomRatio()*100||100;return Math.round(s)},[t]),[n,o]=V.useState(()=>e());V.useEffect(()=>i.onCommandExecuted(l=>{if(l.id===Le.id||l.id===_.SetWorksheetActivateCommand.id){const d=e();o(d)}}).dispose,[i,e]);function r(s){o(s);const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d=l==null?void 0:l.getActiveSheet();if(d==null)return;const c=s/100;i.executeCommand(Bn.id,{unitId:l.getUnitId(),subUnitId:d.getSheetId(),zoomRatio:c})}return v.jsx(re.Slider,{min:vi[0],value:n,shortcuts:ih,onChange:r})}function rh(i){return v.jsx("section",{className:nh.countBar,children:v.jsx(oh,{})})}const Cs={editorContainer:"univer-editor-container",editorInput:"univer-editor-input"},qn=-1e3,Is={width:0,height:0,top:qn,left:qn},sh=()=>{const[i,t]=V.useState({...Is}),e=G.useDependency(tn),n=G.useDependency(C.IEditorService),o=G.useDependency(a.IContextService),r=C.useObservable(()=>o.subscribeContextValue$(C.DISABLE_AUTO_FOCUS_KEY),!1,void 0,[o,C.DISABLE_AUTO_FOCUS_KEY]),s={id:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}};return V.useEffect(()=>{e.state$.subscribe(l=>{if(l==null)return;const{startX:d=qn,startY:c=qn,endX:u=0,endY:h=0,show:m=!1}=l;if(!m)t({...Is});else{t({width:u-d-T.FIX_ONE_PIXEL_BLUR_OFFSET+2,height:h-c-T.FIX_ONE_PIXEL_BLUR_OFFSET+2,left:d+T.FIX_ONE_PIXEL_BLUR_OFFSET,top:c+T.FIX_ONE_PIXEL_BLUR_OFFSET});const f=n.getEditor(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(f==null)return;const{left:g,top:S,width:p,height:R}=f.getBoundingClientRect();e.setRect({left:g,top:S,width:p,height:R})}})},[]),V.useEffect(()=>{r||e.setFocus(!0)},[r,i]),v.jsx("div",{className:Cs.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:v.jsx(C.TextEditor,{id:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:Cs.editorInput,snapshot:s,cancelDefaultResizeListener:!0,isSheetEditor:!0,isSingle:!1})})},ae={definedName:"univer-defined-name",definedNameDropDown:"univer-defined-name-drop-down",definedNameOverlay:"univer-defined-name-overlay",definedNameOverlayContainer:"univer-defined-name-overlay-container",definedNameOverlayItem:"univer-defined-name-overlay-item",definedNameOverlayItemName:"univer-defined-name-overlay-item-name",definedNameOverlayItemNameForSheet:"univer-defined-name-overlay-item-name-for-sheet",definedNameOverlayItemFormula:"univer-defined-name-overlay-item-formula",definedNameOverlayManager:"univer-defined-name-overlay-manager",definedNameOverlayManagerTitle:"univer-defined-name-overlay-manager-title",definedNameOverlayManagerContent:"univer-defined-name-overlay-manager-content",definedNameContainer:"univer-defined-name-container",definedNameContainerScroll:"univer-defined-name-container-scroll",definedNameContainerAddButton:"univer-defined-name-container-addButton",definedNameContainerAddButtonText:"univer-defined-name-container-addButton-text",definedNameContainerItem:"univer-defined-name-container-item",definedNameContainerItemName:"univer-defined-name-container-item-name",definedNameContainerItemNameForSheet:"univer-defined-name-container-item-name-for-sheet",definedNameContainerItemFormulaOrRefString:"univer-defined-name-container-item-formula-or-refString",definedNameContainerItemUpdate:"univer-defined-name-container-item-update",definedNameContainerItemDelete:"univer-defined-name-container-item-delete",definedNameContainerItemShow:"univer-defined-name-container-item-show",definedNameInput:"univer-defined-name-input",definedNameInputValidation:"univer-defined-name-input-validation"},Rs="DefinedNameContainer",so="AllDefaultWorkbook",Ms={id:"sidebar.operation.defined-name",type:a.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(C.ISidebarService),n=i.get(C.IEditorService),o=i.get(a.LocaleService),r=i.get(a.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{unitId:l}=s;switch(t.value){case"open":n.setOperationSheetUnitId(l),e.open({header:{title:o.t("definedName.featureTitle")},children:{label:Rs},onClose:()=>{n.closeRangePrompt()},width:333});break;case"close":default:e.close();break}return!0}};function ah(i){const t=G.useDependency(a.ICommandService),e=G.useDependency(a.LocaleService),n=G.useDependency(K.IDefinedNamesService),s=G.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=()=>{const m=n.getDefinedNameMap(s);return m?Array.from(Object.values(m)):[]},[d,c]=V.useState(l());V.useEffect(()=>{const m=n.update$.subscribe(()=>{c(l())});return()=>{m.unsubscribe()}},[]);const u=()=>{t.executeCommand(Ms.id,{value:"open"})},h=m=>{n.focusRange(s,m.id)};return v.jsxs("div",{className:ae.definedNameOverlay,children:[v.jsx("div",{className:ae.definedNameOverlayContainer,children:d.map((m,f)=>v.jsxs("div",{className:ae.definedNameOverlayItem,onClick:()=>{h(m)},children:[v.jsx("div",{className:ae.definedNameOverlayItemName,title:m.name,children:m.name}),v.jsx("div",{className:ae.definedNameOverlayItemFormula,title:m.formulaOrRefString,children:m.formulaOrRefString})]},f))}),v.jsxs("div",{className:ae.definedNameOverlayManager,onClick:u,children:[v.jsx("div",{className:ae.definedNameOverlayManagerTitle,children:e.t("definedName.managerTitle")}),v.jsx("div",{className:ae.definedNameOverlayManagerContent,children:e.t("definedName.managerDescription")})]})]})}function lh(){const[i,t]=V.useState(""),e=G.useDependency(K.IDefinedNamesService);return V.useEffect(()=>{const n=e.currentRange$.subscribe(()=>{t(e.getCurrentRangeForString())});return()=>{n.unsubscribe()}},[]),v.jsxs("div",{className:ae.definedName,children:[v.jsx(re.Input,{value:i,type:"text",size:"small",affixWrapperStyle:{border:"none",paddingLeft:"6px",paddingRight:"6px",height:"100%"}}),v.jsx(re.Dropdown,{overlay:v.jsx(ah,{}),children:v.jsx("div",{className:ae.definedNameDropDown,children:v.jsx(Jn,{})})})]})}const ue={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",iconContainerFx:"univer-icon-container-fx",formulaInput:"univer-formula-input",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container"};function ch(){const[i,t]=V.useState(ue.formulaGrey),[e,n]=V.useState(0),o=G.useDependency(On),r=G.useDependency(we),s={id:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:a.HorizontalAlign.UNSPECIFIED,verticalAlign:a.VerticalAlign.UNSPECIFIED,centerAngle:0,vertexAngle:0,wrapStrategy:a.WrapStrategy.WRAP}}};V.useEffect(()=>{const m=r.visible$.subscribe(f=>{t(f.visible?ue.formulaActive:ue.formulaGrey)});return()=>m.unsubscribe()},[r.visible$]);function l(m){if(m==null)return;const f=m.getBoundingClientRect();o.setPosition(f)}function d(){n(e===0?1:0),setTimeout(()=>{o.handleFoldBtnClick(e===1)},150)}function c(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC})}function u(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:T.DeviceInputEventType.PointerDown})}function h(){o.handleFxBtnClick(!0)}return v.jsxs("div",{className:ue.formulaBox,style:{height:e===0?"28px":"82px"},children:[v.jsx("div",{className:ue.nameRanges,children:v.jsx(lh,{})}),v.jsxs("div",{className:ue.formulaBar,children:[v.jsx("div",{className:ue.formulaIcon,children:v.jsxs("div",{className:ue.formulaIconWrapper,children:[v.jsx("span",{className:Pe(ue.iconContainer,ue.iconContainerError,i),onClick:c,children:v.jsx(yu,{})}),v.jsx("span",{className:Pe(ue.iconContainer,ue.iconContainerSuccess,i),onClick:u,children:v.jsx(ln,{})}),v.jsx("span",{className:Pe(ue.iconContainer,ue.iconContainerFx),onClick:h,children:v.jsx(Vu,{})})]})}),v.jsxs("div",{className:ue.formulaInput,children:[v.jsx(C.TextEditor,{id:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,isSheetEditor:!0,resizeCallBack:l,cancelDefaultResizeListener:!0,onContextMenu:m=>m.preventDefault(),className:ue.formulaContent,snapshot:s,isSingle:!1}),v.jsx("div",{className:ue.arrowContainer,onClick:d,children:e===0?v.jsx(is,{}):v.jsx(is,{style:{transform:"rotateZ(180deg)"}})})]})]}),v.jsx(C.ProgressBar,{})]})}const ht={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},dh=()=>{const[,i]=V.useState({});return V.useCallback(()=>i(t=>!t),[])},uh=()=>{var q;const i=G.useDependency(a.ICommandService),t=G.useDependency(N.SheetSkeletonManagerService),e=G.useDependency(a.IUniverInstanceService),n=G.useDependency(T.IRenderManagerService),o=G.useDependency(Ie),r=G.useDependency(Jt),s=G.useDependency(a.LocaleService),[l,d]=V.useState([]),[c,u]=V.useState(!1),[h,m]=V.useState({row:-1,col:-1}),[f,g]=V.useState(oe.SERIES),[S,p]=V.useState(!1),R=()=>{p(!0)},M=()=>{p(!1)},E=dh();if(V.useEffect(()=>{const L=[ye.id,Cn.id,Le.id,_.SetWorksheetActiveOperation.id,_.MoveRangeMutation.id];return i.onCommandExecuted(F=>{F.id===ot.id&&E(),L.includes(F.id)&&m({row:-1,col:-1})}).dispose},[E,i]),V.useEffect(()=>a.toDisposable(r.menu$.subscribe(U=>{d(U.map(F=>({...F,index:U.indexOf(F)})))})).dispose,[r]),V.useEffect(()=>a.toDisposable(r.showMenu$.subscribe(U=>{const{source:F,target:$}=r.autoFillLocation||{source:null,target:null};if(U&&F&&$){const Z=Math.max(F.rows[F.rows.length-1],$.rows[$.rows.length-1]),ee=Math.max(F.cols[F.cols.length-1],$.cols[$.cols.length-1]);m({row:Z,col:ee})}})).dispose,[r]),V.useEffect(()=>a.toDisposable(r.applyType$.subscribe(U=>{g(U)})).dispose,[r]),V.useEffect(()=>{function L(){u(!1)}return document.addEventListener("wheel",L),()=>{document.removeEventListener("wheel",L)}},[c]),h.col<0||h.row<0)return null;const b=Me(e,n);if(!b)return null;const{scene:w}=b,y=(q=t.getCurrent())==null?void 0:q.skeleton,O=o.getViewPort(),x=w==null?void 0:w.scaleX,D=w==null?void 0:w.scaleY,W=w==null?void 0:w.getScrollXY(O);if(!x||!w||!x||!D||!W)return null;const A=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,H=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,B=y==null?void 0:y.convertTransformToOffsetX(A,x,W),z=y==null?void 0:y.convertTransformToOffsetY(H,D,W);if(B==null||z==null)return null;const Y=L=>{u(L)},Q=L=>{i.executeCommand(zr.id,{type:L.value})},J=c||S,X=l.filter(L=>!L.disable);return v.jsx("div",{onMouseEnter:R,onMouseLeave:M,style:{left:`${B+2}px`,top:`${z+2}px`,position:"absolute"},children:v.jsx(re.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:v.jsx("ul",{className:ht.autoFillPopupMenu,children:X.map(L=>v.jsxs("li",{onClick:()=>Q(L),className:ht.autoFillPopupMenuItem,children:[v.jsx("span",{className:ht.autoFillPopupMenuItemIcon,children:L.value===f&&v.jsx(ln,{style:{color:"rgb(var(--green-700, #409f11))"}})}),v.jsx("span",{className:ht.autoFillPopupMenuItemTitle,children:s.t(L.label)})]},L.index))}),visible:c,onVisibleChange:Y,children:v.jsxs("div",{className:Pe(ht.btnContainer,{[ht.btnContainerExpand]:c}),children:[v.jsx(Tu,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),J&&v.jsx(Jn,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},hh=()=>v.jsx("div",{className:ht.operateContainer,children:v.jsx(uh,{})}),ei={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},mh={sheetBarBtn:"univer-sheet-bar-btn"};function ti(i){const{children:t,className:e,style:n,disabled:o=!1,onClick:r,...s}=i,l=d=>{if(o){d.preventDefault();return}r&&r(d)};return v.jsx("button",{className:mh.sheetBarBtn,style:n,disabled:o,onClick:l,...s,children:t})}const st={sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function fh(i){const{style:t}=i,[e,n]=V.useState([]),[o,r]=V.useState(!1),s=G.useDependency(a.IUniverInstanceService),l=G.useDependency(a.ICommandService),d=G.useDependency(At),c=C.useObservable(()=>s.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[]),u=S=>{const{sheetId:p}=S;!p||!c||(S.hidden?l.executeCommand(_.SetWorksheetShowCommand.id,{value:p}):S.selected||l.executeCommand(_.SetWorksheetActivateCommand.id,{unitId:c.getUnitId(),subUnitId:p}),r(!1))},h=V.useCallback(()=>{if(!c)return;const S=c.getSheets(),p=c.getActiveSheet(),R=S.map((M,E)=>({label:M.getName(),index:`${E}`,sheetId:M.getSheetId(),hidden:M.isSheetHidden()===a.BooleanNumber.TRUE,selected:p===M}));n(R)},[c]),m=V.useCallback(()=>l.onCommandExecuted(S=>{switch(S.id){case _.SetWorksheetHideMutation.id:case _.RemoveSheetMutation.id:case _.SetWorksheetNameMutation.id:case _.InsertSheetMutation.id:case _.SetWorksheetOrderMutation.id:case _.SetWorksheetActiveOperation.id:h();break}}),[l,h]);function f(){r(!0)}const g=S=>{r(S)};return V.useEffect(()=>{h();const S=new a.DisposableCollection;return S.add(m()),S.add(d.registerSheetBarMenuHandler({handleSheetBarMenu:f})),()=>S.dispose()},[m,d,h,c]),v.jsx(re.Dropdown,{placement:"topLeft",trigger:["click"],overlay:v.jsx("ul",{className:st.sheetBarMenu,style:{...t},children:e.map(S=>v.jsxs("li",{onClick:()=>u(S),className:S.selected?`${st.sheetBarMenuItem} ${st.sheetBarMenuItemSelect}`:S.hidden?`${st.sheetBarMenuItem} ${st.sheetBarMenuItemHide}`:st.sheetBarMenuItem,children:[v.jsx("span",{className:st.sheetBarMenuItemIcon,children:S.selected?v.jsx(ln,{}):S.hidden?v.jsx(Lu,{}):v.jsx(ln,{})}),v.jsx("span",{className:st.sheetBarMenuItemLabel,children:S.label})]},S.index))}),visible:o,onVisibleChange:g,children:v.jsx(ti,{children:v.jsx(Nu,{})})})}const Ae={slideTabBarContainer:"univer-slide-tab-bar-container",slideTabBar:"univer-slide-tab-bar",slideTabItem:"univer-slide-tab-item",slideTabActive:"univer-slide-tab-active",slideTabSpan:"univer-slide-tab-span",slideTabSpanEdit:"univer-slide-tab-span-edit",slideTabItemDropdown:"univer-slide-tab-item-dropdown"};function gh(i){const{sheetId:t,label:e,color:n,selected:o}=i,[r,s]=V.useState(o),l=G.useDependency(a.ThemeService);V.useEffect(()=>{s(o)},[o]);const d=c=>{const u=l.getCurrentTheme(),h=u.textColor,m=u.colorWhite;return new a.ColorKit(c).isDark()?m:h};return v.jsx("div",{"data-id":t,className:r?`${Ae.slideTabActive} ${Ae.slideTabItem}`:Ae.slideTabItem,style:{backgroundColor:!r&&n?n:"",color:!r&&n?d(n):"",boxShadow:r&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:v.jsx("span",{className:Ae.slideTabSpan,children:e})},t)}const Sh={easeOutStrong(i,t,e,n){return-e*((i=i/n-1)*i*i*i-1)+t},backOut(i,t,e,n,o){return typeof o>"u"&&(o=.7),e*((i=i/n-1)*i*((o+1)*i+o)+1)+t}},_h={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class ph{constructor(t){I(this,"_config");I(this,"_status",0);I(this,"_start",0);I(this,"_handle",0);I(this,"_delayHandle",null);this._config={..._h,...t},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...t){let e=0;return new Promise(n=>{for(let o=0;o<t.length;o++){const r=t[o],s=r._config,l=s.success;s.loop||(s.success=c=>{e++,l&&l.call(r,c),e===t.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let t=Date.now()-this._start;t=t>=this._config.duration?this._config.duration:t;const n=Sh[this._config.type](t,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(t===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class mt{constructor(t,e){I(this,"_slideTabItem");I(this,"_animate");I(this,"_midline",0);I(this,"_translateX");I(this,"_scrollbar");I(this,"_slideTabBar");I(this,"_editMode");I(this,"_placeholder");this._slideTabItem=t,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=e,this._placeholder=null,this._scrollbar=e.getScrollbar(),this.update()}static midline(t){return t.getBoundingRect().x+t.getBoundingRect().width/2}static leftLine(t){return t.getBoundingRect().x}static rightLine(t){return t.getBoundingRect().x+t.getBoundingRect().width}static make(t,e){const n=[];return t.forEach(o=>n.push(new mt(o,e))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var t;(t=this.getEditor())==null||t.focus()}selectAll(){const t=this.getEditor();t&&Dt.keepSelectAll(t)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(t){return this._translateX=t,this._slideTabItem.style.transform=`translateX(${t}px)`,this.getTranslateXDirection()}setEditor(t){let e=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),o=c=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",o),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",l),n.removeEventListener("input",d),n.removeEventListener("keydown",r),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}t&&t(c)}};let r=c=>{n&&(c.stopPropagation(),c.key==="Enter"&&n.blur())};const s=c=>{e=!1},l=c=>{e=!0},d=c=>{if(!n)return;const u=50;setTimeout(()=>{if(e){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),Dt.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",o),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",l),n.addEventListener("input",d),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,Dt.keepSelectAll(n))}}nameCheck(){const t=this._slideTabItem.querySelector("span");if(!t)return!1;const e=t.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(e)}animate(){return{translateX:t=>{this._translateX!==t&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new ph({begin:this._translateX,end:t,receive:e=>{this._slideTabItem.style.transform=`translateX(${e}px)`}}),this._translateX=t,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(t){this._slideTabItem.after(t._slideTabItem||t)}update(){this._midline=mt.midline(this)}disableFixed(){if(this._placeholder){const t=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),t.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const t=document.createElement("div"),e=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),o=this._slideTabItem.querySelector("span");if(this._placeholder=t,this._placeholder.style.width=`${e.width}px`,this._placeholder.style.height=`${e.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,o){const r=getComputedStyle(o).padding;this._slideTabItem.style.padding=r}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${e.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${e.y}px`,this._slideTabItem.style.width=`${e.width}px`,this._slideTabItem.style.height=`${e.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(t),document.body.appendChild(this._slideTabItem)}addEventListener(t,e,n){this._slideTabItem.addEventListener(t,e,n)}removeEventListener(t,e,n){this._slideTabItem.removeEventListener(t,e,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const t=this._slideTabItem.getBoundingClientRect();return t.x+=this._scrollbar.getScrollX(),t}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const t=mt.midline(this);return t>this._midline?1:t<this._midline?-1:0}equals(t){return t&&t._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class vh{constructor(t){I(this,"_slideTabBar");I(this,"_scrollX");const e=t.primeval();this._scrollX=e.scrollLeft,this._slideTabBar=t}scrollX(t){const e=this._slideTabBar.primeval();e.scrollLeft=t,this._scrollX=e.scrollLeft}scrollRight(){const t=this._slideTabBar.primeval();t.scrollLeft=t.scrollWidth,this._scrollX=t.scrollLeft}getScrollX(){return this._scrollX}}const Ut=class Ut{constructor(t){I(this,"_activeTabItemIndex",0);I(this,"_slideTabBar");I(this,"_slideTabItems",[]);I(this,"_config");I(this,"_downActionX",0);I(this,"_moveActionX",0);I(this,"_compareIndex",0);I(this,"_activeTabItem",null);I(this,"_moveAction");I(this,"_upAction");I(this,"_downAction");I(this,"_wheelAction");I(this,"_scrollIncremental",0);I(this,"_compareDirection",0);I(this,"_autoScrollTime",null);I(this,"_slideScrollbar");I(this,"_longPressTimer",null);I(this,"_leftBoundingLine",0);I(this,"_rightBoundingLine",0);I(this,"_leftMoveX",0);I(this,"_rightMoveX",0);var s;if(t.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const e=t.slideTabBarContainer.querySelector(`.${(s=t.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(e==null)throw new Error("not found slide-tab-bar");this._slideTabBar=e,this._slideScrollbar=new vh(this),this._config=t,this._initConfig();let n=0,o=0,r=0;this._downAction=l=>{var y,O,x,D,W,A;if((y=this._activeTabItem)!=null&&y.isEditMode())return;const d=(x=(O=l.target)==null?void 0:O.closest(`.${t.slideTabBarItemClassName}`))==null?void 0:x.getAttribute("data-id"),c=this._slideTabItems.findIndex(H=>H.getId()===d);if(d==null||c===-1)return;if(this._activeTabItemIndex!==c){(D=this._activeTabItem)==null||D.removeEventListener("pointermove",this._moveAction),(W=this._activeTabItem)==null||W.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(l,d);return}if(this._compareIndex=c,this._downActionX=l.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[c],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const u=this._activeTabItem.getSlideTabItem();u==null||u.setPointerCapture(l.pointerId),(A=this._activeTabItem)==null||A.addEventListener("pointerup",this._upAction);const{x:h,width:m}=this._activeTabItem.getBoundingRect(),{x:f,width:g}=this.getBoundingRect(),S=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-S),this._rightBoundingLine=h-S+m-this._downActionX,this._leftMoveX=h-f-S,this._rightMoveX=f+g-(h+m)+S,l.button===2||this._hasEditItem())return;const{pageX:p,pageY:R}=l,M=Date.now(),E=M-r<=Ut.DoubleClickDelay,b=Math.abs(p-n)<10,w=Math.abs(R-o)<10;E&&b&&w&&this._activeTabItem.setEditor(),n=p,o=R,r=M,this._longPressTimer=setTimeout(()=>{var H,B;(H=this._activeTabItem)==null||H.enableFixed(),this._startAutoScroll(),u&&(u.setPointerCapture(l.pointerId),u.style.cursor="move",(B=this._activeTabItem)==null||B.addEventListener("pointermove",this._moveAction))},Ut.LongPressDelay)},this._upAction=l=>{var c,u,h;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const d=(c=this._activeTabItem)==null?void 0:c.getSlideTabItem();d&&(d.style.cursor="",d.releasePointerCapture(l.pointerId),(u=this._activeTabItem)==null||u.removeEventListener("pointermove",this._moveAction),(h=this._activeTabItem)==null||h.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(l,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=l=>{this._activeTabItem&&(this._moveActionX=l.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(l),this._scrollRight(l))},this._wheelAction=l=>{this.setScroll(l.deltaY)},this.addListener()}static checkedSkipSlide(t){let e=t.target;for(;e!=null&&e!==document.body;){if(e.getAttribute("data-slide-skip"))return!0;e=e.parentElement}return!1}static keepLastIndex(t){setTimeout(()=>{const e=window.getSelection();e&&(e.selectAllChildren(t),e.collapseToEnd())})}static keepSelectAll(t){setTimeout(()=>{const e=window.getSelection();if(!e)return;const n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)})}update(t){this._config.currentIndex=t,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let t=0;t<this._slideTabItems.length;t++)this._slideTabItems[t].animate().cancel(),this._slideTabItems[t].translateX(0),this._slideTabItems[t].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const t=this._slideTabBar.parentElement;return t?this._slideTabBar.scrollWidth-t.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.removeEventListener("pointerdown",this._downAction)})}setScroll(t){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t),t>0){const e=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(t){if(t>0){const e=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,l=o.getSlideTabItem().getBoundingClientRect(),d=l.left,c=l.width;return d<s&&d+c+n*2>s?(e=t?d-r.left-n:d+c-s+n,!0):!1}),e}calculateRightScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,l=o.getSlideTabItem().getBoundingClientRect(),d=l.left,c=l.width;return d-n*2<s&&d+c>s?(e=t?d+c-r.left-r.width+n:d-s-n,!0):!1}),e}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let t=0;t<this._slideTabItems.length;t++)if(this._slideTabItems[t].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n>e.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(e.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let t=0;t<this._slideTabItems.length;t++){const e=this._slideTabItems[t],n=this._slideTabItems[t+1];n&&e.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=0;r<t&&!(r>=t);r++)n.push(this._slideTabItems[r]);for(let r=t+1;r<e;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];mt.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=t+1;r<e;r++)n.push(this._slideTabItems[r]);for(let r=0;r<t;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=0;r<n.length;r++){const s=n[r];mt.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=t+r+1,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var e;const t=this._slideTabBar.querySelectorAll(`.${(e=this._config.slideTabBarItemClassName)!=null?e:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=mt.make(t,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};I(Ut,"LongPressDelay",500),I(Ut,"DoubleClickDelay",300);let Dt=Ut;function Ch(){const[i,t]=V.useState([]),[e,n]=V.useState(""),[o,r]=V.useState(""),[s,l]=V.useState(!1),[d,c]=V.useState([0,0]),u=V.useRef({slideTabBar:null}),h=V.useRef(null),m=G.useDependency(a.IUniverInstanceService),f=G.useDependency(a.ICommandService),g=G.useDependency(At),S=G.useDependency(a.LocaleService),p=G.useDependency(C.IConfirmService),R=G.useDependency(Ie),M=G.useDependency(we);G.useInjector();const E=m.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);V.useEffect(()=>{A();const L=b(),U=W(),F=[H(),B(),z(),Y()];return()=>{U.dispose(),L.destroy(),F.forEach($=>$.unsubscribe())}},[]),V.useEffect(()=>{i.length>0&&D()},[i]);const b=()=>{const L=new Dt({slideTabBarClassName:Ae.slideTabBar,slideTabBarItemActiveClassName:Ae.slideTabActive,slideTabBarItemClassName:Ae.slideTabItem,slideTabBarSpanEditClassName:Ae.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(U,F)=>{f.executeCommand(_.SetWorksheetNameCommand.id,{subUnitId:U,name:F})},onSlideEnd:(U,F)=>{f.executeCommand(_.SetWorksheetOrderCommand.id,{order:F})},onChangeTab:(U,F)=>{f.executeCommand(_.SetWorksheetActiveOperation.id,{subUnitId:F,unitId:E.getUnitId()}).then(()=>{U.button===2&&q(!0)})},onScroll:U=>{g.setScroll(U)},onNameCheckAlert:U=>w(U)||y(U)});return u.current.slideTabBar=L,X(L),L},w=L=>{if(L.trim()===""){const U="sheetNameEmptyAlert";return p.open({id:U,title:{title:S.t("sheetConfig.sheetNameErrorTitle")},children:{title:S.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:S.t("button.cancel"),confirmText:S.t("button.confirm"),onClose(){O(),p.close(U)},onConfirm(){O(),p.close(U)}}),!0}return!1},y=L=>{const U=m.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(U.getActiveSheet().getName()===L)return!1;const Z=U.checkSheetName(L);if(Z){const ee="sheetNameRepeatAlert";p.open({id:ee,title:{title:S.t("sheetConfig.sheetNameErrorTitle")},children:{title:S.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:S.t("button.cancel"),confirmText:S.t("button.confirm"),onClose(){p.close(ee),O()},onConfirm(){p.close(ee),O()}})}return Z},O=()=>{R.endSelection(),setTimeout(()=>{var U;const L=(U=u.current.slideTabBar)==null?void 0:U.getActiveItem();L&&(L.focus(),L.selectAll())},0)},x=()=>{var L,U;(U=(L=u.current.slideTabBar)==null?void 0:L.getActiveItem())==null||U.setEditor()},D=()=>{var U;const L=i.findIndex(F=>F.selected);(U=u.current.slideTabBar)==null||U.update(L)},W=()=>f.onCommandExecuted(L=>{switch(L.id){case _.SetTabColorMutation.id:case _.SetWorksheetHideMutation.id:case _.RemoveSheetMutation.id:case _.SetWorksheetNameMutation.id:case _.InsertSheetMutation.id:case _.SetWorksheetOrderMutation.id:case _.SetWorksheetActiveOperation.id:A();break}}),A=()=>{const L=E.getActiveSheet().getSheetId();n(L);const U=E.getSheets(),F=E.getActiveSheet(),$=U.filter(Z=>!Z.isSheetHidden()).map((Z,ee)=>{var ne;return{sheetId:Z.getSheetId(),label:Z.getName(),index:ee,selected:F===Z,color:(ne=Z.getTabColor())!=null?ne:void 0}});t($)},H=()=>g.scroll$.subscribe(L=>{Q(L)}),B=()=>g.scrollX$.subscribe(L=>{var U;(U=u.current.slideTabBar)==null||U.flipPage(L)}),z=()=>g.renameId$.subscribe(()=>{x()}),Y=()=>g.addSheet$.subscribe(()=>{var L;(L=u.current.slideTabBar)==null||L.getScrollbar().scrollRight()}),Q=L=>{const{leftEnd:U,rightEnd:F}=L;let $="";U&&F?$="":U&&!F?$="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!U&&F?$="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!U&&!F&&($="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r($)},J=L=>{g.setScroll({leftEnd:L.isLeftEnd(),rightEnd:L.isRightEnd()})},X=L=>{var $;const U=($=h.current)==null?void 0:$.querySelector(`.${Ae.slideTabBar}`);if(!U)return;new ResizeObserver(()=>{J(L)}).observe(U)},q=L=>{var U,F,$,Z,ee;if(!M.isForceKeepVisible()){if(L){const{left:ne}=(F=(U=h.current)==null?void 0:U.getBoundingClientRect())!=null?F:{},{left:de}=(ee=(Z=($=u.current.slideTabBar)==null?void 0:$.getActiveItem())==null?void 0:Z.getSlideTabItem().getBoundingClientRect())!=null?ee:{};ne!==void 0&&de!==void 0&&c([de-ne,0])}l(L)}};return v.jsx(re.Dropdown,{className:Ae.slideTabItemDropdown,visible:s,align:{offset:d},trigger:["contextMenu"],overlay:v.jsx(C.Menu,{menuType:le.SHEET_BAR,onOptionSelect:L=>{const{label:U,value:F}=L;f.executeCommand(U,{value:F,subUnitId:e}),l(!1)}}),onVisibleChange:q,children:v.jsx("div",{className:Ae.slideTabBarContainer,ref:h,children:v.jsx("div",{className:Ae.slideTabBar,style:{boxShadow:o},children:i.map(L=>V.createElement(gh,{...L,key:L.sheetId,selected:e===L.sheetId}))})})})}const bs=100,Ih=()=>{const[i,t]=V.useState(!0),[e,n]=V.useState(!0),o=G.useDependency(a.ICommandService),r=G.useDependency(At);V.useEffect(()=>{const u=r.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;t(h),n(m)},l=()=>{o.executeCommand(_.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},d=()=>{r.setScrollX(-bs)},c=()=>{r.setScrollX(bs)};return v.jsxs("div",{className:ei.sheetBar,children:[v.jsxs("div",{className:ei.sheetBarOptions,children:[v.jsx(ti,{onClick:l,children:v.jsx(cs,{})}),v.jsx(fh,{})]}),v.jsx(Ch,{}),(!i||!e)&&v.jsxs("div",{className:`${ei.sheetBarOptions} ${ei.sheetBarOptionsDivider}`,children:[v.jsx(ti,{disabled:i,onClick:d,children:v.jsx(hs,{style:{transform:"rotateZ(180deg)"}})}),v.jsx(ti,{disabled:e,onClick:c,children:v.jsx(hs,{})})]})]})};class Rh{constructor(){I(this,"_functions",[{func:K.FUNCTION_NAMES_STATISTICAL.MAX,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.MIN,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_MATH.SUM,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:t=>{var e,n;return((n=(e=t.values.find(o=>o.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1}},{func:K.FUNCTION_NAMES_STATISTICAL.COUNT,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}}]);I(this,"_state$",new k.BehaviorSubject(null));I(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(t){var n;const e={values:[],pattern:null};t==null||t.values.forEach(o=>{const r=this._functions.find(s=>s.func===o.func);r&&(r.filter===void 0||r.filter(t))&&e.values.push(o)}),e.pattern=(n=t==null?void 0:t.pattern)!=null?n:null,this._state$.next(e)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(t){this._functions.push(...t)}}const ao=P.createIdentifier("univer.sheet-status-bar.service"),Pt={statusBar:"univer-status-bar",singleMode:"univer-single-mode",statusBarDiv:"univer-status-bar-div",statisticList:"univer-statistic-list",statisticListColumn:"univer-statistic-list-column",statisticItem:"univer-statistic-item",statisticPicker:"univer-statistic-picker",statisticPickerItem:"univer-statistic-picker-item",statisticMore:"univer-statistic-more"},Mh=[K.FUNCTION_NAMES_MATH.SUM,K.FUNCTION_NAMES_STATISTICAL.AVERAGE,K.FUNCTION_NAMES_STATISTICAL.MIN,K.FUNCTION_NAMES_STATISTICAL.MAX],lo={[K.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[K.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[K.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[K.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[K.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[K.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[K.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},co=i=>{const t=G.useDependency(a.LocaleService),e=G.useDependency(C.IMessageService),n=G.useDependency(C.IClipboardInterfaceService),o=bh(i),r=async()=>{await n.writeText(i.value.toString()),e.show({type:re.MessageType.Success,content:t.t("statusbar.copied")})};return v.jsx(re.Tooltip,{title:t.t("statusbar.clickToCopy"),placement:"top",children:v.jsx("div",{className:Pt.statisticItem,onClick:r,children:v.jsx("span",{children:`${t.t((lo==null?void 0:lo[i.name])||i.name)}: ${o}`})},i.name)})};function bh(i){const{pattern:t,value:e}=i;return typeof e!="number"?"Invalid input":e>=1e8?e.toExponential(2):t&&Mh.includes(i.name)?Sn.format(t,e):e.toLocaleString()}const Ts=800,Th=3,Eh=()=>{const[i,t]=V.useState(window.innerWidth<Ts),[e,n]=V.useState(!0),o=G.useDependency(ao),r=o.getFunctions().map((m,f)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,l]=V.useState(r),d=s.find(m=>m.show&&!m.disable),c=i&&d?[d]:s.filter(m=>m.show&&!m.disable);V.useEffect(()=>{const m=o.state$.subscribe(f=>{const g=f==null?void 0:f.values;if(!g||g.length===0)n(!1);else{n(!0);const S=s.map(p=>{var M;const R=g.find(E=>E.func===p.name);return R?(p.value=R.value,p.disable=!1):p.disable=!0,p.pattern=(M=f==null?void 0:f.pattern)!=null?M:null,p});l(S)}});return()=>{m.unsubscribe()}},[o]);const u=a.debounce(()=>{const m=window.innerWidth<Ts;i!==m&&t(m)},100);V.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(c.length>Th){const m=[];c.forEach((f,g)=>{g%2===0&&m.push(c.slice(g,g+2))}),h=v.jsxs(v.Fragment,{children:[" ",m.map((f,g)=>v.jsxs("div",{className:Pt.statisticListColumn,children:[(f==null?void 0:f[0])&&v.jsx(co,{...f==null?void 0:f[0]},f==null?void 0:f[0].name),(f==null?void 0:f[1])&&v.jsx(co,{...f==null?void 0:f[1]},f==null?void 0:f[1].name)]},`stat-col-${g}`))," "]})}else h=v.jsx(v.Fragment,{children:c.map(m=>v.jsx(co,{...m},m.name))});return e&&v.jsxs("div",{className:Pe(Pt.statusBar,{[Pt.singleMode]:i}),children:[v.jsx("div",{className:Pe(Pt.statisticList),children:h}),v.jsx("div",{className:Pt.statusBarDiv})]})};function wh(){const i=G.useDependency(a.IUniverInstanceService);return C.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[])?v.jsxs("section",{className:xr.sheetContainer,"data-range-selector":!0,children:[v.jsx(Ih,{}),v.jsx(Eh,{}),v.jsx(rh,{})]}):null}function yh(){const i=G.useDependency(a.IUniverInstanceService);return C.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[])?v.jsx(v.Fragment,{children:v.jsx(ch,{})}):null}function Oh(){const i=G.useDependency(a.IUniverInstanceService);return C.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[])?v.jsxs(v.Fragment,{children:[v.jsx(sh,{}),v.jsx(hh,{})]}):null}const uo={width:"100%"},Es=i=>{const{inputId:t,state:e=!1,type:n="range",confirm:o,cancel:r,name:s,formulaOrRefString:l,comment:d="",localSheetId:c=so,hidden:u=!1,id:h}=i,f=G.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),g=G.useDependency(a.LocaleService),S=G.useDependency(K.IDefinedNamesService),p=G.useDependency(K.IFunctionService),R=G.useDependency(K.LexerTreeBuilder);if(f==null)return;const M=f.getUnitId();f.getActiveSheet().getSheetId();const[E,b]=V.useState(s),[w,y]=V.useState(l),[O,x]=V.useState(d),[D,W]=V.useState(c),[A,H]=V.useState(""),[B,z]=V.useState(n),[Y,Q]=V.useState(!0),J=[{label:g.t("definedName.scopeWorkbook"),value:so}],X=Z=>!K.isReferenceStrings(Z);V.useEffect(()=>{Q(!0),b(s),x(d),W(c);let Z=l;l.substring(0,1)===K.operatorToken.EQUALS?z("formula"):X(l)?(z("formula"),Z=K.operatorToken.EQUALS+l):z("range"),y(Z),H("")},[e]),f.getSheetOrders().forEach(Z=>{const ee=f.getSheetBySheetId(Z);J.push({label:(ee==null?void 0:ee.getName())||"",value:Z})});const q=Z=>Z.map(ne=>{var de;return K.serializeRangeToRefString({...ne,sheetName:((de=f.getSheetBySheetId(ne.sheetId))==null?void 0:de.getName())||""})}).join(","),L=Z=>{y(q(Z))},U=Z=>{y(Z||"")},F=()=>{if(E.length===0){H(g.t("definedName.nameEmpty"));return}if(S.getValueByName(M,E)!=null&&(h==null||h.length===0)){H(g.t("definedName.nameDuplicate"));return}if(!a.Tools.isValidParameter(E)||K.isReferenceStringWithEffectiveColumn(E)||!a.Tools.isStartValidPosition(E)&&!T.hasCJKText(E.substring(0,1))){H(g.t("definedName.nameInvalid"));return}if(f.getSheetOrders().map(ee=>{var ne;return((ne=f.getSheetBySheetId(ee))==null?void 0:ne.getName())||""}).includes(E)){H(g.t("definedName.nameSheetConflict"));return}if(w.length===0){H(g.t("definedName.formulaOrRefStringEmpty"));return}if(!Y){H(g.t("definedName.formulaOrRefStringInvalid"));return}if(p.hasExecutor(E.toUpperCase())){H(g.t("definedName.nameConflict"));return}o&&o({id:h||"",name:E,formulaOrRefString:R.convertRefersToAbsolute(w,a.AbsoluteRefType.ALL,a.AbsoluteRefType.ALL),comment:O,localSheetId:D})},$=Z=>{const ee=Z;ee==="formula"&&w.substring(0,1)!==K.operatorToken.EQUALS?(y(`${K.operatorToken.EQUALS}`),y(`${K.operatorToken.EQUALS}`)):w.substring(0,1)===K.operatorToken.EQUALS&&(y(""),y("")),z(ee)};return v.jsxs("div",{className:ae.definedNameInput,style:{display:e?"block":"none"},children:[v.jsx("div",{children:v.jsx(re.Input,{placeholder:g.t("definedName.inputNamePlaceholder"),value:E,allowClear:!0,onChange:b,affixWrapperStyle:uo})}),v.jsx("div",{children:v.jsxs(re.RadioGroup,{value:B,onChange:$,children:[v.jsx(re.Radio,{value:"range",children:g.t("definedName.ratioRange")}),v.jsx(re.Radio,{value:"formula",children:g.t("definedName.ratioFormula")})]})}),v.jsx("div",{style:{display:B==="range"?"block":"none"},children:v.jsx(C.RangeSelector,{value:w,onValid:Q,onChange:L,placeholder:g.t("definedName.inputRangePlaceholder"),id:a.createInternalEditorID(`${t}-rangeSelector`),width:"99%",openForSheetUnitId:M},`${t}-rangeSelector`)}),v.jsx("div",{style:{display:B==="range"?"none":"block"},children:v.jsx(C.TextEditor,{value:w,onValid:Q,onChange:U,id:a.createInternalEditorID(`${t}-editor`),placeholder:g.t("definedName.inputFormulaPlaceholder"),openForSheetUnitId:M,onlyInputFormula:!0,style:{width:"99%"},canvasStyle:{fontSize:10}},`${t}-editor`)}),v.jsx("div",{children:v.jsx(re.Select,{style:uo,value:D,options:J,onChange:W})}),v.jsx("div",{children:v.jsx(re.Input,{affixWrapperStyle:uo,placeholder:g.t("definedName.inputCommentPlaceholder"),value:O,onChange:x})}),v.jsxs("div",{style:{display:A.length===0?"none":"flex"},className:ae.definedNameInputValidation,children:[v.jsx("span",{children:A}),v.jsx(rs,{})]}),v.jsxs("div",{children:[v.jsx(re.Button,{onClick:()=>{r&&r()},children:g.t("definedName.cancel")}),v.jsx(re.Button,{style:{marginLeft:15},type:"primary",onClick:F,children:g.t("definedName.confirm")})]})]})},Nh=()=>{const i=G.useDependency(a.ICommandService),e=G.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=G.useDependency(a.LocaleService),o=G.useDependency(K.IDefinedNamesService),r=G.useDependency(_.SelectionManagerService);if(e==null)return;const s=e.getUnitId(),l=()=>{const A=o.getDefinedNameMap(s);return A?Array.from(Object.values(A)):[]},[d,c]=V.useState(!1),[u,h]=V.useState(l()),[m,f]=V.useState(null),[g,S]=V.useState();V.useEffect(()=>{const A=o.update$.subscribe(()=>{h(l())});return()=>{A.unsubscribe()}},[]);const p=A=>{const{name:H,formulaOrRefString:B,comment:z,localSheetId:Y,hidden:Q}=A;let J=A.id;if(J==null||J.length===0)J=a.Tools.generateRandomId(10),i.executeCommand(_.InsertDefinedNameCommand.id,{id:J,unitId:s,name:H,formulaOrRefString:B,comment:z,localSheetId:Y,hidden:Q});else{const X=o.getValueById(s,J),q={id:J,unitId:s,name:H,formulaOrRefString:B,comment:z,localSheetId:Y,hidden:Q};i.executeCommand(_.SetDefinedNameCommand.id,{unitId:s,oldDefinedName:{...X,unitId:s},newDefinedName:q})}c(!1),f(null)},R=A=>{S(A)};function M(){S(null)}function E(A){const H=o.getValueById(s,A);i.executeCommand(_.RemoveDefinedNameCommand.id,{...H,unitId:s}),S(null)}const b=A=>{o.focusRange(s,A.id)},w=()=>{const A=u.length+1,H=n.t("definedName.defaultName")+A;if(o.getValueByName(s,H)==null)return H;let B=A+1;for(;;){const z=n.t("definedName.defaultName")+B;if(o.getValueByName(s,z)==null)return z;B++}},y=()=>{const A=e.getActiveSheet().getName(),H=r.getSelections();return H==null?"":H.map(z=>K.serializeRangeWithSheet(A,z.range)).join(",")},O=()=>{c(!1),f(null)},x=()=>{c(!0),f(null)},D=A=>{c(!1),f(A)},W=A=>{const H=e.getSheetBySheetId(A);return H==null?"":H.getName()};return v.jsx("div",{className:ae.definedNameContainer,children:v.jsxs("div",{className:ae.definedNameContainerScroll,children:[v.jsxs("div",{children:[v.jsxs("div",{onClick:x,className:ae.definedNameContainerAddButton,style:{display:d?"none":"flex"},children:[v.jsx(cs,{}),v.jsx("span",{className:ae.definedNameContainerAddButtonText,children:n.t("definedName.addButton")})]}),v.jsx(Es,{confirm:p,cancel:O,state:d,inputId:"insertDefinedName",name:w(),formulaOrRefString:y()})]},"insertDefinedName"),u.map((A,H)=>v.jsxs("div",{children:[v.jsxs("div",{onClick:()=>{b(A)},className:ae.definedNameContainerItem,style:{display:A.id===m?"none":"flex"},children:[v.jsxs("div",{title:A.comment,children:[v.jsxs("div",{className:ae.definedNameContainerItemName,children:[A.name,v.jsx("span",{className:ae.definedNameContainerItemNameForSheet,children:A.localSheetId===so||A.localSheetId==null?"":W(A.localSheetId)})]}),v.jsx("div",{className:ae.definedNameContainerItemFormulaOrRefString,children:A.formulaOrRefString})]}),v.jsx(re.Tooltip,{title:n.t("definedName.updateButton"),placement:"top",style:{pointerEvents:"none"},children:v.jsx("div",{className:Pe(ae.definedNameContainerItemUpdate,ae.definedNameContainerItemShow),onClick:()=>{D(A.id)},children:v.jsx(ln,{})})}),v.jsx(re.Tooltip,{title:n.t("definedName.deleteButton"),placement:"top",style:{pointerEvents:"none"},children:v.jsx("div",{className:Pe(ae.definedNameContainerItemDelete,ae.definedNameContainerItemShow),onClick:()=>{R(A.id)},children:v.jsx(Au,{})})})]}),v.jsx(re.Confirm,{visible:g===A.id,onClose:M,onConfirm:()=>{E(A.id)},children:n.t("definedName.deleteConfirmText")}),v.jsx(Es,{confirm:p,cancel:O,state:A.id===m,id:A.id,inputId:A.id+H,name:A.name,formulaOrRefString:A.formulaOrRefString,comment:A.comment,localSheetId:A.localSheetId})]},H))]})})};function xh(i){const t=i.get(_.BorderStyleManagerService),e=_.getCurrentSheetDisabled$(i);return{id:_.SetBorderBasicCommand.id,icon:new k.Observable(n=>{const o="AllBorderSingle",r=i.get(_.BorderStyleManagerService),s=i.get(a.ICommandService).onCommandExecuted(l=>{var m;if(l.id!==_.SetBorderBasicCommand.id)return;const{type:c}=r.getBorderInfo(),u=vs.find(f=>f.value===c),h=(m=u==null?void 0:u.icon)!=null?m:o;n.next(h)});return n.next(o),s.dispose}),group:C.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[C.MenuPosition.TOOLBAR_START],type:C.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:ps,hoverable:!1},value$:t.borderInfo$}],value$:t.borderInfo$,hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:e}}const ni="sheet.menu.clear-selection";function Ah(){return{id:ni,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[C.MenuPosition.CONTEXT_MENU,le.COL_HEADER_CONTEXT_MENU,le.ROW_HEADER_CONTEXT_MENU]}}function Dh(){return{id:_.ClearSelectionContentCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[ni]}}function Ph(){return{id:_.ClearSelectionFormatCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[ni]}}function Hh(){return{id:_.ClearSelectionAllCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[ni]}}const cn="sheet.menu.delete";function Lh(){return{id:cn,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[C.MenuPosition.CONTEXT_MENU]}}function Uh(){return{id:Xr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[cn,le.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function Vh(){return{id:Yr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteRow",positions:[cn,le.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function Bh(){return{id:oo.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[cn]}}function kh(){return{id:Kn.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[cn]}}const ho="sheet.menu.col-insert";function Fh(){return{id:ho,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.COL_HEADER_CONTEXT_MENU]}}const mo="sheet.menu.row-insert";function Wh(){return{id:mo,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.ROW_HEADER_CONTEXT_MENU]}}const dn="sheet.menu.cell-insert";function jh(){return{id:dn,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[C.MenuPosition.CONTEXT_MENU]}}function zh(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertRowBeforeCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[mo,dn],hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Yh(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertRowAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[mo],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Xh(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertColBeforeCommand.id,type:C.MenuItemType.BUTTON,positions:[ho,dn],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function $h(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertColAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[ho],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Gh(){return{id:ro.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[dn]}}function Zh(){return{id:Qn.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[dn]}}function Kh(i){return i.get(_.SelectionManagerService).selectionMoveEnd$.pipe(k.filter(e=>e!=null&&e.length>=2),k.map(e=>{if(!e)return!1;for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++)if(a.Rectangle.intersects(e[n].range,e[o].range))return!0;return!1}))}function Qh(i){const t=_.getCurrentSheetDisabled$(i),e=Kh(i);return{id:Ke.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[C.MenuPosition.TOOLBAR_START],group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SUBITEMS,hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:t.pipe(k.combineLatestWith(e),k.map(([n,o])=>n||o))}}function Jh(i){return{id:Fr.id,type:C.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Ke.id]}}function qh(i){return{id:Wr.id,type:C.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Ke.id]}}function em(i){return{id:jr.id,type:C.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Ke.id]}}function tm(i){return{id:_.RemoveWorksheetMergeCommand.id,type:C.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Ke.id]}}function nm(i){const t=i.get(a.IUniverInstanceService),e=i.get(a.ICommandService);return{id:$r.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.delete",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),d=Array.from(l.values()).filter(c=>c.getConfig().hidden===a.BooleanNumber.FALSE);n.next(d.length===1)}});return n.next(!1),o.dispose})}}function im(){return{id:_.CopySheetCommand.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.copy"}}function om(){return{id:Zr.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.rename"}}function rm(){return{id:_.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[le.SHEET_BAR],type:C.MenuItemType.SELECTOR,selections:[{label:{name:wn,hoverable:!1}}]}}function sm(i){const t=i.get(a.IUniverInstanceService),e=i.get(a.ICommandService);return{id:_.SetWorksheetHideCommand.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.hide",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),d=Array.from(l.values()).filter(c=>c.getConfig().hidden===a.BooleanNumber.FALSE);n.next(d.length===1)}});return n.next(!1),o.dispose})}}function am(i){const t=i.get(a.IUniverInstanceService),e=i.get(a.ICommandService);return{id:Gr.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.unhide",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),d=Array.from(l.values());n.next(d.length===1)}});return n.next(!1),o.dispose})}}const lm={id:_.SetRowHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit9|C.MetaKeys.CTRL_COMMAND},cm={id:_.SetColHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT},dm={id:Ee.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.DOWN}},um={id:Ee.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.UP}},hm={id:Ee.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT,priority:100,preconditions:yo,staticParameters:{direction:a.Direction.LEFT}},mm={id:Ee.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT,priority:100,preconditions:yo,staticParameters:{direction:a.Direction.RIGHT}},fm={id:ct.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:C.KeyCode.TAB,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT,keycode:C.KeyCode.TAB}},gm={id:ct.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:C.KeyCode.TAB|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.LEFT,keycode:C.KeyCode.TAB}},Sm={id:ct.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.DOWN,keycode:C.KeyCode.ENTER}},_m={id:ct.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.UP,keycode:C.KeyCode.ENTER}},pm={id:Ee.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.DOWN,jumpOver:Fe.moveGap}},vm={id:Ee.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.UP,jumpOver:Fe.moveGap}},Cm={id:Ee.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.LEFT,jumpOver:Fe.moveGap}},Im={id:Ee.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Fe.moveGap}},Rm={id:He.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.DOWN}},Mm={id:He.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.UP}},bm={id:He.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.LEFT}},Tm={id:He.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT}},Em={id:He.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.DOWN,jumpOver:Fe.moveGap}},wm={id:He.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.UP,jumpOver:Fe.moveGap}},ym={id:He.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.LEFT,jumpOver:Fe.moveGap}},Om={id:He.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Fe.moveGap}},Nm={id:qo.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:C.KeyCode.A|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{expandToGapFirst:!0,loop:!0}},xm={id:Hi.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.B|C.MetaKeys.CTRL_COMMAND},Am={id:Li.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.I|C.MetaKeys.CTRL_COMMAND},Dm={id:Ui.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.U|C.MetaKeys.CTRL_COMMAND},Pm={id:Vi.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.X|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND},Hm={id:_.ClearSelectionContentCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.DELETE,mac:C.KeyCode.BACKSPACE},Lm={id:Vn.id,description:"shortcut.sheet.zoom-in",binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:.2}},Um={id:a.NilCommand.id,binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND},Vm={id:Vn.id,description:"shortcut.sheet.zoom-out",binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:-.2}},Bm={id:a.NilCommand.id,binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND},km={id:Vn.id,description:"shortcut.sheet.reset-zoom",binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND,preconditions:ie,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},Fm={id:a.NilCommand.id,binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND};var Wm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,zm=(i,t,e,n)=>{for(var o=n>1?void 0:n?jm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Wm(t,e,o),o},ft=(i,t)=>(e,n)=>t(e,n,i);let ii=class extends a.Disposable{constructor(i,t,e,n,o,r,s){super(),this._injector=i,this._componentManager=t,this._layoutService=e,this._commandService=n,this._shortcutService=o,this._menuService=r,this._uiController=s,this._init()}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(ji,Ql)),this.disposeWithMe(i.register(ps,th)),this.disposeWithMe(i.register(wn,re.ColorPicker)),this.disposeWithMe(i.register(fr,C.FontFamily)),this.disposeWithMe(i.register(gr,C.FontFamilyItem)),this.disposeWithMe(i.register(Sr,C.FontSize)),this.disposeWithMe(i.register(Rs,Nh))}_initCommands(){[Fr,Ke,jr,Wr,Vn,He,Ee,ct,Zr,$r,Yr,Xr,nr,ir,dt,er,qo,Pr,_.SetBoldCommand,Zt,ye,xi,Hi,Li,Ui,Vi,Hl,Ll,or,rr,Tn,_.SetItalicCommand,_.SetStrikeThroughCommand,_.SetFontFamilyCommand,_.SetFontSizeCommand,Fi,cr,Wi,dr,ot,Kt,En,ur,hr,mr,_.SetUnderlineCommand,Bn,Le,Gr,zr,Qn,Kn,ro,oo,Ms].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[mc,fc,gc,Sc,_c,pc,vc,Dh,Ph,Hh,Ah,Fh,Wh,jh,zh,Yh,Xh,$h,Vh,wc,Oc,yc,Nc,Uh,xc,Cc,Ac,Lh,Bh,kh,Gh,Zh,Mc,bc,Tc,Ec,Ic,Rc,Jl,ql,ec,tc,nc,ic,oc,rc,sc,ac,lc,xh,Qh,Jh,qh,em,tm,cc,dc,uc,hc,nm,im,om,rm,sm,am].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[dm,um,hm,mm,fm,gm,Sm,_m,pm,vm,Cm,Im,Rm,Mm,bm,Tm,Em,wm,ym,Om,Nm,Lm,Vm,km,Fm,Um,Bm,xm,Am,Dm,Pm,Hm,...ed(),nd,td,id,rd,sd,ad,od,lm,cm].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){const i=this._uiController,t=this._injector;this.disposeWithMe(i.registerComponent(C.DesktopUIPart.HEADER,()=>G.connectInjector(yh,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.FOOTER,()=>G.connectInjector(wh,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.CONTENT,()=>G.connectInjector(Oh,t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_SHEET,i=>{this._injector.get(T.ITextSelectionRenderManager).focus()}))}};ii=zm([a.OnLifecycle(a.LifecycleStages.Ready,ii),ft(0,P.Inject(P.Injector)),ft(1,P.Inject(C.ComponentManager)),ft(2,C.ILayoutService),ft(3,a.ICommandService),ft(4,C.IShortcutService),ft(5,C.IMenuService),ft(6,C.IUIController)],ii);var Ym=Object.defineProperty,Xm=Object.getOwnPropertyDescriptor,$m=(i,t,e,n)=>{for(var o=n>1?void 0:n?Xm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ym(t,e,o),o},gt=(i,t)=>(e,n)=>t(e,n,i);let oi=class extends a.Disposable{constructor(t,e,n,o,r,s,l){super();I(this,"_calculateTimeout",-1);this._univerInstanceService=t,this._selectionManagerService=e,this._functionService=n,this._statusBarService=o,this._commandService=r,this._formulaDataModel=s,this._numfmtService=l,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){const t=a.debounce(e=>{var o;const n=(o=e[e.length-1])==null?void 0:o.primary;this._calculateSelection(e.map(r=>r.range),n)},100);this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===_.SetRangeValuesMutation.id){const n=this._selectionManagerService.getSelections();n&&t(n)}}))}_calculateSelection(t,e){var d;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=n.getUnitId(),r=n.getActiveSheet().getSheetId(),s={},l=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(c=>{const u=c.getConfig();s[c.getSheetId()]={cellData:new a.ObjectMatrix(u.cellData),rowCount:u.rowCount,columnCount:u.columnCount,rowData:u.rowData,columnData:u.columnData}}),t!=null&&t.length){const c=t.map(p=>new K.RangeReferenceObject(p,r,o));c.forEach(p=>{p.setUnitData({[o]:s}),l&&p.setArrayFormulaCellData(K.convertUnitDataToRuntime(l))});const u=this._statusBarService.getFunctions(),h=c.map(p=>p.toArrayValueObject(!1)),m=u.map(p=>{const R=this._functionService.getExecutor(p.func);if(!R)return;const M=R==null?void 0:R.calculate(...h),E=M==null?void 0:M.getValue();if(E)return{func:p.func,value:E}});if(m.every(p=>p===void 0))return;let f=null;if(e){const{actualRow:p,actualColumn:R}=e;f=(d=this._numfmtService.getValue(o,r,p,R))==null?void 0:d.pattern}const S={values:m.filter(p=>p!==void 0),pattern:f};this._statusBarService.setState(S)}else this._statusBarService.setState(null)}_isSingleCell(t){return t.startRow===t.endRow&&t.startColumn===t.endColumn}};oi=$m([a.OnLifecycle(a.LifecycleStages.Ready,oi),gt(0,a.IUniverInstanceService),gt(1,P.Inject(_.SelectionManagerService)),gt(2,K.IFunctionService),gt(3,ao),gt(4,a.ICommandService),gt(5,P.Inject(K.FormulaDataModel)),gt(6,P.Inject(_.INumfmtService))],oi);var Gm=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,Km=(i,t,e,n)=>{for(var o=n>1?void 0:n?Zm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Gm(t,e,o),o},St=(i,t)=>(e,n)=>t(e,n,i);let ri=class extends a.Disposable{constructor(i,t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._univerInstanceService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;i!=null&&(i.getViewport(j.VIEW_MAIN),this.disposeWithMe(a.toDisposable(i.onMouseWheelObserver.add((e,n)=>{if(!e.ctrlKey)return;const o=Math.abs(e.deltaX);let r=o<40?.2:o<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),d=l.getZoomRatio();let c=+Number.parseFloat(`${d+r}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(Bn.id,{zoomRatio:Math.round(c*10)/10,unitId:s.getUnitId(),subUnitId:l.getSheetId()}),e.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const i=[Le.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;const l=n.getConfig().zoomRatio||1;this._updateViewZoom(l)}}))}_updateViewZoom(i){const t=this._getSheetObject();t==null||t.scene.scale(i,i),t==null||t.spreadsheet.makeForceDirty()}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}};ri=Km([a.OnLifecycle(a.LifecycleStages.Rendered,ri),St(0,P.Inject(N.SheetSkeletonManagerService)),St(1,a.IUniverInstanceService),St(2,a.ICommandService),St(3,T.IRenderManagerService),St(4,Ie),St(5,P.Inject(_.SelectionManagerService)),St(6,P.Inject($e))],ri);var Qm=Object.defineProperty,Jm=Object.getOwnPropertyDescriptor,qm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Jm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Qm(t,e,o),o},si=(i,t)=>(e,n)=>t(e,n,i);N.SheetCanvasView=class extends a.RxDisposable{constructor(e,n,o,r){super();I(this,"_scene");I(this,"_fps$",new k.BehaviorSubject(""));I(this,"fps$",this._fps$.asObservable());this._univerInstanceService=e,this._commandService=n,this._renderManagerService=o,this._sheetSkeletonManagerService=r,this._initialize()}_initialize(){this._init()}dispose(){this._fps$.complete()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(e=>this._create(e)),this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(e=>this._dispose(e)),this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._create(e))}_dispose(e){const n=e.getUnitId();this._renderManagerService.removeRender(n)}_create(e){if(!e)return;const n=e.getUnitId();this._renderManagerService.has(n)||this._addNewRender(e)}_addNewRender(e){const n=e.getUnitId(),o=e.getContainer(),r=e.getParentRenderUnitId();if(o!=null&&r!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=o==null&&r!=null;s?this._renderManagerService.createRenderWithParent(n,r):this._renderManagerService.createRender(n);const l=this._renderManagerService.getRenderById(n);if(l==null)return;const{scene:d,engine:c}=l;d.openTransformer(),this._scene=d,d.addLayer(new T.Layer(d,[],0),new T.Layer(d,[],2)),l!=null&&this._addComponent(l,e),e.getShouldRenderLoopImmediately()&&!s&&c.runRenderLoop(()=>{d.render(),this._fps$.next(Math.round(c.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(e,n){const o=this._scene,r=n.getActiveSheet(),s=n.getUnitId(),l=r.getSheetId();this._addViewport(r);const d=new T.Spreadsheet(me.MAIN),c=new T.SpreadsheetRowHeader(me.ROW),u=new T.SpreadsheetColumnHeader(me.COLUMN),h=new T.Rect(me.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});e.mainComponent=d,e.components.set(me.MAIN,d),e.components.set(me.ROW,c),e.components.set(me.COLUMN,u),e.components.set(me.LEFT_TOP,h),o.addObjects([d],No),o.addObjects([c,u,h],tt),o.enableLayerCache(No,tt),this._sheetSkeletonManagerService.setCurrent({sheetId:l,unitId:s})}_addViewport(e){const n=this._scene;if(n==null)return;const{rowHeader:o,columnHeader:r}=e.getConfig(),s=new T.Viewport(j.VIEW_MAIN,n,{left:o.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new T.Viewport(j.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new T.Viewport(j.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:o.width,isWheelPreventDefaultX:!0}),new T.Viewport(j.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new T.Viewport(j.VIEW_COLUMN_RIGHT,n,{left:o.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),new T.Viewport(j.VIEW_LEFT_TOP,n,{left:0,top:0,width:o.width,height:r.height,isWheelPreventDefaultX:!0}),new T.Viewport(j.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new T.Viewport(j.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new T.Viewport(j.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),this.disposeWithMe(a.toDisposable(n.onMouseWheelObserver.add((l,d)=>{if(l.ctrlKey)return;let c=0,u=0;const h=s.limitedScroll();if(l.inputIndex===T.PointerInput.MouseWheelX){const f=Math.abs(l.deltaX);l.deltaX>0?c=f:c=-f,this._commandService.executeCommand(Kt.id,{offsetX:c}),n.getParent().classType===T.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||d.stopPropagation():s.isWheelPreventDefaultX?l.preventDefault():h!=null&&h.isLimitedX||l.preventDefault()}if(l.inputIndex===T.PointerInput.MouseWheelY){let f=Math.abs(l.deltaY);l.shiftKey?(f*=3,l.deltaY>0?c=f:c=-f,this._commandService.executeCommand(Kt.id,{offsetX:c}),n.getParent().classType===T.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||d.stopPropagation():s.isWheelPreventDefaultX?l.preventDefault():h!=null&&h.isLimitedX||l.preventDefault()):(l.deltaY>0?u=f:u=-f,this._commandService.executeCommand(Kt.id,{offsetY:u}),n.getParent().classType===T.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||d.stopPropagation():s.isWheelPreventDefaultY?l.preventDefault():h!=null&&h.isLimitedY||l.preventDefault())}l.inputIndex,T.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}))),new T.ScrollBar(s),n.attachControl(),s}},N.SheetCanvasView=qm([a.OnLifecycle(a.LifecycleStages.Ready,N.SheetCanvasView),si(0,a.IUniverInstanceService),si(1,a.ICommandService),si(2,T.IRenderManagerService),si(3,P.Inject(N.SheetSkeletonManagerService))],N.SheetCanvasView);var ef=Object.defineProperty,tf=Object.getOwnPropertyDescriptor,nf=(i,t,e,n)=>{for(var o=n>1?void 0:n?tf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ef(t,e,o),o},ai=(i,t)=>(e,n)=>t(e,n,i);N.HoverManagerService=class extends a.Disposable{constructor(e,n,o,r){super();I(this,"_currentCell$",new k.Subject);I(this,"currentCell$",this._currentCell$.asObservable().pipe(k.distinctUntilChanged((e,n)=>{var o,r,s,l,d,c,u,h;return((o=e==null?void 0:e.location)==null?void 0:o.unitId)===((r=n==null?void 0:n.location)==null?void 0:r.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=n==null?void 0:n.location)==null?void 0:l.subUnitId)&&((d=e==null?void 0:e.location)==null?void 0:d.row)===((c=n==null?void 0:n.location)==null?void 0:c.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=n==null?void 0:n.location)==null?void 0:h.col)})));I(this,"_lastPosition",null);this._univerInstanceService=e,this._scrollManagerService=n,this._sheetSkeletonManagerService=o,this._renderManagerService=r,this._initCellDisposableListener()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)}))}_calcActiveCell(){if(!this._lastPosition)return;const{offsetX:e,offsetY:n}=this._lastPosition,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o){this._currentCell$.next(null);return}const r=o.getActiveSheet(),s=this._sheetSkeletonManagerService.getCurrent(),l=this._renderManagerService.getRenderById(o.getUnitId()),d=this._scrollManagerService.getCurrentScroll();if(!s||!d||!l)return;const{scene:c}=l,{skeleton:u,sheetId:h,unitId:m}=s,f=Bl(e,n,c,u);if(!f){this._currentCell$.next(null);return}const{row:g,col:S,mergeCell:p,actualCol:R,actualRow:M}=f,E={unitId:m,subUnitId:h,workbook:o,worksheet:r,row:M,col:R};let b;p?b=p:b={startRow:g,endRow:g,startColumn:S,endColumn:S};const w=c.getActiveViewportByCoord(T.Vector2.FromArray([e,n]));if(!w)return;const{scaleX:y,scaleY:O}=c.getAncestorScale(),x={x:w.actualScrollX,y:w.actualScrollY},D={startX:(u.getOffsetByPositionX(b.startColumn-1)-x.x)*y,endX:(u.getOffsetByPositionX(b.endColumn)-x.x)*y,startY:(u.getOffsetByPositionY(b.startRow-1)-x.y)*O,endY:(u.getOffsetByPositionY(b.endRow)-x.y)*O};this._currentCell$.next({location:E,position:D})}onMouseMove(e,n){this._lastPosition={offsetX:e,offsetY:n},this._calcActiveCell()}onScrollStart(){this._currentCell$.next(null)}onScrollEnd(){this._calcActiveCell()}},N.HoverManagerService=nf([ai(0,a.IUniverInstanceService),ai(1,P.Inject($e)),ai(2,P.Inject(N.SheetSkeletonManagerService)),ai(3,T.IRenderManagerService)],N.HoverManagerService);var of=Object.defineProperty,rf=Object.getOwnPropertyDescriptor,sf=(i,t,e,n)=>{for(var o=n>1?void 0:n?rf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&of(t,e,o),o},fo=(i,t)=>(e,n)=>t(e,n,i);N.HoverController=class extends a.Disposable{constructor(t,e,n){super(),this._renderManagerService=t,this._hoverManagerService=e,this._univerInstanceService=n,this._initPointerEvent()}_initScrollEvent(){}_initPointerEvent(){const t=this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId());if(!t)return;const{scene:e}=t,n=e.onPointerMoveObserver.add(o=>{this._hoverManagerService.onMouseMove(o.offsetX,o.offsetY)});this.disposeWithMe({dispose(){e.onPointerMoveObserver.remove(n)}})}},N.HoverController=sf([a.OnLifecycle(a.LifecycleStages.Rendered,N.HoverController),fo(0,T.IRenderManagerService),fo(1,P.Inject(N.HoverManagerService)),fo(2,a.IUniverInstanceService)],N.HoverController);const Qe={cellAlert:"univer-cell-alert",cellAlertTitle:"univer-cell-alert-title",cellAlertIcon:"univer-cell-alert-icon",cellAlertIconError:"univer-cell-alert-icon-error",cellAlertIconInfo:"univer-cell-alert-icon-info",cellAlertIconWarning:"univer-cell-alert-icon-warning",cellAlertContent:"univer-cell-alert-content"};function af({popup:i}){var s;const t=(s=i.extraProps)==null?void 0:s.alert;if(!t)return null;const{type:e,title:n,message:o}=t,r={[Lt.ERROR]:v.jsx(rs,{className:Pe(Qe.cellAlertIcon,Qe.cellAlertIconError)}),[Lt.INFO]:v.jsx(gs,{className:Pe(Qe.cellAlertIcon,Qe.cellAlertIconInfo)}),[Lt.WARNING]:v.jsx(gs,{className:Pe(Qe.cellAlertIcon,Qe.cellAlertIconWarning)})};return v.jsxs("div",{className:Qe.cellAlert,children:[v.jsxs("div",{className:Qe.cellAlertTitle,children:[e?r[e]:null,n]}),v.jsx("div",{className:Qe.cellAlertContent,children:o})]})}const ws="univer.sheet.cell-alert";var lf=Object.defineProperty,cf=Object.getOwnPropertyDescriptor,df=(i,t,e,n)=>{for(var o=n>1?void 0:n?cf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&lf(t,e,o),o},Ht=(i,t)=>(e,n)=>t(e,n,i);N.SheetCanvasPopManagerService=class extends a.Disposable{constructor(t,e,n,o,r,s){super(),this._globalPopupManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._refRangeService=r,this._commandService=s}_calcCellPosition(t,e,n,o,r){const{scene:s,engine:l}=n,d=o.getCellByIndex(t,e),c=d.isMergedMainCell?d.mergeInfo:d,{scaleX:u,scaleY:h}=s.getAncestorScale(),m={x:r.actualScrollX,y:r.actualScrollY},f=l.getCanvasElement().getBoundingClientRect();return{left:(c.startX-m.x)*u+f.left,right:(c.endX-m.x)*u+f.left,top:(c.startY-m.y)*h+f.top,bottom:(c.endY-m.y)*h+f.top}}_createCellPositionObserver(t,e,n,o,r){let s=t,l=e;const d=this._calcCellPosition(s,l,n,o,r),c=new k.BehaviorSubject(d),u=()=>c.next(this._calcCellPosition(s,l,n,o,r)),h=new a.DisposableCollection;return h.add(this._commandService.onCommandExecuted(f=>{if(f.id===_.SetWorksheetRowAutoHeightMutation.id&&f.params.rowsAutoHeightInfo.findIndex(S=>S.row===s)>-1){u();return}(_.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(f.id)>-1||f.id===ot.id||f.id===Le.id)&&u()})),{position$:c,disposable:h,position:d,updateRowCol:(f,g)=>{s=f,l=g,u()}}}_createObjectPositionObserver(t,e,n,o){const r=()=>{const{scene:c}=e,{left:u,top:h,width:m,height:f}=t,g={left:u,right:u+m,top:h,bottom:h+f},S=Fl(g,c,n,o),p=e.engine.getCanvasElement().getBoundingClientRect();return{left:S.left,right:S.right,top:S.top+p.top,bottom:S.bottom+p.top}},s=r(),l=new k.BehaviorSubject(s),d=new a.DisposableCollection;return d.add(this._commandService.onCommandExecuted(c=>{(c.id===ot.id||c.id===Le.id)&&l.next(r())})),{position:s,position$:l,disposable:d}}attachPopupToObject(t,e){const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=n.getActiveSheet(),r=n.getUnitId(),s=o.getSheetId(),l=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:r,sheetId:s}),d=this._renderManagerService.getRenderById(r);if(!d||!l)return{dispose:()=>{}};const{position:c,position$:u,disposable:h}=this._createObjectPositionObserver(t,d,l,o),m=this._globalPopupManagerService.addPopup({...e,unitId:r,subUnitId:s,anchorRect:c,anchorRect$:u});return{dispose:()=>{this._globalPopupManagerService.removePopup(m),u.complete(),h.dispose()}}}attachPopupToCell(t,e,n,o){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),l=r.getUnitId(),d=s.getSheetId(),c=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:l,sheetId:d}),u=this._renderManagerService.getRenderById(l);if(!u||!c)return null;const h=o!=null?o:kl(t,e,u.scene,s);if(!h)return null;const{position:m,position$:f,disposable:g,updateRowCol:S}=this._createCellPositionObserver(t,e,u,c,h),p=this._globalPopupManagerService.addPopup({...n,unitId:l,subUnitId:d,anchorRect:m,anchorRect$:f}),R=new a.DisposableCollection;R.add(g),R.add(a.toDisposable(()=>{this._globalPopupManagerService.removePopup(p),f.complete()}));const M={startRow:t,endRow:t,startColumn:e,endColumn:e};return R.add(this._refRangeService.watchRange(l,d,M,(E,b)=>{b?S(b.startRow,b.startColumn):R.dispose()})),R}},N.SheetCanvasPopManagerService=df([Ht(0,P.Inject(C.ICanvasPopupService)),Ht(1,T.IRenderManagerService),Ht(2,a.IUniverInstanceService),Ht(3,P.Inject(N.SheetSkeletonManagerService)),Ht(4,P.Inject(_.RefRangeService)),Ht(5,a.ICommandService)],N.SheetCanvasPopManagerService);var uf=Object.defineProperty,hf=Object.getOwnPropertyDescriptor,mf=(i,t,e,n)=>{for(var o=n>1?void 0:n?hf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&uf(t,e,o),o},ys=(i,t)=>(e,n)=>t(e,n,i),Lt=(i=>(i[i.INFO=0]="INFO",i[i.WARNING=1]="WARNING",i[i.ERROR=2]="ERROR",i))(Lt||{});N.CellAlertManagerService=class{constructor(t,e){I(this,"_currentAlert$",new k.Subject);I(this,"_currentAlert",new Map);I(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=t,this._canvasPopManagerService=e}get currentAlert(){return this._currentAlert}showAlert(t){let e=this._currentAlert.get(t.key);e&&e.dispose.dispose(),e?e.dispose.dispose():(e={alert:t,dispose:{dispose(){}}},this._currentAlert.set(t.key,e));const{location:n}=t,{row:o,col:r,unitId:s}=n;if(!this._renderManagerService.getRenderById(s))return;const d=this._canvasPopManagerService.attachPopupToCell(o,r,{componentKey:ws,direction:"horizontal",offset:[2,0],extraProps:{alert:t}});d&&(e.dispose=d),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}removeAlert(t){const e=this._currentAlert.get(t);e&&(this._currentAlert.delete(t),e==null||e.dispose.dispose(),this._currentAlert$.next(Array.from(this._currentAlert.entries())))}clearAlert(){this._currentAlert.forEach(t=>{t.dispose.dispose()}),this._currentAlert.clear(),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}},N.CellAlertManagerService=mf([ys(0,T.IRenderManagerService),ys(1,P.Inject(N.SheetCanvasPopManagerService))],N.CellAlertManagerService);var ff=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,Sf=(i,t,e,n)=>{for(var o=n>1?void 0:n?gf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ff(t,e,o),o},_f=(i,t)=>(e,n)=>t(e,n,i);let li=class extends a.Disposable{constructor(i){super(),this._componentManager=i,this._initComponent()}_initComponent(){this._componentManager.register(ws,af)}};li=Sf([a.OnLifecycle(a.LifecycleStages.Starting,li),_f(0,P.Inject(C.ComponentManager))],li);var pf=Object.defineProperty,vf=Object.getOwnPropertyDescriptor,Cf=(i,t,e,n)=>{for(var o=n>1?void 0:n?vf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&pf(t,e,o),o},go=(i,t)=>(e,n)=>t(e,n,i);let ci=class extends a.RxDisposable{constructor(i,t,e){super(),this._sheetSkeletonManagerService=i,this._sheetInterceptorService=t,this._themeService=e,this._init()}_init(){this._initViewModelIntercept()}_initViewModelIntercept(){const t={tr:{size:6,color:this._themeService.getCurrentTheme().errorColor}};this.disposeWithMe(this._sheetInterceptorService.intercept(_.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,n,o)=>{var l;if(!((l=this._sheetSkeletonManagerService.getCurrent())==null?void 0:l.skeleton))return o(e);const s=n.worksheet.getCellRaw(n.row,n.col);return!s||s.v===null||s.v===void 0?o(e):(e==null?void 0:e.t)===a.CellValueType.FORCE_STRING&&a.isRealNum(s.v)?o({...e,markers:{...e==null?void 0:e.markers,...t}}):o(e)}}))}};ci=Cf([a.OnLifecycle(a.LifecycleStages.Rendered,ci),go(0,P.Inject(N.SheetSkeletonManagerService)),go(1,P.Inject(_.SheetInterceptorService)),go(2,P.Inject(a.ThemeService))],ci);var If=Object.defineProperty,Rf=Object.getOwnPropertyDescriptor,Mf=(i,t,e,n)=>{for(var o=n>1?void 0:n?Rf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&If(t,e,o),o},di=(i,t)=>(e,n)=>t(e,n,i);const So="SHEET_FORCE_STRING_ALERT";let ui=class extends a.Disposable{constructor(i,t,e,n){super(),this._hoverManagerService=i,this._cellAlertManagerService=t,this._univerInstanceService=e,this._localeService=n,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(i=>{var t;if(i){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCell(i.location.row,i.location.col);if((o==null?void 0:o.t)===a.CellValueType.FORCE_STRING&&o.v&&a.isRealNum(o.v)){const r=this._cellAlertManagerService.currentAlert.get(So),s=(t=r==null?void 0:r.alert)==null?void 0:t.location;if(s&&s.row===i.location.row&&s.col===i.location.col&&s.subUnitId===i.location.subUnitId&&s.unitId===i.location.unitId)return;this._cellAlertManagerService.showAlert({type:Lt.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:i.location,width:200,height:74,key:So});return}}this._cellAlertManagerService.removeAlert(So)}))}};ui=Mf([a.OnLifecycle(a.LifecycleStages.Rendered,ui),di(0,P.Inject(N.HoverManagerService)),di(1,P.Inject(N.CellAlertManagerService)),di(2,a.IUniverInstanceService),di(3,P.Inject(a.LocaleService))],ui);var bf=Object.defineProperty,Tf=Object.getOwnPropertyDescriptor,Ef=(i,t,e,n)=>{for(var o=n>1?void 0:n?Tf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&bf(t,e,o),o},hi=(i,t)=>(e,n)=>t(e,n,i);N.UniverSheetsUIPlugin=(fi=class extends a.Plugin{constructor(t,e,n,o,r){super(),this._injector=e,this._localeService=n,this._renderManagerService=o,this._univerInstanceService=r,this._localeService.load({zhCN:Mr})}onStarting(t){[[N.SheetCanvasView],[$t],[we,{useClass:N.EditorBridgeService}],[It,{useClass:N.SheetClipboardService}],[At,{useClass:vu}],[Et,{useClass:ki}],[tn,{useClass:br}],[On,{useClass:Pc}],[Jt,{useClass:N.AutoFillService}],[$e],[N.SheetSkeletonManagerService],[Ie,{useClass:N.SelectionRenderService}],[ao,{useClass:Rh}],[Wt,{useClass:N.MarkSelectionService}],[N.HoverManagerService],[N.SheetCanvasPopManagerService],[N.CellAlertManagerService],[Nn],[xn],[kn],[Hn],[Ln],[Fn],[Wn],[zn],[Yn],[Xn],[Gn],[N.ScrollController],[Zn],[An],[Dn],[N.SheetRenderController],[ii],[Un],[ri],[N.AutoFillController],[oi],[Pn],[$n],[N.HoverController],[li],[N.CellCustomRenderController],[ci],[ui]].forEach(e=>t.add(e))}onReady(){this._markSheetAsFocused(),this._registerRenderControllers()}_registerRenderControllers(){[Wn,to,Xn].forEach(t=>{this.disposeWithMe(this._renderManagerService.registerRenderControllers(a.UniverInstanceType.UNIVER_SHEET,t))})}_markSheetAsFocused(){const t=this._univerInstanceService;t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(Ps.filter(e=>!!e)).subscribe(e=>{t.focusUnit(e.getUnitId())})}},I(fi,"pluginName","SHEET_UI_PLUGIN_NAME"),I(fi,"type",a.UniverInstanceType.UNIVER_SHEET),fi),N.UniverSheetsUIPlugin=Ef([hi(1,P.Inject(P.Injector)),hi(2,P.Inject(a.LocaleService)),hi(3,T.IRenderManagerService),hi(4,a.IUniverInstanceService)],N.UniverSheetsUIPlugin),N.APPLY_TYPE=oe,N.AutoFillCommand=wo,N.COPY_TYPE=nt,N.CellAlertType=Lt,N.CellEditorManagerService=br,N.DATA_TYPE=ce,N.ExpandSelectionCommand=He,N.IAutoFillService=Jt,N.ICellEditorManagerService=tn,N.IEditorBridgeService=we,N.IFormulaEditorManagerService=On,N.IMarkSelectionService=Wt,N.ISelectionRenderService=Ie,N.ISheetClipboardService=It,N.JumpOver=Fe,N.MoveSelectionCommand=Ee,N.PASTE_SPECIAL_MENU_ID=Ot,N.PREDEFINED_HOOK_NAME=Se,N.ResetScrollCommand=dl,N.SHEET_UI_PLUGIN_NAME=Hs,N.SHEET_VIEW_KEY=me,N.ScrollCommand=dt,N.ScrollToCellCommand=er,N.SelectionShape=In,N.SetCellEditVisibleArrowOperation=Zt,N.SetCellEditVisibleOperation=ye,N.SetScrollOperation=ot,N.SetScrollRelativeCommand=Kt,N.SetZoomRatioOperation=Le,N.SheetCopyCommand=Wo,N.SheetPasteCommand=Rt,N.VIEWPORT_KEY=j,N.deriveStateFromActiveSheet$=_e,N.enUS=Dc,N.expandToContinuousRange=Go,N.getAutoFillRepeatRange=Zs,N.getCoordByCell=Ai,N.getCoordByOffset=Mt,N.getEditorObject=_n,N.getRepeatRange=La,N.getSheetObject=Me,N.getTransformCoord=bn,N.mergeSetRangeValues=bi,N.rangeToDiscreteRange=vt,N.virtualizeDiscreteRanges=jt,N.whenFormulaEditorActivated=qs,N.whenSheetEditorFocused=ie,N.zhCN=Mr,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
|
19
|
+
`)}]}}var zc=Object.defineProperty,Yc=Object.getOwnPropertyDescriptor,Xc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Yc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&zc(t,e,o),o},Ve=(i,t)=>(e,n)=>t(e,n,i);let An=class extends a.RxDisposable{constructor(i,t,e,n,o,r,s,l,d,c,u){var h;super(),this._injector=i,this._currentUniverSheet=t,this._commandService=e,this._contextService=n,this._configService=o,this._sheetClipboardService=r,this._clipboardInterfaceService=s,this._messageService=l,this._sheetSkeletonManagerService=d,this._localService=c,this._textSelectionRenderManager=u,this._init(),(h=this._textSelectionRenderManager)==null||h.onPaste$.pipe(k.takeUntil(this.dispose$)).subscribe(m=>{var p,R;if(!ie(this._contextService))return;m.event.preventDefault();const f=m.event,g=(p=f.clipboardData)==null?void 0:p.getData("text/html"),S=(R=f.clipboardData)==null?void 0:R.getData("text/plain");this._sheetClipboardService.legacyPaste(g,S)})}_init(){[Fo,Za,Rt].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t))),[Wo,jo,zo,Yo].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(t=>this._sheetClipboardService.addClipboardHook(t));this.disposeWithMe({dispose:()=>i.forEach(t=>t.dispose())})}_initCopyingHooks(){const i=this;let t=null;return{id:Se.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(e,n){t=i._getWorksheet(e,n)},onCopyCellContent(e,n){var s,l,d,c;const o=t.getCell(e,n);return(l=(s=o==null?void 0:o.p)==null?void 0:s.body)!=null&&l.paragraphs||(c=(d=o==null?void 0:o.p)==null?void 0:d.body)!=null&&c.textRuns?a.convertBodyToHtml(o.p.body):o?a.extractPureTextFromCell(o):""},onCopyCellStyle:(e,n,o,r)=>{const s={};(o||r)&&(s.rowspan=`${o||1}`,s.colspan=`${r||1}`);const l=t.getRange(e,n),d=t.getMergedCell(e,n),c=l.getTextStyle();let u="";if(c&&(u=a.handleStyleToString(c)),d){const h=d.endRow,m=d.endColumn,g=t.getRange(h,m).getTextStyle();if(g){const S=a.handleStyleToString(g);u?u+=S?`;${S}`:"":u=S}}return u&&(s.style=u),s},onCopyColumn(e){return{width:`${t.getColumnWidth(e)}`}},onCopyRow(e){return{style:`height: ${t.getRowHeight(e)}px;`}},onAfterCopy(){t=null},getFilteredOutRows(e){var l;const{startRow:n,endRow:o}=e,r=(l=i._currentUniverSheet.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getActiveSheet(),s=[];if(!r)return s;for(let d=n;d<=o;d++)r.getRowFiltered(d)&&s.push(d);return s}}}_initPastingHook(){const i=this;let t=null,e=null,n=null;return{id:Se.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:o,subUnitId:r,range:s}){n=i._getWorksheet(o,r),t=o,e=r;const l=i._configService.getConfig(_.MAX_CELL_PER_SHEET_KEY),d=s.rows[s.rows.length-1],c=s.cols[s.cols.length-1];return l&&d*c>l?(i._messageService.show({type:re.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,r){const{range:s}=o,l=[],d=[],c=n.getMaxRows(),u=s.rows[s.rows.length-1]-c,h=r.length-u,m=n.getRowManager();if(u>0){const p={};r.slice(h).forEach((M,T)=>{const{style:b,height:E}=M||{};if(b){const y=b.split(";");let O=a.DEFAULT_WORKSHEET_ROW_HEIGHT;y.find(x=>{x=x.toLowerCase();const D=C.textTrim(x.substr(0,x.indexOf(":"))),W=C.textTrim(x.substr(x.indexOf(":")+1));return D==="height"?(W.endsWith("pt")?O=w.ptToPx(Number.parseFloat(W)):O=Number.parseFloat(W),!0):!1}),p[T]={h:O,hd:a.BooleanNumber.FALSE}}else E&&(p[T]={h:Number.parseFloat(E),hd:a.BooleanNumber.FALSE})});const R={unitId:t,subUnitId:e,range:{startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1],endRow:s.rows[s.rows.length-1],startRow:c},rowInfo:p};l.push({id:_.InsertRowMutation.id,params:R})}const f={},g={};r.slice(0,h).forEach((p,R)=>{var b,E;const{style:M,height:T}=p;if(M){const y=M.split(";");let O=a.DEFAULT_WORKSHEET_ROW_HEIGHT;y.find(x=>{x=x.toLowerCase();const D=C.textTrim(x.substr(0,x.indexOf(":"))),W=C.textTrim(x.substr(x.indexOf(":")+1));return D==="height"?(W.endsWith("pt")?O=w.ptToPx(Number.parseFloat(W)):O=Number.parseFloat(W),!0):!1}),f[R+s.rows[0]]=O}else if(T){const y=m.getRow(s.rows[0]+R),O=Number.parseFloat(T);if(y){const{h:x=a.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:D=0}=y,W=Math.max(x,D);O>W&&(f[R+s.rows[0]]=O,g[R+s.rows[0]]=W)}else f[R+s.rows[0]]=O,g[R+s.rows[0]]=(E=(b=m.getRow(s.rows[0]+R))==null?void 0:b.h)!=null?E:a.DEFAULT_WORKSHEET_ROW_HEIGHT}});const S={unitId:t,subUnitId:e,ranges:[{startRow:s.rows[0],endRow:Math.min(s.rows[s.rows.length-1],c),startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1]}],rowHeight:f};return l.push({id:_.SetWorksheetRowHeightMutation.id,params:S}),d.push({id:_.SetWorksheetRowHeightMutation.id,params:{...S,rowHeight:20}}),{redos:l,undos:d}},onPasteColumns(o,r,s){var g;const{range:l}=o,d=[],c=n.getMaxColumns(),u=l.cols[l.cols.length-1]-c,h=r.length-u,m=(g=i._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?g:a.DEFAULT_WORKSHEET_COLUMN_WIDTH;if(u>0){const S={unitId:t,subUnitId:e,range:{startRow:l.rows[0],endRow:l.rows[l.rows.length-1],endColumn:l.cols[l.cols.length-1],startColumn:c},colInfo:r.slice(h).map(p=>({w:p.width?+p.width:m,hd:a.BooleanNumber.FALSE}))};d.push({id:_.InsertColMutation.id,params:S})}const f={unitId:t,subUnitId:e,ranges:[{startRow:l.rows[0],endRow:l.rows[l.rows.length-1],startColumn:l.cols[0],endColumn:Math.min(l.cols[l.cols.length-1],c)}],colWidth:r.slice(0,h).map(S=>S.width?+S.width:m)};return d.push({id:_.SetWorksheetColWidthMutation.id,params:f}),{redos:d,undos:[]}},onPastePlainText(o,r,s){return i._onPastePlainText(o,r,s)},onPasteCells(o,r,s,l){return i._onPasteCells(o,r,s,l)},onAfterPaste(o){n=null}}}_generateDocumentDataModelSnapshot(i){var s;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null)return null;const{skeleton:e}=t,n=(s=e.getBlankCellDocumentModel())==null?void 0:s.documentModel,r={...n==null?void 0:n.getSnapshot(),...i};return n==null||n.reset(r),n==null?void 0:n.getSnapshot()}_onPastePlainText(i,t,e){const{range:n,unitId:o,subUnitId:r}=i;let s;if(/\r|\n/.test(t)){const d=jc(t),c=this._generateDocumentDataModelSnapshot({body:d});s={[n.rows[0]]:{[n.cols[0]]:{p:c}}}}else a.isFormulaString(t)?s={[n.rows[0]]:{[n.cols[0]]:{f:t}}}:s={[n.rows[0]]:{[n.cols[0]]:{v:t}}};const l={unitId:o,subUnitId:r,cellValue:s};return{redos:[{id:_.SetRangeValuesMutation.id,params:l}],undos:[{id:_.SetRangeValuesMutation.id,params:_.SetRangeValuesUndoMutationFactory(this._injector,l)}]}}_onPasteCells(i,t,e,n){const o={get:this._injector.get.bind(this._injector)};return Fc(i,t,e,n,o)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},t=this,e={id:Se.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,l,d)=>wr(l,s,d,i)},n={id:Se.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,l,d){const c=[],u=[],{undos:h,redos:m}=yr(l,d,i);c.push(...m),u.push(...h);const{undos:f,redos:g}=Xi(l,d,i);c.push(...g),u.push(...f);const{undos:S,redos:p}=Er(l,d,i);return c.push(...p),u.push(...S),{undos:u,redos:c}}},o={id:Se.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,l,d){var b;const c=t._currentUniverSheet.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=c.getUnitId(),h=c.getActiveSheet().getSheetId(),m=[],f=t._getWorksheet(u,h),{range:g}=s,S=f.getMaxColumns(),p=g.cols[g.cols.length-1]-S,R=l.length-p,M=(b=t._configService.getConfig(a.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?b:a.DEFAULT_WORKSHEET_COLUMN_WIDTH,T={unitId:u,subUnitId:h,ranges:[{startRow:g.rows[0],endRow:Math.min(g.cols[g.cols.length-1],S),startColumn:g.cols[0],endColumn:g.cols[g.cols.length-1]}],colWidth:l.slice(0,R).map(E=>E.width?+E.width:M)};return m.push({id:_.SetWorksheetColWidthMutation.id,params:T}),m.push({id:_.SetWorksheetColWidthMutation.id,params:T}),{redos:m,undos:[]}}},r={id:Se.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,l,d,c){t._currentUniverSheet.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);const u=[],h=[],{range:m,unitId:f,subUnitId:g}=l,S=new a.ObjectMatrix;d.forValue((b,E,y)=>{const O=y.s;typeof O=="object"&&S.setValue(m.rows[b],m.cols[E],{s:{...O,bd:void 0},v:y.v})});const p={unitId:f,subUnitId:g,cellValue:S.getData()};u.push({id:_.SetRangeValuesMutation.id,params:p});const R=_.SetRangeValuesUndoMutationFactory(i,p);h.push({id:_.SetRangeValuesMutation.id,params:R});const{undos:M,redos:T}=Xi(l,d,i);return h.push(...M),u.push(...T),{redos:u,undos:h}}};return[e,n,o,r]}_getWorksheet(i,t){var n;const e=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(t);if(!e)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${t}.`);return e}};An=Xc([a.OnLifecycle(a.LifecycleStages.Steady,An),Ve(0,P.Inject(P.Injector)),Ve(1,a.IUniverInstanceService),Ve(2,a.ICommandService),Ve(3,a.IContextService),Ve(4,a.IConfigService),Ve(5,It),Ve(6,C.IClipboardInterfaceService),Ve(7,C.IMessageService),Ve(8,P.Inject(N.SheetSkeletonManagerService)),Ve(9,P.Inject(a.LocaleService)),Ve(10,P.Optional(w.ITextSelectionRenderManager))],An);var $c=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,Zc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Gc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&$c(t,e,o),o},on=(i,t)=>(e,n)=>t(e,n,i);let Dn=class extends a.Disposable{constructor(i,t,e,n,o){super(),this._univerInstanceService=i,this._contextMenuService=t,this._renderManagerService=e,this._selectionManagerService=n,this._selectionRenderService=o,this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(r=>{r&&this._addListeners()})}_addListeners(){const i=Me(this._univerInstanceService,this._renderManagerService);if(!i)return;const t=i.spreadsheet.onPointerDownObserver,e=t.add(l=>{if(l.button===2){const d=this._selectionManagerService.getSelections(),c=d==null?void 0:d[0];if(!c)return;const u=c.range.rangeType,h=this._selectionRenderService.convertSelectionRangeToData(c).rangeWithCoord,m=()=>{if(!h)return!1;const g=l.offsetX,S=l.offsetY;switch(u){case a.RANGE_TYPE.ROW:return h.startY<=S&&h.endY>=S;case a.RANGE_TYPE.COLUMN:return h.startX<=g&&h.endX>=g;default:return h.startX<=g&&h.endX>=g&&h.startY<=S&&h.endY>=S}},f=g=>{this._contextMenuService.triggerContextMenu(l,g)};m()?u===a.RANGE_TYPE.COLUMN?f(le.COL_HEADER_CONTEXT_MENU):u===a.RANGE_TYPE.ROW?f(le.ROW_HEADER_CONTEXT_MENU):f(C.MenuPosition.CONTEXT_MENU):f(C.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(a.toDisposable(()=>t.remove(e)));const o=i.spreadsheetRowHeader.onPointerDownObserver.add(l=>{l.button===2&&this._contextMenuService.triggerContextMenu(l,le.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(a.toDisposable(()=>t.remove(o)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(l=>{l.button===2&&this._contextMenuService.triggerContextMenu(l,le.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(a.toDisposable(()=>t.remove(s)))}};Dn=Zc([a.OnLifecycle(a.LifecycleStages.Rendered,Dn),on(0,a.IUniverInstanceService),on(1,C.IContextMenuService),on(2,w.IRenderManagerService),on(3,P.Inject(_.SelectionManagerService)),on(4,Ie)],Dn);var Kc=Object.defineProperty,Qc=Object.getOwnPropertyDescriptor,Jc=(i,t,e,n)=>{for(var o=n>1?void 0:n?Qc(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Kc(t,e,o),o},$i=(i,t)=>(e,n)=>t(e,n,i);let Pn=class extends a.RxDisposable{constructor(i,t,e){super(),this._univerInstanceService=i,this._renderManagerService=t,this._undoRedoService=e,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_DOC).pipe(k.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;i.getUnitId()!==a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const i={};this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(t=>{const e=t.getConfig();i[t.getSheetId()]={cellData:new a.ObjectMatrix(e.cellData),rowCount:e.rowCount,columnCount:e.columnCount,rowData:e.rowData,columnData:e.columnData}})}_commandExecutedListener(){}_getDocObject(){return q.getDocObject(this._univerInstanceService,this._renderManagerService)}};Pn=Jc([a.OnLifecycle(a.LifecycleStages.Rendered,Pn),$i(0,a.IUniverInstanceService),$i(1,w.IRenderManagerService),$i(2,P.Inject(a.IUndoRedoService))],Pn);const Or=[C.KeyCode.ARROW_DOWN,C.KeyCode.ARROW_UP,C.KeyCode.ARROW_LEFT,C.KeyCode.ARROW_RIGHT],qc=[C.KeyCode.ENTER,C.KeyCode.TAB,...Or];function ed(){const i=[];for(const t of Or)i.push({id:Zt.id,binding:t,preconditions:e=>kt(e),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:t,isShift:!1}}),i.push({id:Zt.id,binding:t|C.MetaKeys.SHIFT,preconditions:e=>kt(e),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:t,isShift:!0}});return i}const td={id:xi.id,binding:C.KeyCode.F2,description:"shortcut.sheet.start-editing",group:"4_sheet-edit",preconditions:ie,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.F2}},nd={id:ye.id,binding:C.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>kt(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ENTER}},id={id:ye.id,binding:C.KeyCode.TAB,preconditions:i=>kt(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.TAB}},od={id:ye.id,binding:C.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>kt(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC}},rd={id:q.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>Qs(i),binding:C.KeyCode.ENTER|C.MetaKeys.ALT},sd={id:q.DeleteLeftCommand.id,preconditions:i=>Js(i)||yo(i),binding:C.KeyCode.BACKSPACE},ad={id:ye.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>ie(i)&&!yo(i),binding:C.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.BACKSPACE}};function ld(i){return i.startsWith("'")}function cd(i){return i.slice(1)}var dd=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,hd=(i,t,e,n)=>{for(var o=n>1?void 0:n?ud(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&dd(t,e,o),o},je=(i,t)=>(e,n)=>t(e,n,i);function md(i){const{textRuns:t=[],paragraphs:e=[]}=i;return t.some(n=>n.ts&&!a.Tools.isEmptyObject(n.ts))||e.some(n=>n.bullet)||e.length>=2}let Hn=class extends a.Disposable{constructor(t,e,n,o,r,s,l,d,c,u){super();I(this,"_cursorChangeObservers");I(this,"_editorVisiblePrevious",!1);I(this,"_cursorChange",0);this._univerInstanceService=t,this._renderManagerService=e,this._commandService=n,this._editorBridgeService=o,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=l,this._undoRedoService=d,this._selectionManagerService=c,this._editorService=u,this._initialize(),this._commandExecutedListener()}dispose(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;e.onPointerDownObserver.remove(this._cursorChangeObservers),super.dispose()}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(async t=>{const{visible:e,keycode:n,eventType:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!0){this._cursorChange=o===w.DeviceInputEventType.PointerDown?2:1;return}this._cursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:l,sheetId:d,pluginName:c}=s;if(this._exitInput(t),n===C.KeyCode.ESC){r&&this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,{unitId:l,subUnitId:d,pluginName:c,selections:r});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:f,column:g,documentLayoutObject:S}=u;if(this._editorBridgeService.getEditorDirty()===!1){this._moveCursor(n);return}const R=this._univerInstanceService.getUniverSheetInstance(h),M=R==null?void 0:R.getSheetBySheetId(m);if(M==null)return;const T=fd(M.getCellRaw(f,g)||{},S,this._lexerTreeBuilder);if(T==null){this._moveCursor(n);return}const b={subUnitId:m,unitId:h,workbook:R,worksheet:M,row:f,col:g};l===h&&m!==d&&this._editorBridgeService.isForceKeepVisible()&&this._commandService.executeCommand(_.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h}),this._selectionManagerService.refreshSelection();const E=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(T,b),y=await this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC)(Promise.resolve(E),b);this._commandService.executeCommand(_.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:f,startColumn:g,endRow:f,endColumn:g},value:y}),this._moveCursor(n)}))}_exitInput(t){this._contextService.setContextValue(a.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(a.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:t.visible});const e=this._editorBridgeService.getCurrentEditorId();e==null||!this._editorService.isSheetEditor(e)||(this._undoRedoService.clearUndoRedo(e),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(t){if(t==null||!qc.includes(t))return;let e=a.Direction.LEFT;switch(t){case C.KeyCode.ENTER:e=a.Direction.DOWN;break;case C.KeyCode.TAB:e=a.Direction.RIGHT;break;case C.KeyCode.ARROW_DOWN:e=a.Direction.DOWN;break;case C.KeyCode.ARROW_UP:e=a.Direction.UP;break;case C.KeyCode.ARROW_LEFT:e=a.Direction.LEFT;break;case C.KeyCode.ARROW_RIGHT:e=a.Direction.RIGHT;break}t===C.KeyCode.ENTER||t===C.KeyCode.TAB?this._commandService.executeCommand(ct.id,{keycode:t,direction:e}):this._commandService.executeCommand(we.id,{direction:e})}_cursorStateListener(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;this.disposeWithMe(a.toDisposable(e.onPointerDownObserver.add(()=>{this._cursorChange===1&&(this._cursorChange=2)})))}_commandExecutedListener(){const t=[Zt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{keycode:o,isShift:r}=n;if(o!=null&&(this._cursorChange===2||this._contextService.getContextValue(a.FOCUSING_FORMULA_EDITOR))){this._moveInEditor(o,r);return}this._editorBridgeService.changeVisible(n)}e.id===xi.id&&(this._cursorChange=2)}))}_moveInEditor(t,e){let n=a.Direction.LEFT;t===C.KeyCode.ARROW_DOWN?n=a.Direction.DOWN:t===C.KeyCode.ARROW_UP?n=a.Direction.UP:t===C.KeyCode.ARROW_RIGHT&&(n=a.Direction.RIGHT),e?this._commandService.executeCommand(q.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(q.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return _n(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Hn=hd([a.OnLifecycle(a.LifecycleStages.Rendered,Hn),je(0,a.IUniverInstanceService),je(1,w.IRenderManagerService),je(2,a.ICommandService),je(3,Ee),je(4,a.IContextService),je(5,tn),je(6,P.Inject(K.LexerTreeBuilder)),je(7,a.IUndoRedoService),je(8,P.Inject(_.SelectionManagerService)),je(9,C.IEditorService)],Hn);function fd(i,t,e){i=a.Tools.deepClone(i);const{documentModel:n}=t;if(n==null)return null;const o=n.getSnapshot(),{body:r}=o;if(r==null)return null;i.t=void 0;const s=r.dataStream;let d=s.substring(s.length-2,s.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?s.substring(0,s.length-2):s;if(a.isFormulaString(d)){if(i.f===d)return null;const c=e.checkIfAddBracket(d);for(let u=0;u<c;u++)d+=K.matchToken.CLOSE_BRACKET;i.f=d,i.v=null,i.p=null}else if(ld(d)){const c=cd(d);i.v=c,i.f=null,i.si=null,i.p=null,i.t=a.CellValueType.FORCE_STRING}else if(md(r))r.dataStream===`\r
|
|
20
|
+
`?(i.v="",i.f=null,i.si=null,i.p=null):(i.p=o,i.v=null,i.f=null,i.si=null);else{if((d===i.v||d===""&&i.v==null)&&i.p==null)return null;i.v=d,i.f=null,i.si=null,i.p=null}return i}var gd=Object.defineProperty,Sd=Object.getOwnPropertyDescriptor,_d=(i,t,e,n)=>{for(var o=n>1?void 0:n?Sd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&gd(t,e,o),o},ze=(i,t)=>(e,n)=>t(e,n,i);let Ln=class extends a.RxDisposable{constructor(t,e,n,o,r,s,l,d,c,u){super();I(this,"_loadedMap",new WeakSet);this._univerInstanceService=t,this._renderManagerService=e,this._editorBridgeService=n,this._commandService=o,this._contextService=r,this._formulaEditorManagerService=s,this._undoRedoService=l,this._docSkeletonManagerService=d,this._docViewModelManagerService=c,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._listenFoldBtnClick(),this._renderManagerService.currentRender$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._create(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._textSelectionManagerService.textSelection$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const{unitId:e}=t;e!==a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_create(t){if(t!==a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&(this._loadedMap.has(n)||(this._initialMain(t),this._loadedMap.add(n)))}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(k.takeUntil(this.dispose$)).subscribe(()=>{var e;if(this._contextService.getContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(a.EDITOR_ACTIVATED)){this._univerInstanceService.setCurrentUnitForType(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.PointerDown});const r=(e=n==null?void 0:n.getBody())==null?void 0:e.dataStream;if(r==null)return;let s=r.startsWith("=")?r:`=${r}`;s=s.replace(/\r\n$/,"");const l=[{startOffset:s.length,endOffset:s.length}],d={unitId:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(q.CoverContentCommand.id,d),this._textSelectionManagerService.replaceTextRanges(l)}})}_listenFoldBtnClick(){this._formulaEditorManagerService.foldBtnStatus$.pipe(k.takeUntil(this.dispose$)).subscribe(()=>{this._textSelectionManagerService.refreshSelection()})}_initialMain(t){const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&this.disposeWithMe(a.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(a.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.Dblclick})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const e=_n(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||n==null)return;const{width:o,height:r}=t,{engine:s}=e;n.updateDocumentDataPageSize(o),this._autoScroll(),requestIdleCallback(()=>{s.resizeBySize(o,r)})})}_syncFormulaEditorContent(){this._editorBridgeService.currentEditCellState$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{t==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(t)}),this._editorBridgeService.visible$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{if(t==null||t.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const e=this._editorBridgeService.getLatestEditCellState();e!=null&&this._editorSyncHandler(e)})}_editorSyncHandler(t){var s;const e=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=e==null?void 0:e.dataStream,o=e==null?void 0:e.paragraphs,r=[];n==null||o==null||(t.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===w.DeviceInputEventType.Dblclick?(n=`\r
|
|
21
|
+
`,o=[{startIndex:0}]):t.isInArrayFormulaRange===!0&&(r=(e==null?void 0:e.textRuns)||[]),this._syncContentAndRender(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,o,r),this._autoScroll())}_commandExecutedListener(){const t=[q.RichTextEditingMutation.id,C.SetEditorResizeOperation.id],e=[a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s;if(t.includes(o.id)){const l=o.params,{unitId:d}=l;if(e.includes(d)){const c=this._univerInstanceService.getUniverDocInstance(d),u=(r=c==null?void 0:c.getBody())==null?void 0:r.dataStream,h=(s=c==null?void 0:c.getBody())==null?void 0:s.paragraphs,m=d===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(u==null||h==null)return;this._syncContentAndRender(m,u,h),this._autoScroll()}}}));const n=[_.SetRangeValuesMutation.id,_.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(o=>{var r,s,l,d,c;if(n.includes(o.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:f}=u;if(o.id===_.SetRangeValuesMutation.id&&o.params?(s=(r=o.params.cellValue)==null?void 0:r[m])!=null&&s[f]&&(h=!0):o.id===_.MoveRangeMutation.id&&o.params&&(d=(l=o.params.to.value)==null?void 0:l[m])!=null&&d[f]&&(h=!0),h){const g=(c=u.documentLayoutObject.documentModel)==null?void 0:c.getBody();if(g==null)return;const{dataStream:S,paragraphs:p=[]}=g;this._syncContentAndRender(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,S,p),this._autoScroll()}}}))}_syncContentAndRender(t,e,n,o=[]){var h;const r=[a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),l=this._univerInstanceService.getUniverDocInstance(t),d=this._docViewModelManagerService.getViewModel(t);if(l==null||d==null||s==null)return;l.getBody().dataStream=e,l.getBody().paragraphs=this._clearParagraph(n),t===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(l.getBody().textRuns=[]),o.length>0&&(l.getBody().textRuns=o),d.reset(l);const{skeleton:c}=s,u=this._renderManagerService.getRenderById(t);u!=null&&(c.calculate(),r.includes(t)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(t){const e=a.Tools.deepClone(t);for(const n of e)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=a.HorizontalAlign.UNSPECIFIED);return e}_autoScroll(){var g,S;const t=(g=this._docSkeletonManagerService.getSkeletonByUnitId(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:g.skeleton,e=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),o=this._univerInstanceService.getUniverDocInstance(a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||e==null||n==null||o==null)return;const{marginTop:r=0,marginBottom:s=0}=o.getSnapshot().documentStyle,{scene:l,mainComponent:d}=n;let{actualHeight:c}=t.getActualSize();c+=r+s;const{width:u,height:h}=e,m=l.getViewport(q.VIEWPORT_KEY.VIEW_MAIN);let f=m==null?void 0:m.getScrollBar();l.transformByState({width:u,height:c}),d==null||d.resize(u,c),c>h?f==null?m&&new w.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(f=null,m==null||m.scrollTo({x:0,y:0}),(S=m==null?void 0:m.getScrollBar())==null||S.dispose())}};Ln=_d([a.OnLifecycle(a.LifecycleStages.Steady,Ln),ze(0,a.IUniverInstanceService),ze(1,w.IRenderManagerService),ze(2,Ee),ze(3,a.ICommandService),ze(4,a.IContextService),ze(5,On),ze(6,a.IUndoRedoService),ze(7,P.Inject(q.DocSkeletonManagerService)),ze(8,P.Inject(q.DocViewModelManagerService)),ze(9,P.Inject(q.TextSelectionManagerService))],Ln);const Nr={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container"};var pd=Object.defineProperty,vd=Object.getOwnPropertyDescriptor,Cd=(i,t,e,n)=>{for(var o=n>1?void 0:n?vd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&pd(t,e,o),o},Ne=(i,t)=>(e,n)=>t(e,n,i);const xr=-1e3,Ar=5,Id=2;let Un=class extends a.Disposable{constructor(t,e,n,o,r,s,l,d,c,u,h,m){super();I(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=t,this._docViewModelManagerService=e,this._contextService=n,this._univerInstanceService=o,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=l,this._textSelectionRenderManager=d,this._textSelectionManagerService=c,this._commandService=u,this._localService=h,this._editorService=m,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const t=this._getEditorObject();t!=null&&this.disposeWithMe(a.toDisposable(t.document.onPointerDownObserver.add(()=>{var e;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),o=this._editorBridgeService.getCurrentEditorId();if(n==null||o==null||!this._editorService.isSheetEditor(o))return;const r=(e=this._docSkeletonManagerService.getSkeletonByUnitId(o))==null?void 0:e.skeleton;if(r==null)return;const{position:s,documentLayoutObject:l,canvasOffset:d,scaleX:c,scaleY:u}=n;this._fitTextSize(s,d,r,l,c,u)}})))}_initialCursorSync(){this.disposeWithMe(this._cellEditorManagerService.focus$.pipe(k.filter(t=>!!t)).subscribe(()=>{this._textSelectionRenderManager.sync()}))}_initialEditFocusListener(){this.disposeWithMe(this._editorBridgeService.currentEditCellState$.subscribe(t=>{if(t==null||this._editorBridgeService.isForceKeepVisible())return;const{position:e,documentLayoutObject:n,scaleX:o,editorUnitId:r}=t;if(this._getEditorObject()==null)return;const{startX:l,endX:d}=e,{textRotation:c,wrapStrategy:u,documentModel:h}=n,{vertexAngle:m}=w.convertTextRotation(c);h.updateDocumentId(r),u===a.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((d-l)/o),this._univerInstanceService.changeDoc(r,h),this._contextService.setContextValue(a.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(xr,xr)}))}_fitTextSize(t,e,n,o,r=1,s=1){const{startX:l,startY:d,endX:c,endY:u}=t,h=o.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:f}=this._predictingSize(t,e,n,o,r,s),{verticalAlign:g,paddingData:S,fill:p}=o;let R=c-l,M=u-d;if(R<m&&(R=m),M<f)M=f,h.updateDocumentDataMargin(S);else{let T=0;g===a.VerticalAlign.MIDDLE?T=(M-f)/2/s:g===a.VerticalAlign.TOP?T=S.t||0:T=(M-f)/s-(S.b||0),T=T<(S.t||0)?S.t||0:T,h.updateDocumentDataMargin({t:T})}n.calculate(),this._editAreaProcessing(R,M,t,e,p,r,s)}_predictingSize(t,e,n,o,r=1,s=1){const{startX:l,endX:d}=t,{textRotation:c,wrapStrategy:u}=o,h=o.documentModel,{vertexAngle:m}=w.convertTextRotation(c),f=document.body.clientWidth;if(u===a.WrapStrategy.WRAP&&m===0){const{actualWidth:p,actualHeight:R}=n.getActualSize();return{actualWidth:p*r,actualHeight:R*s}}h==null||h.updateDocumentDataPageSize((f-l-e.left)/r),n.calculate();const g=n.getActualSize();let S=d-l;return S<g.actualWidth*r+Ar*r&&(S=g.actualWidth*r+Ar*r),h==null||h.updateDocumentDataPageSize(S/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:a.HorizontalAlign.UNSPECIFIED,cellValueType:void 0}),{actualWidth:S,actualHeight:g.actualHeight*s}}_editAreaProcessing(t,e,n,o,r,s=1,l=1){var E;const d=this._getEditorObject();if(d==null)return;let{startX:c,startY:u}=n;const{document:h,scene:m,engine:f}=d,g=m.getViewport(q.VIEWPORT_KEY.VIEW_MAIN),S=document.body.clientHeight-u-Number.parseFloat(Nr.sheetFooterBarHeight)-o.top-Id*2,p=document.body.clientWidth-c-o.left;let R=e,M=g==null?void 0:g.getScrollBar();R>S?(R=S,M==null?g&&new w.ScrollBar(g,{enableHorizontal:!1,barSize:8}):g==null||g.resetSizeAndScrollBar()):(M=null,(E=g==null?void 0:g.getScrollBar())==null||E.dispose()),t+=(M==null?void 0:M.barSize)||0,t>p&&(t=p),c-=w.FIX_ONE_PIXEL_BLUR_OFFSET,u-=w.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,t/s,e/l,r);const{scaleX:T,scaleY:b}=m.getPrecisionScale();m.transformByState({width:t/s,height:e/l,scaleX:s,scaleY:l}),h.resize(t/s,e/l),requestIdleCallback(()=>{f.resizeBySize(w.fixLineWidthByScale(t,T),w.fixLineWidthByScale(R,b))}),this._cellEditorManagerService.setState({startX:c,startY:u,endX:t+c,endY:R+u,show:!0})}_addBackground(t,e,n,o){const r="_backgroundRectHelperColor_",s=t.getObject(r);s==null&&o==null||(s==null?t.addObjects([new w.Rect(r,{width:e,height:n,fill:o,evented:!1})],q.DOCS_COMPONENT_MAIN_LAYER_INDEX):o==null?s.dispose():(s.setProps({fill:o}),s.transformByState({width:e,height:n})))}_initialStartEdit(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var E,y;const{visible:e,eventType:n,keycode:o}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!1){this._setOpenForCurrent(null,null);return}const r=this._editorBridgeService.getEditCellState();if(r==null)return;const{position:s,documentLayoutObject:l,canvasOffset:d,scaleX:c,scaleY:u,editorUnitId:h,unitId:m,sheetId:f,isInArrayFormulaRange:g=!1}=r,S=this._getEditorObject();if(S==null)return;this._setOpenForCurrent(m,f);const{document:p,scene:R}=S;this._contextService.setContextValue(a.EDITOR_ACTIVATED,!0);const{documentModel:M}=l,T=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(T==null||M==null)return;const{skeleton:b}=T;if(this._fitTextSize(s,d,b,l,c,u),n===w.DeviceInputEventType.Keyboard||n===w.DeviceInputEventType.Dblclick&&g){const O=a.Tools.deepClone(M.snapshot),x=this._docViewModelManagerService.getViewModel(h);if(x==null)return;this._resetBodyStyle(O.body,!!g),M.reset(O),x.reset(M),p.makeDirty(),(o===C.KeyCode.BACKSPACE||n===w.DeviceInputEventType.Dblclick)&&(b.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===w.DeviceInputEventType.Dblclick){const O=M.getBody().dataStream.length-2||0;(E=R.getViewport(q.VIEWPORT_KEY.VIEW_MAIN))==null||E.scrollTo({y:Number.POSITIVE_INFINITY}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O}])}(y=this._renderManagerService.getRenderById(m))==null||y.scene.resetCursor()}))}_resetBodyStyle(t,e=!1){t.dataStream=a.DEFAULT_EMPTY_DOCUMENT_VALUE,t.textRuns!=null&&(t.textRuns.length===1&&!e?(t.textRuns[0].st=0,t.textRuns[0].ed=1):t.textRuns=void 0),t.paragraphs!=null&&(t.paragraphs.length===1?t.paragraphs[0].startIndex=0:t.paragraphs=[{startIndex:0}]),t.sectionBreaks!=null&&(t.sectionBreaks=void 0),t.tables!=null&&(t.tables=void 0),t.customRanges!=null&&(t.customRanges=void 0),t.customBlocks!=null&&(t.customBlocks=void 0)}_initialKeyboardListener(){this.disposeWithMe(this._textSelectionRenderManager.onInputBefore$.subscribe(t=>{const e=this._contextService.getContextValue(a.FOCUSING_FORMULA_EDITOR),n=this._contextService.getContextValue(a.FOCUSING_SHEET),o=this._univerInstanceService.getCurrentUniverDocInstance().getUnitId();n&&!e&&this._editorService.isSheetEditor(o)&&this._showEditorByKeyboard(t)}))}_showEditorByKeyboard(t){if(t==null)return;const e=t.event;this._commandService.executeCommand(ye.id,{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:e.which})}_commandExecutedListener(){const t=[q.RichTextEditingMutation.id,C.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const o=e.params,{unitId:r}=o;if(!this._editorService.isSheetEditor(r))return;const s=this._editorBridgeService.getCurrentEditorId();if(s==null)return;this._editorBridgeService.changeEditorDirty(!0);const l=(n=this._docSkeletonManagerService.getSkeletonByUnitId(s))==null?void 0:n.skeleton;if(l==null)return;const d=this._editorBridgeService.getEditCellState();if(d==null)return;const{position:c,documentLayoutObject:u,canvasOffset:h,scaleX:m,scaleY:f}=d;this._fitTextSize(c,h,l,u,m,f)}}))}_setOpenForCurrent(t,e){const n=this._editorService.getAllEditor();for(const[o,r]of n)r.isSheetEditor()&&(r.setOpenForSheetUnitId(t),r.setOpenForSheetSubUnitId(e))}_getEditorObject(){return _n(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};Un=Cd([a.OnLifecycle(a.LifecycleStages.Rendered,Un),Ne(0,P.Inject(q.DocSkeletonManagerService)),Ne(1,P.Inject(q.DocViewModelManagerService)),Ne(2,a.IContextService),Ne(3,a.IUniverInstanceService),Ne(4,w.IRenderManagerService),Ne(5,Ee),Ne(6,tn),Ne(7,w.ITextSelectionRenderManager),Ne(8,P.Inject(q.TextSelectionManagerService)),Ne(9,a.ICommandService),Ne(10,P.Inject(a.LocaleService)),Ne(11,C.IEditorService)],Un);const Vn={id:"sheet.command.change-zoom-ratio",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const e=i.get(a.IUniverInstanceService),n=_.getSheetCommandTarget(e);if(!n)return!1;const{worksheet:o,subUnitId:r,unitId:s}=n,{delta:l,reset:d}=t;let c=d?100:Math.round((o.getConfig().zoomRatio+l)*100);c=Math.max(vi[0],c),c=Math.min(vi[1],c);const u=c/100;return i.get(a.ICommandService).executeCommand(Le.id,{unitId:s,subUnitId:r,zoomRatio:u})}},Bn={id:"sheet.command.set-zoom-ratio",type:a.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{unitId:e,subUnitId:n,zoomRatio:o}=t;return i.get(a.ICommandService).executeCommand(Le.id,{unitId:e,subUnitId:n,zoomRatio:o})}},Dr={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(i,t)=>(i.get(Ee).setEditCell(t),!0)};var Rd=Object.defineProperty,Md=Object.getOwnPropertyDescriptor,bd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Md(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Rd(t,e,o),o},Be=(i,t)=>(e,n)=>t(e,n,i);let kn=class extends a.RxDisposable{constructor(i,t,e,n,o,r,s,l,d,c,u){super(),this._injector=i,this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._layoutService=s,this._editorService=l,this._contextService=d,this._selectionManagerService=c,this._rangeSelectorService=u,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initSelectionChangeListener(),this._initialEventListener(),this._initialChangeEditorListener(),this._initialRangeSelector()}_initSelectionChangeListener(){k.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(k.takeUntil(this.dispose$)).subscribe(i=>this._handleSelectionListener(i))}_handleSelectionListener(i){const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible===!0)return;const e=this._injector.get(w.ITextSelectionRenderManager,P.Quantity.OPTIONAL);if(!this._layoutService.checkCanvasIsFocused()&&e&&!e.hasFocus())return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null||i==null||i.length===0||i[i.length-1]==null)return;const{primary:o}=i[i.length-1];if(o==null)return;const r=this._getSheetObject();if(r==null)return;const{unitId:s,sheetId:l}=n,{scene:d,engine:c}=r;this._commandService.executeCommand(Dr.id,{scene:d,engine:c,primary:o,unitId:s,sheetId:l})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:t,spreadsheetColumnHeader:e,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:o}=i;t.onDblclickObserver.add(r=>{if(r.button===2)return;const s=this._selectionManagerService.getCurrent();(s==null?void 0:s.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&this._commandService.executeCommand(ye.id,{visible:!0,eventType:w.DeviceInputEventType.Dblclick})}),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),o.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_initialChangeEditorListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_DOC).subscribe(i=>{if(i==null)return;const t=i.getUnitId();this._editorService.isEditor(t)&&(this._editorService.isSheetEditor(t)?(this._contextService.setContextValue(a.FOCUSING_DOC,!1),this._contextService.setContextValue(a.FOCUSING_SHEET,!0)):(this._contextService.setContextValue(a.FOCUSING_SHEET,!1),this._contextService.setContextValue(a.FOCUSING_DOC,!0),this._hideEditor()))}))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(ye.id,{visible:!1,eventType:w.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_initialRangeSelector(){this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._selectionManagerService.selectionMoveStart$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._rangeSelectorService.openSelector$.subscribe(()=>{const i=this._selectionManagerService.getSelections(),{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i==null?void 0:i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));o&&this._rangeSelectorService.selectionChange(o)}))}_rangeSelector(i){if(!i)return;const{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),o=i.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));this._rangeSelectorService.selectionChange(o)}_getCurrentUnitIdAndSheetId(){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=i.getActiveSheet();return{unitId:i.getUnitId(),sheetId:t.getSheetId(),sheetName:t.getName()}}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_commandExecutedListener(){const i=_.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((t,e)=>{e!=null&&e.fromCollab||(t.id===_.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(t.id)&&this._hideEditor())})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===Bn.id&&this._editorBridgeService.refreshEditCellState()}))}};kn=bd([a.OnLifecycle(a.LifecycleStages.Rendered,kn),Be(0,P.Inject(P.Injector)),Be(1,P.Inject(N.SheetSkeletonManagerService)),Be(2,a.IUniverInstanceService),Be(3,a.ICommandService),Be(4,w.IRenderManagerService),Be(5,Ee),Be(6,C.ILayoutService),Be(7,C.IEditorService),Be(8,a.IContextService),Be(9,P.Inject(_.SelectionManagerService)),Be(10,C.IRangeSelectorService)],kn);var Td=Object.defineProperty,wd=Object.getOwnPropertyDescriptor,Ed=(i,t,e,n)=>{for(var o=n>1?void 0:n?wd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Td(t,e,o),o},rn=(i,t)=>(e,n)=>t(e,n,i);let Fn=class extends a.Disposable{constructor(i,t,e,n,o){super(),this._commandService=i,this._formatPainterService=t,this._univerInstanceService=e,this._renderManagerService=n,this._selectionRenderService=o,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:t}=this._getSheetObject()||{};t&&(i!==Ue.OFF?t.setDefaultCursor(w.CURSOR_TYPE.CELL):t.setDefaultCursor(w.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(a.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{if(this._formatPainterService.getStatus()!==Ue.OFF){const{rangeWithCoord:t}=i[i.length-1];this._applyFormatPainter({startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}),this._formatPainterService.getStatus()===Ue.ONCE&&this._commandService.executeCommand(Wi.id)}})))}async _applyFormatPainter(i){const{styles:t,merges:e}=this._formatPainterService.getSelectionFormat(),n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=n.getUnitId(),r=n.getActiveSheet().getSheetId();if(!t)return;const{startRow:s,startColumn:l,endRow:d,endColumn:c}=t.getDataRange(),u=d-s+1,h=c-l+1,m=Array.from({length:i.endRow-i.startRow+1},()=>Array.from({length:i.endColumn-i.startColumn+1},()=>({}))),f=[];m.forEach((S,p)=>{S.forEach((R,M)=>{const T=p%u+s,b=M%h+l,E=t.getValue(T,b);E&&(m[p][M].s=E)})}),e.forEach(S=>{const p={startRow:S.startRow-s,startColumn:S.startColumn-l,endRow:S.endRow-s,endColumn:S.endColumn-l},R=Math.max(1,Math.floor((i.endRow-i.startRow+1)/u)),M=Math.max(1,Math.floor((i.endColumn-i.startColumn+1)/h));for(let T=0;T<R;T++)for(let b=0;b<M;b++)f.push({startRow:p.startRow+T*u+i.startRow,startColumn:p.startColumn+b*h+i.startColumn,endRow:p.endRow+T*u+i.startRow,endColumn:p.endColumn+b*h+i.startColumn})});const g={subUnitId:r,unitId:o,styleRange:i,styleValues:m,mergeRanges:f};await this._commandService.executeCommand(cr.id,g)}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}};Fn=Ed([a.OnLifecycle(a.LifecycleStages.Rendered,Fn),rn(0,a.ICommandService),rn(1,wt),rn(2,a.IUniverInstanceService),rn(3,w.IRenderManagerService),rn(4,Ie)],Fn);var yd=Object.defineProperty,Od=Object.getOwnPropertyDescriptor,Nd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Od(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&yd(t,e,o),o},ut=(i,t)=>(e,n)=>t(e,n,i);const xd="__SpreadsheetFreezeRowMainName__",Ad="__SpreadsheetFreezeRowHeaderName__",Dd="__SpreadsheetFreezeColumnMainName__",Pd="__SpreadsheetFreezeColumnHeaderName__",Gi=4,Hd=.01;let Wn=class extends a.Disposable{constructor(t,e,n,o,r,s,l,d){super();I(this,"_rowFreezeHeaderRect");I(this,"_rowFreezeMainRect");I(this,"_columnFreezeHeaderRect");I(this,"_columnFreezeMainRect");I(this,"_freezeDownObservers",[]);I(this,"_freezeMoveObservers",[]);I(this,"_freezeLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_changeToRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToOffsetX",0);I(this,"_changeToOffsetY",0);I(this,"_activeViewport",null);I(this,"_freezeNormalHeaderColor","");I(this,"_freezeNormalMainColor","");I(this,"_freezeActiveColor","");I(this,"_freezeHoverColor","");I(this,"_lastFreeze");this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._selectionManagerService=o,this._scrollManagerService=r,this._themeService=s,this._sheetInterceptorService=l,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(t=0,e){var O;const n=e!=null?e:this._getFreeze();if(n==null)return null;const o=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton,{startRow:r,startColumn:s}=n,l=this._getPositionByIndex(r,s);if(l==null)return null;const d=this._getSheetObject(),c=d.engine,u=(c==null?void 0:c.width)||0,h=(c==null?void 0:c.height)||0,m=d.scene,{startX:f,startY:g}=l,{rowTotalHeight:S,columnTotalWidth:p,rowHeaderWidthAndMarginLeft:R,columnHeaderHeightAndMarginTop:M}=o,T=u>p+R?u:p+M,b=h>S+M?h:S+M;this._changeToRow=r,this._changeToColumn=s,this._changeToOffsetX=f,this._changeToOffsetY=g;const E=Math.max(m.scaleX,m.scaleY),y=Gi/(E<1?1:E);if(t===0){const x=y;this._rowFreezeHeaderRect=new w.Rect(Ad,{fill:this._freezeNormalHeaderColor,width:R,height:y,left:0,top:g-x,zIndex:3});let D=this._freezeNormalHeaderColor;(r===-1||r===0)&&(D=this._freezeNormalMainColor),this._rowFreezeMainRect=new w.Rect(xd,{fill:D,width:T*2,height:y,left:R,top:g-x,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],tt)}else{const x=y;this._columnFreezeHeaderRect=new w.Rect(Pd,{fill:this._freezeNormalHeaderColor,width:y,height:M,left:f-x,top:0,zIndex:3});let D=this._freezeNormalHeaderColor;(s===-1||s===0)&&(D=this._freezeNormalMainColor),this._columnFreezeMainRect=new w.Rect(Dd,{fill:D,width:y,height:b*2,left:f-x,top:M,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],tt)}this._eventBinding(t)}_eventBinding(t=0){let e=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;t===1&&(e=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:r}=o;this._freezeMoveObservers.push(e==null?void 0:e.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(e==null?void 0:e.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(e==null?void 0:e.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)}))}_getCurrentLastVisibleRow(){var h,m,f,g;const t=this._getSheetObject();if(t==null)return;const e=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(e==null)return;const n=t.scene,o=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(t.engine.height-e.columnHeaderHeight)/o,l=(m=r==null?void 0:r.sheetViewStartRow)!=null?m:0,d=l===0?-((f=r==null?void 0:r.offsetY)!=null?f:0):e.rowHeightAccumulation[l-1]-((g=r==null?void 0:r.offsetY)!=null?g:0);let c=0,u=!1;for(let S=l,p=e.rowHeightAccumulation.length;S<p;S++)if(e.rowHeightAccumulation[S]-d>s){c=S,u=!0;break}return u||(c=e.rowHeightAccumulation.length-1),c}_getActiveViewport(t){var n;const e=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return e&&e.find(o=>o.isHit(new w.Vector2(t.offsetX,t.offsetY)))||null}_freezeDown(t,e,n,o=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:l}=s;l.setCursor(w.CURSOR_TYPE.GRABBING),l.disableEvent();const d=this._getCurrentLastVisibleRow(),c=d===void 0?Number.POSITIVE_INFINITY:r.rowHeightAccumulation[d];this._activeViewport=null;const u=this._getFreeze();u&&(this._changeToColumn=u.startColumn,this._changeToRow=u.startRow),this._moveObserver=l.onPointerMoveObserver.add(m=>{var T,b,E,y;const f=this._getActiveViewport(m),{startX:g,startY:S,row:p,column:R}=Mt(m.offsetX,m.offsetY,l,r,f||void 0);l.setCursor(w.CURSOR_TYPE.GRABBING);const M=Gi/Math.max(l.scaleX,l.scaleY);o===0?((T=e.transformByState({top:Math.min(S,c)-M/2}))==null||T.setProps({fill:this._freezeActiveColor}),(b=n.transformByState({top:Math.min(S,c)-M/2}))==null||b.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=d===void 0?p:Math.min(p,d),this._changeToOffsetY=Math.min(S,c),this._activeViewport=f):((E=e.transformByState({left:g-M/2}))==null||E.setProps({fill:this._freezeActiveColor}),(y=n.transformByState({left:g-M/2}))==null||y.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=R,this._changeToOffsetX=g,this._activeViewport=f)}),this._upObserver=l.onPointerUpObserver.add(()=>{var x,D;l.resetCursor(),l.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:f}=r;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(e.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(e==null||e.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const g=Gi/Math.max(l.scaleX,l.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(e.transformByState({top:f-g}),n.transformByState({top:f-g})):(this._changeToColumn===0||this._changeToColumn===-1)&&(e.transformByState({left:m-g}),n.transformByState({left:m-g}));const S=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:p,sheetViewStartColumn:R}=S;if(R==null||p==null)return;const M=this._context.unit,T=M.getActiveSheet(),b=(x=T.getConfig())==null?void 0:x.freeze;let E=(b==null?void 0:b.xSplit)||0,y=(b==null?void 0:b.ySplit)||0;const O=(D=this._activeViewport)==null?void 0:D.viewPortKey;o===0&&(!O||O===j.VIEW_LEFT_TOP||O===j.VIEW_MAIN_LEFT_TOP||O===j.VIEW_MAIN_TOP||O===j.VIEW_ROW_TOP?y=this._changeToRow-(b.startRow-b.ySplit):y=this._changeToRow-p,y=y<0?0:y),o===1&&(!O||O===j.VIEW_LEFT_TOP||O===j.VIEW_MAIN_LEFT_TOP||O===j.VIEW_MAIN_LEFT||O===j.VIEW_COLUMN_LEFT?E=this._changeToColumn-(b.startColumn-b.xSplit):E=this._changeToColumn-R,E=E<0?0:E),this._commandService.executeCommand(_.SetFrozenCommand.id,{startRow:y===0?-1:this._changeToRow,startColumn:E===0?-1:this._changeToColumn,ySplit:y,xSplit:E,unitId:M.getUnitId(),subUnitId:T.getSheetId()})})}_getViewports(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t,n=e.getViewport(j.VIEW_COLUMN_LEFT),o=e.getViewport(j.VIEW_COLUMN_RIGHT),r=e.getViewport(j.VIEW_ROW_TOP),s=e.getViewport(j.VIEW_ROW_BOTTOM),l=e.getViewport(j.VIEW_LEFT_TOP),d=e.getViewport(j.VIEW_MAIN),c=e.getViewport(j.VIEW_MAIN_LEFT_TOP),u=e.getViewport(j.VIEW_MAIN_LEFT),h=e.getViewport(j.VIEW_MAIN_TOP);if(!(n==null||o==null||r==null||s==null||l==null||d==null||c==null||u==null||h==null))return{viewMain:d,viewMainLeftTop:c,viewMainLeft:u,viewMainTop:h,viewColumnLeft:n,viewColumnRight:o,viewRowTop:r,viewRowBottom:s,viewLeftTop:l}}_bindViewportScroll(){const t=this._getViewports();if(!t)return;const{viewMain:e,viewRowBottom:n,viewColumnRight:o,viewMainLeft:r,viewMainTop:s}=t;this.disposeWithMe(e.onScrollAfterObserver.add(l=>{const{scrollX:d,scrollY:c,actualScrollX:u,actualScrollY:h}=l;n.isActive&&n.updateScroll({scrollY:c,actualScrollY:h}),o.isActive&&o.updateScroll({scrollX:d,actualScrollX:u}),r.isActive&&r.updateScroll({scrollY:c,actualScrollY:h}),s.isActive&&s.updateScroll({scrollX:d,actualScrollX:u})}))}_updateViewport(t=-1,e=-1,n=0,o=0,r=3){var O;const s=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(s==null)return;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:d}=s,c=this._getViewports();if(!c)return;const{viewMain:u,viewMainLeftTop:h,viewMainLeft:m,viewMainTop:f,viewColumnLeft:g,viewColumnRight:S,viewRowTop:p,viewRowBottom:R,viewLeftTop:M}=c;S.resize({left:l,top:0,height:d,right:0}),R.resize({left:0,top:d,bottom:0,width:l}),M.resize({left:0,top:0,width:l,height:d});let T=!0,b=!0;h.enable(),(t===-1||t===0)&&(T=!1),(e===-1||e===0)&&(b=!1);const E=s.getNoMergeCellPositionByIndexWithNoHeader(t-n,e-o),y=s.getNoMergeCellPositionByIndexWithNoHeader(t,e);if(h.disable(),f.disable(),m.disable(),p.disable(),g.disable(),h.resetPadding(),f.resetPadding(),m.resetPadding(),p.resetPadding(),g.resetPadding(),T===!1&&b===!1)u.resize({left:l,top:d,bottom:0,right:0}),u.resetPadding();else if(T===!0&&b===!1){const x=y.startY-E.startY;u.resize({left:l,top:d+x,bottom:0,right:0}),u.setPadding({startY:E.startY,endY:y.startY,startX:0,endX:0}),r&2&&this._commandService.executeCommand(dt.id,{sheetViewStartRow:0,offsetY:0}),f.resize({left:l,top:d,height:x,right:0}),f.updateScroll({actualScrollY:E.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),p.resize({left:0,top:d,width:l,height:x}),p.updateScroll({actualScrollY:E.startY}),R.resize({left:0,top:d+x,bottom:0,width:l}),f.enable(),p.enable()}else if(T===!1&&b===!0){const x=y.startX-E.startX;u.resize({left:l+x,top:d,bottom:0,right:0}),u.setPadding({startX:E.startX,endX:y.startX,startY:0,endY:0}),r&1&&this._commandService.executeCommand(dt.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:l,top:d,width:x,bottom:0,right:0}),m.updateScroll({actualScrollX:E.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),g.resize({left:l,top:0,width:x,height:d}),g.updateScroll({actualScrollX:E.startX}),S.resize({left:l+x,top:0,height:d,right:0}),m.enable(),g.enable()}else{const x=y.startX-E.startX,D=y.startY-E.startY;u.resize({left:l+x,top:d+D,bottom:0,right:0}),u.setPadding({startY:E.startY,endY:y.startY,startX:E.startX,endX:y.startX}),r&&this._commandService.executeCommand(dt.id,{...r&1?{sheetViewStartColumn:0,offsetX:0}:null,...r&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:l,top:d+D,width:x,bottom:0}),m.updateScroll({actualScrollX:E.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),f.resize({left:l+x,top:d,height:D,right:0}),f.updateScroll({actualScrollY:E.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),h.resize({left:l,top:d,width:x,height:D}),h.updateScroll({actualScrollX:E.startX,actualScrollY:E.startY}),p.resize({left:0,top:d,width:l,height:D}),p.updateScroll({actualScrollY:E.startY}),R.resize({left:0,top:d+D,bottom:0,width:l}),g.resize({left:l,top:0,width:x,height:d}),g.updateScroll({actualScrollX:E.startX}),S.resize({left:l+x,top:0,height:d,right:0}),h.enable(),f.enable(),m.enable(),p.enable(),g.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{[_.SetWorksheetActiveOperation.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id].includes((t==null?void 0:t.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._context.unit.getActiveSheet().getConfig().freeze,{startRow:o=-1,startColumn:r=-1,ySplit:s=0,xSplit:l=0}=n;this._refreshFreeze(o,r,s,l,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(t=>{this._clearFreeze(),this._themeChange(t),this._refreshCurrent()}))}_themeChange(t){this._freezeNormalHeaderColor=t.grey400,this._freezeNormalMainColor=new a.ColorKit(t.grey400).setAlpha(Hd).toRgbString(),this._freezeActiveColor=t.primaryColor,this._freezeHoverColor=t.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{const e={redos:[],undos:[]},n=this._getFreeze();if(!n)return e;const o=r=>{const s=this._context.unit,l=s.getUnitId(),c=s.getActiveSheet().getSheetId();this._refreshFreeze(r.startRow,r.startColumn,r.ySplit,r.xSplit,0);const u={...r,unitId:l,subUnitId:c,resetScroll:!1},h=_.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:_.SetFrozenMutation.id,params:h}],redos:[{id:_.SetFrozenMutation.id,params:u}]}};if(t.id===_.InsertRowCommand.id){const s=t.params.range,l=s.endRow-s.startRow+1;if(s.startRow<=n.startRow){const d={...n,startRow:Math.max(1,n.startRow+l),ySplit:Math.max(1,n.ySplit+l)};return o(d)}}if(t.id===_.InsertColCommand.id){const s=t.params.range,l=s.endColumn-s.startColumn+1;if(s.startColumn<=n.startColumn){const d={...n,startColumn:Math.max(1,n.startColumn+l),xSplit:Math.max(1,n.xSplit+l)};return o(d)}}if(t.id===_.MoveColsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:l}}=t.params,d=r==null?void 0:r.filter(p=>p.range.rangeType===a.RANGE_TYPE.COLUMN&&p.range.startColumn<=s&&s<=p.range.endColumn);if(!(d!=null&&d.length))return e;const c=d[0].range,u={...c,startColumn:l,endColumn:l+c.endColumn-c.startColumn};if(!n||n.startColumn<=0||c.startColumn>=n.startColumn&&u.startColumn>=n.startColumn||c.startColumn===u.startColumn||c.endColumn<n.startColumn&&u.startColumn<n.startColumn)return e;const h=c.endColumn-c.startColumn+1,m=Math.max(Math.min(n.startColumn,c.endColumn+1)-c.startColumn,0);let f,g;u.startColumn>=n.startColumn?(f=Math.max(n.startColumn-m,1),g=Math.max(n.xSplit-m,1)):(f=n.startColumn+h-m,g=n.xSplit+h-m);const S={...n,startColumn:f,xSplit:g};return o(S)}if(t.id===_.MoveRowsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:l}}=t.params,d=r==null?void 0:r.filter(p=>p.range.rangeType===a.RANGE_TYPE.ROW&&p.range.startRow<=s&&s<=p.range.endRow);if(!(d!=null&&d.length))return e;const c=d[0].range,u={...c,startRow:l,endRow:l+c.endRow-c.startRow};if(!n||n.startRow<=0||c.startRow>=n.startRow&&u.startRow>=n.startRow||c.startRow===u.startRow||c.endRow<n.startRow&&u.startRow<n.startRow)return e;const h=c.endRow-c.startRow+1,m=Math.max(Math.min(n.startRow,c.endRow+1)-c.startRow,0);let f,g;u.startRow>=n.startRow?(f=Math.max(n.startRow-m,1),g=Math.max(n.ySplit-m,1)):(f=n.startRow+h-m,g=n.ySplit+h-m);const S={...n,startRow:f,ySplit:g};return o(S)}if(t.id===_.RemoveColCommand.id||t.id===_.RemoveRowCommand.id){const r=t.params,s=r.range;if(s.rangeType===a.RANGE_TYPE.COLUMN&&s.startColumn<n.startColumn){const l=Math.min(n.startColumn,s.endColumn+1)-s.startColumn,d={...n,startColumn:Math.max(1,n.startColumn-l),xSplit:Math.max(1,n.xSplit-l)};return o(d)}if(r.range.rangeType===a.RANGE_TYPE.ROW&&s.startRow<n.startRow){const l=Math.min(n.startRow,s.endRow+1)-s.startRow,d={...n,startRow:Math.max(1,n.startRow-l),ySplit:Math.max(1,n.ySplit-l)};return o(d)}}return e}}))}_commandExecutedListener(){const t=[_.SetFrozenMutation.id,Le.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=this._lastFreeze,o=this._context.unit,r=o.getActiveSheet(),s=e.params,{unitId:l,subUnitId:d}=s;if(!(l===o.getUnitId()&&d===r.getSheetId()))return;const c=r.getConfig().freeze;if(this._lastFreeze=c,c==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:f=0,xSplit:g=0}=c;(!n||n.startRow!==h||n.ySplit!==f)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==g)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,f,g,u)}else if(e.id===_.SetWorksheetRowHeightMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startRow<n.startRow)&&this._refreshCurrent()}else if(e.id===_.SetWorksheetColWidthMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(o=>o.startColumn<n.startColumn)&&this._refreshCurrent()}else if(e.id===_.SetWorksheetRowAutoHeightMutation.id){const n=e.params,o=this._getFreeze();if(o&&o.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<o.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}else if(e.id===_.SetColHiddenMutation.id||e.id===_.SetColVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startColumn>-1&&r.some(s=>s.startColumn<o.startColumn)&&this._refreshCurrent()}else if(e.id===_.SetRowHiddenMutation.id||e.id===_.SetRowVisibleMutation.id){const n=e.params,o=this._getFreeze(),r=n.ranges;o&&o.startRow>-1&&r.some(s=>s.startRow<o.startRow)&&this._refreshCurrent()}}))}_zoomRefresh(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onTransformChangeObservable.add(n=>{n.type===w.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._refreshCurrent()})}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,o,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(o=this._rowFreezeMainRect)==null||o.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(l=>{e.onPointerDownObserver.remove(l),e.onPointerMoveObserver.remove(l),e.onPointerLeaveObserver.remove(l)}),e.onPointerEnterObserver.remove(this._moveObserver),e.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(t,e){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrent())==null?void 0:d.skeleton,r=o==null?void 0:o.getNoMergeCellPositionByIndex(t,e);if(o==null)return;if(r!=null&&(!isNaN(r.endX)||!isNaN(r.endY)))return r;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:l}=o;return{startX:s,endX:s,startY:l,endY:l}}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_getSheetObject(){return Me(this._context.unit,this._context)}_refreshFreeze(t,e,n,o,r){var l;const s={startRow:t,startColumn:e,ySplit:n,xSplit:o};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(t,e,n,o,r),(l=this._getSheetObject())==null||l.spreadsheet.makeForceDirty()}};Wn=Nd([ut(1,P.Inject(N.SheetSkeletonManagerService)),ut(2,a.ICommandService),ut(3,P.Inject(_.SelectionManagerService)),ut(4,P.Inject($e)),ut(5,P.Inject(a.ThemeService)),ut(6,P.Inject(_.SheetInterceptorService)),ut(7,P.Inject(P.Injector))],Wn);var Zi=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(Zi||{});const Ld="rgba(0, 0, 0, 0.15)",Ze="rgb(0, 0, 0)",jn="rgb(255, 255, 255, 1)";class Ud extends w.Shape{constructor(e,n){super(e,n);I(this,"_size",12);I(this,"_iconRatio",.4);I(this,"_mode",0);this.setShapeProps(n)}setShapeProps(e){e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),this.transformByState({width:this._size,height:this._size})}_draw(e){this._mode===1&&w.Rect.drawWith(e,{width:this._size,height:this._size,radius:this._size,fill:Ld});const n=this._size*.5*this._iconRatio,o=Math.PI/180*60,r=n*Math.sin(o),s=n*Math.cos(o);w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Ze})}}var Vd=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,kd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Bd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Vd(t,e,o),o},Nt=(i,t)=>(e,n)=>t(e,n,i);const Fd="__SpreadsheetHeaderMenuSHAPEControllerShape__",Wd="__SpreadsheetHeaderMenuMAINControllerShape__",jd="rgba(0, 0, 0, 0.1)";let zn=class extends a.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_hoverRect");I(this,"_hoverMenu");I(this,"_currentColumn",Number.POSITIVE_INFINITY);I(this,"_observers",[]);this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._renderManagerService=n,this._contextMenuService=o,this._commandService=r,this._selectionManagerService=s,this._initialize()}dispose(){var o,r;(o=this._hoverRect)==null||o.dispose(),(r=this._hoverMenu)==null||r.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerEnterObserver.remove(s),e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._hoverRect=new w.Rect(Fd,{fill:jd,evented:!1}),this._hoverMenu=new Ud(Wd,{zIndex:100,visible:!1}),e.addObjects([this._hoverRect,this._hoverMenu],tt),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:o}=e,r=t===0?o:n;this._observers.push(r==null?void 0:r.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var p,R,M;const l=(p=this._sheetSkeletonManagerService.getCurrent())==null?void 0:p.skeleton;if(l==null)return;const d=this._getSheetObject();if(d==null)return;const{rowHeaderWidth:c,columnHeaderHeight:u}=l,{startX:h,startY:m,endX:f,endY:g,column:S}=Mt(s.offsetX,s.offsetY,d.scene,l);if(t===0)(R=this._hoverRect)==null||R.transformByState({width:c,height:g-m,left:0,top:m});else{if(this._currentColumn=S,(M=this._hoverRect)==null||M.transformByState({width:f-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(f-h<u*2){this._hoverMenu.hide();return}const T=u*.8;this._hoverMenu.transformByState({left:f-u,top:u/2-T/2}),this._hoverMenu.setShapeProps({size:T}),this._hoverMenu.show()}})),this._observers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,l;(s=this._hoverRect)==null||s.hide(),(l=this._hoverMenu)==null||l.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Zi.HIGHLIGHT,visible:!0}),t.scene.setCursor(w.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const t=this._getSheetObject();t!=null&&(this._hoverMenu.setProps({mode:Zi.NORMAL,visible:!1}),t.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(t=>{if(!this._getSheetObject())return;const n=this._currentColumn,o=this._selectionManagerService.getSelectionRanges();if(!!!(o!=null&&o.filter(s=>s.rangeType===a.RANGE_TYPE.COLUMN).find(s=>{const{startColumn:l,endColumn:d}=s;return n>=l&&n<=d}))){const s=this._getSelectionOnColumn(n);this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,s)}t.stopPropagation(),t.preventDefault(),this._contextMenuService.triggerContextMenu(t,le.COL_HEADER_CONTEXT_MENU)}))}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_getSelectionOnColumn(t){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:0,startColumn:t,endRow:n.getRowCount()-1,endColumn:t,rangeType:a.RANGE_TYPE.COLUMN},primary:{startRow:0,startColumn:t,endRow:0,endColumn:t,actualRow:0,actualColumn:t,isMerged:!1,isMergedMainCell:!1},style:null}]}}};zn=kd([a.OnLifecycle(a.LifecycleStages.Rendered,zn),Nt(0,P.Inject(N.SheetSkeletonManagerService)),Nt(1,a.IUniverInstanceService),Nt(2,w.IRenderManagerService),Nt(3,C.IContextMenuService),Nt(4,a.ICommandService),Nt(5,P.Inject(_.SelectionManagerService))],zn);var zd=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Xd=(i,t,e,n)=>{for(var o=n>1?void 0:n?Yd(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&zd(t,e,o),o},xt=(i,t)=>(e,n)=>t(e,n,i);const $d="__SpreadsheetHeaderMoveControllerBackground__",Gd="__SpreadsheetHeaderMoveControllerShapeLine__",Zd="rgba(0, 0, 0, 0.1)",Kd="rgb(119, 119, 119)",Qd=4;let Yn=class extends a.Disposable{constructor(t,e,n,o,r,s){super();I(this,"_startOffsetX",Number.NEGATIVE_INFINITY);I(this,"_startOffsetY",Number.NEGATIVE_INFINITY);I(this,"_moveHelperBackgroundShape");I(this,"_moveHelperLineShape");I(this,"_sheetObject");I(this,"_rowOrColumnDownObservers",[]);I(this,"_rowOrColumnMoveObservers",[]);I(this,"_rowOrColumnLeaveObservers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_scrollTimer");I(this,"_changeFromColumn",-1);I(this,"_changeFromRow",-1);I(this,"_changeToColumn",-1);I(this,"_changeToRow",-1);this._sheetSkeletonManagerService=t,this._univerInstanceService=e,this._renderManagerService=n,this._commandService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._initialize()}dispose(){var r,s;(r=this._moveHelperBackgroundShape)==null||r.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n,scene:o}=t;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(l=>{e.onPointerDownObserver.remove(l),n.onPointerDownObserver.remove(l)}),o.onPointerMoveObserver.remove(this._moveObserver),o.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const t=this._getSheetObject();t!=null&&(this._sheetObject=t,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(t=0){const{spreadsheetColumnHeader:e,spreadsheetRowHeader:n,scene:o}=this._sheetObject,r=t===0?n:e;this._rowOrColumnMoveObservers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var h;const l=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(l==null)return;const{row:d,column:c}=Mt(s.offsetX,s.offsetY,o,l);if(this._checkInHeaderRange(t===0?d:c,t)===!1){o.resetCursor(),this._selectionRenderService.enableSelection();return}o.setCursor(w.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,l;(s=this._moveHelperBackgroundShape)==null||s.hide(),(l=this._moveHelperLineShape)==null||l.hide(),o.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var E;const l=(E=this._sheetSkeletonManagerService.getCurrent())==null?void 0:E.skeleton;if(l==null)return;const{offsetX:d,offsetY:c}=s,u=o.getRelativeCoord(w.Vector2.FromArray([d,c])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:f,column:g}=Mt(s.offsetX,s.offsetY,o,l);let S;t===0?(this._changeFromRow=f,S=w.ScrollTimerType.Y):(this._changeFromColumn=g,S=w.ScrollTimerType.X);const p=this._checkInHeaderRange(t===0?f:g,t);if(p===!1)return;const R=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(w.CURSOR_TYPE.GRABBING),o.disableEvent();let M=!1,T;const b=()=>{if(M)return;T=w.ScrollTimer.create(o,S);const y=o.getViewport(j.VIEW_MAIN);T.startScroll(h,m,y),this._scrollTimer=T,M=!0};this._moveObserver=o.onPointerMoveObserver.add(y=>{b();const{offsetX:O,offsetY:x}=y,{x:D,y:W}=o.getRelativeCoord(w.Vector2.FromArray([O,x]));o.setCursor(w.CURSOR_TYPE.GRABBING),this._rowColumnMoving(D,W,p,R,t),T.scrolling(D,W,()=>{this._rowColumnMoving(D,W,p,R,t)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var O,x,D;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableEvent(),this._clearObserverEvent(),(O=this._scrollTimer)==null||O.dispose();const y=this._selectionManagerService.getSelections();if(t===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const A=(x=((y==null?void 0:y.filter(H=>H.range.rangeType===a.RANGE_TYPE.ROW&&H.range.startRow<=this._changeFromRow&&this._changeFromRow<=H.range.endRow))||[])[0])==null?void 0:x.range;A&&this._commandService.executeCommand(_.MoveRowsCommand.id,{fromRange:A,toRange:{...A,startRow:this._changeToRow,endRow:this._changeToRow+A.endRow-A.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const A=(D=((y==null?void 0:y.filter(H=>H.range.rangeType===a.RANGE_TYPE.COLUMN&&H.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=H.range.endColumn))||[])[0])==null?void 0:D.range;A&&this._commandService.executeCommand(_.MoveColsCommand.id,{fromRange:A,toRange:{...A,startColumn:this._changeToColumn,endColumn:this._changeToColumn+A.endColumn-A.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(t,e,n,o,r){var $,ee,L,U,F,Y,G;const{scene:s}=this._sheetObject,l=($=this._sheetSkeletonManagerService.getCurrent())==null?void 0:$.skeleton;if(l==null)return;const{rowHeaderWidth:d,columnHeaderHeight:c,rowTotalHeight:u,columnTotalWidth:h}=l,m=s.getScrollXY(s.getViewport(j.VIEW_MAIN)),{scaleX:f,scaleY:g}=s.getAncestorScale(),S=l.getCellPositionByOffset(t,e,f,g,m),{row:p,column:R}=S,M=l.getNoMergeCellPositionByIndex(p,R),{startX:T,startY:b,endX:E,endY:y}=M,O=this._selectionRenderService.convertRangeDataToSelection(n.range);if(O==null)return;const x=Math.max(f,f),{startX:D,endX:W,startY:A,endY:H,startRow:B,startColumn:z,endRow:X,endColumn:Q}=O;r===0?(ee=this._moveHelperBackgroundShape)==null||ee.transformByState({height:H-A,width:h+d,left:0,top:A+(e-this._startOffsetY)/x+m.y-o.y}):(L=this._moveHelperBackgroundShape)==null||L.transformByState({height:u+c,width:W-D,left:D+(t-this._startOffsetX)/x+m.x-o.x,top:0}),(U=this._moveHelperBackgroundShape)==null||U.show();const J=Qd/x;if(r===0){let te=0;if(p<=B)te=b-J/2,this._changeToRow=p;else if(p>X)te=y-J/2,this._changeToRow=p+1;else return;(F=this._moveHelperLineShape)==null||F.transformByState({height:J,width:h,left:d,top:te})}else{let te=0;if(R<=z)te=T-J/2,this._changeToColumn=R;else if(R>Q)te=E-J/2,this._changeToColumn=R+1;else return;(Y=this._moveHelperLineShape)==null||Y.transformByState({height:u,width:J,left:te,top:c})}(G=this._moveHelperLineShape)==null||G.show()}_checkInHeaderRange(t,e=0){var l;const n=this._selectionManagerService.getSelections();if(((l=this._selectionManagerService.getCurrent())==null?void 0:l.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return!1;const r=n==null?void 0:n.find(d=>{const c=d.range,{startRow:u,endRow:h,startColumn:m,endColumn:f,rangeType:g}=c;return e===1?t>=m&&t<=f&&a.RANGE_TYPE.COLUMN===g:t>=u&&t<=h&&a.RANGE_TYPE.ROW===g}),s=r==null?void 0:r.range;return r==null||s==null||s.rangeType===a.RANGE_TYPE.ALL||s.rangeType===a.RANGE_TYPE.NORMAL||s.rangeType===a.RANGE_TYPE.ROW&&e!==0||s.rangeType===a.RANGE_TYPE.COLUMN&&e!==1?!1:r}_clearObserverEvent(){const{scene:t}=this._sheetObject;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:t}=this._sheetObject;this._moveHelperBackgroundShape=new w.Rect($d,{fill:Zd,evented:!1,zIndex:100}),this._moveHelperLineShape=new w.Rect(Gd,{fill:Kd,evented:!1,zIndex:100}),t.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],tt)}_disposeBackgroundAndLine(){var t,e;(t=this._moveHelperBackgroundShape)==null||t.dispose(),(e=this._moveHelperLineShape)==null||e.dispose()}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}};Yn=Xd([a.OnLifecycle(a.LifecycleStages.Rendered,Yn),xt(0,P.Inject(N.SheetSkeletonManagerService)),xt(1,a.IUniverInstanceService),xt(2,w.IRenderManagerService),xt(3,a.ICommandService),xt(4,Ie),xt(5,P.Inject(_.SelectionManagerService))],Yn);var Ki=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(Ki||{});const Jd="rgba(120, 120, 120, 0.01)",Qi="rgb(68, 71, 70)",sn=12,Ji=4;class Pr extends w.Shape{constructor(e,n){super(e,n);I(this,"_size",sn);I(this,"_color",Qi);I(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){let{width:n,height:o}=this,r=0,s=0;const l=this.getScene(),{scaleX:d,scaleY:c}=l.getAncestorScale(),u=Math.max(d,c),h=sn/u,m=Ji/u;this.mode===0?(n=m,r=h-m):(o=m,s=h-m),w.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:Jd}),w.Rect.drawWith(e,{width:n,height:o,fill:Qi,radius:m}),e.save(),e.transform(1,0,0,1,r,s),w.Rect.drawWith(e,{width:n,height:o,fill:Qi,radius:m}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:sn,height:this.size}):this.transformByState({width:this.size,height:sn}),this}}var qd=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,tu=(i,t,e,n)=>{for(var o=n>1?void 0:n?eu(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&qd(t,e,o),o},qi=(i,t)=>(e,n)=>t(e,n,i);const nu="__SpreadsheetHeaderResizeControllerShapeRow__",iu="__SpreadsheetHeaderResizeControllerShapeColumn__",Hr="__SpreadsheetHeaderResizeControllerShapeHelper__",Lr="rgb(199, 199, 199)",ou=2;let Xn=class extends a.Disposable{constructor(t,e,n,o){super();I(this,"_currentRow",0);I(this,"_currentColumn",0);I(this,"_rowResizeRect");I(this,"_columnResizeRect");I(this,"_observers",[]);I(this,"_moveObserver");I(this,"_upObserver");I(this,"_resizeHelperShape");I(this,"_startOffsetX",Number.POSITIVE_INFINITY);I(this,"_startOffsetY",Number.POSITIVE_INFINITY);this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._editorBridgeService=o,this._init()}dispose(){var o,r;(o=this._rowResizeRect)==null||o.dispose(),this._rowResizeRect=null,(r=this._columnResizeRect)==null||r.dispose(),this._columnResizeRect=null;const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:e,spreadsheetColumnHeader:n}=t;this._observers.forEach(s=>{e.onPointerMoveObserver.remove(s),e.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_init(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;this._rowResizeRect=new Pr(nu,{visible:!1,mode:Ki.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Pr(iu,{visible:!1,mode:Ki.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],tt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(t=0){const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:o,scene:r}=e,s=t===0?n:o;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((l,d)=>{var O;const c=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(c==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=c,{startX:m,startY:f,endX:g,endY:S,row:p,column:R}=Mt(l.offsetX,l.offsetY,r,c),M=bn(l.offsetX,l.offsetY,r),{scaleX:T,scaleY:b}=r.getAncestorScale(),E=Math.max(T,b),y=sn/E;if(t===0){let x=f-y/2;if(M.y<=f+y/2&&M.y>=f)this._currentRow=p-1;else if(M.y>=S-y/2&&M.y<=S)this._currentRow=p,x=S-y/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const D=u/3;this._rowResizeRect.transformByState({left:u/2-D/2,top:x}),this._rowResizeRect.setShapeProps({size:D}),this._rowResizeRect.show()}else{let x=m-y/2;if(M.x<=m+y/2&&M.x>=m)this._currentColumn=R-1;else if(M.x>=g-y/2&&M.x<=g)this._currentColumn=R,x=g-y/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const D=h*.7;this._columnResizeRect.transformByState({left:x,top:h/2-D/2}),this._columnResizeRect.setShapeProps({size:D}),this._columnResizeRect.show()}})),this._observers.push(s==null?void 0:s.onPointerLeaveObserver.add((l,d)=>{var c,u;(c=this._rowResizeRect)==null||c.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(t=0){const e=this._getSheetObject(),{scene:n}=e,o=t===0?this._rowResizeRect:this._columnResizeRect;o!=null&&(this.disposeWithMe(a.toDisposable(o.onPointerEnterObserver.add(()=>{o!=null&&(o.show(),n.setCursor(t===0?w.CURSOR_TYPE.ROW_RESIZE:w.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(a.toDisposable(o.onPointerLeaveObserver.add(()=>{o!=null&&(o.hide(),n.resetCursor())}))),this.disposeWithMe(a.toDisposable(o.onPointerDownObserver.add((r,s)=>{var ee,L,U,F,Y,G,te;const l=(ee=this._sheetSkeletonManagerService.getCurrent())==null?void 0:ee.skeleton;if(l==null)return;const d=this._getSheetObject(),{scene:c}=d,u=c.getEngine(),h=(u==null?void 0:u.height)||0,m=(u==null?void 0:u.width)||0,f=c.getViewport(j.VIEW_MAIN),g=(((U=(L=f==null?void 0:f.getScrollBar())==null?void 0:L.horizonBarRect)==null?void 0:U.height)||0)+10,S=(((Y=(F=f==null?void 0:f.getScrollBar())==null?void 0:F.verticalBarRect)==null?void 0:Y.width)||0)+10,p=bn(r.offsetX,r.offsetY,c),{scaleX:R,scaleY:M}=c.getAncestorScale();this._startOffsetX=p.x,this._startOffsetY=p.y;const T=l.getOffsetByPositionX(this._currentColumn),b=l.getOffsetByPositionY(this._currentRow),E=l.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let y=!1,O=0,x=0;const{columnTotalWidth:D,rowHeaderWidth:W,rowTotalHeight:A,columnHeaderHeight:H}=l,B=m>D+W?m:D+W,z=h>A+H?h:A+H,X=Math.max(R,M),Q=Ji/X;t===0?this._resizeHelperShape=new w.Rect(Hr,{width:B,height:Q,fill:Lr,left:0,top:b-Q/2}):this._resizeHelperShape=new w.Rect(Hr,{width:Q,height:z,fill:Lr,left:T-Q/2,top:0});const J=((G=this._columnResizeRect)==null?void 0:G.left)||0,$=((te=this._rowResizeRect)==null?void 0:te.top)||0;c.addObject(this._resizeHelperShape,tt),c.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown}),this._moveObserver=c.onPointerMoveObserver.add(ne=>{var qe,Ce,un,hn,mn,fn;const de=c.getRelativeCoord(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),fe=c.getScrollXYByRelativeCoords(de,f),be=bn(ne.offsetX,ne.offsetY,c),{x:Te,y:De}=be,{scaleX:Je,scaleY:ve}=c.getAncestorScale(),he=Math.max(Je,ve),se=Ji/he;O=Te-this._startOffsetX-se/2,x=De-this._startOffsetY-se/2,Math.abs(t===0?x:O)>=ou&&(y=!0),t===0?(x>h-g+fe.y-E.startY&&(x=h-g+fe.y-E.startY),x<-(E.endY-E.startY)+2&&(x=-(E.endY-E.startY)+2),y&&((qe=this._resizeHelperShape)==null||qe.transformByState({top:b+x}),(Ce=this._rowResizeRect)==null||Ce.transformByState({top:$+x+se/2}),(un=this._rowResizeRect)==null||un.show(),c.setCursor(w.CURSOR_TYPE.ROW_RESIZE))):(O>m-S+fe.x-E.startX&&(O=m-S+fe.x-E.startX),O<-(E.endX-E.startX)+2&&(O=-(E.endX-E.startX)+2),y&&((hn=this._resizeHelperShape)==null||hn.transformByState({left:T+O}),(mn=this._columnResizeRect)==null||mn.transformByState({left:J+O+se/2}),(fn=this._columnResizeRect)==null||fn.show(),c.setCursor(w.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=c.onPointerUpObserver.add(ne=>{var be,Te,De;const de=this._getSheetObject();if(de==null)return;this._clearObserverEvent(),(be=this._resizeHelperShape)==null||be.dispose(),this._resizeHelperShape=null;const{scene:fe}=de;fe.enableEvent(),y&&(fe.resetCursor(),(Te=this._rowResizeRect)==null||Te.hide(),(De=this._columnResizeRect)==null||De.hide(),t===0?this._commandService.executeCommand(_.DeltaRowHeightCommand.id,{deltaY:x,anchorRow:this._currentRow}):this._commandService.executeCommand(_.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(a.toDisposable(o.onDblclickObserver.add(()=>{var r;if(t===0){const s=this._getSheetObject(),{scene:l}=s;l.resetCursor(),this._commandService.executeCommand(_.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(r=this._rowResizeRect)==null||r.hide()}}))))}_clearObserverEvent(){const t=this._getSheetObject(),{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return Me(this._context.unit,this._context)}};Xn=tu([qi(1,P.Inject(N.SheetSkeletonManagerService)),qi(2,a.ICommandService),qi(3,Ee)],Xn);var eo=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(eo||{});const an=12,ru=.4;class Ur extends w.Shape{constructor(e,n,o){super(e,n);I(this,"_size",an);I(this,"_iconRatio",ru);I(this,"_hovered",!0);I(this,"_hasPrevious",!0);I(this,"_hasNext",!0);I(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>o==null?void 0:o())}setShapeProps(e){e.type!==void 0&&(this._unhideType=e.type),e.hovered!==void 0&&(this._hovered=e.hovered),e.hasPrevious!==void 0&&(this._hasPrevious=e.hasPrevious),e.hasNext!==void 0&&(this._hasNext=e.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(e){this._unhideType===0?this._drawOnRow(e):this._drawOnCol(e)}_drawOnRow(e){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:jn}):w.Rect.drawWith(e,{width:this._size,height:2*this._size,stroke:Ze,fill:jn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:Ze}),this._hasNext){const l=this._hasPrevious?3:1;w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size*l/2+s},{x:this._size/2-s,y:this._size*l/2-r},{x:this._size/2+s,y:this._size*l/2-r}]],fill:Ze})}}_drawOnCol(e){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Ze,fill:jn}):w.Rect.drawWith(e,{width:2*this._size,height:this._size,stroke:Ze,fill:jn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:Ze}),this._hasNext){const l=this._hasPrevious?3:1;w.RegularPolygon.drawWith(e,{pointsGroup:[[{x:r+this._size*l/2,y:this._size/2},{x:-s+this._size*l/2,y:this._size/2-s},{x:-s+this._size*l/2,y:this._size/2+s}]],fill:Ze})}}}var su=Object.defineProperty,au=Object.getOwnPropertyDescriptor,lu=(i,t,e,n)=>{for(var o=n>1?void 0:n?au(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&su(t,e,o),o},Vr=(i,t)=>(e,n)=>t(e,n,i);const Br="__SpreadsheetHeaderUnhideSHAPEControllerShape__",cu=[_.InsertColMutation.id,_.InsertRowMutation.id,_.RemoveColMutation.id,_.RemoveRowMutation.id,_.SetWorksheetColWidthMutation.id,_.SetWorksheetRowIsAutoHeightMutation.id,_.SetRowHiddenMutation.id,_.SetRowVisibleMutation.id,_.SetColHiddenMutation.id,_.SetColVisibleMutation.id];let to=class extends a.RxDisposable{constructor(t,e,n){super();I(this,"_shapes",{cols:[],rows:[]});this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._init()}get _workbook(){return this._context.unit}dispose(){super.dispose(),this._clearShapes()}_init(){let t="";this._context.unit.activeSheet$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(this._clearShapes(),!e){t="";return}t=e.getSheetId(),this._update(this._workbook,e)}),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!cu.includes(e.id)||!e.params||!e.params.unitId||e.params.subUnitId!==t)return;const n=this._workbook,o=n.getSheetBySheetId(e.params.subUnitId);o&&this._update(n,o)}))}_update(t,e){var m;const n=(m=this._sheetSkeletonManagerService.getUnitSkeleton(t.getUnitId(),e.getSheetId()))==null?void 0:m.skeleton;if(!n)return;const o=e.getHiddenRows(),r=e.getHiddenCols(),s=this._getSheetObject(),{scene:l}=s,d=e.getRowCount(),c=o.map(f=>{const{startRow:g,endRow:S}=f,p=Ai(g,0,l,n),R=g!==0,M=S!==d-1;return new Ur(Br,{type:eo.ROW,hovered:!1,hasPrevious:R,hasNext:M,top:p.startY-(R?an:0),left:p.startX-an},()=>this._commandService.executeCommand(_.SetSpecificRowsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[f]}))}),u=e.getColumnCount(),h=r.map(f=>{const{startColumn:g,endColumn:S}=f,p=Ai(0,g,l,n),R=g!==0,M=S!==u-1;return new Ur(Br,{type:eo.COLUMN,hovered:!1,hasPrevious:R,hasNext:M,top:20-an,left:p.startX-(R?an:0)},()=>this._commandService.executeCommand(_.SetSpecificColsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[f]}))});l.addObjects(h,No),l.addObjects(c,No),this._clearShapes(),this._shapes={cols:h,rows:c}}_clearShapes(){this._shapes.cols.forEach(t=>t.dispose()),this._shapes.rows.forEach(t=>t.dispose()),this._shapes={cols:[],rows:[]}}_getSheetObject(){return Me(this._workbook,this._context)}};to=lu([Vr(1,P.Inject(N.SheetSkeletonManagerService)),Vr(2,a.ICommandService)],to);var du=Object.defineProperty,uu=Object.getOwnPropertyDescriptor,hu=(i,t,e,n)=>{for(var o=n>1?void 0:n?uu(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&du(t,e,o),o},no=(i,t)=>(e,n)=>t(e,n,i);let $n=class extends a.Disposable{constructor(i,t,e){super(),this._markSelectionService=i,this._commandService=t,this._sheetSkeletonManagerService=e,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const i=[ye.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{i.includes(t.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,o)=>{n.exits.includes(t.id)&&this._markSelectionService.removeShape(o)})}))}_addRefreshListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{i&&this._markSelectionService.refreshShapes()})))}};$n=hu([a.OnLifecycle(a.LifecycleStages.Steady,$n),no(0,P.Inject(Wt)),no(1,a.ICommandService),no(2,P.Inject(N.SheetSkeletonManagerService))],$n);var mu=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,gu=(i,t,e,n)=>{for(var o=n>1?void 0:n?fu(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&mu(t,e,o),o},io=(i,t)=>(e,n)=>t(e,n,i);let Gn=class extends a.Disposable{constructor(t,e,n){super();I(this,"_initialize",()=>{const t=new a.DisposableCollection;this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{t.dispose();const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(o=>{t.add(a.toDisposable(o.selectionMoved$.subscribe(r=>{if(!r)return;const s=o.model.getRange(),l={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},d={startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn,rangeType:s.rangeType};if(l.startRow===d.startRow&&l.startColumn===d.startColumn||d.startRow<0||d.startColumn<0)return;const c={fromRange:l,toRange:d};this._commandService.executeCommand(_.MoveRangeCommand.id,c)})))})})))});this._selectionRenderService=t,this._selectionManagerService=e,this._commandService=n,this._initialize()}};Gn=gu([a.OnLifecycle(a.LifecycleStages.Steady,Gn),io(0,P.Inject(Ie)),io(1,P.Inject(_.SelectionManagerService)),io(2,P.Inject(a.ICommandService))],Gn);var Su=Object.defineProperty,_u=Object.getOwnPropertyDescriptor,pu=(i,t,e,n)=>{for(var o=n>1?void 0:n?_u(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Su(t,e,o),o},rt=(i,t)=>(e,n)=>t(e,n,i);let Zn=class extends a.Disposable{constructor(i,t,e,n,o,r,s,l){super(),this._sheetSkeletonManagerService=i,this._univerInstanceService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._themeService=s,this._definedNamesService=l,this._initialize()}_initialize(){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=i.getActiveSheet(),e=this._getSheetObject();if(e==null)return;this._initViewMainListener(e),this._initRowHeader(e),this._initColumnHeader(e),this._initLeftTop(e),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener(),this._initDefinedNameListener();const n=i.getUnitId(),o=t.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:o})}_initDefinedNameListener(){this.disposeWithMe(a.toDisposable(this._definedNamesService.focusRange$.subscribe(async i=>{if(i==null)return;const{unitId:t}=i;let{formulaOrRefString:e}=i;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(t!==n.getUnitId()||(e.substring(0,1)===K.operatorToken.EQUALS&&(e=e.substring(1)),!K.isReferenceStrings(e)))return;const r=await this._getSelections(n,t,e);this._selectionManagerService.replace(r),this._commandService.executeCommand(_.ScrollToCellOperation.id,r[0].range)})))}async _getSelections(i,t,e){const n=e.split(",");let o=i.getActiveSheet();const r=[];for(let s=0;s<n.length;s++){const l=n[s].trim(),d=K.deserializeRangeWithSheet(l.trim());if(s===0){const u=i.getSheetBySheetName(d.sheetName);u&&o.getSheetId()!==u.getSheetId()&&(o=u,await this._commandService.executeCommand(_.SetWorksheetActivateCommand.id,{subUnitId:o.getSheetId(),unitId:t}))}if(o.getName()!==d.sheetName)continue;let c=null;if(s===n.length-1){const u=d.range,{startRow:h,startColumn:m,endRow:f,endColumn:g}=u;c=_.getPrimaryForRange({startRow:h,startColumn:m,endRow:f,endColumn:g},o)}r.push({range:d.range,style:_.getNormalSelectionStyle(this._themeService),primary:c})}return r}_getActiveViewport(i){const t=this._getSheetObject();return t==null?void 0:t.scene.getActiveViewportByCoord(w.Vector2.FromArray([i.offsetX,i.offsetY]))}_initViewMainListener(i){const{spreadsheet:t}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(e,t.zIndex+1,a.RANGE_TYPE.NORMAL,this._getActiveViewport(e)),e.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(a.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),t=this._selectionManagerService.getCurrent();i==null||(t==null?void 0:t.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(i)})))}_refreshSelection(i){const t=i.map(e=>{const n=this._selectionRenderService.convertSelectionRangeToData(e);return n.style=_.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(t)}_initRowHeader(i){const{spreadsheetRowHeader:t,spreadsheet:e}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,a.RANGE_TYPE.ROW,this._getActiveViewport(n),w.ScrollTimerType.Y),n.button!==2&&o.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:t,spreadsheet:e}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((n,o)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,a.RANGE_TYPE.COLUMN,this._getActiveViewport(n),w.ScrollTimerType.X),n.button!==2&&o.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:t}=i;this.disposeWithMe(a.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{var l;const o=(l=this._sheetSkeletonManagerService.getCurrent())==null?void 0:l.skeleton;if(o==null)return;this._selectionRenderService.reset();const r=this._getAllRange(o),s=this._selectionRenderService.convertSelectionRangeToData(r);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),e.button!==2&&n.stopPropagation()})))}_initSelectionChangeListener(){this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null){for(const t of i){if(t==null)continue;const e=this._selectionRenderService.convertSelectionRangeToData(t);this._selectionRenderService.addControlToCurrentByRangeData(e)}this._syncDefinedNameRange(i)}}))),this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)}))),this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveStart$.subscribe(i=>{i!=null&&this._syncDefinedNameRange(i)})))}_syncDefinedNameRange(i){if(i.length===0)return;const t=i[i.length-1],e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet();this._definedNamesService.setCurrentRange({range:t.range,unitId:e.getUnitId(),sheetId:n.getSheetId()})}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,_.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,_.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,_.SelectionMoveType.MOVE_END)})}_move(i,t){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),o=e.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(_.SetSelectionsOperation.id,{unitId:n,subUnitId:o,type:t,pluginName:(r==null?void 0:r.pluginName)||_.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>_.convertSelectionDataToRange(s))})}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}_initCommandListener(){const i=[Le.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:t,sheetId:e,skeleton:n}=i,o=this._renderManagerService.getRenderById(t);if(o==null)return;const{scene:r}=o,s=r.getViewport(j.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,r,s);const l=this._selectionManagerService.getCurrent(),d=(l==null?void 0:l.pluginName)||_.NORMAL_SELECTION_PLUGIN_NAME;if((l==null?void 0:l.unitId)===t&&l.sheetId===e){const c=this._selectionManagerService.getSelections();c!=null&&this._refreshSelection(c)}else this._selectionManagerService.setCurrentSelection({pluginName:d,unitId:t,sheetId:e});d===_.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getAllRange(i){return{range:{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1,rangeType:a.RANGE_TYPE.ALL},primary:this._getZeroRange(i).primary,style:null}}_getZeroRange(i){const t=i.mergeData;return _.transformCellDataToSelectionData(0,0,t)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};Zn=pu([a.OnLifecycle(a.LifecycleStages.Rendered,Zn),rt(0,P.Inject(N.SheetSkeletonManagerService)),rt(1,a.IUniverInstanceService),rt(2,a.ICommandService),rt(3,w.IRenderManagerService),rt(4,Ie),rt(5,P.Inject(_.SelectionManagerService)),rt(6,P.Inject(a.ThemeService)),rt(7,K.IDefinedNamesService)],Zn);const Ke={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,t)=>{const e=i.get(a.ICommandService),n=i.get(a.IUndoRedoService),o=i.get(a.IUniverInstanceService),r=i.get(C.IConfirmService),s=i.get(a.LocaleService),l=t.unitId,d=t.subUnitId,c=t.selections,u=_.getAddMergeMutationRangeByType(c,t.value),h=o.getUniverSheetInstance(l).getSheetBySheetId(d),m=[],f=[],g=rr(h,u);if(g&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const S={unitId:l,subUnitId:d,ranges:u},p={unitId:l,subUnitId:d,ranges:u},R=_.RemoveMergeUndoMutationFactory(i,S),M=_.AddMergeUndoMutationFactory(i,p);if(R.ranges.length>0&&m.push({id:_.RemoveWorksheetMergeMutation.id,params:R}),m.push({id:_.AddWorksheetMergeMutation.id,params:p}),f.push({id:_.RemoveWorksheetMergeMutation.id,params:M}),R.ranges.length>0&&f.push({id:_.AddWorksheetMergeMutation.id,params:R}),g){const y=sr(i,l,h,u);m.unshift(...y.redos),f.push(...y.undos)}const T=_.AddMergeRedoSelectionsOperationFactory(i,t,u);T&&m.push(T);const b=_.AddMergeUndoSelectionsOperationFactory(i,t);return b&&f.push(b),a.sequenceExecute(m,e).result?(n.pushUndoRedo({unitID:l,undoMutations:f,redoMutations:m}),!0):!1}},kr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const t=i.get(a.ICommandService),n=i.get(_.SelectionManagerService).getSelectionRanges(),o=Oi(Mn.MergeAll,n);if(!(o!=null&&o.length))return!1;const s=i.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const d=s.getUnitId(),c=l.getSheetId();return t.executeCommand(Ke.id,{selections:o,unitId:d,subUnitId:c})}},Fr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const t=i.get(a.ICommandService),n=i.get(_.SelectionManagerService).getSelectionRanges(),o=Oi(Mn.MergeVertical,n);if(!(o!=null&&o.length))return!1;const s=i.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const d=s.getUnitId(),c=l.getSheetId();return t.executeCommand(Ke.id,{value:a.Dimension.COLUMNS,selections:o,unitId:d,subUnitId:c})}},Wr={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const t=i.get(a.ICommandService),n=i.get(_.SelectionManagerService).getSelectionRanges(),o=Oi(Mn.MergeHorizontal,n);if(!(o!=null&&o.length))return!1;const s=i.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const d=s.getUnitId(),c=l.getSheetId();return t.executeCommand(Ke.id,{value:a.Dimension.ROWS,selections:o,unitId:d,subUnitId:c})}},oo={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endColumn:d.getColumnCount()-1};const u=f=>f.endRow-f.startRow;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:oo.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.DeleteRangeMoveLeftCommand.id):!0}},Kn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endRow:d.getRowCount()-1};for(let f=c.startRow;f<=c.endRow;f++)if(d.getRowFiltered(f)&&await t.confirm({id:Kn.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const u=f=>f.endColumn-f.startColumn;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:Kn.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.DeleteRangeMoveUpCommand.id):!0}},Qn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endRow:d.getRowCount()-1};for(let f=c.startRow;f<=c.endRow;f++)if(d.getRowFiltered(f)&&await t.confirm({id:Qn.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const u=f=>f.endColumn-f.startColumn;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:Qn.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.InsertRangeMoveDownCommand.id):!0}},ro={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async i=>{const t=i.get(C.IConfirmService),e=i.get(a.ICommandService),n=i.get(a.LocaleService),o=i.get(_.SelectionManagerService),r=i.get(a.IUniverInstanceService),s=o.getSelections();if(!s)return!1;const l=_.getSheetCommandTarget(r);if(!l)return!1;const{worksheet:d}=l;let c=s[0].range;if(!c)return!1;c={...c,endColumn:d.getColumnCount()-1};const u=f=>f.endRow-f.startRow;return!d.getMergeData().find(f=>{const g=a.Rectangle.getIntersects(f,c);return g?u(f)>u(g):!1})||await t.confirm({id:ro.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.InsertRangeMoveRightCommand.id):!0}},jr={id:"sheet.command.refill",type:a.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(Jt);return e.applyType=t.type,!0}},zr={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(i,t)=>{var c;const e=i.get(_.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(c=e.getLast())==null?void 0:c.range),!n)return!1;const o=i.get(a.ICommandService),r=i.get(a.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,d=l.getVisibleRows();if(Zo(d,[n])){const u=i.get(C.IConfirmService),h=i.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await o.executeCommand(_.RemoveRowCommand.id,{range:n}),!0}},Yr={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(i,t)=>{var c;const e=i.get(_.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(c=e.getLast())==null?void 0:c.range),!n)return!1;const o=i.get(a.ICommandService),r=i.get(a.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:l}=s,d=l.getVisibleCols();if(Ko(d,[n])){const u=i.get(C.IConfirmService),h=i.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await o.executeCommand(_.RemoveColCommand.id,{range:n}),!0}},Xr={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(i,t)=>{const{subUnitId:e}=t,n=i.get(C.IConfirmService),o=i.get(a.ICommandService),r=i.get(a.LocaleService);return await n.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await o.executeCommand(_.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},At=P.createIdentifier("univer.sheetbar-service");class vu extends a.Disposable{constructor(){super();I(this,"renameId$");I(this,"removeId$");I(this,"scroll$");I(this,"scrollX$");I(this,"addSheet$");I(this,"_renameId$");I(this,"_removeId$");I(this,"_scroll$");I(this,"_scrollX$");I(this,"_addSheet$");I(this,"_currentHandler",null);this._renameId$=new k.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new k.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new k.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new k.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new k.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,a.toDisposable(()=>{this._currentHandler=null})}}const $r={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async i=>(i.get(At).triggerSheetBarMenu(),!0)},Gr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(i,t)=>{const e=i.get(At);return t&&e.setRenameId(t.subUnitId),!0}};var xe=function(){return xe=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(i[o]=t[o])}return i},xe.apply(this,arguments)},Cu=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(i);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(i,n[o])&&(e[n[o]]=i[n[o]]);return e},pe=V.forwardRef(function(i,t){var e=i.icon,n=i.id,o=i.className,r=i.extend,s=Cu(i,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=V.useRef("_".concat(Mu()));return Zr(e,"".concat(n),{defIds:e.defIds,idSuffix:d.current},xe({ref:t,className:l},s),r)});function Zr(i,t,e,n,o){return V.createElement(i.tag,xe(xe({key:t},Iu(i,e,o)),n),(Ru(i,e).children||[]).map(function(r,s){return Zr(r,"".concat(t,"-").concat(i.tag,"-").concat(s),e,void 0,o)}))}function Iu(i,t,e){var n=xe({},i.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var o=t.defIds;return!o||o.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],l=r[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ru(i,t){var e,n=t.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?xe(xe({},i),{children:i.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?xe(xe({},o),{attrs:xe(xe({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):i}function Mu(){return Math.random().toString(36).substring(2,8)}pe.displayName="UniverIcon";var bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},Kr=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"autofill",ref:t,icon:bu}))});Kr.displayName="Autofill";const Tu=Kr;var wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qr=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"check-mark-single",ref:t,icon:wu}))});Qr.displayName="CheckMarkSingle";const ln=Qr;var Eu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},Jr=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"close-single",ref:t,icon:Eu}))});Jr.displayName="CloseSingle";const yu=Jr;var Ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.22297.954345C1.3529.929358 1.51542.914795 1.7147.914795H6.85715C7.0561.914795 7.21986.929297 7.35152.959681 7.48737.991031 7.5967 1.04983 7.67995 1.13863 7.76349 1.22774 7.81571 1.34646 7.84615 1.48343L7.84671 1.48597C7.87164 1.62058 7.88612 1.79252 7.88612 2.00111V7.16269C7.88612 7.36211 7.87154 7.52439 7.84667 7.6587 7.82039 7.79533 7.76169 7.91004 7.67831 7.9934 7.59462 8.0771 7.48565 8.13006 7.35692 8.16096 7.22966 8.1915 7.06561 8.20599 6.87627 8.20599H1.7147C1.52177 8.20599 1.36349 8.19641 1.23252 8.17122 1.09967 8.14567.98914 8.09813.90398 8.0134.818184 7.93285.765734 7.8172.735395 7.68573.705177 7.55478.68573 7.38178.68573 7.16269V1.9581C.68573 1.7541.700286 1.58699.725186 1.45253.751461 1.31589.810166 1.20119.893537 1.11782.978617 1.03274 1.08895.98522 1.22033.954901L1.22297.954345zM2.02733 2.07424C1.95064 2.07854 1.91191 2.09755 1.89153 2.11849 1.86949 2.1517 1.85476 2.19738 1.85473 2.25901L1.86389 3.92571H3.72054V2.07424H2.02733zM4.8991 2.07901V3.92571H6.70756V2.20184C6.70756 2.15684 6.7041 2.12531 6.69899 2.10487 6.69675 2.09591 6.69467 2.09093 6.69349 2.08853 6.68344 2.08345 6.66389 2.07901 6.61819 2.07901H4.8991zM1.86466 5.08037L1.87384 6.90902C1.87384 6.95115 1.87723 6.98219 1.8825 7.00371 1.8864 7.01961 1.89067 7.02788 1.8933 7.03179 1.8933 7.03179 1.89686 7.03365 1.8996 7.03479 1.90589 7.03741 1.91476 7.04025 1.92666 7.04282 1.95062 7.04799 1.98341 7.05133 2.02535 7.05133H3.72532V5.08037H1.86466zM4.8991 5.08037V7.05133H6.55606C6.63148 7.05133 6.67174 7.04228 6.68909 7.03374 6.69039 7.03177 6.69349 7.02643 6.69691 7.01502 6.70311 6.99436 6.70756 6.96264 6.70756 6.91894V5.08037H4.8991zM8.65114 7.83368C8.78108 7.80869 8.94359 7.79413 9.14288 7.79413H14.2853C14.4843 7.79413 14.648 7.80863 14.7797 7.83902 14.9155 7.87037 15.0249 7.92916 15.1081 8.01797 15.1917 8.10707 15.2439 8.2258 15.2743 8.36277L15.2749 8.36531C15.2998 8.49991 15.3143 8.67185 15.3143 8.88045V14.042C15.3143 14.2414 15.2997 14.4037 15.2748 14.538 15.2486 14.6747 15.1899 14.7894 15.1065 14.8727 15.0228 14.9564 14.9138 15.0094 14.7851 15.0403 14.6578 15.0708 14.4938 15.0853 14.3044 15.0853H9.14288C8.94995 15.0853 8.79166 15.0757 8.6607 15.0506 8.52785 15.025 8.41732 14.9775 8.33216 14.8927 8.24636 14.8122 8.19391 14.6965 8.16358 14.5651 8.13336 14.4341 8.11391 14.2611 8.11391 14.042V8.83744C8.11391 8.63343 8.12847 8.46633 8.15337 8.33186 8.17964 8.19523 8.23835 8.08053 8.32172 7.99716 8.4068 7.91208 8.51713 7.86456 8.64851 7.83424L8.65114 7.83368zM9.45551 8.95357C9.37882 8.95788 9.34009 8.97689 9.3197 8.99782 9.29767 9.03103 9.28294 9.07672 9.28291 9.13834L9.29206 10.805H11.1487V8.95357H9.45551zM12.3273 8.95835V10.805H14.1357V9.08118C14.1357 9.03618 14.1323 9.00465 14.1272 8.98421 14.1249 8.97524 14.1228 8.97026 14.1217 8.96786 14.1116 8.96278 14.0921 8.95835 14.0464 8.95835H12.3273zM9.29283 11.9597L9.30202 13.7884C9.30202 13.8305 9.30541 13.8615 9.31068 13.883 9.31457 13.8989 9.31885 13.9072 9.32148 13.9111L9.32448 13.9127 9.32778 13.9141C9.33407 13.9167 9.34293 13.9196 9.35484 13.9222 9.3788 13.9273 9.41159 13.9307 9.45353 13.9307H11.1535V11.9597H9.29283zM12.3273 11.9597V13.9307H13.9842C14.0597 13.9307 14.0999 13.9216 14.1173 13.9131 14.1186 13.9111 14.1217 13.9058 14.1251 13.8944 14.1313 13.8737 14.1357 13.842 14.1357 13.7983V11.9597H12.3273z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.46247 2.15033C9.46247 1.74649 9.78985 1.41911 10.1937 1.41911H12.3873C13.5988 1.41911 14.581 2.40124 14.581 3.61276V5.80641C14.581 6.21025 14.2536 6.53762 13.8498 6.53762 13.4459 6.53762 13.1185 6.21025 13.1185 5.80641V3.61276C13.1185 3.20893 12.7912 2.88154 12.3873 2.88154H10.1937C9.78985 2.88154 9.46247 2.55417 9.46247 2.15033zM2.88154 10.1937C2.88154 9.78986 2.55416 9.46248 2.15032 9.46248 1.74648 9.46248 1.4191 9.78986 1.4191 10.1937V12.3873C1.4191 13.5988 2.40123 14.581 3.61275 14.581H5.8064C6.21024 14.581 6.53761 14.2536 6.53761 13.8498 6.53761 13.4459 6.21024 13.1186 5.8064 13.1186H3.61275C3.20892 13.1186 2.88154 12.7912 2.88154 12.3873V10.1937z"}}]}]},qr=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"convert-single",ref:t,icon:Ou}))});qr.displayName="ConvertSingle";const Nu=qr;var xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.78662 6.17993C7.12169 6.17993 7.39331 6.45156 7.39331 6.78662V10.7301C7.39331 11.0652 7.12169 11.3368 6.78662 11.3368 6.45156 11.3368 6.17993 11.0652 6.17993 10.7301V6.78662C6.17993 6.45156 6.45156 6.17993 6.78662 6.17993zM9.82007 6.78662C9.82007 6.45156 9.54844 6.17993 9.21338 6.17993 8.87831 6.17993 8.60669 6.45156 8.60669 6.78662V10.7301C8.60669 11.0652 8.87831 11.3368 9.21338 11.3368 9.54844 11.3368 9.82007 11.0652 9.82007 10.7301V6.78662z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57094 1.32642C6.34938 1.32642 6.14544 1.44719 6.03894 1.64148L5.21395 3.14648H1.93311C1.59804 3.14648 1.32642 3.41811 1.32642 3.75317C1.32642 4.08824 1.59804 4.35986 1.93311 4.35986H2.84314V14.0669C2.84314 14.402 3.11476 14.6736 3.44983 14.6736H12.5502C12.8852 14.6736 13.1569 14.402 13.1569 14.0669V4.35986H14.0669C14.402 4.35986 14.6736 4.08824 14.6736 3.75317C14.6736 3.41811 14.402 3.14648 14.0669 3.14648H10.7895L9.98357 1.64602C9.87785 1.4492 9.67252 1.32642 9.44911 1.32642H6.57094ZM9.4122 3.14648L9.08632 2.53979H6.93024L6.59767 3.14648H9.4122ZM4.05652 4.35986V13.4602H11.9435V4.35986H4.05652Z",fillRule:"evenodd",clipRule:"evenodd"}}]},es=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"delete-single",ref:t,icon:xu}))});es.displayName="DeleteSingle";const Au=es;var Du={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]}]},ts=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"dropdown-single",ref:t,icon:Du}))});ts.displayName="DropdownSingle";const ns=ts;var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0 0H16V16H0z",opacity:.01}},{tag:"path",attrs:{fill:"currentColor",d:"M8.09973 1.50049C4.51022 1.50049 1.59973 4.41098 1.59973 8.00049C1.59973 11.59 4.51022 14.5005 8.09973 14.5005C11.6892 14.5005 14.5997 11.59 14.5997 8.00049C14.5997 4.41098 11.6892 1.50049 8.09973 1.50049ZM10.4995 10.4701L9.5419 10.4657L8.09971 8.74643L6.65897 10.4643L5.69993 10.4686C5.63609 10.4686 5.58386 10.4179 5.58386 10.3526C5.58386 10.325 5.59402 10.2989 5.61143 10.2771L7.49904 8.02824L5.61143 5.7808C5.59402 5.75904 5.58386 5.73292 5.58386 5.70536C5.58386 5.64152 5.63609 5.58929 5.69993 5.58929L6.65897 5.59364L8.09971 7.31295L9.54045 5.59509L10.498 5.59074C10.5619 5.59074 10.6141 5.64152 10.6141 5.70681C10.6141 5.73438 10.604 5.76049 10.5865 5.78225L8.70183 8.02969L10.588 10.2786C10.6054 10.3003 10.6156 10.3265 10.6156 10.354C10.6156 10.4179 10.5633 10.4701 10.4995 10.4701Z",fillRule:"evenodd",clipRule:"evenodd"}}]},is=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"error-single",ref:t,icon:Pu}))});is.displayName="ErrorSingle";const os=is;var Hu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.6905 4.78738C2.01709 4.61737 2.41966 4.7443 2.58967 5.07089C2.75217 5.38305 3.00913 5.69251 3.36183 5.98156C4.36103 6.80048 6.03866 7.37872 7.99833 7.37872C9.958 7.37872 11.6356 6.80049 12.6348 5.98157C12.9875 5.69251 13.2445 5.38304 13.407 5.0709C13.577 4.7443 13.9796 4.61737 14.3062 4.78737C14.6327 4.95738 14.7597 5.35995 14.5897 5.68654C14.329 6.18726 13.9448 6.63187 13.48 7.01281C13.4365 7.04842 13.3923 7.08356 13.3473 7.11821L14.8065 8.57746C15.0669 8.83781 15.0669 9.25992 14.8065 9.52027C14.5462 9.78062 14.124 9.78062 13.8637 9.52027L12.1741 7.83063C11.6495 8.08125 11.0697 8.28368 10.451 8.43104L10.9916 10.4486C11.0869 10.8042 10.8759 11.1698 10.5202 11.2651C10.1646 11.3604 9.79902 11.1493 9.70373 10.7937L9.13044 8.6541C8.7607 8.69234 8.38239 8.71205 7.99833 8.71205C7.61155 8.71205 7.2306 8.69206 6.85837 8.65329L6.28486 10.7937C6.18957 11.1494 5.82401 11.3604 5.46837 11.2651C5.11272 11.1698 4.90167 10.8043 4.99696 10.4486L5.53804 8.42923C4.92309 8.28224 4.34666 8.0808 3.82483 7.8317L2.13636 9.52018C1.87602 9.78053 1.45391 9.78053 1.19355 9.52018C0.933204 9.25983 0.933203 8.83772 1.19355 8.57737L2.65127 7.11965C2.60559 7.08453 2.56072 7.04892 2.51667 7.01281C2.05184 6.63186 1.66764 6.18725 1.40699 5.68655C1.23698 5.35996 1.36391 4.95739 1.6905 4.78738Z"}}]},rs=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"eyelash-single",ref:t,icon:Hu}))});rs.displayName="EyelashSingle";const Lu=rs;var Uu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.48334 4.89587C5.35517 4.89587 5.26008 4.777 5.28822 4.65196L5.37367 4.27223C5.47369 3.84311 5.65731 3.4768 5.93107 3.18085 6.23007 2.85761 6.67323 2.71538 7.21663 2.71538 7.41772 2.71538 7.63284 2.73908 7.86113 2.78378 7.88014 2.7875 7.89899 2.79139 7.91771 2.79543 8.12915 2.84113 8.35624 2.74611 8.43956 2.54647L8.66692 2.00173C8.75382 1.79351 8.65103 1.55537 8.43507 1.49007 8.40283 1.48032 8.36953 1.47045 8.33516 1.46047 8.0467 1.37763 7.70317 1.3335 7.29999 1.3335 6.2394 1.3335 5.44639 1.60069 4.89385 2.10573 4.32912 2.62202 3.92814 3.3605 3.70338 4.33753L2.25629 10.5523C2.18051 10.8899 2.08525 11.253 1.96769 11.6425 1.849 12.0347 1.70655 12.4208 1.54146 12.7986 1.37502 13.1773 1.18738 13.5375.978805 13.8784.912697 13.9865.8444 14.0896.773916 14.1876.684332 14.3122.753952 14.4944.905805 14.5167 1.5556 14.6123 2.23715 14.4376 2.60122 13.8909 2.74587 13.6737 2.88704 13.426 3.02434 13.1464 3.3856 12.411 3.72447 11.3716 4.03792 10.0188L4.88825 6.37667C4.90938 6.28616 4.99007 6.22214 5.08301 6.22214H7.04403C7.22895 6.22214 7.38976 6.09538 7.43296 5.91557L7.55939 5.3893C7.61982 5.13775 7.42917 4.89587 7.17046 4.89587H5.48334zM13.7403 5.0817L11.9317 7.33096 10.8281 5.13886C10.7615 4.99145 10.6146 4.89673 10.4529 4.89673H9.73214C9.4277 4.89673 9.22847 5.21561 9.36195 5.48923L10.8281 8.41635 8.21708 11.5106C7.98512 11.7771 8.17444 12.1929 8.5278 12.1929H9.10532C9.22597 12.1929 9.37975 12.1436 9.45801 12.0518L11.53 9.62616 12.5369 11.9223C12.5978 12.0844 12.7522 12.1929 12.9254 12.1929H13.7193C14.0023 12.1929 14.161 11.9788 14.0619 11.7137L12.592 8.64761C12.592 8.64761 14.8202 5.81675 15.0205 5.54025 15.2159 5.27062 15.0215 4.89673 14.6886 4.89673H14.0854C13.9467 4.89673 13.8525 4.9502 13.7403 5.0817z"}}]}]},ss=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"fx-single",ref:t,icon:Uu}))});ss.displayName="FxSingle";const Vu=ss;var Bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.74717 2.0944C8.74717 1.68671 8.41279 1.3562 8.00032 1.3562C7.58785 1.3562 7.25347 1.68671 7.25347 2.0944V7.26186H2.02541C1.61294 7.26186 1.27856 7.59237 1.27856 8.00007C1.27856 8.40777 1.61294 8.73827 2.02541 8.73827H7.25347V13.9057C7.25347 14.3134 7.58785 14.6439 8.00032 14.6439C8.41279 14.6439 8.74717 14.3134 8.74717 13.9057V8.73827H13.975C14.3874 8.73827 14.7218 8.40777 14.7218 8.00007C14.7218 7.59237 14.3874 7.26186 13.975 7.26186H8.74717V2.0944Z"}}]}]},as=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"increase-single",ref:t,icon:Bu}))});as.displayName="IncreaseSingle";const ls=as;var ku={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0.629584 3.99986C1.13729 3.4922 1.9604 3.49224 2.46806 3.99995L7.57569 9.10806C7.81 9.3424 8.18992 9.3424 8.42424 9.10808L13.5323 3.99998C14.04 3.4923 14.8631 3.4923 15.3708 3.99998C15.8785 4.50766 15.8785 5.33078 15.3708 5.83846L9.41415 11.7951C8.63307 12.5762 7.36669 12.5762 6.58565 11.7951L0.629497 5.83834C0.121839 5.33063 0.121879 4.50752 0.629584 3.99986Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},cs=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"more-down-single",ref:t,icon:ku}))});cs.displayName="MoreDownSingle";const Jn=cs;var Fu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.45493 2.80093C5.74783 2.49409 6.2227 2.49409 6.5156 2.80093L11.0156 7.51523C11.3085 7.82207 11.3085 8.31956 11.0156 8.6264L6.44488 13.27C6.15199 13.5768 5.67711 13.5768 5.38422 13.27C5.09133 12.9631 5.09133 12.4656 5.38422 12.1588L9.28804 8.20898C9.36409 8.13203 9.36517 8.00855 9.29047 7.93029L5.45493 3.9121C5.16204 3.60526 5.16204 3.10777 5.45493 2.80093Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ds=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"more-single",ref:t,icon:Fu}))});ds.displayName="MoreSingle";const us=ds;var Wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.69,y:12.25,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.74646 2.1642C7.34284 1.65121 6.85947 1.28205 6.38447 1.09593C5.86863 0.893787 5.15166 0.852126 4.70047 1.42917C4.29842 1.94344 4.33082 2.70249 4.57691 3.50395C4.68808 3.8661 4.86846 4.22254 5.12522 4.56617C5.13695 4.58185 5.14927 4.5968 5.16211 4.61102C5.17152 4.6214 5.18122 4.63139 5.19115 4.64096C5.20459 4.65393 5.21855 4.66618 5.23296 4.6777L3.5064 6.40422C3.26756 6.64306 3.26756 7.03033 3.5064 7.26919L7.23756 11.0004C7.47648 11.2392 7.86375 11.2392 8.1026 11.0004L12.8329 6.27001C13.0717 6.03117 13.0717 5.6439 12.8329 5.40505L9.10172 1.67387C8.86288 1.43503 8.47561 1.43503 8.23676 1.67387L7.74646 2.1642ZM7.46162 4.50638C7.47252 4.57574 7.48163 4.64652 7.4888 4.71868C7.52232 5.05481 7.82194 5.30013 8.15807 5.26661C8.4942 5.23311 8.73954 4.93345 8.70601 4.59732C8.65786 4.11463 8.54251 3.6666 8.37892 3.26169L8.66928 2.97135L11.5354 5.83753L10.6106 6.76237H4.87824L7.40802 4.2326C7.42885 4.32128 7.44684 4.41255 7.46162 4.50638ZM6.87284 3.03784C6.57441 2.62008 6.22261 2.34634 5.93815 2.23487C5.80233 2.18165 5.71528 2.17827 5.67638 2.18335C5.6725 2.18387 5.66929 2.18443 5.6666 2.18497L5.6619 2.18607C5.64166 2.21954 5.53594 2.45979 5.74626 3.1449C5.81241 3.36036 5.92262 3.58602 6.09307 3.81761L6.87284 3.03784Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.1932 11.5463C12.6454 11.5463 13.012 11.1797 13.012 10.7275C13.012 10.4475 12.6981 9.92821 12.459 9.5733C12.3299 9.38173 12.0564 9.38174 11.9274 9.57331C11.6883 9.92822 11.3744 10.4475 11.3744 10.7275C11.3744 11.1797 11.741 11.5463 12.1932 11.5463Z"}}]}]},hs=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"paint-bucket",ref:t,icon:Wu}))});hs.displayName="PaintBucket";const ju=hs;var zu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.40051 8.00049C1.40051 4.41098 4.311 1.50049 7.90051 1.50049C11.49 1.50049 14.4005 4.41098 14.4005 8.00049C14.4005 11.59 11.49 14.5005 7.90051 14.5005C4.311 14.5005 1.40051 11.59 1.40051 8.00049ZM7.31368 5.3379L7.56087 9.33424H8.24066L8.49816 5.3379L8.51876 4.12252H7.28278L7.31368 5.3379ZM7.07678 11.0646C7.07678 11.5693 7.44758 11.8783 7.90077 11.8783C8.35396 11.8783 8.72476 11.5693 8.72476 11.0646C8.72476 10.5805 8.35396 10.2612 7.90077 10.2612C7.44758 10.2612 7.07678 10.5805 7.07678 11.0646Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ms=V.forwardRef(function(i,t){return V.createElement(pe,Object.assign({},i,{id:"warning-single",ref:t,icon:zu}))});ms.displayName="WarningSingle";const fs=ms,Yu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),v.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),v.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),v.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),v.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),v.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),v.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),v.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),v.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),v.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),v.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),v.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),v.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),v.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),v.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),v.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),v.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),v.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),v.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),v.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),v.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),v.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),v.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),v.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),v.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),v.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),v.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),Xu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),v.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),v.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),v.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),v.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),v.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),v.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),v.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),v.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),v.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),v.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),v.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),v.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),v.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),v.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),v.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),v.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),v.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),v.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),v.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),v.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),v.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),v.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),v.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),v.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),v.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),v.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),v.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),$u=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),v.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),v.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),v.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),v.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),v.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),v.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),v.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),v.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),v.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),v.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),v.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),v.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),v.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),v.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),v.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),v.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),v.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),v.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),v.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Gu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),v.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),v.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),v.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),v.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),v.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),v.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),v.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),v.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),v.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),v.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),v.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),v.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),v.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),v.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),v.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),v.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),v.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),v.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),v.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),v.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),v.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),v.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),v.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),v.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),v.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),v.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),v.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),v.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),v.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),v.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),v.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),v.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),v.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),v.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),v.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),v.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),v.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),v.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),v.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),v.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),v.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),v.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),v.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),v.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),v.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),v.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),v.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),v.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),Zu=()=>v.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),Ku=()=>v.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),v.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),v.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),v.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),v.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),v.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),v.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),v.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),v.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),v.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),v.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),v.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),v.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),v.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),v.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),v.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),v.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),v.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),Qu=()=>v.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),v.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),v.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),v.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),v.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),v.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),v.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),v.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),v.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),v.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),v.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),v.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),v.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),v.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),v.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),v.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),v.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),v.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),v.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),v.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),Ju=()=>v.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),v.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),v.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),v.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),v.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),v.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),v.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),v.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),v.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),v.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),v.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),v.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),v.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),v.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),v.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),v.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),v.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),v.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),v.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),v.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),qu=()=>v.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),gs=()=>v.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Ss(i){const{type:t=a.BorderStyleTypes.THIN}=i;switch(t){case a.BorderStyleTypes.DASH_DOT:return v.jsx(Yu,{});case a.BorderStyleTypes.DASH_DOT_DOT:return v.jsx(Xu,{});case a.BorderStyleTypes.DASHED:return v.jsx($u,{});case a.BorderStyleTypes.HAIR:return v.jsx(Gu,{});case a.BorderStyleTypes.MEDIUM:return v.jsx(Zu,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return v.jsx(Ku,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return v.jsx(Qu,{});case a.BorderStyleTypes.MEDIUM_DASHED:return v.jsx(Ju,{});case a.BorderStyleTypes.THICK:return v.jsx(qu,{});case a.BorderStyleTypes.THIN:return v.jsx(gs,{});default:return v.jsx(gs,{})}}const ke={uiPluginSheetsBorderPanel:"univer-ui-plugin-sheets-border-panel",uiPluginSheetsBorderPanelPosition:"univer-ui-plugin-sheets-border-panel-position",uiPluginSheetsBorderPanelPositionItem:"univer-ui-plugin-sheets-border-panel-position-item",uiPluginSheetsBorderPanelPositionItemActive:"univer-ui-plugin-sheets-border-panel-position-item-active",uiPluginSheetsBorderPanelStyles:"univer-ui-plugin-sheets-border-panel-styles",uiPluginSheetsBorderPanelBoard:"univer-ui-plugin-sheets-border-panel-board",uiPluginSheetsBorderPanelButton:"univer-ui-plugin-sheets-border-panel-button",uiPluginSheetsBorderPanelMoreIcon:"univer-ui-plugin-sheets-border-panel-more-icon"},_s=`${Et}_BORDER_PANEL_COMPONENT`,ps=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],eh=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function th(i){var d;const t=Z.useDependency(C.ComponentManager),e=Z.useDependency(_.BorderStyleManagerService),{onChange:n,value:o}=i;function r(c,u){n==null||n({...o,[u]:c})}function s(c){const u=t.get(c);return u&&v.jsx(u,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function l(c){c.stopPropagation()}return v.jsxs("section",{className:ke.uiPluginSheetsBorderPanel,children:[v.jsx("div",{className:ke.uiPluginSheetsBorderPanelPosition,children:ps.map(c=>v.jsx("div",{className:e.getBorderInfo().type===c.value?`${ke.uiPluginSheetsBorderPanelPositionItemActive} ${ke.uiPluginSheetsBorderPanelPositionItem}`:ke.uiPluginSheetsBorderPanelPositionItem,onClick:u=>{u.stopPropagation(),r(c.value,"type")},children:s(c.icon)},c.value))}),v.jsxs("div",{className:ke.uiPluginSheetsBorderPanelStyles,children:[v.jsx("div",{children:v.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:v.jsx("section",{className:ke.uiPluginSheetsBorderPanelBoard,onClick:l,children:v.jsx(re.ColorPicker,{onChange:c=>r(c,"color")})}),children:v.jsxs("a",{className:ke.uiPluginSheetsBorderPanelButton,onClick:l,children:[v.jsx(ju,{extend:{colorChannel1:(d=o.color)!=null?d:"rgb(var(--primary-color))"}}),v.jsx("span",{className:ke.uiPluginSheetsBorderPanelMoreIcon,children:v.jsx(Jn,{})})]})})}),v.jsx("div",{children:v.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:v.jsx("section",{onClick:l,children:v.jsx(re.Menu,{children:eh.map(c=>v.jsx(re.MenuItem,{eventKey:c.value.toString(),onClick:()=>r(c.value,"style"),children:v.jsx(Ss,{type:c.value})},c.value))})}),children:v.jsxs("a",{className:ke.uiPluginSheetsBorderPanelButton,onClick:l,children:[v.jsx(Ss,{type:a.BorderStyleTypes.THIN}),v.jsx("span",{className:ke.uiPluginSheetsBorderPanelMoreIcon,children:v.jsx(Jn,{})})]})})})]})]})}const nh={countBar:"univer-count-bar"},ih=[50,80,100,130,150,170,200,400];function oh(){const i=Z.useDependency(a.ICommandService),t=Z.useDependency(a.IUniverInstanceService),e=V.useCallback(()=>{const s=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getZoomRatio()*100||100;return Math.round(s)},[t]),[n,o]=V.useState(()=>e());V.useEffect(()=>i.onCommandExecuted(l=>{if(l.id===Le.id||l.id===_.SetWorksheetActivateCommand.id){const d=e();o(d)}}).dispose,[i,e]);function r(s){o(s);const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d=l==null?void 0:l.getActiveSheet();if(d==null)return;const c=s/100;i.executeCommand(Bn.id,{unitId:l.getUnitId(),subUnitId:d.getSheetId(),zoomRatio:c})}return v.jsx(re.Slider,{min:vi[0],value:n,shortcuts:ih,onChange:r})}function rh(i){return v.jsx("section",{className:nh.countBar,children:v.jsx(oh,{})})}const vs={editorContainer:"univer-editor-container",editorInput:"univer-editor-input"},qn=-1e3,Cs={width:0,height:0,top:qn,left:qn},sh=()=>{const[i,t]=V.useState({...Cs}),e=Z.useDependency(tn),n=Z.useDependency(C.IEditorService),o=Z.useDependency(a.IContextService),r=C.useObservable(()=>o.subscribeContextValue$(C.DISABLE_AUTO_FOCUS_KEY),!1,void 0,[o,C.DISABLE_AUTO_FOCUS_KEY]),s={id:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}};return V.useEffect(()=>{e.state$.subscribe(l=>{if(l==null)return;const{startX:d=qn,startY:c=qn,endX:u=0,endY:h=0,show:m=!1}=l;if(!m)t({...Cs});else{t({width:u-d-w.FIX_ONE_PIXEL_BLUR_OFFSET+2,height:h-c-w.FIX_ONE_PIXEL_BLUR_OFFSET+2,left:d+w.FIX_ONE_PIXEL_BLUR_OFFSET,top:c+w.FIX_ONE_PIXEL_BLUR_OFFSET});const f=n.getEditor(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(f==null)return;const{left:g,top:S,width:p,height:R}=f.getBoundingClientRect();e.setRect({left:g,top:S,width:p,height:R})}})},[]),V.useEffect(()=>{r||e.setFocus(!0)},[r,i]),v.jsx("div",{className:vs.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:v.jsx(C.TextEditor,{id:a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:vs.editorInput,snapshot:s,cancelDefaultResizeListener:!0,isSheetEditor:!0,isSingle:!1})})},ae={definedName:"univer-defined-name",definedNameDropDown:"univer-defined-name-drop-down",definedNameOverlay:"univer-defined-name-overlay",definedNameOverlayContainer:"univer-defined-name-overlay-container",definedNameOverlayItem:"univer-defined-name-overlay-item",definedNameOverlayItemName:"univer-defined-name-overlay-item-name",definedNameOverlayItemNameForSheet:"univer-defined-name-overlay-item-name-for-sheet",definedNameOverlayItemFormula:"univer-defined-name-overlay-item-formula",definedNameOverlayManager:"univer-defined-name-overlay-manager",definedNameOverlayManagerTitle:"univer-defined-name-overlay-manager-title",definedNameOverlayManagerContent:"univer-defined-name-overlay-manager-content",definedNameContainer:"univer-defined-name-container",definedNameContainerScroll:"univer-defined-name-container-scroll",definedNameContainerAddButton:"univer-defined-name-container-addButton",definedNameContainerAddButtonText:"univer-defined-name-container-addButton-text",definedNameContainerItem:"univer-defined-name-container-item",definedNameContainerItemName:"univer-defined-name-container-item-name",definedNameContainerItemNameForSheet:"univer-defined-name-container-item-name-for-sheet",definedNameContainerItemFormulaOrRefString:"univer-defined-name-container-item-formula-or-refString",definedNameContainerItemUpdate:"univer-defined-name-container-item-update",definedNameContainerItemDelete:"univer-defined-name-container-item-delete",definedNameContainerItemShow:"univer-defined-name-container-item-show",definedNameInput:"univer-defined-name-input",definedNameInputValidation:"univer-defined-name-input-validation"},Is="DefinedNameContainer",so="AllDefaultWorkbook",Rs={id:"sidebar.operation.defined-name",type:a.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(C.ISidebarService),n=i.get(C.IEditorService),o=i.get(a.LocaleService),r=i.get(a.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{unitId:l}=s;switch(t.value){case"open":n.setOperationSheetUnitId(l),e.open({header:{title:o.t("definedName.featureTitle")},children:{label:Is},onClose:()=>{n.closeRangePrompt()},width:333});break;case"close":default:e.close();break}return!0}};function ah(i){const t=Z.useDependency(a.ICommandService),e=Z.useDependency(a.LocaleService),n=Z.useDependency(K.IDefinedNamesService),s=Z.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=()=>{const m=n.getDefinedNameMap(s);return m?Array.from(Object.values(m)):[]},[d,c]=V.useState(l());V.useEffect(()=>{const m=n.update$.subscribe(()=>{c(l())});return()=>{m.unsubscribe()}},[]);const u=()=>{t.executeCommand(Rs.id,{value:"open"})},h=m=>{n.focusRange(s,m.id)};return v.jsxs("div",{className:ae.definedNameOverlay,children:[v.jsx("div",{className:ae.definedNameOverlayContainer,children:d.map((m,f)=>v.jsxs("div",{className:ae.definedNameOverlayItem,onClick:()=>{h(m)},children:[v.jsx("div",{className:ae.definedNameOverlayItemName,title:m.name,children:m.name}),v.jsx("div",{className:ae.definedNameOverlayItemFormula,title:m.formulaOrRefString,children:m.formulaOrRefString})]},f))}),v.jsxs("div",{className:ae.definedNameOverlayManager,onClick:u,children:[v.jsx("div",{className:ae.definedNameOverlayManagerTitle,children:e.t("definedName.managerTitle")}),v.jsx("div",{className:ae.definedNameOverlayManagerContent,children:e.t("definedName.managerDescription")})]})]})}function lh(){const[i,t]=V.useState(""),e=Z.useDependency(K.IDefinedNamesService);return V.useEffect(()=>{const n=e.currentRange$.subscribe(()=>{t(e.getCurrentRangeForString())});return()=>{n.unsubscribe()}},[]),v.jsxs("div",{className:ae.definedName,children:[v.jsx(re.Input,{value:i,type:"text",size:"small",affixWrapperStyle:{border:"none",paddingLeft:"6px",paddingRight:"6px",height:"100%"}}),v.jsx(re.Dropdown,{overlay:v.jsx(ah,{}),children:v.jsx("div",{className:ae.definedNameDropDown,children:v.jsx(Jn,{})})})]})}const ue={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",iconContainerFx:"univer-icon-container-fx",formulaInput:"univer-formula-input",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container"};function ch(){const[i,t]=V.useState(ue.formulaGrey),[e,n]=V.useState(0),o=Z.useDependency(On),r=Z.useDependency(Ee),s={id:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:a.HorizontalAlign.UNSPECIFIED,verticalAlign:a.VerticalAlign.TOP,centerAngle:0,vertexAngle:0,wrapStrategy:a.WrapStrategy.WRAP}}};V.useEffect(()=>{const m=r.visible$.subscribe(f=>{t(f.visible?ue.formulaActive:ue.formulaGrey)});return()=>m.unsubscribe()},[r.visible$]);function l(m){if(m==null)return;const f=m.getBoundingClientRect();o.setPosition(f)}function d(){n(e===0?1:0),setTimeout(()=>{o.handleFoldBtnClick(e===1)},150)}function c(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:C.KeyCode.ESC})}function u(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})}function h(){o.handleFxBtnClick(!0)}return v.jsxs("div",{className:ue.formulaBox,style:{height:e===0?"28px":"82px"},children:[v.jsx("div",{className:ue.nameRanges,children:v.jsx(lh,{})}),v.jsxs("div",{className:ue.formulaBar,children:[v.jsx("div",{className:ue.formulaIcon,children:v.jsxs("div",{className:ue.formulaIconWrapper,children:[v.jsx("span",{className:Pe(ue.iconContainer,ue.iconContainerError,i),onClick:c,children:v.jsx(yu,{})}),v.jsx("span",{className:Pe(ue.iconContainer,ue.iconContainerSuccess,i),onClick:u,children:v.jsx(ln,{})}),v.jsx("span",{className:Pe(ue.iconContainer,ue.iconContainerFx),onClick:h,children:v.jsx(Vu,{})})]})}),v.jsxs("div",{className:ue.formulaInput,children:[v.jsx(C.TextEditor,{id:a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,isSheetEditor:!0,resizeCallBack:l,cancelDefaultResizeListener:!0,onContextMenu:m=>m.preventDefault(),className:ue.formulaContent,snapshot:s,isSingle:!1}),v.jsx("div",{className:ue.arrowContainer,onClick:d,children:e===0?v.jsx(ns,{}):v.jsx(ns,{style:{transform:"rotateZ(180deg)"}})})]})]}),v.jsx(C.ProgressBar,{})]})}const ht={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},dh=()=>{const[,i]=V.useState({});return V.useCallback(()=>i(t=>!t),[])},uh=()=>{var ee;const i=Z.useDependency(a.ICommandService),t=Z.useDependency(N.SheetSkeletonManagerService),e=Z.useDependency(a.IUniverInstanceService),n=Z.useDependency(w.IRenderManagerService),o=Z.useDependency(Ie),r=Z.useDependency(Jt),s=Z.useDependency(a.LocaleService),[l,d]=V.useState([]),[c,u]=V.useState(!1),[h,m]=V.useState({row:-1,col:-1}),[f,g]=V.useState(oe.SERIES),[S,p]=V.useState(!1),R=()=>{p(!0)},M=()=>{p(!1)},T=dh();if(V.useEffect(()=>{const L=[ye.id,Cn.id,Le.id,_.SetWorksheetActiveOperation.id,_.SetRangeValuesMutation.id,_.MoveRangeMutation.id,_.RemoveRowMutation.id,_.RemoveColMutation.id,_.InsertRowMutation.id,_.InsertColMutation.id,_.MoveRowsMutation.id,_.MoveColsMutation.id,_.SetWorksheetColWidthMutation.id,_.SetWorksheetRowHeightMutation.id];return i.onCommandExecuted((F,Y)=>{F.id===ot.id&&T();const G=Y==null?void 0:Y.fromCollab;L.includes(F.id)&&!G&&m({row:-1,col:-1})}).dispose},[T,i]),V.useEffect(()=>a.toDisposable(t.currentSkeleton$.subscribe(U=>{U&&T()})).dispose,[t,T]),V.useEffect(()=>a.toDisposable(r.menu$.subscribe(U=>{d(U.map(F=>({...F,index:U.indexOf(F)})))})).dispose,[r]),V.useEffect(()=>a.toDisposable(r.showMenu$.subscribe(U=>{const{source:F,target:Y}=r.autoFillLocation||{source:null,target:null};if(U&&F&&Y){const G=Math.max(F.rows[F.rows.length-1],Y.rows[Y.rows.length-1]),te=Math.max(F.cols[F.cols.length-1],Y.cols[Y.cols.length-1]);m({row:G,col:te})}})).dispose,[r]),V.useEffect(()=>a.toDisposable(r.applyType$.subscribe(U=>{g(U)})).dispose,[r]),V.useEffect(()=>{function L(){u(!1)}return document.addEventListener("wheel",L),()=>{document.removeEventListener("wheel",L)}},[c]),h.col<0||h.row<0)return null;const b=Me(e,n);if(!b)return null;const{scene:E}=b,y=(ee=t.getCurrent())==null?void 0:ee.skeleton,O=o.getViewPort(),x=E==null?void 0:E.scaleX,D=E==null?void 0:E.scaleY,W=E==null?void 0:E.getScrollXY(O);if(!x||!E||!x||!D||!W)return null;const A=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,H=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,B=y==null?void 0:y.convertTransformToOffsetX(A,x,W),z=y==null?void 0:y.convertTransformToOffsetY(H,D,W);if(B==null||z==null)return null;const X=L=>{u(L)},Q=L=>{i.executeCommand(jr.id,{type:L.value})},J=c||S,$=l.filter(L=>!L.disable);return v.jsx("div",{onMouseEnter:R,onMouseLeave:M,style:{left:`${B+2}px`,top:`${z+2}px`,position:"absolute"},children:v.jsx(re.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:v.jsx("ul",{className:ht.autoFillPopupMenu,children:$.map(L=>v.jsxs("li",{onClick:()=>Q(L),className:ht.autoFillPopupMenuItem,children:[v.jsx("span",{className:ht.autoFillPopupMenuItemIcon,children:L.value===f&&v.jsx(ln,{style:{color:"rgb(var(--green-700, #409f11))"}})}),v.jsx("span",{className:ht.autoFillPopupMenuItemTitle,children:s.t(L.label)})]},L.index))}),visible:c,onVisibleChange:X,children:v.jsxs("div",{className:Pe(ht.btnContainer,{[ht.btnContainerExpand]:c}),children:[v.jsx(Tu,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),J&&v.jsx(Jn,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},hh=()=>v.jsx("div",{className:ht.operateContainer,children:v.jsx(uh,{})}),ei={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},mh={sheetBarBtn:"univer-sheet-bar-btn"};function ti(i){const{children:t,className:e,style:n,disabled:o=!1,onClick:r,...s}=i,l=d=>{if(o){d.preventDefault();return}r&&r(d)};return v.jsx("button",{className:mh.sheetBarBtn,style:n,disabled:o,onClick:l,...s,children:t})}const st={sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function fh(i){const{style:t}=i,[e,n]=V.useState([]),[o,r]=V.useState(!1),s=Z.useDependency(a.IUniverInstanceService),l=Z.useDependency(a.ICommandService),d=Z.useDependency(At),c=C.useObservable(()=>s.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[]),u=S=>{const{sheetId:p}=S;!p||!c||(S.hidden?l.executeCommand(_.SetWorksheetShowCommand.id,{value:p}):S.selected||l.executeCommand(_.SetWorksheetActivateCommand.id,{unitId:c.getUnitId(),subUnitId:p}),r(!1))},h=V.useCallback(()=>{if(!c)return;const S=c.getSheets(),p=c.getActiveSheet(),R=S.map((M,T)=>({label:M.getName(),index:`${T}`,sheetId:M.getSheetId(),hidden:M.isSheetHidden()===a.BooleanNumber.TRUE,selected:p===M}));n(R)},[c]),m=V.useCallback(()=>l.onCommandExecuted(S=>{switch(S.id){case _.SetWorksheetHideMutation.id:case _.RemoveSheetMutation.id:case _.SetWorksheetNameMutation.id:case _.InsertSheetMutation.id:case _.SetWorksheetOrderMutation.id:case _.SetWorksheetActiveOperation.id:h();break}}),[l,h]);function f(){r(!0)}const g=S=>{r(S)};return V.useEffect(()=>{h();const S=new a.DisposableCollection;return S.add(m()),S.add(d.registerSheetBarMenuHandler({handleSheetBarMenu:f})),()=>S.dispose()},[m,d,h,c]),v.jsx(re.Dropdown,{placement:"topLeft",trigger:["click"],overlay:v.jsx("ul",{className:st.sheetBarMenu,style:{...t},children:e.map(S=>v.jsxs("li",{onClick:()=>u(S),className:S.selected?`${st.sheetBarMenuItem} ${st.sheetBarMenuItemSelect}`:S.hidden?`${st.sheetBarMenuItem} ${st.sheetBarMenuItemHide}`:st.sheetBarMenuItem,children:[v.jsx("span",{className:st.sheetBarMenuItemIcon,children:S.selected?v.jsx(ln,{}):S.hidden?v.jsx(Lu,{}):v.jsx(ln,{})}),v.jsx("span",{className:st.sheetBarMenuItemLabel,children:S.label})]},S.index))}),visible:o,onVisibleChange:g,children:v.jsx(ti,{children:v.jsx(Nu,{})})})}const Ae={slideTabBarContainer:"univer-slide-tab-bar-container",slideTabBar:"univer-slide-tab-bar",slideTabItem:"univer-slide-tab-item",slideTabActive:"univer-slide-tab-active",slideTabSpan:"univer-slide-tab-span",slideTabSpanEdit:"univer-slide-tab-span-edit",slideTabItemDropdown:"univer-slide-tab-item-dropdown"};function gh(i){const{sheetId:t,label:e,color:n,selected:o}=i,[r,s]=V.useState(o),l=Z.useDependency(a.ThemeService);V.useEffect(()=>{s(o)},[o]);const d=c=>{const u=l.getCurrentTheme(),h=u.textColor,m=u.colorWhite;return new a.ColorKit(c).isDark()?m:h};return v.jsx("div",{"data-id":t,className:r?`${Ae.slideTabActive} ${Ae.slideTabItem}`:Ae.slideTabItem,style:{backgroundColor:!r&&n?n:"",color:!r&&n?d(n):"",boxShadow:r&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:v.jsx("span",{className:Ae.slideTabSpan,children:e})},t)}const Sh={easeOutStrong(i,t,e,n){return-e*((i=i/n-1)*i*i*i-1)+t},backOut(i,t,e,n,o){return typeof o>"u"&&(o=.7),e*((i=i/n-1)*i*((o+1)*i+o)+1)+t}},_h={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class ph{constructor(t){I(this,"_config");I(this,"_status",0);I(this,"_start",0);I(this,"_handle",0);I(this,"_delayHandle",null);this._config={..._h,...t},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...t){let e=0;return new Promise(n=>{for(let o=0;o<t.length;o++){const r=t[o],s=r._config,l=s.success;s.loop||(s.success=c=>{e++,l&&l.call(r,c),e===t.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let t=Date.now()-this._start;t=t>=this._config.duration?this._config.duration:t;const n=Sh[this._config.type](t,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(t===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class mt{constructor(t,e){I(this,"_slideTabItem");I(this,"_animate");I(this,"_midline",0);I(this,"_translateX");I(this,"_scrollbar");I(this,"_slideTabBar");I(this,"_editMode");I(this,"_placeholder");this._slideTabItem=t,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=e,this._placeholder=null,this._scrollbar=e.getScrollbar(),this.update()}static midline(t){return t.getBoundingRect().x+t.getBoundingRect().width/2}static leftLine(t){return t.getBoundingRect().x}static rightLine(t){return t.getBoundingRect().x+t.getBoundingRect().width}static make(t,e){const n=[];return t.forEach(o=>n.push(new mt(o,e))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var t;(t=this.getEditor())==null||t.focus()}selectAll(){const t=this.getEditor();t&&Dt.keepSelectAll(t)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(t){return this._translateX=t,this._slideTabItem.style.transform=`translateX(${t}px)`,this.getTranslateXDirection()}setEditor(t){let e=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),o=c=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",o),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",l),n.removeEventListener("input",d),n.removeEventListener("keydown",r),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}t&&t(c)}};let r=c=>{n&&(c.stopPropagation(),c.key==="Enter"&&n.blur())};const s=c=>{e=!1},l=c=>{e=!0},d=c=>{if(!n)return;const u=50;setTimeout(()=>{if(e){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),Dt.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",o),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",l),n.addEventListener("input",d),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,Dt.keepSelectAll(n))}}nameCheck(){const t=this._slideTabItem.querySelector("span");if(!t)return!1;const e=t.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(e)}animate(){return{translateX:t=>{this._translateX!==t&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new ph({begin:this._translateX,end:t,receive:e=>{this._slideTabItem.style.transform=`translateX(${e}px)`}}),this._translateX=t,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(t){this._slideTabItem.after(t._slideTabItem||t)}update(){this._midline=mt.midline(this)}disableFixed(){if(this._placeholder){const t=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),t.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const t=document.createElement("div"),e=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),o=this._slideTabItem.querySelector("span");if(this._placeholder=t,this._placeholder.style.width=`${e.width}px`,this._placeholder.style.height=`${e.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,o){const r=getComputedStyle(o).padding;this._slideTabItem.style.padding=r}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${e.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${e.y}px`,this._slideTabItem.style.width=`${e.width}px`,this._slideTabItem.style.height=`${e.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(t),document.body.appendChild(this._slideTabItem)}addEventListener(t,e,n){this._slideTabItem.addEventListener(t,e,n)}removeEventListener(t,e,n){this._slideTabItem.removeEventListener(t,e,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const t=this._slideTabItem.getBoundingClientRect();return t.x+=this._scrollbar.getScrollX(),t}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const t=mt.midline(this);return t>this._midline?1:t<this._midline?-1:0}equals(t){return t&&t._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class vh{constructor(t){I(this,"_slideTabBar");I(this,"_scrollX");const e=t.primeval();this._scrollX=e.scrollLeft,this._slideTabBar=t}scrollX(t){const e=this._slideTabBar.primeval();e.scrollLeft=t,this._scrollX=e.scrollLeft}scrollRight(){const t=this._slideTabBar.primeval();t.scrollLeft=t.scrollWidth,this._scrollX=t.scrollLeft}getScrollX(){return this._scrollX}}const Ut=class Ut{constructor(t){I(this,"_activeTabItemIndex",0);I(this,"_slideTabBar");I(this,"_slideTabItems",[]);I(this,"_config");I(this,"_downActionX",0);I(this,"_moveActionX",0);I(this,"_compareIndex",0);I(this,"_activeTabItem",null);I(this,"_moveAction");I(this,"_upAction");I(this,"_downAction");I(this,"_wheelAction");I(this,"_scrollIncremental",0);I(this,"_compareDirection",0);I(this,"_autoScrollTime",null);I(this,"_slideScrollbar");I(this,"_longPressTimer",null);I(this,"_leftBoundingLine",0);I(this,"_rightBoundingLine",0);I(this,"_leftMoveX",0);I(this,"_rightMoveX",0);var s;if(t.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const e=t.slideTabBarContainer.querySelector(`.${(s=t.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(e==null)throw new Error("not found slide-tab-bar");this._slideTabBar=e,this._slideScrollbar=new vh(this),this._config=t,this._initConfig();let n=0,o=0,r=0;this._downAction=l=>{var y,O,x,D,W,A;if((y=this._activeTabItem)!=null&&y.isEditMode())return;const d=(x=(O=l.target)==null?void 0:O.closest(`.${t.slideTabBarItemClassName}`))==null?void 0:x.getAttribute("data-id"),c=this._slideTabItems.findIndex(H=>H.getId()===d);if(d==null||c===-1)return;if(this._activeTabItemIndex!==c){(D=this._activeTabItem)==null||D.removeEventListener("pointermove",this._moveAction),(W=this._activeTabItem)==null||W.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(l,d);return}if(this._compareIndex=c,this._downActionX=l.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[c],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const u=this._activeTabItem.getSlideTabItem();u==null||u.setPointerCapture(l.pointerId),(A=this._activeTabItem)==null||A.addEventListener("pointerup",this._upAction);const{x:h,width:m}=this._activeTabItem.getBoundingRect(),{x:f,width:g}=this.getBoundingRect(),S=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-S),this._rightBoundingLine=h-S+m-this._downActionX,this._leftMoveX=h-f-S,this._rightMoveX=f+g-(h+m)+S,l.button===2||this._hasEditItem())return;const{pageX:p,pageY:R}=l,M=Date.now(),T=M-r<=Ut.DoubleClickDelay,b=Math.abs(p-n)<10,E=Math.abs(R-o)<10;T&&b&&E&&this._activeTabItem.setEditor(),n=p,o=R,r=M,this._longPressTimer=setTimeout(()=>{var H,B;(H=this._activeTabItem)==null||H.enableFixed(),this._startAutoScroll(),u&&(u.setPointerCapture(l.pointerId),u.style.cursor="move",(B=this._activeTabItem)==null||B.addEventListener("pointermove",this._moveAction))},Ut.LongPressDelay)},this._upAction=l=>{var c,u,h;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const d=(c=this._activeTabItem)==null?void 0:c.getSlideTabItem();d&&(d.style.cursor="",d.releasePointerCapture(l.pointerId),(u=this._activeTabItem)==null||u.removeEventListener("pointermove",this._moveAction),(h=this._activeTabItem)==null||h.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(l,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=l=>{this._activeTabItem&&(this._moveActionX=l.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(l),this._scrollRight(l))},this._wheelAction=l=>{this.setScroll(l.deltaY)},this.addListener()}static checkedSkipSlide(t){let e=t.target;for(;e!=null&&e!==document.body;){if(e.getAttribute("data-slide-skip"))return!0;e=e.parentElement}return!1}static keepLastIndex(t){setTimeout(()=>{const e=window.getSelection();e&&(e.selectAllChildren(t),e.collapseToEnd())})}static keepSelectAll(t){setTimeout(()=>{const e=window.getSelection();if(!e)return;const n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)})}update(t){this._config.currentIndex=t,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let t=0;t<this._slideTabItems.length;t++)this._slideTabItems[t].animate().cancel(),this._slideTabItems[t].translateX(0),this._slideTabItems[t].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const t=this._slideTabBar.parentElement;return t?this._slideTabBar.scrollWidth-t.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.removeEventListener("pointerdown",this._downAction)})}setScroll(t){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t),t>0){const e=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(t){if(t>0){const e=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,l=o.getSlideTabItem().getBoundingClientRect(),d=l.left,c=l.width;return d<s&&d+c+n*2>s?(e=t?d-r.left-n:d+c-s+n,!0):!1}),e}calculateRightScrollX(t){let e=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,l=o.getSlideTabItem().getBoundingClientRect(),d=l.left,c=l.width;return d-n*2<s&&d+c>s?(e=t?d+c-r.left-r.width+n:d-s-n,!0):!1}),e}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let t=0;t<this._slideTabItems.length;t++)if(this._slideTabItems[t].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n>e.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(e.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let t=0;t<this._slideTabItems.length;t++){const e=this._slideTabItems[t],n=this._slideTabItems[t+1];n&&e.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=0;r<t&&!(r>=t);r++)n.push(this._slideTabItems[r]);for(let r=t+1;r<e;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];mt.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=t+1;r<e;r++)n.push(this._slideTabItems[r]);for(let r=0;r<t;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=0;r<n.length;r++){const s=n[r];mt.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=t+r+1,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var e;const t=this._slideTabBar.querySelectorAll(`.${(e=this._config.slideTabBarItemClassName)!=null?e:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=mt.make(t,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};I(Ut,"LongPressDelay",500),I(Ut,"DoubleClickDelay",300);let Dt=Ut;function Ch(){const[i,t]=V.useState([]),[e,n]=V.useState(""),[o,r]=V.useState(""),[s,l]=V.useState(!1),[d,c]=V.useState([0,0]),u=V.useRef({slideTabBar:null}),h=V.useRef(null),m=Z.useDependency(a.IUniverInstanceService),f=Z.useDependency(a.ICommandService),g=Z.useDependency(At),S=Z.useDependency(a.LocaleService),p=Z.useDependency(C.IConfirmService),R=Z.useDependency(Ie),M=Z.useDependency(Ee);Z.useInjector();const T=m.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);V.useEffect(()=>{A();const L=b(),U=W(),F=[H(),B(),z(),X()];return()=>{U.dispose(),L.destroy(),F.forEach(Y=>Y.unsubscribe())}},[]),V.useEffect(()=>{i.length>0&&D()},[i]);const b=()=>{const L=new Dt({slideTabBarClassName:Ae.slideTabBar,slideTabBarItemActiveClassName:Ae.slideTabActive,slideTabBarItemClassName:Ae.slideTabItem,slideTabBarSpanEditClassName:Ae.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(U,F)=>{f.executeCommand(_.SetWorksheetNameCommand.id,{subUnitId:U,name:F})},onSlideEnd:(U,F)=>{f.executeCommand(_.SetWorksheetOrderCommand.id,{order:F})},onChangeTab:(U,F)=>{f.executeCommand(_.SetWorksheetActiveOperation.id,{subUnitId:F,unitId:T.getUnitId()}).then(()=>{U.button===2&&ee(!0)})},onScroll:U=>{g.setScroll(U)},onNameCheckAlert:U=>E(U)||y(U)});return u.current.slideTabBar=L,$(L),L},E=L=>{if(L.trim()===""){const U="sheetNameEmptyAlert";return p.open({id:U,title:{title:S.t("sheetConfig.sheetNameErrorTitle")},children:{title:S.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:S.t("button.cancel"),confirmText:S.t("button.confirm"),onClose(){O(),p.close(U)},onConfirm(){O(),p.close(U)}}),!0}return!1},y=L=>{const U=m.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(U.getActiveSheet().getName()===L)return!1;const G=U.checkSheetName(L);if(G){const te="sheetNameRepeatAlert";p.open({id:te,title:{title:S.t("sheetConfig.sheetNameErrorTitle")},children:{title:S.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:S.t("button.cancel"),confirmText:S.t("button.confirm"),onClose(){p.close(te),O()},onConfirm(){p.close(te),O()}})}return G},O=()=>{R.endSelection(),setTimeout(()=>{var U;const L=(U=u.current.slideTabBar)==null?void 0:U.getActiveItem();L&&(L.focus(),L.selectAll())},0)},x=()=>{var L,U;(U=(L=u.current.slideTabBar)==null?void 0:L.getActiveItem())==null||U.setEditor()},D=()=>{var U;const L=i.findIndex(F=>F.selected);(U=u.current.slideTabBar)==null||U.update(L)},W=()=>f.onCommandExecuted(L=>{switch(L.id){case _.SetTabColorMutation.id:case _.SetWorksheetHideMutation.id:case _.RemoveSheetMutation.id:case _.SetWorksheetNameMutation.id:case _.InsertSheetMutation.id:case _.SetWorksheetOrderMutation.id:case _.SetWorksheetActiveOperation.id:A();break}}),A=()=>{const L=T.getActiveSheet().getSheetId();n(L);const U=T.getSheets(),F=T.getActiveSheet(),Y=U.filter(G=>!G.isSheetHidden()).map((G,te)=>{var ne;return{sheetId:G.getSheetId(),label:G.getName(),index:te,selected:F===G,color:(ne=G.getTabColor())!=null?ne:void 0}});t(Y)},H=()=>g.scroll$.subscribe(L=>{Q(L)}),B=()=>g.scrollX$.subscribe(L=>{var U;(U=u.current.slideTabBar)==null||U.flipPage(L)}),z=()=>g.renameId$.subscribe(()=>{x()}),X=()=>g.addSheet$.subscribe(()=>{var L;(L=u.current.slideTabBar)==null||L.getScrollbar().scrollRight()}),Q=L=>{const{leftEnd:U,rightEnd:F}=L;let Y="";U&&F?Y="":U&&!F?Y="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!U&&F?Y="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!U&&!F&&(Y="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(Y)},J=L=>{g.setScroll({leftEnd:L.isLeftEnd(),rightEnd:L.isRightEnd()})},$=L=>{var Y;const U=(Y=h.current)==null?void 0:Y.querySelector(`.${Ae.slideTabBar}`);if(!U)return;new ResizeObserver(()=>{J(L)}).observe(U)},ee=L=>{var U,F,Y,G,te;if(!M.isForceKeepVisible()){if(L){const{left:ne}=(F=(U=h.current)==null?void 0:U.getBoundingClientRect())!=null?F:{},{left:de}=(te=(G=(Y=u.current.slideTabBar)==null?void 0:Y.getActiveItem())==null?void 0:G.getSlideTabItem().getBoundingClientRect())!=null?te:{};ne!==void 0&&de!==void 0&&c([de-ne,0])}l(L)}};return v.jsx(re.Dropdown,{className:Ae.slideTabItemDropdown,visible:s,align:{offset:d},trigger:["contextMenu"],overlay:v.jsx(C.Menu,{menuType:le.SHEET_BAR,onOptionSelect:L=>{const{label:U,value:F}=L;f.executeCommand(U,{value:F,subUnitId:e}),l(!1)}}),onVisibleChange:ee,children:v.jsx("div",{className:Ae.slideTabBarContainer,ref:h,children:v.jsx("div",{className:Ae.slideTabBar,style:{boxShadow:o},children:i.map(L=>V.createElement(gh,{...L,key:L.sheetId,selected:e===L.sheetId}))})})})}const Ms=100,Ih=()=>{const[i,t]=V.useState(!0),[e,n]=V.useState(!0),o=Z.useDependency(a.ICommandService),r=Z.useDependency(At);V.useEffect(()=>{const u=r.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;t(h),n(m)},l=()=>{o.executeCommand(_.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},d=()=>{r.setScrollX(-Ms)},c=()=>{r.setScrollX(Ms)};return v.jsxs("div",{className:ei.sheetBar,children:[v.jsxs("div",{className:ei.sheetBarOptions,children:[v.jsx(ti,{onClick:l,children:v.jsx(ls,{})}),v.jsx(fh,{})]}),v.jsx(Ch,{}),(!i||!e)&&v.jsxs("div",{className:`${ei.sheetBarOptions} ${ei.sheetBarOptionsDivider}`,children:[v.jsx(ti,{disabled:i,onClick:d,children:v.jsx(us,{style:{transform:"rotateZ(180deg)"}})}),v.jsx(ti,{disabled:e,onClick:c,children:v.jsx(us,{})})]})]})};class Rh{constructor(){I(this,"_functions",[{func:K.FUNCTION_NAMES_STATISTICAL.MAX,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.MIN,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_MATH.SUM,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:t=>{var e,n;return((n=(e=t.values.find(o=>o.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1}},{func:K.FUNCTION_NAMES_STATISTICAL.COUNT,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}},{func:K.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:t=>{var e,n,o,r;return((n=(e=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(o=t.values.find(s=>s.func===K.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:o.value)!=null?r:0)>0}}]);I(this,"_state$",new k.BehaviorSubject(null));I(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(t){var n;const e={values:[],pattern:null};t==null||t.values.forEach(o=>{const r=this._functions.find(s=>s.func===o.func);r&&(r.filter===void 0||r.filter(t))&&e.values.push(o)}),e.pattern=(n=t==null?void 0:t.pattern)!=null?n:null,this._state$.next(e)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(t){this._functions.push(...t)}}const ao=P.createIdentifier("univer.sheet-status-bar.service"),Pt={statusBar:"univer-status-bar",singleMode:"univer-single-mode",statusBarDiv:"univer-status-bar-div",statisticList:"univer-statistic-list",statisticListColumn:"univer-statistic-list-column",statisticItem:"univer-statistic-item",statisticPicker:"univer-statistic-picker",statisticPickerItem:"univer-statistic-picker-item",statisticMore:"univer-statistic-more"},Mh=[K.FUNCTION_NAMES_MATH.SUM,K.FUNCTION_NAMES_STATISTICAL.AVERAGE,K.FUNCTION_NAMES_STATISTICAL.MIN,K.FUNCTION_NAMES_STATISTICAL.MAX],lo={[K.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[K.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[K.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[K.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[K.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[K.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[K.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},co=i=>{const t=Z.useDependency(a.LocaleService),e=Z.useDependency(C.IMessageService),n=Z.useDependency(C.IClipboardInterfaceService),o=bh(i),r=async()=>{await n.writeText(i.value.toString()),e.show({type:re.MessageType.Success,content:t.t("statusbar.copied")})};return v.jsx(re.Tooltip,{title:t.t("statusbar.clickToCopy"),placement:"top",children:v.jsx("div",{className:Pt.statisticItem,onClick:r,children:v.jsx("span",{children:`${t.t((lo==null?void 0:lo[i.name])||i.name)}: ${o}`})},i.name)})};function bh(i){const{pattern:t,value:e}=i;return typeof e!="number"?"Invalid input":e>=1e8?e.toExponential(2):t&&Mh.includes(i.name)?Sn.format(t,e):e.toLocaleString()}const bs=800,Th=3,wh=()=>{const[i,t]=V.useState(window.innerWidth<bs),[e,n]=V.useState(!0),o=Z.useDependency(ao),r=o.getFunctions().map((m,f)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,l]=V.useState(r),d=s.find(m=>m.show&&!m.disable),c=i&&d?[d]:s.filter(m=>m.show&&!m.disable);V.useEffect(()=>{const m=o.state$.subscribe(f=>{const g=f==null?void 0:f.values;if(!g||g.length===0)n(!1);else{n(!0);const S=s.map(p=>{var M;const R=g.find(T=>T.func===p.name);return R?(p.value=R.value,p.disable=!1):p.disable=!0,p.pattern=(M=f==null?void 0:f.pattern)!=null?M:null,p});l(S)}});return()=>{m.unsubscribe()}},[o]);const u=a.debounce(()=>{const m=window.innerWidth<bs;i!==m&&t(m)},100);V.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[i]);let h=null;if(c.length>Th){const m=[];c.forEach((f,g)=>{g%2===0&&m.push(c.slice(g,g+2))}),h=v.jsxs(v.Fragment,{children:[" ",m.map((f,g)=>v.jsxs("div",{className:Pt.statisticListColumn,children:[(f==null?void 0:f[0])&&v.jsx(co,{...f==null?void 0:f[0]},f==null?void 0:f[0].name),(f==null?void 0:f[1])&&v.jsx(co,{...f==null?void 0:f[1]},f==null?void 0:f[1].name)]},`stat-col-${g}`))," "]})}else h=v.jsx(v.Fragment,{children:c.map(m=>v.jsx(co,{...m},m.name))});return e&&v.jsxs("div",{className:Pe(Pt.statusBar,{[Pt.singleMode]:i}),children:[v.jsx("div",{className:Pe(Pt.statisticList),children:h}),v.jsx("div",{className:Pt.statusBarDiv})]})};function Eh(){const i=Z.useDependency(a.IUniverInstanceService);return C.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[])?v.jsxs("section",{className:Nr.sheetContainer,"data-range-selector":!0,children:[v.jsx(Ih,{}),v.jsx(wh,{}),v.jsx(rh,{})]}):null}function yh(){const i=Z.useDependency(a.IUniverInstanceService);return C.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[])?v.jsx(v.Fragment,{children:v.jsx(ch,{})}):null}function Oh(){const i=Z.useDependency(a.IUniverInstanceService);return C.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),null,!1,[])?v.jsxs(v.Fragment,{children:[v.jsx(sh,{}),v.jsx(hh,{})]}):null}const uo={width:"100%"},Ts=i=>{const{inputId:t,state:e=!1,type:n="range",confirm:o,cancel:r,name:s,formulaOrRefString:l,comment:d="",localSheetId:c=so,hidden:u=!1,id:h}=i,f=Z.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),g=Z.useDependency(a.LocaleService),S=Z.useDependency(K.IDefinedNamesService),p=Z.useDependency(K.IFunctionService),R=Z.useDependency(K.LexerTreeBuilder);if(f==null)return;const M=f.getUnitId();f.getActiveSheet().getSheetId();const[T,b]=V.useState(s),[E,y]=V.useState(l),[O,x]=V.useState(d),[D,W]=V.useState(c),[A,H]=V.useState(""),[B,z]=V.useState(n),[X,Q]=V.useState(!0),J=[{label:g.t("definedName.scopeWorkbook"),value:so}],$=G=>!K.isReferenceStrings(G);V.useEffect(()=>{Q(!0),b(s),x(d),W(c);let G=l;l.substring(0,1)===K.operatorToken.EQUALS?z("formula"):$(l)?(z("formula"),G=K.operatorToken.EQUALS+l):z("range"),y(G),H("")},[e]),f.getSheetOrders().forEach(G=>{const te=f.getSheetBySheetId(G);J.push({label:(te==null?void 0:te.getName())||"",value:G})});const ee=G=>G.map(ne=>{var de;return K.serializeRangeToRefString({...ne,sheetName:((de=f.getSheetBySheetId(ne.sheetId))==null?void 0:de.getName())||""})}).join(","),L=G=>{y(ee(G))},U=G=>{y(G||"")},F=()=>{if(T.length===0){H(g.t("definedName.nameEmpty"));return}if(S.getValueByName(M,T)!=null&&(h==null||h.length===0)){H(g.t("definedName.nameDuplicate"));return}if(!a.Tools.isValidParameter(T)||K.isReferenceStringWithEffectiveColumn(T)||!a.Tools.isStartValidPosition(T)&&!w.hasCJKText(T.substring(0,1))){H(g.t("definedName.nameInvalid"));return}if(f.getSheetOrders().map(te=>{var ne;return((ne=f.getSheetBySheetId(te))==null?void 0:ne.getName())||""}).includes(T)){H(g.t("definedName.nameSheetConflict"));return}if(E.length===0){H(g.t("definedName.formulaOrRefStringEmpty"));return}if(!X){H(g.t("definedName.formulaOrRefStringInvalid"));return}if(p.hasExecutor(T.toUpperCase())){H(g.t("definedName.nameConflict"));return}o&&o({id:h||"",name:T,formulaOrRefString:R.convertRefersToAbsolute(E,a.AbsoluteRefType.ALL,a.AbsoluteRefType.ALL),comment:O,localSheetId:D})},Y=G=>{const te=G;te==="formula"&&E.substring(0,1)!==K.operatorToken.EQUALS?(y(`${K.operatorToken.EQUALS}`),y(`${K.operatorToken.EQUALS}`)):E.substring(0,1)===K.operatorToken.EQUALS&&(y(""),y("")),z(te)};return v.jsxs("div",{className:ae.definedNameInput,style:{display:e?"block":"none"},children:[v.jsx("div",{children:v.jsx(re.Input,{placeholder:g.t("definedName.inputNamePlaceholder"),value:T,allowClear:!0,onChange:b,affixWrapperStyle:uo})}),v.jsx("div",{children:v.jsxs(re.RadioGroup,{value:B,onChange:Y,children:[v.jsx(re.Radio,{value:"range",children:g.t("definedName.ratioRange")}),v.jsx(re.Radio,{value:"formula",children:g.t("definedName.ratioFormula")})]})}),v.jsx("div",{style:{display:B==="range"?"block":"none"},children:v.jsx(C.RangeSelector,{value:E,onValid:Q,onChange:L,placeholder:g.t("definedName.inputRangePlaceholder"),id:a.createInternalEditorID(`${t}-rangeSelector`),width:"99%",openForSheetUnitId:M},`${t}-rangeSelector`)}),v.jsx("div",{style:{display:B==="range"?"none":"block"},children:v.jsx(C.TextEditor,{value:E,onValid:Q,onChange:U,id:a.createInternalEditorID(`${t}-editor`),placeholder:g.t("definedName.inputFormulaPlaceholder"),openForSheetUnitId:M,onlyInputFormula:!0,style:{width:"99%"},canvasStyle:{fontSize:10}},`${t}-editor`)}),v.jsx("div",{children:v.jsx(re.Select,{style:uo,value:D,options:J,onChange:W})}),v.jsx("div",{children:v.jsx(re.Input,{affixWrapperStyle:uo,placeholder:g.t("definedName.inputCommentPlaceholder"),value:O,onChange:x})}),v.jsxs("div",{style:{display:A.length===0?"none":"flex"},className:ae.definedNameInputValidation,children:[v.jsx("span",{children:A}),v.jsx(os,{})]}),v.jsxs("div",{children:[v.jsx(re.Button,{onClick:()=>{r&&r()},children:g.t("definedName.cancel")}),v.jsx(re.Button,{style:{marginLeft:15},type:"primary",onClick:F,children:g.t("definedName.confirm")})]})]})},Nh=()=>{const i=Z.useDependency(a.ICommandService),e=Z.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=Z.useDependency(a.LocaleService),o=Z.useDependency(K.IDefinedNamesService),r=Z.useDependency(_.SelectionManagerService);if(e==null)return;const s=e.getUnitId(),l=()=>{const A=o.getDefinedNameMap(s);return A?Array.from(Object.values(A)):[]},[d,c]=V.useState(!1),[u,h]=V.useState(l()),[m,f]=V.useState(null),[g,S]=V.useState();V.useEffect(()=>{const A=o.update$.subscribe(()=>{h(l())});return()=>{A.unsubscribe()}},[]);const p=A=>{const{name:H,formulaOrRefString:B,comment:z,localSheetId:X,hidden:Q}=A;let J=A.id;if(J==null||J.length===0)J=a.Tools.generateRandomId(10),i.executeCommand(_.InsertDefinedNameCommand.id,{id:J,unitId:s,name:H,formulaOrRefString:B,comment:z,localSheetId:X,hidden:Q});else{const $=o.getValueById(s,J),ee={id:J,unitId:s,name:H,formulaOrRefString:B,comment:z,localSheetId:X,hidden:Q};i.executeCommand(_.SetDefinedNameCommand.id,{unitId:s,oldDefinedName:{...$,unitId:s},newDefinedName:ee})}c(!1),f(null)},R=A=>{S(A)};function M(){S(null)}function T(A){const H=o.getValueById(s,A);i.executeCommand(_.RemoveDefinedNameCommand.id,{...H,unitId:s}),S(null)}const b=A=>{o.focusRange(s,A.id)},E=()=>{const A=u.length+1,H=n.t("definedName.defaultName")+A;if(o.getValueByName(s,H)==null)return H;let B=A+1;for(;;){const z=n.t("definedName.defaultName")+B;if(o.getValueByName(s,z)==null)return z;B++}},y=()=>{const A=e.getActiveSheet().getName(),H=r.getSelections();return H==null?"":H.map(z=>K.serializeRangeWithSheet(A,z.range)).join(",")},O=()=>{c(!1),f(null)},x=()=>{c(!0),f(null)},D=A=>{c(!1),f(A)},W=A=>{const H=e.getSheetBySheetId(A);return H==null?"":H.getName()};return v.jsx("div",{className:ae.definedNameContainer,children:v.jsxs("div",{className:ae.definedNameContainerScroll,children:[v.jsxs("div",{children:[v.jsxs("div",{onClick:x,className:ae.definedNameContainerAddButton,style:{display:d?"none":"flex"},children:[v.jsx(ls,{}),v.jsx("span",{className:ae.definedNameContainerAddButtonText,children:n.t("definedName.addButton")})]}),v.jsx(Ts,{confirm:p,cancel:O,state:d,inputId:"insertDefinedName",name:E(),formulaOrRefString:y()})]},"insertDefinedName"),u.map((A,H)=>v.jsxs("div",{children:[v.jsxs("div",{onClick:()=>{b(A)},className:ae.definedNameContainerItem,style:{display:A.id===m?"none":"flex"},children:[v.jsxs("div",{title:A.comment,children:[v.jsxs("div",{className:ae.definedNameContainerItemName,children:[A.name,v.jsx("span",{className:ae.definedNameContainerItemNameForSheet,children:A.localSheetId===so||A.localSheetId==null?"":W(A.localSheetId)})]}),v.jsx("div",{className:ae.definedNameContainerItemFormulaOrRefString,children:A.formulaOrRefString})]}),v.jsx(re.Tooltip,{title:n.t("definedName.updateButton"),placement:"top",style:{pointerEvents:"none"},children:v.jsx("div",{className:Pe(ae.definedNameContainerItemUpdate,ae.definedNameContainerItemShow),onClick:()=>{D(A.id)},children:v.jsx(ln,{})})}),v.jsx(re.Tooltip,{title:n.t("definedName.deleteButton"),placement:"top",style:{pointerEvents:"none"},children:v.jsx("div",{className:Pe(ae.definedNameContainerItemDelete,ae.definedNameContainerItemShow),onClick:()=>{R(A.id)},children:v.jsx(Au,{})})})]}),v.jsx(re.Confirm,{visible:g===A.id,onClose:M,onConfirm:()=>{T(A.id)},children:n.t("definedName.deleteConfirmText")}),v.jsx(Ts,{confirm:p,cancel:O,state:A.id===m,id:A.id,inputId:A.id+H,name:A.name,formulaOrRefString:A.formulaOrRefString,comment:A.comment,localSheetId:A.localSheetId})]},H))]})})};function xh(i){const t=i.get(_.BorderStyleManagerService),e=_.getCurrentSheetDisabled$(i);return{id:_.SetBorderBasicCommand.id,icon:new k.Observable(n=>{const o="AllBorderSingle",r=i.get(_.BorderStyleManagerService),s=i.get(a.ICommandService).onCommandExecuted(l=>{var m;if(l.id!==_.SetBorderBasicCommand.id)return;const{type:c}=r.getBorderInfo(),u=ps.find(f=>f.value===c),h=(m=u==null?void 0:u.icon)!=null?m:o;n.next(h)});return n.next(o),s.dispose}),group:C.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[C.MenuPosition.TOOLBAR_START],type:C.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:_s,hoverable:!1},value$:t.borderInfo$}],value$:t.borderInfo$,hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:e}}const ni="sheet.menu.clear-selection";function Ah(){return{id:ni,group:C.MenuGroup.CONTEXT_MENU_FORMAT,type:C.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[C.MenuPosition.CONTEXT_MENU,le.COL_HEADER_CONTEXT_MENU,le.ROW_HEADER_CONTEXT_MENU]}}function Dh(){return{id:_.ClearSelectionContentCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[ni]}}function Ph(){return{id:_.ClearSelectionFormatCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[ni]}}function Hh(){return{id:_.ClearSelectionAllCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[ni]}}const cn="sheet.menu.delete";function Lh(){return{id:cn,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[C.MenuPosition.CONTEXT_MENU]}}function Uh(){return{id:Yr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[cn,le.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function Vh(){return{id:zr.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,icon:"DeleteRow",positions:[cn,le.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function Bh(){return{id:oo.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[cn]}}function kh(){return{id:Kn.id,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[cn]}}const ho="sheet.menu.col-insert";function Fh(){return{id:ho,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.COL_HEADER_CONTEXT_MENU]}}const mo="sheet.menu.row-insert";function Wh(){return{id:mo,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.ROW_HEADER_CONTEXT_MENU]}}const dn="sheet.menu.cell-insert";function jh(){return{id:dn,group:C.MenuGroup.CONTEXT_MENU_LAYOUT,type:C.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[C.MenuPosition.CONTEXT_MENU]}}function zh(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertRowBeforeCommand.id,type:C.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[mo,dn],hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Yh(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertRowAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[mo],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Xh(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertColBeforeCommand.id,type:C.MenuItemType.BUTTON,positions:[ho,dn],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function $h(i){const t=i.get(_.SelectionManagerService);return{id:_.InsertColAfterCommand.id,type:C.MenuItemType.BUTTON,positions:[ho],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new k.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Gh(){return{id:ro.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[dn]}}function Zh(){return{id:Qn.id,type:C.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[dn]}}function Kh(i){return i.get(_.SelectionManagerService).selectionMoveEnd$.pipe(k.filter(e=>e!=null&&e.length>=2),k.map(e=>{if(!e)return!1;for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++)if(a.Rectangle.intersects(e[n].range,e[o].range))return!0;return!1}))}function Qh(i){const t=_.getCurrentSheetDisabled$(i),e=Kh(i);return{id:Ke.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[C.MenuPosition.TOOLBAR_START],group:C.MenuGroup.TOOLBAR_LAYOUT,type:C.MenuItemType.SUBITEMS,hidden$:C.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:t.pipe(k.combineLatestWith(e),k.map(([n,o])=>n||o))}}function Jh(i){return{id:kr.id,type:C.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Ke.id]}}function qh(i){return{id:Fr.id,type:C.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Ke.id]}}function em(i){return{id:Wr.id,type:C.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Ke.id]}}function tm(i){return{id:_.RemoveWorksheetMergeCommand.id,type:C.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Ke.id]}}function nm(i){const t=i.get(a.IUniverInstanceService),e=i.get(a.ICommandService);return{id:Xr.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.delete",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),d=Array.from(l.values()).filter(c=>c.getConfig().hidden===a.BooleanNumber.FALSE);n.next(d.length===1)}});return n.next(!1),o.dispose})}}function im(){return{id:_.CopySheetCommand.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.copy"}}function om(){return{id:Gr.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.rename"}}function rm(){return{id:_.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[le.SHEET_BAR],type:C.MenuItemType.SELECTOR,selections:[{label:{name:En,hoverable:!1}}]}}function sm(i){const t=i.get(a.IUniverInstanceService),e=i.get(a.ICommandService);return{id:_.SetWorksheetHideCommand.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.hide",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),d=Array.from(l.values()).filter(c=>c.getConfig().hidden===a.BooleanNumber.FALSE);n.next(d.length===1)}});return n.next(!1),o.dispose})}}function am(i){const t=i.get(a.IUniverInstanceService),e=i.get(a.ICommandService);return{id:$r.id,type:C.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.unhide",disabled$:new k.Observable(n=>{const o=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const l=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),d=Array.from(l.values());n.next(d.length===1)}});return n.next(!1),o.dispose})}}const lm={id:_.SetRowHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit9|C.MetaKeys.CTRL_COMMAND},cm={id:_.SetColHiddenCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT},dm={id:we.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.DOWN}},um={id:we.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.UP}},hm={id:we.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT,priority:100,preconditions:Eo,staticParameters:{direction:a.Direction.LEFT}},mm={id:we.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT,priority:100,preconditions:Eo,staticParameters:{direction:a.Direction.RIGHT}},fm={id:ct.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:C.KeyCode.TAB,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT,keycode:C.KeyCode.TAB}},gm={id:ct.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:C.KeyCode.TAB|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.LEFT,keycode:C.KeyCode.TAB}},Sm={id:ct.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.DOWN,keycode:C.KeyCode.ENTER}},_m={id:ct.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:C.KeyCode.ENTER|C.MetaKeys.SHIFT,priority:100,preconditions:ie,staticParameters:{direction:a.Direction.UP,keycode:C.KeyCode.ENTER}},pm={id:we.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.DOWN,jumpOver:Fe.moveGap}},vm={id:we.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.UP,jumpOver:Fe.moveGap}},Cm={id:we.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.LEFT,jumpOver:Fe.moveGap}},Im={id:we.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Fe.moveGap}},Rm={id:He.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.DOWN}},Mm={id:He.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.UP}},bm={id:He.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.LEFT}},Tm={id:He.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT}},wm={id:He.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_DOWN|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.DOWN,jumpOver:Fe.moveGap}},Em={id:He.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_UP|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.UP,jumpOver:Fe.moveGap}},ym={id:He.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_LEFT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.LEFT,jumpOver:Fe.moveGap}},Om={id:He.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:C.KeyCode.ARROW_RIGHT|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Fe.moveGap}},Nm={id:Jo.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:C.KeyCode.A|C.MetaKeys.CTRL_COMMAND,preconditions:ie,staticParameters:{expandToGapFirst:!0,loop:!0}},xm={id:Hi.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.B|C.MetaKeys.CTRL_COMMAND},Am={id:Li.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.I|C.MetaKeys.CTRL_COMMAND},Dm={id:Ui.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.U|C.MetaKeys.CTRL_COMMAND},Pm={id:Vi.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>ie(i),binding:C.KeyCode.X|C.MetaKeys.SHIFT|C.MetaKeys.CTRL_COMMAND},Hm={id:_.ClearSelectionContentCommand.id,preconditions:i=>ie(i),binding:C.KeyCode.DELETE,mac:C.KeyCode.BACKSPACE},Lm={id:Vn.id,description:"shortcut.sheet.zoom-in",binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:.2}},Um={id:a.NilCommand.id,binding:C.KeyCode.EQUAL|C.MetaKeys.CTRL_COMMAND},Vm={id:Vn.id,description:"shortcut.sheet.zoom-out",binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ie,priority:1,staticParameters:{delta:-.2}},Bm={id:a.NilCommand.id,binding:C.KeyCode.MINUS|C.MetaKeys.CTRL_COMMAND},km={id:Vn.id,description:"shortcut.sheet.reset-zoom",binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND,preconditions:ie,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},Fm={id:a.NilCommand.id,binding:C.KeyCode.Digit0|C.MetaKeys.CTRL_COMMAND};var Wm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,zm=(i,t,e,n)=>{for(var o=n>1?void 0:n?jm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Wm(t,e,o),o},ft=(i,t)=>(e,n)=>t(e,n,i);let ii=class extends a.Disposable{constructor(i,t,e,n,o,r,s){super(),this._injector=i,this._componentManager=t,this._layoutService=e,this._commandService=n,this._shortcutService=o,this._menuService=r,this._uiController=s,this._init()}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(ji,Ql)),this.disposeWithMe(i.register(_s,th)),this.disposeWithMe(i.register(En,re.ColorPicker)),this.disposeWithMe(i.register(mr,C.FontFamily)),this.disposeWithMe(i.register(fr,C.FontFamilyItem)),this.disposeWithMe(i.register(gr,C.FontSize)),this.disposeWithMe(i.register(Is,Nh))}_initCommands(){[kr,Ke,Wr,Fr,Vn,He,we,ct,Gr,Xr,zr,Yr,tr,nr,dt,qo,Jo,Dr,_.SetBoldCommand,Zt,ye,xi,Hi,Li,Ui,Vi,Hl,Ll,ir,or,Tn,_.SetItalicCommand,_.SetStrikeThroughCommand,_.SetFontFamilyCommand,_.SetFontSizeCommand,Fi,lr,Wi,cr,ot,Kt,wn,dr,ur,hr,_.SetUnderlineCommand,Bn,Le,$r,jr,Qn,Kn,ro,oo,Rs].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[mc,fc,gc,Sc,_c,pc,vc,Dh,Ph,Hh,Ah,Fh,Wh,jh,zh,Yh,Xh,$h,Vh,Ec,Oc,yc,Nc,Uh,xc,Cc,Ac,Lh,Bh,kh,Gh,Zh,Mc,bc,Tc,wc,Ic,Rc,Jl,ql,ec,tc,nc,ic,oc,rc,sc,ac,lc,xh,Qh,Jh,qh,em,tm,cc,dc,uc,hc,nm,im,om,rm,sm,am].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[dm,um,hm,mm,fm,gm,Sm,_m,pm,vm,Cm,Im,Rm,Mm,bm,Tm,wm,Em,ym,Om,Nm,Lm,Vm,km,Fm,Um,Bm,xm,Am,Dm,Pm,Hm,...ed(),nd,td,id,rd,sd,ad,od,lm,cm].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){const i=this._uiController,t=this._injector;this.disposeWithMe(i.registerComponent(C.DesktopUIPart.HEADER,()=>Z.connectInjector(yh,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.FOOTER,()=>Z.connectInjector(Eh,t))),this.disposeWithMe(i.registerComponent(C.DesktopUIPart.CONTENT,()=>Z.connectInjector(Oh,t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_SHEET,i=>{this._injector.get(w.ITextSelectionRenderManager).focus()}))}};ii=zm([a.OnLifecycle(a.LifecycleStages.Ready,ii),ft(0,P.Inject(P.Injector)),ft(1,P.Inject(C.ComponentManager)),ft(2,C.ILayoutService),ft(3,a.ICommandService),ft(4,C.IShortcutService),ft(5,C.IMenuService),ft(6,C.IUIController)],ii);var Ym=Object.defineProperty,Xm=Object.getOwnPropertyDescriptor,$m=(i,t,e,n)=>{for(var o=n>1?void 0:n?Xm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Ym(t,e,o),o},gt=(i,t)=>(e,n)=>t(e,n,i);let oi=class extends a.Disposable{constructor(t,e,n,o,r,s,l){super();I(this,"_calculateTimeout",-1);this._univerInstanceService=t,this._selectionManagerService=e,this._functionService=n,this._statusBarService=o,this._commandService=r,this._formulaDataModel=s,this._numfmtService=l,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){const t=a.debounce(e=>{var o;const n=(o=e[e.length-1])==null?void 0:o.primary;this._calculateSelection(e.map(r=>r.range),n)},100);this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(a.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===_.SetRangeValuesMutation.id){const n=this._selectionManagerService.getSelections();n&&t(n)}}))}_calculateSelection(t,e){var d;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=n.getUnitId(),r=n.getActiveSheet().getSheetId(),s={},l=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(c=>{const u=c.getConfig();s[c.getSheetId()]={cellData:new a.ObjectMatrix(u.cellData),rowCount:u.rowCount,columnCount:u.columnCount,rowData:u.rowData,columnData:u.columnData}}),t!=null&&t.length){const c=t.map(p=>new K.RangeReferenceObject(p,r,o));c.forEach(p=>{p.setUnitData({[o]:s}),l&&p.setArrayFormulaCellData(K.convertUnitDataToRuntime(l))});const u=this._statusBarService.getFunctions(),h=c.map(p=>p.toArrayValueObject(!1)),m=u.map(p=>{const R=this._functionService.getExecutor(p.func);if(!R)return;const M=R==null?void 0:R.calculate(...h),T=M==null?void 0:M.getValue();if(T)return{func:p.func,value:T}});if(m.every(p=>p===void 0))return;let f=null;if(e){const{actualRow:p,actualColumn:R}=e;f=(d=this._numfmtService.getValue(o,r,p,R))==null?void 0:d.pattern}const S={values:m.filter(p=>p!==void 0),pattern:f};this._statusBarService.setState(S)}else this._statusBarService.setState(null)}_isSingleCell(t){return t.startRow===t.endRow&&t.startColumn===t.endColumn}};oi=$m([a.OnLifecycle(a.LifecycleStages.Ready,oi),gt(0,a.IUniverInstanceService),gt(1,P.Inject(_.SelectionManagerService)),gt(2,K.IFunctionService),gt(3,ao),gt(4,a.ICommandService),gt(5,P.Inject(K.FormulaDataModel)),gt(6,P.Inject(_.INumfmtService))],oi);var Gm=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,Km=(i,t,e,n)=>{for(var o=n>1?void 0:n?Zm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Gm(t,e,o),o},St=(i,t)=>(e,n)=>t(e,n,i);let ri=class extends a.Disposable{constructor(i,t,e,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._univerInstanceService=t,this._commandService=e,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;i!=null&&(i.getViewport(j.VIEW_MAIN),this.disposeWithMe(a.toDisposable(i.onMouseWheelObserver.add((e,n)=>{if(!e.ctrlKey)return;const o=Math.abs(e.deltaX);let r=o<40?.2:o<80?.4:.2;r*=e.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),d=l.getZoomRatio();let c=+Number.parseFloat(`${d+r}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(Bn.id,{zoomRatio:Math.round(c*10)/10,unitId:s.getUnitId(),subUnitId:l.getSheetId()}),e.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const i=[Le.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),o=t.params,{unitId:r,subUnitId:s}=o;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;const l=n.getConfig().zoomRatio||1;this._updateViewZoom(l)}}))}_updateViewZoom(i){const t=this._getSheetObject();t==null||t.scene.scale(i,i),t==null||t.spreadsheet.makeForceDirty()}_getSheetObject(){return Me(this._univerInstanceService,this._renderManagerService)}};ri=Km([a.OnLifecycle(a.LifecycleStages.Rendered,ri),St(0,P.Inject(N.SheetSkeletonManagerService)),St(1,a.IUniverInstanceService),St(2,a.ICommandService),St(3,w.IRenderManagerService),St(4,Ie),St(5,P.Inject(_.SelectionManagerService)),St(6,P.Inject($e))],ri);var Qm=Object.defineProperty,Jm=Object.getOwnPropertyDescriptor,qm=(i,t,e,n)=>{for(var o=n>1?void 0:n?Jm(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&Qm(t,e,o),o},si=(i,t)=>(e,n)=>t(e,n,i);N.SheetCanvasView=class extends a.RxDisposable{constructor(e,n,o,r){super();I(this,"_scene");I(this,"_fps$",new k.BehaviorSubject(""));I(this,"fps$",this._fps$.asObservable());this._univerInstanceService=e,this._commandService=n,this._renderManagerService=o,this._sheetSkeletonManagerService=r,this._initialize()}_initialize(){this._init()}dispose(){this._fps$.complete()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(e=>this._create(e)),this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(e=>this._dispose(e)),this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._create(e))}_dispose(e){const n=e.getUnitId();this._renderManagerService.removeRender(n)}_create(e){if(!e)return;const n=e.getUnitId();this._renderManagerService.has(n)||this._addNewRender(e)}_addNewRender(e){const n=e.getUnitId(),o=e.getContainer(),r=e.getParentRenderUnitId();if(o!=null&&r!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=o==null&&r!=null;s?this._renderManagerService.createRenderWithParent(n,r):this._renderManagerService.createRender(n);const l=this._renderManagerService.getRenderById(n);if(l==null)return;const{scene:d,engine:c}=l;d.openTransformer(),this._scene=d,d.addLayer(new w.Layer(d,[],0),new w.Layer(d,[],2)),l!=null&&this._addComponent(l,e),e.getShouldRenderLoopImmediately()&&!s&&c.runRenderLoop(()=>{d.render(),this._fps$.next(Math.round(c.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(e,n){const o=this._scene,r=n.getActiveSheet(),s=n.getUnitId(),l=r.getSheetId();this._addViewport(r);const d=new w.Spreadsheet(me.MAIN),c=new w.SpreadsheetRowHeader(me.ROW),u=new w.SpreadsheetColumnHeader(me.COLUMN),h=new w.Rect(me.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});e.mainComponent=d,e.components.set(me.MAIN,d),e.components.set(me.ROW,c),e.components.set(me.COLUMN,u),e.components.set(me.LEFT_TOP,h),o.addObjects([d],Oo),o.addObjects([c,u,h],tt),o.enableLayerCache(Oo,tt),this._sheetSkeletonManagerService.setCurrent({sheetId:l,unitId:s})}_addViewport(e){const n=this._scene;if(n==null)return;const{rowHeader:o,columnHeader:r}=e.getConfig(),s=new w.Viewport(j.VIEW_MAIN,n,{left:o.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new w.Viewport(j.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new w.Viewport(j.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:o.width,isWheelPreventDefaultX:!0}),new w.Viewport(j.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new w.Viewport(j.VIEW_COLUMN_RIGHT,n,{left:o.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),new w.Viewport(j.VIEW_LEFT_TOP,n,{left:0,top:0,width:o.width,height:r.height,isWheelPreventDefaultX:!0}),new w.Viewport(j.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new w.Viewport(j.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new w.Viewport(j.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),this.disposeWithMe(a.toDisposable(n.onMouseWheelObserver.add((l,d)=>{if(l.ctrlKey)return;let c=0,u=0;const h=s.limitedScroll();if(l.inputIndex===w.PointerInput.MouseWheelX){const f=Math.abs(l.deltaX);l.deltaX>0?c=f:c=-f,this._commandService.executeCommand(Kt.id,{offsetX:c}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||d.stopPropagation():s.isWheelPreventDefaultX?l.preventDefault():h!=null&&h.isLimitedX||l.preventDefault()}if(l.inputIndex===w.PointerInput.MouseWheelY){let f=Math.abs(l.deltaY);l.shiftKey?(f*=3,l.deltaY>0?c=f:c=-f,this._commandService.executeCommand(Kt.id,{offsetX:c}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||d.stopPropagation():s.isWheelPreventDefaultX?l.preventDefault():h!=null&&h.isLimitedX||l.preventDefault()):(l.deltaY>0?u=f:u=-f,this._commandService.executeCommand(Kt.id,{offsetY:u}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||d.stopPropagation():s.isWheelPreventDefaultY?l.preventDefault():h!=null&&h.isLimitedY||l.preventDefault())}l.inputIndex,w.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}))),new w.ScrollBar(s),n.attachControl(),s}},N.SheetCanvasView=qm([a.OnLifecycle(a.LifecycleStages.Ready,N.SheetCanvasView),si(0,a.IUniverInstanceService),si(1,a.ICommandService),si(2,w.IRenderManagerService),si(3,P.Inject(N.SheetSkeletonManagerService))],N.SheetCanvasView);var ef=Object.defineProperty,tf=Object.getOwnPropertyDescriptor,nf=(i,t,e,n)=>{for(var o=n>1?void 0:n?tf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ef(t,e,o),o},ai=(i,t)=>(e,n)=>t(e,n,i);N.HoverManagerService=class extends a.Disposable{constructor(e,n,o,r){super();I(this,"_currentCell$",new k.Subject);I(this,"currentCell$",this._currentCell$.asObservable().pipe(k.distinctUntilChanged((e,n)=>{var o,r,s,l,d,c,u,h;return((o=e==null?void 0:e.location)==null?void 0:o.unitId)===((r=n==null?void 0:n.location)==null?void 0:r.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((l=n==null?void 0:n.location)==null?void 0:l.subUnitId)&&((d=e==null?void 0:e.location)==null?void 0:d.row)===((c=n==null?void 0:n.location)==null?void 0:c.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=n==null?void 0:n.location)==null?void 0:h.col)})));I(this,"_lastPosition",null);this._univerInstanceService=e,this._scrollManagerService=n,this._sheetSkeletonManagerService=o,this._renderManagerService=r,this._initCellDisposableListener()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)}))}_calcActiveCell(){if(!this._lastPosition)return;const{offsetX:e,offsetY:n}=this._lastPosition,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o){this._currentCell$.next(null);return}const r=o.getActiveSheet(),s=this._sheetSkeletonManagerService.getCurrent(),l=this._renderManagerService.getRenderById(o.getUnitId()),d=this._scrollManagerService.getCurrentScroll();if(!s||!d||!l)return;const{scene:c}=l,{skeleton:u,sheetId:h,unitId:m}=s,f=Bl(e,n,c,u);if(!f){this._currentCell$.next(null);return}const{row:g,col:S,mergeCell:p,actualCol:R,actualRow:M}=f,T={unitId:m,subUnitId:h,workbook:o,worksheet:r,row:M,col:R};let b;p?b=p:b={startRow:g,endRow:g,startColumn:S,endColumn:S};const E=c.getActiveViewportByCoord(w.Vector2.FromArray([e,n]));if(!E)return;const{scaleX:y,scaleY:O}=c.getAncestorScale(),x={x:E.actualScrollX,y:E.actualScrollY},D={startX:(u.getOffsetByPositionX(b.startColumn-1)-x.x)*y,endX:(u.getOffsetByPositionX(b.endColumn)-x.x)*y,startY:(u.getOffsetByPositionY(b.startRow-1)-x.y)*O,endY:(u.getOffsetByPositionY(b.endRow)-x.y)*O};this._currentCell$.next({location:T,position:D})}onMouseMove(e,n){this._lastPosition={offsetX:e,offsetY:n},this._calcActiveCell()}onScrollStart(){this._currentCell$.next(null)}onScrollEnd(){this._calcActiveCell()}},N.HoverManagerService=nf([ai(0,a.IUniverInstanceService),ai(1,P.Inject($e)),ai(2,P.Inject(N.SheetSkeletonManagerService)),ai(3,w.IRenderManagerService)],N.HoverManagerService);var of=Object.defineProperty,rf=Object.getOwnPropertyDescriptor,sf=(i,t,e,n)=>{for(var o=n>1?void 0:n?rf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&of(t,e,o),o},fo=(i,t)=>(e,n)=>t(e,n,i);N.HoverController=class extends a.Disposable{constructor(t,e,n){super(),this._renderManagerService=t,this._hoverManagerService=e,this._univerInstanceService=n,this._initPointerEvent()}_initScrollEvent(){}_initPointerEvent(){const t=this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId());if(!t)return;const{scene:e}=t,n=e.onPointerMoveObserver.add(o=>{this._hoverManagerService.onMouseMove(o.offsetX,o.offsetY)});this.disposeWithMe({dispose(){e.onPointerMoveObserver.remove(n)}})}},N.HoverController=sf([a.OnLifecycle(a.LifecycleStages.Rendered,N.HoverController),fo(0,w.IRenderManagerService),fo(1,P.Inject(N.HoverManagerService)),fo(2,a.IUniverInstanceService)],N.HoverController);const Qe={cellAlert:"univer-cell-alert",cellAlertTitle:"univer-cell-alert-title",cellAlertIcon:"univer-cell-alert-icon",cellAlertIconError:"univer-cell-alert-icon-error",cellAlertIconInfo:"univer-cell-alert-icon-info",cellAlertIconWarning:"univer-cell-alert-icon-warning",cellAlertContent:"univer-cell-alert-content"};function af({popup:i}){var s;const t=(s=i.extraProps)==null?void 0:s.alert;if(!t)return null;const{type:e,title:n,message:o}=t,r={[Lt.ERROR]:v.jsx(os,{className:Pe(Qe.cellAlertIcon,Qe.cellAlertIconError)}),[Lt.INFO]:v.jsx(fs,{className:Pe(Qe.cellAlertIcon,Qe.cellAlertIconInfo)}),[Lt.WARNING]:v.jsx(fs,{className:Pe(Qe.cellAlertIcon,Qe.cellAlertIconWarning)})};return v.jsxs("div",{className:Qe.cellAlert,children:[v.jsxs("div",{className:Qe.cellAlertTitle,children:[e?r[e]:null,n]}),v.jsx("div",{className:Qe.cellAlertContent,children:o})]})}const ws="univer.sheet.cell-alert";var lf=Object.defineProperty,cf=Object.getOwnPropertyDescriptor,df=(i,t,e,n)=>{for(var o=n>1?void 0:n?cf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&lf(t,e,o),o},Ht=(i,t)=>(e,n)=>t(e,n,i);N.SheetCanvasPopManagerService=class extends a.Disposable{constructor(t,e,n,o,r,s){super(),this._globalPopupManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._refRangeService=r,this._commandService=s}_calcCellPosition(t,e,n,o,r){const{scene:s,engine:l}=n,d=o.getCellByIndex(t,e),c=d.isMergedMainCell?d.mergeInfo:d,{scaleX:u,scaleY:h}=s.getAncestorScale(),m={x:r.actualScrollX,y:r.actualScrollY},f=l.getCanvasElement().getBoundingClientRect();return{left:(c.startX-m.x)*u+f.left,right:(c.endX-m.x)*u+f.left,top:(c.startY-m.y)*h+f.top,bottom:(c.endY-m.y)*h+f.top}}_createCellPositionObserver(t,e,n,o,r){let s=t,l=e;const d=this._calcCellPosition(s,l,n,o,r),c=new k.BehaviorSubject(d),u=()=>c.next(this._calcCellPosition(s,l,n,o,r)),h=new a.DisposableCollection;return h.add(this._commandService.onCommandExecuted(f=>{if(f.id===_.SetWorksheetRowAutoHeightMutation.id&&f.params.rowsAutoHeightInfo.findIndex(S=>S.row===s)>-1){u();return}(_.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(f.id)>-1||f.id===ot.id||f.id===Le.id)&&u()})),{position$:c,disposable:h,position:d,updateRowCol:(f,g)=>{s=f,l=g,u()}}}_createObjectPositionObserver(t,e,n,o){const r=()=>{const{scene:c}=e,{left:u,top:h,width:m,height:f}=t,g={left:u,right:u+m,top:h,bottom:h+f},S=Fl(g,c,n,o),p=e.engine.getCanvasElement().getBoundingClientRect();return{left:S.left,right:S.right,top:S.top+p.top,bottom:S.bottom+p.top}},s=r(),l=new k.BehaviorSubject(s),d=new a.DisposableCollection;return d.add(this._commandService.onCommandExecuted(c=>{(c.id===ot.id||c.id===Le.id)&&l.next(r())})),{position:s,position$:l,disposable:d}}attachPopupToObject(t,e){const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=n.getActiveSheet(),r=n.getUnitId(),s=o.getSheetId(),l=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:r,sheetId:s}),d=this._renderManagerService.getRenderById(r);if(!d||!l)return{dispose:()=>{}};const{position:c,position$:u,disposable:h}=this._createObjectPositionObserver(t,d,l,o),m=this._globalPopupManagerService.addPopup({...e,unitId:r,subUnitId:s,anchorRect:c,anchorRect$:u});return{dispose:()=>{this._globalPopupManagerService.removePopup(m),u.complete(),h.dispose()}}}attachPopupToCell(t,e,n,o){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),l=r.getUnitId(),d=s.getSheetId(),c=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:l,sheetId:d}),u=this._renderManagerService.getRenderById(l);if(!u||!c)return null;const h=o!=null?o:kl(t,e,u.scene,s);if(!h)return null;const{position:m,position$:f,disposable:g,updateRowCol:S}=this._createCellPositionObserver(t,e,u,c,h),p=this._globalPopupManagerService.addPopup({...n,unitId:l,subUnitId:d,anchorRect:m,anchorRect$:f}),R=new a.DisposableCollection;R.add(g),R.add(a.toDisposable(()=>{this._globalPopupManagerService.removePopup(p),f.complete()}));const M={startRow:t,endRow:t,startColumn:e,endColumn:e};return R.add(this._refRangeService.watchRange(l,d,M,(T,b)=>{b?S(b.startRow,b.startColumn):R.dispose()})),R}},N.SheetCanvasPopManagerService=df([Ht(0,P.Inject(C.ICanvasPopupService)),Ht(1,w.IRenderManagerService),Ht(2,a.IUniverInstanceService),Ht(3,P.Inject(N.SheetSkeletonManagerService)),Ht(4,P.Inject(_.RefRangeService)),Ht(5,a.ICommandService)],N.SheetCanvasPopManagerService);var uf=Object.defineProperty,hf=Object.getOwnPropertyDescriptor,mf=(i,t,e,n)=>{for(var o=n>1?void 0:n?hf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&uf(t,e,o),o},Es=(i,t)=>(e,n)=>t(e,n,i),Lt=(i=>(i[i.INFO=0]="INFO",i[i.WARNING=1]="WARNING",i[i.ERROR=2]="ERROR",i))(Lt||{});N.CellAlertManagerService=class{constructor(t,e){I(this,"_currentAlert$",new k.Subject);I(this,"_currentAlert",new Map);I(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=t,this._canvasPopManagerService=e}get currentAlert(){return this._currentAlert}showAlert(t){let e=this._currentAlert.get(t.key);e&&e.dispose.dispose(),e?e.dispose.dispose():(e={alert:t,dispose:{dispose(){}}},this._currentAlert.set(t.key,e));const{location:n}=t,{row:o,col:r,unitId:s}=n;if(!this._renderManagerService.getRenderById(s))return;const d=this._canvasPopManagerService.attachPopupToCell(o,r,{componentKey:ws,direction:"horizontal",offset:[2,0],extraProps:{alert:t}});d&&(e.dispose=d),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}removeAlert(t){const e=this._currentAlert.get(t);e&&(this._currentAlert.delete(t),e==null||e.dispose.dispose(),this._currentAlert$.next(Array.from(this._currentAlert.entries())))}clearAlert(){this._currentAlert.forEach(t=>{t.dispose.dispose()}),this._currentAlert.clear(),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}},N.CellAlertManagerService=mf([Es(0,w.IRenderManagerService),Es(1,P.Inject(N.SheetCanvasPopManagerService))],N.CellAlertManagerService);var ff=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,Sf=(i,t,e,n)=>{for(var o=n>1?void 0:n?gf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&ff(t,e,o),o},_f=(i,t)=>(e,n)=>t(e,n,i);let li=class extends a.Disposable{constructor(i){super(),this._componentManager=i,this._initComponent()}_initComponent(){this._componentManager.register(ws,af)}};li=Sf([a.OnLifecycle(a.LifecycleStages.Starting,li),_f(0,P.Inject(C.ComponentManager))],li);var pf=Object.defineProperty,vf=Object.getOwnPropertyDescriptor,Cf=(i,t,e,n)=>{for(var o=n>1?void 0:n?vf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&pf(t,e,o),o},ys=(i,t)=>(e,n)=>t(e,n,i);let ci=class extends a.RxDisposable{constructor(i,t){super(),this._sheetSkeletonManagerService=i,this._sheetInterceptorService=t,this._init()}_init(){this._initViewModelIntercept()}_initViewModelIntercept(){const i={tl:{size:6,color:"#409f11"}};this.disposeWithMe(this._sheetInterceptorService.intercept(_.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,e,n)=>{var s;if(!((s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton))return n(t);const r=e.worksheet.getCellRaw(e.row,e.col);return!r||r.v===null||r.v===void 0?n(t):(t==null?void 0:t.t)===a.CellValueType.FORCE_STRING&&a.isRealNum(r.v)?n({...t,markers:{...t==null?void 0:t.markers,...i}}):n(t)}}))}};ci=Cf([a.OnLifecycle(a.LifecycleStages.Rendered,ci),ys(0,P.Inject(N.SheetSkeletonManagerService)),ys(1,P.Inject(_.SheetInterceptorService))],ci);var If=Object.defineProperty,Rf=Object.getOwnPropertyDescriptor,Mf=(i,t,e,n)=>{for(var o=n>1?void 0:n?Rf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&If(t,e,o),o},di=(i,t)=>(e,n)=>t(e,n,i);const go="SHEET_FORCE_STRING_ALERT";let ui=class extends a.Disposable{constructor(i,t,e,n){super(),this._hoverManagerService=i,this._cellAlertManagerService=t,this._univerInstanceService=e,this._localeService=n,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(i=>{var t;if(i){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCell(i.location.row,i.location.col);if((o==null?void 0:o.t)===a.CellValueType.FORCE_STRING&&o.v&&a.isRealNum(o.v)){const r=this._cellAlertManagerService.currentAlert.get(go),s=(t=r==null?void 0:r.alert)==null?void 0:t.location;if(s&&s.row===i.location.row&&s.col===i.location.col&&s.subUnitId===i.location.subUnitId&&s.unitId===i.location.unitId)return;this._cellAlertManagerService.showAlert({type:Lt.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:i.location,width:200,height:74,key:go});return}}this._cellAlertManagerService.removeAlert(go)}))}};ui=Mf([a.OnLifecycle(a.LifecycleStages.Rendered,ui),di(0,P.Inject(N.HoverManagerService)),di(1,P.Inject(N.CellAlertManagerService)),di(2,a.IUniverInstanceService),di(3,P.Inject(a.LocaleService))],ui);var bf=Object.defineProperty,Tf=Object.getOwnPropertyDescriptor,wf=(i,t,e,n)=>{for(var o=n>1?void 0:n?Tf(t,e):t,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(t,e,o):s(o))||o);return n&&o&&bf(t,e,o),o},hi=(i,t)=>(e,n)=>t(e,n,i);N.UniverSheetsUIPlugin=(fi=class extends a.Plugin{constructor(t,e,n,o,r){super(),this._injector=e,this._localeService=n,this._renderManagerService=o,this._univerInstanceService=r,this._localeService.load({zhCN:Rr})}onStarting(t){[[N.SheetCanvasView],[$t],[Ee,{useClass:N.EditorBridgeService}],[It,{useClass:N.SheetClipboardService}],[At,{useClass:vu}],[wt,{useClass:ki}],[tn,{useClass:Mr}],[On,{useClass:Pc}],[Jt,{useClass:N.AutoFillService}],[$e],[N.SheetSkeletonManagerService],[Ie,{useClass:N.SelectionRenderService}],[ao,{useClass:Rh}],[Wt,{useClass:N.MarkSelectionService}],[N.HoverManagerService],[N.SheetCanvasPopManagerService],[N.CellAlertManagerService],[Nn],[xn],[kn],[Hn],[Ln],[Fn],[Wn],[zn],[Yn],[Xn],[Gn],[N.ScrollController],[Zn],[An],[Dn],[N.SheetRenderController],[ii],[Un],[ri],[N.AutoFillController],[oi],[Pn],[$n],[N.HoverController],[li],[N.CellCustomRenderController],[ci],[ui]].forEach(e=>t.add(e))}onReady(){this._markSheetAsFocused(),this._registerRenderControllers()}_registerRenderControllers(){[Wn,to,Xn].forEach(t=>{this.disposeWithMe(this._renderManagerService.registerRenderControllers(a.UniverInstanceType.UNIVER_SHEET,t))})}_markSheetAsFocused(){const t=this._univerInstanceService;t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(Ps.filter(e=>!!e)).subscribe(e=>{t.focusUnit(e.getUnitId())})}},I(fi,"pluginName","SHEET_UI_PLUGIN_NAME"),I(fi,"type",a.UniverInstanceType.UNIVER_SHEET),fi),N.UniverSheetsUIPlugin=wf([hi(1,P.Inject(P.Injector)),hi(2,P.Inject(a.LocaleService)),hi(3,w.IRenderManagerService),hi(4,a.IUniverInstanceService)],N.UniverSheetsUIPlugin),N.APPLY_TYPE=oe,N.AutoFillCommand=wo,N.COPY_TYPE=nt,N.CellAlertType=Lt,N.CellEditorManagerService=Mr,N.DATA_TYPE=ce,N.ExpandSelectionCommand=He,N.IAutoFillService=Jt,N.ICellEditorManagerService=tn,N.IEditorBridgeService=Ee,N.IFormulaEditorManagerService=On,N.IMarkSelectionService=Wt,N.ISelectionRenderService=Ie,N.ISheetClipboardService=It,N.JumpOver=Fe,N.MoveSelectionCommand=we,N.PASTE_SPECIAL_MENU_ID=Ot,N.PREDEFINED_HOOK_NAME=Se,N.ResetScrollCommand=dl,N.SHEET_UI_PLUGIN_NAME=Hs,N.SHEET_VIEW_KEY=me,N.ScrollCommand=dt,N.ScrollToCellCommand=qo,N.SelectionShape=In,N.SetCellEditVisibleArrowOperation=Zt,N.SetCellEditVisibleOperation=ye,N.SetScrollOperation=ot,N.SetScrollRelativeCommand=Kt,N.SetZoomRatioOperation=Le,N.SheetCopyCommand=Fo,N.SheetPasteCommand=Rt,N.VIEWPORT_KEY=j,N.deriveStateFromActiveSheet$=_e,N.enUS=Dc,N.expandToContinuousRange=$o,N.getAutoFillRepeatRange=Zs,N.getCoordByCell=Ai,N.getCoordByOffset=Mt,N.getEditorObject=_n,N.getRepeatRange=La,N.getSheetObject=Me,N.getTransformCoord=bn,N.mergeSetRangeValues=bi,N.rangeToDiscreteRange=vt,N.virtualizeDiscreteRanges=jt,N.whenFormulaEditorActivated=qs,N.whenSheetEditorFocused=ie,N.zhCN=Rr,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|