"use strict";var t=require("../i18n-CP31jeWH.js"),e=require("../intlFormat-Bs-dlvDH.js"),r=require("../NumberFormat-BOQwROTf.js");require("../observable-BXDJFaLN.js");var i=require("../normalize-DKPi18vK.js");require("./features.js");var n=require("../utils-HAAanx64.js");require("./i18nCldrOptions.js"),require("../ssr-RXknEJpO.js"),require("./iso8601Utils.js"),require("./i18nService.js"),require("./configProvider.js"),require("../empty_html-hFq4zm9t.js"),require("@kdcloudjs/kwc"),require("../classSet-B5xuJbNb.js"),require("../labelUtils-C2UzbgdZ.js"),require("../label-DdXuOVTE.js"),require("./utilsPrivate.js"),require("../client-Co_j5m_k.js"),require("../colorValid-BBnkvgd_.js");const{groupingSeparator:s,decimalSeparator:o}=t.number,u=new RegExp("^[-+0-9kKmMbBtTeE.,٠-٩۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯෦-෯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꧰-꧹꩐-꩙꯰-꯹]$"),a={k:3,m:6,b:9,t:12},l=["k","m","b","t"],c=["+","-"];function p(t,r){if(null==t||0===t.length)return"";const i=r?r.decimalSeparator:o,n=r?r.groupSeparator:s;let u=t.split(n).join("");return"."!==i&&(u=u.replace(i,".")),m(function(t){const e=t.indexOf(".");if(0===e||1===e){const r=t.charAt(0);"+"!==r&&"-"!==r&&"."!==r||(t=`${t.substring(0,e)}0${t.substring(e)}`)}return t}(e.fromLocalizedDigits(u)))}function f(t){const e=t.toLowerCase().trim(),r=l.join(""),i=new RegExp(`([${r}])`,"g"),n=e.match(i);if(n&&n.length>1)return!1;const s=new RegExp(`[${r}]$`);return null!==e.match(s)&&e.length>1}function m(t){if(!f(t))return t;let e=t.toLowerCase().trim();const r=e.charAt(e.length-1);if(e=e.substring(0,e.length-1),isNaN(e))return t;const i=e.split(".");let n=0;i.length>1&&(n=i[1].length);const s=a[r],o=Math.max(0,n-s);return parseFloat(e*Math.pow(10,s)).toFixed(o)}function g(t){return/^\d$/.test(t)||"."===t||"-"===t}function d(t){return/^0\d+/.test(t)&&!t.startsWith("0.")||/^-0\d+/.test(t)&&!t.startsWith("-0.")}exports.calculateFractionDigitsFromStep=function(t){let e;if(t){const r=String(t).toLowerCase();if("any"!==r){let t=0;if(r.indexOf(".")>=0&&r.indexOf("e")<0){const e=r.split(".")[1];parseInt(e,10)>0&&(t=e.length)}else if(r.indexOf("e-")>0){const e=r.split("e-"),i=e[0].split(".")[1],n=e[1],s=i?i.length:0;t=parseInt(n,10)+s}e=t}}return e},exports.cleanValue=function(t,e){const r=t.replace(/。/,".");let i=t.split("").filter(t=>g(t)).join("");if(i.includes("-")){const t=i.indexOf("-");i=0===t?`-${i.substring(1).replace(/-/g,"")}`:i.replace(/-/g,"")}if(0===e)i=i.replace(/\./g,"");else if(i.includes(".")){const t=i.indexOf(".");i=i.substring(0,t+1)+i.substring(t+1).replace(/\./g,"")}for(i.startsWith(".")&&(i=i.substring(1)),i.startsWith("-.")&&i.length>2&&(i=`-${i.substring(2)}`);d(i);)i.startsWith("0")?i=i.substring(1):i.startsWith("-0")&&(i=`-${i.substring(2)}`);if(""===i&&r.includes("-")&&1===r.length&&(i="-"),""===i&&"0"===r&&(i="0"),i.includes(".")&&e>0){const t=i.split(".");i=`${t[0]}.${(t[1]||"").substring(0,e)}`}return i},exports.expandShortcuts=m,exports.formatNumber=function(t,e){if(n.isEmptyString(t))return"";let i=t,s=t;const o=e.style,u={style:o};if(u.minimumFractionDigits=e.minimumFractionDigits,u.maximumFractionDigits=e.maximumFractionDigits,"percent-fixed"===o){u.style="percent";const t=s.toString(),e=parseFloat(s)/100;s=t.indexOf(".")>0&&t.indexOf("e")<0?e.toFixed(t.split(".")[1].length+2):e}try{i=r.numberFormat(u).format(s)||""}catch(t){}return i},exports.fromIsoDecimal=function(t){return e.toLocalizedDigits(t.replace(".",o))},exports.getDecimalPlaces=function(t){const e=`${t}`.match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return e?Math.max(0,(e[1]?e[1].length:0)-(e[2]?Number(e[2]):0)):0},exports.hasValidNumberShortcut=f,exports.hasValidNumberSymbol=function(t){const e=c.join(""),r=new RegExp(`[${e}]`);return!!t.match(r)},exports.increaseNumberByStep=function({value:t,increment:e,step:r,fractionDigits:i}){const n=""===t||null==t?"0":t,s=parseFloat(r);let o;if(isNaN(s))o=parseFloat(n)+e;else{const t=e*s;o=parseFloat(n)+t}return o.toFixed(i)},exports.isAllowedChar=g,exports.isControlKey=function(t){return["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Escape","Enter","Home","End"].includes(t)},exports.isValidInput=function(t,e,r,i,n){const s=t.substring(0,r)+e+t.substring(i);if("-"===e&&((s.match(/-/g)||[]).length>1||0!==r))return!1;if("."===e){if(0===n)return!1;if((s.match(/\./g)||[]).length>1)return!1;if("."===s||"-."===s)return!1}if(s.includes(".")&&n>0){if((s.split(".")[1]||"").length>n)return!1}return!d(s)},exports.isValidNumber=function(t){return!isNaN(p(t))},exports.isValidNumberCharacter=function(t){return u.test(t)},exports.stringifyNumber=function(t){const e="string"==typeof t?Number(t):t;return void 0===i.normalizeNumber(e)?"":String(t)},exports.toIsoDecimal=function(t){const e=p(t);return isNaN(e)?"":e},exports.transformLocalizedNumberToIsoDecimal=p;
