@univerjs/sheets-numfmt 0.1.2 → 0.1.4

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/index.css CHANGED
@@ -1 +1 @@
1
- .numfmt-panel{overflow-y:auto;display:flex;flex-direction:column;justify-content:space-between;height:100%}.numfmt-panel .group-title{font-size:16px;color:rgba(var(--color-black))}.numfmt-panel .label{font-size:15px;color:rgba(var(--grey-400))}.numfmt-panel .describe{font-size:13px;line-height:20px;color:rgba(var(--grey-600))}.numfmt-panel .preview{height:36px;padding:0 16px;font-size:14px;line-height:36px;color:var(--color-black);border:1px solid rgb(var(--grey-200));border-radius:4px}.numfmt-panel .btn-list{display:flex;justify-content:end}.numfmt-panel .m-r-12{margin-right:12px}.numfmt-panel .m-t-16{margin-top:16px}.numfmt-panel .m-t-14{margin-top:14px}.numfmt-panel .m-t-8{margin-top:8px}.numfmt-panel .m-b-20{margin-bottom:20px}.options{display:flex;justify-content:space-between}.options .w-140{width:140px}.options .w-120{width:120px}.more-numfmt-type{display:flex;flex-shrink:0;padding:0 4px;font-size:13px;color:var(--black)}.more-numfmt-type .icon{display:flex;align-items:center;height:auto;padding-left:8px;font-size:10px;color:rgb(var(--grey-400))}.more-numfmt-type-options .line{width:100%;height:1px;background-color:rgb(var(--grey-200))}.more-numfmt-type-options .m-t-4{margin-top:4px}.more-numfmt-type-options .option-item{display:flex;align-items:center;justify-content:space-between;height:28px;padding:0 8px;font-size:13px}.more-numfmt-type-options .option-item:hover{background-color:rgb(var(--grey-100));border-radius:var(--border-radius-base)}.more-numfmt-type-options .m-l-26{margin-left:26px}
1
+ .numfmt-panel{overflow-y:auto;display:flex;flex-direction:column;justify-content:space-between;height:100%}.numfmt-panel .group-title{font-size:16px;color:rgba(var(--color-black))}.numfmt-panel .label{font-size:15px;color:rgba(var(--grey-400))}.numfmt-panel .describe{font-size:13px;line-height:20px;color:rgba(var(--grey-600))}.numfmt-panel .preview{height:36px;padding:0 16px;font-size:14px;line-height:36px;color:var(--color-black);border:1px solid rgb(var(--grey-200));border-radius:4px}.numfmt-panel .btn-list{display:flex;justify-content:flex-end}.numfmt-panel .m-r-12{margin-right:12px}.numfmt-panel .m-t-16{margin-top:16px}.numfmt-panel .m-t-14{margin-top:14px}.numfmt-panel .m-t-8{margin-top:8px}.numfmt-panel .m-b-20{margin-bottom:20px}.options{display:flex;justify-content:space-between}.options .w-140{width:140px}.options .w-120{width:120px}.more-numfmt-type{display:flex;flex-shrink:0;padding:0 4px;font-size:13px;color:var(--black)}.more-numfmt-type .icon{display:flex;align-items:center;height:auto;padding-left:8px;font-size:10px;color:rgb(var(--grey-400))}.more-numfmt-type-options .line{width:100%;height:1px;background-color:rgb(var(--grey-200))}.more-numfmt-type-options .m-t-4{margin-top:4px}.more-numfmt-type-options .option-item{display:flex;align-items:center;justify-content:space-between;height:28px;padding:0 8px;font-size:13px}.more-numfmt-type-options .option-item:hover{background-color:rgb(var(--grey-100));border-radius:var(--border-radius-base)}.more-numfmt-type-options .m-l-26{margin-left:26px}
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Disposable, ICommandService, ThemeService } from '@univerjs/core';
16
+ import { Disposable, ICommandService, LocaleService, ThemeService } from '@univerjs/core';
17
17
  import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
18
18
  import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
