@iqmo/browser
Version:
Browser Stlite
2 lines (1 loc) • 15 kB
JavaScript
function Bt(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function T(t,r){if((e=(t=r?t.toExponential(r-1):t.toExponential()).indexOf("e"))<0)return null;var e,i=t.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+t.slice(e+1)]}function lt(t){return t=T(Math.abs(t)),t?t[1]:NaN}function Gt(t,r){return function(e,i){for(var n=e.length,o=[],a=0,s=t[0],l=0;n>0&&s>0&&(l+s+1>i&&(s=Math.max(1,i-l)),o.push(e.substring(n-=s,n+s)),!((l+=s+1)>i));)s=t[a=(a+1)%t.length];return o.reverse().join(r)}}function Ut(t){return function(r){return r.replace(/[0-9]/g,function(e){return t[+e]})}}var Yt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function V(t){if(!(r=Yt.exec(t)))throw new Error("invalid format: "+t);var r;return new K({fill:r[1],align:r[2],sign:r[3],symbol:r[4],zero:r[5],width:r[6],comma:r[7],precision:r[8]&&r[8].slice(1),trim:r[9],type:r[10]})}V.prototype=K.prototype;function K(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}K.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 Zt(t){t:for(var r=t.length,e=1,i=-1,n;e<r;++e)switch(t[e]){case".":i=n=e;break;case"0":i===0&&(i=e),n=e;break;default:if(!+t[e])break t;i>0&&(i=0);break}return i>0?t.slice(0,i)+t.slice(n+1):t}var ht;function It(t,r){var e=T(t,r);if(!e)return t+"";var i=e[0],n=e[1],o=n-(ht=Math.max(-8,Math.min(8,Math.floor(n/3)))*3)+1,a=i.length;return o===a?i:o>a?i+new Array(o-a+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+T(t,Math.max(0,r+o-1))[0]}function ct(t,r){var e=T(t,r);if(!e)return t+"";var i=e[0],n=e[1];return n<0?"0."+new Array(-n).join("0")+i:i.length>n+1?i.slice(0,n+1)+"."+i.slice(n+1):i+new Array(n-i.length+2).join("0")}const ft={"%":(t,r)=>(t*100).toFixed(r),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Bt,e:(t,r)=>t.toExponential(r),f:(t,r)=>t.toFixed(r),g:(t,r)=>t.toPrecision(r),o:t=>Math.round(t).toString(8),p:(t,r)=>ct(t*100,r),r:ct,s:It,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function gt(t){return t}var dt=Array.prototype.map,pt=["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];function mt(t){var r=t.grouping===void 0||t.thousands===void 0?gt:Gt(dt.call(t.grouping,Number),t.thousands+""),e=t.currency===void 0?"":t.currency[0]+"",i=t.currency===void 0?"":t.currency[1]+"",n=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?gt:Ut(dt.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",s=t.minus===void 0?"\u2212":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function k(h){h=V(h);var R=h.fill,q=h.align,m=h.sign,H=h.symbol,M=h.zero,z=h.width,J=h.comma,w=h.precision,at=h.trim,f=h.type;f==="n"?(J=!0,f="g"):ft[f]||(w===void 0&&(w=12),at=!0,f="g"),(M||R==="0"&&q==="=")&&(M=!0,R="0",q="=");var Tt=H==="$"?e:H==="#"&&/[boxX]/.test(f)?"0"+f.toLowerCase():"",Vt=H==="$"?i:/[%p]/.test(f)?a:"",ot=ft[f],Xt=/[defgprs%]/.test(f);w=w===void 0?6:/[gprs]/.test(f)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function st(u){var v=Tt,g=Vt,N,ut,D;if(f==="c")g=ot(u)+g,u="";else{u=+u;var L=u<0||1/u<0;if(u=isNaN(u)?l:ot(Math.abs(u),w),at&&(u=Zt(u)),L&&+u==0&&m!=="+"&&(L=!1),v=(L?m==="("?m:s:m==="-"||m==="("?"":m)+v,g=(f==="s"?pt[8+ht/3]:"")+g+(L&&m==="("?")":""),Xt){for(N=-1,ut=u.length;++N<ut;)if(D=u.charCodeAt(N),48>D||D>57){g=(D===46?n+u.slice(N+1):u.slice(N))+g,u=u.slice(0,N);break}}}J&&!M&&(u=r(u,1/0));var F=v.length+u.length+g.length,b=F<z?new Array(z-F+1).join(R):"";switch(J&&M&&(u=r(b+u,b.length?z-g.length:1/0),b=""),q){case"<":u=v+u+g+b;break;case"=":u=v+b+u+g;break;case"^":u=b.slice(0,F=b.length>>1)+v+u+g+b.slice(F);break;default:u=b+v+u+g;break}return o(u)}return st.toString=function(){return h+""},st}function p(h,R){var q=k((h=V(h),h.type="f",h)),m=Math.max(-8,Math.min(8,Math.floor(lt(R)/3)))*3,H=Math.pow(10,-m),M=pt[8+m/3];return function(z){return q(H*z)+M}}return{format:k,formatPrefix:p}}var X,yt,bt;Jt({thousands:",",grouping:[3],currency:["$",""]});function Jt(t){return X=mt(t),yt=X.format,bt=X.formatPrefix,X}function B(t,r,e){t.prototype=r.prototype=e,e.constructor=t}function Q(t,r){var e=Object.create(t.prototype);for(var i in r)e[i]=r[i];return e}function A(){}var E=.7,C=1/E,S="\\s*([+-]?\\d+)\\s*",O="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",y="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Kt=/^#([0-9a-f]{3,8})$/,Qt=new RegExp(`^rgb\\(${S},${S},${S}\\)$`),Wt=new RegExp(`^rgb\\(${y},${y},${y}\\)$`),_t=new RegExp(`^rgba\\(${S},${S},${S},${O}\\)$`),tr=new RegExp(`^rgba\\(${y},${y},${y},${O}\\)$`),rr=new RegExp(`^hsl\\(${O},${y},${y}\\)$`),er=new RegExp(`^hsla\\(${O},${y},${y},${O}\\)$`),wt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};B(A,j,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:vt,formatHex:vt,formatHex8:ir,formatHsl:nr,formatRgb:xt,toString:xt});function vt(){return this.rgb().formatHex()}function ir(){return this.rgb().formatHex8()}function nr(){return Et(this).formatHsl()}function xt(){return this.rgb().formatRgb()}function j(t){var r,e;return t=(t+"").trim().toLowerCase(),(r=Kt.exec(t))?(e=r[1].length,r=parseInt(r[1],16),e===6?$t(r):e===3?new c(r>>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):e===8?G(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):e===4?G(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=Qt.exec(t))?new c(r[1],r[2],r[3],1):(r=Wt.exec(t))?new c(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=_t.exec(t))?G(r[1],r[2],r[3],r[4]):(r=tr.exec(t))?G(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=rr.exec(t))?At(r[1],r[2]/100,r[3]/100,1):(r=er.exec(t))?At(r[1],r[2]/100,r[3]/100,r[4]):wt.hasOwnProperty(t)?$t(wt[t]):t==="transparent"?new c(NaN,NaN,NaN,0):null}function $t(t){return new c(t>>16&255,t>>8&255,t&255,1)}function G(t,r,e,i){return i<=0&&(t=r=e=NaN),new c(t,r,e,i)}function kt(t){return t instanceof A||(t=j(t)),t?(t=t.rgb(),new c(t.r,t.g,t.b,t.opacity)):new c}function P(t,r,e,i){return arguments.length===1?kt(t):new c(t,r,e,i??1)}function c(t,r,e,i){this.r=+t,this.g=+r,this.b=+e,this.opacity=+i}B(c,P,Q(A,{brighter(t){return t=t==null?C:Math.pow(C,t),new c(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?E:Math.pow(E,t),new c(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new c(x(this.r),x(this.g),x(this.b),U(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Mt,formatHex:Mt,formatHex8:ar,formatRgb:Nt,toString:Nt}));function Mt(){return`#${$(this.r)}${$(this.g)}${$(this.b)}`}function ar(){return`#${$(this.r)}${$(this.g)}${$(this.b)}${$((isNaN(this.opacity)?1:this.opacity)*255)}`}function Nt(){const t=U(this.opacity);return`${t===1?"rgb(":"rgba("}${x(this.r)}, ${x(this.g)}, ${x(this.b)}${t===1?")":`, ${t})`}`}function U(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function x(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function $(t){return t=x(t),(t<16?"0":"")+t.toString(16)}function At(t,r,e,i){return i<=0?t=r=e=NaN:e<=0||e>=1?t=r=NaN:r<=0&&(t=NaN),new d(t,r,e,i)}function Et(t){if(t instanceof d)return new d(t.h,t.s,t.l,t.opacity);if(t instanceof A||(t=j(t)),!t)return new d;if(t instanceof d)return t;t=t.rgb();var r=t.r/255,e=t.g/255,i=t.b/255,n=Math.min(r,e,i),o=Math.max(r,e,i),a=NaN,s=o-n,l=(o+n)/2;return s?(r===o?a=(e-i)/s+(e<i)*6:e===o?a=(i-r)/s+2:a=(r-e)/s+4,s/=l<.5?o+n:2-o-n,a*=60):s=l>0&&l<1?0:a,new d(a,s,l,t.opacity)}function St(t,r,e,i){return arguments.length===1?Et(t):new d(t,r,e,i??1)}function d(t,r,e,i){this.h=+t,this.s=+r,this.l=+e,this.opacity=+i}B(d,St,Q(A,{brighter(t){return t=t==null?C:Math.pow(C,t),new d(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?E:Math.pow(E,t),new d(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,i=e+(e<.5?e:1-e)*r,n=2*e-i;return new c(W(t>=240?t-240:t+120,n,i),W(t,n,i),W(t<120?t+240:t-120,n,i),this.opacity)},clamp(){return new d(jt(this.h),Y(this.s),Y(this.l),U(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=U(this.opacity);return`${t===1?"hsl(":"hsla("}${jt(this.h)}, ${Y(this.s)*100}%, ${Y(this.l)*100}%${t===1?")":`, ${t})`}`}}));function jt(t){return t=(t||0)%360,t<0?t+360:t}function Y(t){return Math.max(0,Math.min(1,t||0))}function W(t,r,e){return(t<60?r+(e-r)*t/60:t<180?e:t<240?r+(e-r)*(240-t)/60:r)*255}function Rt(t,r,e,i,n){var o=t*t,a=o*t;return((1-3*t+3*o-a)*r+(4-6*o+3*a)*e+(1+3*t+3*o-3*a)*i+a*n)/6}function qt(t){var r=t.length-1;return function(e){var i=e<=0?e=0:e>=1?(e=1,r-1):Math.floor(e*r),n=t[i],o=t[i+1],a=i>0?t[i-1]:2*n-o,s=i<r-1?t[i+2]:2*o-n;return Rt((e-i/r)*r,a,n,o,s)}}function Ht(t){var r=t.length;return function(e){var i=Math.floor(((e%=1)<0?++e:e)*r),n=t[(i+r-1)%r],o=t[i%r],a=t[(i+1)%r],s=t[(i+2)%r];return Rt((e-i/r)*r,n,o,a,s)}}const Z=t=>()=>t;function zt(t,r){return function(e){return t+e*r}}function or(t,r,e){return t=Math.pow(t,e),r=Math.pow(r,e)-t,e=1/e,function(i){return Math.pow(t+i*r,e)}}function sr(t,r){var e=r-t;return e?zt(t,e>180||e<-180?e-360*Math.round(e/360):e):Z(isNaN(t)?r:t)}function ur(t){return(t=+t)==1?_:function(r,e){return e-r?or(r,e,t):Z(isNaN(r)?e:r)}}function _(t,r){var e=r-t;return e?zt(t,e):Z(isNaN(t)?r:t)}const tt=function t(r){var e=ur(r);function i(n,o){var a=e((n=P(n)).r,(o=P(o)).r),s=e(n.g,o.g),l=e(n.b,o.b),k=_(n.opacity,o.opacity);return function(p){return n.r=a(p),n.g=s(p),n.b=l(p),n.opacity=k(p),n+""}}return i.gamma=t,i}(1);function Ct(t){return function(r){var e=r.length,i=new Array(e),n=new Array(e),o=new Array(e),a,s;for(a=0;a<e;++a)s=P(r[a]),i[a]=s.r||0,n[a]=s.g||0,o[a]=s.b||0;return i=t(i),n=t(n),o=t(o),s.opacity=1,function(l){return s.r=i(l),s.g=n(l),s.b=o(l),s+""}}}var lr=Ct(qt),hr=Ct(Ht);function rt(t,r){r||(r=[]);var e=t?Math.min(r.length,t.length):0,i=r.slice(),n;return function(o){for(n=0;n<e;++n)i[n]=t[n]*(1-o)+r[n]*o;return i}}function Ot(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function cr(t,r){return(Ot(r)?rt:Pt)(t,r)}function Pt(t,r){var e=r?r.length:0,i=t?Math.min(e,t.length):0,n=new Array(i),o=new Array(e),a;for(a=0;a<i;++a)n[a]=nt(t[a],r[a]);for(;a<e;++a)o[a]=r[a];return function(s){for(a=0;a<i;++a)o[a]=n[a](s);return o}}function Dt(t,r){var e=new Date;return t=+t,r=+r,function(i){return e.setTime(t*(1-i)+r*i),e}}function I(t,r){return t=+t,r=+r,function(e){return t*(1-e)+r*e}}function Lt(t,r){var e={},i={},n;(t===null||typeof t!="object")&&(t={}),(r===null||typeof r!="object")&&(r={});for(n in r)n in t?e[n]=nt(t[n],r[n]):i[n]=r[n];return function(o){for(n in e)i[n]=e[n](o);return i}}var et=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,it=new RegExp(et.source,"g");function fr(t){return function(){return t}}function gr(t){return function(r){return t(r)+""}}function Ft(t,r){var e=et.lastIndex=it.lastIndex=0,i,n,o,a=-1,s=[],l=[];for(t=t+"",r=r+"";(i=et.exec(t))&&(n=it.exec(r));)(o=n.index)>e&&(o=r.slice(e,o),s[a]?s[a]+=o:s[++a]=o),(i=i[0])===(n=n[0])?s[a]?s[a]+=n:s[++a]=n:(s[++a]=null,l.push({i:a,x:I(i,n)})),e=it.lastIndex;return e<r.length&&(o=r.slice(e),s[a]?s[a]+=o:s[++a]=o),s.length<2?l[0]?gr(l[0].x):fr(r):(r=l.length,function(k){for(var p=0,h;p<r;++p)s[(h=l[p]).i]=h.x(k);return s.join("")})}function nt(t,r){var e=typeof r,i;return r==null||e==="boolean"?Z(r):(e==="number"?I:e==="string"?(i=j(r))?(r=i,tt):Ft:r instanceof j?tt:r instanceof Date?Dt:Ot(r)?rt:Array.isArray(r)?Pt:typeof r.valueOf!="function"&&typeof r.toString!="function"||isNaN(r)?Lt:I)(t,r)}export{j as A,A as C,c as R,V as a,yt as b,bt as c,B as d,Q as e,mt as f,E as g,C as h,sr as i,St as j,nt as k,cr as l,qt as m,_ as n,Ht as o,Dt as p,I as q,kt as r,rt as s,Lt as t,tt as u,lr as v,hr as w,Ft as x,P as y,lt as z};