import{l as n,n as t,f as r}from"./i18n-B98kiI7M.js";import{getNumberFormat as i}from"./kd/i18nService.js";import{I as e,H as c}from"./intlFormat-DNT_1eg4.js";const o="currency",a="percent",s="symbol",u="name",m=/0+$/;function l(n){return parseInt(n,10)}function f(n,t){!function(n,t){const r=function(n){return n.split(";")[0].split(".")[1]||""}(n),i=r.replace(/[^0]/g,"").length,e=r.replace(/[^0#]/g,"").length,c=l(t.minimumFractionDigits),o=l(t.maximumFractionDigits);isFinite(t.minimumFractionDigits)||(t.minimumFractionDigits=Math.min(i,isNaN(o)?i:o)),(!isFinite(t.maximumFractionDigits)||o<c)&&(t.maximumFractionDigits=Math.max(e,isNaN(c)?e:c))}(n,t);const r=function(n){const{minimumFractionDigits:t,maximumFractionDigits:r}=n;return`.${"0".repeat(t)}${"#".repeat(r-t)}`}(t);return p(n,r)}function p(n,t){if(!t)return n;if(n.indexOf(";")>0){const[r,i]=n.split(";");return`${p(r,t)};${p(i,t)}`}if(n.indexOf(".")>0)return n.replace(/\.(0|#)*/,t);const r=Math.max(n.lastIndexOf("0"),n.lastIndexOf("#"))+1;return[n.slice(0,r),t,n.slice(r)].join("")}function g(t){const r=t.currencyDisplay||s;return r===s||r===u?function(t,r){const e={style:o,currency:t,minimumFractionDigits:0};return e.currencyDisplay=r,i(n,e).format(2).replace(/2/g,"")}(t.currency,r):t.currency}const{numberFormat:y,percentFormat:F,currencyFormat:D}=t,x=n=>{const t=(n=>n.style===o?D:n.style===a?F:y)(n);let i=f(t,n);return i=function(n,t){const{minimumIntegerDigits:r}=t,i=function(n){const t=n.match(/,[#0]*\./);return t?t[0].length-2:0}(n);return r?r<=i?n.replace(/,[#0]*\./,`,${"#".repeat(i-r)}${"0".repeat(r)}.`):n.replace(/[#0]*\./,`${"0".repeat(r-i)},${"0".repeat(i)}.`):n}(i,n),(n=>!n.currency||r===n.currency)(n)||(i=function(n,t,r){const i=String.fromCharCode(164);return r.currencyDisplay===u?n.replace(i,"")+t:n.replace(i,t)}(i,g(n),n)),i};function h(t){const o={currency:t.currency||r},a=Object.assign({},t,o);return{format:t=>{const r=c&&t&&function(n){const t=n.toString(),[r,i]=t.split(".");return r.length+(i?i.replace(m,"").length:0)>=15}(t),o=r?function(n){const t=x(n);return{format:n=>e(t).format(n)}}(a):i(n,a);return o.format(t)}}}export{h as n};
