// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["exports","./dom","./key","./observers"],function(h,r,w,t){function n(a){return!(!a||isNaN(Number(a)))}function p(a,b){if(!a)return a;const c=a.toLowerCase().indexOf("e")+1;return c?a.replace(/[eE]*$/g,"").substring(0,c).concat(a.slice(c).replace(/[eE]/g,"")).split(/[eE]/).map((d,f)=>1===f?b(d.replace(/\./g,"")):b(d)).join("e").replace(/^e/,"1e"):b(a)}function E(a){var b=a.split(/[eE]/);if(1===b.length)return a;var c=+a;if(Number.isSafeInteger(c))return`${c}`;a="-"===a.charAt(0);c=+b[1];var d= b[0].split(".");b=(a?d[0].substring(1):d[0])||"";d=d[1]||"";const f=(g,k)=>{const x=Math.abs(k)-g.length;g=0{g=k>g.length?`${g}${"0".repeat(k-g.length)}`:g;return`${g.slice(0,k)}${"."}${g.slice(k)}`};c=0a.includes(b))}function u(a,b="cldr"){const c="cldr"===b?H:I; if(!a)return"en";if(c.includes(a))return a;a=a.toLowerCase();if("nb"===a)return"no";if("t9n"===b&&"pt"===a)return"pt-BR";a.includes("-")&&(a=a.replace(/(\w+)-(\w+)/,(d,f,l)=>`${f}-${l.toUpperCase()}`),c.includes(a)||(a=a.split("-")[0]));return"zh"===a?"zh-CN":c.includes(a)?a:(console.warn(`Translations for the "${a}" locale are not available and will fall back to the default, English (en).`),"en")}function J(a={}){return Object.entries(a).sort(([b],[c])=>b.localeCompare(c)).map(b=>`${b[0]}-${b[1]}`).flat().join(":")} const F=RegExp("\\.(0+)?$"),K=RegExp("0+$");class e{constructor(a){if(a instanceof e)return a;const [b,c]=E(a).split(".").concat("");this.value=BigInt(b+c.padEnd(e.DECIMALS,"0").slice(0,e.DECIMALS))+BigInt(e.ROUNDED&&"5"<=c[e.DECIMALS]);this.isNegative="-"===a.charAt(0)}getIntegersAndDecimals(){var a=this.value.toString().replace("-","").padStart(e.DECIMALS+1,"0");const b=a.slice(0,-e.DECIMALS);a=a.slice(-e.DECIMALS).replace(K,"");return{integers:b,decimals:a}}toString(){const {integers:a,decimals:b}= this.getIntegersAndDecimals();return`${this.isNegative?"-":""}${a}${b.length?"."+b:""}`}formatToParts(a){const {integers:b,decimals:c}=this.getIntegersAndDecimals(),d=a.numberFormatter.formatToParts(BigInt(b));this.isNegative&&d.unshift({type:"minusSign",value:a.minusSign});c.length&&(d.push({type:"decimal",value:a.decimal}),c.split("").forEach(f=>d.push({type:"fraction",value:f})));return d}format(a){const {integers:b,decimals:c}=this.getIntegersAndDecimals(),d=`${this.isNegative?a.minusSign:""}${a.numberFormatter.format(BigInt(b))}`, f=c.length?`${a.decimal}${c.split("").map(l=>a.numberFormatter.format(Number(l))).join("")}`:"";return`${d}${f}`}add(a){return e.fromBigInt(this.value+(new e(a)).value)}subtract(a){return e.fromBigInt(this.value-(new e(a)).value)}multiply(a){return e._divRound(this.value*(new e(a)).value,e.SHIFT)}divide(a){return e._divRound(this.value*e.SHIFT,(new e(a)).value)}}e.DECIMALS=100;e.ROUNDED=!0;e.SHIFT=BigInt("1"+"0".repeat(e.DECIMALS));e._divRound=(a,b)=>e.fromBigInt(a/b+(e.ROUNDED?a*BigInt(2)/b%BigInt(2): BigInt(0)));e.fromBigInt=a=>Object.assign(Object.create(e.prototype),{value:a,isNegative:az.includes(a)?a:A,m=new Set,C=t.createObserver("mutation",a=>{a.forEach(b=>{const c=b.target;m.forEach(d=>{if(r.containsCrossShadowBoundary(c,d.el)){var f=r.closestElementCrossShadowBoundary(d.el,"[lang]");if(f){var l=f.lang;d.effectiveLocale=f.hasAttribute("lang")&&""===l?"en":l}else d.effectiveLocale="en"}})})});class P{constructor(){this.delocalize=a=>this._numberFormatOptions? p(a,b=>b.replace(new RegExp(`[${this._minusSign}]`,"g"),"-").replace(new RegExp(`[${this._group}]`,"g"),"").replace(new RegExp(`[${this._decimal}]`,"g"),".").replace(new RegExp(`[${this._digits.join("")}]`,"g"),this._getDigitIndex)):a;this.localize=a=>this._numberFormatOptions?p(a,b=>n(b.trim())?(new e(b.trim())).format(this).replace(new RegExp(`[${this._actualGroup}]`,"g"),this._group):b):a}get group(){return this._group}get decimal(){return this._decimal}get minusSign(){return this._minusSign}get digits(){return this._digits}get numberFormatter(){return this._numberFormatter}get numberFormatOptions(){return this._numberFormatOptions}set numberFormatOptions(a){a.locale= u(a?.locale);a.numberingSystem=B(a?.numberingSystem);if((this._numberFormatOptions||"en"!==a.locale||a.numberingSystem!==A||2!==Object.keys(a).length)&&JSON.stringify(this._numberFormatOptions)!==JSON.stringify(a)){this._numberFormatOptions=a;this._numberFormatter=new Intl.NumberFormat(this._numberFormatOptions.locale,this._numberFormatOptions);this._digits=[...(new Intl.NumberFormat(this._numberFormatOptions.locale,{useGrouping:!1,numberingSystem:this._numberFormatOptions.numberingSystem})).format(9876543210)].reverse(); var b=new Map(this._digits.map((c,d)=>[c,d]));a=(new Intl.NumberFormat(this._numberFormatOptions.locale,{numberingSystem:this._numberFormatOptions.numberingSystem})).formatToParts(-1.23456789E7);this._actualGroup=a.find(c=>"group"===c.type).value;this._group=0===this._actualGroup.trim().length||" "==this._actualGroup?"\u00a0":this._actualGroup;this._decimal=a.find(c=>"decimal"===c.type).value;this._minusSign=a.find(c=>"minusSign"===c.type).value;this._getDigitIndex=c=>b.get(c)}}}t=new P;let q,D;h.BigDecimal= e;h.addLocalizedTrailingDecimalZeros=function(a,b,c){const d=b.split(".")[1];if(d){const f=d.match(O)[0];if(f&&c.delocalize(a).length!==b.length&&-1===d.indexOf("e"))return b=c.decimal,a=a.includes(b)?a:`${a}${b}`,a.padEnd(a.length+f.length,c.localize("0"))}return a};h.connectLocalized=function(a){a.effectiveLocale=a.el.lang||r.closestElementCrossShadowBoundary(a.el,"[lang]")?.lang||document.documentElement.lang||"en";0===m.size&&C?.observe(document.documentElement,{attributes:!0,attributeFilter:["lang"], subtree:!0});m.add(a)};h.disconnectLocalized=function(a){m.delete(a);0===m.size&&C.disconnect()};h.getDateTimeFormat=function(a,b){a=u(a);q||=new Map;D!==a&&(q.clear(),D=a);const c=J(b),d=q.get(c);if(d)return d;a=new Intl.DateTimeFormat(a,b);q.set(c,a);return a};h.getSupportedLocale=u;h.getSupportedNumberingSystem=B;h.isValidNumber=n;h.numberStringFormatter=t;h.parseNumberString=function(a){return a&&G(a)?p(a,b=>{let c=!1;b=b.split("").filter((d,f)=>d.match(/\./g)&&!c?c=!0:d.match(/\-/g)&&0===f?!0: w.numberKeys.includes(d)).join("");return n(b)?(new e(b)).toString():""}):""};h.sanitizeNumberString=a=>p(a,b=>{var c=b.replace(M,"").replace(L,"").replace(y,"$1");if(n(c)){if(!N.test(c)){b=c.split(".")[1];c=(new e(c)).toString();const [d,f]=c.split(".");c=b&&f!==b?`${d}.${b}`:c}}else c=b;return c})});