@likec4/mcp 1.47.0 → 1.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +1 -1
  2. package/dist/_chunks/libs/@chevrotain/gast.mjs +1 -0
  3. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -0
  4. package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -0
  5. package/dist/_chunks/libs/@hono/node-server.mjs +1 -0
  6. package/dist/_chunks/libs/@logtape/logtape.mjs +6 -0
  7. package/dist/_chunks/libs/@lume/kiwi.mjs +1 -0
  8. package/dist/_chunks/libs/@mantine/colors-generator.mjs +15 -0
  9. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +41 -0
  10. package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -0
  11. package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -0
  12. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -0
  13. package/dist/_chunks/libs/bail.mjs +1 -0
  14. package/dist/_chunks/libs/ccount.mjs +1 -0
  15. package/dist/_chunks/libs/character-entities-html4.mjs +1 -0
  16. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -0
  17. package/dist/_chunks/libs/character-entities.mjs +2 -0
  18. package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -0
  19. package/dist/_chunks/libs/chevrotain.mjs +58 -0
  20. package/dist/_chunks/libs/chokidar.mjs +3 -0
  21. package/dist/_chunks/libs/citty.mjs +5 -0
  22. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -0
  23. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -0
  24. package/dist/_chunks/libs/defu.mjs +1 -0
  25. package/dist/_chunks/libs/devlop.mjs +1 -0
  26. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -0
  27. package/dist/_chunks/libs/eventemitter3.mjs +1 -0
  28. package/dist/_chunks/libs/extend.mjs +1 -0
  29. package/dist/_chunks/libs/fast-equals.mjs +1 -0
  30. package/dist/_chunks/libs/fdir.mjs +1 -0
  31. package/dist/_chunks/libs/graphology-dag.mjs +1 -0
  32. package/dist/_chunks/libs/graphology.mjs +1 -0
  33. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -0
  34. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -0
  35. package/dist/_chunks/libs/hono.mjs +1 -0
  36. package/dist/_chunks/libs/immer.mjs +1 -0
  37. package/dist/_chunks/libs/is-error-instance.mjs +1 -0
  38. package/dist/_chunks/libs/is-plain-obj.mjs +1 -0
  39. package/dist/_chunks/libs/json5.mjs +14 -0
  40. package/dist/_chunks/libs/khroma.mjs +1 -0
  41. package/dist/_chunks/libs/langium.mjs +29 -0
  42. package/dist/_chunks/libs/longest-streak.mjs +1 -0
  43. package/dist/_chunks/libs/markdown-table.mjs +2 -0
  44. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -0
  45. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -0
  46. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -0
  47. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -0
  48. package/dist/_chunks/libs/merge-error-cause.mjs +2 -0
  49. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -0
  50. package/dist/_chunks/libs/mnemonist.mjs +1 -0
  51. package/dist/_chunks/libs/nanoid.mjs +1 -0
  52. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -0
  53. package/dist/_chunks/libs/ohash.mjs +1 -0
  54. package/dist/_chunks/libs/p-limit.mjs +1 -0
  55. package/dist/_chunks/libs/p-queue.mjs +1 -0
  56. package/dist/_chunks/libs/parse-ms.mjs +1 -0
  57. package/dist/_chunks/libs/pretty-ms.mjs +1 -0
  58. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -0
  59. package/dist/_chunks/libs/rehype-stringify.mjs +1 -0
  60. package/dist/_chunks/libs/remark-gfm.mjs +1 -0
  61. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -0
  62. package/dist/_chunks/libs/remark-parse.mjs +1 -0
  63. package/dist/_chunks/libs/remark-rehype.mjs +1 -0
  64. package/dist/_chunks/libs/remeda.mjs +1 -0
  65. package/dist/_chunks/libs/safe-stringify.mjs +1 -0
  66. package/dist/_chunks/libs/strip-indent.mjs +1 -0
  67. package/dist/_chunks/libs/trough.mjs +1 -0
  68. package/dist/_chunks/libs/ts-graphviz.mjs +4 -0
  69. package/dist/_chunks/libs/ufo.mjs +1 -0
  70. package/dist/_chunks/libs/unified.mjs +1 -0
  71. package/dist/_chunks/libs/word-wrap.mjs +12 -0
  72. package/dist/_chunks/rolldown-runtime.mjs +1 -0
  73. package/dist/index.mjs +179 -543
  74. package/package.json +23 -18
  75. package/.turbo/turbo-build.log +0 -1350
  76. package/CHANGELOG.md +0 -13
  77. package/build.config.ts +0 -22
  78. package/src/empty.ts +0 -2
  79. package/src/index.ts +0 -99
  80. package/tsconfig.json +0 -24
  81. package/turbo.json +0 -18
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023-2025 Denis Davydkov
3
+ Copyright (c) 2023-2026 Denis Davydkov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1 @@
1
+ var e=typeof global==`object`&&global&&global.Object===Object&&global,t=typeof self==`object`&&self&&self.Object===Object&&self,n=e||t||Function(`return this`)(),r=n.Symbol,i=Object.prototype,a=i.hasOwnProperty,o=i.toString,s=r?r.toStringTag:void 0;function c(e){var t=a.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch{}var i=o.call(e);return r&&(t?e[s]=n:delete e[s]),i}var l=c,u=Object.prototype.toString;function d(e){return u.call(e)}var f=d,p=`[object Null]`,m=`[object Undefined]`,h=r?r.toStringTag:void 0;function g(e){return e==null?e===void 0?m:p:h&&h in Object(e)?l(e):f(e)}var _=g;function v(e){return typeof e==`object`&&!!e}var y=v,ee=`[object Symbol]`;function te(e){return typeof e==`symbol`||y(e)&&_(e)==ee}var b=te;function ne(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var x=ne,S=Array.isArray,re=1/0,ie=r?r.prototype:void 0,ae=ie?ie.toString:void 0;function oe(e){if(typeof e==`string`)return e;if(S(e))return x(e,oe)+``;if(b(e))return ae?ae.call(e):``;var t=e+``;return t==`0`&&1/e==-re?`-0`:t}var se=oe,ce=/\s/;function le(e){for(var t=e.length;t--&&ce.test(e.charAt(t)););return t}var ue=le,de=/^\s+/;function fe(e){return e&&e.slice(0,ue(e)+1).replace(de,``)}var pe=fe;function me(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var C=me,he=NaN,ge=/^[-+]0x[0-9a-f]+$/i,_e=/^0b[01]+$/i,ve=/^0o[0-7]+$/i,ye=parseInt;function be(e){if(typeof e==`number`)return e;if(b(e))return he;if(C(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=C(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=pe(e);var n=_e.test(e);return n||ve.test(e)?ye(e.slice(2),n?2:8):ge.test(e)?he:+e}var xe=be,Se=1/0,Ce=17976931348623157e292;function we(e){return e?(e=xe(e),e===Se||e===-Se?(e<0?-1:1)*Ce:e===e?e:0):e===0?e:0}var Te=we;function Ee(e){var t=Te(e),n=t%1;return t===t?n?t-n:t:0}var De=Ee;function Oe(e){return e}var w=Oe,ke=`[object AsyncFunction]`,Ae=`[object Function]`,je=`[object GeneratorFunction]`,Me=`[object Proxy]`;function Ne(e){if(!C(e))return!1;var t=_(e);return t==Ae||t==je||t==ke||t==Me}var Pe=Ne,Fe=n[`__core-js_shared__`],Ie=function(){var e=/[^.]+$/.exec(Fe&&Fe.keys&&Fe.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Le(e){return!!Ie&&Ie in e}var Re=Le,ze=Function.prototype.toString;function Be(e){if(e!=null){try{return ze.call(e)}catch{}try{return e+``}catch{}}return``}var T=Be,Ve=/[\\^$.*+?()[\]{}|]/g,He=/^\[object .+?Constructor\]$/,Ue=Function.prototype,We=Object.prototype,Ge=Ue.toString,Ke=We.hasOwnProperty,qe=RegExp(`^`+Ge.call(Ke).replace(Ve,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Je(e){return!C(e)||Re(e)?!1:(Pe(e)?qe:He).test(T(e))}var Ye=Je;function Xe(e,t){return e?.[t]}var Ze=Xe;function Qe(e,t){var n=Ze(e,t);return Ye(n)?n:void 0}var E=Qe,$e=E(n,`WeakMap`);function et(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var tt=et,nt=800,rt=16,it=Date.now;function at(e){var t=0,n=0;return function(){var r=it(),i=rt-(r-n);if(n=r,i>0){if(++t>=nt)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var ot=at;function st(e){return function(){return e}}var ct=st,lt=function(){try{var e=E(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),ut=ot(lt?function(e,t){return lt(e,`toString`,{configurable:!0,enumerable:!1,value:ct(t),writable:!0})}:w);function dt(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var ft=dt;function pt(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}var mt=pt;function ht(e){return e!==e}var gt=ht;function _t(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}var vt=_t;function yt(e,t,n){return t===t?vt(e,t,n):mt(e,gt,n)}var bt=yt,xt=9007199254740991,St=/^(?:0|[1-9]\d*)$/;function Ct(e,t){var n=typeof e;return t??=xt,!!t&&(n==`number`||n!=`symbol`&&St.test(e))&&e>-1&&e%1==0&&e<t}var wt=Ct;function Tt(e,t,n){t==`__proto__`&&lt?lt(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var Et=Tt;function Dt(e,t){return e===t||e!==e&&t!==t}var D=Dt,Ot=Object.prototype.hasOwnProperty;function kt(e,t,n){var r=e[t];(!(Ot.call(e,t)&&D(r,n))||n===void 0&&!(t in e))&&Et(e,t,n)}var At=kt;function jt(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?Et(n,s,c):At(n,s,c)}return n}var Mt=jt,Nt=Math.max;function Pt(e,t,n){return t=Nt(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=Nt(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),tt(e,this,s)}}var Ft=Pt;function It(e,t){return ut(Ft(e,t,w),e+``)}var Lt=It,Rt=9007199254740991;function zt(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Rt}var Bt=zt;function Vt(e){return e!=null&&Bt(e.length)&&!Pe(e)}var O=Vt;function Ht(e,t,n){if(!C(n))return!1;var r=typeof t;return(r==`number`?O(n)&&wt(t,n.length):r==`string`&&t in n)?D(n[t],e):!1}var Ut=Ht;function Wt(e){return Lt(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&Ut(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var Gt=Wt,Kt=Object.prototype;function qt(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Kt)}var Jt=qt;function Yt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Xt=Yt,Zt=`[object Arguments]`;function Qt(e){return y(e)&&_(e)==Zt}var $t=Qt,en=Object.prototype,tn=en.hasOwnProperty,nn=en.propertyIsEnumerable,rn=$t(function(){return arguments}())?$t:function(e){return y(e)&&tn.call(e,`callee`)&&!nn.call(e,`callee`)};function an(){return!1}var on=an,sn=typeof exports==`object`&&exports&&!exports.nodeType&&exports,cn=sn&&typeof module==`object`&&module&&!module.nodeType&&module,ln=cn&&cn.exports===sn?n.Buffer:void 0,un=(ln?ln.isBuffer:void 0)||on,dn=`[object Arguments]`,fn=`[object Array]`,pn=`[object Boolean]`,mn=`[object Date]`,hn=`[object Error]`,gn=`[object Function]`,_n=`[object Map]`,vn=`[object Number]`,yn=`[object Object]`,bn=`[object RegExp]`,xn=`[object Set]`,Sn=`[object String]`,Cn=`[object WeakMap]`,wn=`[object ArrayBuffer]`,Tn=`[object DataView]`,En=`[object Float32Array]`,Dn=`[object Float64Array]`,On=`[object Int8Array]`,kn=`[object Int16Array]`,An=`[object Int32Array]`,jn=`[object Uint8Array]`,Mn=`[object Uint8ClampedArray]`,Nn=`[object Uint16Array]`,Pn=`[object Uint32Array]`,k={};k[En]=k[Dn]=k[On]=k[kn]=k[An]=k[jn]=k[Mn]=k[Nn]=k[Pn]=!0,k[dn]=k[fn]=k[wn]=k[pn]=k[Tn]=k[mn]=k[hn]=k[gn]=k[_n]=k[vn]=k[yn]=k[bn]=k[xn]=k[Sn]=k[Cn]=!1;function Fn(e){return y(e)&&Bt(e.length)&&!!k[_(e)]}var In=Fn;function Ln(e){return function(t){return e(t)}}var Rn=Ln,zn=typeof exports==`object`&&exports&&!exports.nodeType&&exports,A=zn&&typeof module==`object`&&module&&!module.nodeType&&module,Bn=A&&A.exports===zn&&e.process,j=function(){try{return A&&A.require&&A.require(`util`).types||Bn&&Bn.binding&&Bn.binding(`util`)}catch{}}(),Vn=j&&j.isTypedArray,Hn=Vn?Rn(Vn):In,Un=Object.prototype.hasOwnProperty;function Wn(e,t){var n=S(e),r=!n&&rn(e),i=!n&&!r&&un(e),a=!n&&!r&&!i&&Hn(e),o=n||r||i||a,s=o?Xt(e.length,String):[],c=s.length;for(var l in e)(t||Un.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||wt(l,c)))&&s.push(l);return s}var Gn=Wn;function Kn(e,t){return function(n){return e(t(n))}}var qn=Kn,Jn=qn(Object.keys,Object),Yn=Object.prototype.hasOwnProperty;function Xn(e){if(!Jt(e))return Jn(e);var t=[];for(var n in Object(e))Yn.call(e,n)&&n!=`constructor`&&t.push(n);return t}var Zn=Xn;function Qn(e){return O(e)?Gn(e):Zn(e)}var M=Qn,$n=Object.prototype.hasOwnProperty,N=Gt(function(e,t){if(Jt(t)||O(t)){Mt(t,M(t),e);return}for(var n in t)$n.call(t,n)&&At(e,n,t[n])});function er(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var tr=er,nr=Object.prototype.hasOwnProperty;function rr(e){if(!C(e))return tr(e);var t=Jt(e),n=[];for(var r in e)r==`constructor`&&(t||!nr.call(e,r))||n.push(r);return n}var ir=rr;function ar(e){return O(e)?Gn(e,!0):ir(e)}var or=ar,sr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,cr=/^\w*$/;function lr(e,t){if(S(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||b(e)?!0:cr.test(e)||!sr.test(e)||t!=null&&e in Object(t)}var ur=lr,P=E(Object,`create`);function dr(){this.__data__=P?P(null):{},this.size=0}var fr=dr;function pr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var mr=pr,hr=`__lodash_hash_undefined__`,gr=Object.prototype.hasOwnProperty;function _r(e){var t=this.__data__;if(P){var n=t[e];return n===hr?void 0:n}return gr.call(t,e)?t[e]:void 0}var vr=_r,yr=Object.prototype.hasOwnProperty;function br(e){var t=this.__data__;return P?t[e]!==void 0:yr.call(t,e)}var xr=br,Sr=`__lodash_hash_undefined__`;function Cr(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=P&&t===void 0?Sr:t,this}var wr=Cr;function F(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}F.prototype.clear=fr,F.prototype.delete=mr,F.prototype.get=vr,F.prototype.has=xr,F.prototype.set=wr;var Tr=F;function Er(){this.__data__=[],this.size=0}var Dr=Er;function Or(e,t){for(var n=e.length;n--;)if(D(e[n][0],t))return n;return-1}var kr=Or,Ar=Array.prototype.splice;function jr(e){var t=this.__data__,n=kr(t,e);return n<0?!1:(n==t.length-1?t.pop():Ar.call(t,n,1),--this.size,!0)}var Mr=jr;function Nr(e){var t=this.__data__,n=kr(t,e);return n<0?void 0:t[n][1]}var Pr=Nr;function Fr(e){return kr(this.__data__,e)>-1}var Ir=Fr;function Lr(e,t){var n=this.__data__,r=kr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var Rr=Lr;function I(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}I.prototype.clear=Dr,I.prototype.delete=Mr,I.prototype.get=Pr,I.prototype.has=Ir,I.prototype.set=Rr;var zr=I,L=E(n,`Map`);function Br(){this.size=0,this.__data__={hash:new Tr,map:new(L||zr),string:new Tr}}var Vr=Br;function Hr(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}var Ur=Hr;function Wr(e,t){var n=e.__data__;return Ur(t)?n[typeof t==`string`?`string`:`hash`]:n.map}var Gr=Wr;function Kr(e){var t=Gr(this,e).delete(e);return this.size-=t?1:0,t}var qr=Kr;function Jr(e){return Gr(this,e).get(e)}var Yr=Jr;function Xr(e){return Gr(this,e).has(e)}var Zr=Xr;function Qr(e,t){var n=Gr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var $r=Qr;function R(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}R.prototype.clear=Vr,R.prototype.delete=qr,R.prototype.get=Yr,R.prototype.has=Zr,R.prototype.set=$r;var ei=R,ti=`Expected a function`;function ni(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(ti);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(ni.Cache||ei),n}ni.Cache=ei;var ri=ni,ii=500;function ai(e){var t=ri(e,function(e){return n.size===ii&&n.clear(),e}),n=t.cache;return t}var oi=ai,si=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ci=/\\(\\)?/g,li=oi(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(si,function(e,n,r,i){t.push(r?i.replace(ci,`$1`):n||e)}),t});function ui(e){return e==null?``:se(e)}var di=ui;function fi(e,t){return S(e)?e:ur(e,t)?[e]:li(di(e))}var pi=fi,mi=1/0;function hi(e){if(typeof e==`string`||b(e))return e;var t=e+``;return t==`0`&&1/e==-mi?`-0`:t}var z=hi;function gi(e,t){t=pi(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[z(t[n++])];return n&&n==r?e:void 0}var _i=gi;function vi(e,t,n){var r=e==null?void 0:_i(e,t);return r===void 0?n:r}var yi=vi;function bi(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var xi=bi,Si=qn(Object.getPrototypeOf,Object);function Ci(){this.__data__=new zr,this.size=0}var wi=Ci;function Ti(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var Ei=Ti;function Di(e){return this.__data__.get(e)}var Oi=Di;function ki(e){return this.__data__.has(e)}var Ai=ki,ji=200;function Mi(e,t){var n=this.__data__;if(n instanceof zr){var r=n.__data__;if(!L||r.length<ji-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ei(r)}return n.set(e,t),this.size=n.size,this}var Ni=Mi;function B(e){this.size=(this.__data__=new zr(e)).size}B.prototype.clear=wi,B.prototype.delete=Ei,B.prototype.get=Oi,B.prototype.has=Ai,B.prototype.set=Ni;var V=B;function Pi(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}var Fi=Pi;function Ii(){return[]}var Li=Ii,Ri=Object.prototype.propertyIsEnumerable,zi=Object.getOwnPropertySymbols,Bi=zi?function(e){return e==null?[]:(e=Object(e),Fi(zi(e),function(t){return Ri.call(e,t)}))}:Li,Vi=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)xi(t,Bi(e)),e=Si(e);return t}:Li;function Hi(e,t,n){var r=t(e);return S(e)?r:xi(r,n(e))}var Ui=Hi;function Wi(e){return Ui(e,M,Bi)}var Gi=Wi;function Ki(e){return Ui(e,or,Vi)}var qi=Ki,Ji=E(n,`DataView`),Yi=E(n,`Promise`),Xi=E(n,`Set`),Zi=`[object Map]`,Qi=`[object Object]`,$i=`[object Promise]`,ea=`[object Set]`,ta=`[object WeakMap]`,na=`[object DataView]`,ra=T(Ji),ia=T(L),aa=T(Yi),oa=T(Xi),sa=T($e),H=_;(Ji&&H(new Ji(new ArrayBuffer(1)))!=na||L&&H(new L)!=Zi||Yi&&H(Yi.resolve())!=$i||Xi&&H(new Xi)!=ea||$e&&H(new $e)!=ta)&&(H=function(e){var t=_(e),n=t==Qi?e.constructor:void 0,r=n?T(n):``;if(r)switch(r){case ra:return na;case ia:return Zi;case aa:return $i;case oa:return ea;case sa:return ta}return t});var ca=H,la=n.Uint8Array,ua=`__lodash_hash_undefined__`;function da(e){return this.__data__.set(e,ua),this}var fa=da;function pa(e){return this.__data__.has(e)}var ma=pa;function ha(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new ei;++t<n;)this.add(e[t])}ha.prototype.add=ha.prototype.push=fa,ha.prototype.has=ma;var ga=ha;function _a(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var va=_a;function ya(e,t){return e.has(t)}var ba=ya,xa=1,Sa=2;function Ca(e,t,n,r,i,a){var o=n&xa,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&Sa?new ga:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!va(t,function(e,t){if(!ba(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}var wa=Ca;function Ta(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}var Ea=Ta;function Da(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Oa=Da,ka=1,Aa=2,ja=`[object Boolean]`,Ma=`[object Date]`,Na=`[object Error]`,Pa=`[object Map]`,Fa=`[object Number]`,Ia=`[object RegExp]`,La=`[object Set]`,Ra=`[object String]`,za=`[object Symbol]`,Ba=`[object ArrayBuffer]`,Va=`[object DataView]`,Ha=r?r.prototype:void 0,Ua=Ha?Ha.valueOf:void 0;function Wa(e,t,n,r,i,a,o){switch(n){case Va:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Ba:return!(e.byteLength!=t.byteLength||!a(new la(e),new la(t)));case ja:case Ma:case Fa:return D(+e,+t);case Na:return e.name==t.name&&e.message==t.message;case Ia:case Ra:return e==t+``;case Pa:var s=Ea;case La:var c=r&ka;if(s||=Oa,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=Aa,o.set(e,t);var u=wa(s(e),s(t),r,i,a,o);return o.delete(e),u;case za:if(Ua)return Ua.call(e)==Ua.call(t)}return!1}var Ga=Wa,Ka=1,qa=Object.prototype.hasOwnProperty;function Ja(e,t,n,r,i,a){var o=n&Ka,s=Gi(e),c=s.length;if(c!=Gi(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:qa.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var Ya=Ja,Xa=1,Za=`[object Arguments]`,Qa=`[object Array]`,$a=`[object Object]`,eo=Object.prototype.hasOwnProperty;function to(e,t,n,r,i,a){var o=S(e),s=S(t),c=o?Qa:ca(e),l=s?Qa:ca(t);c=c==Za?$a:c,l=l==Za?$a:l;var u=c==$a,d=l==$a,f=c==l;if(f&&un(e)){if(!un(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new V,o||Hn(e)?wa(e,t,n,r,i,a):Ga(e,t,c,n,r,i,a);if(!(n&Xa)){var p=u&&eo.call(e,`__wrapped__`),m=d&&eo.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new V,i(h,g,n,r,a)}}return f?(a||=new V,Ya(e,t,n,r,i,a)):!1}var no=to;function ro(e,t,n,r,i){return e===t?!0:e==null||t==null||!y(e)&&!y(t)?e!==e&&t!==t:no(e,t,n,r,ro,i)}var io=ro,ao=1,oo=2;function so(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new V;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?io(u,l,ao|oo,r,d):f))return!1}}return!0}var co=so;function lo(e){return e===e&&!C(e)}var uo=lo;function fo(e){for(var t=M(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,uo(i)]}return t}var po=fo;function mo(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}var ho=mo;function go(e){var t=po(e);return t.length==1&&t[0][2]?ho(t[0][0],t[0][1]):function(n){return n===e||co(n,e,t)}}var _o=go;function vo(e,t){return e!=null&&t in Object(e)}var yo=vo;function bo(e,t,n){t=pi(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=z(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&Bt(i)&&wt(o,i)&&(S(e)||rn(e)))}var xo=bo;function So(e,t){return e!=null&&xo(e,t,yo)}var Co=So,wo=1,To=2;function Eo(e,t){return ur(e)&&uo(t)?ho(z(e),t):function(n){var r=yi(n,e);return r===void 0&&r===t?Co(n,e):io(t,r,wo|To)}}var Do=Eo;function Oo(e){return function(t){return t?.[e]}}var ko=Oo;function Ao(e){return function(t){return _i(t,e)}}var jo=Ao;function Mo(e){return ur(e)?ko(z(e)):jo(e)}var No=Mo;function Po(e){return typeof e==`function`?e:e==null?w:typeof e==`object`?S(e)?Do(e[0],e[1]):_o(e):No(e)}var U=Po;function Fo(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Io=Fo();function Lo(e,t){return e&&Io(e,t,M)}var Ro=Lo;function zo(e,t){return function(n,r){if(n==null)return n;if(!O(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var W=zo(Ro);function Bo(e){return typeof e==`function`?e:w}var Vo=Bo;function Ho(e,t){return(S(e)?ft:W)(e,Vo(t))}var Uo=Ho;function Wo(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}var Go=Wo;function Ko(e,t){var n=!0;return W(e,function(e,r,i){return n=!!t(e,r,i),n}),n}var qo=Ko;function Jo(e,t,n){var r=S(e)?Go:qo;return n&&Ut(e,t,n)&&(t=void 0),r(e,U(t,3))}var Yo=Jo;function Xo(e,t){var n=-1,r=O(e)?Array(e.length):[];return W(e,function(e,i,a){r[++n]=t(e,i,a)}),r}var Zo=Xo;function Qo(e,t){return(S(e)?x:Zo)(e,U(t,3))}var $o=Qo,es=`[object String]`;function ts(e){return typeof e==`string`||!S(e)&&y(e)&&_(e)==es}var G=ts;function ns(e,t){return x(t,function(t){return e[t]})}var rs=ns;function is(e){return e==null?[]:rs(e,M(e))}var as=is,os=Math.max;function ss(e,t,n,r){e=O(e)?e:as(e),n=n&&!r?De(n):0;var i=e.length;return n<0&&(n=os(i+n,0)),G(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&bt(e,t,n)>-1}var cs=ss,ls=`[object RegExp]`;function us(e){return y(e)&&_(e)==ls}var ds=us,fs=j&&j.isRegExp,ps=fs?Rn(fs):ds;function ms(e,t,n,r){if(!C(e))return e;t=pi(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=z(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=C(u)?u:wt(t[i+1])?[]:{})}At(s,c,l),s=s[c]}return e}var hs=ms;function gs(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=_i(e,o);n(s,o)&&hs(a,pi(o,e),s)}return a}var _s=gs;function vs(e,t){if(e==null)return{};var n=x(qi(e),function(e){return[e]});return t=U(t),_s(e,n,function(e,n){return t(e,n[0])})}var K=vs;function ys(e,t){var n;return W(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}var bs=ys;function xs(e,t,n){var r=S(e)?va:bs;return n&&Ut(e,t,n)&&(t=void 0),r(e,U(t,3))}var Ss=xs;function Cs(e){return ws(e)?e.LABEL:e.name}function ws(e){return G(e.LABEL)&&e.LABEL!==``}var q=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),Uo(this.definition,t=>{t.accept(e)})}},J=class extends q{constructor(e){super([]),this.idx=1,N(this,K(e,e=>e!==void 0))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},Ts=class extends q{constructor(e){super(e.definition),this.orgText=``,N(this,K(e,e=>e!==void 0))}},Es=class extends q{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,N(this,K(e,e=>e!==void 0))}},Y=class extends q{constructor(e){super(e.definition),this.idx=1,N(this,K(e,e=>e!==void 0))}},Ds=class extends q{constructor(e){super(e.definition),this.idx=1,N(this,K(e,e=>e!==void 0))}},Os=class extends q{constructor(e){super(e.definition),this.idx=1,N(this,K(e,e=>e!==void 0))}},X=class extends q{constructor(e){super(e.definition),this.idx=1,N(this,K(e,e=>e!==void 0))}},Z=class extends q{constructor(e){super(e.definition),this.idx=1,N(this,K(e,e=>e!==void 0))}},Q=class extends q{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,N(this,K(e,e=>e!==void 0))}},$=class{constructor(e){this.idx=1,N(this,K(e,e=>e!==void 0))}accept(e){e.visit(this)}};function ks(e){return $o(e,As)}function As(e){function t(e){return $o(e,As)}if(e instanceof J){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return G(e.label)&&(t.label=e.label),t}else if(e instanceof Es)return{type:`Alternative`,definition:t(e.definition)};else if(e instanceof Y)return{type:`Option`,idx:e.idx,definition:t(e.definition)};else if(e instanceof Ds)return{type:`RepetitionMandatory`,idx:e.idx,definition:t(e.definition)};else if(e instanceof Os)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:As(new $({terminalType:e.separator})),definition:t(e.definition)};else if(e instanceof Z)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:As(new $({terminalType:e.separator})),definition:t(e.definition)};else if(e instanceof X)return{type:`Repetition`,idx:e.idx,definition:t(e.definition)};else if(e instanceof Q)return{type:`Alternation`,idx:e.idx,definition:t(e.definition)};else if(e instanceof $){let t={type:`Terminal`,name:e.terminalType.name,label:Cs(e.terminalType),idx:e.idx};G(e.label)&&(t.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=ps(n)?n.source:n),t}else if(e instanceof Ts)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:t(e.definition)};else throw Error(`non exhaustive match`)}var js=class{visit(e){let t=e;switch(t.constructor){case J:return this.visitNonTerminal(t);case Es:return this.visitAlternative(t);case Y:return this.visitOption(t);case Ds:return this.visitRepetitionMandatory(t);case Os:return this.visitRepetitionMandatoryWithSeparator(t);case Z:return this.visitRepetitionWithSeparator(t);case X:return this.visitRepetition(t);case Q:return this.visitAlternation(t);case $:return this.visitTerminal(t);case Ts:return this.visitRule(t);default:throw Error(`non exhaustive match`)}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function Ms(e){return e instanceof Es||e instanceof Y||e instanceof X||e instanceof Ds||e instanceof Os||e instanceof Z||e instanceof $||e instanceof Ts}function Ns(e,t=[]){return e instanceof Y||e instanceof X||e instanceof Z?!0:e instanceof Q?Ss(e.definition,e=>Ns(e,t)):e instanceof J&&cs(t,e)?!1:e instanceof q?(e instanceof J&&t.push(e),Yo(e.definition,e=>Ns(e,t))):!1}function Ps(e){return e instanceof Q}function Fs(e){if(e instanceof J)return`SUBRULE`;if(e instanceof Y)return`OPTION`;if(e instanceof Q)return`OR`;if(e instanceof Ds)return`AT_LEAST_ONE`;if(e instanceof Os)return`AT_LEAST_ONE_SEP`;if(e instanceof Z)return`MANY_SEP`;if(e instanceof X)return`MANY`;if(e instanceof $)return`CONSUME`;throw Error(`non exhaustive match`)}export{Ut as $,ba as A,V as B,$o as C,U as D,W as E,qi as F,M as G,xi as H,Gi as I,j as J,Zn as K,Vi as L,la as M,ca as N,xo as O,Xi as P,Jt as Q,Bi as R,G as S,Uo as T,or as U,Si as V,N as W,un as X,Rn as Y,rn as Z,Ss as _,r as _t,js as a,Et as at,cs as b,J as c,ft as ct,Ds as d,De as dt,O as et,Os as f,C as ft,ks as g,y as gt,$ as h,b as ht,Ms as i,D as it,ga as j,Oa as k,Y as l,Pe as lt,Ts as m,x as mt,Ps as n,Mt as nt,Q as o,bt as ot,Z as p,S as pt,Hn as q,Ns as r,At as rt,Es as s,mt as st,Fs as t,Lt as tt,X as u,w as ut,K as v,n as vt,Yo as w,as as x,ps as y,Fi as z};
@@ -0,0 +1,9 @@
1
+ function e(e){return e.charCodeAt(0)}function t(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function n(e,t){if(e[t]===!0)throw`duplicate flag `+t;e[t],e[t]=!0}function r(e){if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}function i(){throw Error(`Internal Error - Should never get here!`)}function a(e){return e.type===`Character`}const o=[];for(let t=e(`0`);t<=e(`9`);t++)o.push(t);const s=[e(`_`)].concat(o);for(let t=e(`a`);t<=e(`z`);t++)s.push(t);for(let t=e(`A`);t<=e(`Z`);t++)s.push(t);const c=[e(` `),e(`\f`),e(`
2
+ `),e(`\r`),e(` `),e(`\v`),e(` `),e(`\xA0`),e(` `),e(` `),e(` `),e(` `),e(` `),e(` `),e(` `),e(` `),e(` `),e(` `),e(` `),e(` `),e(`\u2028`),e(`\u2029`),e(` `),e(` `),e(` `),e(``)],l=/[0-9a-fA-F]/,u=/[0-9]/,d=/[1-9]/;var f=class{constructor(){this.idx=0,this.input=``,this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar(`/`);let t=this.disjunction();this.consumeChar(`/`);let r={type:`Flags`,loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case`g`:n(r,`global`);break;case`i`:n(r,`ignoreCase`);break;case`m`:n(r,`multiLine`);break;case`u`:n(r,`unicode`);break;case`y`:n(r,`sticky`);break}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:r,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}throw Error(`Invalid Assertion Escape`);case`(`:this.consumeChar(`?`);let t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break}r(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}return i()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`);break}if(e===!0&&t===void 0)return;r(t);break}if(!(e===!0&&t===void 0)&&r(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,t=this.idx;switch(this.peekChar()){case`.`:e=this.dotAll();break;case`\\`:e=this.atomEscape();break;case`[`:e=this.characterClass();break;case`(`:e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),r(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):i()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[e(`
3
+ `),e(`\r`),e(`\u2028`),e(`\u2029`)]}}atomEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:return this.decimalEscapeAtom();case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:`GroupBackReference`,value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case`d`:e=o;break;case`D`:e=o,t=!0;break;case`s`:e=c;break;case`S`:e=c,t=!0;break;case`w`:e=s;break;case`W`:e=s,t=!0;break}return r(e)?{type:`Set`,value:e,complement:t}:i()}controlEscapeAtom(){let t;switch(this.popChar()){case`f`:t=e(`\f`);break;case`n`:t=e(`
4
+ `);break;case`r`:t=e(`\r`);break;case`t`:t=e(` `);break;case`v`:t=e(`\v`);break}return r(t)?{type:`Character`,value:t}:i()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:e(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:e(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
+ `:case`\r`:case`\u2028`:case`\u2029`:case`\\`:case`]`:throw Error(`TBD`);default:return{type:`Character`,value:e(this.popChar())}}}characterClass(){let n=[],r=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),r=!0);this.isClassAtom();){let r=this.classAtom();if(r.type,a(r)&&this.isRangeDash()){this.consumeChar(`-`);let i=this.classAtom();if(i.type,a(i)){if(i.value<r.value)throw Error(`Range out of order in character class`);n.push({from:r.value,to:i.value})}else t(r.value,n),n.push(e(`-`)),t(i.value,n)}else t(r.value,n)}return this.consumeChar(`]`),{type:`Set`,complement:r,value:n}}classAtom(){switch(this.peekChar()){case`]`:case`
6
+ `:case`\r`:case`\u2028`:case`\u2029`:throw Error(`TBD`);case`\\`:return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`b`:return this.consumeChar(`b`),{type:`Character`,value:e(`\b`)};case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar(`(`),this.peekChar(0)){case`?`:this.consumeChar(`?`),this.consumeChar(`:`),e=!1;break;default:this.groupIdx++;break}let t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(d.test(e)===!1)throw Error(`Expecting a positive integer`);for(;u.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(u.test(e)===!1)throw Error(`Expecting an integer`);for(;u.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let t=this.popChar();switch(t){case`
7
+ `:case`\r`:case`\u2028`:case`\u2029`:case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:throw Error(`TBD`);default:return{type:`Character`,value:e(t)}}}isRegExpFlag(){switch(this.peekChar(0)){case`g`:case`i`:case`m`:case`u`:case`y`:return!0;default:return!1}}isRangeDash(){return this.peekChar()===`-`&&this.isClassAtom(1)}isDigit(){return u.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
8
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case`.`:case`\\`:case`[`:case`(`:return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case`^`:case`$`:return!0;case`\\`:switch(this.peekChar(1)){case`b`:case`B`:return!0;default:return!1}case`(`:return this.peekChar(1)===`?`&&(this.peekChar(2)===`=`||this.peekChar(2)===`!`);default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
9
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(l.test(e)===!1)throw Error(`Expecting a HexDecimal digits`);t+=e}return{type:`Character`,value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error(`Expected: '`+e+`' but found: '`+this.input[this.idx]+`' at offset: `+this.idx);if(this.idx>=this.input.length)throw Error(`Unexpected end of input`);this.idx++}loc(e){return{begin:e,end:this.idx}}},p=class{visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}visit(e){switch(e.type){case`Pattern`:this.visitPattern(e);break;case`Flags`:this.visitFlags(e);break;case`Disjunction`:this.visitDisjunction(e);break;case`Alternative`:this.visitAlternative(e);break;case`StartAnchor`:this.visitStartAnchor(e);break;case`EndAnchor`:this.visitEndAnchor(e);break;case`WordBoundary`:this.visitWordBoundary(e);break;case`NonWordBoundary`:this.visitNonWordBoundary(e);break;case`Lookahead`:this.visitLookahead(e);break;case`NegativeLookahead`:this.visitNegativeLookahead(e);break;case`Character`:this.visitCharacter(e);break;case`Set`:this.visitSet(e);break;case`Group`:this.visitGroup(e);break;case`GroupBackReference`:this.visitGroupBackReference(e);break;case`Quantifier`:this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}};export{f as n,p as t};
@@ -0,0 +1 @@
1
+ function e(e){console&&console.error&&console.error(`Error: ${e}`)}function t(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function n(e){let t=new Date().getTime(),n=e();return{time:new Date().getTime()-t,value:n}}function r(e){function t(){}t.prototype=e;let n=new t;function r(){return typeof n.bar}return r(),r(),e}export{t as i,n,e as r,r as t};
@@ -0,0 +1 @@
1
+ import e from"crypto";import{createServer as t}from"http";import{Http2ServerRequest as n}from"http2";import{Readable as r}from"stream";var i=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},a=e=>e instanceof i?e:new i(e.message,{cause:e}),o=global.Request,s=class extends o{constructor(e,t){typeof e==`object`&&d in e&&(e=e[d]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},c=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},l=Symbol(`wrapBodyStream`),u=(e,t,n,i,a)=>{let o={method:e,headers:n,signal:a.signal};if(e===`TRACE`){o.method=`GET`;let e=new s(t,o);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in i&&i.rawBody instanceof Buffer)o.body=new ReadableStream({start(e){e.enqueue(i.rawBody),e.close()}});else if(i[l]){let e;o.body=new ReadableStream({async pull(t){try{e||=r.toWeb(i).getReader();let{done:n,value:a}=await e.read();n?t.close():t.enqueue(a)}catch(e){t.error(e)}}})}else o.body=r.toWeb(i);return new s(t,o)},d=Symbol(`getRequestCache`),f=Symbol(`requestCache`),p=Symbol(`incomingKey`),m=Symbol(`urlKey`),h=Symbol(`headersKey`),g=Symbol(`abortControllerKey`),_={get method(){return this[p].method||`GET`},get url(){return this[m]},get headers(){return this[h]||=c(this[p])},[Symbol(`getAbortController`)](){return this[d](),this[g]},[d](){return this[g]||=new AbortController,this[f]||=u(this.method,this[m],this.headers,this[p],this[g])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(_,e,{get(){return this[d]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(_,e,{value:function(){return this[d]()[e]()}})}),Object.setPrototypeOf(_,s.prototype);var v=(e,t)=>{let r=Object.create(_);r[p]=e;let a=e.url||``;if(a[0]!==`/`&&(a.startsWith(`http://`)||a.startsWith(`https://`))){if(e instanceof n)throw new i(`Absolute URL for :path is not allowed in HTTP/2`);try{r[m]=new URL(a).href}catch(e){throw new i(`Invalid absolute URL`,{cause:e})}return r}let o=(e instanceof n?e.authority:e.headers.host)||t;if(!o)throw new i(`Missing host header`);let s;if(e instanceof n){if(s=e.scheme,!(s===`http`||s===`https`))throw new i(`Unsupported scheme`)}else s=e.socket&&e.socket.encrypted?`https`:`http`;let c=new URL(`${s}://${o}${a}`);if(c.hostname.length!==o.length&&c.hostname!==o.replace(/:\d+$/,``))throw new i(`Invalid host header`);return r[m]=c.href,r},y=Symbol(`responseCache`),b=Symbol(`getResponseCache`),x=Symbol(`cache`),S=global.Response,C=class e{#e;#t;[b](){return delete this[x],this[y]||=new S(this.#e,this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof e){let e=n[y];if(e){this.#t=e,this[b]();return}else this.#t=n.#t,r=new Headers(n.#t.headers)}else this.#t=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(r||=n?.headers||{"content-type":`text/plain; charset=UTF-8`},this[x]=[n?.status||200,t,r])}get headers(){let e=this[x];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2])),e[2]):this[b]().headers}get status(){return this[x]?.[0]??this[b]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(C.prototype,e,{get(){return this[b]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(C.prototype,e,{value:function(){return this[b]()[e]()}})}),Object.setPrototypeOf(C,S),Object.setPrototypeOf(C.prototype,S.prototype);async function w(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function T(e,t,n){let r=t=>{e.cancel(t).catch(()=>{})};return t.on(`close`,r),t.on(`error`,r),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off(`close`,r),t.off(`error`,r)});function i(e){e&&t.destroy(e)}function a(){e.read().then(o,i)}function o({done:n,value:r}){try{if(n)t.end();else if(!t.write(r))t.once(`drain`,a);else return e.read().then(o,i)}catch(e){i(e)}}}function E(e,t){if(e.locked)throw TypeError(`ReadableStream is locked.`);return t.destroyed?void 0:T(e.getReader(),t)}var D=e=>{let t={};e instanceof Headers||(e=new Headers(e??void 0));let n=[];for(let[r,i]of e)r===`set-cookie`?n.push(i):t[r]=i;return n.length>0&&(t[`set-cookie`]=n),t[`content-type`]??=`text/plain; charset=UTF-8`,t},O=`x-hono-already-sent`;global.crypto===void 0&&(global.crypto=e);var k=Symbol(`outgoingEnded`),A=()=>new Response(null,{status:400}),j=e=>new Response(null,{status:e instanceof Error&&(e.name===`TimeoutError`||e.constructor.name===`TimeoutError`)?504:500}),M=(e,t)=>{let n=e instanceof Error?e:Error(`unknown error`,{cause:e});n.code===`ERR_STREAM_PREMATURE_CLOSE`?console.info(`The user aborted a request.`):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":`text/plain`}),t.end(`Error: ${n.message}`),t.destroy(n))},N=e=>{`flushHeaders`in e&&e.writable&&e.flushHeaders()},P=async(e,t)=>{let[n,r,i]=e[x];i instanceof Headers&&(i=D(i)),typeof r==`string`?i[`Content-Length`]=Buffer.byteLength(r):r instanceof Uint8Array?i[`Content-Length`]=r.byteLength:r instanceof Blob&&(i[`Content-Length`]=r.size),t.writeHead(n,i),typeof r==`string`||r instanceof Uint8Array?t.end(r):r instanceof Blob?t.end(new Uint8Array(await r.arrayBuffer())):(N(t),await E(r,t)?.catch(e=>M(e,t))),t[k]?.()},F=e=>typeof e.then==`function`,I=async(e,t,n={})=>{if(F(e))if(n.errorHandler)try{e=await e}catch(t){let r=await n.errorHandler(t);if(!r)return;e=r}else e=await e.catch(j);if(x in e)return P(e,t);let r=D(e.headers);if(e.body){let n=e.body.getReader(),i=[],a=!1,o;if(r[`transfer-encoding`]!==`chunked`){let e=2;for(let t=0;t<e;t++){o||=n.read();let r=await w(o).catch(e=>{console.error(e),a=!0});if(!r){if(t===1){await new Promise(e=>setTimeout(e)),e=3;continue}break}if(o=void 0,r.value&&i.push(r.value),r.done){a=!0;break}}a&&!(`content-length`in r)&&(r[`content-length`]=i.reduce((e,t)=>e+t.length,0))}t.writeHead(e.status,r),i.forEach(e=>{t.write(e)}),a?t.end():(i.length===0&&N(t),await T(n,t,o))}else r[O]||(t.writeHead(e.status,r),t.end());t[k]?.()},L=(e,t={})=>{let r=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==s&&(Object.defineProperty(global,`Request`,{value:s}),Object.defineProperty(global,`Response`,{value:C})),async(i,o)=>{let s,c;try{c=v(i,t.hostname);let a=!r||i.method===`GET`||i.method===`HEAD`;if(a||(i[l]=!0,i.on(`end`,()=>{a=!0}),i instanceof n&&(o[k]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{i.destroy(),o.destroy()})})})),o.on(`close`,()=>{c[g]&&(i.errored?c[g].abort(i.errored.toString()):o.writableFinished||c[g].abort(`Client connection prematurely closed.`)),a||setTimeout(()=>{a||setTimeout(()=>{i.destroy()})})}),s=e(c,{incoming:i,outgoing:o}),x in s)return P(s,o)}catch(e){if(s)return M(e,o);if(t.errorHandler){if(s=await t.errorHandler(c?e:a(e)),!s)return}else s=c?j(e):A()}try{return await I(s,o,t)}catch(e){return M(e,o)}}},R=e=>{let n=e.fetch,r=L(n,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming});return(e.createServer||t)(e.serverOptions||{},r)},z=(e,t)=>{let n=R(e);return n.listen(e?.port??3e3,e.hostname,()=>{let e=n.address();t&&t(e)}),n};export{z as t};
@@ -0,0 +1,6 @@
1
+ import{r as e}from"../../rolldown-runtime.mjs";import t from"node:util";function n(e){return typeof e==`function`?e:r(e)}function r(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}const i=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function a(e,t){let n=i.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=i.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}function o(e=[]){return c.getLogger(e)}const s=Symbol.for(`logtape.rootLogger`);var c=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=s in globalThis?globalThis[s]??null:null;return n??(n=new e(null,[]),globalThis[s]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new l(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||a(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}emit(e,t){let n=y(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,o=Object.getOwnPropertyDescriptors(e);o.category={value:i,enumerable:!0,configurable:!0};let s=Object.defineProperties({},o);if(!(this.lowestLevel===null||a(s.level,this.lowestLevel)<0||!this.filter(s))){for(let e of this.getSinks(s.level))if(!t?.has(e))try{e(s)}catch(n){let r=new Set(t);r.add(e),u.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:s},r)}}}log(e,t,n,r){let i=b(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return g(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:g(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=b(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,_(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=b();this.emit({category:this.category,level:e,message:_(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},l=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){this.logger.log(e,t,typeof n==`function`?()=>({...this.properties,...n()}):{...this.properties,...n},r)}logLazily(e,t){this.logger.logLazily(e,t,this.properties)}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,this.properties)}emit(e){let t={...e,properties:{...this.properties,...e.properties}};this.logger.emit(t)}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const u=c.getLogger([`logtape`,`meta`]);function d(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function f(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function p(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
2
+ `;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function m(e,t){if(typeof t==`string`)return f(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function h(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=p(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=m(n,i),n===void 0)return}return n}function g(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&d(u)&&(l=h(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function _(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}const v=Symbol.for(`logtape.categoryPrefix`);function y(){let e=c.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[v];return Array.isArray(t)?t:[]}function b(){let e=c.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var x=e({inspect:()=>S});function S(e,n){return t.inspect(e,n)}const C={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},w=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):x!=null&&`inspect`in x&&typeof S==`function`?(e,t)=>S(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function T(e){return e<10?`0${e}`:`${e}`}function E(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const D={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())} ${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${T(t.getUTCHours())}:${T(t.getUTCMinutes())}:${T(t.getUTCSeconds())}.${E(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${T(t.getUTCMonth()+1)}-${T(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},O={ABBR:C,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function k(e={}){let t=(()=>{let t=e.timestamp;return t==null?D[`date-time-timezone`]:t===`disabled`?D.none:typeof t==`string`&&t in D?D[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,w):w,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>O.ABBR[e]:t===`abbr`?e=>O.abbr[e]:t===`FULL`?e=>O.FULL[e]:t===`full`?e=>O.full[e]:t===`L`?e=>O.L[e]:t===`l`?e=>O.l[e]:t})(),a=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let o=e.message,s=o.length,c;if(s===1)c=o[0];else if(s<=6){c=``;for(let e=0;e<s;e++)c+=e%2==0?o[e]:r(o[e])}else{let e=Array(s);for(let t=0;t<s;t++)e[t]=t%2==0?o[t]:r(o[t]);c=e.join(``)}return`${a({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:c,record:e})}\n`}}k();const A=`\x1B[0m`,j={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},M={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},N={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function P(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:M[n]}${r==null?``:j[r]}`,a=n==null&&r==null?``:A,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??N,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:M[c]}${l==null?``:j[l]}`,d=c==null&&l==null?``:A;return k({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=`${i}${e}${a}`,n=`${o==null?``:M[o]}${f==null?``:j[f]}${n}${o==null&&f==null?``:A}`,t==null?`${e} ${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}P();function F(e={}){if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties})+`
3
+ `;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties})+`
4
+ `;let t=e.message[0];for(let n=1;n<e.message.length;n++)t+=n&1?JSON.stringify(e.message[n]):e.message[n];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:t,logger:e.category.join(`.`),properties:e.properties})+`
5
+ `};let t=e.message===`template`,n=e.properties??`nest:properties`,r;if(typeof e.categorySeparator==`function`)r=e.categorySeparator;else{let t=e.categorySeparator??`.`;r=e=>e.join(t)}let i;if(n===`flatten`)i=e=>e;else if(n.startsWith(`prepend:`)){let e=n.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);i=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(n.startsWith(`nest:`)){let e=n.substring(5);i=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let a;return a=t?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:a(e),logger:r(e.category),...i(e.properties)})+`
6
+ `}F();const I={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function L(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${C[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,I[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function R(e={}){let t=e.formatter??L,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}let z=null;const B=new Set,V=new Set,H=new Set;function U(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function W(e){if(z!=null&&!e.reset)throw new X(`Already configured; if you want to reset, turn on the reset flag.`);if(H.size>0)throw new X(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);K();try{G(e,!1)}catch(e){throw e instanceof X&&K(),e}}function G(e,t){z=e;let r=!1,i=new Set;for(let t of e.loggers){U(t)&&(r=!0);let a=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(i.has(a))throw new X(`Duplicate logger configuration for category: ${a}. Each category can only be configured once.`);i.add(a);let o=c.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new X(`Sink not found: ${n}.`);o.sinks.push(t)}o.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(o.lowestLevel=t.lowestLevel);for(let r of t.filters??[]){let t=e.filters?.[r];if(t===void 0)throw new X(`Filter not found: ${r}.`);o.filters.push(n(t))}B.add(o)}c.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)H.add(n);else throw new X(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&V.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)H.add(n);else throw new X(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&V.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?J:Y)}else addEventListener(`unload`,t?J:Y);let a=c.getLogger([`logtape`,`meta`]);r||a.sinks.push(R()),a.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function K(){Y(),q()}function q(){let e=c.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,B.clear(),z=null}async function J(){Y();let e=[];for(let t of H)e.push(t[Symbol.asyncDispose]()),H.delete(t);await Promise.all(e)}function Y(){for(let e of V)e[Symbol.dispose]();V.clear()}var X=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};export{o as i,R as n,P as r,W as t};
@@ -0,0 +1 @@
1
+ function e(){return new t}var t=class e{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){let t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){let r=this.index[e.id()];if(r===void 0){let r=new n(e,t());return this.index[e.id()]=this.array.length,this.array.push(r),r}else return this.array[r]}insert(e,t){let r=new n(e,t),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(r)):this.array[i]=r,r}erase(e){let t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;let n=this.array[t],r=this.array.pop();return n!==r&&(this.array[t]=r,this.index[r.first.id()]=t),n}copy(){let t=new e;for(let e=0;e<this.array.length;e++){let n=this.array[e].copy();t.array[e]=n,t.index[n.first.id()]=e}return t}},n=class e{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new e(this.first,this.second)}},r=class{constructor(e=``){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new a(this,e)}minus(e){return new a(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new a([e,this])}divide(e){return new a([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+`[`+this._name+`:`+this._value+`]`}_name;_value=0;_context=null;_id=i++};let i=0;var a=class e{constructor(){let e=o(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let n=this._terms.itemAt(t);e+=n.first.value()*n.second}return e}plus(t){return new e(this,t)}minus(t){return new e(this,typeof t==`number`?-t:[-1,t])}multiply(t){return new e([t,this])}divide(t){return new e([1/t,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(e){return e.second+`*`+e.first.toString()}).join(` + `);return!this.isConstant()&&this._constant!==0&&(e+=` + `),e+=this._constant,e}_terms;_constant};function o(t){let n=0,i=()=>0,o=e();for(let e=0,s=t.length;e<s;++e){let s=t[e];if(typeof s==`number`)n+=s;else if(s instanceof r)o.setDefault(s,i).second+=1;else if(s instanceof a){n+=s.constant();let e=s.terms();for(let t=0,n=e.size();t<n;t++){let n=e.itemAt(t);o.setDefault(n.first,i).second+=n.second}}else if(s instanceof Array){if(s.length!==2)throw Error(`array must have length 2`);let e=s[0],t=s[1];if(typeof e!=`number`)throw Error(`array item 0 must be a number`);if(t instanceof r)o.setDefault(t,i).second+=e;else if(t instanceof a){n+=t.constant()*e;let r=t.terms();for(let t=0,n=r.size();t<n;t++){let n=r.itemAt(t);o.setDefault(n.first,i).second+=n.second*e}}else throw Error(`array item 1 must be a variable or expression`)}else throw Error(`invalid Expression argument: `+s)}return{terms:o,constant:n}}var s=class e{static create(e,t,n,r=1){let i=0;return i+=Math.max(0,Math.min(1e3,e*r))*1e6,i+=Math.max(0,Math.min(1e3,t*r))*1e3,i+=Math.max(0,Math.min(1e3,n*r)),i}static required=e.create(1e3,1e3,1e3);static strong=e.create(1,0,0);static medium=e.create(0,1,0);static weak=e.create(0,0,1);static clip(t){return Math.max(0,Math.min(e.required,t))}},c;(function(e){e[e.Le=0]=`Le`,e[e.Ge=1]=`Ge`,e[e.Eq=2]=`Eq`})(c||={});var l=class{constructor(e,t,n,r=s.required){this._operator=t,this._strength=s.clip(r),n===void 0&&e instanceof a?this._expression=e:this._expression=e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+` `+[`<=`,`>=`,`=`][this._operator]+` 0 (`+this._strength.toString()+`)`}_expression;_operator;_strength;_id=u++};let u=0;var d=class{maxIterations=1e3;constructor(){}createConstraint(e,t,n,r=s.required){let i=new l(e,t,n,r);return this.addConstraint(i),i}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw Error(`duplicate constraint`);let t=this._createRow(e),n=t.row,r=t.tag,i=this._chooseSubject(n,r);if(i.type()===_.Invalid&&n.allDummies())if(f(n.constant()))i=r.marker;else throw Error(`unsatisfiable constraint`);if(i.type()===_.Invalid){if(!this._addWithArtificialVariable(n))throw Error(`unsatisfiable constraint`)}else n.solveFor(i),this._substitute(i,n),this._rowMap.insert(i,n);this._cnMap.insert(e,r),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw Error(`unknown constraint`);this._removeConstraintEffects(e,t.second);let n=t.second.marker,r=this._rowMap.erase(n);if(r===void 0){let e=this._getMarkerLeavingSymbol(n);if(e.type()===_.Invalid)throw Error(`failed to find leaving row`);r=this._rowMap.erase(e),r.second.solveForEx(e,n),this._substitute(n,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw Error(`duplicate edit variable`);if(t=s.clip(t),t===s.required)throw Error(`bad required strength`);let n=new l(new a(e),c.Eq,void 0,t);this.addConstraint(n);let r={tag:this._cnMap.find(n).second,constraint:n,constant:0};this._editMap.insert(e,r)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw Error(`unknown edit variable`);this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw Error(`unknown edit variable`);let r=this._rowMap,i=n.second,a=t-i.constant;i.constant=t;let o=i.tag.marker,s=r.find(o);if(s!==void 0){s.second.add(-a)<0&&this._infeasibleRows.push(o),this._dualOptimize();return}let c=i.tag.other;if(s=r.find(c),s!==void 0){s.second.add(a)<0&&this._infeasibleRows.push(c),this._dualOptimize();return}for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e),n=t.second,i=n.coefficientFor(o);i!==0&&n.add(a*i)<0&&t.first.type()!==_.External&&this._infeasibleRows.push(t.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,r=e.size();n<r;++n){let r=e.itemAt(n),i=t.find(r.second);i===void 0?r.first.setValue(0):r.first.setValue(i.second.constant())}}_getVarSymbol(e){return this._varMap.setDefault(e,()=>this._makeSymbol(_.External)).second}_createRow(e){let t=e.expression(),n=new b(t.constant()),r=t.terms();for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e);if(!f(t.second)){let e=this._getVarSymbol(t.first),r=this._rowMap.find(e);r===void 0?n.insertSymbol(e,t.second):n.insertRow(r.second,t.second)}}let i=this._objective,a=e.strength(),o={marker:y,other:y};switch(e.op()){case c.Le:case c.Ge:{let t=e.op()===c.Le?1:-1,r=this._makeSymbol(_.Slack);if(o.marker=r,n.insertSymbol(r,t),a<s.required){let e=this._makeSymbol(_.Error);o.other=e,n.insertSymbol(e,-t),i.insertSymbol(e,a)}break}case c.Eq:if(a<s.required){let e=this._makeSymbol(_.Error),t=this._makeSymbol(_.Error);o.marker=e,o.other=t,n.insertSymbol(e,-1),n.insertSymbol(t,1),i.insertSymbol(e,a),i.insertSymbol(t,a)}else{let e=this._makeSymbol(_.Dummy);o.marker=e,n.insertSymbol(e)}break}return n.constant()<0&&n.reverseSign(),{row:n,tag:o}}_chooseSubject(e,t){let n=e.cells();for(let e=0,t=n.size();e<t;++e){let t=n.itemAt(e);if(t.first.type()===_.External)return t.first}let r=t.marker.type();return(r===_.Slack||r===_.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===_.Slack||r===_.Error)&&e.coefficientFor(t.other)<0?t.other:y)}_addWithArtificialVariable(e){let t=this._makeSymbol(_.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=f(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let e=r.second;if(e.isConstant())return n;let i=this._anyPivotableSymbol(e);if(i.type()===_.Invalid)return!1;e.solveForEx(t,i),this._substitute(i,e),this._rowMap.insert(i,e)}let i=this._rowMap;for(let e=0,n=i.size();e<n;++e)i.itemAt(e).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let r=0,i=n.size();r<i;++r){let i=n.itemAt(r);i.second.substitute(e,t),i.second.constant()<0&&i.first.type()!==_.External&&this._infeasibleRows.push(i.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===_.Invalid)return;let r=this._getLeavingSymbol(n);if(r.type()===_.Invalid)throw Error(`the objective is unbounded`);let i=this._rowMap.erase(r).second;i.solveForEx(r,n),this._substitute(n,i),this._rowMap.insert(n,i),t++}throw Error(`solver iterations exceeded`)}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),r=e.find(n);if(r!==void 0&&r.second.constant()<0){let t=this._getDualEnteringSymbol(r.second);if(t.type()===_.Invalid)throw Error(`dual optimize failed`);let i=r.second;e.erase(n),i.solveForEx(n,t),this._substitute(t,i),e.insert(t,i)}}}_getEnteringSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first;if(n.second<0&&r.type()!==_.Dummy)return r}return y}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=y,r=e.cells();for(let e=0,i=r.size();e<i;++e){let i=r.itemAt(e),a=i.first,o=i.second;if(o>0&&a.type()!==_.Dummy){let e=this._objective.coefficientFor(a)/o;e<t&&(t=e,n=a)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=y,r=this._rowMap;for(let i=0,a=r.size();i<a;++i){let a=r.itemAt(i),o=a.first;if(o.type()!==_.External){let r=a.second,i=r.coefficientFor(e);if(i<0){let e=-r.constant()/i;e<t&&(t=e,n=o)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,r=t,i=y,a=i,o=i,s=i,c=this._rowMap;for(let t=0,i=c.size();t<i;++t){let i=c.itemAt(t),l=i.second,u=l.coefficientFor(e);if(u===0)continue;let d=i.first;if(d.type()===_.External)s=d;else if(u<0){let e=-l.constant()/u;e<n&&(n=e,a=d)}else{let e=l.constant()/u;e<r&&(r=e,o=d)}}return a===i?o===i?s:o:a}_removeConstraintEffects(e,t){t.marker.type()===_.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===_.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n===void 0?this._objective.insertSymbol(e,-t):this._objective.insertRow(n.second,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first.type();if(r===_.Slack||r===_.Error)return n.first}return y}_makeSymbol(e){return new v(e,this._idTick++)}_cnMap=p();_rowMap=m();_varMap=h();_editMap=g();_infeasibleRows=[];_objective=new b;_artificial=null;_idTick=0};function f(e){let t=1e-8;return e<0?-e<t:e<t}function p(){return e()}function m(){return e()}function h(){return e()}function g(){return e()}var _;(function(e){e[e.Invalid=0]=`Invalid`,e[e.External=1]=`External`,e[e.Slack=2]=`Slack`,e[e.Error=3]=`Error`,e[e.Dummy=4]=`Dummy`})(_||={});var v=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type};let y=new v(_.Invalid,-1);var b=class t{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==_.Dummy)return!1;return!0}copy(){let e=new t(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);f(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let e=0,r=n.size();e<r;++e){let r=n.itemAt(e);this.insertSymbol(r.first,r.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let n=e.itemAt(t);n.second=-n.second}}solveFor(e){let t=this._cellMap,n=-1/t.erase(e).second;this._constant*=n;for(let e=0,r=t.size();e<r;++e)t.itemAt(e).second*=n}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t===void 0?0:t.second}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}_cellMap=e();_constant};export{r as a,s as i,l as n,c as r,d as t};
@@ -0,0 +1,15 @@
1
+ const{min:e,max:t}=Math;var n=(n,r=0,i=1)=>e(t(r,n),i),r=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=n(e[t],0,255)):t===3&&(e[t]=n(e[t],0,1));return e};const i={};for(let e of[`Boolean`,`Number`,`String`,`Function`,`Array`,`Date`,`RegExp`,`Undefined`,`Null`])i[`[object ${e}]`]=e.toLowerCase();function a(e){return i[Object.prototype.toString.call(e)]||`object`}var o=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):a(e[0])==`object`&&t?t.split(``).filter(t=>e[0][t]!==void 0).map(t=>e[0][t]):e[0].slice(0),s=e=>{if(e.length<2)return null;let t=e.length-1;return a(e[t])==`string`?e[t].toLowerCase():null};const{PI:c,min:l,max:u}=Math,d=e=>Math.round(e*100)/100,f=e=>Math.round(e*100)/100,p=c*2,m=c/3,h=c/180,g=180/c;function _(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var v={format:{},autodetect:[]},y=class{constructor(...e){let t=this;if(a(e[0])===`object`&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let n=s(e),i=!1;if(!n){i=!0,v.sorted||=(v.autodetect=v.autodetect.sort((e,t)=>t.p-e.p),!0);for(let t of v.autodetect)if(n=t.test(...e),n)break}if(v.format[n])t._rgb=r(v.format[n].apply(null,i?e:e.slice(0,-1)));else throw Error(`unknown format: `+e);t._rgb.length===3&&t._rgb.push(1)}toString(){return a(this.hex)==`function`?this.hex():`[${this._rgb.join(`,`)}]`}};const b=(...e)=>new y(...e);b.version=`3.2.0`;var x=b,S={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,laserlemon:`#ffff54`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrod:`#fafad2`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,maroon2:`#7f0000`,maroon3:`#b03060`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,purple2:`#7f007f`,purple3:`#a020f0`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`};const C=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,w=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/;var T=e=>{if(e.match(C)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16);return[t>>16,t>>8&255,t&255,1]}if(e.match(w)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((t&255)/255*100)/100]}throw Error(`unknown hex color: ${e}`)};const{round:E}=Math;var ee=(...e)=>{let[t,n,r,i]=o(e,`rgba`),a=s(e)||`auto`;i===void 0&&(i=1),a===`auto`&&(a=i<1?`rgba`:`rgb`),t=E(t),n=E(n),r=E(r);let c=`000000`+(t<<16|n<<8|r).toString(16);c=c.substr(c.length-6);let l=`0`+E(i*255).toString(16);switch(l=l.substr(l.length-2),a.toLowerCase()){case`rgba`:return`#${c}${l}`;case`argb`:return`#${l}${c}`;default:return`#${c}`}};y.prototype.name=function(){let e=ee(this._rgb,`rgb`);for(let t of Object.keys(S))if(S[t]===e)return t.toLowerCase();return e},v.format.named=e=>{if(e=e.toLowerCase(),S[e])return T(S[e]);throw Error(`unknown color name: `+e)},v.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&a(e)===`string`&&S[e.toLowerCase()])return`named`}}),y.prototype.alpha=function(e,t=!1){return e!==void 0&&a(e)===`number`?t?(this._rgb[3]=e,this):new y([this._rgb[0],this._rgb[1],this._rgb[2],e],`rgb`):this._rgb[3]},y.prototype.clipped=function(){return this._rgb._clipped||!1};const D={Kn:18,labWhitePoint:`d65`,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}};var O=D;const te=new Map([[`a`,[1.0985,.35585]],[`b`,[1.0985,.35585]],[`c`,[.98074,1.18232]],[`d50`,[.96422,.82521]],[`d55`,[.95682,.92149]],[`d65`,[.95047,1.08883]],[`e`,[1,1,1]],[`f2`,[.99186,.67393]],[`f7`,[.95041,1.08747]],[`f11`,[1.00962,.6435]],[`icc`,[.96422,.82521]]]);function k(e){let t=te.get(String(e).toLowerCase());if(!t)throw Error(`unknown Lab illuminant `+e);D.labWhitePoint=e,D.Xn=t[0],D.Zn=t[1]}function A(){return D.labWhitePoint}const ne=(...e)=>{e=o(e,`lab`);let[t,n,r]=e,[i,a,s]=re(t,n,r),[c,l,u]=ie(i,a,s);return[c,l,u,e.length>3?e[3]:1]},re=(e,t,n)=>{let{kE:r,kK:i,kKE:a,Xn:o,Yn:s,Zn:c}=O,l=(e+16)/116,u=.002*t+l,d=l-.005*n,f=u*u*u,p=d*d*d,m=f>r?f:(116*u-16)/i,h=e>a?((e+16)/116)**3:e/i,g=p>r?p:(116*d-16)/i;return[m*o,h*s,g*c]},j=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055)*t},ie=(e,t,n)=>{let{MtxAdaptMa:r,MtxAdaptMaI:i,MtxXYZ2RGB:a,RefWhiteRGB:o,Xn:s,Yn:c,Zn:l}=O,u=s*r.m00+c*r.m10+l*r.m20,d=s*r.m01+c*r.m11+l*r.m21,f=s*r.m02+c*r.m12+l*r.m22,p=o.X*r.m00+o.Y*r.m10+o.Z*r.m20,m=o.X*r.m01+o.Y*r.m11+o.Z*r.m21,h=o.X*r.m02+o.Y*r.m12+o.Z*r.m22,g=(e*r.m00+t*r.m10+n*r.m20)*(p/u),_=(e*r.m01+t*r.m11+n*r.m21)*(m/d),v=(e*r.m02+t*r.m12+n*r.m22)*(h/f),y=g*i.m00+_*i.m10+v*i.m20,b=g*i.m01+_*i.m11+v*i.m21,x=g*i.m02+_*i.m12+v*i.m22,S=j(y*a.m00+b*a.m10+x*a.m20),C=j(y*a.m01+b*a.m11+x*a.m21),w=j(y*a.m02+b*a.m12+x*a.m22);return[S*255,C*255,w*255]};var ae=ne;const oe=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=le(t,n,r),[l,u,d]=se(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function se(e,t,n){let{Xn:r,Yn:i,Zn:a,kE:o,kK:s}=O,c=e/r,l=t/i,u=n/a,d=c>o?c**(1/3):(s*c+16)/116,f=l>o?l**(1/3):(s*l+16)/116,p=u>o?u**(1/3):(s*u+16)/116;return[116*f-16,500*(d-f),200*(f-p)]}function ce(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:((e+.055)/1.055)**2.4)*t}const le=(e,t,n)=>{e=ce(e/255),t=ce(t/255),n=ce(n/255);let{MtxRGB2XYZ:r,MtxAdaptMa:i,MtxAdaptMaI:a,Xn:o,Yn:s,Zn:c,As:l,Bs:u,Cs:d}=O,f=e*r.m00+t*r.m10+n*r.m20,p=e*r.m01+t*r.m11+n*r.m21,m=e*r.m02+t*r.m12+n*r.m22,h=o*i.m00+s*i.m10+c*i.m20,g=o*i.m01+s*i.m11+c*i.m21,_=o*i.m02+s*i.m12+c*i.m22,v=f*i.m00+p*i.m10+m*i.m20,y=f*i.m01+p*i.m11+m*i.m21,b=f*i.m02+p*i.m12+m*i.m22;return v*=h/l,y*=g/u,b*=_/d,f=v*a.m00+y*a.m10+b*a.m20,p=v*a.m01+y*a.m11+b*a.m21,m=v*a.m02+y*a.m12+b*a.m22,[f,p,m]};var ue=oe;y.prototype.lab=function(){return ue(this._rgb)},Object.assign(x,{lab:(...e)=>new y(...e,`lab`),getLabWhitePoint:A,setLabWhitePoint:k}),v.format.lab=ae,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`lab`),a(e)===`array`&&e.length===3)return`lab`}}),y.prototype.darken=function(e=1){let t=this,n=t.lab();return n[0]-=O.Kn*e,new y(n,`lab`).alpha(t.alpha(),!0)},y.prototype.brighten=function(e=1){return this.darken(-e)},y.prototype.darker=y.prototype.darken,y.prototype.brighter=y.prototype.brighten,y.prototype.get=function(e){let[t,n]=e.split(`.`),r=this[t]();if(n){let e=t.indexOf(n)-(t.substr(0,2)===`ok`?2:0);if(e>-1)return r[e];throw Error(`unknown channel ${n} in mode ${t}`)}else return r};const{pow:de}=Math;y.prototype.luminance=function(e,t=`rgb`){if(e!==void 0&&a(e)===`number`){if(e===0)return new y([0,0,0,this._rgb[3]],`rgb`);if(e===1)return new y([255,255,255,this._rgb[3]],`rgb`);let n=this.luminance(),r=20,i=(n,a)=>{let o=n.interpolate(a,.5,t),s=o.luminance();return Math.abs(e-s)<1e-7||!r--?o:s>e?i(n,o):i(o,a)};return new y([...(n>e?i(new y([0,0,0]),this):i(this,new y([255,255,255]))).rgb(),this._rgb[3]])}return fe(...this._rgb.slice(0,3))};const fe=(e,t,n)=>(e=pe(e),t=pe(t),n=pe(n),.2126*e+.7152*t+.0722*n),pe=e=>(e/=255,e<=.03928?e/12.92:de((e+.055)/1.055,2.4));var M={},N=(e,t,n=.5,...r)=>{let i=r[0]||`lrgb`;if(!M[i]&&!r.length&&(i=Object.keys(M)[0]),!M[i])throw Error(`interpolation mode ${i} is not defined`);return a(e)!==`object`&&(e=new y(e)),a(t)!==`object`&&(t=new y(t)),M[i](e,t,n).alpha(e.alpha()+n*(t.alpha()-e.alpha()))};y.prototype.mix=y.prototype.interpolate=function(e,t=.5,...n){return N(this,e,t,...n)},y.prototype.premultiply=function(e=!1){let t=this._rgb,n=t[3];return e?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new y([t[0]*n,t[1]*n,t[2]*n,n],`rgb`)};const{sin:me,cos:he}=Math;var ge=(...e)=>{let[t,n,r]=o(e,`lch`);return isNaN(r)&&(r=0),r*=h,[t,he(r)*n,me(r)*n]},_e=(...e)=>{e=o(e,`lch`);let[t,n,r]=e,[i,a,s]=ge(t,n,r),[c,l,u]=ae(i,a,s);return[c,l,u,e.length>3?e[3]:1]},ve=(...e)=>_e(..._(o(e,`hcl`)));const{sqrt:ye,atan2:be,round:xe}=Math;var Se=(...e)=>{let[t,n,r]=o(e,`lab`),i=ye(n*n+r*r),a=(be(r,n)*g+360)%360;return xe(i*1e4)===0&&(a=NaN),[t,i,a]},Ce=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=ue(t,n,r),[l,u,d]=Se(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};y.prototype.lch=function(){return Ce(this._rgb)},y.prototype.hcl=function(){return _(Ce(this._rgb))},Object.assign(x,{lch:(...e)=>new y(...e,`lch`),hcl:(...e)=>new y(...e,`hcl`)}),v.format.lch=_e,v.format.hcl=ve,[`lch`,`hcl`].forEach(e=>v.autodetect.push({p:2,test:(...t)=>{if(t=o(t,e),a(t)===`array`&&t.length===3)return e}})),y.prototype.saturate=function(e=1){let t=this,n=t.lch();return n[1]+=O.Kn*e,n[1]<0&&(n[1]=0),new y(n,`lch`).alpha(t.alpha(),!0)},y.prototype.desaturate=function(e=1){return this.saturate(-e)},y.prototype.set=function(e,t,n=!1){let[r,i]=e.split(`.`),o=this[r]();if(i){let e=r.indexOf(i)-(r.substr(0,2)===`ok`?2:0);if(e>-1){if(a(t)==`string`)switch(t.charAt(0)){case`+`:o[e]+=+t;break;case`-`:o[e]+=+t;break;case`*`:o[e]*=+t.substr(1);break;case`/`:o[e]/=+t.substr(1);break;default:o[e]=+t}else if(a(t)===`number`)o[e]=t;else throw Error(`unsupported value for Color.set`);let i=new y(o,r);return n?(this._rgb=i._rgb,this):i}throw Error(`unknown channel ${i} in mode ${r}`)}else return o},y.prototype.tint=function(e=.5,...t){return N(this,`white`,e,...t)},y.prototype.shade=function(e=.5,...t){return N(this,`black`,e,...t)},M.rgb=(e,t,n)=>{let r=e._rgb,i=t._rgb;return new y(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`rgb`)};const{sqrt:we,pow:P}=Math;M.lrgb=(e,t,n)=>{let[r,i,a]=e._rgb,[o,s,c]=t._rgb;return new y(we(P(r,2)*(1-n)+P(o,2)*n),we(P(i,2)*(1-n)+P(s,2)*n),we(P(a,2)*(1-n)+P(c,2)*n),`rgb`)},M.lab=(e,t,n)=>{let r=e.lab(),i=t.lab();return new y(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`lab`)};var F=(e,t,n,r)=>{let i,a;r===`hsl`?(i=e.hsl(),a=t.hsl()):r===`hsv`?(i=e.hsv(),a=t.hsv()):r===`hcg`?(i=e.hcg(),a=t.hcg()):r===`hsi`?(i=e.hsi(),a=t.hsi()):r===`lch`||r===`hcl`?(r=`hcl`,i=e.hcl(),a=t.hcl()):r===`oklch`&&(i=e.oklch().reverse(),a=t.oklch().reverse());let o,s,c,l,u,d;(r.substr(0,1)===`h`||r===`oklch`)&&([o,c,u]=i,[s,l,d]=a);let f,p,m,h;return!isNaN(o)&&!isNaN(s)?(h=s>o&&s-o>180?s-(o+360):s<o&&o-s>180?s+360-o:s-o,p=o+n*h):isNaN(o)?isNaN(s)?p=NaN:(p=s,(u==1||u==0)&&r!=`hsv`&&(f=l)):(p=o,(d==1||d==0)&&r!=`hsv`&&(f=c)),f===void 0&&(f=c+n*(l-c)),m=u+n*(d-u),r===`oklch`?new y([m,f,p],r):new y([p,f,m],r)};const Te=(e,t,n)=>F(e,t,n,`lch`);M.lch=Te,M.hcl=Te;var Ee=e=>{if(a(e)==`number`&&e>=0&&e<=16777215)return[e>>16,e>>8&255,e&255,1];throw Error(`unknown num color: `+e)},De=(...e)=>{let[t,n,r]=o(e,`rgb`);return(t<<16)+(n<<8)+r};y.prototype.num=function(){return De(this._rgb)},Object.assign(x,{num:(...e)=>new y(...e,`num`)}),v.format.num=Ee,v.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&a(e[0])===`number`&&e[0]>=0&&e[0]<=16777215)return`num`}}),M.num=(e,t,n)=>{let r=e.num();return new y(r+n*(t.num()-r),`num`)};const{floor:Oe}=Math;var ke=(...e)=>{e=o(e,`hcg`);let[t,n,r]=e,i,a,s;r*=255;let c=n*255;if(n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=Oe(t),o=t-e,l=r*(1-n),u=l+c*(1-o),d=l+c*o,f=l+c;switch(e){case 0:[i,a,s]=[f,d,l];break;case 1:[i,a,s]=[u,f,l];break;case 2:[i,a,s]=[l,f,d];break;case 3:[i,a,s]=[l,u,f];break;case 4:[i,a,s]=[d,l,f];break;case 5:[i,a,s]=[f,l,u];break}}return[i,a,s,e.length>3?e[3]:1]},Ae=(...e)=>{let[t,n,r]=o(e,`rgb`),i=l(t,n,r),a=u(t,n,r),s=a-i,c=s*100/255,d=i/(255-s)*100,f;return s===0?f=NaN:(t===a&&(f=(n-r)/s),n===a&&(f=2+(r-t)/s),r===a&&(f=4+(t-n)/s),f*=60,f<0&&(f+=360)),[f,c,d]};y.prototype.hcg=function(){return Ae(this._rgb)},x.hcg=(...e)=>new y(...e,`hcg`),v.format.hcg=ke,v.autodetect.push({p:1,test:(...e)=>{if(e=o(e,`hcg`),a(e)===`array`&&e.length===3)return`hcg`}}),M.hcg=(e,t,n)=>F(e,t,n,`hcg`);const{cos:I}=Math;var je=(...e)=>{e=o(e,`hsi`);let[t,r,i]=e,a,s,c;return isNaN(t)&&(t=0),isNaN(r)&&(r=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(c=(1-r)/3,a=(1+r*I(p*t)/I(m-p*t))/3,s=1-(c+a)):t<2/3?(t-=1/3,a=(1-r)/3,s=(1+r*I(p*t)/I(m-p*t))/3,c=1-(a+s)):(t-=2/3,s=(1-r)/3,c=(1+r*I(p*t)/I(m-p*t))/3,a=1-(s+c)),a=n(i*a*3),s=n(i*s*3),c=n(i*c*3),[a*255,s*255,c*255,e.length>3?e[3]:1]};const{min:Me,sqrt:Ne,acos:Pe}=Math;var Fe=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i,a=Me(t,n,r),s=(t+n+r)/3,c=s>0?1-a/s:0;return c===0?i=NaN:(i=(t-n+(t-r))/2,i/=Ne((t-n)*(t-n)+(t-r)*(n-r)),i=Pe(i),r>n&&(i=p-i),i/=p),[i*360,c,s]};y.prototype.hsi=function(){return Fe(this._rgb)},x.hsi=(...e)=>new y(...e,`hsi`),v.format.hsi=je,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsi`),a(e)===`array`&&e.length===3)return`hsi`}}),M.hsi=(e,t,n)=>F(e,t,n,`hsi`);var Ie=(...e)=>{e=o(e,`hsl`);let[t,n,r]=e,i,a,s;if(n===0)i=a=s=r*255;else{let e=[0,0,0],o=[0,0,0],c=r<.5?r*(1+n):r+n-r*n,l=2*r-c,u=t/360;e[0]=u+1/3,e[1]=u,e[2]=u-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&--e[t],6*e[t]<1?o[t]=l+(c-l)*6*e[t]:2*e[t]<1?o[t]=c:3*e[t]<2?o[t]=l+(c-l)*(2/3-e[t])*6:o[t]=l;[i,a,s]=[o[0]*255,o[1]*255,o[2]*255]}return e.length>3?[i,a,s,e[3]]:[i,a,s,1]},Le=(...e)=>{e=o(e,`rgba`);let[t,n,r]=e;t/=255,n/=255,r/=255;let i=l(t,n,r),a=u(t,n,r),s=(a+i)/2,c,d;return a===i?(c=0,d=NaN):c=s<.5?(a-i)/(a+i):(a-i)/(2-a-i),t==a?d=(n-r)/(a-i):n==a?d=2+(r-t)/(a-i):r==a&&(d=4+(t-n)/(a-i)),d*=60,d<0&&(d+=360),e.length>3&&e[3]!==void 0?[d,c,s,e[3]]:[d,c,s]};y.prototype.hsl=function(){return Le(this._rgb)},x.hsl=(...e)=>new y(...e,`hsl`),v.format.hsl=Ie,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsl`),a(e)===`array`&&e.length===3)return`hsl`}}),M.hsl=(e,t,n)=>F(e,t,n,`hsl`);const{floor:Re}=Math;var ze=(...e)=>{e=o(e,`hsv`);let[t,n,r]=e,i,a,s;if(r*=255,n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=Re(t),o=t-e,c=r*(1-n),l=r*(1-n*o),u=r*(1-n*(1-o));switch(e){case 0:[i,a,s]=[r,u,c];break;case 1:[i,a,s]=[l,r,c];break;case 2:[i,a,s]=[c,r,u];break;case 3:[i,a,s]=[c,l,r];break;case 4:[i,a,s]=[u,c,r];break;case 5:[i,a,s]=[r,c,l];break}}return[i,a,s,e.length>3?e[3]:1]};const{min:Be,max:Ve}=Math;var He=(...e)=>{e=o(e,`rgb`);let[t,n,r]=e,i=Be(t,n,r),a=Ve(t,n,r),s=a-i,c,l,u;return u=a/255,a===0?(c=NaN,l=0):(l=s/a,t===a&&(c=(n-r)/s),n===a&&(c=2+(r-t)/s),r===a&&(c=4+(t-n)/s),c*=60,c<0&&(c+=360)),[c,l,u]};y.prototype.hsv=function(){return He(this._rgb)},x.hsv=(...e)=>new y(...e,`hsv`),v.format.hsv=ze,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsv`),a(e)===`array`&&e.length===3)return`hsv`}}),M.hsv=(e,t,n)=>F(e,t,n,`hsv`);function L(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>Array.isArray(e)?e.reduce((e,n,r)=>e+n*(t[r]||0),0):t.reduce((t,n)=>t+n*e,0)));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}const Ue=(...e)=>{e=o(e,`lab`);let[t,n,r,...i]=e,[a,s,c]=We([t,n,r]),[l,u,d]=ie(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function We(e){return L([[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],L([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],e).map(e=>e**3))}var Ge=Ue;const Ke=(...e)=>{let[t,n,r,...i]=o(e,`rgb`);return[...qe(le(t,n,r)),...i.length>0&&i[0]<1?[i[0]]:[]]};function qe(e){return L([[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],L([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e).map(e=>Math.cbrt(e)))}var Je=Ke;y.prototype.oklab=function(){return Je(this._rgb)},Object.assign(x,{oklab:(...e)=>new y(...e,`oklab`)}),v.format.oklab=Ge,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklab`),a(e)===`array`&&e.length===3)return`oklab`}}),M.oklab=(e,t,n)=>{let r=e.oklab(),i=t.oklab();return new y(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`oklab`)},M.oklch=(e,t,n)=>F(e,t,n,`oklch`);const{pow:Ye,sqrt:Xe,PI:Ze,cos:Qe,sin:$e,atan2:et}=Math;var tt=(e,t=`lrgb`,n=null)=>{let r=e.length;n||=Array.from(Array(r)).map(()=>1);let i=r/n.reduce(function(e,t){return e+t});if(n.forEach((e,t)=>{n[t]*=i}),e=e.map(e=>new y(e)),t===`lrgb`)return nt(e,n);let a=e.shift(),o=a.get(t),s=[],c=0,l=0;for(let e=0;e<o.length;e++)if(o[e]=(o[e]||0)*n[0],s.push(isNaN(o[e])?0:n[0]),t.charAt(e)===`h`&&!isNaN(o[e])){let t=o[e]/180*Ze;c+=Qe(t)*n[0],l+=$e(t)*n[0]}let u=a.alpha()*n[0];e.forEach((e,r)=>{let i=e.get(t);u+=e.alpha()*n[r+1];for(let e=0;e<o.length;e++)if(!isNaN(i[e]))if(s[e]+=n[r+1],t.charAt(e)===`h`){let t=i[e]/180*Ze;c+=Qe(t)*n[r+1],l+=$e(t)*n[r+1]}else o[e]+=i[e]*n[r+1]});for(let e=0;e<o.length;e++)if(t.charAt(e)===`h`){let t=et(l/s[e],c/s[e])/Ze*180;for(;t<0;)t+=360;for(;t>=360;)t-=360;o[e]=t}else o[e]=o[e]/s[e];return u/=r,new y(o,t).alpha(u>.99999?1:u,!0)};const nt=(e,t)=>{let n=e.length,i=[0,0,0,0];for(let r=0;r<e.length;r++){let a=e[r],o=t[r]/n,s=a._rgb;i[0]+=Ye(s[0],2)*o,i[1]+=Ye(s[1],2)*o,i[2]+=Ye(s[2],2)*o,i[3]+=s[3]*o}return i[0]=Xe(i[0]),i[1]=Xe(i[1]),i[2]=Xe(i[2]),i[3]>.9999999&&(i[3]=1),new y(r(i))},{pow:rt}=Math;function R(e){let t=`rgb`,r=x(`#ccc`),i=0,o=[0,1],s=[0,1],c=[],l=[0,0],u=!1,d=[],f=!1,p=0,m=1,h=!1,g={},_=!0,v=1,y=function(e){if(e||=[`#fff`,`#000`],e&&a(e)===`string`&&x.brewer&&x.brewer[e.toLowerCase()]&&(e=x.brewer[e.toLowerCase()]),a(e)===`array`){e.length===1&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;t<e.length;t++)e[t]=x(e[t]);c.length=0;for(let t=0;t<e.length;t++)c.push(t/(e.length-1))}return T(),d=e},b=function(e){if(u!=null){let t=u.length-1,n=0;for(;n<t&&e>=u[n];)n++;return n-1}return 0},S=e=>e,C=e=>e,w=function(e,i){let o,s;if(i??=!1,isNaN(e)||e===null)return r;s=i?e:u&&u.length>2?b(e)/(u.length-2):m===p?1:(e-p)/(m-p),s=C(s),i||(s=S(s)),v!==1&&(s=rt(s,v)),s=l[0]+s*(1-l[0]-l[1]),s=n(s,0,1);let f=Math.floor(s*1e4);if(_&&g[f])o=g[f];else{if(a(d)===`array`)for(let e=0;e<c.length;e++){let n=c[e];if(s<=n){o=d[e];break}if(s>=n&&e===c.length-1){o=d[e];break}if(s>n&&s<c[e+1]){s=(s-n)/(c[e+1]-n),o=x.interpolate(d[e],d[e+1],s,t);break}}else a(d)===`function`&&(o=d(s));_&&(g[f]=o)}return o};var T=()=>g={};y(e);let E=function(e){let t=x(w(e));return f&&t[f]?t[f]():t};return E.classes=function(e){if(e!=null){if(a(e)===`array`)u=e,o=[e[0],e[e.length-1]];else{let t=x.analyze(o);u=e===0?[t.min,t.max]:x.limits(t,`e`,e)}return E}return u},E.domain=function(e){if(!arguments.length)return s;s=e.slice(0),p=e[0],m=e[e.length-1],c=[];let t=d.length;if(e.length===t&&p!==m)for(let t of Array.from(e))c.push((t-p)/(m-p));else{for(let e=0;e<t;e++)c.push(e/(t-1));if(e.length>2){let t=e.map((t,n)=>n/(e.length-1)),n=e.map(e=>(e-p)/(m-p));n.every((e,n)=>t[n]===e)||(C=e=>{if(e<=0||e>=1)return e;let r=0;for(;e>=n[r+1];)r++;let i=(e-n[r])/(n[r+1]-n[r]);return t[r]+i*(t[r+1]-t[r])})}}return o=[p,m],E},E.mode=function(e){return arguments.length?(t=e,T(),E):t},E.range=function(e,t){return y(e,t),E},E.out=function(e){return f=e,E},E.spread=function(e){return arguments.length?(i=e,E):i},E.correctLightness=function(e){return e??=!0,h=e,T(),S=h?function(e){let t=w(0,!0).lab()[0],n=w(1,!0).lab()[0],r=t>n,i=w(e,!0).lab()[0],a=t+(n-t)*e,o=i-a,s=0,c=1,l=20;for(;Math.abs(o)>.01&&l-- >0;)(function(){return r&&(o*=-1),o<0?(s=e,e+=(c-e)*.5):(c=e,e+=(s-e)*.5),i=w(e,!0).lab()[0],o=i-a})();return e}:e=>e,E},E.padding=function(e){return e==null?l:(a(e)===`number`&&(e=[e,e]),l=e,E)},E.colors=function(t,n){arguments.length<2&&(n=`hex`);let r=[];if(arguments.length===0)r=d.slice(0);else if(t===1)r=[E(.5)];else if(t>1){let e=o[0],n=o[1]-e;r=it(0,t,!1).map(r=>E(e+r/(t-1)*n))}else{e=[];let t=[];if(u&&u.length>2)for(let e=1,n=u.length,r=1<=n;r?e<n:e>n;r?e++:e--)t.push((u[e-1]+u[e])*.5);else t=o;r=t.map(e=>E(e))}return x[n]&&(r=r.map(e=>e[n]())),r},E.cache=function(e){return e==null?_:(_=e,E)},E.gamma=function(e){return e==null?v:(v=e,E)},E.nodata=function(e){return e==null?r:(r=x(e),E)},E}function it(e,t,n){let r=[],i=e<t,a=n?i?t+1:t-1:t;for(let t=e;i?t<a:t>a;i?t++:t--)r.push(t);return r}const at=function(e){let t=[1,1];for(let n=1;n<e;n++){let e=[1];for(let n=1;n<=t.length;n++)e[n]=(t[n]||0)+t[n-1];t=e}return t},ot=function(e){let t,n,r,i;if(e=e.map(e=>new y(e)),e.length===2)[n,r]=e.map(e=>e.lab()),t=function(e){return new y([0,1,2].map(t=>n[t]+e*(r[t]-n[t])),`lab`)};else if(e.length===3)[n,r,i]=e.map(e=>e.lab()),t=function(e){return new y([0,1,2].map(t=>(1-e)*(1-e)*n[t]+2*(1-e)*e*r[t]+e*e*i[t]),`lab`)};else if(e.length===4){let a;[n,r,i,a]=e.map(e=>e.lab()),t=function(e){return new y([0,1,2].map(t=>(1-e)*(1-e)*(1-e)*n[t]+3*(1-e)*(1-e)*e*r[t]+3*(1-e)*e*e*i[t]+e*e*e*a[t]),`lab`)}}else if(e.length>=5){let n,r,i;n=e.map(e=>e.lab()),i=e.length-1,r=at(i),t=function(e){let t=1-e;return new y([0,1,2].map(a=>n.reduce((n,o,s)=>n+r[s]*t**(i-s)*e**s*o[a],0)),`lab`)}}else throw RangeError(`No point in running bezier with only one color.`);return t};var st=e=>{let t=ot(e);return t.scale=()=>R(t),t};const{round:ct}=Math;y.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(ct)},y.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,n)=>n<3?e===!1?t:ct(t):t)},Object.assign(x,{rgb:(...e)=>new y(...e,`rgb`)}),v.format.rgb=(...e)=>{let t=o(e,`rgba`);return t[3]===void 0&&(t[3]=1),t},v.autodetect.push({p:3,test:(...e)=>{if(e=o(e,`rgba`),a(e)===`array`&&(e.length===3||e.length===4&&a(e[3])==`number`&&e[3]>=0&&e[3]<=1))return`rgb`}});const z=(e,t,n)=>{if(!z[n])throw Error(`unknown blend mode `+n);return z[n](e,t)},B=e=>(t,n)=>{let r=x(n).rgb(),i=x(t).rgb();return x.rgb(e(r,i))},V=e=>(t,n)=>{let r=[];return r[0]=e(t[0],n[0]),r[1]=e(t[1],n[1]),r[2]=e(t[2],n[2]),r};z.normal=B(V(e=>e)),z.multiply=B(V((e,t)=>e*t/255)),z.screen=B(V((e,t)=>255*(1-(1-e/255)*(1-t/255)))),z.overlay=B(V((e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)))),z.darken=B(V((e,t)=>e>t?t:e)),z.lighten=B(V((e,t)=>e>t?e:t)),z.dodge=B(V((e,t)=>e===255?255:(e=t/255*255/(1-e/255),e>255?255:e))),z.burn=B(V((e,t)=>255*(1-(1-t/255)/(e/255))));var lt=z;const{pow:ut,sin:dt,cos:ft}=Math;function pt(e=300,t=-1.5,n=1,i=1,o=[0,1]){let s=0,c;a(o)===`array`?c=o[1]-o[0]:(c=0,o=[o,o]);let l=function(a){let l=p*((e+120)/360+t*a),u=ut(o[0]+c*a,i),d=(s===0?n:n[0]+a*s)*u*(1-u)/2,f=ft(l),m=dt(l),h=u+d*(-.14861*f+1.78277*m),g=u+d*(-.29227*f-.90649*m),_=u+1.97294*f*d;return x(r([h*255,g*255,_*255,1]))};return l.start=function(t){return t==null?e:(e=t,l)},l.rotations=function(e){return e==null?t:(t=e,l)},l.gamma=function(e){return e==null?i:(i=e,l)},l.hue=function(e){return e==null?n:(n=e,a(n)===`array`?(s=n[1]-n[0],s===0&&(n=n[1])):s=0,l)},l.lightness=function(e){return e==null?o:(a(e)===`array`?(o=e,c=e[1]-e[0]):(o=[e,e],c=0),l)},l.scale=()=>x.scale(l),l.hue(n),l}const{floor:mt,random:ht}=Math;var gt=(e=ht)=>{let t=`#`;for(let n=0;n<6;n++)t+=`0123456789abcdef`.charAt(mt(e()*16));return new y(t,`hex`)};const{log:_t,pow:vt,floor:yt,abs:bt}=Math;function xt(e,t=null){let n={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return a(e)===`object`&&(e=Object.values(e)),e.forEach(e=>{t&&a(e)===`object`&&(e=e[t]),e!=null&&!isNaN(e)&&(n.values.push(e),n.sum+=e,e<n.min&&(n.min=e),e>n.max&&(n.max=e),n.count+=1)}),n.domain=[n.min,n.max],n.limits=(e,t)=>St(n,e,t),n}function St(e,t=`equal`,n=7){a(e)==`array`&&(e=xt(e));let{min:r,max:i}=e,o=e.values.sort((e,t)=>e-t);if(n===1)return[r,i];let s=[];if(t.substr(0,1)===`c`&&(s.push(r),s.push(i)),t.substr(0,1)===`e`){s.push(r);for(let e=1;e<n;e++)s.push(r+e/n*(i-r));s.push(i)}else if(t.substr(0,1)===`l`){if(r<=0)throw Error(`Logarithmic scales are only possible for values > 0`);let e=Math.LOG10E*_t(r),t=Math.LOG10E*_t(i);s.push(r);for(let r=1;r<n;r++)s.push(vt(10,e+r/n*(t-e)));s.push(i)}else if(t.substr(0,1)===`q`){s.push(r);for(let e=1;e<n;e++){let t=(o.length-1)*e/n,r=yt(t);if(r===t)s.push(o[r]);else{let e=t-r;s.push(o[r]*(1-e)+o[r+1]*e)}}s.push(i)}else if(t.substr(0,1)===`k`){let e,t=o.length,a=Array(t),c=Array(n),l=!0,u=0,d=null;d=[],d.push(r);for(let e=1;e<n;e++)d.push(r+e/n*(i-r));for(d.push(i);l;){for(let e=0;e<n;e++)c[e]=0;for(let e=0;e<t;e++){let t=o[e],r=Number.MAX_VALUE,i;for(let o=0;o<n;o++){let n=bt(d[o]-t);n<r&&(r=n,i=o),c[i]++,a[e]=i}}let r=Array(n);for(let e=0;e<n;e++)r[e]=null;for(let n=0;n<t;n++)e=a[n],r[e]===null?r[e]=o[n]:r[e]+=o[n];for(let e=0;e<n;e++)r[e]*=1/c[e];l=!1;for(let e=0;e<n;e++)if(r[e]!==d[e]){l=!0;break}d=r,u++,u>200&&(l=!1)}let f={};for(let e=0;e<n;e++)f[e]=[];for(let n=0;n<t;n++)e=a[n],f[e].push(o[n]);let p=[];for(let e=0;e<n;e++)p.push(f[e][0]),p.push(f[e][f[e].length-1]);p=p.sort((e,t)=>e-t),s.push(p[0]);for(let e=1;e<p.length;e+=2){let t=p[e];!isNaN(t)&&s.indexOf(t)===-1&&s.push(t)}}return s}var Ct=(e,t)=>{e=new y(e),t=new y(t);let n=e.luminance(),r=t.luminance();return n>r?(n+.05)/(r+.05):(r+.05)/(n+.05)};
2
+ /**
3
+ * @license
4
+ *
5
+ * The APCA contrast prediction algorithm is based of the formulas published
6
+ * in the APCA-1.0.98G specification by Myndex. The specification is available at:
7
+ * https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
8
+ *
9
+ * Note that the APCA implementation is still beta, so please update to
10
+ * future versions of chroma.js when they become available.
11
+ *
12
+ * You can read more about the APCA Readability Criterion at
13
+ * https://readtech.org/ARC/
14
+ */
15
+ const wt=.027,Tt=1.14,H=.022,Et=1.414;var Dt=(e,t)=>{e=new y(e),t=new y(t),e.alpha()<1&&(e=N(t,e,e.alpha(),`rgb`));let n=Ot(...e.rgb()),r=Ot(...t.rgb()),i=n>=H?n:n+(H-n)**+Et,a=r>=H?r:r+(H-r)**+Et,o=a**.56-i**.57,s=a**.65-i**.62,c=Math.abs(a-i)<5e-4?0:i<a?o*Tt:s*Tt;return(Math.abs(c)<.1?0:c>0?c-wt:c+wt)*100};function Ot(e,t,n){return .2126729*(e/255)**2.4+.7151522*(t/255)**2.4+.072175*(n/255)**2.4}const{sqrt:U,pow:W,min:kt,max:At,atan2:jt,abs:Mt,cos:G,sin:Nt,exp:Pt,PI:Ft}=Math;function It(e,t,n=1,r=1,i=1){var a=function(e){return 360*e/(2*Ft)},o=function(e){return 2*Ft*e/360};e=new y(e),t=new y(t);let[s,c,l]=Array.from(e.lab()),[u,d,f]=Array.from(t.lab()),p=(s+u)/2,m=(U(W(c,2)+W(l,2))+U(W(d,2)+W(f,2)))/2,h=.5*(1-U(W(m,7)/(W(m,7)+W(25,7)))),g=c*(1+h),_=d*(1+h),v=U(W(g,2)+W(l,2)),b=U(W(_,2)+W(f,2)),x=(v+b)/2,S=a(jt(l,g)),C=a(jt(f,_)),w=S>=0?S:S+360,T=C>=0?C:C+360,E=Mt(w-T)>180?(w+T+360)/2:(w+T)/2,ee=1-.17*G(o(E-30))+.24*G(o(2*E))+.32*G(o(3*E+6))-.2*G(o(4*E-63)),D=T-w;D=Mt(D)<=180?D:T<=w?D+360:D-360,D=2*U(v*b)*Nt(o(D)/2);let O=u-s,te=b-v,k=1+.015*W(p-50,2)/U(20+W(p-50,2)),A=1+.045*x,ne=1+.015*x*ee,re=30*Pt(-W((E-275)/25,2)),j=-(2*U(W(x,7)/(W(x,7)+W(25,7))))*Nt(2*o(re));return At(0,kt(100,U(W(O/(n*k),2)+W(te/(r*A),2)+W(D/(i*ne),2)+j*(te/(r*A))*(D/(i*ne)))))}function Lt(e,t,n=`lab`){e=new y(e),t=new y(t);let r=e.get(n),i=t.get(n),a=0;for(let e in r){let t=(r[e]||0)-(i[e]||0);a+=t*t}return Math.sqrt(a)}var Rt=(...e)=>{try{return new y(...e),!0}catch{return!1}},zt={cool(){return R([x.hsl(180,1,.9),x.hsl(250,.7,.4)])},hot(){return R([`#000`,`#f00`,`#ff0`,`#fff`],[0,.25,.75,1]).mode(`rgb`)}};const Bt={OrRd:[`#fff7ec`,`#fee8c8`,`#fdd49e`,`#fdbb84`,`#fc8d59`,`#ef6548`,`#d7301f`,`#b30000`,`#7f0000`],PuBu:[`#fff7fb`,`#ece7f2`,`#d0d1e6`,`#a6bddb`,`#74a9cf`,`#3690c0`,`#0570b0`,`#045a8d`,`#023858`],BuPu:[`#f7fcfd`,`#e0ecf4`,`#bfd3e6`,`#9ebcda`,`#8c96c6`,`#8c6bb1`,`#88419d`,`#810f7c`,`#4d004b`],Oranges:[`#fff5eb`,`#fee6ce`,`#fdd0a2`,`#fdae6b`,`#fd8d3c`,`#f16913`,`#d94801`,`#a63603`,`#7f2704`],BuGn:[`#f7fcfd`,`#e5f5f9`,`#ccece6`,`#99d8c9`,`#66c2a4`,`#41ae76`,`#238b45`,`#006d2c`,`#00441b`],YlOrBr:[`#ffffe5`,`#fff7bc`,`#fee391`,`#fec44f`,`#fe9929`,`#ec7014`,`#cc4c02`,`#993404`,`#662506`],YlGn:[`#ffffe5`,`#f7fcb9`,`#d9f0a3`,`#addd8e`,`#78c679`,`#41ab5d`,`#238443`,`#006837`,`#004529`],Reds:[`#fff5f0`,`#fee0d2`,`#fcbba1`,`#fc9272`,`#fb6a4a`,`#ef3b2c`,`#cb181d`,`#a50f15`,`#67000d`],RdPu:[`#fff7f3`,`#fde0dd`,`#fcc5c0`,`#fa9fb5`,`#f768a1`,`#dd3497`,`#ae017e`,`#7a0177`,`#49006a`],Greens:[`#f7fcf5`,`#e5f5e0`,`#c7e9c0`,`#a1d99b`,`#74c476`,`#41ab5d`,`#238b45`,`#006d2c`,`#00441b`],YlGnBu:[`#ffffd9`,`#edf8b1`,`#c7e9b4`,`#7fcdbb`,`#41b6c4`,`#1d91c0`,`#225ea8`,`#253494`,`#081d58`],Purples:[`#fcfbfd`,`#efedf5`,`#dadaeb`,`#bcbddc`,`#9e9ac8`,`#807dba`,`#6a51a3`,`#54278f`,`#3f007d`],GnBu:[`#f7fcf0`,`#e0f3db`,`#ccebc5`,`#a8ddb5`,`#7bccc4`,`#4eb3d3`,`#2b8cbe`,`#0868ac`,`#084081`],Greys:[`#ffffff`,`#f0f0f0`,`#d9d9d9`,`#bdbdbd`,`#969696`,`#737373`,`#525252`,`#252525`,`#000000`],YlOrRd:[`#ffffcc`,`#ffeda0`,`#fed976`,`#feb24c`,`#fd8d3c`,`#fc4e2a`,`#e31a1c`,`#bd0026`,`#800026`],PuRd:[`#f7f4f9`,`#e7e1ef`,`#d4b9da`,`#c994c7`,`#df65b0`,`#e7298a`,`#ce1256`,`#980043`,`#67001f`],Blues:[`#f7fbff`,`#deebf7`,`#c6dbef`,`#9ecae1`,`#6baed6`,`#4292c6`,`#2171b5`,`#08519c`,`#08306b`],PuBuGn:[`#fff7fb`,`#ece2f0`,`#d0d1e6`,`#a6bddb`,`#67a9cf`,`#3690c0`,`#02818a`,`#016c59`,`#014636`],Viridis:[`#440154`,`#482777`,`#3f4a8a`,`#31678e`,`#26838f`,`#1f9d8a`,`#6cce5a`,`#b6de2b`,`#fee825`],Spectral:[`#9e0142`,`#d53e4f`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#e6f598`,`#abdda4`,`#66c2a5`,`#3288bd`,`#5e4fa2`],RdYlGn:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#d9ef8b`,`#a6d96a`,`#66bd63`,`#1a9850`,`#006837`],RdBu:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#f7f7f7`,`#d1e5f0`,`#92c5de`,`#4393c3`,`#2166ac`,`#053061`],PiYG:[`#8e0152`,`#c51b7d`,`#de77ae`,`#f1b6da`,`#fde0ef`,`#f7f7f7`,`#e6f5d0`,`#b8e186`,`#7fbc41`,`#4d9221`,`#276419`],PRGn:[`#40004b`,`#762a83`,`#9970ab`,`#c2a5cf`,`#e7d4e8`,`#f7f7f7`,`#d9f0d3`,`#a6dba0`,`#5aae61`,`#1b7837`,`#00441b`],RdYlBu:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee090`,`#ffffbf`,`#e0f3f8`,`#abd9e9`,`#74add1`,`#4575b4`,`#313695`],BrBG:[`#543005`,`#8c510a`,`#bf812d`,`#dfc27d`,`#f6e8c3`,`#f5f5f5`,`#c7eae5`,`#80cdc1`,`#35978f`,`#01665e`,`#003c30`],RdGy:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#ffffff`,`#e0e0e0`,`#bababa`,`#878787`,`#4d4d4d`,`#1a1a1a`],PuOr:[`#7f3b08`,`#b35806`,`#e08214`,`#fdb863`,`#fee0b6`,`#f7f7f7`,`#d8daeb`,`#b2abd2`,`#8073ac`,`#542788`,`#2d004b`],Set2:[`#66c2a5`,`#fc8d62`,`#8da0cb`,`#e78ac3`,`#a6d854`,`#ffd92f`,`#e5c494`,`#b3b3b3`],Accent:[`#7fc97f`,`#beaed4`,`#fdc086`,`#ffff99`,`#386cb0`,`#f0027f`,`#bf5b17`,`#666666`],Set1:[`#e41a1c`,`#377eb8`,`#4daf4a`,`#984ea3`,`#ff7f00`,`#ffff33`,`#a65628`,`#f781bf`,`#999999`],Set3:[`#8dd3c7`,`#ffffb3`,`#bebada`,`#fb8072`,`#80b1d3`,`#fdb462`,`#b3de69`,`#fccde5`,`#d9d9d9`,`#bc80bd`,`#ccebc5`,`#ffed6f`],Dark2:[`#1b9e77`,`#d95f02`,`#7570b3`,`#e7298a`,`#66a61e`,`#e6ab02`,`#a6761d`,`#666666`],Paired:[`#a6cee3`,`#1f78b4`,`#b2df8a`,`#33a02c`,`#fb9a99`,`#e31a1c`,`#fdbf6f`,`#ff7f00`,`#cab2d6`,`#6a3d9a`,`#ffff99`,`#b15928`],Pastel2:[`#b3e2cd`,`#fdcdac`,`#cbd5e8`,`#f4cae4`,`#e6f5c9`,`#fff2ae`,`#f1e2cc`,`#cccccc`],Pastel1:[`#fbb4ae`,`#b3cde3`,`#ccebc5`,`#decbe4`,`#fed9a6`,`#ffffcc`,`#e5d8bd`,`#fddaec`,`#f2f2f2`]},Vt=Object.keys(Bt),Ht=new Map(Vt.map(e=>[e.toLowerCase(),e]));var Ut=typeof Proxy==`function`?new Proxy(Bt,{get(e,t){let n=t.toLowerCase();if(Ht.has(n))return e[Ht.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(Vt)}}):Bt,Wt=(...e)=>{e=o(e,`cmyk`);let[t,n,r,i]=e,a=e.length>4?e[4]:1;return i===1?[0,0,0,a]:[t>=1?0:255*(1-t)*(1-i),n>=1?0:255*(1-n)*(1-i),r>=1?0:255*(1-r)*(1-i),a]};const{max:Gt}=Math;var Kt=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i=1-Gt(t,Gt(n,r)),a=i<1?1/(1-i):0;return[(1-t-i)*a,(1-n-i)*a,(1-r-i)*a,i]};y.prototype.cmyk=function(){return Kt(this._rgb)},Object.assign(x,{cmyk:(...e)=>new y(...e,`cmyk`)}),v.format.cmyk=Wt,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`cmyk`),a(e)===`array`&&e.length===4)return`cmyk`}});var qt=(...e)=>{let t=o(e,`hsla`),n=s(e)||`lsa`;return t[0]=d(t[0]||0)+`deg`,t[1]=d(t[1]*100)+`%`,t[2]=d(t[2]*100)+`%`,n===`hsla`||t.length>3&&t[3]<1?(t[3]=`/ `+(t.length>3?t[3]:1),n=`hsla`):t.length=3,`${n.substr(0,3)}(${t.join(` `)})`},Jt=(...e)=>{let t=o(e,`lab`),n=s(e)||`lab`;return t[0]=d(t[0])+`%`,t[1]=d(t[1]),t[2]=d(t[2]),n===`laba`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(` `)})`},Yt=(...e)=>{let t=o(e,`lch`),n=s(e)||`lab`;return t[0]=d(t[0])+`%`,t[1]=d(t[1]),t[2]=isNaN(t[2])?`none`:d(t[2])+`deg`,n===`lcha`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(` `)})`},Xt=(...e)=>{let t=o(e,`lab`);return t[0]=d(t[0]*100)+`%`,t[1]=f(t[1]),t[2]=f(t[2]),t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(` `)})`},Zt=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=Je(t,n,r),[l,u,d]=Se(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},Qt=(...e)=>{let t=o(e,`lch`);return t[0]=d(t[0]*100)+`%`,t[1]=f(t[1]),t[2]=isNaN(t[2])?`none`:d(t[2])+`deg`,t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(` `)})`};const{round:$t}=Math;var en=(...e)=>{let t=o(e,`rgba`),n=s(e)||`rgb`;if(n.substr(0,3)===`hsl`)return qt(Le(t),n);if(n.substr(0,3)===`lab`){let e=A();k(`d50`);let r=Jt(ue(t),n);return k(e),r}if(n.substr(0,3)===`lch`){let e=A();k(`d50`);let r=Yt(Ce(t),n);return k(e),r}return n.substr(0,5)===`oklab`?Xt(Je(t)):n.substr(0,5)===`oklch`?Qt(Zt(t)):(t[0]=$t(t[0]),t[1]=$t(t[1]),t[2]=$t(t[2]),(n===`rgba`||t.length>3&&t[3]<1)&&(t[3]=`/ `+(t.length>3?t[3]:1),n=`rgba`),`${n.substr(0,3)}(${t.slice(0,n===`rgb`?3:4).join(` `)})`)},tn=(...e)=>{e=o(e,`lch`);let[t,n,r,...i]=e,[a,s,c]=ge(t,n,r),[l,u,d]=Ge(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};const K=`((?:-?\\d+)|(?:-?\\d+(?:\\.\\d+)?)%|none)`,q=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%?)|none)`,J=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%)|none)`,nn=`\\s*,\\s*`,rn=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:deg)?)|none)`,Y=`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?`,an=RegExp(`^rgba?\\(\\s*`+[K,K,K].join(`\\s+`)+Y+`\\)$`),on=RegExp(`^rgb\\(\\s*`+[K,K,K].join(nn)+`\\s*\\)$`),sn=RegExp(`^rgba\\(\\s*`+[K,K,K,q].join(nn)+`\\s*\\)$`),cn=RegExp(`^hsla?\\(\\s*`+[rn,J,J].join(`\\s+`)+Y+`\\)$`),ln=RegExp(`^hsl?\\(\\s*`+[rn,J,J].join(nn)+`\\s*\\)$`),un=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,dn=RegExp(`^lab\\(\\s*`+[q,q,q].join(`\\s+`)+Y+`\\)$`),fn=RegExp(`^lch\\(\\s*`+[q,q,rn].join(`\\s+`)+Y+`\\)$`),pn=RegExp(`^oklab\\(\\s*`+[q,q,q].join(`\\s+`)+Y+`\\)$`),mn=RegExp(`^oklch\\(\\s*`+[q,q,rn].join(`\\s+`)+Y+`\\)$`),{round:hn}=Math,X=e=>e.map((e,t)=>t<=2?n(hn(e),0,255):e),Z=(e,t=0,n=100,r=!1)=>(typeof e==`string`&&e.endsWith(`%`)&&(e=parseFloat(e.substring(0,e.length-1))/100,e=r?t+(e+1)*.5*(n-t):t+e*(n-t)),+e),Q=(e,t)=>e===`none`?t:e,gn=e=>{if(e=e.toLowerCase().trim(),e===`transparent`)return[0,0,0,0];let t;if(v.format.named)try{return v.format.named(e)}catch{}if((t=e.match(an))||(t=e.match(on))){let e=t.slice(1,4);for(let t=0;t<3;t++)e[t]=+Z(Q(e[t],0),0,255);e=X(e);let n=t[4]===void 0?1:+Z(t[4],0,1);return e[3]=n,e}if(t=e.match(sn)){let e=t.slice(1,5);for(let t=0;t<4;t++)e[t]=+Z(e[t],0,255);return e}if((t=e.match(cn))||(t=e.match(ln))){let e=t.slice(1,4);e[0]=+Q(e[0].replace(`deg`,``),0),e[1]=Z(Q(e[1],0),0,100)*.01,e[2]=Z(Q(e[2],0),0,100)*.01;let n=X(Ie(e));return n[3]=t[4]===void 0?1:+Z(t[4],0,1),n}if(t=e.match(un)){let e=t.slice(1,4);e[1]*=.01,e[2]*=.01;let n=Ie(e);for(let e=0;e<3;e++)n[e]=hn(n[e]);return n[3]=+t[4],n}if(t=e.match(dn)){let e=t.slice(1,4);e[0]=Z(Q(e[0],0),0,100),e[1]=Z(Q(e[1],0),-125,125,!0),e[2]=Z(Q(e[2],0),-125,125,!0);let n=A();k(`d50`);let r=X(ae(e));return k(n),r[3]=t[4]===void 0?1:+Z(t[4],0,1),r}if(t=e.match(fn)){let e=t.slice(1,4);e[0]=Z(e[0],0,100),e[1]=Z(Q(e[1],0),0,150,!1),e[2]=+Q(e[2].replace(`deg`,``),0);let n=A();k(`d50`);let r=X(_e(e));return k(n),r[3]=t[4]===void 0?1:+Z(t[4],0,1),r}if(t=e.match(pn)){let e=t.slice(1,4);e[0]=Z(Q(e[0],0),0,1),e[1]=Z(Q(e[1],0),-.4,.4,!0),e[2]=Z(Q(e[2],0),-.4,.4,!0);let n=X(Ge(e));return n[3]=t[4]===void 0?1:+Z(t[4],0,1),n}if(t=e.match(mn)){let e=t.slice(1,4);e[0]=Z(Q(e[0],0),0,1),e[1]=Z(Q(e[1],0),0,.4,!1),e[2]=+Q(e[2].replace(`deg`,``),0);let n=X(tn(e));return n[3]=t[4]===void 0?1:+Z(t[4],0,1),n}};gn.test=e=>an.test(e)||cn.test(e)||dn.test(e)||fn.test(e)||pn.test(e)||mn.test(e)||on.test(e)||sn.test(e)||ln.test(e)||un.test(e)||e===`transparent`;var _n=gn;y.prototype.css=function(e){return en(this._rgb,e)},x.css=(...e)=>new y(...e,`css`),v.format.css=_n,v.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&a(e)===`string`&&_n.test(e))return`css`}}),v.format.gl=(...e)=>{let t=o(e,`rgba`);return t[0]*=255,t[1]*=255,t[2]*=255,t},x.gl=(...e)=>new y(...e,`gl`),y.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]},y.prototype.hex=function(e){return ee(this._rgb,e)},x.hex=(...e)=>new y(...e,`hex`),v.format.hex=T,v.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&a(e)===`string`&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return`hex`}});const{log:vn}=Math;var yn=e=>{let t=e/100,n,r,i;return t<66?(n=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*vn(r),i=t<20?0:-254.76935184120902+.8274096064007395*(i=t-10)+115.67994401066147*vn(i)):(n=351.97690566805693+.114206453784165*(n=t-55)-40.25366309332127*vn(n),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*vn(r),i=255),[n,r,i,1]};const{round:bn}=Math;var xn=(...e)=>{let t=o(e,`rgb`),n=t[0],r=t[2],i=1e3,a=4e4,s;for(;a-i>.4;){s=(a+i)*.5;let e=yn(s);e[2]/e[0]>=r/n?a=s:i=s}return bn(s)};y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return xn(this._rgb)};const Sn=(...e)=>new y(...e,`temp`);Object.assign(x,{temp:Sn,kelvin:Sn,temperature:Sn}),v.format.temp=v.format.kelvin=v.format.temperature=yn,y.prototype.oklch=function(){return Zt(this._rgb)},Object.assign(x,{oklch:(...e)=>new y(...e,`oklch`)}),v.format.oklch=tn,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklch`),a(e)===`array`&&e.length===3)return`oklch`}}),Object.assign(x,{analyze:xt,average:tt,bezier:st,blend:lt,brewer:Ut,Color:y,colors:S,contrast:Ct,contrastAPCA:Dt,cubehelix:pt,deltaE:It,distance:Lt,input:v,interpolate:N,limits:St,mix:N,random:gt,scale:R,scales:zt,valid:Rt});var $=x;const Cn=[.96,.907,.805,.697,.605,.547,.518,.445,.395,.34],wn=[.32,.16,.08,.04,0,0,.04,.08,.16,.32];function Tn(e){let t=e.get(`hsl.l`);return Cn.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function En(e){let t=$(e),n=Tn(t),r=Cn.findIndex(e=>e===n),i=Cn.map(e=>t.set(`hsl.l`,e)).map(e=>$(e)).map((e,t)=>{let n=wn[t]-wn[r];return n>=0?e.saturate(n):e.desaturate(n*-1)});return i[r]=$(e),{baseColorIndex:r,colors:i}}function Dn(e){return En(e).colors.map(e=>e.hex())}export{$ as n,Dn as t};