19
19
  export declare class NumfmtCellContent extends Disposable {
@@ -22,6 +22,7 @@ export declare class NumfmtCellContent extends Disposable {
22
22
  private _sheetSkeletonManagerService;
23
23
  private _commandService;
24
24
  private _numfmtService;
25
- constructor(_sheetInterceptorService: SheetInterceptorService, _themeService: ThemeService, _sheetSkeletonManagerService: SheetSkeletonManagerService, _commandService: ICommandService, _numfmtService: INumfmtService);
25
+ private _localeService;
26
+ constructor(_sheetInterceptorService: SheetInterceptorService, _themeService: ThemeService, _sheetSkeletonManagerService: SheetSkeletonManagerService, _commandService: ICommandService, _numfmtService: INumfmtService, _localeService: LocaleService);
26
27
  private _initInterceptorCellContent;
27
28
  }
@@ -16,6 +16,7 @@
16
16
  declare const locale: {
17
17
  sheet: {
18
18
  numfmt: {
19
+ percent: string;
19
20
  title: string;
20
21
  numfmtType: string;
21
22
  cancel: string;
@@ -14,8 +14,9 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { FormatType } from '@univerjs/sheets';
17
+ import { LocaleType } from '@univerjs/core';
17
18
  export declare const getPatternType: (pattern: string) => FormatType;
18
- export declare const getPatternPreview: (pattern: string, value: number) => {
19
+ export declare const getPatternPreview: (pattern: string, value: number, _locale?: LocaleType) => {
19
20
  result: string;
20
21
  color: string;
21
22
  } | {
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(R,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/engine-numfmt"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-ui","rxjs/operators","@univerjs/engine-numfmt","@univerjs/engine-render","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings","@univerjs/engine-formula"],c):(R=typeof globalThis<"u"?globalThis:R||self,c(R.UniverSheetsNumfmt={},R.UniverCore,R.UniverSheets,R["@wendellhu/redi"],R.UniverSheetsUi,R.rxjs.operators,R.UniverEngineNumfmt,R.UniverEngineRender,R.UniverUi,R.rxjs,R.React,R.UniverDesign,R["@wendellhu/redi/react-bindings"],R.UniverEngineFormula))})(this,function(R,c,u,S,O,P,L,be,M,x,I,U,w,ze){"use strict";var bn=Object.defineProperty;var Mn=(R,c,u)=>c in R?bn(R,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):R[c]=u;var B=(R,c,u)=>(Mn(R,typeof c!="symbol"?c+"":c,u),u);var Re;const V={id:"sheet.command.numfmt.set.numfmt",type:c.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const r=e.get(c.ICommandService),n=e.get(c.IUniverInstanceService),a=e.get(c.IUndoRedoService),s=n.getCurrentUniverSheetInstance(),i=s.getUnitId(),l=s.getActiveSheet().getSheetId(),f=t.values.filter(g=>!!g.pattern),m=t.values.filter(g=>!g.pattern),d=u.transformCellsToRange(i,l,f),v={unitId:i,subUnitId:l,ranges:m.map(g=>({startColumn:g.col,startRow:g.row,endColumn:g.col,endRow:g.row}))},h=[],C=[];if(f.length){Object.keys(d.values).forEach(y=>{const b=d.values[y];b.ranges=u.rangeMerge(b.ranges)}),h.push({id:u.SetNumfmtMutation.id,params:d});const g=u.factorySetNumfmtUndoMutation(e,d);C.push(...g)}if(m.length){v.ranges=u.rangeMerge(v.ranges),h.push({id:u.RemoveNumfmtMutation.id,params:v});const g=u.factoryRemoveNumfmtUndoMutation(e,v);C.push(...g)}const _=c.sequenceExecute(h,r).result;return _&&a.pushUndoRedo({unitID:i,undoMutations:C,redoMutations:h}),_}},Me={sheet:{numfmt:{title:"Number format",numfmtType:"Format types",cancel:"Cancel",confirm:"Confirm",general:"General",accounting:"Accounting",text:"Text",number:"Number",currency:"Currency",date:"Date",time:"Time",thousandthPercentile:"Thousands separator",preview:"Preview",dateTime:"Date and time",decimalLength:"Decimal places",currencyType:"Currency Symbol",moreFmt:"More Formats",financialValue:"Financial value",roundingCurrency:"Rounding up the currency",timeDuration:"Duration Time",currencyDes:"The currency format is used to represent general currency values. The accounting format aligns a column of values with decimal points",accountingDes:"The accounting number format aligns a column of values with currency symbols and decimal points",dateType:"Date Type",dateDes:"The date format presents date and time series values as date values.",negType:"A negative number type",generalDes:"The regular format does not contain any specific number format.",thousandthPercentileDes:"The percentile format is used for the representation of ordinary numbers. Monetary and accounting formats provide a specialized format for monetary value calculations.",addDecimal:"Increase decimal places",subtractDecimal:"Decreasing decimal places"}}},je={sheet:{numfmt:{title:"数据格式",numfmtType:"格式类型",cancel:"取消",confirm:"确认",general:"常规",accounting:"会计",text:"文本",number:"数值",currency:"货币",date:"日期",time:"时间",thousandthPercentile:"千分位符",preview:"示例",dateTime:"日期时间",decimalLength:"小数位数",currencyType:"货币类型",moreFmt:"更多格式",financialValue:"财务数值",roundingCurrency:"货币取整",timeDuration:"持续时间",currencyDes:"货币格式用于表示一般货币数值。会计格式可以对一列数值进行小数点对齐",accountingDes:"会计数字格式可对一列数值进行货币符号和小数点对齐",dateType:"日期类型",dateDes:"日期格式将日期和时间系列数值品示为日期值。",negType:"负数类型",generalDes:"常规格式不包含任何特定的数字格式。",thousandthPercentileDes:"千分位符格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。",addDecimal:"增加小数位",subtractDecimal:"减少小数位"}}},G="SHEET_NUMFMT_PLUGIN",Q=e=>{const t=e.filter(s=>s.id===u.RemoveNumfmtMutation.id).map(s=>s.params),r=e.filter(s=>s.id===u.SetNumfmtMutation.id).map(s=>s.params),n=[];if(t[0]){const s=t.reduce((i,o)=>(i.ranges.push(...o.ranges),i),{ranges:[],unitId:t[0].unitId,subUnitId:t[0].subUnitId});s.ranges=u.rangeMerge(s.ranges),n.push({id:u.RemoveNumfmtMutation.id,params:s})}const a=(s,i)=>{const o=Object.keys(s),l=o.findIndex(f=>{const m=s[f];return c.Tools.diffValue(m,i)});return o[l]};if(r[0]){const s=r.reduce((i,o)=>(Object.keys(o.values).forEach(l=>{const f=o.values[l],m=o.refMap[l],d=a(i.refMap,m);if(d)i.values[d].ranges.push(...f.ranges);else{const v=Math.max(...Object.keys(i.refMap).map(Number),0)+1;i.values[v]={ranges:f.ranges},i.refMap[v]=m}}),i),{values:{},refMap:{},unitId:r[0].unitId,subUnitId:r[0].subUnitId});Object.keys(s.values).forEach(i=>{const o=s.values[i];o.ranges=u.rangeMerge(o.ranges)}),n.push({id:u.SetNumfmtMutation.id,params:s})}return n};var We=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ge=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ye(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&We(t,r,a),a},X=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r,n){super(),this._injector=e,this._univerInstanceService=t,this._numfmtService=r,this._autoFillService=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,s,i)=>{const o=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),l=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),f={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},m={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},d=[];if(c.Range.foreach(i,(v,h)=>{const C=c.Rectangle.getPositionRange({startRow:v,startColumn:h,endColumn:h,endRow:v},f),_=this._numfmtService.getValue(o,l,C.startRow,C.startColumn);if(_){const g=c.Rectangle.getPositionRange({startRow:v,startColumn:h,endColumn:h,endRow:v},m);d.push({pattern:_.pattern,type:_.type,row:g.startRow,col:g.startColumn})}}),d.length){const v={id:u.SetNumfmtMutation.id,params:u.transformCellsToRange(o,l,d)},h=u.factorySetNumfmtUndoMutation(this._injector,v.params);return{redos:[v],undos:h}}return{redos:[],undos:[]}},r=(a,s)=>{const i=[],o=[],l={row:a.startRow,col:a.startColumn};return O.getAutoFillRepeatRange(a,s).forEach(m=>{const{undos:d,redos:v}=t(l,m.repeatStartCell,m.relativeRange);i.push(...d),o.push(...v)}),{undos:Q(i),redos:Q(o)}},n={id:G,onFillData:(a,s,i)=>{if(i===O.APPLY_TYPE.COPY||i===O.APPLY_TYPE.ONLY_FORMAT||i===O.APPLY_TYPE.SERIES){const{source:o,target:l}=a;return r(o,l)}return e()}};this.disposeWithMe(this._autoFillService.addHook(n))}};q=Ge([c.OnLifecycle(c.LifecycleStages.Rendered,q),X(0,S.Inject(S.Injector)),X(1,S.Inject(c.IUniverInstanceService)),X(2,S.Inject(u.INumfmtService)),X(3,S.Inject(O.IAutoFillService))],q);const he=e=>L.getInfo(e).type||"unknown",ge=(e,t)=>{const n=L.getInfo(e)._partitions[1],a=L.format(e,t,{locale:"zh-CN"});return t<0?{result:a,color:n.color}:{result:a}};var Ke=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Je=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ze(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Ke(t,r,a),a},K=(e,t)=>(r,n)=>t(r,n,e);let ee=class extends c.Disposable{constructor(e,t,r,n,a){super(),this._sheetInterceptorService=e,this._themeService=t,this._sheetSkeletonManagerService=r,this._commandService=n,this._numfmtService=a,this._initInterceptorCellContent()}_initInterceptorCellContent(){const e=new c.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(u.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,r,n)=>{const a=r.unitId,s=r.subUnitId,i=this._numfmtService.getValue(a,s,r.row,r.col);if(!i)return n(t);const o=t;if(!o||o.t!==c.CellValueType.NUMBER)return n(t);let l="";const f=e.getValue(r.row,r.col);if(f&&f.parameters===o.v)return{...t,...f.result};const m=ge(i.pattern,Number(o.v));if(l=m.result,!l)return n(t);const d={v:l};if(m.color){const v=this._themeService.getCurrentTheme()[`${m.color}500`];v&&(d.interceptorStyle={cl:{rgb:v}})}return e.setValue(r.row,r.col,{result:d,parameters:o.v}),{...t,...d}}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===u.SetNumfmtMutation.id){const r=t.params;Object.keys(r.values).forEach(n=>{r.values[n].ranges.forEach(s=>{c.Range.foreach(s,(i,o)=>{e.realDeleteValue(i,o)})})})}})),this.disposeWithMe(c.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.pipe(P.map(t=>t==null?void 0:t.sheetId),P.distinctUntilChanged()).subscribe(()=>{e.reset()})))}};ee=Je([c.OnLifecycle(c.LifecycleStages.Rendered,ee),K(0,S.Inject(u.SheetInterceptorService)),K(1,S.Inject(c.ThemeService)),K(2,S.Inject(O.SheetSkeletonManagerService)),K(3,S.Inject(c.ICommandService)),K(4,S.Inject(u.INumfmtService))],ee);const H=(e,t=0)=>{var n;return e&&(n=L.getInfo(e).maxDecimals)!=null?n:t},te=(e,t)=>{if(e&&!t||!e&&t)return!1;const r=f=>f.reduce((m,d)=>{if(m.isEnd)return m;const v=d.value||d.num;return d.type==="point"?(m.isEnd=!0,m):{...m,result:m.result+v}},{isEnd:!1,result:""}).result,n=L.getInfo(e)._partitions,a=L.getInfo(t)._partitions,s=r(n[0].tokens),i=r(a[0].tokens),o=r(n[1].tokens),l=r(a[1].tokens);return s===i&&o===l&&n[1].color===a[1].color},Ne=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),T=(e,t)=>e.split(";").map(n=>/\.0?/.test(n)?n.replace(/\.0*/g,`${t>0?".":""}${Ne(Number(t||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${t>0?".":""}${Ne(Number(t||0))}$1`):n).join(";"),Qe=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),Oe={id:"sheet.command.numfmt.add.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(u.SelectionManagerService),n=e.get(u.INumfmtService),a=e.get(c.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const i=a.getCurrentUniverSheetInstance(),o=i.getActiveSheet(),l=i.getUnitId(),f=o.getSheetId();let m=0;s.forEach(C=>{c.Range.foreach(C.range,(_,g)=>{const y=n.getValue(l,f,_,g);if(!y)return;const b=H(y.pattern);m=b>m?b:m})});const d=m+1,v=T(`0${d>0?".0":""}`,d),h=[];return s.forEach(C=>{c.Range.foreach(C.range,(_,g)=>{const y=n.getValue(l,f,_,g);if(!y)h.push({row:_,col:g,pattern:v});else{const b=H(y.pattern),N=T(y.pattern,b+1);N!==y.pattern&&h.push({row:_,col:g,pattern:N})}})}),h.length?await t.executeCommand(V.id,{values:h}):!1}},Xe=[{label:"1930-08-05",suffix:"yyyy-MM-dd"},{label:"1930/08/05",suffix:"yyyy/MM/dd"},{label:"1930年08月05日",suffix:'yyyy"年"MM"月"dd"日"'},{label:"08-05",suffix:"MM-dd"},{label:"8月5日",suffix:'M"月"d"日"'},{label:"13:30:30",suffix:"h:mm:ss"},{label:"13:30",suffix:"h:mm"},{label:"下午01:30",suffix:"A/P hh:mm"},{label:"下午1:30",suffix:"A/P h:mm"},{label:"下午1:30:30",suffix:"A/P h:mm:ss"},{label:"08-05 下午 01:30",suffix:"MM-dd A/P hh:mm"}],qe=[{label:"(1,235)",suffix:"#,##0_);(#,##0)"},{label:"(1,235) ",suffix:"#,##0_);[Red](#,##0)",color:"red"},{label:"1,234.56",suffix:"#,##0.00_);#,##0.00"},{label:"1,234.56",suffix:"#,##0.00_);[Red]#,##0.00",color:"red"},{label:"-1,234.56",suffix:"#,##0.00_);-#,##0.00"},{label:"-1,234.56",suffix:"#,##0.00_);[Red]-#,##0.00",color:"red"}],Pe=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:"red"},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:"red"},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:"red"}],Te={id:"sheet.command.numfmt.set.currency",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(u.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s=Pe[0].suffix("¥");return n.forEach(o=>{c.Range.foreach(o.range,(l,f)=>{a.push({row:l,col:f,pattern:s,type:"currency"})})}),await t.executeCommand(V.id,{values:a})}},we={id:"sheet.command.numfmt.subtract.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(u.SelectionManagerService),n=e.get(u.INumfmtService),a=e.get(c.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const i=a.getCurrentUniverSheetInstance(),o=i.getActiveSheet(),l=i.getUnitId(),f=o.getSheetId();let m=0;s.forEach(_=>{c.Range.foreach(_.range,(g,y)=>{const b=n.getValue(l,f,g,y);if(!b)return;const N=H(b.pattern);m=N>m?N:m})});const d=m-1,v=T(`0${d>0?".0":"."}`,d),h=[];return s.forEach(_=>{c.Range.foreach(_.range,(g,y)=>{const b=n.getValue(l,f,g,y);if(!b)h.push({row:g,col:y,pattern:v});else{const N=H(b.pattern);h.push({row:g,col:y,pattern:T(b.pattern,N-1)})}})}),await t.executeCommand(V.id,{values:h})}},pe={id:"sheet.operation.close.numfmt.panel",type:c.CommandType.OPERATION,handler:()=>!0},Se=S.createIdentifier("INumfmtController");c.runOnLifecycle(c.LifecycleStages.Rendered,Se);const ne={id:"sheet.operation.open.numfmt.panel",type:c.CommandType.OPERATION,handler:e=>(e.get(Se).openPanel(),!0)};var De={exports:{}},re={};/**
1
+ (function(R,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/engine-numfmt"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-ui","rxjs/operators","@univerjs/engine-numfmt","@univerjs/engine-render","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings","@univerjs/engine-formula"],c):(R=typeof globalThis<"u"?globalThis:R||self,c(R.UniverSheetsNumfmt={},R.UniverCore,R.UniverSheets,R["@wendellhu/redi"],R.UniverSheetsUi,R.rxjs.operators,R.UniverEngineNumfmt,R.UniverEngineRender,R.UniverUi,R.rxjs,R.React,R.UniverDesign,R["@wendellhu/redi/react-bindings"],R.UniverEngineFormula))})(this,function(R,c,u,p,O,P,L,be,M,x,I,U,w,ze){"use strict";var bn=Object.defineProperty;var Mn=(R,c,u)=>c in R?bn(R,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):R[c]=u;var B=(R,c,u)=>(Mn(R,typeof c!="symbol"?c+"":c,u),u);var Re;const V={id:"sheet.command.numfmt.set.numfmt",type:c.CommandType.COMMAND,handler:(e,t)=>{if(!t)return!1;const r=e.get(c.ICommandService),n=e.get(c.IUniverInstanceService),a=e.get(c.IUndoRedoService),s=n.getCurrentUniverSheetInstance(),i=s.getUnitId(),l=s.getActiveSheet().getSheetId(),f=t.values.filter(g=>!!g.pattern),m=t.values.filter(g=>!g.pattern),d=u.transformCellsToRange(i,l,f),v={unitId:i,subUnitId:l,ranges:m.map(g=>({startColumn:g.col,startRow:g.row,endColumn:g.col,endRow:g.row}))},h=[],C=[];if(f.length){Object.keys(d.values).forEach(y=>{const b=d.values[y];b.ranges=u.rangeMerge(b.ranges)}),h.push({id:u.SetNumfmtMutation.id,params:d});const g=u.factorySetNumfmtUndoMutation(e,d);C.push(...g)}if(m.length){v.ranges=u.rangeMerge(v.ranges),h.push({id:u.RemoveNumfmtMutation.id,params:v});const g=u.factoryRemoveNumfmtUndoMutation(e,v);C.push(...g)}const _=c.sequenceExecute(h,r).result;return _&&a.pushUndoRedo({unitID:i,undoMutations:C,redoMutations:h}),_}},Me={sheet:{numfmt:{percent:"Percentage",title:"Number format",numfmtType:"Format types",cancel:"Cancel",confirm:"Confirm",general:"General",accounting:"Accounting",text:"Text",number:"Number",currency:"Currency",date:"Date",time:"Time",thousandthPercentile:"Thousands separator",preview:"Preview",dateTime:"Date and time",decimalLength:"Decimal places",currencyType:"Currency Symbol",moreFmt:"More Formats",financialValue:"Financial value",roundingCurrency:"Rounding up the currency",timeDuration:"Duration Time",currencyDes:"The currency format is used to represent general currency values. The accounting format aligns a column of values with decimal points",accountingDes:"The accounting number format aligns a column of values with currency symbols and decimal points",dateType:"Date Type",dateDes:"The date format presents date and time series values as date values.",negType:"A negative number type",generalDes:"The regular format does not contain any specific number format.",thousandthPercentileDes:"The percentile format is used for the representation of ordinary numbers. Monetary and accounting formats provide a specialized format for monetary value calculations.",addDecimal:"Increase decimal places",subtractDecimal:"Decreasing decimal places"}}},je={sheet:{numfmt:{percent:"百分比",title:"数字格式",numfmtType:"格式类型",cancel:"取消",confirm:"确认",general:"常规",accounting:"会计",text:"文本",number:"数值",currency:"货币",date:"日期",time:"时间",thousandthPercentile:"千分位符",preview:"示例",dateTime:"日期时间",decimalLength:"小数位数",currencyType:"货币类型",moreFmt:"更多格式",financialValue:"财务数值",roundingCurrency:"货币取整",timeDuration:"持续时间",currencyDes:"货币格式用于表示一般货币数值。会计格式可以对一列数值进行小数点对齐",accountingDes:"会计数字格式可对一列数值进行货币符号和小数点对齐",dateType:"日期类型",dateDes:"日期格式将日期和时间系列数值品示为日期值。",negType:"负数类型",generalDes:"常规格式不包含任何特定的数字格式。",thousandthPercentileDes:"千分位符格式用于一般数字的表示。货币和会计格式则提供货币值计算的专用格式。",addDecimal:"增加小数位",subtractDecimal:"减少小数位"}}},K="SHEET_NUMFMT_PLUGIN",Q=e=>{const t=e.filter(s=>s.id===u.RemoveNumfmtMutation.id).map(s=>s.params),r=e.filter(s=>s.id===u.SetNumfmtMutation.id).map(s=>s.params),n=[];if(t[0]){const s=t.reduce((i,o)=>(i.ranges.push(...o.ranges),i),{ranges:[],unitId:t[0].unitId,subUnitId:t[0].subUnitId});s.ranges=u.rangeMerge(s.ranges),n.push({id:u.RemoveNumfmtMutation.id,params:s})}const a=(s,i)=>{const o=Object.keys(s),l=o.findIndex(f=>{const m=s[f];return c.Tools.diffValue(m,i)});return o[l]};if(r[0]){const s=r.reduce((i,o)=>(Object.keys(o.values).forEach(l=>{const f=o.values[l],m=o.refMap[l],d=a(i.refMap,m);if(d)i.values[d].ranges.push(...f.ranges);else{const v=Math.max(...Object.keys(i.refMap).map(Number),0)+1;i.values[v]={ranges:f.ranges},i.refMap[v]=m}}),i),{values:{},refMap:{},unitId:r[0].unitId,subUnitId:r[0].subUnitId});Object.keys(s.values).forEach(i=>{const o=s.values[i];o.ranges=u.rangeMerge(o.ranges)}),n.push({id:u.SetNumfmtMutation.id,params:s})}return n};var We=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ge=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ye(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&We(t,r,a),a},X=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r,n){super(),this._injector=e,this._univerInstanceService=t,this._numfmtService=r,this._autoFillService=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,s,i)=>{const o=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),l=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),f={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},m={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},d=[];if(c.Range.foreach(i,(v,h)=>{const C=c.Rectangle.getPositionRange({startRow:v,startColumn:h,endColumn:h,endRow:v},f),_=this._numfmtService.getValue(o,l,C.startRow,C.startColumn);if(_){const g=c.Rectangle.getPositionRange({startRow:v,startColumn:h,endColumn:h,endRow:v},m);d.push({pattern:_.pattern,type:_.type,row:g.startRow,col:g.startColumn})}}),d.length){const v={id:u.SetNumfmtMutation.id,params:u.transformCellsToRange(o,l,d)},h=u.factorySetNumfmtUndoMutation(this._injector,v.params);return{redos:[v],undos:h}}return{redos:[],undos:[]}},r=(a,s)=>{const i=[],o=[],l={row:a.startRow,col:a.startColumn};return O.getAutoFillRepeatRange(a,s).forEach(m=>{const{undos:d,redos:v}=t(l,m.repeatStartCell,m.relativeRange);i.push(...d),o.push(...v)}),{undos:Q(i),redos:Q(o)}},n={id:K,onFillData:(a,s,i)=>{if(i===O.APPLY_TYPE.COPY||i===O.APPLY_TYPE.ONLY_FORMAT||i===O.APPLY_TYPE.SERIES){const{source:o,target:l}=a;return r(o,l)}return e()}};this.disposeWithMe(this._autoFillService.addHook(n))}};q=Ge([c.OnLifecycle(c.LifecycleStages.Rendered,q),X(0,p.Inject(p.Injector)),X(1,p.Inject(c.IUniverInstanceService)),X(2,p.Inject(u.INumfmtService)),X(3,p.Inject(O.IAutoFillService))],q);const ge=e=>L.getInfo(e).type||"unknown",ee=(e,t,r)=>{const n=L.getInfo(e),a=r===c.LocaleType.ZH_CN?"zh-CN":"en",s=n._partitions[1],i=L.format(e,t,{locale:a});return t<0?{result:i,color:s.color}:{result:i}};var Ke=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Je=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ze(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Ke(t,r,a),a},z=(e,t)=>(r,n)=>t(r,n,e);let te=class extends c.Disposable{constructor(e,t,r,n,a,s){super(),this._sheetInterceptorService=e,this._themeService=t,this._sheetSkeletonManagerService=r,this._commandService=n,this._numfmtService=a,this._localeService=s,this._initInterceptorCellContent()}_initInterceptorCellContent(){const e=new c.ObjectMatrix;this.disposeWithMe(this._sheetInterceptorService.intercept(u.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,r,n)=>{const a=r.unitId,s=r.subUnitId,i=this._numfmtService.getValue(a,s,r.row,r.col);if(!i)return n(t);const o=t;if(!o||o.t!==c.CellValueType.NUMBER)return n(t);let l="";const f=e.getValue(r.row,r.col);if(f&&f.parameters===o.v)return{...t,...f.result};const m=ee(i.pattern,Number(o.v),this._localeService.getCurrentLocale());if(l=m.result,!l)return n(t);const d={v:l};if(m.color){const v=this._themeService.getCurrentTheme()[`${m.color}500`];v&&(d.interceptorStyle={cl:{rgb:v}})}return e.setValue(r.row,r.col,{result:d,parameters:o.v}),{...t,...d}}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===u.SetNumfmtMutation.id){const r=t.params;Object.keys(r.values).forEach(n=>{r.values[n].ranges.forEach(s=>{c.Range.foreach(s,(i,o)=>{e.realDeleteValue(i,o)})})})}})),this.disposeWithMe(c.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.pipe(P.map(t=>t==null?void 0:t.sheetId),P.distinctUntilChanged()).subscribe(()=>{e.reset()})))}};te=Je([c.OnLifecycle(c.LifecycleStages.Rendered,te),z(0,p.Inject(u.SheetInterceptorService)),z(1,p.Inject(c.ThemeService)),z(2,p.Inject(O.SheetSkeletonManagerService)),z(3,p.Inject(c.ICommandService)),z(4,p.Inject(u.INumfmtService)),z(5,p.Inject(c.LocaleService))],te);const H=(e,t=0)=>{var n;return e&&(n=L.getInfo(e).maxDecimals)!=null?n:t},ne=(e,t)=>{if(e&&!t||!e&&t)return!1;const r=f=>f.reduce((m,d)=>{if(m.isEnd)return m;const v=d.value||d.num;return d.type==="point"?(m.isEnd=!0,m):{...m,result:m.result+v}},{isEnd:!1,result:""}).result,n=L.getInfo(e)._partitions,a=L.getInfo(t)._partitions,s=r(n[0].tokens),i=r(a[0].tokens),o=r(n[1].tokens),l=r(a[1].tokens);return s===i&&o===l&&n[1].color===a[1].color},Ne=e=>new Array(Math.min(Math.max(0,Number(e)),30)).fill(0).join(""),T=(e,t)=>e.split(";").map(n=>/\.0?/.test(n)?n.replace(/\.0*/g,`${t>0?".":""}${Ne(Number(t||0))}`):/0([^0]?)|0$/.test(n)?n.replace(/0([^0]+)|0$/,`0${t>0?".":""}${Ne(Number(t||0))}$1`):n).join(";"),Qe=e=>/\.0?/.test(e)||/0([^0]?)|0$/.test(e),Oe={id:"sheet.command.numfmt.add.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(u.SelectionManagerService),n=e.get(u.INumfmtService),a=e.get(c.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const i=a.getCurrentUniverSheetInstance(),o=i.getActiveSheet(),l=i.getUnitId(),f=o.getSheetId();let m=0;s.forEach(C=>{c.Range.foreach(C.range,(_,g)=>{const y=n.getValue(l,f,_,g);if(!y)return;const b=H(y.pattern);m=b>m?b:m})});const d=m+1,v=T(`0${d>0?".0":""}`,d),h=[];return s.forEach(C=>{c.Range.foreach(C.range,(_,g)=>{const y=n.getValue(l,f,_,g);if(!y)h.push({row:_,col:g,pattern:v});else{const b=H(y.pattern),N=T(y.pattern,b+1);N!==y.pattern&&h.push({row:_,col:g,pattern:N})}})}),h.length?await t.executeCommand(V.id,{values:h}):!1}},Xe=[{label:"1930-08-05",suffix:"yyyy-MM-dd"},{label:"1930/08/05",suffix:"yyyy/MM/dd"},{label:"1930年08月05日",suffix:'yyyy"年"MM"月"dd"日"'},{label:"08-05",suffix:"MM-dd"},{label:"8月5日",suffix:'M"月"d"日"'},{label:"13:30:30",suffix:"h:mm:ss"},{label:"13:30",suffix:"h:mm"},{label:"下午01:30",suffix:"A/P hh:mm"},{label:"下午1:30",suffix:"A/P h:mm"},{label:"下午1:30:30",suffix:"A/P h:mm:ss"},{label:"08-05 下午 01:30",suffix:"MM-dd A/P hh:mm"}],qe=[{label:"(1,235)",suffix:"#,##0_);(#,##0)"},{label:"(1,235) ",suffix:"#,##0_);[Red](#,##0)",color:"red"},{label:"1,234.56",suffix:"#,##0.00_);#,##0.00"},{label:"1,234.56",suffix:"#,##0.00_);[Red]#,##0.00",color:"red"},{label:"-1,234.56",suffix:"#,##0.00_);-#,##0.00"},{label:"-1,234.56",suffix:"#,##0.00_);[Red]-#,##0.00",color:"red"}],Pe=[{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);"${e}"#,##0.00`},{label:e=>`${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,color:"red"},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);("${e}"#,##0.00)`},{label:e=>`(${e}1,235)`,suffix:e=>`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,color:"red"},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);-"${e}"#,##0.00`},{label:e=>`-${e}1,235`,suffix:e=>`"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,color:"red"}],Te={id:"sheet.command.numfmt.set.currency",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(u.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s=Pe[0].suffix("¥");return n.forEach(o=>{c.Range.foreach(o.range,(l,f)=>{a.push({row:l,col:f,pattern:s,type:"currency"})})}),await t.executeCommand(V.id,{values:a})}},we={id:"sheet.command.numfmt.subtract.decimal.command",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),r=e.get(u.SelectionManagerService),n=e.get(u.INumfmtService),a=e.get(c.IUniverInstanceService),s=r.getSelections();if(!s||!s.length)return!1;const i=a.getCurrentUniverSheetInstance(),o=i.getActiveSheet(),l=i.getUnitId(),f=o.getSheetId();let m=0;s.forEach(_=>{c.Range.foreach(_.range,(g,y)=>{const b=n.getValue(l,f,g,y);if(!b)return;const N=H(b.pattern);m=N>m?N:m})});const d=m-1,v=T(`0${d>0?".0":"."}`,d),h=[];return s.forEach(_=>{c.Range.foreach(_.range,(g,y)=>{const b=n.getValue(l,f,g,y);if(!b)h.push({row:g,col:y,pattern:v});else{const N=H(b.pattern);h.push({row:g,col:y,pattern:T(b.pattern,N-1)})}})}),await t.executeCommand(V.id,{values:h})}},pe={id:"sheet.operation.close.numfmt.panel",type:c.CommandType.OPERATION,handler:()=>!0},Se=p.createIdentifier("INumfmtController");c.runOnLifecycle(c.LifecycleStages.Rendered,Se);const re={id:"sheet.operation.open.numfmt.panel",type:c.CommandType.OPERATION,handler:e=>(e.get(Se).openPanel(),!0)};var De={exports:{}},ae={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var et=I,tt=Symbol.for("react.element"),nt=Symbol.for("react.fragment"),rt=Object.prototype.hasOwnProperty,at=et.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0};function Ee(e,t,r){var n,a={},s=null,i=null;r!==void 0&&(s=""+r),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(n in t)rt.call(t,n)&&!st.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)a[n]===void 0&&(a[n]=t[n]);return{$$typeof:tt,type:e,key:s,ref:i,props:a,_owner:at.current}}re.Fragment=nt,re.jsx=Ee,re.jsxs=Ee,De.exports=re;var p=De.exports;const _e=I.createContext([]),Ce=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"];var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,ct=(e,t,r,n)=>{for(var a=n>1?void 0:n?ot(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&it(t,r,a),a},lt=(e,t)=>(r,n)=>t(r,n,e);let ae=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const a=n.findIndex(s=>s===t);a>-1&&n.splice(a,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const a=n.map((s,i,o)=>{const l=o.length;return{value:s,priority:l-i}});return t.sort((s,i)=>{var f,m;const o=((f=a.find(d=>d.value===s))==null?void 0:f.priority)||-1;return(((m=a.find(d=>d.value===i))==null?void 0:m.priority)||-1)-o})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};ae=ct([lt(0,S.Inject(c.ILocalStorageService))],ae);const xe="numfmtCurrency",ut=e=>{const t=w.useDependency(ae),[r,n]=I.useState(Ce);return I.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(xe,[...Ce]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(xe,s)}}},mt=()=>{const e=I.useRef([]),[t,r]=I.useState({});return I.useEffect(()=>{e.current.forEach(a=>{a()}),e.current=[]},[t]),a=>{e.current.push(a),r({})}},Z=e=>Ce.find(r=>e.includes(r)),dt=e=>!!Z(e)&&e.startsWith("_("),ft=e=>{const[t,r]=I.useState(()=>H(e.defaultPattern||"",2)),n=I.useContext(_e),[a,s]=I.useState(()=>Z(e.defaultPattern)||n[0]),i=I.useMemo(()=>n.map(d=>({label:d,value:d})),[]),l=w.useDependency(c.LocaleService).t;e.action.current=()=>T(`_("${a}"* #,##0${t>0?".0":""}_)`,t);const f=d=>{s(d),e.onChange(T(`_("${d}"* #,##0${t>0?".0":""}_)`,t))},m=d=>{const v=d||0;r(v),e.onChange(T(`_("${a}"* #,##0${v>0?".0":""}_)`,v))};return p.jsxs("div",{children:[p.jsxs("div",{className:"m-t-16 options ",children:[p.jsxs("div",{className:"option",children:[p.jsx("div",{className:"label",children:l("sheet.numfmt.decimalLength")}),p.jsx("div",{className:"m-t-8 w-120",children:p.jsx(U.InputNumber,{value:t,max:20,min:0,onChange:m})})]}),p.jsxs("div",{className:"option",children:[p.jsx("div",{className:"label",children:l("sheet.numfmt.currencyType")}),p.jsx("div",{className:"m-t-8 w-140",children:p.jsx(U.Select,{onChange:f,options:i,value:a})})]})]}),p.jsx("div",{className:"describe m-t-14",children:l("sheet.numfmt.accountingDes")})]})},Ie=e=>Pe.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),Ue=()=>Xe.map(e=>({label:e.label,value:e.suffix})),Le=()=>qe.map(e=>({label:e.label,value:e.suffix,color:e.color})),vt=e=>!!Z(e)&&!e.startsWith("_("),ht=e=>{const r=w.useDependency(c.LocaleService).t,n=I.useContext(_e),[a,s]=I.useState(()=>Z(e.defaultPattern)||n[0]),[i,o]=I.useState(()=>H(e.defaultPattern||"",2)),[l,f]=I.useState(()=>{var y;const _=Ie(a);return((y=_.find(b=>te(b.value,e.defaultPattern)))==null?void 0:y.value)||_[0].value}),m=I.useMemo(()=>Ie(a),[a]),d=I.useMemo(()=>n.map(_=>({label:_,value:_})),[n]);e.action.current=()=>T(l,i);const v=_=>{s(_);const g=Ie(_)[0].value;f(g),e.onChange(T(g,i))},h=_=>{f(_),e.onChange(T(_,i))},C=_=>{o(_||0),e.onChange(T(l,_||0))};return p.jsxs("div",{children:[p.jsxs("div",{className:"m-t-16 options ",children:[p.jsxs("div",{className:"option",children:[p.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),p.jsx("div",{className:"m-t-8 w-120",children:p.jsx(U.InputNumber,{value:i,max:20,min:0,onChange:C})})]}),p.jsxs("div",{className:"option",children:[p.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),p.jsx("div",{className:"m-t-8 w-140",children:p.jsx(U.Select,{onChange:v,options:d,value:a})})]})]}),p.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),p.jsx("div",{className:"m-t-8",children:p.jsx(U.SelectList,{onChange:h,options:m,value:l})}),p.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})},gt=e=>{const t=L.getInfo(e);return Ue().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},pt=e=>{const t=I.useMemo(Ue,[]),n=w.useDependency(c.LocaleService).t,[a,s]=I.useState(()=>{if(e.defaultPattern){const o=t.find(l=>l.value===e.defaultPattern);if(o)return o.value}return t[0].value});e.action.current=()=>a;const i=o=>{s(o),e.onChange(o)};return p.jsxs("div",{children:[p.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),p.jsx("div",{className:"m-t-8",children:p.jsx(U.SelectList,{value:a,options:t,onChange:i})}),p.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},St=e=>!e,_t=e=>{const r=w.useDependency(c.LocaleService).t;return e.action.current=()=>"",p.jsx("div",{children:p.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},Ct=e=>Le().some(t=>te(t.value,e)),It=e=>{const t=w.useDependency(c.LocaleService),r=I.useMemo(Le,[]),[n,a]=I.useState(()=>H(e.defaultPattern||"",0)),[s,i]=I.useState(()=>{const d=r.find(v=>te(v.value,e.defaultPattern||""));return(d==null?void 0:d.value)||r[0].value}),o=I.useMemo(()=>T(s,Number(n||0)),[s,n]),l=I.useMemo(()=>!Qe(s),[s]),f=d=>{a(d||0),e.onChange(T(s,Number(d||0)))},m=d=>{a(H(d,0)),i(d),e.onChange(d)};return e.action.current=()=>o,p.jsxs("div",{children:[p.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),p.jsx("div",{className:"m-t-8",children:p.jsx(U.InputNumber,{disabled:l,value:n,max:20,min:0,onChange:f})}),p.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),p.jsx("div",{className:"m-t-8",children:p.jsx(U.SelectList,{onChange:m,options:r,value:s})}),p.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},yt=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:a}=e.value,s=w.useDependency(c.LocaleService),i=I.useRef(()=>""),o=s.t,l=mt(),f=I.useMemo(()=>[{label:"sheet.numfmt.general",component:_t},{label:"sheet.numfmt.accounting",component:ft},{label:"sheet.numfmt.currency",component:ht},{label:"sheet.numfmt.date",component:pt},{label:"sheet.numfmt.thousandthPercentile",component:It}].map(j=>({...j,label:o(j.label)})),[]),[m,d]=I.useState(y),[v,h]=I.useState(()=>`${n}_${a}`),{mark:C,userHabitCurrency:_}=ut(()=>h(`${n}_${a}_userCurrency'`)),g=I.useMemo(()=>{var j;return(j=f.find(Y=>Y.label===m))==null?void 0:j.component},[m]);function y(){return[St,dt,vt,gt,Ct].reduce((Y,yn,Rn)=>Y||(yn(r)?f[Rn].label:""),"")||f[0].label}const b=f.map(j=>({label:j.label,value:j.label})),N=j=>{d(j),l(()=>e.onChange({type:"change",value:i.current()||""}))},A=j=>{e.onChange({type:"change",value:j})},$=()=>{const j=i.current()||"",Y=Z(j);Y&&C(Y),e.onChange({type:"confirm",value:j})},k=()=>{e.onChange({type:"cancel",value:""})},F={onChange:A,defaultValue:t,defaultPattern:r,action:i};return I.useEffect(()=>{d(y()),h(`${n}_${a}`)},[n,a]),p.jsxs("div",{className:"numfmt-panel p-b-20",children:[p.jsxs("div",{children:[p.jsx("div",{className:"label m-t-14",children:o("sheet.numfmt.numfmtType")}),p.jsx("div",{className:"m-t-8",children:p.jsx(U.Select,{onChange:N,options:b,value:m})}),p.jsx("div",{children:g&&p.jsx(_e.Provider,{value:_,children:I.createElement(g,{...F,key:v})})})]}),p.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[p.jsx(U.Button,{size:"small",onClick:k,className:"m-r-12",children:o("sheet.numfmt.cancel")}),p.jsx(U.Button,{type:"primary",size:"small",onClick:$,children:o("sheet.numfmt.confirm")})]})]})},Ae={id:"sheet.command.numfmt.set.percent",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(u.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s="0%";return n.forEach(o=>{c.Range.foreach(o.range,(l,f)=>{a.push({row:l,col:f,pattern:s,type:"percent"})})}),await t.executeCommand(V.id,{values:a})}};var Rt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Mt=(e,t,r,n)=>{for(var a=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Rt(t,r,a),a},D=(e,t)=>(r,n)=>t(r,n,e);let se=class extends c.Disposable{constructor(t,r,n,a,s,i,o,l,f,m,d,v){super();B(this,"_previewPattern","");B(this,"openPanel",()=>{const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,a=this._univerInstanceService,s=this._numfmtService,i=this._localeService,l=(r.getSelectionRanges()||[])[0];if(!l)return!1;const f=a.getCurrentUniverSheetInstance(),m=f.getActiveSheet(),d=m.getCellRaw(l.startRow,l.startColumn),v=s.getValue(f.getUnitId(),m.getSheetId(),l.startRow,l.startColumn);let h="";v&&(h=v.pattern);const C=(d==null?void 0:d.t)===c.CellValueType.NUMBER?d.v:12345678,_={onChange:g=>{var y,b;if(g.type==="change")this._previewPattern=g.value,this._sheetSkeletonManagerService.reCalculate(),(b=(y=this._renderManagerService.getRenderById(f.getUnitId()))==null?void 0:y.mainComponent)==null||b.makeDirty();else if(g.type==="confirm"){const N=r.getSelectionRanges()||[],A={values:[]},$=he(g.value);N.forEach(k=>{c.Range.foreach(k,(F,j)=>{A.values.push({row:F,col:j,pattern:g.value,type:$})})}),n.executeCommand(V.id,A),t.close()}else g.type==="cancel"&&t.close()},value:{defaultPattern:h,defaultValue:C,row:l.startRow,col:l.startColumn}};t.open({header:{title:i.t("sheet.numfmt.title")},children:{label:G,..._},onClose:()=>{var g,y;this._sheetSkeletonManagerService.reCalculate(),(y=(g=this._renderManagerService.getRenderById(f.getUnitId()))==null?void 0:g.mainComponent)==null||y.makeDirty(),n.executeCommand(pe.id)}})});this._sheetInterceptorService=t,this._themeService=r,this._injector=n,this._univerInstanceService=a,this._sheetSkeletonManagerService=s,this._commandService=i,this._selectionManagerService=o,this._renderManagerService=l,this._numfmtService=f,this._componentManager=m,this._sidebarService=d,this._localeService=v,this._initInterceptorCommands(),this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._commandExecutedListener()}_initCommands(){[Oe,we,Te,Ae,ne,pe,V].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(G,yt)}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){switch(r.id){case u.ClearSelectionAllCommand.id:case u.ClearSelectionFormatCommand.id:{const n=t._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=t._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s=t._selectionManagerService.getSelectionRanges();if(!(s!=null&&s.length))break;const i={unitId:n,subUnitId:a,ranges:[]},o=t._numfmtService.getModel(n,a);s.forEach(f=>{c.Range.foreach(f,(m,d)=>{o!=null&&o.getValue(m,d)&&i.ranges.push({startColumn:d,endColumn:d,startRow:m,endRow:m})})}),i.ranges=u.rangeMerge(i.ranges);const l=u.factoryRemoveNumfmtUndoMutation(t._injector,i);return{redos:[{id:u.RemoveNumfmtMutation.id,params:i}],undos:l}}}return{redos:[],undos:[]}}}))}_initRealTimeRenderingInterceptor(){const t=new x.Observable(n=>{this._commandService.onCommandExecuted(a=>{a.id===ne.id&&n.next(!0),a.id===pe.id&&n.next(!1)})}),r=x.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(P.map(n=>n?n.map(a=>a.range):[]))]);this.disposeWithMe(c.toDisposable(r.pipe(P.switchMap(([n,a])=>new x.Observable(s=>{const i=new c.DisposableCollection;return n&&a.length&&s.next({selectionRanges:a,disposableCollection:i}),()=>{i.dispose()}})),P.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:a})=>{var i,o;const s=this._univerInstanceService.getCurrentUniverSheetInstance();this.openPanel(),n.add(this._sheetInterceptorService.intercept(u.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,handler:(l,f,m)=>{const{row:d,col:v}=f;if(a.find(h=>h.startColumn<=v&&h.endColumn>=v&&h.startRow<=d&&h.endRow>=d)){const h=f.worksheet.getCellRaw(d,v),C=h==null?void 0:h.v,_=h==null?void 0:h.t;if(C==null||_!==c.CellValueType.NUMBER||this._previewPattern===null)return m(l);const g=ge(this._previewPattern,C);if(g.color){const b=this._themeService.getCurrentTheme()[`${g.color}500`];return{...l,v:g.result,t:c.CellValueType.STRING,s:{cl:{rgb:b}}}}return{...l,v:g.result,t:c.CellValueType.STRING}}return m(l)}})),(o=(i=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:i.mainComponent)==null||o.makeDirty()})))}_commandExecutedListener(){const t=[u.RemoveNumfmtMutation.id,u.SetNumfmtMutation.id];this.disposeWithMe(c.toDisposable(x.merge(new x.Observable(r=>{const n=this._commandService.onCommandExecuted(a=>{if(t.includes(a.id)){const s=a.params;r.next(s.unitId)}});return()=>{n.dispose()}}),this._numfmtService.modelReplace$).pipe(P.debounceTime(16)).subscribe(r=>{var n,a;this._sheetSkeletonManagerService.reCalculate(),(a=(n=this._renderManagerService.getRenderById(r))==null?void 0:n.mainComponent)==null||a.makeDirty()})))}};se=Mt([c.OnLifecycle(c.LifecycleStages.Rendered,se),D(0,S.Inject(u.SheetInterceptorService)),D(1,S.Inject(c.ThemeService)),D(2,S.Inject(S.Injector)),D(3,S.Inject(c.IUniverInstanceService)),D(4,S.Inject(O.SheetSkeletonManagerService)),D(5,S.Inject(c.ICommandService)),D(6,S.Inject(u.SelectionManagerService)),D(7,S.Inject(be.IRenderManagerService)),D(8,S.Inject(u.INumfmtService)),D(9,S.Inject(M.ComponentManager)),D(10,S.Inject(M.ISidebarService)),D(11,S.Inject(c.LocaleService))],se);var jt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,Ot=(e,t,r,n)=>{for(var a=n>1?void 0:n?Nt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&jt(t,r,a),a},ie=(e,t)=>(r,n)=>t(r,n,e);let oe=class extends c.Disposable{constructor(t,r,n,a){super();B(this,"_copyInfo");this._sheetClipboardService=t,this._injector=r,this._numfmtService=n,this._univerInstanceService=a,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:G,onBeforeCopy:(t,r,n)=>this._collectNumfmt(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:s=O.COPY_TYPE.COPY,pasteType:i}=a,{range:o}=t||{},{range:l}=r;return this._generateNumfmtMutations(l,{copyType:s,pasteType:i,copyRange:o})}}))}_collectNumfmt(t,r,n){const a=new c.ObjectMatrix;this._copyInfo={matrix:a,info:{unitId:t,subUnitId:r}};const s=this._numfmtService.getModel(t,r);s&&c.Range.foreach(n,(i,o)=>{const l=this._numfmtService.getValue(t,r,i,o,s);if(!l)return;const f=c.Rectangle.getRelativeRange({startRow:i,endRow:i,startColumn:o,endColumn:o},n);a.setValue(f.startRow,f.startColumn,{pattern:l.pattern,type:l.type})})}_generateNumfmtMutations(t,r){const n=this._univerInstanceService.getCurrentUniverSheetInstance(),a=n.getActiveSheet(),s=n.getUnitId(),i=a.getSheetId();if(r.copyType===O.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([O.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,O.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE].includes(r.pasteType))return{redos:[],undos:[]};const o=O.getRepeatRange(r.copyRange,t,!0),l=[],f={unitId:s,subUnitId:i,ranges:[]},m=this._numfmtService.getModel(s,i);c.Range.foreach(t,(h,C)=>{this._numfmtService.getValue(s,i,h,C,m)&&f.ranges.push({startRow:h,startColumn:C,endRow:h,endColumn:C})}),o.forEach(h=>{this._copyInfo&&this._copyInfo.matrix.forValue((C,_,g)=>{const y=c.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:_,endColumn:_},h.startRange);l.push({row:y.startRow,col:y.startColumn,pattern:g.pattern,type:g.type})})});const d=u.transformCellsToRange(s,i,l);Object.keys(d.values).forEach(h=>{const C=d.values[h];C.ranges=u.rangeMerge(C.ranges)}),f.ranges=u.rangeMerge(f.ranges);const v=[...u.factorySetNumfmtUndoMutation(this._injector,d),...u.factoryRemoveNumfmtUndoMutation(this._injector,f)];return{redos:[{id:u.RemoveNumfmtMutation.id,params:f},{id:u.SetNumfmtMutation.id,params:d}],undos:Q(v)}}};oe=Ot([c.OnLifecycle(c.LifecycleStages.Rendered,oe),ie(0,S.Inject(O.ISheetClipboardService)),ie(1,S.Inject(S.Injector)),ie(2,S.Inject(u.INumfmtService)),ie(3,S.Inject(c.IUniverInstanceService))],oe);var Pt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,wt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Tt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Pt(t,r,a),a},J=(e,t)=>(r,n)=>t(r,n,e);const Dt=()=>{let e=[];return{add:(a,s,i,o,l)=>e.push({unitId:a,subUnitId:s,row:i,col:o,value:l}),getEffects:()=>e,clean:()=>{e=[]}}};let ce=class extends c.Disposable{constructor(t,r,n,a,s){super();B(this,"_collectEffectMutation",Dt());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=a,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const a=r.row,s=r.col,i=this._numfmtService.getValue(r.unitId,r.subUnitId,a,s);if(i)switch(he(i.pattern)){case"scientific":case"percent":case"currency":case"grouped":case"number":return r.worksheet.getCellRaw(a,s);case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(t,r,n)=>{this._collectEffectMutation.clean();const a=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),s=()=>{a&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(t!=null&&t.v))return n(t);const i=String(t.v),o=L.parseDate(i)||L.parseTime(i);if(!!o){if(o&&o.z){const f=Number(o.v);return this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{type:"date",pattern:o.z}),{...t,v:f,t:c.CellValueType.NUMBER}}}else(["date","time","datetime"].includes((a==null?void 0:a.type)||"")||!Et(i))&&s();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){switch(r.id){case u.SetRangeValuesCommand.id:{const n=t._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=t._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s=t._collectEffectMutation.getEffects();if(!s.length)return{redos:[],undos:[]};const i=s.filter(m=>{var d;return!!((d=m.value)!=null&&d.pattern)}).map(m=>({row:m.row,col:m.col,pattern:m.value.pattern,type:m.value.type})),o=s.filter(m=>{var d;return!((d=m.value)!=null&&d.pattern)}).map(m=>({startRow:m.row,endColumn:m.col,startColumn:m.col,endRow:m.row})),l=[],f=[];if(i){const m={id:u.SetNumfmtMutation.id,params:u.transformCellsToRange(n,a,i)};l.push(m),f.push(...u.factorySetNumfmtUndoMutation(t._injector,m.params))}if(o){const m={id:u.RemoveNumfmtMutation.id,params:{unitId:n,subUnitId:a,ranges:o}};l.push(m),f.push(...u.factoryRemoveNumfmtUndoMutation(t._injector,m.params))}return{redos:l,undos:f.reverse()}}}return{redos:[],undos:[]}}}))}};ce=wt([c.OnLifecycle(c.LifecycleStages.Rendered,ce),J(0,S.Inject(u.SheetInterceptorService)),J(1,S.Inject(u.INumfmtService)),J(2,S.Inject(c.IUniverInstanceService)),J(3,S.Inject(S.Injector)),J(4,S.Inject(O.IEditorBridgeService))],ce);function Et(e){return/^-?\d+(\.\d+)?$/.test(e)}var xt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Lt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ut(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&xt(t,r,a),a},At=(e,t)=>(r,n)=>t(r,n,e);let le=class extends c.Disposable{constructor(t){super();B(this,"_initLocal",()=>{this._localeService.load({zhCN:je,enUS:Me})});this._localeService=t,this._initLocal()}};le=Lt([c.OnLifecycle(c.LifecycleStages.Rendered,le),At(0,S.Inject(c.LocaleService))],le);var E=function(){return E=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},E.apply(this,arguments)},Vt=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},z=I.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,s=e.extend,i=Vt(e,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),l=I.useRef("_".concat(Ft()));return Ve(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},E({ref:t,className:o},i),s)});function Ve(e,t,r,n,a){return I.createElement(e.tag,E(E({key:t},Ht(e,r,a)),n),(kt(e,r).children||[]).map(function(s,i){return Ve(s,"".concat(t,"-").concat(e.tag,"-").concat(i),r,void 0,a)}))}function Ht(e,t,r){var n=E({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var i=s[0],o=s[1];typeof o=="string"&&(n[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function kt(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?E(E({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?E(E({},a),{attrs:E(E({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function Ft(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var $t={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.99988 3.60921C3.99988 2.32055 5.04456 1.27588 6.33321 1.27588 7.62187 1.27588 8.66654 2.32055 8.66654 3.60921V6.24136C8.66654 7.53002 7.62187 8.5747 6.33321 8.5747 5.04455 8.5747 3.99988 7.53002 3.99988 6.24136V3.60921zM6.33321 2.60921C5.78093 2.60921 5.33321 3.05693 5.33321 3.60921V6.24136C5.33321 6.79364 5.78093 7.24136 6.33321 7.24136 6.88549 7.24136 7.33321 6.79364 7.33321 6.24136V3.60921C7.33321 3.05693 6.88549 2.60921 6.33321 2.60921zM9.99988 3.60921C9.99988 2.32055 11.0446 1.27588 12.3332 1.27588 13.6219 1.27588 14.6665 2.32055 14.6665 3.60921V6.24136C14.6665 7.53002 13.6219 8.5747 12.3332 8.5747 11.0446 8.5747 9.99988 7.53002 9.99988 6.24136V3.60921zM12.3332 2.60921C11.7809 2.60921 11.3332 3.05693 11.3332 3.60921V6.24136C11.3332 6.79364 11.7809 7.24136 12.3332 7.24136 12.8855 7.24136 13.3332 6.79364 13.3332 6.24136V3.60921C13.3332 3.05693 12.8855 2.60921 12.3332 2.60921z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4713 9.58625C12.211 9.3259 11.7889 9.3259 11.5285 9.58625 11.2682 9.8466 11.2682 10.2687 11.5285 10.5291L12.3904 11.391H6.33329C5.9651 11.391 5.66663 11.6895 5.66663 12.0577 5.66663 12.4258 5.9651 12.7243 6.33329 12.7243H12.3904L11.5285 13.5862C11.2682 13.8466 11.2682 14.2687 11.5285 14.5291 11.7889 14.7894 12.211 14.7894 12.4713 14.5291L14.4669 12.5335C14.4851 12.5156 14.5022 12.4968 14.5183 12.477 14.5484 12.4399 14.5739 12.4003 14.5948 12.359 14.6407 12.2685 14.6666 12.1661 14.6666 12.0577 14.6666 11.9492 14.6407 11.8468 14.5948 11.7563 14.5739 11.715 14.5484 11.6754 14.5183 11.6383 14.5022 11.6185 14.4851 11.5997 14.4669 11.5818L12.4713 9.58625zM1.33325 7.98825C1.33325 7.62006 1.63173 7.32159 1.99992 7.32159H2.33325C2.70144 7.32159 2.99992 7.62006 2.99992 7.98825 2.99992 8.35644 2.70144 8.65492 2.33325 8.65492H1.99992C1.63173 8.65492 1.33325 8.35644 1.33325 7.98825z"}}]},He=I.forwardRef(function(e,t){return I.createElement(z,Object.assign({},e,{id:"add-digits-single",ref:t,icon:$t}))});He.displayName="AddDigitsSingle";const Bt=He;var zt={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"}}]}]},ke=I.forwardRef(function(e,t){return I.createElement(z,Object.assign({},e,{id:"more-down-single",ref:t,icon:zt}))});ke.displayName="MoreDownSingle";const Wt=ke;var Yt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_561_2",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_561_2)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{d:"M4.91876 2.65039C3.66601 2.65039 2.65045 3.66595 2.65045 4.9187 2.65045 6.17146 3.66601 7.18702 4.91876 7.18702 6.17152 7.18702 7.18708 6.17146 7.18708 4.9187 7.18708 3.66595 6.17152 2.65039 4.91876 2.65039zM3.94663 4.9187C3.94663 4.38181 4.38187 3.94657 4.91876 3.94657 5.45566 3.94657 5.8909 4.38181 5.8909 4.9187 5.8909 5.4556 5.45566 5.89084 4.91876 5.89084 4.38187 5.89084 3.94663 5.4556 3.94663 4.9187zM11.0812 8.81299C9.82842 8.81299 8.81286 9.82855 8.81286 11.0813 8.81286 12.3341 9.82842 13.3496 11.0812 13.3496 12.3339 13.3496 13.3495 12.3341 13.3495 11.0813 13.3495 9.82855 12.3339 8.81299 11.0812 8.81299zM10.109 11.0813C10.109 10.5444 10.5443 10.1092 11.0812 10.1092 11.6181 10.1092 12.0533 10.5444 12.0533 11.0813 12.0533 11.6182 11.6181 12.0534 11.0812 12.0534 10.5443 12.0534 10.109 11.6182 10.109 11.0813zM13.1597 2.84021C13.4128 3.09331 13.4128 3.50365 13.1597 3.75675L3.7568 13.1596C3.5037 13.4127 3.09336 13.4127 2.84026 13.1596 2.58717 12.9065 2.58717 12.4962 2.84026 12.2431L12.2431 2.84021C12.4962 2.58712 12.9066 2.58712 13.1597 2.84021z"}}]}]},Fe=I.forwardRef(function(e,t){return I.createElement(z,Object.assign({},e,{id:"percent-single",ref:t,icon:Yt}))});Fe.displayName="PercentSingle";const Gt=Fe;var Kt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5 3.61825C5 2.32958 6.04468 1.28491 7.33333 1.28491C8.62199 1.28491 9.66667 2.32958 9.66667 3.61825V6.30787C9.66667 7.59653 8.62199 8.64121 7.33333 8.64121C6.04468 8.64121 5 7.59653 5 6.30787V3.61825ZM7.33333 2.61825C6.78105 2.61825 6.33333 3.06596 6.33333 3.61825V6.30787C6.33333 6.86015 6.78106 7.30787 7.33333 7.30787C7.88561 7.30787 8.33333 6.86015 8.33333 6.30787V3.61825C8.33333 3.06596 7.88561 2.61825 7.33333 2.61825Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2 7.9745C2 7.60631 2.29848 7.30783 2.66667 7.30783H3C3.36819 7.30783 3.66667 7.60631 3.66667 7.9745 3.66667 8.34269 3.36819 8.64117 3 8.64117H2.66667C2.29848 8.64117 2 8.34269 2 7.9745zM8.80482 9.56197C9.06517 9.82232 9.06517 10.2444 8.80482 10.5048L7.94289 11.3667H13.3334C13.7016 11.3667 14.0001 11.6652 14.0001 12.0334 14.0001 12.4016 13.7016 12.7 13.3334 12.7H7.94289L8.80482 13.562C9.06517 13.8223 9.06517 14.2444 8.80482 14.5048 8.54447 14.7651 8.12236 14.7651 7.86201 14.5048L5.86201 12.5048C5.79809 12.4409 5.74987 12.3672 5.71733 12.2886 5.68474 12.21 5.66675 12.1238 5.66675 12.0334 5.66675 11.943 5.68474 11.8568 5.71733 11.7782 5.74987 11.6996 5.79809 11.6259 5.86201 11.562L7.86201 9.56197C8.12236 9.30162 8.54447 9.30162 8.80482 9.56197z"}}]},$e=I.forwardRef(function(e,t){return I.createElement(z,Object.assign({},e,{id:"reduce-digits-single",ref:t,icon:Kt}))});$e.displayName="ReduceDigitsSingle";const Zt=$e;var Jt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.05443 1.55744C4.34898 1.33653 4.76685 1.39623 4.98776 1.69078L7.99996 5.98276L11.0122 1.69078C11.2331 1.39623 11.6509 1.33653 11.9455 1.55744C12.24 1.77836 12.2997 2.19623 12.0788 2.49078L9.33338 6.42708H12.0788C12.447 6.42708 12.7455 6.72556 12.7455 7.09375C12.7455 7.46194 12.447 7.76042 12.0788 7.76042H8.66659V9.69702H12.3348C12.703 9.69702 13.0015 9.9955 13.0015 10.3637C13.0015 10.7319 12.703 11.0304 12.3348 11.0304H8.66659V13.9091C8.66659 14.2773 8.36811 14.5758 7.99992 14.5758C7.63173 14.5758 7.33325 14.2773 7.33325 13.9091V11.0304H3.66508C3.29689 11.0304 2.99841 10.7319 2.99841 10.3637C2.99841 9.9955 3.29689 9.69702 3.66508 9.69702H7.33325V7.76042H3.92109C3.5529 7.76042 3.25443 7.46194 3.25443 7.09375C3.25443 6.72556 3.5529 6.42708 3.92109 6.42708H6.66653L3.92109 2.49078C3.70018 2.19623 3.75987 1.77836 4.05443 1.55744Z"}}]},Be=I.forwardRef(function(e,t){return I.createElement(z,Object.assign({},e,{id:"rmb-single",ref:t,icon:Jt}))});Be.displayName="RmbSingle";const Qt=Be,ue=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:"@@@"},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Xt=e=>{var n;const t=w.useDependency(c.LocaleService),r=(n=e.value)!=null?n:t.t("sheet.numfmt.general");return p.jsx("span",{className:"more-numfmt-type",children:r})},qt=()=>{const e=w.useDependency(c.ICommandService),t=w.useDependency(c.LocaleService),r=w.useInjector(),n=w.useDependency(u.SelectionManagerService),a=o=>{const l=n.getLast();if(!l)return;const f=r.get(be.ITextSelectionRenderManager),m=l.range,d=[];c.Range.foreach(m,(v,h)=>{o?d.push({row:v,col:h,pattern:o,type:he(o)}):d.push({row:v,col:h})}),e.executeCommand(V.id,{values:d}),f.focus()},s=o=>{if(o===0)a(null);else if(o===ue.length-1)e.executeCommand(ne.id);else{const l=ue[o];l.pattern&&a(l.pattern)}},i=1220;return p.jsx("div",{className:"more-numfmt-type-options",children:ue.map((o,l)=>o==="|"?p.jsx("div",{className:"line m-t-4",onClick:f=>f.stopPropagation()},l):p.jsxs("div",{className:"option-item m-t-4",onClick:()=>{s(l)},children:[p.jsx("div",{children:t.t(o.label)}),p.jsx("div",{className:"m-l-26",children:o.pattern?L.format(o.pattern||"",i,{locale:"zh-CN"}):""})]},l))})},en=e=>{const t="icon-rmbSingle";return e.register(t,Qt),e.register("MoreDownSingle",Wt),r=>({icon:t,id:Te.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},tn=e=>{const t="icon-addDigitsSingle";return e.register(t,Bt),r=>({icon:t,id:Oe.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:M.MenuItemType.BUTTON,positions:[M.MenuPosition.TOOLBAR_START],group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},nn=e=>{const t="icon-reduceDigitsSingle";return e.register(t,Zt),r=>({icon:t,id:we.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},rn=e=>{const t="icon-PercentSingle";return e.register(t,Gt),r=>({icon:t,id:Ae.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},an=e=>{const t="sheet.numfmt.moreNumfmtType",r="sheet.numfmt.moreNumfmtType.options";return e.register(t,Xt),e.register(r,qt),n=>{const a=n.get(u.INumfmtService),s=n.get(ze.FormulaDataModel),i=n.get(c.IUniverInstanceService),o=n.get(c.ICommandService),l=n.get(c.LocaleService),f=n.get(u.SelectionManagerService),m=new x.Observable(d=>x.merge(f.selectionMoveEnd$,new x.Observable(v=>{const h=[u.RemoveNumfmtMutation.id,u.SetNumfmtMutation.id],C=o.onCommandExecuted(_=>{h.includes(_.id)&&v.next(null)});return()=>C.dispose()})).subscribe(()=>{const v=f.getSelections();if(v&&v[0]){const h=i.getCurrentUniverSheetInstance(),C=h.getActiveSheet(),_=v[0].range,g=_.startRow,y=_.startColumn,b=a.getValue(h.getUnitId(),C.getSheetId(),g,y),N=s.getNumfmtValue(h.getUnitId(),C.getSheetId(),g,y),A=(b==null?void 0:b.pattern)||N;let $=l.t("sheet.numfmt.general");if(A){const k=ue.filter(F=>typeof F=="object"&&F.pattern).find(F=>te(A,F.pattern));k&&typeof k=="object"&&k.pattern?$=l.t(k.label):$=l.t("sheet.numfmt.moreFmt")}d.next($)}}));return{label:t,id:ne.id,tooltip:"sheet.numfmt.title",type:M.MenuItemType.SELECTOR,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],selections:[{label:{name:r,hoverable:!1}}],value$:m,hidden$:M.getMenuHiddenObservable(n,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(n)}}};var sn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,cn=(e,t,r,n)=>{for(var a=n>1?void 0:n?on(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&sn(t,r,a),a},ye=(e,t)=>(r,n)=>t(r,n,e);let me=class extends c.Disposable{constructor(e,t,r){super(),this._injector=e,this._componentManager=t,this._menuService=r,this._initMenu()}_initMenu(){[rn,tn,nn,en,an].map(e=>e(this._componentManager)).forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(e(this._injector)))})}};me=cn([c.OnLifecycle(c.LifecycleStages.Rendered,me),ye(0,S.Inject(S.Injector)),ye(1,S.Inject(M.ComponentManager)),ye(2,S.Inject(M.IMenuService))],me);var ln=Object.defineProperty,un=Object.getOwnPropertyDescriptor,mn=(e,t,r,n)=>{for(var a=n>1?void 0:n?un(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&ln(t,r,a),a},W=(e,t)=>(r,n)=>t(r,n,e);const dn=[u.SetNumfmtMutation.id,u.RemoveNumfmtMutation.id];let de=class extends c.Disposable{constructor(e,t,r,n,a,s){super(),this._numfmtService=e,this._univerInstanceService=t,this._injector=r,this._refRangeService=n,this._sheetSkeletonManagerService=a,this._commandService=s,this._registerRefRange(),this._mergeRefMutations()}_mergeRefMutations(){this._refRangeService.interceptor.intercept(this._refRangeService.interceptor.getInterceptPoints().MERGE_REDO,{handler:(e,t,r)=>{if(!e)return r(e);const n=e.filter(a=>!dn.includes(a.id));return n.push(...Q(e)),r(n)}})}_registerRefRange(){this.disposeWithMe(c.toDisposable(x.merge(this._sheetSkeletonManagerService.currentSkeleton$.pipe(P.map(e=>e==null?void 0:e.sheetId),P.distinctUntilChanged()),this._numfmtService.modelReplace$).pipe(P.switchMap(()=>new x.Observable(e=>{const t=new c.DisposableCollection;return e.next(t),()=>{t.dispose()}}))).subscribe(e=>{const r=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),n=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=this._numfmtService.getModel(r,n),s=new Map,i=(o,l,f)=>{const m={startRow:l,startColumn:f,endRow:l,endColumn:f};let d=[];switch(o.id){case u.EffectRefRangId.DeleteRangeMoveLeftCommandId:{d=u.handleDeleteRangeMoveLeft(o,m);break}case u.EffectRefRangId.DeleteRangeMoveUpCommandId:{d=u.handleDeleteRangeMoveUp(o,m);break}case u.EffectRefRangId.InsertColCommandId:{d=u.handleInsertCol(o,m);break}case u.EffectRefRangId.InsertRangeMoveDownCommandId:{d=u.handleInsertRangeMoveDown(o,m);break}case u.EffectRefRangId.InsertRangeMoveRightCommandId:{d=u.handleInsertRangeMoveRight(o,m);break}case u.EffectRefRangId.InsertRowCommandId:{d=u.handleInsertRow(o,m);break}case u.EffectRefRangId.MoveRangeCommandId:{d=u.handleMoveRange(o,m);break}case u.EffectRefRangId.RemoveColCommandId:{d=u.handleIRemoveCol(o,m);break}case u.EffectRefRangId.RemoveRowCommandId:{d=u.handleIRemoveRow(o,m);break}case u.EffectRefRangId.MoveColsCommandId:{d=u.handleMoveCols(o,m);break}case u.EffectRefRangId.MoveRowsCommandId:d=u.handleMoveRows(o,m)}const v=u.runRefRangeMutations(d,m),h=this._numfmtService.getValue(r,n,l,f);if(!v&&h){const C={id:u.RemoveNumfmtMutation.id,params:{unitId:r,subUnitId:n,ranges:[{startColumn:f,startRow:l,endColumn:f,endRow:l}]}},_=u.factoryRemoveNumfmtUndoMutation(this._injector,C.params);return{redos:[C],undos:_}}if(h&&v){const C=[],_=[],g=[{pattern:h.pattern,type:h.type,row:v.startRow,col:v.startColumn}],y={id:u.SetNumfmtMutation.id,params:u.transformCellsToRange(r,n,g)},b=u.factorySetNumfmtUndoMutation(this._injector,y.params),N={id:u.RemoveNumfmtMutation.id,params:{unitId:r,subUnitId:n,ranges:[{startColumn:f,startRow:l,endColumn:f,endRow:l}]}},A=u.factoryRemoveNumfmtUndoMutation(this._injector,N.params);return C.push(y,N),_.push(...b,...A),{redos:C,undos:_.reverse()}}return{redos:[],undos:[]}};a&&a.forValue((o,l)=>{const f={startRow:o,startColumn:l,endRow:o,endColumn:l},m=this._refRangeService.registerRefRange(f,d=>i(d,o,l));s.set(`${o}_${l}`,m),e.add(m)}),e.add(c.toDisposable(new x.Observable(o=>{e.add(this._commandService.onCommandExecuted(l=>{[u.SetNumfmtMutation.id,u.RemoveNumfmtMutation.id].includes(l.id)&&o.next(l.params)}))}).pipe(P.filter(o=>o.unitId===r&&o.subUnitId===n),P.map(o=>o.ranges?o.ranges:o.values?Object.keys(o.values).reduce((l,f)=>{const m=o.values[f];return l.push(...m.ranges),l},[]):[]),P.bufferTime(300),P.map(o=>o.reduce((l,f)=>(l.push(...f),l),[])),P.filter(o=>!!o.length)).subscribe(o=>{o.forEach(l=>{c.Range.foreach(l,(f,m)=>{const d=`${f}_${m}`,v=s.get(d);if(s.delete(d),v&&v.dispose(),this._numfmtService.getValue(r,n,f,m)){const C={startRow:f,startColumn:m,endRow:f,endColumn:m},_=this._refRangeService.registerRefRange(C,g=>i(g,f,m));s.set(d,_),e.add(_)}})})})))})))}};de=mn([c.OnLifecycle(c.LifecycleStages.Rendered,de),W(0,S.Inject(u.INumfmtService)),W(1,S.Inject(c.IUniverInstanceService)),W(2,S.Inject(S.Injector)),W(3,S.Inject(u.RefRangeService)),W(4,S.Inject(O.SheetSkeletonManagerService)),W(5,S.Inject(c.ICommandService))],de);var fn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,hn=(e,t,r,n)=>{for(var a=n>1?void 0:n?vn(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&fn(t,r,a),a},fe=(e,t)=>(r,n)=>t(r,n,e);let ve=class extends c.Disposable{constructor(e,t,r,n){super(),this._numfmtService=e,this._sheetInterceptorService=t,this._univerInstanceService=r,this._injector=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.RemoveSheetCommand.id){const t=e.params,r=t.unitId||gn(this._univerInstanceService),n=t.subUnitId||pn(this._univerInstanceService),a=this._numfmtService.getModel(r,n);if(!a)return{redos:[],undos:[]};const s=[];a.forValue((l,f)=>{s.push({startColumn:f,endColumn:f,startRow:l,endRow:l})});const i={unitId:r,subUnitId:n,ranges:u.rangeMerge(s)},o=u.factoryRemoveNumfmtUndoMutation(this._injector,i);return{redos:[{id:u.RemoveNumfmtMutation.id,params:i}],undos:o}}return{redos:[],undos:[]}}}))}};ve=hn([c.OnLifecycle(c.LifecycleStages.Rendered,ve),fe(0,S.Inject(u.INumfmtService)),fe(1,S.Inject(u.SheetInterceptorService)),fe(2,S.Inject(c.IUniverInstanceService)),fe(3,S.Inject(S.Injector))],ve);const gn=e=>e.getCurrentUniverSheetInstance().getUnitId(),pn=e=>e.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();var Sn=Object.defineProperty,_n=Object.getOwnPropertyDescriptor,Cn=(e,t,r,n)=>{for(var a=n>1?void 0:n?_n(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Sn(t,r,a),a},In=(e,t)=>(r,n)=>t(r,n,e);R.UniverSheetsNumfmtPlugin=(Re=class extends c.Plugin{constructor(t,r){super(G),this._injector=r}onStarting(){this._injector.add([Se,{useClass:se,lazy:!1}]),this._injector.add([ce]),this._injector.add([ae]),this._injector.add([de]),this._injector.add([ve]),this._injector.add([oe]),this._injector.add([q]),this._injector.add([ee]),this._injector.add([le]),this._injector.add([me])}},B(Re,"type",c.PluginType.Sheet),Re),R.UniverSheetsNumfmtPlugin=Cn([In(1,S.Inject(S.Injector))],R.UniverSheetsNumfmtPlugin),R.SetNumfmtCommand=V,R.enUS=Me,R.getPatternPreview=ge,R.zhCN=je,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
9
+ */var et=I,tt=Symbol.for("react.element"),nt=Symbol.for("react.fragment"),rt=Object.prototype.hasOwnProperty,at=et.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0};function Ee(e,t,r){var n,a={},s=null,i=null;r!==void 0&&(s=""+r),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(n in t)rt.call(t,n)&&!st.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)a[n]===void 0&&(a[n]=t[n]);return{$$typeof:tt,type:e,key:s,ref:i,props:a,_owner:at.current}}ae.Fragment=nt,ae.jsx=Ee,ae.jsxs=Ee,De.exports=ae;var S=De.exports;const _e=I.createContext([]),Ce=["$","£","¥","¤","֏","؋","৳","฿","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"];var it=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,ct=(e,t,r,n)=>{for(var a=n>1?void 0:n?ot(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&it(t,r,a),a},lt=(e,t)=>(r,n)=>t(r,n,e);let se=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){const r=this._getKey(e);return this._localStorageService.getItem(r).then(n=>{n||this._localStorageService.setItem(r,t)})}markHabit(e,t){const r=this._getKey(e);this._localStorageService.getItem(r).then(n=>{if(n){const a=n.findIndex(s=>s===t);a>-1&&n.splice(a,1),n.unshift(t),this._localStorageService.setItem(r,n)}})}async getHabit(e,t){const r=this._getKey(e),n=await this._localStorageService.getItem(r);if(t&&n){const a=n.map((s,i,o)=>{const l=o.length;return{value:s,priority:l-i}});return t.sort((s,i)=>{var f,m;const o=((f=a.find(d=>d.value===s))==null?void 0:f.priority)||-1;return(((m=a.find(d=>d.value===i))==null?void 0:m.priority)||-1)-o})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};se=ct([lt(0,p.Inject(c.ILocalStorageService))],se);const xe="numfmtCurrency",ut=e=>{const t=w.useDependency(se),[r,n]=I.useState(Ce);return I.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(xe,[...Ce]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(xe,s)}}},mt=()=>{const e=I.useRef([]),[t,r]=I.useState({});return I.useEffect(()=>{e.current.forEach(a=>{a()}),e.current=[]},[t]),a=>{e.current.push(a),r({})}},Z=e=>Ce.find(r=>e.includes(r)),dt=e=>!!Z(e)&&e.startsWith("_("),ft=e=>{const[t,r]=I.useState(()=>H(e.defaultPattern||"",2)),n=I.useContext(_e),[a,s]=I.useState(()=>Z(e.defaultPattern)||n[0]),i=I.useMemo(()=>n.map(d=>({label:d,value:d})),[]),l=w.useDependency(c.LocaleService).t;e.action.current=()=>T(`_("${a}"* #,##0${t>0?".0":""}_)`,t);const f=d=>{s(d),e.onChange(T(`_("${d}"* #,##0${t>0?".0":""}_)`,t))},m=d=>{const v=d||0;r(v),e.onChange(T(`_("${a}"* #,##0${v>0?".0":""}_)`,v))};return S.jsxs("div",{children:[S.jsxs("div",{className:"m-t-16 options ",children:[S.jsxs("div",{className:"option",children:[S.jsx("div",{className:"label",children:l("sheet.numfmt.decimalLength")}),S.jsx("div",{className:"m-t-8 w-120",children:S.jsx(U.InputNumber,{value:t,max:20,min:0,onChange:m})})]}),S.jsxs("div",{className:"option",children:[S.jsx("div",{className:"label",children:l("sheet.numfmt.currencyType")}),S.jsx("div",{className:"m-t-8 w-140",children:S.jsx(U.Select,{onChange:f,options:i,value:a})})]})]}),S.jsx("div",{className:"describe m-t-14",children:l("sheet.numfmt.accountingDes")})]})},Ie=e=>Pe.map(t=>({label:t.label(e),value:t.suffix(e),color:t.color})),Ue=()=>Xe.map(e=>({label:e.label,value:e.suffix})),Le=()=>qe.map(e=>({label:e.label,value:e.suffix,color:e.color})),vt=e=>!!Z(e)&&!e.startsWith("_("),ht=e=>{const r=w.useDependency(c.LocaleService).t,n=I.useContext(_e),[a,s]=I.useState(()=>Z(e.defaultPattern)||n[0]),[i,o]=I.useState(()=>H(e.defaultPattern||"",2)),[l,f]=I.useState(()=>{var y;const _=Ie(a);return((y=_.find(b=>ne(b.value,e.defaultPattern)))==null?void 0:y.value)||_[0].value}),m=I.useMemo(()=>Ie(a),[a]),d=I.useMemo(()=>n.map(_=>({label:_,value:_})),[n]);e.action.current=()=>T(l,i);const v=_=>{s(_);const g=Ie(_)[0].value;f(g),e.onChange(T(g,i))},h=_=>{f(_),e.onChange(T(_,i))},C=_=>{o(_||0),e.onChange(T(l,_||0))};return S.jsxs("div",{children:[S.jsxs("div",{className:"m-t-16 options ",children:[S.jsxs("div",{className:"option",children:[S.jsx("div",{className:"label",children:r("sheet.numfmt.decimalLength")}),S.jsx("div",{className:"m-t-8 w-120",children:S.jsx(U.InputNumber,{value:i,max:20,min:0,onChange:C})})]}),S.jsxs("div",{className:"option",children:[S.jsx("div",{className:"label",children:r("sheet.numfmt.currencyType")}),S.jsx("div",{className:"m-t-8 w-140",children:S.jsx(U.Select,{onChange:v,options:d,value:a})})]})]}),S.jsx("div",{className:"m-t-16 label",children:r("sheet.numfmt.negType")}),S.jsx("div",{className:"m-t-8",children:S.jsx(U.SelectList,{onChange:h,options:m,value:l})}),S.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.currencyDes")})]})},gt=e=>{const t=L.getInfo(e);return Ue().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)},pt=e=>{const t=I.useMemo(Ue,[]),n=w.useDependency(c.LocaleService).t,[a,s]=I.useState(()=>{if(e.defaultPattern){const o=t.find(l=>l.value===e.defaultPattern);if(o)return o.value}return t[0].value});e.action.current=()=>a;const i=o=>{s(o),e.onChange(o)};return S.jsxs("div",{children:[S.jsx("div",{className:"m-t-16 label",children:n("sheet.numfmt.dateType")}),S.jsx("div",{className:"m-t-8",children:S.jsx(U.SelectList,{value:a,options:t,onChange:i})}),S.jsx("div",{className:"describe m-t-14",children:n("sheet.numfmt.dateDes")})]})},St=e=>!e,_t=e=>{const r=w.useDependency(c.LocaleService).t;return e.action.current=()=>"",S.jsx("div",{children:S.jsx("div",{className:"describe m-t-14",children:r("sheet.numfmt.generalDes")})})},Ct=e=>Le().some(t=>ne(t.value,e)),It=e=>{const t=w.useDependency(c.LocaleService),r=I.useMemo(Le,[]),[n,a]=I.useState(()=>H(e.defaultPattern||"",0)),[s,i]=I.useState(()=>{const d=r.find(v=>ne(v.value,e.defaultPattern||""));return(d==null?void 0:d.value)||r[0].value}),o=I.useMemo(()=>T(s,Number(n||0)),[s,n]),l=I.useMemo(()=>!Qe(s),[s]),f=d=>{a(d||0),e.onChange(T(s,Number(d||0)))},m=d=>{a(H(d,0)),i(d),e.onChange(d)};return e.action.current=()=>o,S.jsxs("div",{children:[S.jsx("div",{className:"m-t-16 label",children:t.t("sheet.numfmt.decimalLength")}),S.jsx("div",{className:"m-t-8",children:S.jsx(U.InputNumber,{disabled:l,value:n,max:20,min:0,onChange:f})}),S.jsxs("div",{className:"m-t-16 label",children:[" ",t.t("sheet.numfmt.negType")]}),S.jsx("div",{className:"m-t-8",children:S.jsx(U.SelectList,{onChange:m,options:r,value:s})}),S.jsx("div",{className:"describe m-t-14",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})},yt=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:a}=e.value,s=w.useDependency(c.LocaleService),i=I.useRef(()=>""),o=s.t,l=mt(),f=I.useMemo(()=>[{label:"sheet.numfmt.general",component:_t},{label:"sheet.numfmt.accounting",component:ft},{label:"sheet.numfmt.currency",component:ht},{label:"sheet.numfmt.date",component:pt},{label:"sheet.numfmt.thousandthPercentile",component:It}].map(j=>({...j,label:o(j.label)})),[]),[m,d]=I.useState(y),[v,h]=I.useState(()=>`${n}_${a}`),{mark:C,userHabitCurrency:_}=ut(()=>h(`${n}_${a}_userCurrency'`)),g=I.useMemo(()=>{var j;return(j=f.find(G=>G.label===m))==null?void 0:j.component},[m]);function y(){return[St,dt,vt,gt,Ct].reduce((G,yn,Rn)=>G||(yn(r)?f[Rn].label:""),"")||f[0].label}const b=f.map(j=>({label:j.label,value:j.label})),N=j=>{d(j),l(()=>e.onChange({type:"change",value:i.current()||""}))},A=j=>{e.onChange({type:"change",value:j})},$=()=>{const j=i.current()||"",G=Z(j);G&&C(G),e.onChange({type:"confirm",value:j})},k=()=>{e.onChange({type:"cancel",value:""})},F={onChange:A,defaultValue:t,defaultPattern:r,action:i};return I.useEffect(()=>{d(y()),h(`${n}_${a}`)},[n,a]),S.jsxs("div",{className:"numfmt-panel p-b-20",children:[S.jsxs("div",{children:[S.jsx("div",{className:"label m-t-14",children:o("sheet.numfmt.numfmtType")}),S.jsx("div",{className:"m-t-8",children:S.jsx(U.Select,{onChange:N,options:b,value:m})}),S.jsx("div",{children:g&&S.jsx(_e.Provider,{value:_,children:I.createElement(g,{...F,key:v})})})]}),S.jsxs("div",{className:"btn-list m-t-14 m-b-20",children:[S.jsx(U.Button,{size:"small",onClick:k,className:"m-r-12",children:o("sheet.numfmt.cancel")}),S.jsx(U.Button,{type:"primary",size:"small",onClick:$,children:o("sheet.numfmt.confirm")})]})]})},Ae={id:"sheet.command.numfmt.set.percent",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(c.ICommandService),n=e.get(u.SelectionManagerService).getSelections();if(!n||!n.length)return!1;const a=[],s="0%";return n.forEach(o=>{c.Range.foreach(o.range,(l,f)=>{a.push({row:l,col:f,pattern:s,type:"percent"})})}),await t.executeCommand(V.id,{values:a})}};var Rt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Mt=(e,t,r,n)=>{for(var a=n>1?void 0:n?bt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Rt(t,r,a),a},D=(e,t)=>(r,n)=>t(r,n,e);let ie=class extends c.Disposable{constructor(t,r,n,a,s,i,o,l,f,m,d,v){super();B(this,"_previewPattern","");B(this,"openPanel",()=>{const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,a=this._univerInstanceService,s=this._numfmtService,i=this._localeService,l=(r.getSelectionRanges()||[])[0];if(!l)return!1;const f=a.getCurrentUniverSheetInstance(),m=f.getActiveSheet(),d=m.getCellRaw(l.startRow,l.startColumn),v=s.getValue(f.getUnitId(),m.getSheetId(),l.startRow,l.startColumn);let h="";v&&(h=v.pattern);const C=(d==null?void 0:d.t)===c.CellValueType.NUMBER?d.v:12345678,_={onChange:g=>{var y,b;if(g.type==="change")this._previewPattern=g.value,this._sheetSkeletonManagerService.reCalculate(),(b=(y=this._renderManagerService.getRenderById(f.getUnitId()))==null?void 0:y.mainComponent)==null||b.makeDirty();else if(g.type==="confirm"){const N=r.getSelectionRanges()||[],A={values:[]},$=ge(g.value);N.forEach(k=>{c.Range.foreach(k,(F,j)=>{A.values.push({row:F,col:j,pattern:g.value,type:$})})}),n.executeCommand(V.id,A),t.close()}else g.type==="cancel"&&t.close()},value:{defaultPattern:h,defaultValue:C,row:l.startRow,col:l.startColumn}};t.open({header:{title:i.t("sheet.numfmt.title")},children:{label:K,..._},onClose:()=>{var g,y;this._sheetSkeletonManagerService.reCalculate(),(y=(g=this._renderManagerService.getRenderById(f.getUnitId()))==null?void 0:g.mainComponent)==null||y.makeDirty(),n.executeCommand(pe.id)}})});this._sheetInterceptorService=t,this._themeService=r,this._injector=n,this._univerInstanceService=a,this._sheetSkeletonManagerService=s,this._commandService=i,this._selectionManagerService=o,this._renderManagerService=l,this._numfmtService=f,this._componentManager=m,this._sidebarService=d,this._localeService=v,this._initInterceptorCommands(),this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._commandExecutedListener()}_initCommands(){[Oe,we,Te,Ae,re,pe,V].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this._componentManager.register(K,yt)}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){switch(r.id){case u.ClearSelectionAllCommand.id:case u.ClearSelectionFormatCommand.id:{const n=t._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=t._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s=t._selectionManagerService.getSelectionRanges();if(!(s!=null&&s.length))break;const i={unitId:n,subUnitId:a,ranges:[]},o=t._numfmtService.getModel(n,a);s.forEach(f=>{c.Range.foreach(f,(m,d)=>{o!=null&&o.getValue(m,d)&&i.ranges.push({startColumn:d,endColumn:d,startRow:m,endRow:m})})}),i.ranges=u.rangeMerge(i.ranges);const l=u.factoryRemoveNumfmtUndoMutation(t._injector,i);return{redos:[{id:u.RemoveNumfmtMutation.id,params:i}],undos:l}}}return{redos:[],undos:[]}}}))}_initRealTimeRenderingInterceptor(){const t=new x.Observable(n=>{this._commandService.onCommandExecuted(a=>{a.id===re.id&&n.next(!0),a.id===pe.id&&n.next(!1)})}),r=x.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(P.map(n=>n?n.map(a=>a.range):[]))]);this.disposeWithMe(c.toDisposable(r.pipe(P.switchMap(([n,a])=>new x.Observable(s=>{const i=new c.DisposableCollection;return n&&a.length&&s.next({selectionRanges:a,disposableCollection:i}),()=>{i.dispose()}})),P.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:a})=>{var i,o;const s=this._univerInstanceService.getCurrentUniverSheetInstance();this.openPanel(),n.add(this._sheetInterceptorService.intercept(u.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,handler:(l,f,m)=>{const{row:d,col:v}=f;if(a.find(h=>h.startColumn<=v&&h.endColumn>=v&&h.startRow<=d&&h.endRow>=d)){const h=f.worksheet.getCellRaw(d,v),C=h==null?void 0:h.v,_=h==null?void 0:h.t;if(C==null||_!==c.CellValueType.NUMBER||this._previewPattern===null)return m(l);const g=ee(this._previewPattern,C,this._localeService.getCurrentLocale());if(g.color){const b=this._themeService.getCurrentTheme()[`${g.color}500`];return{...l,v:g.result,t:c.CellValueType.STRING,s:{cl:{rgb:b}}}}return{...l,v:g.result,t:c.CellValueType.STRING}}return m(l)}})),(o=(i=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:i.mainComponent)==null||o.makeDirty()})))}_commandExecutedListener(){const t=[u.RemoveNumfmtMutation.id,u.SetNumfmtMutation.id];this.disposeWithMe(c.toDisposable(x.merge(new x.Observable(r=>{const n=this._commandService.onCommandExecuted(a=>{if(t.includes(a.id)){const s=a.params;r.next(s.unitId)}});return()=>{n.dispose()}}),this._numfmtService.modelReplace$).pipe(P.debounceTime(16)).subscribe(r=>{var n,a;this._sheetSkeletonManagerService.reCalculate(),(a=(n=this._renderManagerService.getRenderById(r))==null?void 0:n.mainComponent)==null||a.makeDirty()})))}};ie=Mt([c.OnLifecycle(c.LifecycleStages.Rendered,ie),D(0,p.Inject(u.SheetInterceptorService)),D(1,p.Inject(c.ThemeService)),D(2,p.Inject(p.Injector)),D(3,p.Inject(c.IUniverInstanceService)),D(4,p.Inject(O.SheetSkeletonManagerService)),D(5,p.Inject(c.ICommandService)),D(6,p.Inject(u.SelectionManagerService)),D(7,p.Inject(be.IRenderManagerService)),D(8,p.Inject(u.INumfmtService)),D(9,p.Inject(M.ComponentManager)),D(10,p.Inject(M.ISidebarService)),D(11,p.Inject(c.LocaleService))],ie);var jt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,Ot=(e,t,r,n)=>{for(var a=n>1?void 0:n?Nt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&jt(t,r,a),a},oe=(e,t)=>(r,n)=>t(r,n,e);let ce=class extends c.Disposable{constructor(t,r,n,a){super();B(this,"_copyInfo");this._sheetClipboardService=t,this._injector=r,this._numfmtService=n,this._univerInstanceService=a,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:K,onBeforeCopy:(t,r,n)=>this._collectNumfmt(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:s=O.COPY_TYPE.COPY,pasteType:i}=a,{range:o}=t||{},{range:l}=r;return this._generateNumfmtMutations(l,{copyType:s,pasteType:i,copyRange:o})}}))}_collectNumfmt(t,r,n){const a=new c.ObjectMatrix;this._copyInfo={matrix:a,info:{unitId:t,subUnitId:r}};const s=this._numfmtService.getModel(t,r);s&&c.Range.foreach(n,(i,o)=>{const l=this._numfmtService.getValue(t,r,i,o,s);if(!l)return;const f=c.Rectangle.getRelativeRange({startRow:i,endRow:i,startColumn:o,endColumn:o},n);a.setValue(f.startRow,f.startColumn,{pattern:l.pattern,type:l.type})})}_generateNumfmtMutations(t,r){const n=this._univerInstanceService.getCurrentUniverSheetInstance(),a=n.getActiveSheet(),s=n.getUnitId(),i=a.getSheetId();if(r.copyType===O.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([O.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,O.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE].includes(r.pasteType))return{redos:[],undos:[]};const o=O.getRepeatRange(r.copyRange,t,!0),l=[],f={unitId:s,subUnitId:i,ranges:[]},m=this._numfmtService.getModel(s,i);c.Range.foreach(t,(h,C)=>{this._numfmtService.getValue(s,i,h,C,m)&&f.ranges.push({startRow:h,startColumn:C,endRow:h,endColumn:C})}),o.forEach(h=>{this._copyInfo&&this._copyInfo.matrix.forValue((C,_,g)=>{const y=c.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:_,endColumn:_},h.startRange);l.push({row:y.startRow,col:y.startColumn,pattern:g.pattern,type:g.type})})});const d=u.transformCellsToRange(s,i,l);Object.keys(d.values).forEach(h=>{const C=d.values[h];C.ranges=u.rangeMerge(C.ranges)}),f.ranges=u.rangeMerge(f.ranges);const v=[...u.factorySetNumfmtUndoMutation(this._injector,d),...u.factoryRemoveNumfmtUndoMutation(this._injector,f)];return{redos:[{id:u.RemoveNumfmtMutation.id,params:f},{id:u.SetNumfmtMutation.id,params:d}],undos:Q(v)}}};ce=Ot([c.OnLifecycle(c.LifecycleStages.Rendered,ce),oe(0,p.Inject(O.ISheetClipboardService)),oe(1,p.Inject(p.Injector)),oe(2,p.Inject(u.INumfmtService)),oe(3,p.Inject(c.IUniverInstanceService))],ce);var Pt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,wt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Tt(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Pt(t,r,a),a},J=(e,t)=>(r,n)=>t(r,n,e);const Dt=()=>{let e=[];return{add:(a,s,i,o,l)=>e.push({unitId:a,subUnitId:s,row:i,col:o,value:l}),getEffects:()=>e,clean:()=>{e=[]}}};let le=class extends c.Disposable{constructor(t,r,n,a,s){super();B(this,"_collectEffectMutation",Dt());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=a,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const a=r.row,s=r.col,i=this._numfmtService.getValue(r.unitId,r.subUnitId,a,s);if(i)switch(ge(i.pattern)){case"scientific":case"percent":case"currency":case"grouped":case"number":return r.worksheet.getCellRaw(a,s);case"date":case"time":case"datetime":default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(c.toDisposable(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(t,r,n)=>{this._collectEffectMutation.clean();const a=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),s=()=>{a&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,null)};if(!(t!=null&&t.v))return n(t);const i=String(t.v),o=L.parseDate(i)||L.parseTime(i);if(!!o){if(o&&o.z){const f=Number(o.v);return this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{type:"date",pattern:o.z}),{...t,v:f,t:c.CellValueType.NUMBER}}}else(["date","time","datetime"].includes((a==null?void 0:a.type)||"")||!Et(i))&&s();return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){switch(r.id){case u.SetRangeValuesCommand.id:{const n=t._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),a=t._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s=t._collectEffectMutation.getEffects();if(!s.length)return{redos:[],undos:[]};const i=s.filter(m=>{var d;return!!((d=m.value)!=null&&d.pattern)}).map(m=>({row:m.row,col:m.col,pattern:m.value.pattern,type:m.value.type})),o=s.filter(m=>{var d;return!((d=m.value)!=null&&d.pattern)}).map(m=>({startRow:m.row,endColumn:m.col,startColumn:m.col,endRow:m.row})),l=[],f=[];if(i){const m={id:u.SetNumfmtMutation.id,params:u.transformCellsToRange(n,a,i)};l.push(m),f.push(...u.factorySetNumfmtUndoMutation(t._injector,m.params))}if(o){const m={id:u.RemoveNumfmtMutation.id,params:{unitId:n,subUnitId:a,ranges:o}};l.push(m),f.push(...u.factoryRemoveNumfmtUndoMutation(t._injector,m.params))}return{redos:l,undos:f.reverse()}}}return{redos:[],undos:[]}}}))}};le=wt([c.OnLifecycle(c.LifecycleStages.Rendered,le),J(0,p.Inject(u.SheetInterceptorService)),J(1,p.Inject(u.INumfmtService)),J(2,p.Inject(c.IUniverInstanceService)),J(3,p.Inject(p.Injector)),J(4,p.Inject(O.IEditorBridgeService))],le);function Et(e){return/^-?\d+(\.\d+)?$/.test(e)}var xt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Lt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Ut(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&xt(t,r,a),a},At=(e,t)=>(r,n)=>t(r,n,e);let ue=class extends c.Disposable{constructor(t){super();B(this,"_initLocal",()=>{this._localeService.load({zhCN:je,enUS:Me})});this._localeService=t,this._initLocal()}};ue=Lt([c.OnLifecycle(c.LifecycleStages.Rendered,ue),At(0,p.Inject(c.LocaleService))],ue);var E=function(){return E=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},E.apply(this,arguments)},Vt=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},W=I.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,s=e.extend,i=Vt(e,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),l=I.useRef("_".concat(Ft()));return Ve(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},E({ref:t,className:o},i),s)});function Ve(e,t,r,n,a){return I.createElement(e.tag,E(E({key:t},Ht(e,r,a)),n),(kt(e,r).children||[]).map(function(s,i){return Ve(s,"".concat(t,"-").concat(e.tag,"-").concat(i),r,void 0,a)}))}function Ht(e,t,r){var n=E({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var i=s[0],o=s[1];typeof o=="string"&&(n[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function kt(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?E(E({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?E(E({},a),{attrs:E(E({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function Ft(){return Math.random().toString(36).substring(2,8)}W.displayName="UniverIcon";var $t={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.99988 3.60921C3.99988 2.32055 5.04456 1.27588 6.33321 1.27588 7.62187 1.27588 8.66654 2.32055 8.66654 3.60921V6.24136C8.66654 7.53002 7.62187 8.5747 6.33321 8.5747 5.04455 8.5747 3.99988 7.53002 3.99988 6.24136V3.60921zM6.33321 2.60921C5.78093 2.60921 5.33321 3.05693 5.33321 3.60921V6.24136C5.33321 6.79364 5.78093 7.24136 6.33321 7.24136 6.88549 7.24136 7.33321 6.79364 7.33321 6.24136V3.60921C7.33321 3.05693 6.88549 2.60921 6.33321 2.60921zM9.99988 3.60921C9.99988 2.32055 11.0446 1.27588 12.3332 1.27588 13.6219 1.27588 14.6665 2.32055 14.6665 3.60921V6.24136C14.6665 7.53002 13.6219 8.5747 12.3332 8.5747 11.0446 8.5747 9.99988 7.53002 9.99988 6.24136V3.60921zM12.3332 2.60921C11.7809 2.60921 11.3332 3.05693 11.3332 3.60921V6.24136C11.3332 6.79364 11.7809 7.24136 12.3332 7.24136 12.8855 7.24136 13.3332 6.79364 13.3332 6.24136V3.60921C13.3332 3.05693 12.8855 2.60921 12.3332 2.60921z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4713 9.58625C12.211 9.3259 11.7889 9.3259 11.5285 9.58625 11.2682 9.8466 11.2682 10.2687 11.5285 10.5291L12.3904 11.391H6.33329C5.9651 11.391 5.66663 11.6895 5.66663 12.0577 5.66663 12.4258 5.9651 12.7243 6.33329 12.7243H12.3904L11.5285 13.5862C11.2682 13.8466 11.2682 14.2687 11.5285 14.5291 11.7889 14.7894 12.211 14.7894 12.4713 14.5291L14.4669 12.5335C14.4851 12.5156 14.5022 12.4968 14.5183 12.477 14.5484 12.4399 14.5739 12.4003 14.5948 12.359 14.6407 12.2685 14.6666 12.1661 14.6666 12.0577 14.6666 11.9492 14.6407 11.8468 14.5948 11.7563 14.5739 11.715 14.5484 11.6754 14.5183 11.6383 14.5022 11.6185 14.4851 11.5997 14.4669 11.5818L12.4713 9.58625zM1.33325 7.98825C1.33325 7.62006 1.63173 7.32159 1.99992 7.32159H2.33325C2.70144 7.32159 2.99992 7.62006 2.99992 7.98825 2.99992 8.35644 2.70144 8.65492 2.33325 8.65492H1.99992C1.63173 8.65492 1.33325 8.35644 1.33325 7.98825z"}}]},He=I.forwardRef(function(e,t){return I.createElement(W,Object.assign({},e,{id:"add-digits-single",ref:t,icon:$t}))});He.displayName="AddDigitsSingle";const Bt=He;var zt={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"}}]}]},ke=I.forwardRef(function(e,t){return I.createElement(W,Object.assign({},e,{id:"more-down-single",ref:t,icon:zt}))});ke.displayName="MoreDownSingle";const Wt=ke;var Yt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_561_2",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_561_2)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{d:"M4.91876 2.65039C3.66601 2.65039 2.65045 3.66595 2.65045 4.9187 2.65045 6.17146 3.66601 7.18702 4.91876 7.18702 6.17152 7.18702 7.18708 6.17146 7.18708 4.9187 7.18708 3.66595 6.17152 2.65039 4.91876 2.65039zM3.94663 4.9187C3.94663 4.38181 4.38187 3.94657 4.91876 3.94657 5.45566 3.94657 5.8909 4.38181 5.8909 4.9187 5.8909 5.4556 5.45566 5.89084 4.91876 5.89084 4.38187 5.89084 3.94663 5.4556 3.94663 4.9187zM11.0812 8.81299C9.82842 8.81299 8.81286 9.82855 8.81286 11.0813 8.81286 12.3341 9.82842 13.3496 11.0812 13.3496 12.3339 13.3496 13.3495 12.3341 13.3495 11.0813 13.3495 9.82855 12.3339 8.81299 11.0812 8.81299zM10.109 11.0813C10.109 10.5444 10.5443 10.1092 11.0812 10.1092 11.6181 10.1092 12.0533 10.5444 12.0533 11.0813 12.0533 11.6182 11.6181 12.0534 11.0812 12.0534 10.5443 12.0534 10.109 11.6182 10.109 11.0813zM13.1597 2.84021C13.4128 3.09331 13.4128 3.50365 13.1597 3.75675L3.7568 13.1596C3.5037 13.4127 3.09336 13.4127 2.84026 13.1596 2.58717 12.9065 2.58717 12.4962 2.84026 12.2431L12.2431 2.84021C12.4962 2.58712 12.9066 2.58712 13.1597 2.84021z"}}]}]},Fe=I.forwardRef(function(e,t){return I.createElement(W,Object.assign({},e,{id:"percent-single",ref:t,icon:Yt}))});Fe.displayName="PercentSingle";const Gt=Fe;var Kt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5 3.61825C5 2.32958 6.04468 1.28491 7.33333 1.28491C8.62199 1.28491 9.66667 2.32958 9.66667 3.61825V6.30787C9.66667 7.59653 8.62199 8.64121 7.33333 8.64121C6.04468 8.64121 5 7.59653 5 6.30787V3.61825ZM7.33333 2.61825C6.78105 2.61825 6.33333 3.06596 6.33333 3.61825V6.30787C6.33333 6.86015 6.78106 7.30787 7.33333 7.30787C7.88561 7.30787 8.33333 6.86015 8.33333 6.30787V3.61825C8.33333 3.06596 7.88561 2.61825 7.33333 2.61825Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2 7.9745C2 7.60631 2.29848 7.30783 2.66667 7.30783H3C3.36819 7.30783 3.66667 7.60631 3.66667 7.9745 3.66667 8.34269 3.36819 8.64117 3 8.64117H2.66667C2.29848 8.64117 2 8.34269 2 7.9745zM8.80482 9.56197C9.06517 9.82232 9.06517 10.2444 8.80482 10.5048L7.94289 11.3667H13.3334C13.7016 11.3667 14.0001 11.6652 14.0001 12.0334 14.0001 12.4016 13.7016 12.7 13.3334 12.7H7.94289L8.80482 13.562C9.06517 13.8223 9.06517 14.2444 8.80482 14.5048 8.54447 14.7651 8.12236 14.7651 7.86201 14.5048L5.86201 12.5048C5.79809 12.4409 5.74987 12.3672 5.71733 12.2886 5.68474 12.21 5.66675 12.1238 5.66675 12.0334 5.66675 11.943 5.68474 11.8568 5.71733 11.7782 5.74987 11.6996 5.79809 11.6259 5.86201 11.562L7.86201 9.56197C8.12236 9.30162 8.54447 9.30162 8.80482 9.56197z"}}]},$e=I.forwardRef(function(e,t){return I.createElement(W,Object.assign({},e,{id:"reduce-digits-single",ref:t,icon:Kt}))});$e.displayName="ReduceDigitsSingle";const Zt=$e;var Jt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.05443 1.55744C4.34898 1.33653 4.76685 1.39623 4.98776 1.69078L7.99996 5.98276L11.0122 1.69078C11.2331 1.39623 11.6509 1.33653 11.9455 1.55744C12.24 1.77836 12.2997 2.19623 12.0788 2.49078L9.33338 6.42708H12.0788C12.447 6.42708 12.7455 6.72556 12.7455 7.09375C12.7455 7.46194 12.447 7.76042 12.0788 7.76042H8.66659V9.69702H12.3348C12.703 9.69702 13.0015 9.9955 13.0015 10.3637C13.0015 10.7319 12.703 11.0304 12.3348 11.0304H8.66659V13.9091C8.66659 14.2773 8.36811 14.5758 7.99992 14.5758C7.63173 14.5758 7.33325 14.2773 7.33325 13.9091V11.0304H3.66508C3.29689 11.0304 2.99841 10.7319 2.99841 10.3637C2.99841 9.9955 3.29689 9.69702 3.66508 9.69702H7.33325V7.76042H3.92109C3.5529 7.76042 3.25443 7.46194 3.25443 7.09375C3.25443 6.72556 3.5529 6.42708 3.92109 6.42708H6.66653L3.92109 2.49078C3.70018 2.19623 3.75987 1.77836 4.05443 1.55744Z"}}]},Be=I.forwardRef(function(e,t){return I.createElement(W,Object.assign({},e,{id:"rmb-single",ref:t,icon:Jt}))});Be.displayName="RmbSingle";const Qt=Be,me=[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:"@@@"},"|",{label:"sheet.numfmt.number",pattern:"0"},"|",{label:"sheet.numfmt.accounting",pattern:'"¥" #,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:'"¥"#,##0.00_);[Red]("¥"#,##0.00)'},{label:"sheet.numfmt.roundingCurrency",pattern:'"¥"#,##0;[Red]"¥"#,##0'},"|",{label:"sheet.numfmt.date",pattern:"yyyy-mm-dd;@"},{label:"sheet.numfmt.time",pattern:'am/pm h":"mm":"ss'},{label:"sheet.numfmt.dateTime",pattern:"yyyy-m-d am/pm h:mm"},{label:"sheet.numfmt.timeDuration",pattern:"h:mm:ss"},"|",{label:"sheet.numfmt.moreFmt",pattern:""}],Xt=e=>{var n;const t=w.useDependency(c.LocaleService),r=(n=e.value)!=null?n:t.t("sheet.numfmt.general");return S.jsx("span",{className:"more-numfmt-type",children:r})},qt=()=>{const e=w.useDependency(c.ICommandService),t=w.useDependency(c.LocaleService),r=w.useInjector(),n=w.useDependency(u.SelectionManagerService),a=o=>{const l=n.getLast();if(!l)return;const f=r.get(be.ITextSelectionRenderManager),m=l.range,d=[];c.Range.foreach(m,(v,h)=>{o?d.push({row:v,col:h,pattern:o,type:ge(o)}):d.push({row:v,col:h})}),e.executeCommand(V.id,{values:d}),f.focus()},s=o=>{if(o===0)a(null);else if(o===me.length-1)e.executeCommand(re.id);else{const l=me[o];l.pattern&&a(l.pattern)}},i=1220;return S.jsx("div",{className:"more-numfmt-type-options",children:me.map((o,l)=>o==="|"?S.jsx("div",{className:"line m-t-4",onClick:f=>f.stopPropagation()},l):S.jsxs("div",{className:"option-item m-t-4",onClick:()=>{s(l)},children:[S.jsx("div",{children:t.t(o.label)}),S.jsx("div",{className:"m-l-26",children:o.pattern?ee(o.pattern||"",i,t.getCurrentLocale()).result:""})]},l))})},en=e=>{const t="icon-rmbSingle";return e.register(t,Qt),e.register("MoreDownSingle",Wt),r=>({icon:t,id:Te.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},tn=e=>{const t="icon-addDigitsSingle";return e.register(t,Bt),r=>({icon:t,id:Oe.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:M.MenuItemType.BUTTON,positions:[M.MenuPosition.TOOLBAR_START],group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},nn=e=>{const t="icon-reduceDigitsSingle";return e.register(t,Zt),r=>({icon:t,id:we.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},rn=e=>{const t="icon-PercentSingle";return e.register(t,Gt),r=>({icon:t,id:Ae.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:M.MenuItemType.BUTTON,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],hidden$:M.getMenuHiddenObservable(r,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(r)})},an=e=>{const t="sheet.numfmt.moreNumfmtType",r="sheet.numfmt.moreNumfmtType.options";return e.register(t,Xt),e.register(r,qt),n=>{const a=n.get(u.INumfmtService),s=n.get(ze.FormulaDataModel),i=n.get(c.IUniverInstanceService),o=n.get(c.ICommandService),l=n.get(c.LocaleService),f=n.get(u.SelectionManagerService),m=new x.Observable(d=>x.merge(f.selectionMoveEnd$,new x.Observable(v=>{const h=[u.RemoveNumfmtMutation.id,u.SetNumfmtMutation.id],C=o.onCommandExecuted(_=>{h.includes(_.id)&&v.next(null)});return()=>C.dispose()})).subscribe(()=>{const v=f.getSelections();if(v&&v[0]){const h=i.getCurrentUniverSheetInstance(),C=h.getActiveSheet(),_=v[0].range,g=_.startRow,y=_.startColumn,b=a.getValue(h.getUnitId(),C.getSheetId(),g,y),N=s.getNumfmtValue(h.getUnitId(),C.getSheetId(),g,y),A=(b==null?void 0:b.pattern)||N;let $=l.t("sheet.numfmt.general");if(A){const k=me.filter(F=>typeof F=="object"&&F.pattern).find(F=>ne(A,F.pattern));k&&typeof k=="object"&&k.pattern?$=l.t(k.label):$=l.t("sheet.numfmt.moreFmt")}d.next($)}}));return{label:t,id:re.id,tooltip:"sheet.numfmt.title",type:M.MenuItemType.SELECTOR,group:M.MenuGroup.TOOLBAR_FORMULAS_INSERT,positions:[M.MenuPosition.TOOLBAR_START],selections:[{label:{name:r,hoverable:!1}}],value$:m,hidden$:M.getMenuHiddenObservable(n,c.UniverInstanceType.SHEET),disabled$:u.getCurrentSheetDisabled$(n)}}};var sn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,cn=(e,t,r,n)=>{for(var a=n>1?void 0:n?on(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&sn(t,r,a),a},ye=(e,t)=>(r,n)=>t(r,n,e);let de=class extends c.Disposable{constructor(e,t,r){super(),this._injector=e,this._componentManager=t,this._menuService=r,this._initMenu()}_initMenu(){[rn,tn,nn,en,an].map(e=>e(this._componentManager)).forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(e(this._injector)))})}};de=cn([c.OnLifecycle(c.LifecycleStages.Rendered,de),ye(0,p.Inject(p.Injector)),ye(1,p.Inject(M.ComponentManager)),ye(2,p.Inject(M.IMenuService))],de);var ln=Object.defineProperty,un=Object.getOwnPropertyDescriptor,mn=(e,t,r,n)=>{for(var a=n>1?void 0:n?un(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&ln(t,r,a),a},Y=(e,t)=>(r,n)=>t(r,n,e);const dn=[u.SetNumfmtMutation.id,u.RemoveNumfmtMutation.id];let fe=class extends c.Disposable{constructor(e,t,r,n,a,s){super(),this._numfmtService=e,this._univerInstanceService=t,this._injector=r,this._refRangeService=n,this._sheetSkeletonManagerService=a,this._commandService=s,this._registerRefRange(),this._mergeRefMutations()}_mergeRefMutations(){this._refRangeService.interceptor.intercept(this._refRangeService.interceptor.getInterceptPoints().MERGE_REDO,{handler:(e,t,r)=>{if(!e)return r(e);const n=e.filter(a=>!dn.includes(a.id));return n.push(...Q(e)),r(n)}})}_registerRefRange(){this.disposeWithMe(c.toDisposable(x.merge(this._sheetSkeletonManagerService.currentSkeleton$.pipe(P.map(e=>e==null?void 0:e.sheetId),P.distinctUntilChanged()),this._numfmtService.modelReplace$).pipe(P.switchMap(()=>new x.Observable(e=>{const t=new c.DisposableCollection;return e.next(t),()=>{t.dispose()}}))).subscribe(e=>{const r=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),n=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=this._numfmtService.getModel(r,n),s=new Map,i=(o,l,f)=>{const m={startRow:l,startColumn:f,endRow:l,endColumn:f};let d=[];switch(o.id){case u.EffectRefRangId.DeleteRangeMoveLeftCommandId:{d=u.handleDeleteRangeMoveLeft(o,m);break}case u.EffectRefRangId.DeleteRangeMoveUpCommandId:{d=u.handleDeleteRangeMoveUp(o,m);break}case u.EffectRefRangId.InsertColCommandId:{d=u.handleInsertCol(o,m);break}case u.EffectRefRangId.InsertRangeMoveDownCommandId:{d=u.handleInsertRangeMoveDown(o,m);break}case u.EffectRefRangId.InsertRangeMoveRightCommandId:{d=u.handleInsertRangeMoveRight(o,m);break}case u.EffectRefRangId.InsertRowCommandId:{d=u.handleInsertRow(o,m);break}case u.EffectRefRangId.MoveRangeCommandId:{d=u.handleMoveRange(o,m);break}case u.EffectRefRangId.RemoveColCommandId:{d=u.handleIRemoveCol(o,m);break}case u.EffectRefRangId.RemoveRowCommandId:{d=u.handleIRemoveRow(o,m);break}case u.EffectRefRangId.MoveColsCommandId:{d=u.handleMoveCols(o,m);break}case u.EffectRefRangId.MoveRowsCommandId:d=u.handleMoveRows(o,m)}const v=u.runRefRangeMutations(d,m),h=this._numfmtService.getValue(r,n,l,f);if(!v&&h){const C={id:u.RemoveNumfmtMutation.id,params:{unitId:r,subUnitId:n,ranges:[{startColumn:f,startRow:l,endColumn:f,endRow:l}]}},_=u.factoryRemoveNumfmtUndoMutation(this._injector,C.params);return{redos:[C],undos:_}}if(h&&v){const C=[],_=[],g=[{pattern:h.pattern,type:h.type,row:v.startRow,col:v.startColumn}],y={id:u.SetNumfmtMutation.id,params:u.transformCellsToRange(r,n,g)},b=u.factorySetNumfmtUndoMutation(this._injector,y.params),N={id:u.RemoveNumfmtMutation.id,params:{unitId:r,subUnitId:n,ranges:[{startColumn:f,startRow:l,endColumn:f,endRow:l}]}},A=u.factoryRemoveNumfmtUndoMutation(this._injector,N.params);return C.push(y,N),_.push(...b,...A),{redos:C,undos:_.reverse()}}return{redos:[],undos:[]}};a&&a.forValue((o,l)=>{const f={startRow:o,startColumn:l,endRow:o,endColumn:l},m=this._refRangeService.registerRefRange(f,d=>i(d,o,l));s.set(`${o}_${l}`,m),e.add(m)}),e.add(c.toDisposable(new x.Observable(o=>{e.add(this._commandService.onCommandExecuted(l=>{[u.SetNumfmtMutation.id,u.RemoveNumfmtMutation.id].includes(l.id)&&o.next(l.params)}))}).pipe(P.filter(o=>o.unitId===r&&o.subUnitId===n),P.map(o=>o.ranges?o.ranges:o.values?Object.keys(o.values).reduce((l,f)=>{const m=o.values[f];return l.push(...m.ranges),l},[]):[]),P.bufferTime(300),P.map(o=>o.reduce((l,f)=>(l.push(...f),l),[])),P.filter(o=>!!o.length)).subscribe(o=>{o.forEach(l=>{c.Range.foreach(l,(f,m)=>{const d=`${f}_${m}`,v=s.get(d);if(s.delete(d),v&&v.dispose(),this._numfmtService.getValue(r,n,f,m)){const C={startRow:f,startColumn:m,endRow:f,endColumn:m},_=this._refRangeService.registerRefRange(C,g=>i(g,f,m));s.set(d,_),e.add(_)}})})})))})))}};fe=mn([c.OnLifecycle(c.LifecycleStages.Rendered,fe),Y(0,p.Inject(u.INumfmtService)),Y(1,p.Inject(c.IUniverInstanceService)),Y(2,p.Inject(p.Injector)),Y(3,p.Inject(u.RefRangeService)),Y(4,p.Inject(O.SheetSkeletonManagerService)),Y(5,p.Inject(c.ICommandService))],fe);var fn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,hn=(e,t,r,n)=>{for(var a=n>1?void 0:n?vn(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&fn(t,r,a),a},ve=(e,t)=>(r,n)=>t(r,n,e);let he=class extends c.Disposable{constructor(e,t,r,n){super(),this._numfmtService=e,this._sheetInterceptorService=t,this._univerInstanceService=r,this._injector=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.RemoveSheetCommand.id){const t=e.params,r=t.unitId||gn(this._univerInstanceService),n=t.subUnitId||pn(this._univerInstanceService),a=this._numfmtService.getModel(r,n);if(!a)return{redos:[],undos:[]};const s=[];a.forValue((l,f)=>{s.push({startColumn:f,endColumn:f,startRow:l,endRow:l})});const i={unitId:r,subUnitId:n,ranges:u.rangeMerge(s)},o=u.factoryRemoveNumfmtUndoMutation(this._injector,i);return{redos:[{id:u.RemoveNumfmtMutation.id,params:i}],undos:o}}return{redos:[],undos:[]}}}))}};he=hn([c.OnLifecycle(c.LifecycleStages.Rendered,he),ve(0,p.Inject(u.INumfmtService)),ve(1,p.Inject(u.SheetInterceptorService)),ve(2,p.Inject(c.IUniverInstanceService)),ve(3,p.Inject(p.Injector))],he);const gn=e=>e.getCurrentUniverSheetInstance().getUnitId(),pn=e=>e.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();var Sn=Object.defineProperty,_n=Object.getOwnPropertyDescriptor,Cn=(e,t,r,n)=>{for(var a=n>1?void 0:n?_n(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(a=(n?i(t,r,a):i(a))||a);return n&&a&&Sn(t,r,a),a},In=(e,t)=>(r,n)=>t(r,n,e);R.UniverSheetsNumfmtPlugin=(Re=class extends c.Plugin{constructor(t,r){super(K),this._injector=r}onStarting(){this._injector.add([Se,{useClass:ie,lazy:!1}]),this._injector.add([le]),this._injector.add([se]),this._injector.add([fe]),this._injector.add([he]),this._injector.add([ce]),this._injector.add([q]),this._injector.add([te]),this._injector.add([ue]),this._injector.add([de])}},B(Re,"type",c.PluginType.Sheet),Re),R.UniverSheetsNumfmtPlugin=Cn([In(1,p.Inject(p.Injector))],R.UniverSheetsNumfmtPlugin),R.SetNumfmtCommand=V,R.enUS=Me,R.getPatternPreview=ee,R.zhCN=je,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -17,7 +17,9 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/dream-num/univer/issues"
19
19
  },
20
- "keywords": [],
20
+ "keywords": [
21
+ "univer"
22
+ ],
21
23
  "sideEffects": [
22
24
  "**/*.css"
23
25
  ],
@@ -51,39 +53,39 @@
51
53
  "npm": ">=8.0.0"
52
54
  },
53
55
  "peerDependencies": {
54
- "@wendellhu/redi": "^0.13.0",
56
+ "@wendellhu/redi": "0.13.0",
55
57
  "react": ">=16.9.0",
56
58
  "rxjs": ">=7.0.0",
57
- "@univerjs/core": "0.1.2",
58
- "@univerjs/design": "0.1.2",
59
- "@univerjs/engine-formula": "0.1.2",
60
- "@univerjs/engine-numfmt": "0.1.2",
61
- "@univerjs/sheets": "0.1.2",
62
- "@univerjs/engine-render": "0.1.2",
63
- "@univerjs/sheets-ui": "0.1.2",
64
- "@univerjs/ui": "0.1.2"
59
+ "@univerjs/design": "0.1.4",
60
+ "@univerjs/core": "0.1.4",
61
+ "@univerjs/engine-formula": "0.1.4",
62
+ "@univerjs/engine-numfmt": "0.1.4",
63
+ "@univerjs/engine-render": "0.1.4",
64
+ "@univerjs/sheets": "0.1.4",
65
+ "@univerjs/sheets-ui": "0.1.4",
66
+ "@univerjs/ui": "0.1.4"
65
67
  },
