@univerjs/sheets-numfmt-ui 0.15.2 → 0.15.3-insiders.20260131-b9b8805

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var de=Object.defineProperty;var he=(e,t,r)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var A=(e,t,r)=>he(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),ne=require("@univerjs/engine-render"),d=require("@univerjs/sheets-numfmt"),E=require("@univerjs/sheets-ui"),g=require("@univerjs/sheets"),_=require("@univerjs/ui"),j=require("rxjs"),H=require("rxjs/operators"),l=require("react/jsx-runtime"),y=require("react"),T=require("@univerjs/design"),ve=require("@univerjs/engine-formula"),J={};var fe=Object.getOwnPropertyDescriptor,pe=(e,t,r,n)=>{for(var i=n>1?void 0:n?fe(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},U=(e,t)=>(r,n)=>t(r,n,e);const q="SHEET_NUMFMT_ALERT";let z=class extends o.Disposable{constructor(e,t,r,n,i,s,c){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._zenZoneService=i,this._numfmtService=s,this._configService=c,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(j.debounceTime(100)).subscribe(e=>{var t,r;if(e){const n=e.location,i=this._context.unit,s=i.getActiveSheet();if(!s)return this._hideAlert();const c=n.unitId,v=n.subUnitId;let a;const u=s.getCell(n.row,n.col);if(u!=null&&u.s){const h=i.getStyles().get(u.s);h!=null&&h.n&&(a=h.n)}if(a||(a=this._numfmtService.getValue(c,v,n.row,n.col)),!a){this._hideAlert();return}if(o.isTextFormat(a.pattern)&&o.Tools.isDefine(u==null?void 0:u.v)&&o.isRealNum(u.v)){if((t=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&t.disableTextFormatAlert)return;const h=this._cellAlertManagerService.currentAlert.get(q),m=(r=h==null?void 0:h.alert)==null?void 0:r.location;if(m&&m.row===n.row&&m.col===n.col&&m.subUnitId===n.subUnitId&&m.unitId===n.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:E.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:q});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(q)}};z=pe([U(1,o.Inject(E.HoverManagerService)),U(2,o.Inject(E.CellAlertManagerService)),U(3,o.Inject(o.LocaleService)),U(4,_.IZenZoneService),U(5,o.Inject(g.INumfmtService)),U(6,o.IConfigService)],z);const G={id:"sheet.operation.close.numfmt.panel",type:o.CommandType.OPERATION,handler:()=>!0},$={id:"sheet.operation.open.numfmt.panel",type:o.CommandType.OPERATION,handler:e=>(e.get(F).openPanel(),!0)};var ge=Object.getOwnPropertyDescriptor,Se=(e,t,r,n)=>{for(var i=n>1?void 0:n?ge(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},ye=(e,t)=>(r,n)=>t(r,n,e);const X=y.createContext([]);let L=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 i=n.findIndex(s=>s===t);i>-1&&n.splice(i,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 i=n.map((s,c,v)=>{const a=v.length;return{value:s,priority:a-c}});return t.sort((s,c)=>{var u,h;const v=((u=i.find(m=>m.value===s))==null?void 0:u.priority)||-1;return(((h=i.find(m=>m.value===c))==null?void 0:h.priority)||-1)-v})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};L=Se([ye(0,o.Inject(o.ILocalStorageService))],L);const Q="numfmtCurrency",_e=e=>{const t=_.useDependency(L),[r,n]=y.useState(d.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(Q,[...d.currencySymbols]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(Q,s)}}},Ce=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},be=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),Ie=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,s]=y.useState(()=>d.getDecimalFromPattern(t||"",2)),c=y.useContext(X),[v,a]=y.useState(()=>d.getCurrencyType(t)||c[0]),u=y.useMemo(()=>c.map(C=>({label:C,value:C})),[]),m=_.useDependency(o.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${v}"* #,##0${i>0?".0":""}_)`,i);const p=C=>{a(C),n(d.setPatternDecimal(`_("${C}"* #,##0${i>0?".0":""}_)`,i))},S=C=>{const f=C||0;s(f),n(d.setPatternDecimal(`_("${v}"* #,##0${f>0?".0":""}_)`,f))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(T.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(T.Select,{options:u,value:v,onChange:p})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},xe=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),Te=e=>{const r=_.useDependency(o.LocaleService).t,n=y.useContext(X),[i,s]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||n[0]),[c,v]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[a,u]=y.useState(()=>{var b;const f=d.getCurrencyFormatOptions(i);return((b=f.find(N=>o.isPatternEqualWithoutDecimal(N.value,e.defaultPattern)))==null?void 0:b.value)||f[0].value}),h=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>n.map(f=>({label:f,value:f})),[n]);e.action.current=()=>d.setPatternDecimal(a,c);const p=f=>{if(f===void 0)return;s(f);const x=d.getCurrencyFormatOptions(f)[0].value;u(x),e.onChange(d.setPatternDecimal(x,c))},S=f=>{f!==void 0&&(u(f),e.onChange(d.setPatternDecimal(f,c)))},C=f=>{v(f||0),e.onChange(d.setPatternDecimal(a,f||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(T.InputNumber,{value:c,max:20,min:0,onChange:C})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(T.Select,{value:i,options:m,onChange:p})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{value:a,options:h,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};function re({ref:e,...t}){const{icon:r,id:n,className:i,extend:s,...c}=t,v=`univerjs-icon univerjs-icon-${n} ${i||""}`.trim(),a=y.useRef(`_${Pe()}`);return ie(r,`${n}`,{defIds:r.defIds,idSuffix:a.current},{ref:e,className:v,...c},s)}function ie(e,t,r,n,i){return y.createElement(e.tag,{key:t,...Ne(e,r,i),...n},(Ee(e,r).children||[]).map((s,c)=>ie(s,`${t}-${e.tag}-${c}`,r,void 0,i)))}function Ne(e,t,r){const n={...e.attrs};r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(([s,c])=>{s==="mask"&&typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:i}=t;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(([s,c])=>{typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),n}function Ee(e,t){var n;const{defIds:r}=t;return!r||r.length===0?e:e.tag==="defs"&&((n=e.children)!=null&&n.length)?{...e,children:e.children.map(i=>typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?{...i,attrs:{...i.attrs,id:i.attrs.id+t.idSuffix}}:i)}:e}function Pe(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},se=y.forwardRef(function(t,r){return y.createElement(re,Object.assign({},t,{id:"check-mark-icon",ref:r,icon:Me}))});se.displayName="CheckMarkIcon";const K="customFormat",Y="numfmt_custom_pattern";function je(e){const{defaultPattern:t,action:r,onChange:n}=e,i=_.useDependency(L),s=_.useDependency(o.ILocalStorageService),c=_.useDependency(o.LocaleService),[v,a]=y.useState(t);r.current=()=>(i.markHabit(K,v),s.getItem(Y).then((S=[])=>{const C=[...new Set([v,...S||[]])].splice(0,10).filter(f=>!!f);s.setItem(Y,C)}),v);const[u,h]=y.useState([]);y.useEffect(()=>{s.getItem(Y).then(S=>{const C=[...d.CURRENCYFORMAT.map(f=>f.suffix("$")),...d.DATEFMTLISG.map(f=>f.suffix),...d.NUMBERFORMAT.map(f=>f.suffix)];C.push(...S||[]),i.addHabit(K,[]).finally(()=>{i.getHabit(K,C).then(f=>{h([...new Set(f)])})})})},[]);const m=S=>{a(S),n(S)},p=()=>{n(v)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:c.t("sheet.numfmt.customFormat")}),l.jsx(T.Input,{placeholder:c.t("sheet.numfmt.customFormat"),onBlur:p,value:v,onChange:a,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:T.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",T.borderClassName),children:u.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:v===S&&l.jsx(se,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:c.t("sheet.numfmt.customFormatDes")})]})}const Re=e=>{const t=o.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)};function De(e){const{onChange:t,defaultPattern:r}=e,n=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(o.LocaleService),[s,c]=y.useState(()=>{if(r){const a=n.find(u=>u.value===r);if(a)return a.value}return n[0].value});e.action.current=()=>s;const v=a=>{a!==void 0&&(c(a),t(a))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{value:s,options:n,onChange:v})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const we=e=>!e,Ue=e=>{const r=_.useDependency(o.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},Oe=e=>d.getNumberFormatOptions().some(t=>o.isPatternEqualWithoutDecimal(t.value,e));function ke(e){const t=_.useDependency(o.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[n,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[s,c]=y.useState(()=>{const m=r.find(p=>o.isPatternEqualWithoutDecimal(p.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),v=y.useMemo(()=>d.setPatternDecimal(s,Number(n||0)),[s,n]),a=y.useMemo(()=>!d.isPatternHasDecimal(s),[s]),u=m=>{i(m||0),e.onChange(d.setPatternDecimal(s,Number(m||0)))},h=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),c(m),e.onChange(m))};return e.action.current=()=>v,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:t.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.InputNumber,{disabled:a,value:n,max:20,min:0,onChange:u})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",t.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{onChange:h,options:r,value:s})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})}const $e=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,s=_.useDependency(o.LocaleService),c=y.useRef(()=>""),v=s.t,a=Ce(),u=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Ue},{label:"sheet.numfmt.accounting",component:Ie},{label:"sheet.numfmt.currency",component:Te},{label:"sheet.numfmt.date",component:De},{label:"sheet.numfmt.thousandthPercentile",component:ke},{label:"sheet.numfmt.customFormat",component:je}].map(I=>({...I,label:v(I.label)})),[]),[h,m]=y.useState(b),[p,S]=y.useState(()=>`${n}_${i}`),{mark:C,userHabitCurrency:f}=_e(()=>S(`${n}_${i}_userCurrency'`)),x=y.useMemo(()=>{var I;return(I=u.find(w=>w.label===h))==null?void 0:I.component},[h]);function b(){return[we,be,xe,Re,Oe].reduce((w,ue,me)=>w||(ue(r)?u[me].label:""),"")||u[0].label}const N=u.map(I=>({label:I.label,value:I.label})),M=I=>{m(I),a(()=>e.onChange({type:"change",value:c.current()||""}))},R=y.useCallback(I=>{e.onChange({type:"change",value:I})},[]),D=()=>{const I=c.current()||"",w=d.getCurrencyType(I);w&&C(w),e.onChange({type:"confirm",value:I})},O=()=>{e.onChange({type:"cancel",value:""})},V={onChange:R,defaultValue:t,defaultPattern:r,action:c};return y.useEffect(()=>{m(b()),S(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:T.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",T.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:v("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.Select,{className:"univer-w-full",value:h,options:N,onChange:M})}),l.jsx("div",{children:x&&l.jsx(X.Provider,{value:f,children:y.createElement(x,{...V,key:p})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(T.Button,{onClick:O,className:"univer-mr-3",children:v("sheet.numfmt.cancel")}),l.jsx(T.Button,{variant:"primary",onClick:D,children:v("sheet.numfmt.confirm")})]})]})};var Le=Object.getOwnPropertyDescriptor,Fe=(e,t,r,n)=>{for(var i=n>1?void 0:n?Le(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},P=(e,t)=>(r,n)=>t(r,n,e);const ee="SHEET_NUMFMT_PANEL";let F=class extends o.Disposable{constructor(t,r,n,i,s,c,v,a,u,h,m){super();A(this,"_previewPattern","");A(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=s,this._renderManagerService=c,this._numfmtService=v,this._componentManager=a,this._sidebarService=u,this._localeService=h,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(j.merge(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var x;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,s=this._numfmtService,c=this._localeService,a=(((x=r.getCurrentSelections())==null?void 0:x.map(b=>b.range))||[])[0];if(!a)return!1;const u=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),h=u.getActiveSheet();if(!h)return!1;const m=h.getCellRaw(a.startRow,a.startColumn),p=s.getValue(u.getUnitId(),h.getSheetId(),a.startRow,a.startColumn);let S="";p&&(S=p.pattern);const C=(m==null?void 0:m.t)===o.CellValueType.NUMBER?m.v:12345678,f={onChange:b=>{var N;if(b.type==="change")this._previewPattern=b.value,this._forceUpdate();else if(b.type==="confirm"){const M=((N=r.getCurrentSelections())==null?void 0:N.map(O=>O.range))||[],R={values:[]},D=d.getPatternType(b.value);M.forEach(O=>{o.Range.foreach(O,(V,I)=>{R.values.push({row:V,col:I,pattern:b.value,type:D})})}),n.executeCommand(d.SetNumfmtCommand.id,R),t.close()}else b.type==="cancel"&&t.close()},value:{defaultPattern:S,defaultValue:C,row:a.startRow,col:a.startColumn}};return this._sidebarDisposable=t.open({header:{title:c.t("sheet.numfmt.title")},children:{label:ee,...f},onClose:()=>{this._forceUpdate(),n.executeCommand(G.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(E.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[$,G].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this.disposeWithMe(this._componentManager.register(ee,$e))}_initRealTimeRenderingInterceptor(){const t=new j.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===$.id&&n.next(!0),i.id===G.id&&n.next(!1)})}),r=j.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(H.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(o.toDisposable(r.pipe(H.switchMap(([n,i])=>new j.Observable(s=>{const c=new o.DisposableCollection;return n&&i.length&&s.next({selectionRanges:i,disposableCollection:c}),()=>{c.dispose()}})),H.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var c,v;const s=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:o.InterceptorEffectEnum.Value|o.InterceptorEffectEnum.Style,handler:(a,u,h)=>{var C;const{row:m,col:p}=u,S=h(a)||{};if(i.find(f=>f.startColumn<=p&&f.endColumn>=p&&f.startRow<=m&&f.endRow>=m)){const f=u.worksheet.getCellRaw(m,p),x=f==null?void 0:f.v,b=f==null?void 0:f.t;if(x==null||b!==o.CellValueType.NUMBER||this._previewPattern===null)return S;const N=d.getPatternPreviewIgnoreGeneral(this._previewPattern,x,this._sheetsNumfmtCellContentController.locale);if(N.color){const M=(C=this._themeService.getColorFromTheme(`${N.color}.500`))!=null?C:N.color;return{...S,v:N.result,t:o.CellValueType.STRING,s:{cl:{rgb:M}}}}return{...S,v:N.result,t:o.CellValueType.STRING}}return S}})),(v=(c=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:c.mainComponent)==null||v.makeDirty()})))}_commandExecutedListener(){const t=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new j.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const s=i.params;r.next(s.unitId)}});return()=>n.dispose()}).pipe(H.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};F=Fe([P(0,o.Inject(g.SheetInterceptorService)),P(1,o.Inject(o.ThemeService)),P(2,o.IUniverInstanceService),P(3,o.ICommandService),P(4,o.Inject(g.SheetsSelectionsService)),P(5,ne.IRenderManagerService),P(6,g.INumfmtService),P(7,o.Inject(_.ComponentManager)),P(8,_.ISidebarService),P(9,o.Inject(o.LocaleService)),P(10,o.Inject(d.SheetsNumfmtCellContentController))],F);var Ae=Object.getOwnPropertyDescriptor,He=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ae(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},k=(e,t)=>(r,n)=>t(r,n,e);const We=()=>{let e=[];return{add:(i,s,c,v,a)=>e.push({unitId:i,subUnitId:s,row:c,col:v,value:a}),getEffects:()=>e,clean:()=>{e=[]}}};let W=class extends o.Disposable{constructor(t,r,n,i,s){super();A(this,"_collectEffectMutation",We());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,s=r.col,c=this._numfmtService.getValue(r.unitId,r.subUnitId,i,s);if(c)switch(d.getPatternType(c.pattern)){case"scientific":case"currency":case"grouped":case"number":{const a=r.worksheet.getCellRaw(i,s);return(a==null?void 0:a.t)===o.CellValueType.NUMBER&&(a==null?void 0:a.v)!==void 0&&a.v!==null&&o.isRealNum(a.v)&&(a.v=ve.stripErrorMargin(Number(a.v))),n&&n(a)}default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var u,h,m;if(!(t!=null&&t.v)&&!(t!=null&&t.p))return n(t);this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),s=r.worksheet.getCellRaw(r.row,r.col);if(o.isTextFormat(i==null?void 0:i.pattern)||t.t===o.CellValueType.FORCE_STRING)return n(t);const c=(u=t.p)==null?void 0:u.body,v=(m=(h=t==null?void 0:t.p)==null?void 0:h.body)!=null&&m.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),a=o.getNumfmtParseValueFilter(v);if(c)if(Be(c)){const{dataStream:p}=c,S=p.replace(/\r\n$/,""),C=Number(S);if(Number.isNaN(C)&&!a)return n(t)}else return n(t);if(a){if(!a.z&&!(i!=null&&i.pattern)&&(s==null?void 0:s.t)!==o.CellValueType.STRING&&(s==null?void 0:s.t)!==o.CellValueType.FORCE_STRING&&o.willLoseNumericPrecision(v))return n({...t,p:void 0,v,t:o.CellValueType.FORCE_STRING});a.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:a.z});const p=Number(a.v);return n({...t,p:void 0,v:p,t:o.CellValueType.NUMBER})}return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case g.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),s=i.getUnitId(),c=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!c)return{redos:[],undos:[]};const v=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!v.length)return{redos:[],undos:[]};const a=v.filter(p=>{var S;return!!((S=p.value)!=null&&S.pattern)}).map(p=>({row:p.row,col:p.col,pattern:p.value.pattern})),u=v.filter(p=>{var S;return!((S=p.value)!=null&&S.pattern)}).map(p=>({startRow:p.row,endColumn:p.col,startColumn:p.col,endRow:p.row})),h=[],m=[];if(a.length){const p={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(s,c,a)};h.push(p),m.push(...g.factorySetNumfmtUndoMutation(t._injector,p.params))}if(u.length){const p={id:g.RemoveNumfmtMutation.id,params:{unitId:s,subUnitId:c,ranges:u}};h.push(p),m.push(...g.factoryRemoveNumfmtUndoMutation(t._injector,p.params))}return{redos:h,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};W=He([k(0,o.Inject(g.SheetInterceptorService)),k(1,o.Inject(g.INumfmtService)),k(2,o.Inject(o.IUniverInstanceService)),k(3,o.Inject(o.Injector)),k(4,o.Optional(E.IEditorBridgeService))],W);function Be(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,s=["va"];return!(t.some(c=>!!(c.ts&&Object.keys(c.ts).some(a=>s.includes(a))))||r.some(c=>c.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const oe=e=>[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:o.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{label:"sheet.numfmt.accounting",pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.roundingCurrency",pattern:`"${e}"#,##0;[Red]"${e}"#,##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:""}],Ve=e=>({icon:new j.Observable(t=>{const r=e.get(o.LocaleService);return t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon),r.localeChanged$.subscribe(()=>{t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon)})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),qe=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ge=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ye=e=>{const t=e.get(o.IUniverInstanceService),r=e.get(o.ICommandService),n=e.get(o.LocaleService),i=e.get(g.SheetsSelectionsService),s=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],c=E.deriveStateFromActiveSheet$(t,"",({workbook:v,worksheet:a})=>new j.Observable(u=>j.merge(i.selectionMoveEnd$,o.fromCallback(r.onCommandExecuted.bind(r)).pipe(j.filter(([h])=>s.includes(h.id)))).subscribe(()=>{var m,p;const h=i.getCurrentSelections();if(h&&h[0]){const S=h[0].range,C=S.startRow,f=S.startColumn,x=(p=v.getStyles().get((m=a.getCell(C,f))==null?void 0:m.s))==null?void 0:p.n,b=x==null?void 0:x.pattern,N=d.getCurrencySymbolByLocale(n.getCurrentLocale());let M=n.t("sheet.numfmt.general");if(o.isDefaultFormat(b)){u.next(M);return}if(b){const R=oe(N).filter(D=>typeof D=="object"&&D.pattern).find(D=>o.isPatternEqualWithoutDecimal(b,D.pattern));R&&typeof R=="object"&&R.pattern?M=n.t(R.label):M=n.t("sheet.numfmt.moreFmt")}u.next(M)}})));return{label:ce,id:$.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:ae,hoverable:!1,selectable:!1}}],value$:c,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},ce="sheet.numfmt.moreNumfmtType",ae="sheet.numfmt.moreNumfmtType.options";function Ze(e){const{value:t}=e,r=_.useDependency(o.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:n})}function ze(){const e=_.useDependency(o.ICommandService),t=_.useDependency(o.LocaleService),r=_.useDependency(_.ILayoutService),n=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),s=u=>{const h=i.getCurrentLastSelection();if(!h)return;const m=h.range,p=[];o.Range.foreach(m,(S,C)=>{u?p.push({row:S,col:C,pattern:u,type:d.getPatternType(u)}):p.push({row:S,col:C})}),e.executeCommand(d.SetNumfmtCommand.id,{values:p}),r.focus()},c=y.useMemo(()=>{const u=d.localeCurrencySymbolMap.get(t.getCurrentLocale());return oe(u)},[t]),v=u=>{if(u===0)s(null);else if(u===c.length-1)e.executeCommand($.id),r.focus();else{const h=c[u];h.pattern&&s(h.pattern)}},a=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:c.map((u,h)=>u==="|"?l.jsx(T.Separator,{},h):l.jsxs("div",{className:"univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>v(h),children:[l.jsx("span",{children:t.t(u.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",children:u.pattern?d.getPatternPreview(u.pattern||"",a,n.locale).result.trim():""})]},h))})}const Xe={[_.RibbonStartGroup.LAYOUT]:{[$.id]:{order:9,menuItemFactory:Ye},[d.SetPercentCommand.id]:{order:9.1,menuItemFactory:Ke},[d.SetCurrencyCommand.id]:{order:9.2,menuItemFactory:Ve},[d.AddDecimalCommand.id]:{order:9.3,menuItemFactory:qe},[d.SubtractDecimalCommand.id]:{order:9.4,menuItemFactory:Ge}}};var Je=Object.getOwnPropertyDescriptor,Qe=(e,t,r,n)=>{for(var i=n>1?void 0:n?Je(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},te=(e,t)=>(r,n)=>t(r,n,e);let B=class extends o.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Xe),[[ce,Ze],[ae,ze]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};B=Qe([te(0,o.Inject(_.ComponentManager)),te(1,_.IMenuManagerService)],B);var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(e,t,r)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rt=(e,t,r,n)=>{for(var i=n>1?void 0:n?tt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},Z=(e,t)=>(r,n)=>t(r,n,e),le=(e,t,r)=>nt(e,typeof t!="symbol"?t+"":t,r);const it="SHEET_NUMFMT_UI_PLUGIN";exports.UniverSheetsNumfmtUIPlugin=class extends o.Plugin{constructor(t=J,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:s,...c}=o.merge({},J,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",c)}onStarting(){o.registerDependencies(this._injector,[[F],[W],[L],[B]])}onRendered(){this._registerRenderModules(),o.touchDependencies(this._injector,[[F],[W],[B]])}_registerRenderModules(){[[z]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,r))})}};le(exports.UniverSheetsNumfmtUIPlugin,"pluginName",it);le(exports.UniverSheetsNumfmtUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=rt([o.DependentOn(E.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),Z(1,o.Inject(o.Injector)),Z(2,o.IConfigService),Z(3,ne.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
1
+ "use strict";var de=Object.defineProperty;var he=(e,t,r)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var A=(e,t,r)=>he(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),ne=require("@univerjs/engine-render"),d=require("@univerjs/sheets-numfmt"),E=require("@univerjs/sheets-ui"),g=require("@univerjs/sheets"),_=require("@univerjs/ui"),j=require("rxjs"),H=require("rxjs/operators"),l=require("react/jsx-runtime"),y=require("react"),T=require("@univerjs/design"),ve=require("@univerjs/engine-formula"),J={};var fe=Object.getOwnPropertyDescriptor,pe=(e,t,r,n)=>{for(var i=n>1?void 0:n?fe(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},U=(e,t)=>(r,n)=>t(r,n,e);const q="SHEET_NUMFMT_ALERT";let z=class extends o.Disposable{constructor(e,t,r,n,i,s,c){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._zenZoneService=i,this._numfmtService=s,this._configService=c,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(j.debounceTime(100)).subscribe(e=>{var t,r;if(e){const n=e.location,i=this._context.unit,s=i.getActiveSheet();if(!s)return this._hideAlert();const c=n.unitId,v=n.subUnitId;let a;const u=s.getCell(n.row,n.col);if(u!=null&&u.s){const h=i.getStyles().get(u.s);h!=null&&h.n&&(a=h.n)}if(a||(a=this._numfmtService.getValue(c,v,n.row,n.col)),!a){this._hideAlert();return}if(o.isTextFormat(a.pattern)&&o.Tools.isDefine(u==null?void 0:u.v)&&o.isRealNum(u.v)){if((t=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&t.disableTextFormatAlert)return;const h=this._cellAlertManagerService.currentAlert.get(q),m=(r=h==null?void 0:h.alert)==null?void 0:r.location;if(m&&m.row===n.row&&m.col===n.col&&m.subUnitId===n.subUnitId&&m.unitId===n.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:E.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:q});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(q)}};z=pe([U(1,o.Inject(E.HoverManagerService)),U(2,o.Inject(E.CellAlertManagerService)),U(3,o.Inject(o.LocaleService)),U(4,_.IZenZoneService),U(5,o.Inject(g.INumfmtService)),U(6,o.IConfigService)],z);const G={id:"sheet.operation.close.numfmt.panel",type:o.CommandType.OPERATION,handler:()=>!0},$={id:"sheet.operation.open.numfmt.panel",type:o.CommandType.OPERATION,handler:e=>(e.get(F).openPanel(),!0)};var ge=Object.getOwnPropertyDescriptor,Se=(e,t,r,n)=>{for(var i=n>1?void 0:n?ge(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},ye=(e,t)=>(r,n)=>t(r,n,e);const X=y.createContext([]);let L=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 i=n.findIndex(s=>s===t);i>-1&&n.splice(i,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 i=n.map((s,c,v)=>{const a=v.length;return{value:s,priority:a-c}});return t.sort((s,c)=>{var u,h;const v=((u=i.find(m=>m.value===s))==null?void 0:u.priority)||-1;return(((h=i.find(m=>m.value===c))==null?void 0:h.priority)||-1)-v})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};L=Se([ye(0,o.Inject(o.ILocalStorageService))],L);const Q="numfmtCurrency",_e=e=>{const t=_.useDependency(L),[r,n]=y.useState(d.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(Q,[...d.currencySymbols]).then(s=>{n(s),e&&e(s)})})},[]),{userHabitCurrency:r,mark:s=>{t.markHabit(Q,s)}}},Ce=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},be=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),Ie=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,s]=y.useState(()=>d.getDecimalFromPattern(t||"",2)),c=y.useContext(X),[v,a]=y.useState(()=>d.getCurrencyType(t)||c[0]),u=y.useMemo(()=>c.map(C=>({label:C,value:C})),[]),m=_.useDependency(o.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${v}"* #,##0${i>0?".0":""}_)`,i);const p=C=>{a(C),n(d.setPatternDecimal(`_("${C}"* #,##0${i>0?".0":""}_)`,i))},S=C=>{const f=C||0;s(f),n(d.setPatternDecimal(`_("${v}"* #,##0${f>0?".0":""}_)`,f))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(T.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(T.Select,{options:u,value:v,onChange:p})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},xe=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),Te=e=>{const r=_.useDependency(o.LocaleService).t,n=y.useContext(X),[i,s]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||n[0]),[c,v]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[a,u]=y.useState(()=>{var b;const f=d.getCurrencyFormatOptions(i);return((b=f.find(N=>o.isPatternEqualWithoutDecimal(N.value,e.defaultPattern)))==null?void 0:b.value)||f[0].value}),h=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>n.map(f=>({label:f,value:f})),[n]);e.action.current=()=>d.setPatternDecimal(a,c);const p=f=>{if(f===void 0)return;s(f);const x=d.getCurrencyFormatOptions(f)[0].value;u(x),e.onChange(d.setPatternDecimal(x,c))},S=f=>{f!==void 0&&(u(f),e.onChange(d.setPatternDecimal(f,c)))},C=f=>{v(f||0),e.onChange(d.setPatternDecimal(a,f||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(T.InputNumber,{value:c,max:20,min:0,onChange:C})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(T.Select,{value:i,options:m,onChange:p})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{value:a,options:h,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};function re({ref:e,...t}){const{icon:r,id:n,className:i,extend:s,...c}=t,v=`univerjs-icon univerjs-icon-${n} ${i||""}`.trim(),a=y.useRef(`_${Pe()}`);return ie(r,`${n}`,{defIds:r.defIds,idSuffix:a.current},{ref:e,className:v,...c},s)}function ie(e,t,r,n,i){return y.createElement(e.tag,{key:t,...Ne(e,r,i),...n},(Ee(e,r).children||[]).map((s,c)=>ie(s,`${t}-${e.tag}-${c}`,r,void 0,i)))}function Ne(e,t,r){const n={...e.attrs};r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(([s,c])=>{s==="mask"&&typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:i}=t;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(([s,c])=>{typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),n}function Ee(e,t){var n;const{defIds:r}=t;return!r||r.length===0?e:e.tag==="defs"&&((n=e.children)!=null&&n.length)?{...e,children:e.children.map(i=>typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?{...i,attrs:{...i.attrs,id:i.attrs.id+t.idSuffix}}:i)}:e}function Pe(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},se=y.forwardRef(function(t,r){return y.createElement(re,Object.assign({},t,{id:"check-mark-icon",ref:r,icon:Me}))});se.displayName="CheckMarkIcon";const K="customFormat",Y="numfmt_custom_pattern";function je(e){const{defaultPattern:t,action:r,onChange:n}=e,i=_.useDependency(L),s=_.useDependency(o.ILocalStorageService),c=_.useDependency(o.LocaleService),[v,a]=y.useState(t);r.current=()=>(i.markHabit(K,v),s.getItem(Y).then((S=[])=>{const C=[...new Set([v,...S||[]])].splice(0,10).filter(f=>!!f);s.setItem(Y,C)}),v);const[u,h]=y.useState([]);y.useEffect(()=>{s.getItem(Y).then(S=>{const C=[...d.CURRENCYFORMAT.map(f=>f.suffix("$")),...d.DATEFMTLISG.map(f=>f.suffix),...d.NUMBERFORMAT.map(f=>f.suffix)];C.push(...S||[]),i.addHabit(K,[]).finally(()=>{i.getHabit(K,C).then(f=>{h([...new Set(f)])})})})},[]);const m=S=>{a(S),n(S)},p=()=>{n(v)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:c.t("sheet.numfmt.customFormat")}),l.jsx(T.Input,{placeholder:c.t("sheet.numfmt.customFormat"),onBlur:p,value:v,onChange:a,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:T.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",T.borderClassName),children:u.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:v===S&&l.jsx(se,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:c.t("sheet.numfmt.customFormatDes")})]})}const Re=e=>{const t=o.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)};function De(e){const{onChange:t,defaultPattern:r}=e,n=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(o.LocaleService),[s,c]=y.useState(()=>{if(r){const a=n.find(u=>u.value===r);if(a)return a.value}return n[0].value});e.action.current=()=>s;const v=a=>{a!==void 0&&(c(a),t(a))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{value:s,options:n,onChange:v})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const we=e=>!e,Ue=e=>{const r=_.useDependency(o.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},Oe=e=>d.getNumberFormatOptions().some(t=>o.isPatternEqualWithoutDecimal(t.value,e));function ke(e){const t=_.useDependency(o.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[n,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[s,c]=y.useState(()=>{const m=r.find(p=>o.isPatternEqualWithoutDecimal(p.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),v=y.useMemo(()=>d.setPatternDecimal(s,Number(n||0)),[s,n]),a=y.useMemo(()=>!d.isPatternHasDecimal(s),[s]),u=m=>{i(m||0),e.onChange(d.setPatternDecimal(s,Number(m||0)))},h=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),c(m),e.onChange(m))};return e.action.current=()=>v,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:t.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.InputNumber,{disabled:a,value:n,max:20,min:0,onChange:u})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",t.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.SelectList,{onChange:h,options:r,value:s})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})}const $e=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,s=_.useDependency(o.LocaleService),c=y.useRef(()=>""),v=s.t,a=Ce(),u=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Ue},{label:"sheet.numfmt.accounting",component:Ie},{label:"sheet.numfmt.currency",component:Te},{label:"sheet.numfmt.date",component:De},{label:"sheet.numfmt.thousandthPercentile",component:ke},{label:"sheet.numfmt.customFormat",component:je}].map(I=>({...I,label:v(I.label)})),[]),[h,m]=y.useState(b),[p,S]=y.useState(()=>`${n}_${i}`),{mark:C,userHabitCurrency:f}=_e(()=>S(`${n}_${i}_userCurrency'`)),x=y.useMemo(()=>{var I;return(I=u.find(w=>w.label===h))==null?void 0:I.component},[h]);function b(){return[we,be,xe,Re,Oe].reduce((w,ue,me)=>w||(ue(r)?u[me].label:""),"")||u[0].label}const N=u.map(I=>({label:I.label,value:I.label})),M=I=>{m(I),a(()=>e.onChange({type:"change",value:c.current()||""}))},R=y.useCallback(I=>{e.onChange({type:"change",value:I})},[]),D=()=>{const I=c.current()||"",w=d.getCurrencyType(I);w&&C(w),e.onChange({type:"confirm",value:I})},O=()=>{e.onChange({type:"cancel",value:""})},V={onChange:R,defaultValue:t,defaultPattern:r,action:c};return y.useEffect(()=>{m(b()),S(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:T.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",T.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:v("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(T.Select,{className:"univer-w-full",value:h,options:N,onChange:M})}),l.jsx("div",{children:x&&l.jsx(X.Provider,{value:f,children:y.createElement(x,{...V,key:p})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(T.Button,{onClick:O,className:"univer-mr-3",children:v("sheet.numfmt.cancel")}),l.jsx(T.Button,{variant:"primary",onClick:D,children:v("sheet.numfmt.confirm")})]})]})};var Le=Object.getOwnPropertyDescriptor,Fe=(e,t,r,n)=>{for(var i=n>1?void 0:n?Le(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},P=(e,t)=>(r,n)=>t(r,n,e);const ee="SHEET_NUMFMT_PANEL";let F=class extends o.Disposable{constructor(t,r,n,i,s,c,v,a,u,h,m){super();A(this,"_previewPattern","");A(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=s,this._renderManagerService=c,this._numfmtService=v,this._componentManager=a,this._sidebarService=u,this._localeService=h,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(j.merge(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var x;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,s=this._numfmtService,c=this._localeService,a=(((x=r.getCurrentSelections())==null?void 0:x.map(b=>b.range))||[])[0];if(!a)return!1;const u=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),h=u.getActiveSheet();if(!h)return!1;const m=h.getCellRaw(a.startRow,a.startColumn),p=s.getValue(u.getUnitId(),h.getSheetId(),a.startRow,a.startColumn);let S="";p&&(S=p.pattern);const C=(m==null?void 0:m.t)===o.CellValueType.NUMBER?m.v:12345678,f={onChange:b=>{var N;if(b.type==="change")this._previewPattern=b.value,this._forceUpdate();else if(b.type==="confirm"){const M=((N=r.getCurrentSelections())==null?void 0:N.map(O=>O.range))||[],R={values:[]},D=d.getPatternType(b.value);M.forEach(O=>{o.Range.foreach(O,(V,I)=>{R.values.push({row:V,col:I,pattern:b.value,type:D})})}),n.executeCommand(d.SetNumfmtCommand.id,R),t.close()}else b.type==="cancel"&&t.close()},value:{defaultPattern:S,defaultValue:C,row:a.startRow,col:a.startColumn}};return this._sidebarDisposable=t.open({header:{title:c.t("sheet.numfmt.title")},children:{label:ee,...f},onClose:()=>{this._forceUpdate(),n.executeCommand(G.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(E.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[$,G].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this.disposeWithMe(this._componentManager.register(ee,$e))}_initRealTimeRenderingInterceptor(){const t=new j.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===$.id&&n.next(!0),i.id===G.id&&n.next(!1)})}),r=j.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(H.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(o.toDisposable(r.pipe(H.switchMap(([n,i])=>new j.Observable(s=>{const c=new o.DisposableCollection;return n&&i.length&&s.next({selectionRanges:i,disposableCollection:c}),()=>{c.dispose()}})),H.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var c,v;const s=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:o.InterceptorEffectEnum.Value|o.InterceptorEffectEnum.Style,handler:(a,u,h)=>{var C;const{row:m,col:p}=u,S=h(a)||{};if(i.find(f=>f.startColumn<=p&&f.endColumn>=p&&f.startRow<=m&&f.endRow>=m)){const f=u.worksheet.getCellRaw(m,p),x=f==null?void 0:f.v,b=f==null?void 0:f.t;if(x==null||b!==o.CellValueType.NUMBER||this._previewPattern===null)return S;const N=d.getPatternPreviewIgnoreGeneral(this._previewPattern,x,this._sheetsNumfmtCellContentController.locale);if(N.color){const M=(C=this._themeService.getColorFromTheme(`${N.color}.500`))!=null?C:N.color;return{...S,v:N.result,t:o.CellValueType.STRING,s:{cl:{rgb:M}}}}return{...S,v:N.result,t:o.CellValueType.STRING}}return S}})),(v=(c=this._renderManagerService.getRenderById(s.getUnitId()))==null?void 0:c.mainComponent)==null||v.makeDirty()})))}_commandExecutedListener(){const t=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new j.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const s=i.params;r.next(s.unitId)}});return()=>n.dispose()}).pipe(H.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};F=Fe([P(0,o.Inject(g.SheetInterceptorService)),P(1,o.Inject(o.ThemeService)),P(2,o.IUniverInstanceService),P(3,o.ICommandService),P(4,o.Inject(g.SheetsSelectionsService)),P(5,ne.IRenderManagerService),P(6,g.INumfmtService),P(7,o.Inject(_.ComponentManager)),P(8,_.ISidebarService),P(9,o.Inject(o.LocaleService)),P(10,o.Inject(d.SheetsNumfmtCellContentController))],F);var Ae=Object.getOwnPropertyDescriptor,He=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ae(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},k=(e,t)=>(r,n)=>t(r,n,e);const We=()=>{let e=[];return{add:(i,s,c,v,a)=>e.push({unitId:i,subUnitId:s,row:c,col:v,value:a}),getEffects:()=>e,clean:()=>{e=[]}}};let W=class extends o.Disposable{constructor(t,r,n,i,s){super();A(this,"_collectEffectMutation",We());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=s,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,s=r.col,c=this._numfmtService.getValue(r.unitId,r.subUnitId,i,s);if(c)switch(d.getPatternType(c.pattern)){case"scientific":case"currency":case"grouped":case"number":{const a=r.worksheet.getCellRaw(i,s);return(a==null?void 0:a.t)===o.CellValueType.NUMBER&&(a==null?void 0:a.v)!==void 0&&a.v!==null&&o.isRealNum(a.v)&&(a.v=ve.stripErrorMargin(Number(a.v))),n&&n(a)}default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(o.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var u,h,m;if(!(t!=null&&t.v)&&!(t!=null&&t.p))return n(t);this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),s=r.worksheet.getCellRaw(r.row,r.col);if(o.isTextFormat(i==null?void 0:i.pattern)||t.t===o.CellValueType.FORCE_STRING)return n(t);const c=(u=t.p)==null?void 0:u.body,v=(m=(h=t==null?void 0:t.p)==null?void 0:h.body)!=null&&m.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),a=o.getNumfmtParseValueFilter(v);if(c)if(Be(c)){const{dataStream:p}=c,S=p.replace(/\r\n$/,""),C=Number(S);if(Number.isNaN(C)&&!a)return n(t)}else return n(t);if(a){if(!a.z&&!(i!=null&&i.pattern)&&(s==null?void 0:s.t)!==o.CellValueType.STRING&&(s==null?void 0:s.t)!==o.CellValueType.FORCE_STRING&&o.willLoseNumericPrecision(v))return n({...t,p:void 0,v,t:o.CellValueType.FORCE_STRING});a.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:a.z});const p=Number(a.v);return n({...t,p:void 0,v:p,t:o.CellValueType.NUMBER})}return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case g.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),s=i.getUnitId(),c=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!c)return{redos:[],undos:[]};const v=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!v.length)return{redos:[],undos:[]};const a=v.filter(p=>{var S;return!!((S=p.value)!=null&&S.pattern)}).map(p=>({row:p.row,col:p.col,pattern:p.value.pattern})),u=v.filter(p=>{var S;return!((S=p.value)!=null&&S.pattern)}).map(p=>({startRow:p.row,endColumn:p.col,startColumn:p.col,endRow:p.row})),h=[],m=[];if(a.length){const p={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(s,c,a)};h.push(p),m.push(...g.factorySetNumfmtUndoMutation(t._injector,p.params))}if(u.length){const p={id:g.RemoveNumfmtMutation.id,params:{unitId:s,subUnitId:c,ranges:u}};h.push(p),m.push(...g.factoryRemoveNumfmtUndoMutation(t._injector,p.params))}return{redos:h,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};W=He([k(0,o.Inject(g.SheetInterceptorService)),k(1,o.Inject(g.INumfmtService)),k(2,o.Inject(o.IUniverInstanceService)),k(3,o.Inject(o.Injector)),k(4,o.Optional(E.IEditorBridgeService))],W);function Be(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,s=["va"];return!(t.some(c=>!!(c.ts&&Object.keys(c.ts).some(a=>s.includes(a))))||r.some(c=>c.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const oe=e=>[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:o.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{label:"sheet.numfmt.accounting",pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.roundingCurrency",pattern:`"${e}"#,##0;[Red]"${e}"#,##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:""}],Ve=e=>({icon:new j.Observable(t=>{const r=e.get(o.LocaleService);return t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon),r.localeChanged$.subscribe(()=>{t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon)})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),qe=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ge=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ke=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ye=e=>{const t=e.get(o.IUniverInstanceService),r=e.get(o.ICommandService),n=e.get(o.LocaleService),i=e.get(g.SheetsSelectionsService),s=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],c=E.deriveStateFromActiveSheet$(t,"",({workbook:v,worksheet:a})=>new j.Observable(u=>j.merge(i.selectionMoveEnd$,o.fromCallback(r.onCommandExecuted.bind(r)).pipe(j.filter(([h])=>s.includes(h.id)))).subscribe(()=>{var m,p;const h=i.getCurrentSelections();if(h&&h[0]){const S=h[0].range,C=S.startRow,f=S.startColumn,x=(p=v.getStyles().get((m=a.getCell(C,f))==null?void 0:m.s))==null?void 0:p.n,b=x==null?void 0:x.pattern,N=d.getCurrencySymbolByLocale(n.getCurrentLocale());let M=n.t("sheet.numfmt.general");if(o.isDefaultFormat(b)){u.next(M);return}if(b){const R=oe(N).filter(D=>typeof D=="object"&&D.pattern).find(D=>o.isPatternEqualWithoutDecimal(b,D.pattern));R&&typeof R=="object"&&R.pattern?M=n.t(R.label):M=n.t("sheet.numfmt.moreFmt")}u.next(M)}})));return{label:ce,id:$.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:ae,hoverable:!1,selectable:!1}}],value$:c,hidden$:_.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},ce="sheet.numfmt.moreNumfmtType",ae="sheet.numfmt.moreNumfmtType.options";function Ze(e){const{value:t}=e,r=_.useDependency(o.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:n})}function ze(){const e=_.useDependency(o.ICommandService),t=_.useDependency(o.LocaleService),r=_.useDependency(_.ILayoutService),n=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),s=u=>{const h=i.getCurrentLastSelection();if(!h)return;const m=h.range,p=[];o.Range.foreach(m,(S,C)=>{u?p.push({row:S,col:C,pattern:u,type:d.getPatternType(u)}):p.push({row:S,col:C})}),e.executeCommand(d.SetNumfmtCommand.id,{values:p}),r.focus()},c=y.useMemo(()=>{const u=d.localeCurrencySymbolMap.get(t.getCurrentLocale());return oe(u)},[t]),v=u=>{if(u===0)s(null);else if(u===c.length-1)e.executeCommand($.id),r.focus();else{const h=c[u];h.pattern&&s(h.pattern)}},a=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:c.map((u,h)=>u==="|"?l.jsx(T.Separator,{},h):l.jsxs("div",{className:"univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>v(h),children:[l.jsx("span",{children:t.t(u.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",children:u.pattern?d.getPatternPreview(u.pattern||"",a,n.locale).result.trim():""})]},h))})}const Xe={[_.RibbonStartGroup.LAYOUT]:{[$.id]:{order:9,menuItemFactory:Ye},[d.SetPercentCommand.id]:{order:9.1,menuItemFactory:Ke},[d.SetCurrencyCommand.id]:{order:9.2,menuItemFactory:Ve},[d.AddDecimalCommand.id]:{order:9.3,menuItemFactory:qe},[d.SubtractDecimalCommand.id]:{order:9.4,menuItemFactory:Ge}}};var Je=Object.getOwnPropertyDescriptor,Qe=(e,t,r,n)=>{for(var i=n>1?void 0:n?Je(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},te=(e,t)=>(r,n)=>t(r,n,e);let B=class extends o.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Xe),[[ce,Ze],[ae,ze]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};B=Qe([te(0,o.Inject(_.ComponentManager)),te(1,_.IMenuManagerService)],B);var et=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,nt=(e,t,r)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rt=(e,t,r,n)=>{for(var i=n>1?void 0:n?tt(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=c(i)||i);return i},Z=(e,t)=>(r,n)=>t(r,n,e),le=(e,t,r)=>nt(e,typeof t!="symbol"?t+"":t,r);const it="SHEET_NUMFMT_UI_PLUGIN";exports.UniverSheetsNumfmtUIPlugin=class extends o.Plugin{constructor(t=J,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:s,...c}=o.merge({},J,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",c)}onStarting(){o.registerDependencies(this._injector,[[F],[W],[L],[B]])}onRendered(){this._registerRenderModules(),o.touchDependencies(this._injector,[[F],[W],[B]])}_registerRenderModules(){[[z]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,r))})}};le(exports.UniverSheetsNumfmtUIPlugin,"pluginName",it);le(exports.UniverSheetsNumfmtUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNumfmtUIPlugin=rt([o.DependentOn(E.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),Z(1,o.Inject(o.Injector)),Z(2,o.IConfigService),Z(3,ne.IRenderManagerService)],exports.UniverSheetsNumfmtUIPlugin);
@@ -0,0 +1 @@
1
+ "use strict";const e={sheet:{numfmt:{title:"Formát čísla",numfmtType:"Typy formátov",cancel:"Zrušiť",confirm:"Potvrdiť",general:"Všeobecný",accounting:"Účtovnícky",text:"Text",number:"Číslo",percent:"Percento",scientific:"Vedecký",currency:"Mena",date:"Dátum",time:"Čas",thousandthPercentile:"Oddeľovač tisícov",preview:"Náhľad",dateTime:"Dátum a čas",decimalLength:"Počet desatinných miest",currencyType:"Symbol meny",moreFmt:"Formáty",financialValue:"Finančná hodnota",roundingCurrency:"Zaokrúhľovanie meny",timeDuration:"Trvanie",currencyDes:"Formát meny sa používa na zobrazenie bežných menových hodnôt. Účtovnícky formát zarovná stĺpec hodnôt podľa desatinných miest.",accountingDes:"Účtovnícky formát čísiel zarovná stĺpec hodnôt so symbolmi meny a desatinnými miestami.",dateType:"Typ dátumu",dateDes:"Formát dátumu zobrazuje hodnoty dátumu a času ako dátumy.",negType:"Typ záporného čísla",generalDes:"Všeobecný formát neobsahuje žiadny špecifický formát čísla.",thousandthPercentileDes:"Percentilný formát sa používa na reprezentáciu bežných čísel. Menové a účtovnícke formáty poskytujú špecializovaný formát pre výpočty menových hodnôt.",addDecimal:"Zvýšiť počet desatinných miest",subtractDecimal:"Znížiť počet desatinných miest",customFormat:"Vlastný formát",customFormatDes:"Vytvorte vlastné formáty čísiel na základe existujúcich formátov."}}};module.exports=e;
package/lib/es/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  var ut = Object.defineProperty;
2
2
  var mt = (e, t, r) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var X = (e, t, r) => mt(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Inject as C, LocaleService as E, IConfigService as ke, Disposable as te, isTextFormat as Ue, Tools as dt, isRealNum as De, CommandType as Fe, ILocalStorageService as Le, isPatternEqualWithoutDecimal as ne, numfmt as ht, ThemeService as vt, IUniverInstanceService as he, ICommandService as ve, UniverInstanceType as T, CellValueType as P, toDisposable as me, DisposableCollection as ft, InterceptorEffectEnum as Te, Range as Ae, Injector as He, Optional as pt, getNumfmtParseValueFilter as gt, willLoseNumericPrecision as _t, fromCallback as St, isDefaultFormat as Ct, DEFAULT_TEXT_FORMAT_EXCEL as yt, DependentOn as bt, Plugin as It, merge as Nt, registerDependencies as Et, touchDependencies as Tt } from "@univerjs/core";
4
+ import { Inject as C, LocaleService as E, Disposable as te, isTextFormat as ke, Tools as dt, isRealNum as Ue, IConfigService as De, CommandType as Fe, ILocalStorageService as Le, isPatternEqualWithoutDecimal as ne, numfmt as ht, ThemeService as vt, UniverInstanceType as T, CellValueType as P, toDisposable as me, DisposableCollection as ft, InterceptorEffectEnum as Te, Range as Ae, IUniverInstanceService as he, ICommandService as ve, Injector as He, Optional as pt, getNumfmtParseValueFilter as gt, willLoseNumericPrecision as _t, fromCallback as St, isDefaultFormat as Ct, DEFAULT_TEXT_FORMAT_EXCEL as yt, DependentOn as bt, Plugin as It, merge as Nt, registerDependencies as Et, touchDependencies as Tt } from "@univerjs/core";
5
5
  import { IRenderManagerService as je } from "@univerjs/engine-render";
6
6
  import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Mt, currencySymbols as Me, getDecimalFromPattern as q, getCurrencyType as B, setPatternDecimal as $, getCurrencyFormatOptions as se, CURRENCYFORMAT as wt, DATEFMTLISG as Pt, NUMBERFORMAT as xt, getDateFormatOptions as Be, getNumberFormatOptions as Ve, isPatternHasDecimal as Rt, SheetsNumfmtCellContentController as We, getPatternPreviewIgnoreGeneral as $t, getPatternType as fe, SetNumfmtCommand as Ge, SubtractDecimalCommand as Ke, AddDecimalCommand as Ye, SetCurrencyCommand as Ze, getCurrencySymbolIconByLocale as we, SetPercentCommand as ze, getCurrencySymbolByLocale as Ot, localeCurrencySymbolMap as kt, getPatternPreview as Ut, UniverSheetsNumfmtPlugin as Dt } from "@univerjs/sheets-numfmt";
7
7
  import { HoverManagerService as Ft, CellAlertManagerService as Lt, CellAlertType as At, SheetSkeletonManagerService as Ht, IEditorBridgeService as jt, getCurrentRangeDisable$ as V, deriveStateFromActiveSheet$ as Bt, UniverSheetsUIPlugin as Vt } from "@univerjs/sheets-ui";
8
8
  import { INumfmtService as pe, SheetInterceptorService as Xe, SheetsSelectionsService as ge, INTERCEPTOR_POINT as Wt, RemoveNumfmtMutation as _e, SetNumfmtMutation as Se, BEFORE_CELL_EDIT as Gt, AFTER_CELL_EDIT as Kt, SetRangeValuesCommand as Yt, transformCellsToRange as Zt, factorySetNumfmtUndoMutation as zt, factoryRemoveNumfmtUndoMutation as Xt, RangeProtectionPermissionEditPoint as W, WorksheetEditPermission as G, WorksheetSetCellStylePermission as K, WorkbookEditablePermission as Y } from "@univerjs/sheets";
9
- import { IZenZoneService as qt, useDependency as b, ComponentManager as qe, ISidebarService as Jt, getMenuHiddenObservable as Z, MenuItemType as z, ILayoutService as Qt, RibbonStartGroup as en, IMenuManagerService as tn } from "@univerjs/ui";
9
+ import { IZenZoneService as qt, useDependency as b, ComponentManager as qe, ISidebarService as Jt, MenuItemType as Z, getMenuHiddenObservable as z, ILayoutService as Qt, RibbonStartGroup as en, IMenuManagerService as tn } from "@univerjs/ui";
10
10
  import { debounceTime as nn, merge as Je, Observable as L, combineLatest as rn, filter as sn } from "rxjs";
11
11
  import { map as on, switchMap as cn, tap as an, debounceTime as ln } from "rxjs/operators";
12
12
  import { jsxs as y, jsx as h } from "react/jsx-runtime";
@@ -44,7 +44,7 @@ let de = class extends te {
44
44
  this._hideAlert();
45
45
  return;
46
46
  }
47
- if (Ue(c.pattern) && dt.isDefine(a == null ? void 0 : a.v) && De(a.v)) {
47
+ if (ke(c.pattern) && dt.isDefine(a == null ? void 0 : a.v) && Ue(a.v)) {
48
48
  if ((t = this._configService.getConfig(Mt)) != null && t.disableTextFormatAlert)
49
49
  return;
50
50
  const u = this._cellAlertManagerService.currentAlert.get(oe), l = (r = u == null ? void 0 : u.alert) == null ? void 0 : r.location;
@@ -82,7 +82,7 @@ de = Sn([
82
82
  U(3, C(E)),
83
83
  U(4, qt),
84
84
  U(5, C(pe)),
85
- U(6, ke)
85
+ U(6, De)
86
86
  ], de);
87
87
  const ce = {
88
88
  id: "sheet.operation.close.numfmt.panel",
@@ -758,7 +758,7 @@ let J = class extends te {
758
758
  case "grouped":
759
759
  case "number": {
760
760
  const c = r.worksheet.getCellRaw(i, s);
761
- return (c == null ? void 0 : c.t) === P.NUMBER && (c == null ? void 0 : c.v) !== void 0 && c.v !== null && De(c.v) && (c.v = gn(Number(c.v))), n && n(c);
761
+ return (c == null ? void 0 : c.t) === P.NUMBER && (c == null ? void 0 : c.v) !== void 0 && c.v !== null && Ue(c.v) && (c.v = gn(Number(c.v))), n && n(c);
762
762
  }
763
763
  default:
764
764
  return n && n(t);
@@ -791,7 +791,7 @@ let J = class extends te {
791
791
  r.row,
792
792
  r.col
793
793
  ), s = r.worksheet.getCellRaw(r.row, r.col);
794
- if (Ue(i == null ? void 0 : i.pattern) || t.t === P.FORCE_STRING)
794
+ if (ke(i == null ? void 0 : i.pattern) || t.t === P.FORCE_STRING)
795
795
  return n(t);
796
796
  const o = (a = t.p) == null ? void 0 : a.body, m = (l = (u = t == null ? void 0 : t.p) == null ? void 0 : u.body) != null && l.dataStream ? t.p.body.dataStream.replace(/\r\n$/, "") : String(t.v), c = gt(m);
797
797
  if (o)
@@ -981,32 +981,32 @@ const it = (e) => [
981
981
  id: Ze.id,
982
982
  title: "sheet.numfmt.currency",
983
983
  tooltip: "sheet.numfmt.currency",
984
- type: z.BUTTON,
985
- hidden$: Z(e, T.UNIVER_SHEET),
984
+ type: Z.BUTTON,
985
+ hidden$: z(e, T.UNIVER_SHEET),
986
986
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
987
987
  }), Zn = (e) => ({
988
988
  icon: "AddDigitsIcon",
989
989
  id: Ye.id,
990
990
  title: "sheet.numfmt.addDecimal",
991
991
  tooltip: "sheet.numfmt.addDecimal",
992
- type: z.BUTTON,
993
- hidden$: Z(e, T.UNIVER_SHEET),
992
+ type: Z.BUTTON,
993
+ hidden$: z(e, T.UNIVER_SHEET),
994
994
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
995
995
  }), zn = (e) => ({
996
996
  icon: "ReduceDigitsIcon",
997
997
  id: Ke.id,
998
998
  title: "sheet.numfmt.subtractDecimal",
999
999
  tooltip: "sheet.numfmt.subtractDecimal",
1000
- type: z.BUTTON,
1001
- hidden$: Z(e, T.UNIVER_SHEET),
1000
+ type: Z.BUTTON,
1001
+ hidden$: z(e, T.UNIVER_SHEET),
1002
1002
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
1003
1003
  }), Xn = (e) => ({
1004
1004
  icon: "PercentIcon",
1005
1005
  id: ze.id,
1006
1006
  title: "sheet.numfmt.percent",
1007
1007
  tooltip: "sheet.numfmt.percent",
1008
- type: z.BUTTON,
1009
- hidden$: Z(e, T.UNIVER_SHEET),
1008
+ type: Z.BUTTON,
1009
+ hidden$: z(e, T.UNIVER_SHEET),
1010
1010
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
1011
1011
  }), qn = (e) => {
1012
1012
  const t = e.get(he), r = e.get(ve), n = e.get(E), i = e.get(ge), s = [_e.id, Se.id], o = Bt(
@@ -1043,7 +1043,7 @@ const it = (e) => [
1043
1043
  label: st,
1044
1044
  id: A.id,
1045
1045
  tooltip: "sheet.numfmt.title",
1046
- type: z.SELECTOR,
1046
+ type: Z.SELECTOR,
1047
1047
  slot: !0,
1048
1048
  selections: [{
1049
1049
  label: {
@@ -1053,7 +1053,7 @@ const it = (e) => [
1053
1053
  }
1054
1054
  }],
1055
1055
  value$: o,
1056
- hidden$: Z(e, T.UNIVER_SHEET),
1056
+ hidden$: z(e, T.UNIVER_SHEET),
1057
1057
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [K, G], rangeTypes: [W] })
1058
1058
  };
1059
1059
  }, st = "sheet.numfmt.moreNumfmtType", ot = "sheet.numfmt.moreNumfmtType.options";
@@ -1086,7 +1086,7 @@ function Qn() {
1086
1086
  return /* @__PURE__ */ h("div", { className: "univer-grid univer-gap-1 univer-p-1.5", children: o.map((a, u) => a === "|" ? /* @__PURE__ */ h(pn, {}, u) : /* @__PURE__ */ y(
1087
1087
  "div",
1088
1088
  {
1089
- className: "univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
1089
+ className: "univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
1090
1090
  onClick: () => m(u),
1091
1091
  children: [
1092
1092
  /* @__PURE__ */ h("span", { children: t.t(a.label) }),
@@ -1194,7 +1194,7 @@ ct(ee, "type", T.UNIVER_SHEET);
1194
1194
  ee = or([
1195
1195
  bt(Vt, Dt),
1196
1196
  ue(1, C(He)),
1197
- ue(2, ke),
1197
+ ue(2, De),
1198
1198
  ue(3, je)
1199
1199
  ], ee);
1200
1200
  export {
@@ -0,0 +1,42 @@
1
+ const e = {
2
+ sheet: {
3
+ numfmt: {
4
+ title: "Formát čísla",
5
+ numfmtType: "Typy formátov",
6
+ cancel: "Zrušiť",
7
+ confirm: "Potvrdiť",
8
+ general: "Všeobecný",
9
+ accounting: "Účtovnícky",
10
+ text: "Text",
11
+ number: "Číslo",
12
+ percent: "Percento",
13
+ scientific: "Vedecký",
14
+ currency: "Mena",
15
+ date: "Dátum",
16
+ time: "Čas",
17
+ thousandthPercentile: "Oddeľovač tisícov",
18
+ preview: "Náhľad",
19
+ dateTime: "Dátum a čas",
20
+ decimalLength: "Počet desatinných miest",
21
+ currencyType: "Symbol meny",
22
+ moreFmt: "Formáty",
23
+ financialValue: "Finančná hodnota",
24
+ roundingCurrency: "Zaokrúhľovanie meny",
25
+ timeDuration: "Trvanie",
26
+ currencyDes: "Formát meny sa používa na zobrazenie bežných menových hodnôt. Účtovnícky formát zarovná stĺpec hodnôt podľa desatinných miest.",
27
+ accountingDes: "Účtovnícky formát čísiel zarovná stĺpec hodnôt so symbolmi meny a desatinnými miestami.",
28
+ dateType: "Typ dátumu",
29
+ dateDes: "Formát dátumu zobrazuje hodnoty dátumu a času ako dátumy.",
30
+ negType: "Typ záporného čísla",
31
+ generalDes: "Všeobecný formát neobsahuje žiadny špecifický formát čísla.",
32
+ thousandthPercentileDes: "Percentilný formát sa používa na reprezentáciu bežných čísel. Menové a účtovnícke formáty poskytujú špecializovaný formát pre výpočty menových hodnôt.",
33
+ addDecimal: "Zvýšiť počet desatinných miest",
34
+ subtractDecimal: "Znížiť počet desatinných miest",
35
+ customFormat: "Vlastný formát",
36
+ customFormatDes: "Vytvorte vlastné formáty čísiel na základe existujúcich formátov."
37
+ }
38
+ }
39
+ };
40
+ export {
41
+ e as default
42
+ };
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-mb-5{margin-bottom:1.25rem}.univer-mr-3{margin-right:.75rem}.univer-mt-2{margin-top:.5rem}.univer-mt-3{margin-top:.75rem}.univer-mt-3\.5{margin-top:.875rem}.univer-mt-4{margin-top:1rem}.univer-flex{display:flex}.univer-grid{display:grid}.univer-h-7{height:1.75rem}.univer-h-full{height:100%}.univer-max-h-\[400px\]{max-height:400px}.univer-w-32{width:8rem}.univer-w-36{width:9rem}.univer-w-4{width:1rem}.univer-w-\[340px\]{width:340px}.univer-w-full{width:100%}.univer-cursor-pointer{cursor:pointer}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-between{justify-content:space-between}.univer-gap-1{gap:.25rem}.univer-gap-1\.5{gap:.375rem}.univer-gap-6{gap:1.5rem}.univer-overflow-auto{overflow:auto}.univer-overflow-y-auto{overflow-y:auto}.univer-rounded{border-radius:.25rem}.univer-rounded-lg{border-radius:.5rem}.univer-p-1\.5{padding:.375rem}.univer-p-2{padding:.5rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.univer-pb-5{padding-bottom:1.25rem}.univer-text-sm,.univer-text-sm\/5{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-text-gray-600{color:var(--univer-gray-600)}.univer-text-primary-600{color:var(--univer-primary-600)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:\!univer-text-gray-400:where(.univer-dark,.univer-dark *){color:var(--univer-gray-400)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}
1
+ .univer-mb-5{margin-bottom:1.25rem}.univer-mr-3{margin-right:.75rem}.univer-mt-2{margin-top:.5rem}.univer-mt-3{margin-top:.75rem}.univer-mt-3\.5{margin-top:.875rem}.univer-mt-4{margin-top:1rem}.univer-flex{display:flex}.univer-grid{display:grid}.univer-h-7{height:1.75rem}.univer-h-full{height:100%}.univer-max-h-\[400px\]{max-height:400px}.univer-w-32{width:8rem}.univer-w-36{width:9rem}.univer-w-4{width:1rem}.univer-w-\[340px\]{width:340px}.univer-w-full{width:100%}.univer-cursor-default{cursor:default}.univer-cursor-pointer{cursor:pointer}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-between{justify-content:space-between}.univer-gap-1{gap:.25rem}.univer-gap-1\.5{gap:.375rem}.univer-gap-6{gap:1.5rem}.univer-overflow-auto{overflow:auto}.univer-overflow-y-auto{overflow-y:auto}.univer-rounded{border-radius:.25rem}.univer-rounded-lg{border-radius:.5rem}.univer-p-1\.5{padding:.375rem}.univer-p-2{padding:.5rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.univer-pb-5{padding-bottom:1.25rem}.univer-text-sm,.univer-text-sm\/5{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-text-gray-600{color:var(--univer-gray-600)}.univer-text-primary-600{color:var(--univer-primary-600)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:\!univer-text-gray-400:where(.univer-dark,.univer-dark *){color:var(--univer-gray-400)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}
package/lib/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  var ut = Object.defineProperty;
2
2
  var mt = (e, t, r) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var X = (e, t, r) => mt(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Inject as C, LocaleService as E, IConfigService as ke, Disposable as te, isTextFormat as Ue, Tools as dt, isRealNum as De, CommandType as Fe, ILocalStorageService as Le, isPatternEqualWithoutDecimal as ne, numfmt as ht, ThemeService as vt, IUniverInstanceService as he, ICommandService as ve, UniverInstanceType as T, CellValueType as P, toDisposable as me, DisposableCollection as ft, InterceptorEffectEnum as Te, Range as Ae, Injector as He, Optional as pt, getNumfmtParseValueFilter as gt, willLoseNumericPrecision as _t, fromCallback as St, isDefaultFormat as Ct, DEFAULT_TEXT_FORMAT_EXCEL as yt, DependentOn as bt, Plugin as It, merge as Nt, registerDependencies as Et, touchDependencies as Tt } from "@univerjs/core";
4
+ import { Inject as C, LocaleService as E, Disposable as te, isTextFormat as ke, Tools as dt, isRealNum as Ue, IConfigService as De, CommandType as Fe, ILocalStorageService as Le, isPatternEqualWithoutDecimal as ne, numfmt as ht, ThemeService as vt, UniverInstanceType as T, CellValueType as P, toDisposable as me, DisposableCollection as ft, InterceptorEffectEnum as Te, Range as Ae, IUniverInstanceService as he, ICommandService as ve, Injector as He, Optional as pt, getNumfmtParseValueFilter as gt, willLoseNumericPrecision as _t, fromCallback as St, isDefaultFormat as Ct, DEFAULT_TEXT_FORMAT_EXCEL as yt, DependentOn as bt, Plugin as It, merge as Nt, registerDependencies as Et, touchDependencies as Tt } from "@univerjs/core";
5
5
  import { IRenderManagerService as je } from "@univerjs/engine-render";
6
6
  import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Mt, currencySymbols as Me, getDecimalFromPattern as q, getCurrencyType as B, setPatternDecimal as $, getCurrencyFormatOptions as se, CURRENCYFORMAT as wt, DATEFMTLISG as Pt, NUMBERFORMAT as xt, getDateFormatOptions as Be, getNumberFormatOptions as Ve, isPatternHasDecimal as Rt, SheetsNumfmtCellContentController as We, getPatternPreviewIgnoreGeneral as $t, getPatternType as fe, SetNumfmtCommand as Ge, SubtractDecimalCommand as Ke, AddDecimalCommand as Ye, SetCurrencyCommand as Ze, getCurrencySymbolIconByLocale as we, SetPercentCommand as ze, getCurrencySymbolByLocale as Ot, localeCurrencySymbolMap as kt, getPatternPreview as Ut, UniverSheetsNumfmtPlugin as Dt } from "@univerjs/sheets-numfmt";
7
7
  import { HoverManagerService as Ft, CellAlertManagerService as Lt, CellAlertType as At, SheetSkeletonManagerService as Ht, IEditorBridgeService as jt, getCurrentRangeDisable$ as V, deriveStateFromActiveSheet$ as Bt, UniverSheetsUIPlugin as Vt } from "@univerjs/sheets-ui";
8
8
  import { INumfmtService as pe, SheetInterceptorService as Xe, SheetsSelectionsService as ge, INTERCEPTOR_POINT as Wt, RemoveNumfmtMutation as _e, SetNumfmtMutation as Se, BEFORE_CELL_EDIT as Gt, AFTER_CELL_EDIT as Kt, SetRangeValuesCommand as Yt, transformCellsToRange as Zt, factorySetNumfmtUndoMutation as zt, factoryRemoveNumfmtUndoMutation as Xt, RangeProtectionPermissionEditPoint as W, WorksheetEditPermission as G, WorksheetSetCellStylePermission as K, WorkbookEditablePermission as Y } from "@univerjs/sheets";
9
- import { IZenZoneService as qt, useDependency as b, ComponentManager as qe, ISidebarService as Jt, getMenuHiddenObservable as Z, MenuItemType as z, ILayoutService as Qt, RibbonStartGroup as en, IMenuManagerService as tn } from "@univerjs/ui";
9
+ import { IZenZoneService as qt, useDependency as b, ComponentManager as qe, ISidebarService as Jt, MenuItemType as Z, getMenuHiddenObservable as z, ILayoutService as Qt, RibbonStartGroup as en, IMenuManagerService as tn } from "@univerjs/ui";
10
10
  import { debounceTime as nn, merge as Je, Observable as L, combineLatest as rn, filter as sn } from "rxjs";
11
11
  import { map as on, switchMap as cn, tap as an, debounceTime as ln } from "rxjs/operators";
12
12
  import { jsxs as y, jsx as h } from "react/jsx-runtime";
@@ -44,7 +44,7 @@ let de = class extends te {
44
44
  this._hideAlert();
45
45
  return;
46
46
  }
47
- if (Ue(c.pattern) && dt.isDefine(a == null ? void 0 : a.v) && De(a.v)) {
47
+ if (ke(c.pattern) && dt.isDefine(a == null ? void 0 : a.v) && Ue(a.v)) {
48
48
  if ((t = this._configService.getConfig(Mt)) != null && t.disableTextFormatAlert)
49
49
  return;
50
50
  const u = this._cellAlertManagerService.currentAlert.get(oe), l = (r = u == null ? void 0 : u.alert) == null ? void 0 : r.location;
@@ -82,7 +82,7 @@ de = Sn([
82
82
  U(3, C(E)),
83
83
  U(4, qt),
84
84
  U(5, C(pe)),
85
- U(6, ke)
85
+ U(6, De)
86
86
  ], de);
87
87
  const ce = {
88
88
  id: "sheet.operation.close.numfmt.panel",
@@ -758,7 +758,7 @@ let J = class extends te {
758
758
  case "grouped":
759
759
  case "number": {
760
760
  const c = r.worksheet.getCellRaw(i, s);
761
- return (c == null ? void 0 : c.t) === P.NUMBER && (c == null ? void 0 : c.v) !== void 0 && c.v !== null && De(c.v) && (c.v = gn(Number(c.v))), n && n(c);
761
+ return (c == null ? void 0 : c.t) === P.NUMBER && (c == null ? void 0 : c.v) !== void 0 && c.v !== null && Ue(c.v) && (c.v = gn(Number(c.v))), n && n(c);
762
762
  }
763
763
  default:
764
764
  return n && n(t);
@@ -791,7 +791,7 @@ let J = class extends te {
791
791
  r.row,
792
792
  r.col
793
793
  ), s = r.worksheet.getCellRaw(r.row, r.col);
794
- if (Ue(i == null ? void 0 : i.pattern) || t.t === P.FORCE_STRING)
794
+ if (ke(i == null ? void 0 : i.pattern) || t.t === P.FORCE_STRING)
795
795
  return n(t);
796
796
  const o = (a = t.p) == null ? void 0 : a.body, m = (l = (u = t == null ? void 0 : t.p) == null ? void 0 : u.body) != null && l.dataStream ? t.p.body.dataStream.replace(/\r\n$/, "") : String(t.v), c = gt(m);
797
797
  if (o)
@@ -981,32 +981,32 @@ const it = (e) => [
981
981
  id: Ze.id,
982
982
  title: "sheet.numfmt.currency",
983
983
  tooltip: "sheet.numfmt.currency",
984
- type: z.BUTTON,
985
- hidden$: Z(e, T.UNIVER_SHEET),
984
+ type: Z.BUTTON,
985
+ hidden$: z(e, T.UNIVER_SHEET),
986
986
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
987
987
  }), Zn = (e) => ({
988
988
  icon: "AddDigitsIcon",
989
989
  id: Ye.id,
990
990
  title: "sheet.numfmt.addDecimal",
991
991
  tooltip: "sheet.numfmt.addDecimal",
992
- type: z.BUTTON,
993
- hidden$: Z(e, T.UNIVER_SHEET),
992
+ type: Z.BUTTON,
993
+ hidden$: z(e, T.UNIVER_SHEET),
994
994
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
995
995
  }), zn = (e) => ({
996
996
  icon: "ReduceDigitsIcon",
997
997
  id: Ke.id,
998
998
  title: "sheet.numfmt.subtractDecimal",
999
999
  tooltip: "sheet.numfmt.subtractDecimal",
1000
- type: z.BUTTON,
1001
- hidden$: Z(e, T.UNIVER_SHEET),
1000
+ type: Z.BUTTON,
1001
+ hidden$: z(e, T.UNIVER_SHEET),
1002
1002
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
1003
1003
  }), Xn = (e) => ({
1004
1004
  icon: "PercentIcon",
1005
1005
  id: ze.id,
1006
1006
  title: "sheet.numfmt.percent",
1007
1007
  tooltip: "sheet.numfmt.percent",
1008
- type: z.BUTTON,
1009
- hidden$: Z(e, T.UNIVER_SHEET),
1008
+ type: Z.BUTTON,
1009
+ hidden$: z(e, T.UNIVER_SHEET),
1010
1010
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [G, K], rangeTypes: [W] })
1011
1011
  }), qn = (e) => {
1012
1012
  const t = e.get(he), r = e.get(ve), n = e.get(E), i = e.get(ge), s = [_e.id, Se.id], o = Bt(
@@ -1043,7 +1043,7 @@ const it = (e) => [
1043
1043
  label: st,
1044
1044
  id: A.id,
1045
1045
  tooltip: "sheet.numfmt.title",
1046
- type: z.SELECTOR,
1046
+ type: Z.SELECTOR,
1047
1047
  slot: !0,
1048
1048
  selections: [{
1049
1049
  label: {
@@ -1053,7 +1053,7 @@ const it = (e) => [
1053
1053
  }
1054
1054
  }],
1055
1055
  value$: o,
1056
- hidden$: Z(e, T.UNIVER_SHEET),
1056
+ hidden$: z(e, T.UNIVER_SHEET),
1057
1057
  disabled$: V(e, { workbookTypes: [Y], worksheetTypes: [K, G], rangeTypes: [W] })
1058
1058
  };
1059
1059
  }, st = "sheet.numfmt.moreNumfmtType", ot = "sheet.numfmt.moreNumfmtType.options";
@@ -1086,7 +1086,7 @@ function Qn() {
1086
1086
  return /* @__PURE__ */ h("div", { className: "univer-grid univer-gap-1 univer-p-1.5", children: o.map((a, u) => a === "|" ? /* @__PURE__ */ h(pn, {}, u) : /* @__PURE__ */ y(
1087
1087
  "div",
1088
1088
  {
1089
- className: "univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
1089
+ className: "univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
1090
1090
  onClick: () => m(u),
1091
1091
  children: [
1092
1092
  /* @__PURE__ */ h("span", { children: t.t(a.label) }),
@@ -1194,7 +1194,7 @@ ct(ee, "type", T.UNIVER_SHEET);
1194
1194
  ee = or([
1195
1195
  bt(Vt, Dt),
1196
1196
  ue(1, C(He)),
1197
- ue(2, ke),
1197
+ ue(2, De),
1198
1198
  ue(3, je)
1199
1199
  ], ee);
1200
1200
  export {
@@ -0,0 +1,42 @@
1
+ const e = {
2
+ sheet: {
3
+ numfmt: {
4
+ title: "Formát čísla",
5
+ numfmtType: "Typy formátov",
6
+ cancel: "Zrušiť",
7
+ confirm: "Potvrdiť",
8
+ general: "Všeobecný",
9
+ accounting: "Účtovnícky",
10
+ text: "Text",
11
+ number: "Číslo",
12
+ percent: "Percento",
13
+ scientific: "Vedecký",
14
+ currency: "Mena",
15
+ date: "Dátum",
16
+ time: "Čas",
17
+ thousandthPercentile: "Oddeľovač tisícov",
18
+ preview: "Náhľad",
19
+ dateTime: "Dátum a čas",
20
+ decimalLength: "Počet desatinných miest",
21
+ currencyType: "Symbol meny",
22
+ moreFmt: "Formáty",
23
+ financialValue: "Finančná hodnota",
24
+ roundingCurrency: "Zaokrúhľovanie meny",
25
+ timeDuration: "Trvanie",
26
+ currencyDes: "Formát meny sa používa na zobrazenie bežných menových hodnôt. Účtovnícky formát zarovná stĺpec hodnôt podľa desatinných miest.",
27
+ accountingDes: "Účtovnícky formát čísiel zarovná stĺpec hodnôt so symbolmi meny a desatinnými miestami.",
28
+ dateType: "Typ dátumu",
29
+ dateDes: "Formát dátumu zobrazuje hodnoty dátumu a času ako dátumy.",
30
+ negType: "Typ záporného čísla",
31
+ generalDes: "Všeobecný formát neobsahuje žiadny špecifický formát čísla.",
32
+ thousandthPercentileDes: "Percentilný formát sa používa na reprezentáciu bežných čísel. Menové a účtovnícke formáty poskytujú špecializovaný formát pre výpočty menových hodnôt.",
33
+ addDecimal: "Zvýšiť počet desatinných miest",
34
+ subtractDecimal: "Znížiť počet desatinných miest",
35
+ customFormat: "Vlastný formát",
36
+ customFormatDes: "Vytvorte vlastné formáty čísiel na základe existujúcich formátov."
37
+ }
38
+ }
39
+ };
40
+ export {
41
+ e as default
42
+ };
@@ -0,0 +1,3 @@
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
+ export default locale;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(C,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/sheets"),require("@univerjs/ui"),require("rxjs"),require("rxjs/operators"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/sheets","@univerjs/ui","rxjs","rxjs/operators","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula"],s):(C=typeof globalThis<"u"?globalThis:C||self,s(C.UniverSheetsNumfmtUi={},C.UniverCore,C.UniverEngineRender,C.UniverSheetsNumfmt,C.UniverSheetsUi,C.UniverSheets,C.UniverUi,C.rxjs,C.rxjs.operators,C.React,C.React,C.UniverDesign,C.UniverEngineFormula))})(this,(function(C,s,k,d,N,g,_,w,W,l,y,E,me){"use strict";var it=Object.defineProperty;var st=(C,s,k)=>s in C?it(C,s,{enumerable:!0,configurable:!0,writable:!0,value:k}):C[s]=k;var q=(C,s,k)=>st(C,typeof s!="symbol"?s+"":s,k);const ee={};var de=Object.getOwnPropertyDescriptor,ve=(e,t,r,n)=>{for(var i=n>1?void 0:n?de(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},$=(e,t)=>(r,n)=>t(r,n,e);const G="SHEET_NUMFMT_ALERT";let K=class extends s.Disposable{constructor(e,t,r,n,i,a,o){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._zenZoneService=i,this._numfmtService=a,this._configService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(w.debounceTime(100)).subscribe(e=>{var t,r;if(e){const n=e.location,i=this._context.unit,a=i.getActiveSheet();if(!a)return this._hideAlert();const o=n.unitId,p=n.subUnitId;let c;const u=a.getCell(n.row,n.col);if(u!=null&&u.s){const v=i.getStyles().get(u.s);v!=null&&v.n&&(c=v.n)}if(c||(c=this._numfmtService.getValue(o,p,n.row,n.col)),!c){this._hideAlert();return}if(s.isTextFormat(c.pattern)&&s.Tools.isDefine(u==null?void 0:u.v)&&s.isRealNum(u.v)){if((t=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&t.disableTextFormatAlert)return;const v=this._cellAlertManagerService.currentAlert.get(G),m=(r=v==null?void 0:v.alert)==null?void 0:r.location;if(m&&m.row===n.row&&m.col===n.col&&m.subUnitId===n.subUnitId&&m.unitId===n.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:G});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(G)}};K=ve([$(1,s.Inject(N.HoverManagerService)),$(2,s.Inject(N.CellAlertManagerService)),$(3,s.Inject(s.LocaleService)),$(4,_.IZenZoneService),$(5,s.Inject(g.INumfmtService)),$(6,s.IConfigService)],K);const Y={id:"sheet.operation.close.numfmt.panel",type:s.CommandType.OPERATION,handler:()=>!0},j={id:"sheet.operation.open.numfmt.panel",type:s.CommandType.OPERATION,handler:e=>(e.get(A).openPanel(),!0)};var pe=Object.getOwnPropertyDescriptor,he=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},fe=(e,t)=>(r,n)=>t(r,n,e);const Z=y.createContext([]);let F=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 i=n.findIndex(a=>a===t);i>-1&&n.splice(i,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 i=n.map((a,o,p)=>{const c=p.length;return{value:a,priority:c-o}});return t.sort((a,o)=>{var u,v;const p=((u=i.find(m=>m.value===a))==null?void 0:u.priority)||-1;return(((v=i.find(m=>m.value===o))==null?void 0:v.priority)||-1)-p})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};F=he([fe(0,s.Inject(s.ILocalStorageService))],F);const te="numfmtCurrency",ge=e=>{const t=_.useDependency(F),[r,n]=y.useState(d.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(te,[...d.currencySymbols]).then(a=>{n(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{t.markHabit(te,a)}}},Se=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},ye=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),_e=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,a]=y.useState(()=>d.getDecimalFromPattern(t||"",2)),o=y.useContext(Z),[p,c]=y.useState(()=>d.getCurrencyType(t)||o[0]),u=y.useMemo(()=>o.map(b=>({label:b,value:b})),[]),m=_.useDependency(s.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${p}"* #,##0${i>0?".0":""}_)`,i);const f=b=>{c(b),n(d.setPatternDecimal(`_("${b}"* #,##0${i>0?".0":""}_)`,i))},S=b=>{const h=b||0;a(h),n(d.setPatternDecimal(`_("${p}"* #,##0${h>0?".0":""}_)`,h))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{options:u,value:p,onChange:f})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},Ce=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),be=e=>{const r=_.useDependency(s.LocaleService).t,n=y.useContext(Z),[i,a]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||n[0]),[o,p]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[c,u]=y.useState(()=>{var I;const h=d.getCurrencyFormatOptions(i);return((I=h.find(M=>s.isPatternEqualWithoutDecimal(M.value,e.defaultPattern)))==null?void 0:I.value)||h[0].value}),v=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>n.map(h=>({label:h,value:h})),[n]);e.action.current=()=>d.setPatternDecimal(c,o);const f=h=>{if(h===void 0)return;a(h);const P=d.getCurrencyFormatOptions(h)[0].value;u(P),e.onChange(d.setPatternDecimal(P,o))},S=h=>{h!==void 0&&(u(h),e.onChange(d.setPatternDecimal(h,o)))},b=h=>{p(h||0),e.onChange(d.setPatternDecimal(c,h||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:o,max:20,min:0,onChange:b})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{value:i,options:m,onChange:f})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:c,options:v,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};function ne({ref:e,...t}){const{icon:r,id:n,className:i,extend:a,...o}=t,p=`univerjs-icon univerjs-icon-${n} ${i||""}`.trim(),c=y.useRef(`_${Ee()}`);return re(r,`${n}`,{defIds:r.defIds,idSuffix:c.current},{ref:e,className:p,...o},a)}function re(e,t,r,n,i){return y.createElement(e.tag,{key:t,...Ie(e,r,i),...n},(Te(e,r).children||[]).map((a,o)=>re(a,`${t}-${e.tag}-${o}`,r,void 0,i)))}function Ie(e,t,r){const n={...e.attrs};r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(([a,o])=>{a==="mask"&&typeof o=="string"&&(n[a]=o.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:i}=t;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(([a,o])=>{typeof o=="string"&&(n[a]=o.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),n}function Te(e,t){var n;const{defIds:r}=t;return!r||r.length===0?e:e.tag==="defs"&&((n=e.children)!=null&&n.length)?{...e,children:e.children.map(i=>typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?{...i,attrs:{...i.attrs,id:i.attrs.id+t.idSuffix}}:i)}:e}function Ee(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=y.forwardRef(function(t,r){return y.createElement(ne,Object.assign({},t,{id:"check-mark-icon",ref:r,icon:Pe}))});ie.displayName="CheckMarkIcon";const z="customFormat",X="numfmt_custom_pattern";function Me(e){const{defaultPattern:t,action:r,onChange:n}=e,i=_.useDependency(F),a=_.useDependency(s.ILocalStorageService),o=_.useDependency(s.LocaleService),[p,c]=y.useState(t);r.current=()=>(i.markHabit(z,p),a.getItem(X).then((S=[])=>{const b=[...new Set([p,...S||[]])].splice(0,10).filter(h=>!!h);a.setItem(X,b)}),p);const[u,v]=y.useState([]);y.useEffect(()=>{a.getItem(X).then(S=>{const b=[...d.CURRENCYFORMAT.map(h=>h.suffix("$")),...d.DATEFMTLISG.map(h=>h.suffix),...d.NUMBERFORMAT.map(h=>h.suffix)];b.push(...S||[]),i.addHabit(z,[]).finally(()=>{i.getHabit(z,b).then(h=>{v([...new Set(h)])})})})},[]);const m=S=>{c(S),n(S)},f=()=>{n(p)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:o.t("sheet.numfmt.customFormat")}),l.jsx(E.Input,{placeholder:o.t("sheet.numfmt.customFormat"),onBlur:f,value:p,onChange:c,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:E.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",E.borderClassName),children:u.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:p===S&&l.jsx(ie,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:o.t("sheet.numfmt.customFormatDes")})]})}const Ne=e=>{const t=s.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)};function De(e){const{onChange:t,defaultPattern:r}=e,n=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(s.LocaleService),[a,o]=y.useState(()=>{if(r){const c=n.find(u=>u.value===r);if(c)return c.value}return n[0].value});e.action.current=()=>a;const p=c=>{c!==void 0&&(o(c),t(c))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:a,options:n,onChange:p})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const we=e=>!e,Ue=e=>{const r=_.useDependency(s.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},xe=e=>d.getNumberFormatOptions().some(t=>s.isPatternEqualWithoutDecimal(t.value,e));function Oe(e){const t=_.useDependency(s.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[n,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[a,o]=y.useState(()=>{const m=r.find(f=>s.isPatternEqualWithoutDecimal(f.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),p=y.useMemo(()=>d.setPatternDecimal(a,Number(n||0)),[a,n]),c=y.useMemo(()=>!d.isPatternHasDecimal(a),[a]),u=m=>{i(m||0),e.onChange(d.setPatternDecimal(a,Number(m||0)))},v=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),o(m),e.onChange(m))};return e.action.current=()=>p,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:t.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.InputNumber,{disabled:c,value:n,max:20,min:0,onChange:u})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",t.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{onChange:v,options:r,value:a})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})}const ke=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,a=_.useDependency(s.LocaleService),o=y.useRef(()=>""),p=a.t,c=Se(),u=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Ue},{label:"sheet.numfmt.accounting",component:_e},{label:"sheet.numfmt.currency",component:be},{label:"sheet.numfmt.date",component:De},{label:"sheet.numfmt.thousandthPercentile",component:Oe},{label:"sheet.numfmt.customFormat",component:Me}].map(T=>({...T,label:p(T.label)})),[]),[v,m]=y.useState(I),[f,S]=y.useState(()=>`${n}_${i}`),{mark:b,userHabitCurrency:h}=ge(()=>S(`${n}_${i}_userCurrency'`)),P=y.useMemo(()=>{var T;return(T=u.find(L=>L.label===v))==null?void 0:T.component},[v]);function I(){return[we,ye,Ce,Ne,xe].reduce((L,nt,rt)=>L||(nt(r)?u[rt].label:""),"")||u[0].label}const M=u.map(T=>({label:T.label,value:T.label})),U=T=>{m(T),c(()=>e.onChange({type:"change",value:o.current()||""}))},x=y.useCallback(T=>{e.onChange({type:"change",value:T})},[]),O=()=>{const T=o.current()||"",L=d.getCurrencyType(T);L&&b(L),e.onChange({type:"confirm",value:T})},R=()=>{e.onChange({type:"cancel",value:""})},Q={onChange:x,defaultValue:t,defaultPattern:r,action:o};return y.useEffect(()=>{m(I()),S(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:E.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",E.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:p("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.Select,{className:"univer-w-full",value:v,options:M,onChange:U})}),l.jsx("div",{children:P&&l.jsx(Z.Provider,{value:h,children:y.createElement(P,{...Q,key:f})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(E.Button,{onClick:R,className:"univer-mr-3",children:p("sheet.numfmt.cancel")}),l.jsx(E.Button,{variant:"primary",onClick:O,children:p("sheet.numfmt.confirm")})]})]})};var $e=Object.getOwnPropertyDescriptor,Le=(e,t,r,n)=>{for(var i=n>1?void 0:n?$e(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},D=(e,t)=>(r,n)=>t(r,n,e);const se="SHEET_NUMFMT_PANEL";let A=class extends s.Disposable{constructor(t,r,n,i,a,o,p,c,u,v,m){super();q(this,"_previewPattern","");q(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=o,this._numfmtService=p,this._componentManager=c,this._sidebarService=u,this._localeService=v,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(w.merge(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var P;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,a=this._numfmtService,o=this._localeService,c=(((P=r.getCurrentSelections())==null?void 0:P.map(I=>I.range))||[])[0];if(!c)return!1;const u=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),v=u.getActiveSheet();if(!v)return!1;const m=v.getCellRaw(c.startRow,c.startColumn),f=a.getValue(u.getUnitId(),v.getSheetId(),c.startRow,c.startColumn);let S="";f&&(S=f.pattern);const b=(m==null?void 0:m.t)===s.CellValueType.NUMBER?m.v:12345678,h={onChange:I=>{var M;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const U=((M=r.getCurrentSelections())==null?void 0:M.map(R=>R.range))||[],x={values:[]},O=d.getPatternType(I.value);U.forEach(R=>{s.Range.foreach(R,(Q,T)=>{x.values.push({row:Q,col:T,pattern:I.value,type:O})})}),n.executeCommand(d.SetNumfmtCommand.id,x),t.close()}else I.type==="cancel"&&t.close()},value:{defaultPattern:S,defaultValue:b,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=t.open({header:{title:o.t("sheet.numfmt.title")},children:{label:se,...h},onClose:()=>{this._forceUpdate(),n.executeCommand(Y.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(N.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[j,Y].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this.disposeWithMe(this._componentManager.register(se,ke))}_initRealTimeRenderingInterceptor(){const t=new w.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===j.id&&n.next(!0),i.id===Y.id&&n.next(!1)})}),r=w.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(W.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(s.toDisposable(r.pipe(W.switchMap(([n,i])=>new w.Observable(a=>{const o=new s.DisposableCollection;return n&&i.length&&a.next({selectionRanges:i,disposableCollection:o}),()=>{o.dispose()}})),W.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var o,p;const a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:s.InterceptorEffectEnum.Value|s.InterceptorEffectEnum.Style,handler:(c,u,v)=>{var b;const{row:m,col:f}=u,S=v(c)||{};if(i.find(h=>h.startColumn<=f&&h.endColumn>=f&&h.startRow<=m&&h.endRow>=m)){const h=u.worksheet.getCellRaw(m,f),P=h==null?void 0:h.v,I=h==null?void 0:h.t;if(P==null||I!==s.CellValueType.NUMBER||this._previewPattern===null)return S;const M=d.getPatternPreviewIgnoreGeneral(this._previewPattern,P,this._sheetsNumfmtCellContentController.locale);if(M.color){const U=(b=this._themeService.getColorFromTheme(`${M.color}.500`))!=null?b:M.color;return{...S,v:M.result,t:s.CellValueType.STRING,s:{cl:{rgb:U}}}}return{...S,v:M.result,t:s.CellValueType.STRING}}return S}})),(p=(o=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:o.mainComponent)==null||p.makeDirty()})))}_commandExecutedListener(){const t=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new w.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>n.dispose()}).pipe(W.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};A=Le([D(0,s.Inject(g.SheetInterceptorService)),D(1,s.Inject(s.ThemeService)),D(2,s.IUniverInstanceService),D(3,s.ICommandService),D(4,s.Inject(g.SheetsSelectionsService)),D(5,k.IRenderManagerService),D(6,g.INumfmtService),D(7,s.Inject(_.ComponentManager)),D(8,_.ISidebarService),D(9,s.Inject(s.LocaleService)),D(10,s.Inject(d.SheetsNumfmtCellContentController))],A);var je=Object.getOwnPropertyDescriptor,Fe=(e,t,r,n)=>{for(var i=n>1?void 0:n?je(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},H=(e,t)=>(r,n)=>t(r,n,e);const Ae=()=>{let e=[];return{add:(i,a,o,p,c)=>e.push({unitId:i,subUnitId:a,row:o,col:p,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let B=class extends s.Disposable{constructor(t,r,n,i,a){super();q(this,"_collectEffectMutation",Ae());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,a=r.col,o=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(o)switch(d.getPatternType(o.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,a);return(c==null?void 0:c.t)===s.CellValueType.NUMBER&&(c==null?void 0:c.v)!==void 0&&c.v!==null&&s.isRealNum(c.v)&&(c.v=me.stripErrorMargin(Number(c.v))),n&&n(c)}default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var u,v,m;if(!(t!=null&&t.v)&&!(t!=null&&t.p))return n(t);this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=r.worksheet.getCellRaw(r.row,r.col);if(s.isTextFormat(i==null?void 0:i.pattern)||t.t===s.CellValueType.FORCE_STRING)return n(t);const o=(u=t.p)==null?void 0:u.body,p=(m=(v=t==null?void 0:t.p)==null?void 0:v.body)!=null&&m.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),c=s.getNumfmtParseValueFilter(p);if(o)if(He(o)){const{dataStream:f}=o,S=f.replace(/\r\n$/,""),b=Number(S);if(Number.isNaN(b)&&!c)return n(t)}else return n(t);if(c){if(!c.z&&!(i!=null&&i.pattern)&&(a==null?void 0:a.t)!==s.CellValueType.STRING&&(a==null?void 0:a.t)!==s.CellValueType.FORCE_STRING&&s.willLoseNumericPrecision(p))return n({...t,p:void 0,v:p,t:s.CellValueType.FORCE_STRING});c.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:c.z});const f=Number(c.v);return n({...t,p:void 0,v:f,t:s.CellValueType.NUMBER})}return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case g.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),o=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!o)return{redos:[],undos:[]};const p=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!p.length)return{redos:[],undos:[]};const c=p.filter(f=>{var S;return!!((S=f.value)!=null&&S.pattern)}).map(f=>({row:f.row,col:f.col,pattern:f.value.pattern})),u=p.filter(f=>{var S;return!((S=f.value)!=null&&S.pattern)}).map(f=>({startRow:f.row,endColumn:f.col,startColumn:f.col,endRow:f.row})),v=[],m=[];if(c.length){const f={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(a,o,c)};v.push(f),m.push(...g.factorySetNumfmtUndoMutation(t._injector,f.params))}if(u.length){const f={id:g.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:o,ranges:u}};v.push(f),m.push(...g.factoryRemoveNumfmtUndoMutation(t._injector,f.params))}return{redos:v,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};B=Fe([H(0,s.Inject(g.SheetInterceptorService)),H(1,s.Inject(g.INumfmtService)),H(2,s.Inject(s.IUniverInstanceService)),H(3,s.Inject(s.Injector)),H(4,s.Optional(N.IEditorBridgeService))],B);function He(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,a=["va"];return!(t.some(o=>!!(o.ts&&Object.keys(o.ts).some(c=>a.includes(c))))||r.some(o=>o.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const ae=e=>[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:s.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{label:"sheet.numfmt.accounting",pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.roundingCurrency",pattern:`"${e}"#,##0;[Red]"${e}"#,##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:""}],Re=e=>({icon:new w.Observable(t=>{const r=e.get(s.LocaleService);return t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon),r.localeChanged$.subscribe(()=>{t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon)})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),We=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Be=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ve=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),qe=e=>{const t=e.get(s.IUniverInstanceService),r=e.get(s.ICommandService),n=e.get(s.LocaleService),i=e.get(g.SheetsSelectionsService),a=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],o=N.deriveStateFromActiveSheet$(t,"",({workbook:p,worksheet:c})=>new w.Observable(u=>w.merge(i.selectionMoveEnd$,s.fromCallback(r.onCommandExecuted.bind(r)).pipe(w.filter(([v])=>a.includes(v.id)))).subscribe(()=>{var m,f;const v=i.getCurrentSelections();if(v&&v[0]){const S=v[0].range,b=S.startRow,h=S.startColumn,P=(f=p.getStyles().get((m=c.getCell(b,h))==null?void 0:m.s))==null?void 0:f.n,I=P==null?void 0:P.pattern,M=d.getCurrencySymbolByLocale(n.getCurrentLocale());let U=n.t("sheet.numfmt.general");if(s.isDefaultFormat(I)){u.next(U);return}if(I){const x=ae(M).filter(O=>typeof O=="object"&&O.pattern).find(O=>s.isPatternEqualWithoutDecimal(I,O.pattern));x&&typeof x=="object"&&x.pattern?U=n.t(x.label):U=n.t("sheet.numfmt.moreFmt")}u.next(U)}})));return{label:oe,id:j.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:ce,hoverable:!1,selectable:!1}}],value$:o,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},oe="sheet.numfmt.moreNumfmtType",ce="sheet.numfmt.moreNumfmtType.options";function Ge(e){const{value:t}=e,r=_.useDependency(s.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:n})}function Ke(){const e=_.useDependency(s.ICommandService),t=_.useDependency(s.LocaleService),r=_.useDependency(_.ILayoutService),n=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),a=u=>{const v=i.getCurrentLastSelection();if(!v)return;const m=v.range,f=[];s.Range.foreach(m,(S,b)=>{u?f.push({row:S,col:b,pattern:u,type:d.getPatternType(u)}):f.push({row:S,col:b})}),e.executeCommand(d.SetNumfmtCommand.id,{values:f}),r.focus()},o=y.useMemo(()=>{const u=d.localeCurrencySymbolMap.get(t.getCurrentLocale());return ae(u)},[t]),p=u=>{if(u===0)a(null);else if(u===o.length-1)e.executeCommand(j.id),r.focus();else{const v=o[u];v.pattern&&a(v.pattern)}},c=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:o.map((u,v)=>u==="|"?l.jsx(E.Separator,{},v):l.jsxs("div",{className:"univer-flex univer-h-7 univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>p(v),children:[l.jsx("span",{children:t.t(u.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",children:u.pattern?d.getPatternPreview(u.pattern||"",c,n.locale).result.trim():""})]},v))})}const Ye={[_.RibbonStartGroup.LAYOUT]:{[j.id]:{order:9,menuItemFactory:qe},[d.SetPercentCommand.id]:{order:9.1,menuItemFactory:Ve},[d.SetCurrencyCommand.id]:{order:9.2,menuItemFactory:Re},[d.AddDecimalCommand.id]:{order:9.3,menuItemFactory:We},[d.SubtractDecimalCommand.id]:{order:9.4,menuItemFactory:Be}}};var Ze=Object.getOwnPropertyDescriptor,ze=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ze(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},le=(e,t)=>(r,n)=>t(r,n,e);let V=class extends s.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Ye),[[oe,Ge],[ce,Ke]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};V=ze([le(0,s.Inject(_.ComponentManager)),le(1,_.IMenuManagerService)],V);var Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(e,t,r)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t,r,n)=>{for(var i=n>1?void 0:n?Je(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},J=(e,t)=>(r,n)=>t(r,n,e),ue=(e,t,r)=>Qe(e,typeof t!="symbol"?t+"":t,r);const tt="SHEET_NUMFMT_UI_PLUGIN";C.UniverSheetsNumfmtUIPlugin=class extends s.Plugin{constructor(t=ee,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:a,...o}=s.merge({},ee,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",o)}onStarting(){s.registerDependencies(this._injector,[[A],[B],[F],[V]])}onRendered(){this._registerRenderModules(),s.touchDependencies(this._injector,[[A],[B],[V]])}_registerRenderModules(){[[K]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,r))})}},ue(C.UniverSheetsNumfmtUIPlugin,"pluginName",tt),ue(C.UniverSheetsNumfmtUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),C.UniverSheetsNumfmtUIPlugin=et([s.DependentOn(N.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),J(1,s.Inject(s.Injector)),J(2,s.IConfigService),J(3,k.IRenderManagerService)],C.UniverSheetsNumfmtUIPlugin),Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(C,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/sheets"),require("@univerjs/ui"),require("rxjs"),require("rxjs/operators"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/sheets","@univerjs/ui","rxjs","rxjs/operators","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula"],s):(C=typeof globalThis<"u"?globalThis:C||self,s(C.UniverSheetsNumfmtUi={},C.UniverCore,C.UniverEngineRender,C.UniverSheetsNumfmt,C.UniverSheetsUi,C.UniverSheets,C.UniverUi,C.rxjs,C.rxjs.operators,C.React,C.React,C.UniverDesign,C.UniverEngineFormula))})(this,(function(C,s,k,d,N,g,_,w,W,l,y,E,me){"use strict";var it=Object.defineProperty;var st=(C,s,k)=>s in C?it(C,s,{enumerable:!0,configurable:!0,writable:!0,value:k}):C[s]=k;var q=(C,s,k)=>st(C,typeof s!="symbol"?s+"":s,k);const ee={};var de=Object.getOwnPropertyDescriptor,ve=(e,t,r,n)=>{for(var i=n>1?void 0:n?de(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},$=(e,t)=>(r,n)=>t(r,n,e);const G="SHEET_NUMFMT_ALERT";let K=class extends s.Disposable{constructor(e,t,r,n,i,a,o){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=r,this._localeService=n,this._zenZoneService=i,this._numfmtService=a,this._configService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(w.debounceTime(100)).subscribe(e=>{var t,r;if(e){const n=e.location,i=this._context.unit,a=i.getActiveSheet();if(!a)return this._hideAlert();const o=n.unitId,p=n.subUnitId;let c;const u=a.getCell(n.row,n.col);if(u!=null&&u.s){const v=i.getStyles().get(u.s);v!=null&&v.n&&(c=v.n)}if(c||(c=this._numfmtService.getValue(o,p,n.row,n.col)),!c){this._hideAlert();return}if(s.isTextFormat(c.pattern)&&s.Tools.isDefine(u==null?void 0:u.v)&&s.isRealNum(u.v)){if((t=this._configService.getConfig(d.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&t.disableTextFormatAlert)return;const v=this._cellAlertManagerService.currentAlert.get(G),m=(r=v==null?void 0:v.alert)==null?void 0:r.location;if(m&&m.row===n.row&&m.col===n.col&&m.subUnitId===n.subUnitId&&m.unitId===n.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:n,width:200,height:74,key:G});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(G)}};K=ve([$(1,s.Inject(N.HoverManagerService)),$(2,s.Inject(N.CellAlertManagerService)),$(3,s.Inject(s.LocaleService)),$(4,_.IZenZoneService),$(5,s.Inject(g.INumfmtService)),$(6,s.IConfigService)],K);const Y={id:"sheet.operation.close.numfmt.panel",type:s.CommandType.OPERATION,handler:()=>!0},j={id:"sheet.operation.open.numfmt.panel",type:s.CommandType.OPERATION,handler:e=>(e.get(A).openPanel(),!0)};var pe=Object.getOwnPropertyDescriptor,he=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},fe=(e,t)=>(r,n)=>t(r,n,e);const Z=y.createContext([]);let F=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 i=n.findIndex(a=>a===t);i>-1&&n.splice(i,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 i=n.map((a,o,p)=>{const c=p.length;return{value:a,priority:c-o}});return t.sort((a,o)=>{var u,v;const p=((u=i.find(m=>m.value===a))==null?void 0:u.priority)||-1;return(((v=i.find(m=>m.value===o))==null?void 0:v.priority)||-1)-p})}return n||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};F=he([fe(0,s.Inject(s.ILocalStorageService))],F);const te="numfmtCurrency",ge=e=>{const t=_.useDependency(F),[r,n]=y.useState(d.currencySymbols);return y.useEffect(()=>{t.addHabit("numfmtCurrency",[]).then(()=>{t.getHabit(te,[...d.currencySymbols]).then(a=>{n(a),e&&e(a)})})},[]),{userHabitCurrency:r,mark:a=>{t.markHabit(te,a)}}},Se=()=>{const e=y.useRef([]),[t,r]=y.useState({});return y.useEffect(()=>{e.current.forEach(i=>{i()}),e.current=[]},[t]),i=>{e.current.push(i),r({})}},ye=e=>!!d.getCurrencyType(e)&&e.startsWith("_("),_e=e=>{const{defaultPattern:t,action:r,onChange:n}=e,[i,a]=y.useState(()=>d.getDecimalFromPattern(t||"",2)),o=y.useContext(Z),[p,c]=y.useState(()=>d.getCurrencyType(t)||o[0]),u=y.useMemo(()=>o.map(b=>({label:b,value:b})),[]),m=_.useDependency(s.LocaleService).t;r.current=()=>d.setPatternDecimal(`_("${p}"* #,##0${i>0?".0":""}_)`,i);const f=b=>{c(b),n(d.setPatternDecimal(`_("${b}"* #,##0${i>0?".0":""}_)`,i))},S=b=>{const h=b||0;a(h),n(d.setPatternDecimal(`_("${p}"* #,##0${h>0?".0":""}_)`,h))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:i,step:1,precision:0,max:20,min:0,onChange:S})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{options:u,value:p,onChange:f})})]})]}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:m("sheet.numfmt.accountingDes")})]})},Ce=e=>!!d.getCurrencyType(e)&&!e.startsWith("_("),be=e=>{const r=_.useDependency(s.LocaleService).t,n=y.useContext(Z),[i,a]=y.useState(()=>d.getCurrencyType(e.defaultPattern)||n[0]),[o,p]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",2)),[c,u]=y.useState(()=>{var I;const h=d.getCurrencyFormatOptions(i);return((I=h.find(M=>s.isPatternEqualWithoutDecimal(M.value,e.defaultPattern)))==null?void 0:I.value)||h[0].value}),v=y.useMemo(()=>d.getCurrencyFormatOptions(i),[i]),m=y.useMemo(()=>n.map(h=>({label:h,value:h})),[n]);e.action.current=()=>d.setPatternDecimal(c,o);const f=h=>{if(h===void 0)return;a(h);const P=d.getCurrencyFormatOptions(h)[0].value;u(P),e.onChange(d.setPatternDecimal(P,o))},S=h=>{h!==void 0&&(u(h),e.onChange(d.setPatternDecimal(h,o)))},b=h=>{p(h||0),e.onChange(d.setPatternDecimal(c,h||0))};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-between",children:[l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2 univer-w-32",children:l.jsx(E.InputNumber,{value:o,max:20,min:0,onChange:b})})]}),l.jsxs("div",{className:"option",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyType")}),l.jsx("div",{className:"univer-mt-2 univer-w-36",children:l.jsx(E.Select,{value:i,options:m,onChange:f})})]})]}),l.jsx("div",{className:"label univer-mt-4",children:r("sheet.numfmt.negType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:c,options:v,onChange:S})}),l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:r("sheet.numfmt.currencyDes")})]})};function ne({ref:e,...t}){const{icon:r,id:n,className:i,extend:a,...o}=t,p=`univerjs-icon univerjs-icon-${n} ${i||""}`.trim(),c=y.useRef(`_${Ee()}`);return re(r,`${n}`,{defIds:r.defIds,idSuffix:c.current},{ref:e,className:p,...o},a)}function re(e,t,r,n,i){return y.createElement(e.tag,{key:t,...Ie(e,r,i),...n},(Te(e,r).children||[]).map((a,o)=>re(a,`${t}-${e.tag}-${o}`,r,void 0,i)))}function Ie(e,t,r){const n={...e.attrs};r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(([a,o])=>{a==="mask"&&typeof o=="string"&&(n[a]=o.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:i}=t;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(([a,o])=>{typeof o=="string"&&(n[a]=o.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),n}function Te(e,t){var n;const{defIds:r}=t;return!r||r.length===0?e:e.tag==="defs"&&((n=e.children)!=null&&n.length)?{...e,children:e.children.map(i=>typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?{...i,attrs:{...i.attrs,id:i.attrs.id+t.idSuffix}}:i)}:e}function Ee(){return Math.random().toString(36).substring(2,8)}ne.displayName="UniverIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=y.forwardRef(function(t,r){return y.createElement(ne,Object.assign({},t,{id:"check-mark-icon",ref:r,icon:Pe}))});ie.displayName="CheckMarkIcon";const z="customFormat",X="numfmt_custom_pattern";function Me(e){const{defaultPattern:t,action:r,onChange:n}=e,i=_.useDependency(F),a=_.useDependency(s.ILocalStorageService),o=_.useDependency(s.LocaleService),[p,c]=y.useState(t);r.current=()=>(i.markHabit(z,p),a.getItem(X).then((S=[])=>{const b=[...new Set([p,...S||[]])].splice(0,10).filter(h=>!!h);a.setItem(X,b)}),p);const[u,v]=y.useState([]);y.useEffect(()=>{a.getItem(X).then(S=>{const b=[...d.CURRENCYFORMAT.map(h=>h.suffix("$")),...d.DATEFMTLISG.map(h=>h.suffix),...d.NUMBERFORMAT.map(h=>h.suffix)];b.push(...S||[]),i.addHabit(z,[]).finally(()=>{i.getHabit(z,b).then(h=>{v([...new Set(h)])})})})},[]);const m=S=>{c(S),n(S)},f=()=>{n(p)};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:o.t("sheet.numfmt.customFormat")}),l.jsx(E.Input,{placeholder:o.t("sheet.numfmt.customFormat"),onBlur:f,value:p,onChange:c,className:"univer-mt-2 univer-w-full"}),l.jsx("div",{className:E.clsx("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2",E.borderClassName),children:u.map(S=>l.jsxs("div",{onClick:()=>m(S),className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-w-4 univer-items-center univer-text-primary-600",children:p===S&&l.jsx(ie,{})}),l.jsx("div",{children:S})]},S))}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:o.t("sheet.numfmt.customFormatDes")})]})}const Ne=e=>{const t=s.numfmt.getFormatInfo(e);return d.getDateFormatOptions().map(r=>r.value).includes(e)||["date","datetime","time"].includes(t.type)};function De(e){const{onChange:t,defaultPattern:r}=e,n=y.useMemo(d.getDateFormatOptions,[]),i=_.useDependency(s.LocaleService),[a,o]=y.useState(()=>{if(r){const c=n.find(u=>u.value===r);if(c)return c.value}return n[0].value});e.action.current=()=>a;const p=c=>{c!==void 0&&(o(c),t(c))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:i.t("sheet.numfmt.dateType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{value:a,options:n,onChange:p})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.numfmt.dateDes")})]})}const we=e=>!e,Ue=e=>{const r=_.useDependency(s.LocaleService).t;return e.action.current=()=>"",l.jsx("div",{children:l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:r("sheet.numfmt.generalDes")})})},xe=e=>d.getNumberFormatOptions().some(t=>s.isPatternEqualWithoutDecimal(t.value,e));function Oe(e){const t=_.useDependency(s.LocaleService),r=y.useMemo(d.getNumberFormatOptions,[]),[n,i]=y.useState(()=>d.getDecimalFromPattern(e.defaultPattern||"",0)),[a,o]=y.useState(()=>{const m=r.find(f=>s.isPatternEqualWithoutDecimal(f.value,e.defaultPattern||""));return(m==null?void 0:m.value)||r[0].value}),p=y.useMemo(()=>d.setPatternDecimal(a,Number(n||0)),[a,n]),c=y.useMemo(()=>!d.isPatternHasDecimal(a),[a]),u=m=>{i(m||0),e.onChange(d.setPatternDecimal(a,Number(m||0)))},v=m=>{m!==void 0&&(i(d.getDecimalFromPattern(m,0)),o(m),e.onChange(m))};return e.action.current=()=>p,l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:t.t("sheet.numfmt.decimalLength")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.InputNumber,{disabled:c,value:n,max:20,min:0,onChange:u})}),l.jsxs("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-400",children:[" ",t.t("sheet.numfmt.negType")]}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.SelectList,{onChange:v,options:r,value:a})}),l.jsx("div",{className:"univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.numfmt.thousandthPercentileDes")})]})}const ke=e=>{const{defaultValue:t,defaultPattern:r,row:n,col:i}=e.value,a=_.useDependency(s.LocaleService),o=y.useRef(()=>""),p=a.t,c=Se(),u=y.useMemo(()=>[{label:"sheet.numfmt.general",component:Ue},{label:"sheet.numfmt.accounting",component:_e},{label:"sheet.numfmt.currency",component:be},{label:"sheet.numfmt.date",component:De},{label:"sheet.numfmt.thousandthPercentile",component:Oe},{label:"sheet.numfmt.customFormat",component:Me}].map(T=>({...T,label:p(T.label)})),[]),[v,m]=y.useState(I),[f,S]=y.useState(()=>`${n}_${i}`),{mark:b,userHabitCurrency:h}=ge(()=>S(`${n}_${i}_userCurrency'`)),P=y.useMemo(()=>{var T;return(T=u.find(L=>L.label===v))==null?void 0:T.component},[v]);function I(){return[we,ye,Ce,Ne,xe].reduce((L,nt,rt)=>L||(nt(r)?u[rt].label:""),"")||u[0].label}const M=u.map(T=>({label:T.label,value:T.label})),U=T=>{m(T),c(()=>e.onChange({type:"change",value:o.current()||""}))},x=y.useCallback(T=>{e.onChange({type:"change",value:T})},[]),O=()=>{const T=o.current()||"",L=d.getCurrencyType(T);L&&b(L),e.onChange({type:"confirm",value:T})},R=()=>{e.onChange({type:"cancel",value:""})},Q={onChange:x,defaultValue:t,defaultPattern:r,action:o};return y.useEffect(()=>{m(I()),S(`${n}_${i}`)},[n,i]),l.jsxs("div",{className:E.clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5",E.scrollbarClassName),children:[l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3.5 univer-text-sm univer-text-gray-400",children:p("sheet.numfmt.numfmtType")}),l.jsx("div",{className:"univer-mt-2",children:l.jsx(E.Select,{className:"univer-w-full",value:v,options:M,onChange:U})}),l.jsx("div",{children:P&&l.jsx(Z.Provider,{value:h,children:y.createElement(P,{...Q,key:f})})})]}),l.jsxs("div",{className:"univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end",children:[l.jsx(E.Button,{onClick:R,className:"univer-mr-3",children:p("sheet.numfmt.cancel")}),l.jsx(E.Button,{variant:"primary",onClick:O,children:p("sheet.numfmt.confirm")})]})]})};var $e=Object.getOwnPropertyDescriptor,Le=(e,t,r,n)=>{for(var i=n>1?void 0:n?$e(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},D=(e,t)=>(r,n)=>t(r,n,e);const se="SHEET_NUMFMT_PANEL";let A=class extends s.Disposable{constructor(t,r,n,i,a,o,p,c,u,v,m){super();q(this,"_previewPattern","");q(this,"_sidebarDisposable",null);this._sheetInterceptorService=t,this._themeService=r,this._univerInstanceService=n,this._commandService=i,this._selectionManagerService=a,this._renderManagerService=o,this._numfmtService=p,this._componentManager=c,this._sidebarService=u,this._localeService=v,this._sheetsNumfmtCellContentController=m,this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(w.merge(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var P;const t=this._sidebarService,r=this._selectionManagerService,n=this._commandService,i=this._univerInstanceService,a=this._numfmtService,o=this._localeService,c=(((P=r.getCurrentSelections())==null?void 0:P.map(I=>I.range))||[])[0];if(!c)return!1;const u=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),v=u.getActiveSheet();if(!v)return!1;const m=v.getCellRaw(c.startRow,c.startColumn),f=a.getValue(u.getUnitId(),v.getSheetId(),c.startRow,c.startColumn);let S="";f&&(S=f.pattern);const b=(m==null?void 0:m.t)===s.CellValueType.NUMBER?m.v:12345678,h={onChange:I=>{var M;if(I.type==="change")this._previewPattern=I.value,this._forceUpdate();else if(I.type==="confirm"){const U=((M=r.getCurrentSelections())==null?void 0:M.map(R=>R.range))||[],x={values:[]},O=d.getPatternType(I.value);U.forEach(R=>{s.Range.foreach(R,(Q,T)=>{x.values.push({row:Q,col:T,pattern:I.value,type:O})})}),n.executeCommand(d.SetNumfmtCommand.id,x),t.close()}else I.type==="cancel"&&t.close()},value:{defaultPattern:S,defaultValue:b,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=t.open({header:{title:o.t("sheet.numfmt.title")},children:{label:se,...h},onClose:()=>{this._forceUpdate(),n.executeCommand(Y.id)}}),!0}_forceUpdate(t){var n;const r=this._renderManagerService.getRenderById(t!=null?t:this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId());r==null||r.with(N.SheetSkeletonManagerService).reCalculate(),(n=r==null?void 0:r.mainComponent)==null||n.makeDirty()}_initCommands(){[j,Y].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initPanel(){this.disposeWithMe(this._componentManager.register(se,ke))}_initRealTimeRenderingInterceptor(){const t=new w.Observable(n=>{this._commandService.onCommandExecuted(i=>{i.id===j.id&&n.next(!0),i.id===Y.id&&n.next(!1)})}),r=w.combineLatest([t,this._selectionManagerService.selectionMoveEnd$.pipe(W.map(n=>n?n.map(i=>i.range):[]))]);this.disposeWithMe(s.toDisposable(r.pipe(W.switchMap(([n,i])=>new w.Observable(a=>{const o=new s.DisposableCollection;return n&&i.length&&a.next({selectionRanges:i,disposableCollection:o}),()=>{o.dispose()}})),W.tap(()=>{this._previewPattern=null})).subscribe(({disposableCollection:n,selectionRanges:i})=>{var o,p;const a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this.openPanel(),n.add(this._sheetInterceptorService.intercept(g.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:s.InterceptorEffectEnum.Value|s.InterceptorEffectEnum.Style,handler:(c,u,v)=>{var b;const{row:m,col:f}=u,S=v(c)||{};if(i.find(h=>h.startColumn<=f&&h.endColumn>=f&&h.startRow<=m&&h.endRow>=m)){const h=u.worksheet.getCellRaw(m,f),P=h==null?void 0:h.v,I=h==null?void 0:h.t;if(P==null||I!==s.CellValueType.NUMBER||this._previewPattern===null)return S;const M=d.getPatternPreviewIgnoreGeneral(this._previewPattern,P,this._sheetsNumfmtCellContentController.locale);if(M.color){const U=(b=this._themeService.getColorFromTheme(`${M.color}.500`))!=null?b:M.color;return{...S,v:M.result,t:s.CellValueType.STRING,s:{cl:{rgb:U}}}}return{...S,v:M.result,t:s.CellValueType.STRING}}return S}})),(p=(o=this._renderManagerService.getRenderById(a.getUnitId()))==null?void 0:o.mainComponent)==null||p.makeDirty()})))}_commandExecutedListener(){const t=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id];this.disposeWithMe(new w.Observable(r=>{const n=this._commandService.onCommandExecuted(i=>{if(t.includes(i.id)){const a=i.params;r.next(a.unitId)}});return()=>n.dispose()}).pipe(W.debounceTime(16)).subscribe(r=>this._forceUpdate(r)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{var r;t||((r=this._sidebarDisposable)==null||r.dispose(),this._sidebarDisposable=null)})}};A=Le([D(0,s.Inject(g.SheetInterceptorService)),D(1,s.Inject(s.ThemeService)),D(2,s.IUniverInstanceService),D(3,s.ICommandService),D(4,s.Inject(g.SheetsSelectionsService)),D(5,k.IRenderManagerService),D(6,g.INumfmtService),D(7,s.Inject(_.ComponentManager)),D(8,_.ISidebarService),D(9,s.Inject(s.LocaleService)),D(10,s.Inject(d.SheetsNumfmtCellContentController))],A);var je=Object.getOwnPropertyDescriptor,Fe=(e,t,r,n)=>{for(var i=n>1?void 0:n?je(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},H=(e,t)=>(r,n)=>t(r,n,e);const Ae=()=>{let e=[];return{add:(i,a,o,p,c)=>e.push({unitId:i,subUnitId:a,row:o,col:p,value:c}),getEffects:()=>e,clean:()=>{e=[]}}};let B=class extends s.Disposable{constructor(t,r,n,i,a){super();q(this,"_collectEffectMutation",Ae());this._sheetInterceptorService=t,this._numfmtService=r,this._univerInstanceService=n,this._injector=i,this._editorBridgeService=a,this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.BEFORE_CELL_EDIT,{handler:(t,r,n)=>{const i=r.row,a=r.col,o=this._numfmtService.getValue(r.unitId,r.subUnitId,i,a);if(o)switch(d.getPatternType(o.pattern)){case"scientific":case"currency":case"grouped":case"number":{const c=r.worksheet.getCellRaw(i,a);return(c==null?void 0:c.t)===s.CellValueType.NUMBER&&(c==null?void 0:c.v)!==void 0&&c.v!==null&&s.isRealNum(c.v)&&(c.v=me.stripErrorMargin(Number(c.v))),n&&n(c)}default:return n&&n(t)}return n(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(t,r,n)=>{var u,v,m;if(!(t!=null&&t.v)&&!(t!=null&&t.p))return n(t);this._collectEffectMutation.clean();const i=this._numfmtService.getValue(r.unitId,r.subUnitId,r.row,r.col),a=r.worksheet.getCellRaw(r.row,r.col);if(s.isTextFormat(i==null?void 0:i.pattern)||t.t===s.CellValueType.FORCE_STRING)return n(t);const o=(u=t.p)==null?void 0:u.body,p=(m=(v=t==null?void 0:t.p)==null?void 0:v.body)!=null&&m.dataStream?t.p.body.dataStream.replace(/\r\n$/,""):String(t.v),c=s.getNumfmtParseValueFilter(p);if(o)if(He(o)){const{dataStream:f}=o,S=f.replace(/\r\n$/,""),b=Number(S);if(Number.isNaN(b)&&!c)return n(t)}else return n(t);if(c){if(!c.z&&!(i!=null&&i.pattern)&&(a==null?void 0:a.t)!==s.CellValueType.STRING&&(a==null?void 0:a.t)!==s.CellValueType.FORCE_STRING&&s.willLoseNumericPrecision(p))return n({...t,p:void 0,v:p,t:s.CellValueType.FORCE_STRING});c.z&&this._collectEffectMutation.add(r.unitId,r.subUnitId,r.row,r.col,{pattern:c.z});const f=Number(c.v);return n({...t,p:void 0,v:f,t:s.CellValueType.NUMBER})}return n(t)}})))}_initInterceptorCommands(){const t=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(r){var n;switch(r.id){case g.SetRangeValuesCommand.id:{const i=t._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),a=i.getUnitId(),o=(n=i.getActiveSheet())==null?void 0:n.getSheetId();if(!o)return{redos:[],undos:[]};const p=t._collectEffectMutation.getEffects();if(t._collectEffectMutation.clean(),!p.length)return{redos:[],undos:[]};const c=p.filter(f=>{var S;return!!((S=f.value)!=null&&S.pattern)}).map(f=>({row:f.row,col:f.col,pattern:f.value.pattern})),u=p.filter(f=>{var S;return!((S=f.value)!=null&&S.pattern)}).map(f=>({startRow:f.row,endColumn:f.col,startColumn:f.col,endRow:f.row})),v=[],m=[];if(c.length){const f={id:g.SetNumfmtMutation.id,params:g.transformCellsToRange(a,o,c)};v.push(f),m.push(...g.factorySetNumfmtUndoMutation(t._injector,f.params))}if(u.length){const f={id:g.RemoveNumfmtMutation.id,params:{unitId:a,subUnitId:o,ranges:u}};v.push(f),m.push(...g.factoryRemoveNumfmtUndoMutation(t._injector,f.params))}return{redos:v,undos:m.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};B=Fe([H(0,s.Inject(g.SheetInterceptorService)),H(1,s.Inject(g.INumfmtService)),H(2,s.Inject(s.IUniverInstanceService)),H(3,s.Inject(s.Injector)),H(4,s.Optional(N.IEditorBridgeService))],B);function He(e){const{textRuns:t=[],paragraphs:r=[],customRanges:n,customBlocks:i=[]}=e,a=["va"];return!(t.some(o=>!!(o.ts&&Object.keys(o.ts).some(c=>a.includes(c))))||r.some(o=>o.bullet)||r.length>=2||n!=null&&n.length||i.length>0)}const ae=e=>[{label:"sheet.numfmt.general",pattern:null},{label:"sheet.numfmt.text",pattern:s.DEFAULT_TEXT_FORMAT_EXCEL},"|",{label:"sheet.numfmt.number",pattern:"0"},{label:"sheet.numfmt.percent",pattern:"0.00%"},{label:"sheet.numfmt.scientific",pattern:"0.00E+00"},"|",{label:"sheet.numfmt.accounting",pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.financialValue",pattern:"#,##0.00;[Red]#,##0.00"},{label:"sheet.numfmt.currency",pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:"sheet.numfmt.roundingCurrency",pattern:`"${e}"#,##0;[Red]"${e}"#,##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:""}],Re=e=>({icon:new w.Observable(t=>{const r=e.get(s.LocaleService);return t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon),r.localeChanged$.subscribe(()=>{t.next(d.getCurrencySymbolIconByLocale(r.getCurrentLocale()).icon)})}),id:d.SetCurrencyCommand.id,title:"sheet.numfmt.currency",tooltip:"sheet.numfmt.currency",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),We=e=>({icon:"AddDigitsIcon",id:d.AddDecimalCommand.id,title:"sheet.numfmt.addDecimal",tooltip:"sheet.numfmt.addDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Be=e=>({icon:"ReduceDigitsIcon",id:d.SubtractDecimalCommand.id,title:"sheet.numfmt.subtractDecimal",tooltip:"sheet.numfmt.subtractDecimal",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),Ve=e=>({icon:"PercentIcon",id:d.SetPercentCommand.id,title:"sheet.numfmt.percent",tooltip:"sheet.numfmt.percent",type:_.MenuItemType.BUTTON,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetEditPermission,g.WorksheetSetCellStylePermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}),qe=e=>{const t=e.get(s.IUniverInstanceService),r=e.get(s.ICommandService),n=e.get(s.LocaleService),i=e.get(g.SheetsSelectionsService),a=[g.RemoveNumfmtMutation.id,g.SetNumfmtMutation.id],o=N.deriveStateFromActiveSheet$(t,"",({workbook:p,worksheet:c})=>new w.Observable(u=>w.merge(i.selectionMoveEnd$,s.fromCallback(r.onCommandExecuted.bind(r)).pipe(w.filter(([v])=>a.includes(v.id)))).subscribe(()=>{var m,f;const v=i.getCurrentSelections();if(v&&v[0]){const S=v[0].range,b=S.startRow,h=S.startColumn,P=(f=p.getStyles().get((m=c.getCell(b,h))==null?void 0:m.s))==null?void 0:f.n,I=P==null?void 0:P.pattern,M=d.getCurrencySymbolByLocale(n.getCurrentLocale());let U=n.t("sheet.numfmt.general");if(s.isDefaultFormat(I)){u.next(U);return}if(I){const x=ae(M).filter(O=>typeof O=="object"&&O.pattern).find(O=>s.isPatternEqualWithoutDecimal(I,O.pattern));x&&typeof x=="object"&&x.pattern?U=n.t(x.label):U=n.t("sheet.numfmt.moreFmt")}u.next(U)}})));return{label:oe,id:j.id,tooltip:"sheet.numfmt.title",type:_.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:ce,hoverable:!1,selectable:!1}}],value$:o,hidden$:_.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[g.WorkbookEditablePermission],worksheetTypes:[g.WorksheetSetCellStylePermission,g.WorksheetEditPermission],rangeTypes:[g.RangeProtectionPermissionEditPoint]})}},oe="sheet.numfmt.moreNumfmtType",ce="sheet.numfmt.moreNumfmtType.options";function Ge(e){const{value:t}=e,r=_.useDependency(s.LocaleService),n=t!=null?t:r.t("sheet.numfmt.general");return l.jsx("span",{className:"univer-text-sm",children:n})}function Ke(){const e=_.useDependency(s.ICommandService),t=_.useDependency(s.LocaleService),r=_.useDependency(_.ILayoutService),n=_.useDependency(d.SheetsNumfmtCellContentController),i=_.useDependency(g.SheetsSelectionsService),a=u=>{const v=i.getCurrentLastSelection();if(!v)return;const m=v.range,f=[];s.Range.foreach(m,(S,b)=>{u?f.push({row:S,col:b,pattern:u,type:d.getPatternType(u)}):f.push({row:S,col:b})}),e.executeCommand(d.SetNumfmtCommand.id,{values:f}),r.focus()},o=y.useMemo(()=>{const u=d.localeCurrencySymbolMap.get(t.getCurrentLocale());return ae(u)},[t]),p=u=>{if(u===0)a(null);else if(u===o.length-1)e.executeCommand(j.id),r.focus();else{const v=o[u];v.pattern&&a(v.pattern)}},c=1220;return l.jsx("div",{className:"univer-grid univer-gap-1 univer-p-1.5",children:o.map((u,v)=>u==="|"?l.jsx(E.Separator,{},v):l.jsxs("div",{className:"univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",onClick:()=>p(v),children:[l.jsx("span",{children:t.t(u.label)}),l.jsx("span",{className:"univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",children:u.pattern?d.getPatternPreview(u.pattern||"",c,n.locale).result.trim():""})]},v))})}const Ye={[_.RibbonStartGroup.LAYOUT]:{[j.id]:{order:9,menuItemFactory:qe},[d.SetPercentCommand.id]:{order:9.1,menuItemFactory:Ve},[d.SetCurrencyCommand.id]:{order:9.2,menuItemFactory:Re},[d.AddDecimalCommand.id]:{order:9.3,menuItemFactory:We},[d.SubtractDecimalCommand.id]:{order:9.4,menuItemFactory:Be}}};var Ze=Object.getOwnPropertyDescriptor,ze=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ze(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},le=(e,t)=>(r,n)=>t(r,n,e);let V=class extends s.Disposable{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(Ye),[[oe,Ge],[ce,Ke]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};V=ze([le(0,s.Inject(_.ComponentManager)),le(1,_.IMenuManagerService)],V);var Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(e,t,r)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t,r,n)=>{for(var i=n>1?void 0:n?Je(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},J=(e,t)=>(r,n)=>t(r,n,e),ue=(e,t,r)=>Qe(e,typeof t!="symbol"?t+"":t,r);const tt="SHEET_NUMFMT_UI_PLUGIN";C.UniverSheetsNumfmtUIPlugin=class extends s.Plugin{constructor(t=ee,r,n,i){super(),this._config=t,this._injector=r,this._configService=n,this._renderManagerService=i;const{menu:a,...o}=s.merge({},ee,this._config);a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig("sheets-numfmt-ui.config",o)}onStarting(){s.registerDependencies(this._injector,[[A],[B],[F],[V]])}onRendered(){this._registerRenderModules(),s.touchDependencies(this._injector,[[A],[B],[V]])}_registerRenderModules(){[[K]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,r))})}},ue(C.UniverSheetsNumfmtUIPlugin,"pluginName",tt),ue(C.UniverSheetsNumfmtUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),C.UniverSheetsNumfmtUIPlugin=et([s.DependentOn(N.UniverSheetsUIPlugin,d.UniverSheetsNumfmtPlugin),J(1,s.Inject(s.Injector)),J(2,s.IConfigService),J(3,k.IRenderManagerService)],C.UniverSheetsNumfmtUIPlugin),Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsNumfmtUiSkSK=t())})(this,(function(){"use strict";return{sheet:{numfmt:{title:"Formát čísla",numfmtType:"Typy formátov",cancel:"Zrušiť",confirm:"Potvrdiť",general:"Všeobecný",accounting:"Účtovnícky",text:"Text",number:"Číslo",percent:"Percento",scientific:"Vedecký",currency:"Mena",date:"Dátum",time:"Čas",thousandthPercentile:"Oddeľovač tisícov",preview:"Náhľad",dateTime:"Dátum a čas",decimalLength:"Počet desatinných miest",currencyType:"Symbol meny",moreFmt:"Formáty",financialValue:"Finančná hodnota",roundingCurrency:"Zaokrúhľovanie meny",timeDuration:"Trvanie",currencyDes:"Formát meny sa používa na zobrazenie bežných menových hodnôt. Účtovnícky formát zarovná stĺpec hodnôt podľa desatinných miest.",accountingDes:"Účtovnícky formát čísiel zarovná stĺpec hodnôt so symbolmi meny a desatinnými miestami.",dateType:"Typ dátumu",dateDes:"Formát dátumu zobrazuje hodnoty dátumu a času ako dátumy.",negType:"Typ záporného čísla",generalDes:"Všeobecný formát neobsahuje žiadny špecifický formát čísla.",thousandthPercentileDes:"Percentilný formát sa používa na reprezentáciu bežných čísel. Menové a účtovnícke formáty poskytujú špecializovaný formát pre výpočty menových hodnôt.",addDecimal:"Zvýšiť počet desatinných miest",subtractDecimal:"Znížiť počet desatinných miest",customFormat:"Vlastný formát",customFormatDes:"Vytvorte vlastné formáty čísiel na základe existujúcich formátov."}}}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt-ui",
3
- "version": "0.15.2",
3
+ "version": "0.15.3-insiders.20260131-b9b8805",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,14 +55,14 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^1.1.1",
58
- "@univerjs/core": "0.15.2",
59
- "@univerjs/design": "0.15.2",
60
- "@univerjs/engine-formula": "0.15.2",
61
- "@univerjs/engine-render": "0.15.2",
62
- "@univerjs/sheets": "0.15.2",
63
- "@univerjs/sheets-numfmt": "0.15.2",
64
- "@univerjs/sheets-ui": "0.15.2",
65
- "@univerjs/ui": "0.15.2"
58
+ "@univerjs/core": "0.15.3-insiders.20260131-b9b8805",
59
+ "@univerjs/design": "0.15.3-insiders.20260131-b9b8805",
60
+ "@univerjs/engine-render": "0.15.3-insiders.20260131-b9b8805",
61
+ "@univerjs/engine-formula": "0.15.3-insiders.20260131-b9b8805",
62
+ "@univerjs/sheets": "0.15.3-insiders.20260131-b9b8805",
63
+ "@univerjs/sheets-ui": "0.15.3-insiders.20260131-b9b8805",
64
+ "@univerjs/ui": "0.15.3-insiders.20260131-b9b8805",
65
+ "@univerjs/sheets-numfmt": "0.15.3-insiders.20260131-b9b8805"
66
66
  },
67
67
  "devDependencies": {
68
68
  "postcss": "^8.5.6",
@@ -71,8 +71,8 @@
71
71
  "tailwindcss": "3.4.18",
72
72
  "typescript": "^5.9.3",
73
73
  "vite": "^7.3.1",
74
- "vitest": "^4.0.16",
75
- "@univerjs-infra/shared": "0.15.2"
74
+ "vitest": "^4.0.18",
75
+ "@univerjs-infra/shared": "0.15.3"
76
76
  },
77
77
  "scripts": {
78
78
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS