@univerjs/sheets-numfmt-ui 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -592,7 +592,7 @@ const menuSchema = { [_univerjs_ui.RibbonStartGroup.NUMBER]: {
592
592
  //#endregion
593
593
  //#region package.json
594
594
  var name = "@univerjs/sheets-numfmt-ui";
595
- var version = "1.0.2";
595
+ var version = "1.0.4";
596
596
 
597
597
  //#endregion
598
598
  //#region src/config/config.ts
@@ -671,11 +671,7 @@ function createMobileNumberFormatMenuConfig(currencySymbol) {
671
671
  commandId: _univerjs_sheets_numfmt.AddDecimalCommand.id
672
672
  }],
673
673
  detailOptions,
674
- customPatterns: [.../* @__PURE__ */ new Set([
675
- ..._univerjs_sheets_numfmt.CURRENCYFORMAT.map((item) => item.suffix(currencySymbol)),
676
- ..._univerjs_sheets_numfmt.DATEFMTLISG.map((item) => item.suffix),
677
- ..._univerjs_sheets_numfmt.NUMBERFORMAT.map((item) => item.suffix)
678
- ])]
674
+ customPatterns: [.../* @__PURE__ */ new Set([..._univerjs_sheets_numfmt.CURRENCYFORMAT.map((item) => item.suffix(currencySymbol)), ..._univerjs_sheets_numfmt.NUMBERFORMAT.map((item) => item.suffix)])]
679
675
  };
680
676
  }
681
677
  function FactoryMobileOtherMenuItem(accessor) {
@@ -726,8 +722,21 @@ function FactoryMobileOtherMenuItem(accessor) {
726
722
  function MobileCustomFormat(props) {
727
723
  const { patterns, onConfirm } = props;
728
724
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
725
+ const locale = (0, _univerjs_ui.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
729
726
  const [pattern, setPattern] = (0, react.useState)("");
730
727
  const title = localeService.t("sheets-numfmt-ui.customFormat");
728
+ const options = (0, react.useMemo)(() => [.../* @__PURE__ */ new Set([
729
+ ...patterns,
730
+ ...(0, _univerjs_sheets_numfmt.getDateFormatOptions)(locale).map((item) => item.value),
731
+ ...pattern ? [pattern] : []
732
+ ])].map((value) => ({
733
+ label: value,
734
+ value
735
+ })), [
736
+ locale,
737
+ pattern,
738
+ patterns
739
+ ]);
731
740
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
732
741
  "data-u-comp": "mobile-custom-format",
733
742
  className: "univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-gap-4",
@@ -743,10 +752,7 @@ function MobileCustomFormat(props) {
743
752
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileSelect, {
744
753
  className: "univer-w-full univer-shrink-0 [&>div]:univer-font-mono",
745
754
  value: pattern || title,
746
- options: patterns.map((item) => ({
747
- label: item,
748
- value: item
749
- })),
755
+ options,
750
756
  onChange: setPattern
751
757
  }),
752
758
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -1620,14 +1626,15 @@ function CustomFormat(props) {
1620
1626
  const userHabitController = (0, _univerjs_ui.useDependency)(UserHabitController);
1621
1627
  const localStorageService = (0, _univerjs_ui.useDependency)(_univerjs_core.ILocalStorageService);
1622
1628
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
1629
+ const locale = (0, _univerjs_ui.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
1623
1630
  const [pattern, setPattern] = (0, react.useState)(defaultPattern);
1624
1631
  (0, react.useLayoutEffect)(() => {
1625
1632
  onActionChange(() => {
1626
1633
  userHabitController.markHabit(key$1, pattern);
1627
1634
  localStorageService.getItem(historyPatternKey).then((list = []) => {
1628
1635
  const _list = [.../* @__PURE__ */ new Set([pattern, ...list || []])].splice(0, 10).filter((e) => !!e);
1629
- localStorageService.setItem(historyPatternKey, _list);
1630
- });
1636
+ return localStorageService.setItem(historyPatternKey, _list);
1637
+ }).catch(console.error);
1631
1638
  return pattern;
1632
1639
  });
1633
1640
  }, [
@@ -1642,18 +1649,22 @@ function CustomFormat(props) {
1642
1649
  localStorageService.getItem(historyPatternKey).then((historyList) => {
1643
1650
  const list = [
1644
1651
  ..._univerjs_sheets_numfmt.CURRENCYFORMAT.map((item) => item.suffix("$")),
1645
- ..._univerjs_sheets_numfmt.DATEFMTLISG.map((item) => item.suffix),
1652
+ ...(0, _univerjs_sheets_numfmt.getDateFormatOptions)(locale).map((item) => item.value),
1646
1653
  ..._univerjs_sheets_numfmt.NUMBERFORMAT.map((item) => item.suffix),
1647
1654
  ...historyList ?? []
1648
1655
  ];
1649
1656
  return userHabitController.addHabit(key$1, []).then(() => userHabitController.getHabit(key$1, list));
1650
1657
  }).then((list) => {
1651
1658
  if (!cancelled) setOptions([...new Set(list)]);
1652
- });
1659
+ }).catch(console.error);
1653
1660
  return () => {
1654
1661
  cancelled = true;
1655
1662
  };
1656
- }, [localStorageService, userHabitController]);
1663
+ }, [
1664
+ locale,
1665
+ localStorageService,
1666
+ userHabitController
1667
+ ]);
1657
1668
  const handleClick = (p) => {
1658
1669
  setPattern(p);
1659
1670
  onChange(p);
@@ -1695,7 +1706,7 @@ function CustomFormat(props) {
1695
1706
  //#region src/views/components/Date.tsx
1696
1707
  const isDatePanel = (pattern) => {
1697
1708
  const info = _univerjs_core.numfmt.getFormatInfo(pattern);
1698
- return (0, _univerjs_sheets_numfmt.getDateFormatOptions)().map((item) => item.value).includes(pattern) || [
1709
+ return [
1699
1710
  "date",
1700
1711
  "datetime",
1701
1712
  "time"
@@ -1703,20 +1714,15 @@ const isDatePanel = (pattern) => {
1703
1714
  };
1704
1715
  function DatePanel(props) {
1705
1716
  const { onActionChange, onChange, defaultPattern } = props;
1706
- const options = (0, react.useMemo)(_univerjs_sheets_numfmt.getDateFormatOptions, []);
1707
1717
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
1708
- const [suffix, setSuffix] = (0, react.useState)(() => {
1709
- if (defaultPattern) {
1710
- const item = options.find((item) => item.value === defaultPattern);
1711
- if (item) return item.value;
1712
- }
1713
- return options[0].value;
1714
- });
1718
+ const locale = (0, _univerjs_ui.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
1719
+ const [suffix, setSuffix] = (0, react.useState)(() => defaultPattern || (0, _univerjs_sheets_numfmt.getDateFormatOptions)(locale)[0].value);
1720
+ const options = (0, react.useMemo)(() => (0, _univerjs_sheets_numfmt.getDateFormatOptions)(locale, suffix), [locale, suffix]);
1715
1721
  (0, react.useLayoutEffect)(() => {
1716
1722
  onActionChange(() => suffix);
1717
1723
  }, [onActionChange, suffix]);
1718
1724
  const handleChange = (v) => {
1719
- if (v === void 0) return;
1725
+ if (typeof v !== "string") return;
1720
1726
  setSuffix(v);
1721
1727
  onChange(v);
1722
1728
  };
@@ -1889,47 +1895,51 @@ const useNextTick = () => {
1889
1895
 
1890
1896
  //#endregion
1891
1897
  //#region src/views/SheetNumfmtPanel.tsx
1898
+ const TYPE_OPTIONS = [
1899
+ {
1900
+ label: "sheets-numfmt-ui.general",
1901
+ component: GeneralPanel
1902
+ },
1903
+ {
1904
+ label: "sheets-numfmt-ui.accounting",
1905
+ component: AccountingPanel
1906
+ },
1907
+ {
1908
+ label: "sheets-numfmt-ui.currency",
1909
+ component: CurrencyPanel
1910
+ },
1911
+ {
1912
+ label: "sheets-numfmt-ui.date",
1913
+ component: DatePanel
1914
+ },
1915
+ {
1916
+ label: "sheets-numfmt-ui.thousandthPercentile",
1917
+ component: ThousandthPercentilePanel
1918
+ },
1919
+ {
1920
+ label: "sheets-numfmt-ui.customFormat",
1921
+ component: CustomFormat
1922
+ }
1923
+ ];
1892
1924
  function SheetNumfmtPanel(props) {
1893
- var _typeOptions$find;
1925
+ const { row, col, defaultPattern } = props.value;
1926
+ return /* @__PURE__ */ (0, react.createElement)(SheetNumfmtPanelContent, {
1927
+ ...props,
1928
+ key: `${row}_${col}_${defaultPattern}`
1929
+ });
1930
+ }
1931
+ function SheetNumfmtPanelContent(props) {
1932
+ var _TYPE_OPTIONS$find;
1933
+ const { onChange } = props;
1894
1934
  const { defaultValue, defaultPattern, row, col } = props.value;
1895
1935
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
1936
+ (0, _univerjs_ui.useObservable)(localeService.currentLocale$, localeService.getCurrentLocale());
1896
1937
  const currentPatternRef = (0, react.useRef)(() => "");
1897
1938
  const nextTick = useNextTick();
1898
- const typeOptions = (0, react.useMemo)(() => {
1899
- return [
1900
- {
1901
- label: "sheets-numfmt-ui.general",
1902
- component: GeneralPanel
1903
- },
1904
- {
1905
- label: "sheets-numfmt-ui.accounting",
1906
- component: AccountingPanel
1907
- },
1908
- {
1909
- label: "sheets-numfmt-ui.currency",
1910
- component: CurrencyPanel
1911
- },
1912
- {
1913
- label: "sheets-numfmt-ui.date",
1914
- component: DatePanel
1915
- },
1916
- {
1917
- label: "sheets-numfmt-ui.thousandthPercentile",
1918
- component: ThousandthPercentilePanel
1919
- },
1920
- {
1921
- label: "sheets-numfmt-ui.customFormat",
1922
- component: CustomFormat
1923
- }
1924
- ].map((item) => ({
1925
- ...item,
1926
- label: localeService.t(item.label)
1927
- }));
1928
- }, [localeService]);
1929
1939
  const [type, setType] = (0, react.useState)(findDefaultType);
1930
1940
  const [key, setKey] = (0, react.useState)(() => `${row}_${col}_${defaultPattern}`);
1931
1941
  const { mark, userHabitCurrency } = useCurrencyOptions(() => setKey(`${row}_${col}_${defaultPattern}_userCurrency`));
1932
- const BusinessComponent = (_typeOptions$find = typeOptions.find((item) => item.label === type)) === null || _typeOptions$find === void 0 ? void 0 : _typeOptions$find.component;
1942
+ const BusinessComponent = (_TYPE_OPTIONS$find = TYPE_OPTIONS.find((item) => item.label === type)) === null || _TYPE_OPTIONS$find === void 0 ? void 0 : _TYPE_OPTIONS$find.component;
1933
1943
  function findDefaultType() {
1934
1944
  return [
1935
1945
  isGeneralPanel,
@@ -1937,25 +1947,25 @@ function SheetNumfmtPanel(props) {
1937
1947
  isCurrencyPanel,
1938
1948
  isDatePanel,
1939
1949
  isThousandthPercentilePanel
1940
- ].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? typeOptions[index].label : ""), "") || typeOptions[0].label;
1950
+ ].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? TYPE_OPTIONS[index].label : ""), "") || "sheets-numfmt-ui.customFormat";
1941
1951
  }
1942
- const selectOptions = typeOptions.map((option) => ({
1943
- label: option.label,
1952
+ const selectOptions = TYPE_OPTIONS.map((option) => ({
1953
+ label: localeService.t(option.label),
1944
1954
  value: option.label
1945
1955
  }));
1946
1956
  const handleSelect = (value) => {
1947
1957
  setType(value);
1948
- nextTick(() => props.onChange({
1958
+ nextTick(() => onChange({
1949
1959
  type: "change",
1950
1960
  value: currentPatternRef.current() || ""
1951
1961
  }));
1952
1962
  };
1953
1963
  const handleChange = (0, react.useCallback)((v) => {
1954
- props.onChange({
1964
+ onChange({
1955
1965
  type: "change",
1956
1966
  value: v
1957
1967
  });
1958
- }, []);
1968
+ }, [onChange]);
1959
1969
  const handleActionChange = (0, react.useCallback)((action) => {
1960
1970
  currentPatternRef.current = action;
1961
1971
  }, []);
@@ -1963,13 +1973,13 @@ function SheetNumfmtPanel(props) {
1963
1973
  const pattern = currentPatternRef.current() || "";
1964
1974
  const currency = (0, _univerjs_sheets_numfmt.getCurrencyType)(pattern);
1965
1975
  if (currency) mark(currency);
1966
- props.onChange({
1976
+ onChange({
1967
1977
  type: "confirm",
1968
1978
  value: pattern
1969
1979
  });
1970
1980
  };
1971
1981
  const handleCancel = () => {
1972
- props.onChange({
1982
+ onChange({
1973
1983
  type: "cancel",
1974
1984
  value: ""
1975
1985
  });
@@ -1980,14 +1990,6 @@ function SheetNumfmtPanel(props) {
1980
1990
  defaultValue,
1981
1991
  defaultPattern
1982
1992
  };
1983
- (0, react.useEffect)(() => {
1984
- setType(findDefaultType());
1985
- setKey(`${row}_${col}_${defaultPattern}`);
1986
- }, [
1987
- row,
1988
- col,
1989
- defaultPattern
1990
- ]);
1991
1993
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1992
1994
  className: (0, _univerjs_design.clsx)("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5", _univerjs_design.scrollbarClassName),
1993
1995
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
1
+ import { AddDecimalCommand, CURRENCYFORMAT, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
2
2
  import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, UniverMobileUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
3
3
  import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, RegionService, ThemeService, Tools, UniverInstanceType, currencySymbols, excelSerialToDateTimeParts, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
4
4
  import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
@@ -591,7 +591,7 @@ const menuSchema = { [RibbonStartGroup.NUMBER]: {
591
591
  //#endregion
592
592
  //#region package.json
593
593
  var name = "@univerjs/sheets-numfmt-ui";
594
- var version = "1.0.2";
594
+ var version = "1.0.4";
595
595
 
596
596
  //#endregion
597
597
  //#region src/config/config.ts
@@ -670,11 +670,7 @@ function createMobileNumberFormatMenuConfig(currencySymbol) {
670
670
  commandId: AddDecimalCommand.id
671
671
  }],
672
672
  detailOptions,
673
- customPatterns: [.../* @__PURE__ */ new Set([
674
- ...CURRENCYFORMAT.map((item) => item.suffix(currencySymbol)),
675
- ...DATEFMTLISG.map((item) => item.suffix),
676
- ...NUMBERFORMAT.map((item) => item.suffix)
677
- ])]
673
+ customPatterns: [.../* @__PURE__ */ new Set([...CURRENCYFORMAT.map((item) => item.suffix(currencySymbol)), ...NUMBERFORMAT.map((item) => item.suffix)])]
678
674
  };
679
675
  }
680
676
  function FactoryMobileOtherMenuItem(accessor) {
@@ -725,8 +721,21 @@ function FactoryMobileOtherMenuItem(accessor) {
725
721
  function MobileCustomFormat(props) {
726
722
  const { patterns, onConfirm } = props;
727
723
  const localeService = useDependency(LocaleService);
724
+ const locale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
728
725
  const [pattern, setPattern] = useState("");
729
726
  const title = localeService.t("sheets-numfmt-ui.customFormat");
727
+ const options = useMemo(() => [.../* @__PURE__ */ new Set([
728
+ ...patterns,
729
+ ...getDateFormatOptions(locale).map((item) => item.value),
730
+ ...pattern ? [pattern] : []
731
+ ])].map((value) => ({
732
+ label: value,
733
+ value
734
+ })), [
735
+ locale,
736
+ pattern,
737
+ patterns
738
+ ]);
730
739
  return /* @__PURE__ */ jsxs("div", {
731
740
  "data-u-comp": "mobile-custom-format",
732
741
  className: "univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-gap-4",
@@ -742,10 +751,7 @@ function MobileCustomFormat(props) {
742
751
  /* @__PURE__ */ jsx(MobileSelect, {
743
752
  className: "univer-w-full univer-shrink-0 [&>div]:univer-font-mono",
744
753
  value: pattern || title,
745
- options: patterns.map((item) => ({
746
- label: item,
747
- value: item
748
- })),
754
+ options,
749
755
  onChange: setPattern
750
756
  }),
751
757
  /* @__PURE__ */ jsx("div", {
@@ -1619,14 +1625,15 @@ function CustomFormat(props) {
1619
1625
  const userHabitController = useDependency(UserHabitController);
1620
1626
  const localStorageService = useDependency(ILocalStorageService);
1621
1627
  const localeService = useDependency(LocaleService);
1628
+ const locale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
1622
1629
  const [pattern, setPattern] = useState(defaultPattern);
1623
1630
  useLayoutEffect(() => {
1624
1631
  onActionChange(() => {
1625
1632
  userHabitController.markHabit(key$1, pattern);
1626
1633
  localStorageService.getItem(historyPatternKey).then((list = []) => {
1627
1634
  const _list = [.../* @__PURE__ */ new Set([pattern, ...list || []])].splice(0, 10).filter((e) => !!e);
1628
- localStorageService.setItem(historyPatternKey, _list);
1629
- });
1635
+ return localStorageService.setItem(historyPatternKey, _list);
1636
+ }).catch(console.error);
1630
1637
  return pattern;
1631
1638
  });
1632
1639
  }, [
@@ -1641,18 +1648,22 @@ function CustomFormat(props) {
1641
1648
  localStorageService.getItem(historyPatternKey).then((historyList) => {
1642
1649
  const list = [
1643
1650
  ...CURRENCYFORMAT.map((item) => item.suffix("$")),
1644
- ...DATEFMTLISG.map((item) => item.suffix),
1651
+ ...getDateFormatOptions(locale).map((item) => item.value),
1645
1652
  ...NUMBERFORMAT.map((item) => item.suffix),
1646
1653
  ...historyList ?? []
1647
1654
  ];
1648
1655
  return userHabitController.addHabit(key$1, []).then(() => userHabitController.getHabit(key$1, list));
1649
1656
  }).then((list) => {
1650
1657
  if (!cancelled) setOptions([...new Set(list)]);
1651
- });
1658
+ }).catch(console.error);
1652
1659
  return () => {
1653
1660
  cancelled = true;
1654
1661
  };
1655
- }, [localStorageService, userHabitController]);
1662
+ }, [
1663
+ locale,
1664
+ localStorageService,
1665
+ userHabitController
1666
+ ]);
1656
1667
  const handleClick = (p) => {
1657
1668
  setPattern(p);
1658
1669
  onChange(p);
@@ -1694,7 +1705,7 @@ function CustomFormat(props) {
1694
1705
  //#region src/views/components/Date.tsx
1695
1706
  const isDatePanel = (pattern) => {
1696
1707
  const info = numfmt.getFormatInfo(pattern);
1697
- return getDateFormatOptions().map((item) => item.value).includes(pattern) || [
1708
+ return [
1698
1709
  "date",
1699
1710
  "datetime",
1700
1711
  "time"
@@ -1702,20 +1713,15 @@ const isDatePanel = (pattern) => {
1702
1713
  };
1703
1714
  function DatePanel(props) {
1704
1715
  const { onActionChange, onChange, defaultPattern } = props;
1705
- const options = useMemo(getDateFormatOptions, []);
1706
1716
  const localeService = useDependency(LocaleService);
1707
- const [suffix, setSuffix] = useState(() => {
1708
- if (defaultPattern) {
1709
- const item = options.find((item) => item.value === defaultPattern);
1710
- if (item) return item.value;
1711
- }
1712
- return options[0].value;
1713
- });
1717
+ const locale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
1718
+ const [suffix, setSuffix] = useState(() => defaultPattern || getDateFormatOptions(locale)[0].value);
1719
+ const options = useMemo(() => getDateFormatOptions(locale, suffix), [locale, suffix]);
1714
1720
  useLayoutEffect(() => {
1715
1721
  onActionChange(() => suffix);
1716
1722
  }, [onActionChange, suffix]);
1717
1723
  const handleChange = (v) => {
1718
- if (v === void 0) return;
1724
+ if (typeof v !== "string") return;
1719
1725
  setSuffix(v);
1720
1726
  onChange(v);
1721
1727
  };
@@ -1888,47 +1894,51 @@ const useNextTick = () => {
1888
1894
 
1889
1895
  //#endregion
1890
1896
  //#region src/views/SheetNumfmtPanel.tsx
1897
+ const TYPE_OPTIONS = [
1898
+ {
1899
+ label: "sheets-numfmt-ui.general",
1900
+ component: GeneralPanel
1901
+ },
1902
+ {
1903
+ label: "sheets-numfmt-ui.accounting",
1904
+ component: AccountingPanel
1905
+ },
1906
+ {
1907
+ label: "sheets-numfmt-ui.currency",
1908
+ component: CurrencyPanel
1909
+ },
1910
+ {
1911
+ label: "sheets-numfmt-ui.date",
1912
+ component: DatePanel
1913
+ },
1914
+ {
1915
+ label: "sheets-numfmt-ui.thousandthPercentile",
1916
+ component: ThousandthPercentilePanel
1917
+ },
1918
+ {
1919
+ label: "sheets-numfmt-ui.customFormat",
1920
+ component: CustomFormat
1921
+ }
1922
+ ];
1891
1923
  function SheetNumfmtPanel(props) {
1892
- var _typeOptions$find;
1924
+ const { row, col, defaultPattern } = props.value;
1925
+ return /* @__PURE__ */ createElement(SheetNumfmtPanelContent, {
1926
+ ...props,
1927
+ key: `${row}_${col}_${defaultPattern}`
1928
+ });
1929
+ }
1930
+ function SheetNumfmtPanelContent(props) {
1931
+ var _TYPE_OPTIONS$find;
1932
+ const { onChange } = props;
1893
1933
  const { defaultValue, defaultPattern, row, col } = props.value;
1894
1934
  const localeService = useDependency(LocaleService);
1935
+ useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
1895
1936
  const currentPatternRef = useRef(() => "");
1896
1937
  const nextTick = useNextTick();
1897
- const typeOptions = useMemo(() => {
1898
- return [
1899
- {
1900
- label: "sheets-numfmt-ui.general",
1901
- component: GeneralPanel
1902
- },
1903
- {
1904
- label: "sheets-numfmt-ui.accounting",
1905
- component: AccountingPanel
1906
- },
1907
- {
1908
- label: "sheets-numfmt-ui.currency",
1909
- component: CurrencyPanel
1910
- },
1911
- {
1912
- label: "sheets-numfmt-ui.date",
1913
- component: DatePanel
1914
- },
1915
- {
1916
- label: "sheets-numfmt-ui.thousandthPercentile",
1917
- component: ThousandthPercentilePanel
1918
- },
1919
- {
1920
- label: "sheets-numfmt-ui.customFormat",
1921
- component: CustomFormat
1922
- }
1923
- ].map((item) => ({
1924
- ...item,
1925
- label: localeService.t(item.label)
1926
- }));
1927
- }, [localeService]);
1928
1938
  const [type, setType] = useState(findDefaultType);
1929
1939
  const [key, setKey] = useState(() => `${row}_${col}_${defaultPattern}`);
1930
1940
  const { mark, userHabitCurrency } = useCurrencyOptions(() => setKey(`${row}_${col}_${defaultPattern}_userCurrency`));
1931
- const BusinessComponent = (_typeOptions$find = typeOptions.find((item) => item.label === type)) === null || _typeOptions$find === void 0 ? void 0 : _typeOptions$find.component;
1941
+ const BusinessComponent = (_TYPE_OPTIONS$find = TYPE_OPTIONS.find((item) => item.label === type)) === null || _TYPE_OPTIONS$find === void 0 ? void 0 : _TYPE_OPTIONS$find.component;
1932
1942
  function findDefaultType() {
1933
1943
  return [
1934
1944
  isGeneralPanel,
@@ -1936,25 +1946,25 @@ function SheetNumfmtPanel(props) {
1936
1946
  isCurrencyPanel,
1937
1947
  isDatePanel,
1938
1948
  isThousandthPercentilePanel
1939
- ].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? typeOptions[index].label : ""), "") || typeOptions[0].label;
1949
+ ].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? TYPE_OPTIONS[index].label : ""), "") || "sheets-numfmt-ui.customFormat";
1940
1950
  }
1941
- const selectOptions = typeOptions.map((option) => ({
1942
- label: option.label,
1951
+ const selectOptions = TYPE_OPTIONS.map((option) => ({
1952
+ label: localeService.t(option.label),
1943
1953
  value: option.label
1944
1954
  }));
1945
1955
  const handleSelect = (value) => {
1946
1956
  setType(value);
1947
- nextTick(() => props.onChange({
1957
+ nextTick(() => onChange({
1948
1958
  type: "change",
1949
1959
  value: currentPatternRef.current() || ""
1950
1960
  }));
1951
1961
  };
1952
1962
  const handleChange = useCallback((v) => {
1953
- props.onChange({
1963
+ onChange({
1954
1964
  type: "change",
1955
1965
  value: v
1956
1966
  });
1957
- }, []);
1967
+ }, [onChange]);
1958
1968
  const handleActionChange = useCallback((action) => {
1959
1969
  currentPatternRef.current = action;
1960
1970
  }, []);
@@ -1962,13 +1972,13 @@ function SheetNumfmtPanel(props) {
1962
1972
  const pattern = currentPatternRef.current() || "";
1963
1973
  const currency = getCurrencyType(pattern);
1964
1974
  if (currency) mark(currency);
1965
- props.onChange({
1975
+ onChange({
1966
1976
  type: "confirm",
1967
1977
  value: pattern
1968
1978
  });
1969
1979
  };
1970
1980
  const handleCancel = () => {
1971
- props.onChange({
1981
+ onChange({
1972
1982
  type: "cancel",
1973
1983
  value: ""
1974
1984
  });
@@ -1979,14 +1989,6 @@ function SheetNumfmtPanel(props) {
1979
1989
  defaultValue,
1980
1990
  defaultPattern
1981
1991
  };
1982
- useEffect(() => {
1983
- setType(findDefaultType());
1984
- setKey(`${row}_${col}_${defaultPattern}`);
1985
- }, [
1986
- row,
1987
- col,
1988
- defaultPattern
1989
- ]);
1990
1992
  return /* @__PURE__ */ jsxs("div", {
1991
1993
  className: clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5", scrollbarClassName),
1992
1994
  children: [/* @__PURE__ */ jsxs("div", { children: [
package/lib/index.css CHANGED
@@ -130,6 +130,10 @@
130
130
  border-radius: .5rem;
131
131
  }
132
132
 
133
+ .univer-bg-gray-200 {
134
+ background-color: var(--univer-gray-200);
135
+ }
136
+
133
137
  .univer-p-1\.5 {
134
138
  padding: .375rem;
135
139
  }
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
1
+ import { AddDecimalCommand, CURRENCYFORMAT, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
2
2
  import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, UniverMobileUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
3
3
  import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, RegionService, ThemeService, Tools, UniverInstanceType, currencySymbols, excelSerialToDateTimeParts, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
4
4
  import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
@@ -591,7 +591,7 @@ const menuSchema = { [RibbonStartGroup.NUMBER]: {
591
591
  //#endregion
592
592
  //#region package.json
593
593
  var name = "@univerjs/sheets-numfmt-ui";
594
- var version = "1.0.2";
594
+ var version = "1.0.4";
595
595
 
596
596
  //#endregion
597
597
  //#region src/config/config.ts
@@ -670,11 +670,7 @@ function createMobileNumberFormatMenuConfig(currencySymbol) {
670
670
  commandId: AddDecimalCommand.id
671
671
  }],
672
672
  detailOptions,
673
- customPatterns: [.../* @__PURE__ */ new Set([
674
- ...CURRENCYFORMAT.map((item) => item.suffix(currencySymbol)),
675
- ...DATEFMTLISG.map((item) => item.suffix),
676
- ...NUMBERFORMAT.map((item) => item.suffix)
677
- ])]
673
+ customPatterns: [.../* @__PURE__ */ new Set([...CURRENCYFORMAT.map((item) => item.suffix(currencySymbol)), ...NUMBERFORMAT.map((item) => item.suffix)])]
678
674
  };
679
675
  }
680
676
  function FactoryMobileOtherMenuItem(accessor) {
@@ -725,8 +721,21 @@ function FactoryMobileOtherMenuItem(accessor) {
725
721
  function MobileCustomFormat(props) {
726
722
  const { patterns, onConfirm } = props;
727
723
  const localeService = useDependency(LocaleService);
724
+ const locale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
728
725
  const [pattern, setPattern] = useState("");
729
726
  const title = localeService.t("sheets-numfmt-ui.customFormat");
727
+ const options = useMemo(() => [.../* @__PURE__ */ new Set([
728
+ ...patterns,
729
+ ...getDateFormatOptions(locale).map((item) => item.value),
730
+ ...pattern ? [pattern] : []
731
+ ])].map((value) => ({
732
+ label: value,
733
+ value
734
+ })), [
735
+ locale,
736
+ pattern,
737
+ patterns
738
+ ]);
730
739
  return /* @__PURE__ */ jsxs("div", {
731
740
  "data-u-comp": "mobile-custom-format",
732
741
  className: "univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-gap-4",
@@ -742,10 +751,7 @@ function MobileCustomFormat(props) {
742
751
  /* @__PURE__ */ jsx(MobileSelect, {
743
752
  className: "univer-w-full univer-shrink-0 [&>div]:univer-font-mono",
744
753
  value: pattern || title,
745
- options: patterns.map((item) => ({
746
- label: item,
747
- value: item
748
- })),
754
+ options,
749
755
  onChange: setPattern
750
756
  }),
751
757
  /* @__PURE__ */ jsx("div", {
@@ -1619,14 +1625,15 @@ function CustomFormat(props) {
1619
1625
  const userHabitController = useDependency(UserHabitController);
1620
1626
  const localStorageService = useDependency(ILocalStorageService);
1621
1627
  const localeService = useDependency(LocaleService);
1628
+ const locale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
1622
1629
  const [pattern, setPattern] = useState(defaultPattern);
1623
1630
  useLayoutEffect(() => {
1624
1631
  onActionChange(() => {
1625
1632
  userHabitController.markHabit(key$1, pattern);
1626
1633
  localStorageService.getItem(historyPatternKey).then((list = []) => {
1627
1634
  const _list = [.../* @__PURE__ */ new Set([pattern, ...list || []])].splice(0, 10).filter((e) => !!e);
1628
- localStorageService.setItem(historyPatternKey, _list);
1629
- });
1635
+ return localStorageService.setItem(historyPatternKey, _list);
1636
+ }).catch(console.error);
1630
1637
  return pattern;
1631
1638
  });
1632
1639
  }, [
@@ -1641,18 +1648,22 @@ function CustomFormat(props) {
1641
1648
  localStorageService.getItem(historyPatternKey).then((historyList) => {
1642
1649
  const list = [
1643
1650
  ...CURRENCYFORMAT.map((item) => item.suffix("$")),
1644
- ...DATEFMTLISG.map((item) => item.suffix),
1651
+ ...getDateFormatOptions(locale).map((item) => item.value),
1645
1652
  ...NUMBERFORMAT.map((item) => item.suffix),
1646
1653
  ...historyList ?? []
1647
1654
  ];
1648
1655
  return userHabitController.addHabit(key$1, []).then(() => userHabitController.getHabit(key$1, list));
1649
1656
  }).then((list) => {
1650
1657
  if (!cancelled) setOptions([...new Set(list)]);
1651
- });
1658
+ }).catch(console.error);
1652
1659
  return () => {
1653
1660
  cancelled = true;
1654
1661
  };
1655
- }, [localStorageService, userHabitController]);
1662
+ }, [
1663
+ locale,
1664
+ localStorageService,
1665
+ userHabitController
1666
+ ]);
1656
1667
  const handleClick = (p) => {
1657
1668
  setPattern(p);
1658
1669
  onChange(p);
@@ -1694,7 +1705,7 @@ function CustomFormat(props) {
1694
1705
  //#region src/views/components/Date.tsx
1695
1706
  const isDatePanel = (pattern) => {
1696
1707
  const info = numfmt.getFormatInfo(pattern);
1697
- return getDateFormatOptions().map((item) => item.value).includes(pattern) || [
1708
+ return [
1698
1709
  "date",
1699
1710
  "datetime",
1700
1711
  "time"
@@ -1702,20 +1713,15 @@ const isDatePanel = (pattern) => {
1702
1713
  };
1703
1714
  function DatePanel(props) {
1704
1715
  const { onActionChange, onChange, defaultPattern } = props;
1705
- const options = useMemo(getDateFormatOptions, []);
1706
1716
  const localeService = useDependency(LocaleService);
1707
- const [suffix, setSuffix] = useState(() => {
1708
- if (defaultPattern) {
1709
- const item = options.find((item) => item.value === defaultPattern);
1710
- if (item) return item.value;
1711
- }
1712
- return options[0].value;
1713
- });
1717
+ const locale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
1718
+ const [suffix, setSuffix] = useState(() => defaultPattern || getDateFormatOptions(locale)[0].value);
1719
+ const options = useMemo(() => getDateFormatOptions(locale, suffix), [locale, suffix]);
1714
1720
  useLayoutEffect(() => {
1715
1721
  onActionChange(() => suffix);
1716
1722
  }, [onActionChange, suffix]);
1717
1723
  const handleChange = (v) => {
1718
- if (v === void 0) return;
1724
+ if (typeof v !== "string") return;
1719
1725
  setSuffix(v);
1720
1726
  onChange(v);
1721
1727
  };
@@ -1888,47 +1894,51 @@ const useNextTick = () => {
1888
1894
 
1889
1895
  //#endregion
1890
1896
  //#region src/views/SheetNumfmtPanel.tsx
1897
+ const TYPE_OPTIONS = [
1898
+ {
1899
+ label: "sheets-numfmt-ui.general",
1900
+ component: GeneralPanel
1901
+ },
1902
+ {
1903
+ label: "sheets-numfmt-ui.accounting",
1904
+ component: AccountingPanel
1905
+ },
1906
+ {
1907
+ label: "sheets-numfmt-ui.currency",
1908
+ component: CurrencyPanel
1909
+ },
1910
+ {
1911
+ label: "sheets-numfmt-ui.date",
1912
+ component: DatePanel
1913
+ },
1914
+ {
1915
+ label: "sheets-numfmt-ui.thousandthPercentile",
1916
+ component: ThousandthPercentilePanel
1917
+ },
1918
+ {
1919
+ label: "sheets-numfmt-ui.customFormat",
1920
+ component: CustomFormat
1921
+ }
1922
+ ];
1891
1923
  function SheetNumfmtPanel(props) {
1892
- var _typeOptions$find;
1924
+ const { row, col, defaultPattern } = props.value;
1925
+ return /* @__PURE__ */ createElement(SheetNumfmtPanelContent, {
1926
+ ...props,
1927
+ key: `${row}_${col}_${defaultPattern}`
1928
+ });
1929
+ }
1930
+ function SheetNumfmtPanelContent(props) {
1931
+ var _TYPE_OPTIONS$find;
1932
+ const { onChange } = props;
1893
1933
  const { defaultValue, defaultPattern, row, col } = props.value;
1894
1934
  const localeService = useDependency(LocaleService);
1935
+ useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
1895
1936
  const currentPatternRef = useRef(() => "");
1896
1937
  const nextTick = useNextTick();
1897
- const typeOptions = useMemo(() => {
1898
- return [
1899
- {
1900
- label: "sheets-numfmt-ui.general",
1901
- component: GeneralPanel
1902
- },
1903
- {
1904
- label: "sheets-numfmt-ui.accounting",
1905
- component: AccountingPanel
1906
- },
1907
- {
1908
- label: "sheets-numfmt-ui.currency",
1909
- component: CurrencyPanel
1910
- },
1911
- {
1912
- label: "sheets-numfmt-ui.date",
1913
- component: DatePanel
1914
- },
1915
- {
1916
- label: "sheets-numfmt-ui.thousandthPercentile",
1917
- component: ThousandthPercentilePanel
1918
- },
1919
- {
1920
- label: "sheets-numfmt-ui.customFormat",
1921
- component: CustomFormat
1922
- }
1923
- ].map((item) => ({
1924
- ...item,
1925
- label: localeService.t(item.label)
1926
- }));
1927
- }, [localeService]);
1928
1938
  const [type, setType] = useState(findDefaultType);
1929
1939
  const [key, setKey] = useState(() => `${row}_${col}_${defaultPattern}`);
1930
1940
  const { mark, userHabitCurrency } = useCurrencyOptions(() => setKey(`${row}_${col}_${defaultPattern}_userCurrency`));
1931
- const BusinessComponent = (_typeOptions$find = typeOptions.find((item) => item.label === type)) === null || _typeOptions$find === void 0 ? void 0 : _typeOptions$find.component;
1941
+ const BusinessComponent = (_TYPE_OPTIONS$find = TYPE_OPTIONS.find((item) => item.label === type)) === null || _TYPE_OPTIONS$find === void 0 ? void 0 : _TYPE_OPTIONS$find.component;
1932
1942
  function findDefaultType() {
1933
1943
  return [
1934
1944
  isGeneralPanel,
@@ -1936,25 +1946,25 @@ function SheetNumfmtPanel(props) {
1936
1946
  isCurrencyPanel,
1937
1947
  isDatePanel,
1938
1948
  isThousandthPercentilePanel
1939
- ].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? typeOptions[index].label : ""), "") || typeOptions[0].label;
1949
+ ].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? TYPE_OPTIONS[index].label : ""), "") || "sheets-numfmt-ui.customFormat";
1940
1950
  }
1941
- const selectOptions = typeOptions.map((option) => ({
1942
- label: option.label,
1951
+ const selectOptions = TYPE_OPTIONS.map((option) => ({
1952
+ label: localeService.t(option.label),
1943
1953
  value: option.label
1944
1954
  }));
1945
1955
  const handleSelect = (value) => {
1946
1956
  setType(value);
1947
- nextTick(() => props.onChange({
1957
+ nextTick(() => onChange({
1948
1958
  type: "change",
1949
1959
  value: currentPatternRef.current() || ""
1950
1960
  }));
1951
1961
  };
1952
1962
  const handleChange = useCallback((v) => {
1953
- props.onChange({
1963
+ onChange({
1954
1964
  type: "change",
1955
1965
  value: v
1956
1966
  });
1957
- }, []);
1967
+ }, [onChange]);
1958
1968
  const handleActionChange = useCallback((action) => {
1959
1969
  currentPatternRef.current = action;
1960
1970
  }, []);
@@ -1962,13 +1972,13 @@ function SheetNumfmtPanel(props) {
1962
1972
  const pattern = currentPatternRef.current() || "";
1963
1973
  const currency = getCurrencyType(pattern);
1964
1974
  if (currency) mark(currency);
1965
- props.onChange({
1975
+ onChange({
1966
1976
  type: "confirm",
1967
1977
  value: pattern
1968
1978
  });
1969
1979
  };
1970
1980
  const handleCancel = () => {
1971
- props.onChange({
1981
+ onChange({
1972
1982
  type: "cancel",
1973
1983
  value: ""
1974
1984
  });
@@ -1979,14 +1989,6 @@ function SheetNumfmtPanel(props) {
1979
1989
  defaultValue,
1980
1990
  defaultPattern
1981
1991
  };
1982
- useEffect(() => {
1983
- setType(findDefaultType());
1984
- setKey(`${row}_${col}_${defaultPattern}`);
1985
- }, [
1986
- row,
1987
- col,
1988
- defaultPattern
1989
- ]);
1990
1992
  return /* @__PURE__ */ jsxs("div", {
1991
1993
  className: clsx("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5", scrollbarClassName),
1992
1994
  children: [/* @__PURE__ */ jsxs("div", { children: [
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/sheets-numfmt"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs"),require("rxjs/operators"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets-numfmt`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`rxjs`,`rxjs/operators`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmtUi={},e.UniverSheetsNumfmt,e.UniverUi,e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.rxjs,e.rxjs.operators,e.UniverDesign,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p={id:`sheet.operation.close.numfmt.panel`,type:r.CommandType.OPERATION,handler:()=>!0};function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(n,r){t(n,r,e)}}function y(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let b=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._sheetInterceptorService=e,this._themeService=t,this._univerInstanceService=n,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=a,this._numfmtService=o,this._sidebarService=s,this._localeService=c,this._sheetsNumfmtCellContentController=l,_(this,`_previewPattern`,``),_(this,`_sidebarDisposable`,null),this._initRealTimeRenderingInterceptor(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var e;let n=this._sidebarService,i=this._selectionManagerService,a=this._commandService,o=this._univerInstanceService,s=this._numfmtService,c=this._localeService,l=(((e=i.getCurrentSelections())==null?void 0:e.map(e=>e.range))||[])[0];if(!l)return!1;let u=o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),d=u.getActiveSheet();if(!d)return!1;let f=d.getCellRaw(l.startRow,l.startColumn),m=s.getValue(u.getUnitId(),d.getSheetId(),l.startRow,l.startColumn),h=``;m&&(h=m.pattern);let g=(f==null?void 0:f.t)===r.CellValueType.NUMBER?f.v:12345678,_={onChange:e=>{if(e.type===`change`)this._previewPattern=e.value,this._forceUpdate();else if(e.type===`confirm`){var o;let s=((o=i.getCurrentSelections())==null?void 0:o.map(e=>e.range))||[],c={values:[]},l=(0,t.getPatternType)(e.value);s.forEach(t=>{r.Range.foreach(t,(t,n)=>{c.values.push({row:t,col:n,pattern:e.value,type:l})})}),a.executeCommand(t.SetNumfmtCommand.id,c),n.close()}else e.type===`cancel`&&n.close()},value:{defaultPattern:h,defaultValue:g,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=n.open({header:{title:c.t(`sheets-numfmt-ui.title`)},children:{label:`SHEET_NUMFMT_PANEL`,..._},onClose:()=>{this._forceUpdate(),a.executeCommand(p.id)}}),!0}_forceUpdate(e){var t,n;let i=e??((t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId());if(!i)return;let a=this._renderManagerService.getRenderUnitById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}_initCommands(){[x,p].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initRealTimeRenderingInterceptor(){let e=new s.Observable(e=>{this._commandService.onCommandExecuted(t=>{t.id===x.id&&e.next(!0),t.id===p.id&&e.next(!1)})}),n=(0,s.combineLatest)([e,this._selectionManagerService.selectionMoveEnd$.pipe((0,c.map)(e=>e?e.map(e=>e.range):[]))]);this.disposeWithMe((0,r.toDisposable)(n.pipe((0,c.switchMap)(([e,t])=>new s.Observable(n=>{let i=new r.DisposableCollection;return e&&t.length&&n.next({selectionRanges:t,disposableCollection:i}),()=>{i.dispose()}})),(0,c.tap)(()=>{this._previewPattern=null})).subscribe(({disposableCollection:e,selectionRanges:n})=>{var i;let o=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);this.openPanel(),e.add(this._sheetInterceptorService.intercept(a.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:r.InterceptorEffectEnum.Value|r.InterceptorEffectEnum.Style,handler:(e,i,a)=>{let{row:o,col:s}=i,c=a(e)||{};if(n.find(e=>e.startColumn<=s&&e.endColumn>=s&&e.startRow<=o&&e.endRow>=o)){let e=i.worksheet.getCellRaw(o,s),n=e==null?void 0:e.v,a=e==null?void 0:e.t;if(n==null||a!==r.CellValueType.NUMBER||this._previewPattern===null)return c;let l=(0,t.getPatternPreviewIgnoreGeneral)(this._previewPattern,n,this._sheetsNumfmtCellContentController.locale);if(l.color){let e=this._themeService.getColorFromTheme(`${l.color}.500`)??l.color;return{...c,v:l.result,t:r.CellValueType.STRING,s:{cl:{rgb:e}}}}return{...c,v:l.result,t:r.CellValueType.STRING}}return c}})),(i=this._renderManagerService.getRenderUnitById(o.getUnitId()))==null||(i=i.mainComponent)==null||i.makeDirty()})))}_commandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(!e){var t;(t=this._sidebarDisposable)==null||t.dispose(),this._sidebarDisposable=null}})}};b=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(r.ThemeService)),v(2,r.IUniverInstanceService),v(3,r.ICommandService),v(4,(0,r.Inject)(a.SheetsSelectionsService)),v(5,i.IRenderManagerService),v(6,a.INumfmtService),v(7,n.ISidebarService),v(8,(0,r.Inject)(r.LocaleService)),v(9,(0,r.Inject)(t.SheetsNumfmtCellContentController))],b);let x={id:`sheet.operation.open.numfmt.panel`,type:r.CommandType.OPERATION,handler:e=>(e.get(b).openPanel(),!0)},S=e=>[{label:`sheets-numfmt-ui.general`,pattern:null},{label:`sheets-numfmt-ui.text`,pattern:r.DEFAULT_TEXT_FORMAT_EXCEL},`|`,{label:`sheets-numfmt-ui.number`,pattern:`0`},{label:`sheets-numfmt-ui.percent`,pattern:`0.00%`},{label:`sheets-numfmt-ui.scientific`,pattern:`0.00E+00`},`|`,{label:`sheets-numfmt-ui.accounting`,pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.financialValue`,pattern:`#,##0.00;[Red]#,##0.00`},{label:`sheets-numfmt-ui.currency`,pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.roundingCurrency`,pattern:`"${e}"#,##0;[Red]"${e}"#,##0`},`|`,{label:`sheets-numfmt-ui.date`,pattern:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.time`,pattern:`am/pm h":"mm":"ss`},{label:`sheets-numfmt-ui.dateTime`,pattern:`yyyy-m-d am/pm h:mm`},{label:`sheets-numfmt-ui.timeDuration`,pattern:`[h]:mm:ss`},`|`,{label:`sheets-numfmt-ui.moreFmt`,pattern:``}],C=`sheets-numfmt-ui.moreNumfmtType`,w=`sheets-numfmt-ui.moreNumfmtType.options`;function ee(e){let{value:t}=e,i=(0,n.useDependency)(r.LocaleService),a=t??i.t(`sheets-numfmt-ui.general`);return(0,d.jsx)(`span`,{className:`univer-text-sm`,children:a})}function te(){let e=(0,n.useDependency)(r.ICommandService),i=(0,n.useDependency)(r.LocaleService),o=(0,n.useDependency)(r.RegionService),s=(0,n.useDependency)(n.ILayoutService),c=(0,n.useDependency)(t.SheetsNumfmtCellContentController),f=(0,n.useObservable)(i.direction$,i.getDirection()),p=(0,n.useObservable)(o.currentRegion$,o.getCurrentRegion()),m=(0,n.useDependency)(a.SheetsSelectionsService),h=n=>{let i=m.getCurrentLastSelection();if(!i)return;let a=i.range,o=[];r.Range.foreach(a,(e,r)=>{n?o.push({row:e,col:r,pattern:n,type:(0,t.getPatternType)(n)}):o.push({row:e,col:r})}),e.executeCommand(t.SetNumfmtCommand.id,{values:o}),s.focus()},g=(0,u.useMemo)(()=>{let e=(0,t.getCurrencySymbolByLocale)(p);return S(e)},[p]),_=t=>{if(t===0)h(null);else if(t===g.length-1)e.executeCommand(x.id),s.focus();else{let e=g[t];e.pattern&&h(e.pattern)}};return(0,d.jsx)(`div`,{dir:f,className:`univer-grid univer-gap-1 univer-p-1.5`,children:g.map((e,n)=>e===`|`?(0,d.jsx)(l.Separator,{},n):(0,d.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:()=>_(n),children:[(0,d.jsx)(`span`,{children:i.t(e.label)}),(0,d.jsx)(`span`,{className:`univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:e.pattern?(0,t.getPatternPreview)(e.pattern||``,1220,c.locale).result.trim():``})]},n))})}function ne(e){return{icon:e.get(r.RegionService).currentRegion$.pipe((0,s.map)(e=>(0,t.getCurrencySymbolIconByLocale)(e).icon)),id:t.SetCurrencyCommand.id,title:`sheets-numfmt-ui.currency`,tooltip:`sheets-numfmt-ui.currency`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function re(e){return{icon:`AddDigitsIcon`,id:t.AddDecimalCommand.id,title:`sheets-numfmt-ui.addDecimal`,tooltip:`sheets-numfmt-ui.addDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ie(e){return{icon:`ReduceDigitsIcon`,id:t.SubtractDecimalCommand.id,title:`sheets-numfmt-ui.subtractDecimal`,tooltip:`sheets-numfmt-ui.subtractDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ae(e){return{icon:`PercentIcon`,id:t.SetPercentCommand.id,title:`sheets-numfmt-ui.percent`,tooltip:`sheets-numfmt-ui.percent`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function oe(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(r.RegionService),d=e.get(a.SheetsSelectionsService),f=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],p=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(d.selectionMoveEnd$,u.currentRegion$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>f.includes(e.id)))).subscribe(()=>{let a=d.getCurrentSelections();if(a&&a[0]){var o,s;let c=a[0].range,d=c.startRow,f=c.startColumn,p=(o=e.getStyles().get((s=n.getCell(d,f))==null?void 0:s.s))==null?void 0:o.n,m=p==null?void 0:p.pattern,h=(0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()),g=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(m)){i.next(g);return}if(m){let e=S(h).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(m,e.pattern));g=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(g)}})));return{label:C,id:x.id,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:w,hoverable:!1,selectable:!1}}],value$:p,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}let T={[n.RibbonStartGroup.NUMBER]:{[x.id]:{order:9,gridLayout:{row:1,column:1,columnSpan:4,width:160},menuItemFactory:oe},[t.SetPercentCommand.id]:{order:9.1,gridLayout:{row:2,column:1},menuItemFactory:ae},[t.SetCurrencyCommand.id]:{order:9.2,gridLayout:{row:2,column:2},menuItemFactory:ne},[t.AddDecimalCommand.id]:{order:9.3,gridLayout:{row:2,column:3},menuItemFactory:re},[t.SubtractDecimalCommand.id]:{order:9.4,gridLayout:{row:2,column:4},menuItemFactory:ie}}};var E=`@univerjs/sheets-numfmt-ui`,D=`1.0.2`;let O=`sheets-numfmt-ui.config`,k={},A={id:`sheet.command.mobile.numfmt.set`,type:r.CommandType.COMMAND,handler:async(e,n)=>{let i=e.get(a.SheetsSelectionsService).getCurrentSelections();if(!(i!=null&&i.length))return!1;let o=(n==null?void 0:n.value)||void 0,s=o?(0,t.getPatternType)(o):void 0,c=[];return i.forEach(e=>{r.Range.foreach(e.range,(e,t)=>c.push({row:e,col:t,pattern:o,type:s}))}),e.get(r.ICommandService).executeCommand(t.SetNumfmtCommand.id,{values:c})}},se=`sheet.menu.mobile.numfmt`,ce=`sheets-numfmt-ui.mobile.custom-format`;function le(e){let n=S(e).slice(0,-1).map(e=>e===`|`?{divider:!0}:{label:e.label,value:e.pattern});return n.push({label:`sheets-numfmt-ui.customFormat`,custom:!0}),{kind:`number-format`,title:`sheets-numfmt-ui.title`,commandId:A.id,detailTitle:`sheets-numfmt-ui.moreFmt`,customTitle:`sheets-numfmt-ui.customFormat`,customComponent:ce,quickOptions:[{label:`sheets-numfmt-ui.percent`,commandId:t.SetPercentCommand.id},{label:`sheets-numfmt-ui.currency`,commandId:t.SetCurrencyCommand.id},{label:`sheets-numfmt-ui.date`,commandId:A.id,value:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.text`,commandId:A.id,value:r.DEFAULT_TEXT_FORMAT_EXCEL}],decimalOptions:[{label:`sheets-numfmt-ui.subtractDecimal`,commandId:t.SubtractDecimalCommand.id},{label:`sheets-numfmt-ui.addDecimal`,commandId:t.AddDecimalCommand.id}],detailOptions:n,customPatterns:[...new Set([...t.CURRENCYFORMAT.map(t=>t.suffix(e)),...t.DATEFMTLISG.map(e=>e.suffix),...t.NUMBERFORMAT.map(e=>e.suffix)])]}}function ue(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(r.RegionService),d=e.get(a.SheetsSelectionsService),f=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],p=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(d.selectionMoveEnd$,u.currentRegion$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>f.includes(e.id)))).subscribe(()=>{var a,o,s;let c=(a=d.getCurrentSelections())==null?void 0:a[0];if(!c)return;let{startRow:f,startColumn:p}=c.range,m=(o=e.getStyles().get((s=n.getCell(f,p))==null?void 0:s.s))==null?void 0:o.n,h=m==null?void 0:m.pattern,g=(0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()),_=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(h)){i.next(_);return}if(h){let e=S(g).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(h,e.pattern));_=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(_)})));return{id:se,title:`sheets-numfmt-ui.title`,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,selections:[],value$:p,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]}),mobileNumberFormat:le((0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()))}}function de(e){let{patterns:t,onConfirm:i}=e,a=(0,n.useDependency)(r.LocaleService),[o,s]=(0,u.useState)(``),c=a.t(`sheets-numfmt-ui.customFormat`);return(0,d.jsxs)(`div`,{"data-u-comp":`mobile-custom-format`,className:`univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-gap-4`,children:[(0,d.jsx)(l.Input,{className:`univer-shrink-0`,size:`large`,"aria-label":c,value:o,placeholder:c,onChange:s}),(0,d.jsx)(l.MobileSelect,{className:`univer-w-full univer-shrink-0 [&>div]:univer-font-mono`,value:o||c,options:t.map(e=>({label:e,value:e})),onChange:s}),(0,d.jsx)(`div`,{className:`univer-flex-1 univer-px-1 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:a.t(`sheets-numfmt-ui.customFormatDes`)}),(0,d.jsx)(l.MobileActionRowGroup,{className:`univer-shrink-0`,children:(0,d.jsx)(l.Button,{variant:`primary`,disabled:!o.trim(),onClick:()=>i(o.trim()),children:a.t(`sheets-numfmt-ui.confirm`)})})]})}let j=class extends r.Disposable{constructor(e){super(),this.disposeWithMe(e.register(ce,de))}};j=y([v(0,(0,r.Inject)(n.ComponentManager))],j);let M=class extends r.Disposable{constructor(e,t,n,r,i){super(),this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._localeService=r,this._sheetsNumfmtCellContentController=i,this.disposeWithMe(this._commandService.registerCommand(A)),this._initNumfmtLocalChange(),this._initCommandExecutedListener()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>this._forceUpdate()))}_initCommandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_forceUpdate(e){var t,n;let i=e??((t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId());if(!i)return;let a=this._renderManagerService.getRenderUnitById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}};M=y([v(0,r.ICommandService),v(1,r.IUniverInstanceService),v(2,i.IRenderManagerService),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(t.SheetsNumfmtCellContentController))],M);let N=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s){super(),this._context=e,this._selectionManagerService=t,this._cellAlertManagerService=n,this._localeService=r,this._numfmtService=i,this._configService=a,this._commandService=o,this._univerInstanceService=s,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._selectionManagerService.selectionChanged$.subscribe(e=>this._updateAlert(e))),this.disposeWithMe(this._context.unit.activeSheet$.subscribe(()=>this._updateAlert(this._selectionManagerService.getCurrentSelections()))),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(()=>this._updateAlert(this._selectionManagerService.getCurrentSelections())))}_isCurrentSheet(e){let t=this._selectionManagerService.currentSelectionParam;return!!(e&&(t==null?void 0:t.unitId)===this._context.unit.getUnitId()&&t.sheetId===e.getSheetId())}_updateAlert(e){var n,i;this._hideAlert();let s=this._context.unit,c=s.getActiveSheet();if(!this._isCurrentSheet(c)||(e==null?void 0:e.length)!==1||(n=this._configService.getConfig(t.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;let l=e[0],u=l.primary;if(!u)return;let d=u.actualRow,f=u.actualColumn,p=s.getUnitId(),m=c.getSheetId(),h=c.getCell(d,f),g;if(h!=null&&h.s){var _;g=(_=s.getStyles().get(h.s))==null?void 0:_.n}g||=this._numfmtService.getValue(p,m,d,f);let v=h==null?void 0:h.v,y=(0,r.isRealNum)(v)||typeof v==`string`&&typeof((i=(0,r.getNumfmtParseValueFilter)(v))==null?void 0:i.v)==`number`;if(!(0,r.isTextFormat)(g==null?void 0:g.pattern)||!r.Tools.isDefine(v)||!y)return;let b={...l.range};this._cellAlertManagerService.showAlert({type:o.CellAlertType.WARNING,title:this._localeService.t(`sheets-numfmt-ui.info.error`),message:this._localeService.t(`sheets-numfmt-ui.info.forceStringInfo`),location:{unitId:p,subUnitId:m,row:d,col:f},width:200,height:74,key:this._alertKey,menu:[{label:this._localeService.t(`sheets-numfmt-ui.info.convertToNumber`),onSelect:()=>{this._commandService.syncExecuteCommand(a.TextToNumberCommand.id,{unitId:p,subUnitId:m,ranges:[b]})&&this._hideAlert()}}]})}get _alertKey(){return`SHEET_NUMFMT_ALERT:${this._context.unit.getUnitId()}`}_hideAlert(){this._cellAlertManagerService.removeAlert(this._alertKey)}};N=y([v(1,(0,r.Inject)(a.SheetsSelectionsService)),v(2,(0,r.Inject)(o.CellAlertManagerService)),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(a.INumfmtService)),v(5,r.IConfigService),v(6,r.ICommandService),v(7,r.IUniverInstanceService)],N);let P=class extends r.Disposable{constructor(e){super(),this._repeatLastActionService=e,this._initCommandRecording()}_initCommandRecording(){this._repeatLastActionService&&this.disposeWithMe(this._repeatLastActionService.registerRepeatableCommand(t.SetNumfmtCommand.id,(e,t)=>{if(!t)return;let{values:n}=t,r=n.find(e=>e.pattern);if(!r)return;let{pattern:i,type:a}=r,o=[],s=new Set;for(let t of e){let{startRow:e,startColumn:n,endRow:r,endColumn:c}=t;for(let t=e;t<=r;t++)for(let e=n;e<=c;e++){let n=`${t}-${e}`;s.has(n)||(s.add(n),o.push({row:t,col:e,pattern:i,type:a}))}}return{...t,values:o}},o.RepeatLastActionPermission.CellStyle))}};P=y([v(0,(0,r.Optional)(o.IRepeatLastActionService))],P);function fe(e){if(r.numfmt.getFormatDateInfo(e).isDuration)return`duration`;let t=r.numfmt.getFormatInfo(e).type;return t===`date`||t===`datetime`||t===`time`?t:null}function pe(e,t){var n;let i=((n=r.numfmt.getLocale(t))==null?void 0:n.decimal)??`.`,a=e.lastIndexOf(i);if(a<0)return e;let o=e.indexOf(` `,a),s=o<0?e.length:o,c=s;for(;c>a+1&&e[c-1]===`0`;)c--;return e.slice(0,c)+e.slice(s)}function me(e,t){var n;let i=Math.round(Math.abs(e)*864e5),a=Math.floor(i/36e5),o=Math.floor(i/6e4)%60,s=Math.floor(i/1e3)%60,c=i%1e3,l=c?`${((n=r.numfmt.getLocale(t))==null?void 0:n.decimal)??`.`}${String(c).padStart(3,`0`).replace(/0+$/,``)}`:``;return`${e<0?`-`:``}${a}:${String(o).padStart(2,`0`)}:${String(s).padStart(2,`0`)}${l}`}function he(e){let{serial:t,pattern:n,locale:i,dateSystem:a}=e,o=fe(n);if(!o||!Number.isFinite(t)||t<0&&o!==`duration`)return null;if(o===`duration`)return me(t,i);let s=(0,r.excelSerialToDateTimeParts)(t,{dateSystem:a});if(!s)return null;let c=Math.round(s.fractionalSecond*1e3)>0,l=r.numfmt.getDateTimeEditPattern(n,t);if(!l)return null;let u=r.numfmt.format(l,t,{locale:i,dateSystem:a,throws:!1});return c?pe(u,i):u}function ge(e,t){var n;let i=((n=r.numfmt.getLocale(t))==null?void 0:n.decimal)??`.`,a=i===`.`?e:e.replace(i,`.`),o=/^\s*([+-])?(\d+):([0-5]?\d):([0-5]?\d)(\.\d{1,10})?\s*$/.exec(a);if(!o)return null;let s=o[1]===`-`?-1:1,c=Number(o[2]),l=Number(o[3]),u=Number(o[4]),d=Number(o[5]??0);return s*(c*3600+l*60+u+d)/86400}function _e(e){let{content:t,originalSerial:n,pattern:i,locale:a,dateSystem:o}=e,s=fe(i);if(!s||!Number.isFinite(n)||n<0&&s!==`duration`)return null;if(s===`duration`)return ge(t,a);if(s===`time`){let e=r.numfmt.parseTime(t,{locale:a,dateSystem:o});return e?Math.floor(n)+Number(e.v):null}let c=r.numfmt.parseDate(t,{locale:a,dateSystem:o});return!c||typeof c.v!=`number`?null:s===`date`?Math.floor(c.v)+(n-Math.floor(n)):c.v}let ve=()=>{let e=[];return{add:(t,n,r,i,a)=>e.push({unitId:t,subUnitId:n,row:r,col:i,value:a}),getEffects:()=>e,clean:()=>{e=[]}}},F=class extends r.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._numfmtService=t,this._univerInstanceService=n,this._injector=r,this._sheetsNumfmtCellContentController=i,this._editorBridgeService=a,_(this,`_collectEffectMutation`,ve()),this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.BEFORE_CELL_EDIT,{handler:(e,n,i)=>{let a=n.row,o=n.col,s=this._numfmtService.getValue(n.unitId,n.subUnitId,a,o);if(s){let c=n.worksheet.getCellRaw(a,o);if(!(c!=null&&c.f)&&(c==null?void 0:c.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(c.v)){let e=he({serial:Number(c.v),pattern:s.pattern,locale:this._sheetsNumfmtCellContentController.getLocale(n.workbook),dateSystem:n.workbook.getDateSystem()});if(e!=null)return i&&i({...c,v:e})}switch((0,t.getPatternType)(s.pattern)){case`scientific`:case`currency`:case`grouped`:case`number`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=(0,f.stripErrorMargin)(Number(e.v))),i&&i(e)}case`percent`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=`${(0,f.stripErrorMargin)(Number(e.v)*100)}%`,e.isPercentFormat=!0),i&&i(e)}default:return i&&i(e)}}return i(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.AFTER_CELL_EDIT,{handler:(e,n,i)=>{var a,o;if(!(e!=null&&e.v)&&!(e!=null&&e.p))return i(e);this._collectEffectMutation.clean();let s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),c=n.worksheet.getCellRaw(n.row,n.col);if((0,r.isTextFormat)(s==null?void 0:s.pattern)||e.t===r.CellValueType.FORCE_STRING)return i(e);let l=(a=e.p)==null?void 0:a.body,u=e!=null&&(o=e.p)!=null&&(o=o.body)!=null&&o.dataStream?e.p.body.dataStream.replace(/\r\n$/,``):String(e.v),d=this._sheetsNumfmtCellContentController.getLocale(n.workbook),p=n.workbook.getDateSystem(),m=(0,r.getNumfmtParseValueFilter)(u,{locale:d,dateSystem:p});if(l){if(ye(l)){let{dataStream:t}=l,n=t.replace(/\r\n$/,``),r=Number(n);if(Number.isNaN(r)&&!m)return i(e)}else return i(e)}if(s!=null&&s.pattern&&(c==null?void 0:c.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(c.v)){let t=_e({content:u,originalSerial:Number(c.v),pattern:s.pattern,locale:d,dateSystem:p});if(t!=null)return i({...e,p:void 0,v:(0,f.stripErrorMargin)(t,16),t:r.CellValueType.NUMBER})}if(m){if(!m.z&&!(s!=null&&s.pattern)&&(c==null?void 0:c.t)!==r.CellValueType.STRING&&(c==null?void 0:c.t)!==r.CellValueType.FORCE_STRING&&(0,r.willLoseNumericPrecision)(u))return i({...e,p:void 0,v:u,t:r.CellValueType.FORCE_STRING});m.z&&(!(s!=null&&s.pattern)||(0,t.getPatternType)(m.z)!==(0,t.getPatternType)(s.pattern))&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:m.z});let a=(0,f.stripErrorMargin)(Number(m.v),16);return i({...e,p:void 0,v:a,t:r.CellValueType.NUMBER})}return i(e)}})))}_initInterceptorCommands(){let e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case a.SetRangeValuesCommand.id:{let n=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!n.length)return{redos:[],undos:[]};let r=(0,a.getSheetCommandTarget)(e._univerInstanceService,t.params);if(!r)return{redos:[],undos:[]};let{unitId:i,subUnitId:o}=r,s=n.filter(e=>e.unitId===i&&e.subUnitId===o),c=s.filter(e=>{var t;return!!((t=e.value)!=null&&t.pattern)}).map(e=>({row:e.row,col:e.col,pattern:e.value.pattern})),l=s.filter(e=>{var t;return!((t=e.value)!=null&&t.pattern)}).map(e=>({startRow:e.row,endColumn:e.col,startColumn:e.col,endRow:e.row})),u=[],d=[];if(c.length){let t={id:a.SetNumfmtMutation.id,params:(0,a.transformCellsToRange)(i,o,c)};u.push(t),d.push(...(0,a.factorySetNumfmtUndoMutation)(e._injector,t.params))}if(l.length){let t={id:a.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:l}};u.push(t),d.push(...(0,a.factoryRemoveNumfmtUndoMutation)(e._injector,t.params))}return{redos:u,undos:d.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};F=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(a.INumfmtService)),v(2,(0,r.Inject)(r.IUniverInstanceService)),v(3,(0,r.Inject)(r.Injector)),v(4,(0,r.Inject)(t.SheetsNumfmtCellContentController)),v(5,(0,r.Optional)(o.IEditorBridgeService))],F);function ye(e){let{textRuns:t=[],paragraphs:n=[],customRanges:r,customBlocks:i=[]}=e,a=[`va`];return!(t.some(e=>!!(e.ts&&Object.keys(e.ts).some(e=>a.includes(e))))||n.some(e=>e.bullet)||n.length>=2||r!=null&&r.length||i.length>0)}let be={[n.RibbonStartGroup.NUMBER]:{[se]:{order:9,menuItemFactory:ue}}},I=class extends r.Disposable{constructor(e){super(),e.mergeMenu(be)}};I=y([v(0,n.IMenuManagerService)],I);let L=class extends r.Plugin{constructor(e=k,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},k,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(O,o)}onStarting(){(0,r.registerDependencies)(this._injector,[[j],[M],[F],[I],[P]]),(0,r.touchDependencies)(this._injector,[[j],[M]])}onRendered(){[[N]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))}),(0,r.touchDependencies)(this._injector,[[F],[I],[P]])}};_(L,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_(L,`packageName`,E),_(L,`version`,D),_(L,`type`,r.UniverInstanceType.UNIVER_SHEET),L=y([(0,r.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,t.UniverSheetsNumfmtPlugin,o.UniverSheetsMobileUIPlugin,n.UniverMobileUIPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],L);function R({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),l=`_${(0,u.useId)()}`,d=(0,u.useRef)(null);return(0,u.useImperativeHandle)(e,()=>d.current),(0,u.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return Ce(d.current)},[n,r]),z(r,`${i}`,{defIds:r.defIds,idSuffix:l},{ref:d,className:c,...s},o)}function z(e,t,n,r,i){return(0,u.createElement)(e.tag,{key:t,...xe(e,n,i),...r},(Se(e,n).children||[]).map((r,a)=>z(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function xe(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function Se(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function Ce(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:we(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(Te(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function we(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function Te(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}R.displayName=`UniverIcon`;let Ee={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:`M4.06641 3.49366C4.06641 2.27555 5.14145 1.3916 6.33307 1.3916C7.52469 1.3916 8.59974 2.27555 8.59974 3.49366V6.49777C8.59974 7.71586 7.52469 8.59982 6.33307 8.59982C5.14145 8.59982 4.06641 7.71586 4.06641 6.49777V3.49366ZM6.33307 2.5916C5.68376 2.5916 5.26641 3.05264 5.26641 3.49366V6.49777C5.26641 6.93878 5.68376 7.39982 6.33307 7.39982C6.98239 7.39982 7.39974 6.93878 7.39974 6.49777V3.49366C7.39974 3.05264 6.98239 2.5916 6.33307 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.0664 3.49366C10.0664 2.27555 11.1415 1.3916 12.3331 1.3916C13.5247 1.3916 14.5997 2.27555 14.5997 3.49366V6.49777C14.5997 7.71586 13.5247 8.59982 12.3331 8.59982C11.1415 8.59982 10.0664 7.71586 10.0664 6.49777V3.49366ZM12.3331 2.5916C11.6838 2.5916 11.2664 3.05264 11.2664 3.49366V6.49777C11.2664 6.93878 11.6838 7.39982 12.3331 7.39982C12.9824 7.39982 13.3997 6.93878 13.3997 6.49777V3.49366C13.3997 3.05264 12.9824 2.5916 12.3331 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.4242 9.5417C12.1899 9.30739 11.81 9.30739 11.5756 9.5417C11.3413 9.77602 11.3413 10.1559 11.5756 10.3902L12.5514 11.366H6.3334C6.00203 11.366 5.7334 11.6346 5.7334 11.966C5.7334 12.2973 6.00203 12.566 6.3334 12.566H12.5514L11.5756 13.5417C11.3413 13.776 11.3413 14.1559 11.5756 14.3902C11.81 14.6245 12.1899 14.6245 12.4242 14.3902L14.4159 12.3985C14.5294 12.2893 14.6001 12.1359 14.6001 11.966C14.6001 11.796 14.5294 11.6426 14.4159 11.5334L12.4242 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},B=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`add-digits-icon`,ref:t,icon:Ee}))});B.displayName=`AddDigitsIcon`;let De={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`}}]},V=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:De}))});V.displayName=`CheckMarkIcon`;let Oe={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:`M7.3999 2.8999V1.6C7.3999 1.26863 7.66853 1 7.9999 1C8.33127 1 8.5999 1.26863 8.5999 1.6V2.8999H10.2044C11.6655 2.8999 12.8499 4.08431 12.8499 5.54536C12.8499 5.87673 12.5813 6.14536 12.2499 6.14536C11.9185 6.14536 11.6499 5.87673 11.6499 5.54536C11.6499 4.74705 11.0028 4.0999 10.2044 4.0999H5.7384C4.97155 4.0999 4.3499 4.72155 4.3499 5.4884C4.3499 6.14439 4.80899 6.71087 5.45074 6.84677L10.7977 7.97906C11.994 8.23242 12.8499 9.28849 12.8499 10.5114C12.8499 11.941 11.691 13.0999 10.2614 13.0999H8.5999V14.4C8.5999 14.7314 8.33127 15 7.9999 15C7.66853 15 7.3999 14.7314 7.3999 14.4V13.0999H5.79536C4.33431 13.0999 3.1499 11.9155 3.1499 10.4544C3.1499 10.1231 3.41853 9.85445 3.7499 9.85445C4.08127 9.85445 4.3499 10.1231 4.3499 10.4544C4.3499 11.2527 4.99705 11.8999 5.79536 11.8999H10.2614C11.0283 11.8999 11.6499 11.2782 11.6499 10.5114C11.6499 9.85542 11.1908 9.28893 10.5491 9.15303L5.20214 8.02074C4.00575 7.76739 3.1499 6.71132 3.1499 5.4884C3.1499 4.05881 4.30881 2.8999 5.7384 2.8999H7.3999Z`}}]},H=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`dollar-icon`,ref:t,icon:Oe}))});H.displayName=`DollarIcon`;let ke={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:`M12.2058 3.459H11.2416V12.6604H9.6438V11.6962Q8.9091 12.844 7.4858 12.844Q5.8971 12.844 4.8456 11.6686Q3.7942 10.4932 3.7942 8.5739Q3.7942 6.5904 4.7814 5.4471Q5.7685 4.3038 7.4031 4.3038Q8.9183 4.3038 9.5887 5.3415V3.459H7.5041V2.1091H9.5887V1.2H11.2416V2.1091H12.2058V3.459ZM7.6143 11.4941Q8.5234 11.4941 9.0744 10.8008Q9.6254 10.1075 9.6254 8.7484Q9.6254 5.6629 7.5592 5.6629Q6.5491 5.6629 6.0211 6.4297Q5.493 7.1965 5.493 8.5923Q5.493 11.4941 7.6143 11.4941ZM11.2416 14.8H4.0421V13.4501H11.2416V14.8Z`}}]},U=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`dong-icon`,ref:t,icon:ke}))});U.displayName=`DongIcon`;let Ae={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:`M5.84964 5.80918C6.71946 3.63548 8.84516 2.2 11.3295 2.2C11.8324 2.2 12.3198 2.26279 12.7846 2.38065C13.1058 2.46209 13.4322 2.26773 13.5137 1.94652C13.5951 1.62532 13.4008 1.2989 13.0795 1.21746C12.5191 1.07535 11.9327 1 11.3295 1C8.17278 1 5.49724 2.96009 4.57394 5.80918H3.06582C2.73445 5.80918 2.46582 6.07781 2.46582 6.40918C2.46582 6.74055 2.73445 7.00918 3.06582 7.00918H4.29808C4.25287 7.33297 4.22949 7.66376 4.22949 8C4.22949 8.33608 4.25284 8.6667 4.29801 8.99033H3.06582C2.73445 8.99033 2.46582 9.25896 2.46582 9.59033C2.46582 9.9217 2.73445 10.1903 3.06582 10.1903H4.57378C5.49693 13.0397 8.1726 15 11.3295 15C11.9336 15 12.5209 14.9244 13.0821 14.7819C13.4033 14.7003 13.5975 14.3738 13.5159 14.0527C13.4344 13.7315 13.1079 13.5373 12.7867 13.6188C12.3213 13.737 11.8332 13.8 11.3295 13.8C8.84497 13.8 6.71914 12.3643 5.84944 10.1903H11.4291C11.7605 10.1903 12.0291 9.9217 12.0291 9.59033C12.0291 9.25896 11.7605 8.99033 11.4291 8.99033H5.51225C5.45783 8.66834 5.42949 8.33748 5.42949 8C5.42949 7.66235 5.45786 7.33133 5.51233 7.00918H11.4291C11.7605 7.00918 12.0291 6.74055 12.0291 6.40918C12.0291 6.07781 11.7605 5.80918 11.4291 5.80918H5.84964Z`}}]},W=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`euro-icon`,ref:t,icon:Ae}))});W.displayName=`EuroIcon`;let je={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:`M1.85059 4.06725C1.85059 2.84302 2.84302 1.85059 4.06725 1.85059C5.29148 1.85059 6.28392 2.84302 6.28392 4.06725C6.28392 5.29148 5.29148 6.28392 4.06725 6.28392C2.84302 6.28392 1.85059 5.29148 1.85059 4.06725ZM4.06725 2.95059C3.45053 2.95059 2.95059 3.45053 2.95059 4.06725C2.95059 4.68397 3.45053 5.18392 4.06725 5.18392C4.68397 5.18392 5.18392 4.68397 5.18392 4.06725C5.18392 3.45053 4.68397 2.95059 4.06725 2.95059Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.7168 11.933C9.7168 10.7087 10.7092 9.71631 11.9335 9.71631C13.1577 9.71631 14.1501 10.7087 14.1501 11.933C14.1501 13.1572 13.1577 14.1496 11.9335 14.1496C10.7092 14.1496 9.7168 13.1572 9.7168 11.933ZM11.9335 10.8163C11.3167 10.8163 10.8168 11.3163 10.8168 11.933C10.8168 12.5497 11.3167 13.0496 11.9335 13.0496C12.5502 13.0496 13.0501 12.5497 13.0501 11.933C13.0501 11.3163 12.5502 10.8163 11.9335 10.8163Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.5241 3.32407C13.7584 3.08975 13.7584 2.70986 13.5241 2.47554C13.2898 2.24123 12.9099 2.24123 12.6755 2.47554L2.47554 12.6755C2.24123 12.9099 2.24123 13.2898 2.47554 13.5241C2.70986 13.7584 3.08975 13.7584 3.32407 13.5241L13.5241 3.32407Z`}}]},G=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`percent-icon`,ref:t,icon:je}))});G.displayName=`PercentIcon`;let 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:`M6.33307 1.3916C5.14145 1.3916 4.06641 2.27555 4.06641 3.49366V6.49777C4.06641 7.71586 5.14145 8.59982 6.33307 8.59982C7.52469 8.59982 8.59974 7.71586 8.59974 6.49777V3.49366C8.59974 2.27555 7.52469 1.3916 6.33307 1.3916ZM5.26641 3.49366C5.26641 3.05264 5.68376 2.5916 6.33307 2.5916C6.98239 2.5916 7.39974 3.05264 7.39974 3.49366V6.49777C7.39974 6.93878 6.98239 7.39982 6.33307 7.39982C5.68376 7.39982 5.26641 6.93878 5.26641 6.49777V3.49366Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.90913 9.5417C8.14345 9.30739 8.52335 9.30739 8.75766 9.5417C8.99198 9.77602 8.99198 10.1559 8.75766 10.3902L7.78193 11.366H13.9999C14.3313 11.366 14.5999 11.6346 14.5999 11.966C14.5999 12.2973 14.3313 12.566 13.9999 12.566H7.78193L8.75766 13.5417C8.99198 13.776 8.99198 14.1559 8.75766 14.3902C8.52335 14.6245 8.14345 14.6245 7.90913 14.3902L5.91739 12.3985C5.80388 12.2893 5.73324 12.1359 5.73324 11.966C5.73324 11.796 5.80388 11.6426 5.91739 11.5334L7.90913 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},Ne=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`reduce-digits-icon`,ref:t,icon:Me}))});Ne.displayName=`ReduceDigitsIcon`;let 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:`M6.7937 8.6977Q6.7937 9.5729 6.7228 9.9277Q6.6045 10.8264 5.7057 11.3704Q4.8543 11.8908 3.577 12.0327H3.4115Q2.6783 12.0327 2.2052 11.3468Q1.7795 10.7555 1.7795 9.9277Q1.7795 9.5965 1.945 8.887Q2.1343 8.0828 2.3944 7.8226Q2.4417 7.7517 2.5127 7.7517Q2.6546 7.7517 2.6546 7.9172Q2.6546 7.9882 2.489 8.4139Q2.3235 8.8397 2.3235 9.0762Q2.3235 9.904 2.7256 10.2588Q3.1277 10.6136 3.9791 10.6136Q4.9016 10.6136 5.6111 10.1878Q6.4863 9.6911 6.4153 8.8397Q6.2261 8.1774 5.8713 6.4271Q5.4456 4.2038 5.1617 3.0449Q4.9489 2.6191 4.807 2.4536Q4.9489 2.1934 5.0198 1.8859Q5.1617 1.2 5.28 1.2Q5.351 1.2 5.4456 1.4602Q5.5638 1.744 5.6821 1.8623Q6.1078 2.217 6.1551 2.288Q6.1551 2.3353 6.1788 2.3826Q6.2261 2.6191 5.9186 3.2577Q6.2024 4.535 6.4863 6.4271Q6.6991 7.8463 6.7937 8.6977ZM11.3586 8.9816Q11.3823 9.6911 11.0748 10.3061Q10.8856 10.7082 10.0577 10.7082Q9.3009 10.7082 8.8751 9.9277Q8.5677 9.4073 8.4021 7.8226Q8.1656 5.8122 7.9054 4.0146Q7.7398 3.0922 7.6452 2.6428L7.7871 1.9332Q7.8581 1.4602 7.929 1.4602Q7.9763 1.4602 8 1.5784Q8.2365 2.2407 8.4257 3.8963Q8.7096 6.167 8.8042 6.6637Q9.0643 8.5795 9.2299 8.9106Q9.3245 9.1235 9.5729 9.3127Q9.8212 9.5019 10.0577 9.5019Q10.72 9.5019 10.791 9.1471Q10.7437 8.9816 10.4835 8.6268Q10.2706 8.2957 10.247 8.0355L10.3889 7.657Q10.4598 7.4442 10.5781 7.2077Q10.6017 7.184 10.6254 7.184Q10.8383 7.184 11.0275 7.6334Q11.335 8.272 11.3586 8.9816ZM14.2205 10.7318Q14.2205 12.2219 13.511 13.3099Q13.1325 13.8776 12.2574 14.6108Q11.9736 14.8 11.4532 14.8Q10.9329 14.8 9.3245 14.4689Q9.2536 14.4689 9.1471 14.3624Q9.0407 14.256 9.0407 14.2087Q9.0643 14.185 9.0643 14.185L9.088 14.1614Q9.703 14.1141 10.0577 14.1141Q10.72 14.0904 11.0038 13.9722Q13.1089 13.1917 13.7475 11.2995Q13.6765 11.1339 13.2035 10.3061Q12.825 9.6438 12.825 9.3363Q12.825 9.289 12.9197 9.1471Q12.9433 9.1235 13.0379 8.7923Q13.1089 8.5558 13.1798 8.5558Q13.4637 8.5558 13.8657 9.3363Q14.2205 10.0459 14.2205 10.377V10.7318ZM10.6017 12.1273Q10.6254 12.1983 10.4243 12.6122Q10.2233 13.0261 10.105 13.0261Q9.9631 13.0261 9.6793 12.7777Q9.3955 12.5294 9.3245 12.3638Q9.632 11.536 9.7976 11.465Q9.8685 11.465 10.1997 11.7607Q10.5308 12.0563 10.6017 12.1273ZM9.1353 12.4584Q9.159 12.6003 8.9579 12.967Q8.7569 13.3336 8.6386 13.3336Q8.4967 13.3336 8.201 13.097Q7.9054 12.8605 7.9054 12.7423Q7.8344 12.553 8.3075 11.8198Q8.6386 11.9617 9.1353 12.4584Z`}}]},Fe=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`rial-icon`,ref:t,icon:Pe}))});Fe.displayName=`RialIcon`;let Ie={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:`M11.9445 1.55649C12.2184 1.744 12.2895 2.11755 12.1033 2.39085L9.24342 6.58659H12.8001C13.1315 6.58659 13.4001 6.85522 13.4001 7.18659C13.4001 7.51796 13.1315 7.78659 12.8001 7.78659H8.5999V9.91276H13.2221C13.5534 9.91276 13.8221 10.1814 13.8221 10.5128C13.8221 10.8441 13.5534 11.1128 13.2221 11.1128H8.5999V14.0877C8.5999 14.4191 8.33127 14.6877 7.9999 14.6877C7.66853 14.6877 7.3999 14.4191 7.3999 14.0877V11.1128H2.77773C2.44636 11.1128 2.17773 10.8441 2.17773 10.5128C2.17773 10.1814 2.44636 9.91276 2.77773 9.91276H7.3999V7.78659H3.2001C2.86873 7.78659 2.6001 7.51796 2.6001 7.18659C2.6001 6.85522 2.86873 6.58659 3.2001 6.58659H6.75736L3.89753 2.39085C3.71125 2.11755 3.78234 1.744 4.05631 1.55649C4.33029 1.36899 4.7034 1.43854 4.88968 1.71184L7.94595 6.19577C7.96752 6.22741 7.98564 6.2604 8.00039 6.29429C8.01514 6.2604 8.03326 6.22741 8.05483 6.19577L11.1111 1.71184C11.2974 1.43854 11.6705 1.36899 11.9445 1.55649Z`}}]},Le=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`rmb-icon`,ref:t,icon:Ie}))});Le.displayName=`RmbIcon`;let Re={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:`M9.72502 1.02051H6.07803C4.97346 1.02051 4.07803 1.91594 4.07803 3.02051V7.57046H3.00039C2.66902 7.57046 2.40039 7.83909 2.40039 8.17046C2.40039 8.50183 2.66902 8.77046 3.00039 8.77046H4.07803V10.4854H3.00039C2.66902 10.4854 2.40039 10.754 2.40039 11.0854C2.40039 11.4167 2.66902 11.6854 3.00039 11.6854H4.07803V14.3795C4.07803 14.7108 4.34666 14.9795 4.67803 14.9795C5.0094 14.9795 5.27803 14.7108 5.27803 14.3795V11.6854H10.3637C10.695 11.6854 10.9637 11.4167 10.9637 11.0854C10.9637 10.754 10.695 10.4854 10.3637 10.4854H5.27803V8.77046H9.72503C11.8651 8.77046 13.6 7.03557 13.6 4.89548C13.6 2.75539 11.8651 1.02051 9.72502 1.02051ZM9.72503 7.57046H5.27803V3.12051C5.27803 2.62345 5.68097 2.22051 6.17803 2.22051H9.72502C11.2024 2.22051 12.4 3.41814 12.4 4.89548C12.4 6.37283 11.2024 7.57046 9.72503 7.57046Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ze=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`rouble-icon`,ref:t,icon:Re}))});ze.displayName=`RoubleIcon`;let Be={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:`M8.5953 11.0279H7.1987Q5.9451 9.0475 5.6418 8.5953Q5.3384 8.1431 5.0035 7.8197Q4.6687 7.4963 4.3739 7.4104Q4.0791 7.3246 3.5926 7.3246H2.3104V11.0279H1.2V2.6367H4.9148Q5.6761 2.6367 6.1912 2.734Q6.7064 2.8313 7.0956 3.1433Q7.4848 3.4552 7.6938 3.9303Q7.9027 4.4054 7.9027 4.932Q7.9027 5.8822 7.3017 6.4603Q6.7007 7.0384 5.5502 7.1929V7.2158Q6.3916 7.5879 7.13 8.7441L8.5953 11.0279ZM2.3104 6.3286H4.6916Q5.4128 6.3286 5.8335 6.2056Q6.2542 6.0825 6.5061 5.7276Q6.7579 5.3727 6.7579 4.932Q6.7579 4.3596 6.3401 3.9589Q5.9222 3.5582 4.9606 3.5582H2.3104V6.3286ZM10.4842 5.7391Q11.0623 4.8175 12.2185 4.8175Q13.4148 4.8175 14.1074 5.6847Q14.8 6.5519 14.8 7.9428Q14.8 9.4253 14.033 10.2981Q13.266 11.171 12.1498 11.171Q11.171 11.171 10.5815 10.3926H10.5529V13.3633H9.5226V4.9549H10.4613V5.7391H10.4842ZM12.0811 10.3239Q12.8024 10.3239 13.2746 9.7258Q13.7468 9.1276 13.7468 7.9428Q13.7468 6.8266 13.2918 6.2256Q12.8367 5.6246 12.1269 5.6246Q11.3943 5.6246 10.9221 6.2943Q10.4498 6.964 10.4498 8.0286Q10.4498 9.1562 10.902 9.7401Q11.3542 10.3239 12.0811 10.3239Z`}}]},Ve=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`rupiah-icon`,ref:t,icon:Be}))});Ve.displayName=`RupiahIcon`;let He={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.8 9.4486H12.955L11.8883 13.2829H10.5477L9.4811 9.4486H6.5189L5.4378 13.2829H4.0108L2.9874 9.4486H1.2V8.4685H2.7351L2.4541 7.409H1.2V6.436H2.1946L1.2 2.7171H2.6342L3.4919 6.436H6.1153L7.182 2.7171H8.8613L9.9135 6.436H12.4649L13.3802 2.7171H14.8L13.7622 6.436H14.8V7.409H13.5099L13.2144 8.4685H14.8V9.4486ZM8.645 6.436Q8.0757 4.3676 7.9892 4Q7.8667 4.6342 7.3261 6.436H8.645ZM12.2414 7.409H10.209L10.5045 8.4685H11.9748L12.2414 7.409ZM9.2144 8.4685L8.9189 7.409H7.0739L6.7856 8.4685H9.2144ZM5.8559 7.409H3.7297L3.9748 8.4685H5.5604L5.8559 7.409ZM11.7586 9.4486H10.7351Q11.0955 11.1063 11.1964 11.8054L11.7586 9.4486ZM5.2937 9.4486H4.1838Q4.573 11.1063 4.7027 11.8054Q4.955 10.7315 5.2937 9.4486Z`}}]},Ue=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`won-icon`,ref:t,icon:He}))});Ue.displayName=`WonIcon`;let We={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:`M10.092 14.8H1.3716V13.4548L7.6428 6.2652Q6.5389 6.3302 5.7596 6.3302H1.7334V4.9572H9.7858V6.0426L4.4516 12.2767Q4.2939 12.4715 3.6352 13.1858Q3.4775 13.3342 3.4218 13.4363Q4.3774 13.3528 5.5277 13.3528H10.092V14.8ZM14.6284 6.9888L13.376 8.0557V14.8H11.7247V9.4843L10.5094 10.4862V9.0205L11.7247 8.0186V1.2H13.376V6.5899L14.6284 5.5323V6.9888Z`}}]},K=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(R,Object.assign({},e,{id:`zloty-icon`,ref:t,icon:We}))});K.displayName=`ZlotyIcon`;let q=(0,u.createContext)([]),J=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){let n=this._getKey(e);return this._localStorageService.getItem(n).then(e=>{e||this._localStorageService.setItem(n,t)})}markHabit(e,t){let n=this._getKey(e);this._localStorageService.getItem(n).then(e=>{if(e){let r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1),e.unshift(t),this._localStorageService.setItem(n,e)}})}async getHabit(e,t){let n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){let e=r.map((e,t,n)=>({value:e,priority:n.length-t}));return t.sort((t,n)=>{var r,i;let a=((r=e.find(e=>e.value===t))==null?void 0:r.priority)||-1;return(((i=e.find(e=>e.value===n))==null?void 0:i.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};J=y([v(0,(0,r.Inject)(r.ILocalStorageService))],J);let Ge=e=>!!(0,t.getCurrencyType)(e)&&e.startsWith(`_(`);function Ke(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,[s,c]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(i||``,2)),f=(0,u.useContext)(q),[p,m]=(0,u.useState)(()=>(0,t.getCurrencyType)(i)||f[0]),h=(0,u.useMemo)(()=>f.map(e=>({label:e,value:e})),[]),g=(0,n.useDependency)(r.LocaleService);return(0,u.useLayoutEffect)(()=>{a(()=>(0,t.setPatternDecimal)(`_("${p}"* #,##0${s>0?`.0`:``}_)`,s))},[s,a,p]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:s,step:1,precision:0,max:20,min:0,onChange:e=>{let n=e||0;c(n),o((0,t.setPatternDecimal)(`_("${p}"* #,##0${n>0?`.0`:``}_)`,n))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{options:h,value:p,onChange:e=>{m(e),o((0,t.setPatternDecimal)(`_("${e}"* #,##0${s>0?`.0`:``}_)`,s))}})})]})]}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.accountingDes`)})]})}let qe=e=>!!(0,t.getCurrencyType)(e)&&!e.startsWith(`_(`);function Je(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useContext)(q),[c,f]=(0,u.useState)(()=>(0,t.getCurrencyType)(e.defaultPattern)||s[0]),[p,m]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,2)),[h,g]=(0,u.useState)(()=>{var n;let i=(0,t.getCurrencyFormatOptions)(c);return((n=i.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern)))==null?void 0:n.value)||i[0].value}),_=(0,u.useMemo)(()=>(0,t.getCurrencyFormatOptions)(c),[c]),v=(0,u.useMemo)(()=>s.map(e=>({label:e,value:e})),[s]);return(0,u.useLayoutEffect)(()=>{i(()=>(0,t.setPatternDecimal)(h,p))},[p,i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:p,max:20,min:0,onChange:e=>{m(e||0),a((0,t.setPatternDecimal)(h,e||0))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{value:c,options:v,onChange:e=>{if(e===void 0)return;f(e);let n=(0,t.getCurrencyFormatOptions)(e)[0].value;g(n),a((0,t.setPatternDecimal)(n,p))}})})]})]}),(0,d.jsx)(`div`,{className:`label univer-mt-4`,children:o.t(`sheets-numfmt-ui.negType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:h,options:_,onChange:e=>{e!==void 0&&(g(e),a((0,t.setPatternDecimal)(e,p)))}})}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyDes`)})]})}let Y=`customFormat`,X=`numfmt_custom_pattern`;function Ye(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,s=(0,n.useDependency)(J),c=(0,n.useDependency)(r.ILocalStorageService),f=(0,n.useDependency)(r.LocaleService),[p,m]=(0,u.useState)(i);(0,u.useLayoutEffect)(()=>{a(()=>(s.markHabit(Y,p),c.getItem(X).then((e=[])=>{let t=[...new Set([p,...e||[]])].splice(0,10).filter(e=>!!e);c.setItem(X,t)}),p))},[c,a,p,s]);let[h,g]=(0,u.useState)([]);(0,u.useEffect)(()=>{let e=!1;return c.getItem(X).then(e=>{let n=[...t.CURRENCYFORMAT.map(e=>e.suffix(`$`)),...t.DATEFMTLISG.map(e=>e.suffix),...t.NUMBERFORMAT.map(e=>e.suffix),...e??[]];return s.addHabit(Y,[]).then(()=>s.getHabit(Y,n))}).then(t=>{e||g([...new Set(t)])}),()=>{e=!0}},[c,s]);let _=e=>{m(e),o(e)};return(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.customFormat`)}),(0,d.jsx)(l.Input,{placeholder:f.t(`sheets-numfmt-ui.customFormat`),onBlur:()=>{o(p)},value:p,onChange:m,className:`univer-mt-2 univer-w-full`}),(0,d.jsx)(`div`,{className:(0,l.clsx)(`univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2`,l.borderClassName),children:h.map(e=>(0,d.jsxs)(`div`,{onClick:()=>_(e),className:`univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm`,children:[(0,d.jsx)(`div`,{className:`univer-flex univer-w-4 univer-items-center univer-text-primary-600`,children:p===e&&(0,d.jsx)(V,{})}),(0,d.jsx)(`div`,{children:e})]},e))}),(0,d.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:f.t(`sheets-numfmt-ui.customFormatDes`)})]})}let Xe=e=>{let n=r.numfmt.getFormatInfo(e);return(0,t.getDateFormatOptions)().map(e=>e.value).includes(e)||[`date`,`datetime`,`time`].includes(n.type)};function Ze(e){let{onActionChange:i,onChange:a,defaultPattern:o}=e,s=(0,u.useMemo)(t.getDateFormatOptions,[]),c=(0,n.useDependency)(r.LocaleService),[f,p]=(0,u.useState)(()=>{if(o){let e=s.find(e=>e.value===o);if(e)return e.value}return s[0].value});return(0,u.useLayoutEffect)(()=>{i(()=>f)},[i,f]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-numfmt-ui.dateType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:f,options:s,onChange:e=>{e!==void 0&&(p(e),a(e))}})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheets-numfmt-ui.dateDes`)})]})}let Qe=e=>!e;function $e(e){let t=(0,n.useDependency)(r.LocaleService),{onActionChange:i}=e;return(0,u.useLayoutEffect)(()=>{i(()=>``)},[i]),(0,d.jsx)(`div`,{children:(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:t.t(`sheets-numfmt-ui.generalDes`)})})}let et=e=>(0,t.getNumberFormatOptions)().some(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e));function tt(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useMemo)(t.getNumberFormatOptions,[]),[c,f]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,0)),[p,m]=(0,u.useState)(()=>{let t=s.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern||``));return(t==null?void 0:t.value)||s[0].value}),h=(0,u.useMemo)(()=>(0,t.setPatternDecimal)(p,Number(c||0)),[p,c]),g=!(0,t.isPatternHasDecimal)(p);return(0,u.useLayoutEffect)(()=>{i(()=>h)},[i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.InputNumber,{disabled:g,value:c,max:20,min:0,onChange:e=>{f(e||0),a((0,t.setPatternDecimal)(p,Number(e||0)))}})}),(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:[` `,o.t(`sheets-numfmt-ui.negType`)]}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{onChange:e=>{e!==void 0&&(f((0,t.getDecimalFromPattern)(e,0)),m(e),a(e))},options:s,value:p})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:o.t(`sheets-numfmt-ui.thousandthPercentileDes`)})]})}let nt=`numfmtCurrency`,rt=e=>{let t=(0,n.useDependency)(J),[i,a]=(0,u.useState)(r.currencySymbols);return(0,u.useEffect)(()=>{t.addHabit(`numfmtCurrency`,[]).then(()=>{t.getHabit(nt,[...r.currencySymbols]).then(t=>{a(t),e&&e(t)})})},[]),{userHabitCurrency:i,mark:e=>{t.markHabit(nt,e)}}},it=()=>{let e=(0,u.useRef)([]),[t,n]=(0,u.useState)({});return(0,u.useEffect)(()=>{e.current.forEach(e=>{e()}),e.current=[]},[t]),t=>{e.current.push(t),n({})}};function at(e){var i;let{defaultValue:a,defaultPattern:o,row:s,col:c}=e.value,f=(0,n.useDependency)(r.LocaleService),p=(0,u.useRef)(()=>``),m=it(),h=(0,u.useMemo)(()=>[{label:`sheets-numfmt-ui.general`,component:$e},{label:`sheets-numfmt-ui.accounting`,component:Ke},{label:`sheets-numfmt-ui.currency`,component:Je},{label:`sheets-numfmt-ui.date`,component:Ze},{label:`sheets-numfmt-ui.thousandthPercentile`,component:tt},{label:`sheets-numfmt-ui.customFormat`,component:Ye}].map(e=>({...e,label:f.t(e.label)})),[f]),[g,_]=(0,u.useState)(C),[v,y]=(0,u.useState)(()=>`${s}_${c}_${o}`),{mark:b,userHabitCurrency:x}=rt(()=>y(`${s}_${c}_${o}_userCurrency`)),S=(i=h.find(e=>e.label===g))==null?void 0:i.component;function C(){return[Qe,Ge,qe,Xe,et].reduce((e,t,n)=>e||(t(o)?h[n].label:``),``)||h[0].label}let w=h.map(e=>({label:e.label,value:e.label})),ee=t=>{_(t),m(()=>e.onChange({type:`change`,value:p.current()||``}))},te=(0,u.useCallback)(t=>{e.onChange({type:`change`,value:t})},[]),ne=(0,u.useCallback)(e=>{p.current=e},[]),re=()=>{let n=p.current()||``,r=(0,t.getCurrencyType)(n);r&&b(r),e.onChange({type:`confirm`,value:n})},ie=()=>{e.onChange({type:`cancel`,value:``})},ae={onChange:te,onActionChange:ne,defaultValue:a,defaultPattern:o};return(0,u.useEffect)(()=>{_(C()),y(`${s}_${c}_${o}`)},[s,c,o]),(0,d.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5`,l.scrollbarClassName),children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.numfmtType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.Select,{className:`univer-w-full`,value:g,options:w,onChange:ee})}),(0,d.jsx)(`div`,{children:S&&(0,d.jsx)(q.Provider,{value:x,children:(0,u.createElement)(S,{...ae,key:v})})})]}),(0,d.jsxs)(`div`,{className:`univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end univer-gap-2 rtl:univer-flex-row-reverse`,children:[(0,d.jsx)(l.Button,{onClick:ie,children:f.t(`sheets-numfmt-ui.cancel`)}),(0,d.jsx)(l.Button,{variant:`primary`,onClick:re,children:f.t(`sheets-numfmt-ui.confirm`)})]})]})}let Z=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddDigitsIcon:B,DollarIcon:H,DongIcon:U,EuroIcon:W,PercentIcon:G,ReduceDigitsIcon:Ne,RialIcon:Fe,RmbIcon:Le,RoubleIcon:ze,RupiahIcon:Ve,WonIcon:Ue,ZlotyIcon:K}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(`SHEET_NUMFMT_PANEL`,at)),[[C,ee],[w,te]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};Z=y([v(0,(0,r.Inject)(n.ComponentManager)),v(1,(0,r.Inject)(n.IconManager))],Z);let Q=class extends r.Disposable{constructor(e){super(),this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(T)}};Q=y([v(0,n.IMenuManagerService)],Q);let $=class extends r.Plugin{constructor(e=k,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},k,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(O,o)}onStarting(){this._injector.add([Z]),this._injector.get(Z),(0,r.registerDependencies)(this._injector,[[b],[F],[J],[Q],[P]])}onRendered(){this._registerRenderModules(),(0,r.touchDependencies)(this._injector,[[b],[F],[Q],[P]])}_registerRenderModules(){[[N]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))})}};_($,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_($,`packageName`,E),_($,`version`,D),_($,`type`,r.UniverInstanceType.UNIVER_SHEET),$=y([(0,r.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,t.UniverSheetsNumfmtPlugin,o.UniverSheetsUIPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],$),e.SheetsNumfmtUIMenuSchema=T,Object.defineProperty(e,"UniverSheetsNumfmtMobileUIPlugin",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"UniverSheetsNumfmtUIPlugin",{enumerable:!0,get:function(){return $}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/sheets-numfmt"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs"),require("rxjs/operators"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets-numfmt`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`rxjs`,`rxjs/operators`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmtUi={},e.UniverSheetsNumfmt,e.UniverUi,e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.rxjs,e.rxjs.operators,e.UniverDesign,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p={id:`sheet.operation.close.numfmt.panel`,type:r.CommandType.OPERATION,handler:()=>!0};function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(n,r){t(n,r,e)}}function y(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let b=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._sheetInterceptorService=e,this._themeService=t,this._univerInstanceService=n,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=a,this._numfmtService=o,this._sidebarService=s,this._localeService=c,this._sheetsNumfmtCellContentController=l,_(this,`_previewPattern`,``),_(this,`_sidebarDisposable`,null),this._initRealTimeRenderingInterceptor(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var e;let n=this._sidebarService,i=this._selectionManagerService,a=this._commandService,o=this._univerInstanceService,s=this._numfmtService,c=this._localeService,l=(((e=i.getCurrentSelections())==null?void 0:e.map(e=>e.range))||[])[0];if(!l)return!1;let u=o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),d=u.getActiveSheet();if(!d)return!1;let f=d.getCellRaw(l.startRow,l.startColumn),m=s.getValue(u.getUnitId(),d.getSheetId(),l.startRow,l.startColumn),h=``;m&&(h=m.pattern);let g=(f==null?void 0:f.t)===r.CellValueType.NUMBER?f.v:12345678,_={onChange:e=>{if(e.type===`change`)this._previewPattern=e.value,this._forceUpdate();else if(e.type===`confirm`){var o;let s=((o=i.getCurrentSelections())==null?void 0:o.map(e=>e.range))||[],c={values:[]},l=(0,t.getPatternType)(e.value);s.forEach(t=>{r.Range.foreach(t,(t,n)=>{c.values.push({row:t,col:n,pattern:e.value,type:l})})}),a.executeCommand(t.SetNumfmtCommand.id,c),n.close()}else e.type===`cancel`&&n.close()},value:{defaultPattern:h,defaultValue:g,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=n.open({header:{title:c.t(`sheets-numfmt-ui.title`)},children:{label:`SHEET_NUMFMT_PANEL`,..._},onClose:()=>{this._forceUpdate(),a.executeCommand(p.id)}}),!0}_forceUpdate(e){var t,n;let i=e??((t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId());if(!i)return;let a=this._renderManagerService.getRenderUnitById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}_initCommands(){[x,p].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initRealTimeRenderingInterceptor(){let e=new s.Observable(e=>{this._commandService.onCommandExecuted(t=>{t.id===x.id&&e.next(!0),t.id===p.id&&e.next(!1)})}),n=(0,s.combineLatest)([e,this._selectionManagerService.selectionMoveEnd$.pipe((0,c.map)(e=>e?e.map(e=>e.range):[]))]);this.disposeWithMe((0,r.toDisposable)(n.pipe((0,c.switchMap)(([e,t])=>new s.Observable(n=>{let i=new r.DisposableCollection;return e&&t.length&&n.next({selectionRanges:t,disposableCollection:i}),()=>{i.dispose()}})),(0,c.tap)(()=>{this._previewPattern=null})).subscribe(({disposableCollection:e,selectionRanges:n})=>{var i;let o=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);this.openPanel(),e.add(this._sheetInterceptorService.intercept(a.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:r.InterceptorEffectEnum.Value|r.InterceptorEffectEnum.Style,handler:(e,i,a)=>{let{row:o,col:s}=i,c=a(e)||{};if(n.find(e=>e.startColumn<=s&&e.endColumn>=s&&e.startRow<=o&&e.endRow>=o)){let e=i.worksheet.getCellRaw(o,s),n=e==null?void 0:e.v,a=e==null?void 0:e.t;if(n==null||a!==r.CellValueType.NUMBER||this._previewPattern===null)return c;let l=(0,t.getPatternPreviewIgnoreGeneral)(this._previewPattern,n,this._sheetsNumfmtCellContentController.locale);if(l.color){let e=this._themeService.getColorFromTheme(`${l.color}.500`)??l.color;return{...c,v:l.result,t:r.CellValueType.STRING,s:{cl:{rgb:e}}}}return{...c,v:l.result,t:r.CellValueType.STRING}}return c}})),(i=this._renderManagerService.getRenderUnitById(o.getUnitId()))==null||(i=i.mainComponent)==null||i.makeDirty()})))}_commandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(!e){var t;(t=this._sidebarDisposable)==null||t.dispose(),this._sidebarDisposable=null}})}};b=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(r.ThemeService)),v(2,r.IUniverInstanceService),v(3,r.ICommandService),v(4,(0,r.Inject)(a.SheetsSelectionsService)),v(5,i.IRenderManagerService),v(6,a.INumfmtService),v(7,n.ISidebarService),v(8,(0,r.Inject)(r.LocaleService)),v(9,(0,r.Inject)(t.SheetsNumfmtCellContentController))],b);let x={id:`sheet.operation.open.numfmt.panel`,type:r.CommandType.OPERATION,handler:e=>(e.get(b).openPanel(),!0)},S=e=>[{label:`sheets-numfmt-ui.general`,pattern:null},{label:`sheets-numfmt-ui.text`,pattern:r.DEFAULT_TEXT_FORMAT_EXCEL},`|`,{label:`sheets-numfmt-ui.number`,pattern:`0`},{label:`sheets-numfmt-ui.percent`,pattern:`0.00%`},{label:`sheets-numfmt-ui.scientific`,pattern:`0.00E+00`},`|`,{label:`sheets-numfmt-ui.accounting`,pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.financialValue`,pattern:`#,##0.00;[Red]#,##0.00`},{label:`sheets-numfmt-ui.currency`,pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.roundingCurrency`,pattern:`"${e}"#,##0;[Red]"${e}"#,##0`},`|`,{label:`sheets-numfmt-ui.date`,pattern:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.time`,pattern:`am/pm h":"mm":"ss`},{label:`sheets-numfmt-ui.dateTime`,pattern:`yyyy-m-d am/pm h:mm`},{label:`sheets-numfmt-ui.timeDuration`,pattern:`[h]:mm:ss`},`|`,{label:`sheets-numfmt-ui.moreFmt`,pattern:``}],C=`sheets-numfmt-ui.moreNumfmtType`,w=`sheets-numfmt-ui.moreNumfmtType.options`;function ee(e){let{value:t}=e,i=(0,n.useDependency)(r.LocaleService),a=t??i.t(`sheets-numfmt-ui.general`);return(0,d.jsx)(`span`,{className:`univer-text-sm`,children:a})}function te(){let e=(0,n.useDependency)(r.ICommandService),i=(0,n.useDependency)(r.LocaleService),o=(0,n.useDependency)(r.RegionService),s=(0,n.useDependency)(n.ILayoutService),c=(0,n.useDependency)(t.SheetsNumfmtCellContentController),f=(0,n.useObservable)(i.direction$,i.getDirection()),p=(0,n.useObservable)(o.currentRegion$,o.getCurrentRegion()),m=(0,n.useDependency)(a.SheetsSelectionsService),h=n=>{let i=m.getCurrentLastSelection();if(!i)return;let a=i.range,o=[];r.Range.foreach(a,(e,r)=>{n?o.push({row:e,col:r,pattern:n,type:(0,t.getPatternType)(n)}):o.push({row:e,col:r})}),e.executeCommand(t.SetNumfmtCommand.id,{values:o}),s.focus()},g=(0,u.useMemo)(()=>{let e=(0,t.getCurrencySymbolByLocale)(p);return S(e)},[p]),_=t=>{if(t===0)h(null);else if(t===g.length-1)e.executeCommand(x.id),s.focus();else{let e=g[t];e.pattern&&h(e.pattern)}};return(0,d.jsx)(`div`,{dir:f,className:`univer-grid univer-gap-1 univer-p-1.5`,children:g.map((e,n)=>e===`|`?(0,d.jsx)(l.Separator,{},n):(0,d.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:()=>_(n),children:[(0,d.jsx)(`span`,{children:i.t(e.label)}),(0,d.jsx)(`span`,{className:`univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:e.pattern?(0,t.getPatternPreview)(e.pattern||``,1220,c.locale).result.trim():``})]},n))})}function ne(e){return{icon:e.get(r.RegionService).currentRegion$.pipe((0,s.map)(e=>(0,t.getCurrencySymbolIconByLocale)(e).icon)),id:t.SetCurrencyCommand.id,title:`sheets-numfmt-ui.currency`,tooltip:`sheets-numfmt-ui.currency`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function re(e){return{icon:`AddDigitsIcon`,id:t.AddDecimalCommand.id,title:`sheets-numfmt-ui.addDecimal`,tooltip:`sheets-numfmt-ui.addDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ie(e){return{icon:`ReduceDigitsIcon`,id:t.SubtractDecimalCommand.id,title:`sheets-numfmt-ui.subtractDecimal`,tooltip:`sheets-numfmt-ui.subtractDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ae(e){return{icon:`PercentIcon`,id:t.SetPercentCommand.id,title:`sheets-numfmt-ui.percent`,tooltip:`sheets-numfmt-ui.percent`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function oe(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(r.RegionService),d=e.get(a.SheetsSelectionsService),f=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],p=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(d.selectionMoveEnd$,u.currentRegion$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>f.includes(e.id)))).subscribe(()=>{let a=d.getCurrentSelections();if(a&&a[0]){var o,s;let c=a[0].range,d=c.startRow,f=c.startColumn,p=(o=e.getStyles().get((s=n.getCell(d,f))==null?void 0:s.s))==null?void 0:o.n,m=p==null?void 0:p.pattern,h=(0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()),g=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(m)){i.next(g);return}if(m){let e=S(h).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(m,e.pattern));g=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(g)}})));return{label:C,id:x.id,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:w,hoverable:!1,selectable:!1}}],value$:p,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}let se={[n.RibbonStartGroup.NUMBER]:{[x.id]:{order:9,gridLayout:{row:1,column:1,columnSpan:4,width:160},menuItemFactory:oe},[t.SetPercentCommand.id]:{order:9.1,gridLayout:{row:2,column:1},menuItemFactory:ae},[t.SetCurrencyCommand.id]:{order:9.2,gridLayout:{row:2,column:2},menuItemFactory:ne},[t.AddDecimalCommand.id]:{order:9.3,gridLayout:{row:2,column:3},menuItemFactory:re},[t.SubtractDecimalCommand.id]:{order:9.4,gridLayout:{row:2,column:4},menuItemFactory:ie}}};var T=`@univerjs/sheets-numfmt-ui`,E=`1.0.4`;let D=`sheets-numfmt-ui.config`,O={},k={id:`sheet.command.mobile.numfmt.set`,type:r.CommandType.COMMAND,handler:async(e,n)=>{let i=e.get(a.SheetsSelectionsService).getCurrentSelections();if(!(i!=null&&i.length))return!1;let o=(n==null?void 0:n.value)||void 0,s=o?(0,t.getPatternType)(o):void 0,c=[];return i.forEach(e=>{r.Range.foreach(e.range,(e,t)=>c.push({row:e,col:t,pattern:o,type:s}))}),e.get(r.ICommandService).executeCommand(t.SetNumfmtCommand.id,{values:c})}},ce=`sheet.menu.mobile.numfmt`,le=`sheets-numfmt-ui.mobile.custom-format`;function ue(e){let n=S(e).slice(0,-1).map(e=>e===`|`?{divider:!0}:{label:e.label,value:e.pattern});return n.push({label:`sheets-numfmt-ui.customFormat`,custom:!0}),{kind:`number-format`,title:`sheets-numfmt-ui.title`,commandId:k.id,detailTitle:`sheets-numfmt-ui.moreFmt`,customTitle:`sheets-numfmt-ui.customFormat`,customComponent:le,quickOptions:[{label:`sheets-numfmt-ui.percent`,commandId:t.SetPercentCommand.id},{label:`sheets-numfmt-ui.currency`,commandId:t.SetCurrencyCommand.id},{label:`sheets-numfmt-ui.date`,commandId:k.id,value:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.text`,commandId:k.id,value:r.DEFAULT_TEXT_FORMAT_EXCEL}],decimalOptions:[{label:`sheets-numfmt-ui.subtractDecimal`,commandId:t.SubtractDecimalCommand.id},{label:`sheets-numfmt-ui.addDecimal`,commandId:t.AddDecimalCommand.id}],detailOptions:n,customPatterns:[...new Set([...t.CURRENCYFORMAT.map(t=>t.suffix(e)),...t.NUMBERFORMAT.map(e=>e.suffix)])]}}function de(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(r.RegionService),d=e.get(a.SheetsSelectionsService),f=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],p=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(d.selectionMoveEnd$,u.currentRegion$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>f.includes(e.id)))).subscribe(()=>{var a,o,s;let c=(a=d.getCurrentSelections())==null?void 0:a[0];if(!c)return;let{startRow:f,startColumn:p}=c.range,m=(o=e.getStyles().get((s=n.getCell(f,p))==null?void 0:s.s))==null?void 0:o.n,h=m==null?void 0:m.pattern,g=(0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()),_=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(h)){i.next(_);return}if(h){let e=S(g).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(h,e.pattern));_=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(_)})));return{id:ce,title:`sheets-numfmt-ui.title`,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,selections:[],value$:p,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]}),mobileNumberFormat:ue((0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()))}}function fe(e){let{patterns:i,onConfirm:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,n.useObservable)(o.currentLocale$,o.getCurrentLocale()),[c,f]=(0,u.useState)(``),p=o.t(`sheets-numfmt-ui.customFormat`),m=(0,u.useMemo)(()=>[...new Set([...i,...(0,t.getDateFormatOptions)(s).map(e=>e.value),...c?[c]:[]])].map(e=>({label:e,value:e})),[s,c,i]);return(0,d.jsxs)(`div`,{"data-u-comp":`mobile-custom-format`,className:`univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-gap-4`,children:[(0,d.jsx)(l.Input,{className:`univer-shrink-0`,size:`large`,"aria-label":p,value:c,placeholder:p,onChange:f}),(0,d.jsx)(l.MobileSelect,{className:`univer-w-full univer-shrink-0 [&>div]:univer-font-mono`,value:c||p,options:m,onChange:f}),(0,d.jsx)(`div`,{className:`univer-flex-1 univer-px-1 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:o.t(`sheets-numfmt-ui.customFormatDes`)}),(0,d.jsx)(l.MobileActionRowGroup,{className:`univer-shrink-0`,children:(0,d.jsx)(l.Button,{variant:`primary`,disabled:!c.trim(),onClick:()=>a(c.trim()),children:o.t(`sheets-numfmt-ui.confirm`)})})]})}let A=class extends r.Disposable{constructor(e){super(),this.disposeWithMe(e.register(le,fe))}};A=y([v(0,(0,r.Inject)(n.ComponentManager))],A);let j=class extends r.Disposable{constructor(e,t,n,r,i){super(),this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._localeService=r,this._sheetsNumfmtCellContentController=i,this.disposeWithMe(this._commandService.registerCommand(k)),this._initNumfmtLocalChange(),this._initCommandExecutedListener()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>this._forceUpdate()))}_initCommandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_forceUpdate(e){var t,n;let i=e??((t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId());if(!i)return;let a=this._renderManagerService.getRenderUnitById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}};j=y([v(0,r.ICommandService),v(1,r.IUniverInstanceService),v(2,i.IRenderManagerService),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(t.SheetsNumfmtCellContentController))],j);let M=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s){super(),this._context=e,this._selectionManagerService=t,this._cellAlertManagerService=n,this._localeService=r,this._numfmtService=i,this._configService=a,this._commandService=o,this._univerInstanceService=s,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._selectionManagerService.selectionChanged$.subscribe(e=>this._updateAlert(e))),this.disposeWithMe(this._context.unit.activeSheet$.subscribe(()=>this._updateAlert(this._selectionManagerService.getCurrentSelections()))),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(()=>this._updateAlert(this._selectionManagerService.getCurrentSelections())))}_isCurrentSheet(e){let t=this._selectionManagerService.currentSelectionParam;return!!(e&&(t==null?void 0:t.unitId)===this._context.unit.getUnitId()&&t.sheetId===e.getSheetId())}_updateAlert(e){var n,i;this._hideAlert();let s=this._context.unit,c=s.getActiveSheet();if(!this._isCurrentSheet(c)||(e==null?void 0:e.length)!==1||(n=this._configService.getConfig(t.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;let l=e[0],u=l.primary;if(!u)return;let d=u.actualRow,f=u.actualColumn,p=s.getUnitId(),m=c.getSheetId(),h=c.getCell(d,f),g;if(h!=null&&h.s){var _;g=(_=s.getStyles().get(h.s))==null?void 0:_.n}g||=this._numfmtService.getValue(p,m,d,f);let v=h==null?void 0:h.v,y=(0,r.isRealNum)(v)||typeof v==`string`&&typeof((i=(0,r.getNumfmtParseValueFilter)(v))==null?void 0:i.v)==`number`;if(!(0,r.isTextFormat)(g==null?void 0:g.pattern)||!r.Tools.isDefine(v)||!y)return;let b={...l.range};this._cellAlertManagerService.showAlert({type:o.CellAlertType.WARNING,title:this._localeService.t(`sheets-numfmt-ui.info.error`),message:this._localeService.t(`sheets-numfmt-ui.info.forceStringInfo`),location:{unitId:p,subUnitId:m,row:d,col:f},width:200,height:74,key:this._alertKey,menu:[{label:this._localeService.t(`sheets-numfmt-ui.info.convertToNumber`),onSelect:()=>{this._commandService.syncExecuteCommand(a.TextToNumberCommand.id,{unitId:p,subUnitId:m,ranges:[b]})&&this._hideAlert()}}]})}get _alertKey(){return`SHEET_NUMFMT_ALERT:${this._context.unit.getUnitId()}`}_hideAlert(){this._cellAlertManagerService.removeAlert(this._alertKey)}};M=y([v(1,(0,r.Inject)(a.SheetsSelectionsService)),v(2,(0,r.Inject)(o.CellAlertManagerService)),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(a.INumfmtService)),v(5,r.IConfigService),v(6,r.ICommandService),v(7,r.IUniverInstanceService)],M);let N=class extends r.Disposable{constructor(e){super(),this._repeatLastActionService=e,this._initCommandRecording()}_initCommandRecording(){this._repeatLastActionService&&this.disposeWithMe(this._repeatLastActionService.registerRepeatableCommand(t.SetNumfmtCommand.id,(e,t)=>{if(!t)return;let{values:n}=t,r=n.find(e=>e.pattern);if(!r)return;let{pattern:i,type:a}=r,o=[],s=new Set;for(let t of e){let{startRow:e,startColumn:n,endRow:r,endColumn:c}=t;for(let t=e;t<=r;t++)for(let e=n;e<=c;e++){let n=`${t}-${e}`;s.has(n)||(s.add(n),o.push({row:t,col:e,pattern:i,type:a}))}}return{...t,values:o}},o.RepeatLastActionPermission.CellStyle))}};N=y([v(0,(0,r.Optional)(o.IRepeatLastActionService))],N);function pe(e){if(r.numfmt.getFormatDateInfo(e).isDuration)return`duration`;let t=r.numfmt.getFormatInfo(e).type;return t===`date`||t===`datetime`||t===`time`?t:null}function me(e,t){var n;let i=((n=r.numfmt.getLocale(t))==null?void 0:n.decimal)??`.`,a=e.lastIndexOf(i);if(a<0)return e;let o=e.indexOf(` `,a),s=o<0?e.length:o,c=s;for(;c>a+1&&e[c-1]===`0`;)c--;return e.slice(0,c)+e.slice(s)}function he(e,t){var n;let i=Math.round(Math.abs(e)*864e5),a=Math.floor(i/36e5),o=Math.floor(i/6e4)%60,s=Math.floor(i/1e3)%60,c=i%1e3,l=c?`${((n=r.numfmt.getLocale(t))==null?void 0:n.decimal)??`.`}${String(c).padStart(3,`0`).replace(/0+$/,``)}`:``;return`${e<0?`-`:``}${a}:${String(o).padStart(2,`0`)}:${String(s).padStart(2,`0`)}${l}`}function ge(e){let{serial:t,pattern:n,locale:i,dateSystem:a}=e,o=pe(n);if(!o||!Number.isFinite(t)||t<0&&o!==`duration`)return null;if(o===`duration`)return he(t,i);let s=(0,r.excelSerialToDateTimeParts)(t,{dateSystem:a});if(!s)return null;let c=Math.round(s.fractionalSecond*1e3)>0,l=r.numfmt.getDateTimeEditPattern(n,t);if(!l)return null;let u=r.numfmt.format(l,t,{locale:i,dateSystem:a,throws:!1});return c?me(u,i):u}function _e(e,t){var n;let i=((n=r.numfmt.getLocale(t))==null?void 0:n.decimal)??`.`,a=i===`.`?e:e.replace(i,`.`),o=/^\s*([+-])?(\d+):([0-5]?\d):([0-5]?\d)(\.\d{1,10})?\s*$/.exec(a);if(!o)return null;let s=o[1]===`-`?-1:1,c=Number(o[2]),l=Number(o[3]),u=Number(o[4]),d=Number(o[5]??0);return s*(c*3600+l*60+u+d)/86400}function ve(e){let{content:t,originalSerial:n,pattern:i,locale:a,dateSystem:o}=e,s=pe(i);if(!s||!Number.isFinite(n)||n<0&&s!==`duration`)return null;if(s===`duration`)return _e(t,a);if(s===`time`){let e=r.numfmt.parseTime(t,{locale:a,dateSystem:o});return e?Math.floor(n)+Number(e.v):null}let c=r.numfmt.parseDate(t,{locale:a,dateSystem:o});return!c||typeof c.v!=`number`?null:s===`date`?Math.floor(c.v)+(n-Math.floor(n)):c.v}let ye=()=>{let e=[];return{add:(t,n,r,i,a)=>e.push({unitId:t,subUnitId:n,row:r,col:i,value:a}),getEffects:()=>e,clean:()=>{e=[]}}},P=class extends r.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._numfmtService=t,this._univerInstanceService=n,this._injector=r,this._sheetsNumfmtCellContentController=i,this._editorBridgeService=a,_(this,`_collectEffectMutation`,ye()),this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.BEFORE_CELL_EDIT,{handler:(e,n,i)=>{let a=n.row,o=n.col,s=this._numfmtService.getValue(n.unitId,n.subUnitId,a,o);if(s){let c=n.worksheet.getCellRaw(a,o);if(!(c!=null&&c.f)&&(c==null?void 0:c.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(c.v)){let e=ge({serial:Number(c.v),pattern:s.pattern,locale:this._sheetsNumfmtCellContentController.getLocale(n.workbook),dateSystem:n.workbook.getDateSystem()});if(e!=null)return i&&i({...c,v:e})}switch((0,t.getPatternType)(s.pattern)){case`scientific`:case`currency`:case`grouped`:case`number`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=(0,f.stripErrorMargin)(Number(e.v))),i&&i(e)}case`percent`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=`${(0,f.stripErrorMargin)(Number(e.v)*100)}%`,e.isPercentFormat=!0),i&&i(e)}default:return i&&i(e)}}return i(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.AFTER_CELL_EDIT,{handler:(e,n,i)=>{var a,o;if(!(e!=null&&e.v)&&!(e!=null&&e.p))return i(e);this._collectEffectMutation.clean();let s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),c=n.worksheet.getCellRaw(n.row,n.col);if((0,r.isTextFormat)(s==null?void 0:s.pattern)||e.t===r.CellValueType.FORCE_STRING)return i(e);let l=(a=e.p)==null?void 0:a.body,u=e!=null&&(o=e.p)!=null&&(o=o.body)!=null&&o.dataStream?e.p.body.dataStream.replace(/\r\n$/,``):String(e.v),d=this._sheetsNumfmtCellContentController.getLocale(n.workbook),p=n.workbook.getDateSystem(),m=(0,r.getNumfmtParseValueFilter)(u,{locale:d,dateSystem:p});if(l){if(be(l)){let{dataStream:t}=l,n=t.replace(/\r\n$/,``),r=Number(n);if(Number.isNaN(r)&&!m)return i(e)}else return i(e)}if(s!=null&&s.pattern&&(c==null?void 0:c.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(c.v)){let t=ve({content:u,originalSerial:Number(c.v),pattern:s.pattern,locale:d,dateSystem:p});if(t!=null)return i({...e,p:void 0,v:(0,f.stripErrorMargin)(t,16),t:r.CellValueType.NUMBER})}if(m){if(!m.z&&!(s!=null&&s.pattern)&&(c==null?void 0:c.t)!==r.CellValueType.STRING&&(c==null?void 0:c.t)!==r.CellValueType.FORCE_STRING&&(0,r.willLoseNumericPrecision)(u))return i({...e,p:void 0,v:u,t:r.CellValueType.FORCE_STRING});m.z&&(!(s!=null&&s.pattern)||(0,t.getPatternType)(m.z)!==(0,t.getPatternType)(s.pattern))&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:m.z});let a=(0,f.stripErrorMargin)(Number(m.v),16);return i({...e,p:void 0,v:a,t:r.CellValueType.NUMBER})}return i(e)}})))}_initInterceptorCommands(){let e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case a.SetRangeValuesCommand.id:{let n=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!n.length)return{redos:[],undos:[]};let r=(0,a.getSheetCommandTarget)(e._univerInstanceService,t.params);if(!r)return{redos:[],undos:[]};let{unitId:i,subUnitId:o}=r,s=n.filter(e=>e.unitId===i&&e.subUnitId===o),c=s.filter(e=>{var t;return!!((t=e.value)!=null&&t.pattern)}).map(e=>({row:e.row,col:e.col,pattern:e.value.pattern})),l=s.filter(e=>{var t;return!((t=e.value)!=null&&t.pattern)}).map(e=>({startRow:e.row,endColumn:e.col,startColumn:e.col,endRow:e.row})),u=[],d=[];if(c.length){let t={id:a.SetNumfmtMutation.id,params:(0,a.transformCellsToRange)(i,o,c)};u.push(t),d.push(...(0,a.factorySetNumfmtUndoMutation)(e._injector,t.params))}if(l.length){let t={id:a.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:l}};u.push(t),d.push(...(0,a.factoryRemoveNumfmtUndoMutation)(e._injector,t.params))}return{redos:u,undos:d.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};P=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(a.INumfmtService)),v(2,(0,r.Inject)(r.IUniverInstanceService)),v(3,(0,r.Inject)(r.Injector)),v(4,(0,r.Inject)(t.SheetsNumfmtCellContentController)),v(5,(0,r.Optional)(o.IEditorBridgeService))],P);function be(e){let{textRuns:t=[],paragraphs:n=[],customRanges:r,customBlocks:i=[]}=e,a=[`va`];return!(t.some(e=>!!(e.ts&&Object.keys(e.ts).some(e=>a.includes(e))))||n.some(e=>e.bullet)||n.length>=2||r!=null&&r.length||i.length>0)}let xe={[n.RibbonStartGroup.NUMBER]:{[ce]:{order:9,menuItemFactory:de}}},F=class extends r.Disposable{constructor(e){super(),e.mergeMenu(xe)}};F=y([v(0,n.IMenuManagerService)],F);let I=class extends r.Plugin{constructor(e=O,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},O,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(D,o)}onStarting(){(0,r.registerDependencies)(this._injector,[[A],[j],[P],[F],[N]]),(0,r.touchDependencies)(this._injector,[[A],[j]])}onRendered(){[[M]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))}),(0,r.touchDependencies)(this._injector,[[P],[F],[N]])}};_(I,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_(I,`packageName`,T),_(I,`version`,E),_(I,`type`,r.UniverInstanceType.UNIVER_SHEET),I=y([(0,r.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,t.UniverSheetsNumfmtPlugin,o.UniverSheetsMobileUIPlugin,n.UniverMobileUIPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],I);function L({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),l=`_${(0,u.useId)()}`,d=(0,u.useRef)(null);return(0,u.useImperativeHandle)(e,()=>d.current),(0,u.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return we(d.current)},[n,r]),R(r,`${i}`,{defIds:r.defIds,idSuffix:l},{ref:d,className:c,...s},o)}function R(e,t,n,r,i){return(0,u.createElement)(e.tag,{key:t,...Se(e,n,i),...r},(Ce(e,n).children||[]).map((r,a)=>R(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function Se(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function Ce(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function we(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:Te(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(Ee(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function Te(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function Ee(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}L.displayName=`UniverIcon`;let De={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:`M4.06641 3.49366C4.06641 2.27555 5.14145 1.3916 6.33307 1.3916C7.52469 1.3916 8.59974 2.27555 8.59974 3.49366V6.49777C8.59974 7.71586 7.52469 8.59982 6.33307 8.59982C5.14145 8.59982 4.06641 7.71586 4.06641 6.49777V3.49366ZM6.33307 2.5916C5.68376 2.5916 5.26641 3.05264 5.26641 3.49366V6.49777C5.26641 6.93878 5.68376 7.39982 6.33307 7.39982C6.98239 7.39982 7.39974 6.93878 7.39974 6.49777V3.49366C7.39974 3.05264 6.98239 2.5916 6.33307 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.0664 3.49366C10.0664 2.27555 11.1415 1.3916 12.3331 1.3916C13.5247 1.3916 14.5997 2.27555 14.5997 3.49366V6.49777C14.5997 7.71586 13.5247 8.59982 12.3331 8.59982C11.1415 8.59982 10.0664 7.71586 10.0664 6.49777V3.49366ZM12.3331 2.5916C11.6838 2.5916 11.2664 3.05264 11.2664 3.49366V6.49777C11.2664 6.93878 11.6838 7.39982 12.3331 7.39982C12.9824 7.39982 13.3997 6.93878 13.3997 6.49777V3.49366C13.3997 3.05264 12.9824 2.5916 12.3331 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.4242 9.5417C12.1899 9.30739 11.81 9.30739 11.5756 9.5417C11.3413 9.77602 11.3413 10.1559 11.5756 10.3902L12.5514 11.366H6.3334C6.00203 11.366 5.7334 11.6346 5.7334 11.966C5.7334 12.2973 6.00203 12.566 6.3334 12.566H12.5514L11.5756 13.5417C11.3413 13.776 11.3413 14.1559 11.5756 14.3902C11.81 14.6245 12.1899 14.6245 12.4242 14.3902L14.4159 12.3985C14.5294 12.2893 14.6001 12.1359 14.6001 11.966C14.6001 11.796 14.5294 11.6426 14.4159 11.5334L12.4242 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},z=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`add-digits-icon`,ref:t,icon:De}))});z.displayName=`AddDigitsIcon`;let Oe={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`}}]},B=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:Oe}))});B.displayName=`CheckMarkIcon`;let ke={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:`M7.3999 2.8999V1.6C7.3999 1.26863 7.66853 1 7.9999 1C8.33127 1 8.5999 1.26863 8.5999 1.6V2.8999H10.2044C11.6655 2.8999 12.8499 4.08431 12.8499 5.54536C12.8499 5.87673 12.5813 6.14536 12.2499 6.14536C11.9185 6.14536 11.6499 5.87673 11.6499 5.54536C11.6499 4.74705 11.0028 4.0999 10.2044 4.0999H5.7384C4.97155 4.0999 4.3499 4.72155 4.3499 5.4884C4.3499 6.14439 4.80899 6.71087 5.45074 6.84677L10.7977 7.97906C11.994 8.23242 12.8499 9.28849 12.8499 10.5114C12.8499 11.941 11.691 13.0999 10.2614 13.0999H8.5999V14.4C8.5999 14.7314 8.33127 15 7.9999 15C7.66853 15 7.3999 14.7314 7.3999 14.4V13.0999H5.79536C4.33431 13.0999 3.1499 11.9155 3.1499 10.4544C3.1499 10.1231 3.41853 9.85445 3.7499 9.85445C4.08127 9.85445 4.3499 10.1231 4.3499 10.4544C4.3499 11.2527 4.99705 11.8999 5.79536 11.8999H10.2614C11.0283 11.8999 11.6499 11.2782 11.6499 10.5114C11.6499 9.85542 11.1908 9.28893 10.5491 9.15303L5.20214 8.02074C4.00575 7.76739 3.1499 6.71132 3.1499 5.4884C3.1499 4.05881 4.30881 2.8999 5.7384 2.8999H7.3999Z`}}]},V=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`dollar-icon`,ref:t,icon:ke}))});V.displayName=`DollarIcon`;let Ae={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:`M12.2058 3.459H11.2416V12.6604H9.6438V11.6962Q8.9091 12.844 7.4858 12.844Q5.8971 12.844 4.8456 11.6686Q3.7942 10.4932 3.7942 8.5739Q3.7942 6.5904 4.7814 5.4471Q5.7685 4.3038 7.4031 4.3038Q8.9183 4.3038 9.5887 5.3415V3.459H7.5041V2.1091H9.5887V1.2H11.2416V2.1091H12.2058V3.459ZM7.6143 11.4941Q8.5234 11.4941 9.0744 10.8008Q9.6254 10.1075 9.6254 8.7484Q9.6254 5.6629 7.5592 5.6629Q6.5491 5.6629 6.0211 6.4297Q5.493 7.1965 5.493 8.5923Q5.493 11.4941 7.6143 11.4941ZM11.2416 14.8H4.0421V13.4501H11.2416V14.8Z`}}]},H=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`dong-icon`,ref:t,icon:Ae}))});H.displayName=`DongIcon`;let je={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:`M5.84964 5.80918C6.71946 3.63548 8.84516 2.2 11.3295 2.2C11.8324 2.2 12.3198 2.26279 12.7846 2.38065C13.1058 2.46209 13.4322 2.26773 13.5137 1.94652C13.5951 1.62532 13.4008 1.2989 13.0795 1.21746C12.5191 1.07535 11.9327 1 11.3295 1C8.17278 1 5.49724 2.96009 4.57394 5.80918H3.06582C2.73445 5.80918 2.46582 6.07781 2.46582 6.40918C2.46582 6.74055 2.73445 7.00918 3.06582 7.00918H4.29808C4.25287 7.33297 4.22949 7.66376 4.22949 8C4.22949 8.33608 4.25284 8.6667 4.29801 8.99033H3.06582C2.73445 8.99033 2.46582 9.25896 2.46582 9.59033C2.46582 9.9217 2.73445 10.1903 3.06582 10.1903H4.57378C5.49693 13.0397 8.1726 15 11.3295 15C11.9336 15 12.5209 14.9244 13.0821 14.7819C13.4033 14.7003 13.5975 14.3738 13.5159 14.0527C13.4344 13.7315 13.1079 13.5373 12.7867 13.6188C12.3213 13.737 11.8332 13.8 11.3295 13.8C8.84497 13.8 6.71914 12.3643 5.84944 10.1903H11.4291C11.7605 10.1903 12.0291 9.9217 12.0291 9.59033C12.0291 9.25896 11.7605 8.99033 11.4291 8.99033H5.51225C5.45783 8.66834 5.42949 8.33748 5.42949 8C5.42949 7.66235 5.45786 7.33133 5.51233 7.00918H11.4291C11.7605 7.00918 12.0291 6.74055 12.0291 6.40918C12.0291 6.07781 11.7605 5.80918 11.4291 5.80918H5.84964Z`}}]},U=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`euro-icon`,ref:t,icon:je}))});U.displayName=`EuroIcon`;let 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:`M1.85059 4.06725C1.85059 2.84302 2.84302 1.85059 4.06725 1.85059C5.29148 1.85059 6.28392 2.84302 6.28392 4.06725C6.28392 5.29148 5.29148 6.28392 4.06725 6.28392C2.84302 6.28392 1.85059 5.29148 1.85059 4.06725ZM4.06725 2.95059C3.45053 2.95059 2.95059 3.45053 2.95059 4.06725C2.95059 4.68397 3.45053 5.18392 4.06725 5.18392C4.68397 5.18392 5.18392 4.68397 5.18392 4.06725C5.18392 3.45053 4.68397 2.95059 4.06725 2.95059Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.7168 11.933C9.7168 10.7087 10.7092 9.71631 11.9335 9.71631C13.1577 9.71631 14.1501 10.7087 14.1501 11.933C14.1501 13.1572 13.1577 14.1496 11.9335 14.1496C10.7092 14.1496 9.7168 13.1572 9.7168 11.933ZM11.9335 10.8163C11.3167 10.8163 10.8168 11.3163 10.8168 11.933C10.8168 12.5497 11.3167 13.0496 11.9335 13.0496C12.5502 13.0496 13.0501 12.5497 13.0501 11.933C13.0501 11.3163 12.5502 10.8163 11.9335 10.8163Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.5241 3.32407C13.7584 3.08975 13.7584 2.70986 13.5241 2.47554C13.2898 2.24123 12.9099 2.24123 12.6755 2.47554L2.47554 12.6755C2.24123 12.9099 2.24123 13.2898 2.47554 13.5241C2.70986 13.7584 3.08975 13.7584 3.32407 13.5241L13.5241 3.32407Z`}}]},W=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`percent-icon`,ref:t,icon:Me}))});W.displayName=`PercentIcon`;let Ne={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:`M6.33307 1.3916C5.14145 1.3916 4.06641 2.27555 4.06641 3.49366V6.49777C4.06641 7.71586 5.14145 8.59982 6.33307 8.59982C7.52469 8.59982 8.59974 7.71586 8.59974 6.49777V3.49366C8.59974 2.27555 7.52469 1.3916 6.33307 1.3916ZM5.26641 3.49366C5.26641 3.05264 5.68376 2.5916 6.33307 2.5916C6.98239 2.5916 7.39974 3.05264 7.39974 3.49366V6.49777C7.39974 6.93878 6.98239 7.39982 6.33307 7.39982C5.68376 7.39982 5.26641 6.93878 5.26641 6.49777V3.49366Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.90913 9.5417C8.14345 9.30739 8.52335 9.30739 8.75766 9.5417C8.99198 9.77602 8.99198 10.1559 8.75766 10.3902L7.78193 11.366H13.9999C14.3313 11.366 14.5999 11.6346 14.5999 11.966C14.5999 12.2973 14.3313 12.566 13.9999 12.566H7.78193L8.75766 13.5417C8.99198 13.776 8.99198 14.1559 8.75766 14.3902C8.52335 14.6245 8.14345 14.6245 7.90913 14.3902L5.91739 12.3985C5.80388 12.2893 5.73324 12.1359 5.73324 11.966C5.73324 11.796 5.80388 11.6426 5.91739 11.5334L7.90913 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},Pe=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`reduce-digits-icon`,ref:t,icon:Ne}))});Pe.displayName=`ReduceDigitsIcon`;let Fe={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:`M6.7937 8.6977Q6.7937 9.5729 6.7228 9.9277Q6.6045 10.8264 5.7057 11.3704Q4.8543 11.8908 3.577 12.0327H3.4115Q2.6783 12.0327 2.2052 11.3468Q1.7795 10.7555 1.7795 9.9277Q1.7795 9.5965 1.945 8.887Q2.1343 8.0828 2.3944 7.8226Q2.4417 7.7517 2.5127 7.7517Q2.6546 7.7517 2.6546 7.9172Q2.6546 7.9882 2.489 8.4139Q2.3235 8.8397 2.3235 9.0762Q2.3235 9.904 2.7256 10.2588Q3.1277 10.6136 3.9791 10.6136Q4.9016 10.6136 5.6111 10.1878Q6.4863 9.6911 6.4153 8.8397Q6.2261 8.1774 5.8713 6.4271Q5.4456 4.2038 5.1617 3.0449Q4.9489 2.6191 4.807 2.4536Q4.9489 2.1934 5.0198 1.8859Q5.1617 1.2 5.28 1.2Q5.351 1.2 5.4456 1.4602Q5.5638 1.744 5.6821 1.8623Q6.1078 2.217 6.1551 2.288Q6.1551 2.3353 6.1788 2.3826Q6.2261 2.6191 5.9186 3.2577Q6.2024 4.535 6.4863 6.4271Q6.6991 7.8463 6.7937 8.6977ZM11.3586 8.9816Q11.3823 9.6911 11.0748 10.3061Q10.8856 10.7082 10.0577 10.7082Q9.3009 10.7082 8.8751 9.9277Q8.5677 9.4073 8.4021 7.8226Q8.1656 5.8122 7.9054 4.0146Q7.7398 3.0922 7.6452 2.6428L7.7871 1.9332Q7.8581 1.4602 7.929 1.4602Q7.9763 1.4602 8 1.5784Q8.2365 2.2407 8.4257 3.8963Q8.7096 6.167 8.8042 6.6637Q9.0643 8.5795 9.2299 8.9106Q9.3245 9.1235 9.5729 9.3127Q9.8212 9.5019 10.0577 9.5019Q10.72 9.5019 10.791 9.1471Q10.7437 8.9816 10.4835 8.6268Q10.2706 8.2957 10.247 8.0355L10.3889 7.657Q10.4598 7.4442 10.5781 7.2077Q10.6017 7.184 10.6254 7.184Q10.8383 7.184 11.0275 7.6334Q11.335 8.272 11.3586 8.9816ZM14.2205 10.7318Q14.2205 12.2219 13.511 13.3099Q13.1325 13.8776 12.2574 14.6108Q11.9736 14.8 11.4532 14.8Q10.9329 14.8 9.3245 14.4689Q9.2536 14.4689 9.1471 14.3624Q9.0407 14.256 9.0407 14.2087Q9.0643 14.185 9.0643 14.185L9.088 14.1614Q9.703 14.1141 10.0577 14.1141Q10.72 14.0904 11.0038 13.9722Q13.1089 13.1917 13.7475 11.2995Q13.6765 11.1339 13.2035 10.3061Q12.825 9.6438 12.825 9.3363Q12.825 9.289 12.9197 9.1471Q12.9433 9.1235 13.0379 8.7923Q13.1089 8.5558 13.1798 8.5558Q13.4637 8.5558 13.8657 9.3363Q14.2205 10.0459 14.2205 10.377V10.7318ZM10.6017 12.1273Q10.6254 12.1983 10.4243 12.6122Q10.2233 13.0261 10.105 13.0261Q9.9631 13.0261 9.6793 12.7777Q9.3955 12.5294 9.3245 12.3638Q9.632 11.536 9.7976 11.465Q9.8685 11.465 10.1997 11.7607Q10.5308 12.0563 10.6017 12.1273ZM9.1353 12.4584Q9.159 12.6003 8.9579 12.967Q8.7569 13.3336 8.6386 13.3336Q8.4967 13.3336 8.201 13.097Q7.9054 12.8605 7.9054 12.7423Q7.8344 12.553 8.3075 11.8198Q8.6386 11.9617 9.1353 12.4584Z`}}]},Ie=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`rial-icon`,ref:t,icon:Fe}))});Ie.displayName=`RialIcon`;let Le={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:`M11.9445 1.55649C12.2184 1.744 12.2895 2.11755 12.1033 2.39085L9.24342 6.58659H12.8001C13.1315 6.58659 13.4001 6.85522 13.4001 7.18659C13.4001 7.51796 13.1315 7.78659 12.8001 7.78659H8.5999V9.91276H13.2221C13.5534 9.91276 13.8221 10.1814 13.8221 10.5128C13.8221 10.8441 13.5534 11.1128 13.2221 11.1128H8.5999V14.0877C8.5999 14.4191 8.33127 14.6877 7.9999 14.6877C7.66853 14.6877 7.3999 14.4191 7.3999 14.0877V11.1128H2.77773C2.44636 11.1128 2.17773 10.8441 2.17773 10.5128C2.17773 10.1814 2.44636 9.91276 2.77773 9.91276H7.3999V7.78659H3.2001C2.86873 7.78659 2.6001 7.51796 2.6001 7.18659C2.6001 6.85522 2.86873 6.58659 3.2001 6.58659H6.75736L3.89753 2.39085C3.71125 2.11755 3.78234 1.744 4.05631 1.55649C4.33029 1.36899 4.7034 1.43854 4.88968 1.71184L7.94595 6.19577C7.96752 6.22741 7.98564 6.2604 8.00039 6.29429C8.01514 6.2604 8.03326 6.22741 8.05483 6.19577L11.1111 1.71184C11.2974 1.43854 11.6705 1.36899 11.9445 1.55649Z`}}]},Re=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`rmb-icon`,ref:t,icon:Le}))});Re.displayName=`RmbIcon`;let ze={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:`M9.72502 1.02051H6.07803C4.97346 1.02051 4.07803 1.91594 4.07803 3.02051V7.57046H3.00039C2.66902 7.57046 2.40039 7.83909 2.40039 8.17046C2.40039 8.50183 2.66902 8.77046 3.00039 8.77046H4.07803V10.4854H3.00039C2.66902 10.4854 2.40039 10.754 2.40039 11.0854C2.40039 11.4167 2.66902 11.6854 3.00039 11.6854H4.07803V14.3795C4.07803 14.7108 4.34666 14.9795 4.67803 14.9795C5.0094 14.9795 5.27803 14.7108 5.27803 14.3795V11.6854H10.3637C10.695 11.6854 10.9637 11.4167 10.9637 11.0854C10.9637 10.754 10.695 10.4854 10.3637 10.4854H5.27803V8.77046H9.72503C11.8651 8.77046 13.6 7.03557 13.6 4.89548C13.6 2.75539 11.8651 1.02051 9.72502 1.02051ZM9.72503 7.57046H5.27803V3.12051C5.27803 2.62345 5.68097 2.22051 6.17803 2.22051H9.72502C11.2024 2.22051 12.4 3.41814 12.4 4.89548C12.4 6.37283 11.2024 7.57046 9.72503 7.57046Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Be=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`rouble-icon`,ref:t,icon:ze}))});Be.displayName=`RoubleIcon`;let Ve={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:`M8.5953 11.0279H7.1987Q5.9451 9.0475 5.6418 8.5953Q5.3384 8.1431 5.0035 7.8197Q4.6687 7.4963 4.3739 7.4104Q4.0791 7.3246 3.5926 7.3246H2.3104V11.0279H1.2V2.6367H4.9148Q5.6761 2.6367 6.1912 2.734Q6.7064 2.8313 7.0956 3.1433Q7.4848 3.4552 7.6938 3.9303Q7.9027 4.4054 7.9027 4.932Q7.9027 5.8822 7.3017 6.4603Q6.7007 7.0384 5.5502 7.1929V7.2158Q6.3916 7.5879 7.13 8.7441L8.5953 11.0279ZM2.3104 6.3286H4.6916Q5.4128 6.3286 5.8335 6.2056Q6.2542 6.0825 6.5061 5.7276Q6.7579 5.3727 6.7579 4.932Q6.7579 4.3596 6.3401 3.9589Q5.9222 3.5582 4.9606 3.5582H2.3104V6.3286ZM10.4842 5.7391Q11.0623 4.8175 12.2185 4.8175Q13.4148 4.8175 14.1074 5.6847Q14.8 6.5519 14.8 7.9428Q14.8 9.4253 14.033 10.2981Q13.266 11.171 12.1498 11.171Q11.171 11.171 10.5815 10.3926H10.5529V13.3633H9.5226V4.9549H10.4613V5.7391H10.4842ZM12.0811 10.3239Q12.8024 10.3239 13.2746 9.7258Q13.7468 9.1276 13.7468 7.9428Q13.7468 6.8266 13.2918 6.2256Q12.8367 5.6246 12.1269 5.6246Q11.3943 5.6246 10.9221 6.2943Q10.4498 6.964 10.4498 8.0286Q10.4498 9.1562 10.902 9.7401Q11.3542 10.3239 12.0811 10.3239Z`}}]},He=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`rupiah-icon`,ref:t,icon:Ve}))});He.displayName=`RupiahIcon`;let Ue={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.8 9.4486H12.955L11.8883 13.2829H10.5477L9.4811 9.4486H6.5189L5.4378 13.2829H4.0108L2.9874 9.4486H1.2V8.4685H2.7351L2.4541 7.409H1.2V6.436H2.1946L1.2 2.7171H2.6342L3.4919 6.436H6.1153L7.182 2.7171H8.8613L9.9135 6.436H12.4649L13.3802 2.7171H14.8L13.7622 6.436H14.8V7.409H13.5099L13.2144 8.4685H14.8V9.4486ZM8.645 6.436Q8.0757 4.3676 7.9892 4Q7.8667 4.6342 7.3261 6.436H8.645ZM12.2414 7.409H10.209L10.5045 8.4685H11.9748L12.2414 7.409ZM9.2144 8.4685L8.9189 7.409H7.0739L6.7856 8.4685H9.2144ZM5.8559 7.409H3.7297L3.9748 8.4685H5.5604L5.8559 7.409ZM11.7586 9.4486H10.7351Q11.0955 11.1063 11.1964 11.8054L11.7586 9.4486ZM5.2937 9.4486H4.1838Q4.573 11.1063 4.7027 11.8054Q4.955 10.7315 5.2937 9.4486Z`}}]},We=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`won-icon`,ref:t,icon:Ue}))});We.displayName=`WonIcon`;let Ge={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:`M10.092 14.8H1.3716V13.4548L7.6428 6.2652Q6.5389 6.3302 5.7596 6.3302H1.7334V4.9572H9.7858V6.0426L4.4516 12.2767Q4.2939 12.4715 3.6352 13.1858Q3.4775 13.3342 3.4218 13.4363Q4.3774 13.3528 5.5277 13.3528H10.092V14.8ZM14.6284 6.9888L13.376 8.0557V14.8H11.7247V9.4843L10.5094 10.4862V9.0205L11.7247 8.0186V1.2H13.376V6.5899L14.6284 5.5323V6.9888Z`}}]},G=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(L,Object.assign({},e,{id:`zloty-icon`,ref:t,icon:Ge}))});G.displayName=`ZlotyIcon`;let K=(0,u.createContext)([]),q=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){let n=this._getKey(e);return this._localStorageService.getItem(n).then(e=>{e||this._localStorageService.setItem(n,t)})}markHabit(e,t){let n=this._getKey(e);this._localStorageService.getItem(n).then(e=>{if(e){let r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1),e.unshift(t),this._localStorageService.setItem(n,e)}})}async getHabit(e,t){let n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){let e=r.map((e,t,n)=>({value:e,priority:n.length-t}));return t.sort((t,n)=>{var r,i;let a=((r=e.find(e=>e.value===t))==null?void 0:r.priority)||-1;return(((i=e.find(e=>e.value===n))==null?void 0:i.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};q=y([v(0,(0,r.Inject)(r.ILocalStorageService))],q);let Ke=e=>!!(0,t.getCurrencyType)(e)&&e.startsWith(`_(`);function qe(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,[s,c]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(i||``,2)),f=(0,u.useContext)(K),[p,m]=(0,u.useState)(()=>(0,t.getCurrencyType)(i)||f[0]),h=(0,u.useMemo)(()=>f.map(e=>({label:e,value:e})),[]),g=(0,n.useDependency)(r.LocaleService);return(0,u.useLayoutEffect)(()=>{a(()=>(0,t.setPatternDecimal)(`_("${p}"* #,##0${s>0?`.0`:``}_)`,s))},[s,a,p]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:s,step:1,precision:0,max:20,min:0,onChange:e=>{let n=e||0;c(n),o((0,t.setPatternDecimal)(`_("${p}"* #,##0${n>0?`.0`:``}_)`,n))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{options:h,value:p,onChange:e=>{m(e),o((0,t.setPatternDecimal)(`_("${e}"* #,##0${s>0?`.0`:``}_)`,s))}})})]})]}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.accountingDes`)})]})}let Je=e=>!!(0,t.getCurrencyType)(e)&&!e.startsWith(`_(`);function Ye(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useContext)(K),[c,f]=(0,u.useState)(()=>(0,t.getCurrencyType)(e.defaultPattern)||s[0]),[p,m]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,2)),[h,g]=(0,u.useState)(()=>{var n;let i=(0,t.getCurrencyFormatOptions)(c);return((n=i.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern)))==null?void 0:n.value)||i[0].value}),_=(0,u.useMemo)(()=>(0,t.getCurrencyFormatOptions)(c),[c]),v=(0,u.useMemo)(()=>s.map(e=>({label:e,value:e})),[s]);return(0,u.useLayoutEffect)(()=>{i(()=>(0,t.setPatternDecimal)(h,p))},[p,i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:p,max:20,min:0,onChange:e=>{m(e||0),a((0,t.setPatternDecimal)(h,e||0))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{value:c,options:v,onChange:e=>{if(e===void 0)return;f(e);let n=(0,t.getCurrencyFormatOptions)(e)[0].value;g(n),a((0,t.setPatternDecimal)(n,p))}})})]})]}),(0,d.jsx)(`div`,{className:`label univer-mt-4`,children:o.t(`sheets-numfmt-ui.negType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:h,options:_,onChange:e=>{e!==void 0&&(g(e),a((0,t.setPatternDecimal)(e,p)))}})}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyDes`)})]})}let J=`customFormat`,Y=`numfmt_custom_pattern`;function Xe(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,s=(0,n.useDependency)(q),c=(0,n.useDependency)(r.ILocalStorageService),f=(0,n.useDependency)(r.LocaleService),p=(0,n.useObservable)(f.currentLocale$,f.getCurrentLocale()),[m,h]=(0,u.useState)(i);(0,u.useLayoutEffect)(()=>{a(()=>(s.markHabit(J,m),c.getItem(Y).then((e=[])=>{let t=[...new Set([m,...e||[]])].splice(0,10).filter(e=>!!e);return c.setItem(Y,t)}).catch(console.error),m))},[c,a,m,s]);let[g,_]=(0,u.useState)([]);(0,u.useEffect)(()=>{let e=!1;return c.getItem(Y).then(e=>{let n=[...t.CURRENCYFORMAT.map(e=>e.suffix(`$`)),...(0,t.getDateFormatOptions)(p).map(e=>e.value),...t.NUMBERFORMAT.map(e=>e.suffix),...e??[]];return s.addHabit(J,[]).then(()=>s.getHabit(J,n))}).then(t=>{e||_([...new Set(t)])}).catch(console.error),()=>{e=!0}},[p,c,s]);let v=e=>{h(e),o(e)};return(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.customFormat`)}),(0,d.jsx)(l.Input,{placeholder:f.t(`sheets-numfmt-ui.customFormat`),onBlur:()=>{o(m)},value:m,onChange:h,className:`univer-mt-2 univer-w-full`}),(0,d.jsx)(`div`,{className:(0,l.clsx)(`univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2`,l.borderClassName),children:g.map(e=>(0,d.jsxs)(`div`,{onClick:()=>v(e),className:`univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm`,children:[(0,d.jsx)(`div`,{className:`univer-flex univer-w-4 univer-items-center univer-text-primary-600`,children:m===e&&(0,d.jsx)(B,{})}),(0,d.jsx)(`div`,{children:e})]},e))}),(0,d.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:f.t(`sheets-numfmt-ui.customFormatDes`)})]})}let Ze=e=>{let t=r.numfmt.getFormatInfo(e);return[`date`,`datetime`,`time`].includes(t.type)};function Qe(e){let{onActionChange:i,onChange:a,defaultPattern:o}=e,s=(0,n.useDependency)(r.LocaleService),c=(0,n.useObservable)(s.currentLocale$,s.getCurrentLocale()),[f,p]=(0,u.useState)(()=>o||(0,t.getDateFormatOptions)(c)[0].value),m=(0,u.useMemo)(()=>(0,t.getDateFormatOptions)(c,f),[c,f]);return(0,u.useLayoutEffect)(()=>{i(()=>f)},[i,f]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:s.t(`sheets-numfmt-ui.dateType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:f,options:m,onChange:e=>{typeof e==`string`&&(p(e),a(e))}})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:s.t(`sheets-numfmt-ui.dateDes`)})]})}let $e=e=>!e;function et(e){let t=(0,n.useDependency)(r.LocaleService),{onActionChange:i}=e;return(0,u.useLayoutEffect)(()=>{i(()=>``)},[i]),(0,d.jsx)(`div`,{children:(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:t.t(`sheets-numfmt-ui.generalDes`)})})}let tt=e=>(0,t.getNumberFormatOptions)().some(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e));function nt(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useMemo)(t.getNumberFormatOptions,[]),[c,f]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,0)),[p,m]=(0,u.useState)(()=>{let t=s.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern||``));return(t==null?void 0:t.value)||s[0].value}),h=(0,u.useMemo)(()=>(0,t.setPatternDecimal)(p,Number(c||0)),[p,c]),g=!(0,t.isPatternHasDecimal)(p);return(0,u.useLayoutEffect)(()=>{i(()=>h)},[i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.InputNumber,{disabled:g,value:c,max:20,min:0,onChange:e=>{f(e||0),a((0,t.setPatternDecimal)(p,Number(e||0)))}})}),(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:[` `,o.t(`sheets-numfmt-ui.negType`)]}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{onChange:e=>{e!==void 0&&(f((0,t.getDecimalFromPattern)(e,0)),m(e),a(e))},options:s,value:p})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:o.t(`sheets-numfmt-ui.thousandthPercentileDes`)})]})}let rt=`numfmtCurrency`,it=e=>{let t=(0,n.useDependency)(q),[i,a]=(0,u.useState)(r.currencySymbols);return(0,u.useEffect)(()=>{t.addHabit(`numfmtCurrency`,[]).then(()=>{t.getHabit(rt,[...r.currencySymbols]).then(t=>{a(t),e&&e(t)})})},[]),{userHabitCurrency:i,mark:e=>{t.markHabit(rt,e)}}},at=()=>{let e=(0,u.useRef)([]),[t,n]=(0,u.useState)({});return(0,u.useEffect)(()=>{e.current.forEach(e=>{e()}),e.current=[]},[t]),t=>{e.current.push(t),n({})}},X=[{label:`sheets-numfmt-ui.general`,component:et},{label:`sheets-numfmt-ui.accounting`,component:qe},{label:`sheets-numfmt-ui.currency`,component:Ye},{label:`sheets-numfmt-ui.date`,component:Qe},{label:`sheets-numfmt-ui.thousandthPercentile`,component:nt},{label:`sheets-numfmt-ui.customFormat`,component:Xe}];function ot(e){let{row:t,col:n,defaultPattern:r}=e.value;return(0,u.createElement)(st,{...e,key:`${t}_${n}_${r}`})}function st(e){var i;let{onChange:a}=e,{defaultValue:o,defaultPattern:s,row:c,col:f}=e.value,p=(0,n.useDependency)(r.LocaleService);(0,n.useObservable)(p.currentLocale$,p.getCurrentLocale());let m=(0,u.useRef)(()=>``),h=at(),[g,_]=(0,u.useState)(C),[v,y]=(0,u.useState)(()=>`${c}_${f}_${s}`),{mark:b,userHabitCurrency:x}=it(()=>y(`${c}_${f}_${s}_userCurrency`)),S=(i=X.find(e=>e.label===g))==null?void 0:i.component;function C(){return[$e,Ke,Je,Ze,tt].reduce((e,t,n)=>e||(t(s)?X[n].label:``),``)||`sheets-numfmt-ui.customFormat`}let w=X.map(e=>({label:p.t(e.label),value:e.label})),ee=e=>{_(e),h(()=>a({type:`change`,value:m.current()||``}))},te=(0,u.useCallback)(e=>{a({type:`change`,value:e})},[a]),ne=(0,u.useCallback)(e=>{m.current=e},[]),re=()=>{let e=m.current()||``,n=(0,t.getCurrencyType)(e);n&&b(n),a({type:`confirm`,value:e})},ie=()=>{a({type:`cancel`,value:``})},ae={onChange:te,onActionChange:ne,defaultValue:o,defaultPattern:s};return(0,d.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5`,l.scrollbarClassName),children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm univer-text-gray-400`,children:p.t(`sheets-numfmt-ui.numfmtType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.Select,{className:`univer-w-full`,value:g,options:w,onChange:ee})}),(0,d.jsx)(`div`,{children:S&&(0,d.jsx)(K.Provider,{value:x,children:(0,u.createElement)(S,{...ae,key:v})})})]}),(0,d.jsxs)(`div`,{className:`univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end univer-gap-2 rtl:univer-flex-row-reverse`,children:[(0,d.jsx)(l.Button,{onClick:ie,children:p.t(`sheets-numfmt-ui.cancel`)}),(0,d.jsx)(l.Button,{variant:`primary`,onClick:re,children:p.t(`sheets-numfmt-ui.confirm`)})]})]})}let Z=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddDigitsIcon:z,DollarIcon:V,DongIcon:H,EuroIcon:U,PercentIcon:W,ReduceDigitsIcon:Pe,RialIcon:Ie,RmbIcon:Re,RoubleIcon:Be,RupiahIcon:He,WonIcon:We,ZlotyIcon:G}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(`SHEET_NUMFMT_PANEL`,ot)),[[C,ee],[w,te]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};Z=y([v(0,(0,r.Inject)(n.ComponentManager)),v(1,(0,r.Inject)(n.IconManager))],Z);let Q=class extends r.Disposable{constructor(e){super(),this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(se)}};Q=y([v(0,n.IMenuManagerService)],Q);let $=class extends r.Plugin{constructor(e=O,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},O,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(D,o)}onStarting(){this._injector.add([Z]),this._injector.get(Z),(0,r.registerDependencies)(this._injector,[[b],[P],[q],[Q],[N]])}onRendered(){this._registerRenderModules(),(0,r.touchDependencies)(this._injector,[[b],[P],[Q],[N]])}_registerRenderModules(){[[M]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))})}};_($,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_($,`packageName`,T),_($,`version`,E),_($,`type`,r.UniverInstanceType.UNIVER_SHEET),$=y([(0,r.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,t.UniverSheetsNumfmtPlugin,o.UniverSheetsUIPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],$),e.SheetsNumfmtUIMenuSchema=se,Object.defineProperty(e,"UniverSheetsNumfmtMobileUIPlugin",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"UniverSheetsNumfmtUIPlugin",{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "description": "Number format menus, editors, and previews for Univer Sheets.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,18 +58,18 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/core": "1.0.2",
62
- "@univerjs/design": "1.0.2",
63
- "@univerjs/engine-formula": "1.0.2",
64
- "@univerjs/engine-render": "1.0.2",
61
+ "@univerjs/core": "1.0.4",
62
+ "@univerjs/design": "1.0.4",
63
+ "@univerjs/engine-formula": "1.0.4",
64
+ "@univerjs/engine-render": "1.0.4",
65
65
  "@univerjs/icons": "1.43.1",
66
- "@univerjs/sheets": "1.0.2",
67
- "@univerjs/sheets-numfmt": "1.0.2",
68
- "@univerjs/sheets-ui": "1.0.2",
69
- "@univerjs/ui": "1.0.2"
66
+ "@univerjs/sheets": "1.0.4",
67
+ "@univerjs/sheets-numfmt": "1.0.4",
68
+ "@univerjs/sheets-ui": "1.0.4",
69
+ "@univerjs/ui": "1.0.4"
70
70
  },
71
71
  "devDependencies": {
72
- "@univerjs-infra/shared": "1.0.2",
72
+ "@univerjs-infra/shared": "1.0.4",
73
73
  "postcss": "^8.5.28",
74
74
  "react": "18.3.1",
75
75
  "rxjs": "^7.8.2",