66
68
  "dependencies": {
67
- "@univerjs/icons": "^0.1.30"
69
+ "@univerjs/icons": "^0.1.42"
68
70
  },
69
71
  "devDependencies": {
70
- "@types/react": "^18.2.57",
72
+ "@types/react": "^18.2.67",
71
73
  "@wendellhu/redi": "^0.13.0",
72
74
  "less": "^4.2.0",
73
75
  "react": "^18.2.0",
74
76
  "rxjs": "^7.8.1",
75
- "typescript": "^5.3.3",
76
- "vite": "^5.1.4",
77
- "vitest": "^1.3.1",
78
- "@univerjs/core": "0.1.2",
79
- "@univerjs/design": "0.1.2",
80
- "@univerjs/engine-formula": "0.1.2",
81
- "@univerjs/engine-numfmt": "0.1.2",
82
- "@univerjs/engine-render": "0.1.2",
83
- "@univerjs/sheets": "0.1.2",
84
- "@univerjs/sheets-ui": "0.1.2",
85
- "@univerjs/ui": "0.1.2",
86
- "@univerjs/shared": "0.1.2"
77
+ "typescript": "^5.4.2",
78
+ "vite": "^5.1.6",
79
+ "vitest": "^1.4.0",
80
+ "@univerjs/core": "0.1.4",
81
+ "@univerjs/design": "0.1.4",
82
+ "@univerjs/engine-formula": "0.1.4",
83
+ "@univerjs/engine-render": "0.1.4",
84
+ "@univerjs/engine-numfmt": "0.1.4",
85
+ "@univerjs/sheets": "0.1.4",
86
+ "@univerjs/shared": "0.1.4",
87
+ "@univerjs/ui": "0.1.4",
88
+ "@univerjs/sheets-ui": "0.1.4"
87
89
  },
88
90
  "scripts": {
89
91
  "test": "vitest run",