function K(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function N(n,t){if(!isFinite(n)||n===0)return null;var e=(n=t?n.toExponential(t-1):n.toExponential()).indexOf("e"),i=n.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+n.slice(e+1)]}function l(n){return n=N(Math.abs(n)),n?n[1]:NaN}function Q(n,t){return function(e,i){for(var a=e.length,f=[],c=0,h=n[0],p=0;a>0&&h>0&&(p+h+1>i&&(h=Math.max(1,i-p)),f.push(e.substring(a-=h,a+h)),!((p+=h+1)>i));)h=n[c=(c+1)%n.length];return f.reverse().join(t)}}function V(n){return function(t){return t.replace(/[0-9]/g,function(e){return n[+e]})}}var W=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function L(n){if(!(t=W.exec(n)))throw new Error("invalid format: "+n);var t;return new T({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}L.prototype=T.prototype;function T(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}T.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function _(n){n:for(var t=n.length,e=1,i=-1,a;e<t;++e)switch(n[e]){case".":i=a=e;break;case"0":i===0&&(i=e),a=e;break;default:if(!+n[e])break n;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(a+1):n}var E;function v(n,t){var e=N(n,t);if(!e)return E=void 0,n.toPrecision(t);var i=e[0],a=e[1],f=a-(E=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,c=i.length;return f===c?i:f>c?i+new Array(f-c+1).join("0"):f>0?i.slice(0,f)+"."+i.slice(f):"0."+new Array(1-f).join("0")+N(n,Math.max(0,t+f-1))[0]}function X(n,t){var e=N(n,t);if(!e)return n+"";var i=e[0],a=e[1];return a<0?"0."+new Array(-a).join("0")+i:i.length>a+1?i.slice(0,a+1)+"."+i.slice(a+1):i+new Array(a-i.length+2).join("0")}const O={"%":(n,t)=>(n*100).toFixed(t),b:n=>Math.round(n).toString(2),c:n=>n+"",d:K,e:(n,t)=>n.toExponential(t),f:(n,t)=>n.toFixed(t),g:(n,t)=>n.toPrecision(t),o:n=>Math.round(n).toString(8),p:(n,t)=>X(n*100,t),r:X,s:v,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function U(n){return n}var Y=Array.prototype.map,Z=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nn(n){var t=n.grouping===void 0||n.thousands===void 0?U:Q(Y.call(n.grouping,Number),n.thousands+""),e=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",a=n.decimal===void 0?".":n.decimal+"",f=n.numerals===void 0?U:V(Y.call(n.numerals,String)),c=n.percent===void 0?"%":n.percent+"",h=n.minus===void 0?"−":n.minus+"",p=n.nan===void 0?"NaN":n.nan+"";function C(o,g){o=L(o);var b=o.fill,w=o.align,m=o.sign,S=o.symbol,k=o.zero,F=o.width,$=o.comma,y=o.precision,D=o.trim,d=o.type;d==="n"?($=!0,d="g"):O[d]||(y===void 0&&(y=12),D=!0,d="g"),(k||b==="0"&&w==="=")&&(k=!0,b="0",w="=");var B=(g&&g.prefix!==void 0?g.prefix:"")+(S==="$"?e:S==="#"&&/[boxX]/.test(d)?"0"+d.toLowerCase():""),H=(S==="$"?i:/[%p]/.test(d)?c:"")+(g&&g.suffix!==void 0?g.suffix:""),G=O[d],J=/[defgprs%]/.test(d);y=y===void 0?6:/[gprs]/.test(d)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y));function I(r){var M=B,u=H,x,R,P;if(d==="c")u=G(r)+u,r="";else{r=+r;var z=r<0||1/r<0;if(r=isNaN(r)?p:G(Math.abs(r),y),D&&(r=_(r)),z&&+r==0&&m!=="+"&&(z=!1),M=(z?m==="("?m:h:m==="-"||m==="("?"":m)+M,u=(d==="s"&&!isNaN(r)&&E!==void 0?Z[8+E/3]:"")+u+(z&&m==="("?")":""),J){for(x=-1,R=r.length;++x<R;)if(P=r.charCodeAt(x),48>P||P>57){u=(P===46?a+r.slice(x+1):r.slice(x))+u,r=r.slice(0,x);break}}}$&&!k&&(r=t(r,1/0));var A=M.length+r.length+u.length,s=A<F?new Array(F-A+1).join(b):"";switch($&&k&&(r=t(s+r,s.length?F-u.length:1/0),s=""),w){case"<":r=M+r+u+s;break;case"=":r=M+s+r+u;break;case"^":r=s.slice(0,A=s.length>>1)+M+r+u+s.slice(A);break;default:r=s+M+r+u;break}return f(r)}return I.toString=function(){return o+""},I}function q(o,g){var b=Math.max(-8,Math.min(8,Math.floor(l(g)/3)))*3,w=Math.pow(10,-b),m=C((o=L(o),o.type="f",o),{suffix:Z[8+b/3]});return function(S){return m(w*S)}}return{format:C,formatPrefix:q}}var j,tn,rn;en({thousands:",",grouping:[3],currency:["$",""]});function en(n){return j=nn(n),tn=j.format,rn=j.formatPrefix,j}function an(n){return Math.max(0,-l(Math.abs(n)))}function on(n,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(l(t)/3)))*3-l(Math.abs(n)))}function fn(n,t){return n=Math.abs(n),t=Math.abs(t)-n,Math.max(0,l(t)-l(n))+1}export{fn as a,on as b,rn as c,tn as d,L as f,an as p};
