@tanstack/history 1.7.1 → 1.12.16

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.
@@ -1,4838 +0,0 @@
1
-
2
- <!DOCTYPE html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <meta http-equiv="X-UA-Compatible" content="ie=edge" />
8
- <title>Rollup Visualizer</title>
9
- <style>
10
- :root {
11
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
12
- "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
13
- --background-color: #2b2d42;
14
- --text-color: #edf2f4;
15
- }
16
-
17
- html {
18
- box-sizing: border-box;
19
- }
20
-
21
- *,
22
- *:before,
23
- *:after {
24
- box-sizing: inherit;
25
- }
26
-
27
- html {
28
- background-color: var(--background-color);
29
- color: var(--text-color);
30
- font-family: var(--font-family);
31
- }
32
-
33
- body {
34
- padding: 0;
35
- margin: 0;
36
- }
37
-
38
- html,
39
- body {
40
- height: 100%;
41
- width: 100%;
42
- overflow: hidden;
43
- }
44
-
45
- body {
46
- display: flex;
47
- flex-direction: column;
48
- }
49
-
50
- svg {
51
- vertical-align: middle;
52
- width: 100%;
53
- height: 100%;
54
- max-height: 100vh;
55
- }
56
-
57
- main {
58
- flex-grow: 1;
59
- height: 100vh;
60
- padding: 20px;
61
- }
62
-
63
- .tooltip {
64
- position: absolute;
65
- z-index: 1070;
66
- border: 2px solid;
67
- border-radius: 5px;
68
- padding: 5px;
69
- white-space: nowrap;
70
- font-size: 0.875rem;
71
- background-color: var(--background-color);
72
- color: var(--text-color);
73
- }
74
-
75
- .tooltip-hidden {
76
- visibility: hidden;
77
- opacity: 0;
78
- }
79
-
80
- .sidebar {
81
- position: fixed;
82
- top: 0;
83
- left: 0;
84
- right: 0;
85
- display: flex;
86
- flex-direction: row;
87
- font-size: 0.7rem;
88
- align-items: center;
89
- margin: 0 50px;
90
- height: 20px;
91
- }
92
-
93
- .size-selectors {
94
- display: flex;
95
- flex-direction: row;
96
- align-items: center;
97
- }
98
-
99
- .size-selector {
100
- display: flex;
101
- flex-direction: row;
102
- align-items: center;
103
- justify-content: center;
104
- margin-right: 1rem;
105
- }
106
- .size-selector input {
107
- margin: 0 0.3rem 0 0;
108
- }
109
-
110
- .filters {
111
- flex: 1;
112
- display: flex;
113
- flex-direction: row;
114
- align-items: center;
115
- }
116
-
117
- .module-filters {
118
- display: flex;
119
- flex-grow: 1;
120
- }
121
-
122
- .module-filter {
123
- display: flex;
124
- flex-direction: row;
125
- align-items: center;
126
- justify-content: center;
127
- flex: 1;
128
- }
129
- .module-filter input {
130
- flex: 1;
131
- height: 1rem;
132
- padding: 0.01rem;
133
- font-size: 0.7rem;
134
- margin-left: 0.3rem;
135
- }
136
- .module-filter + .module-filter {
137
- margin-left: 0.5rem;
138
- }
139
- </style>
140
- </head>
141
- <body>
142
- <main></main>
143
- <script>
144
- /*<!--*/
145
- var drawChart = (function (exports) {
146
- 'use strict';
147
-
148
- var n,l$1,u$2,i$1,o$1,r$1,f$2,e$1,c$1={},s$1=[],a$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,h$1=Array.isArray;function v$1(n,l){for(var u in l)n[u]=l[u];return n}function p$1(n){var l=n.parentNode;l&&l.removeChild(n);}function y$1(l,u,t){var i,o,r,f={};for(r in u)"key"==r?i=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return d$1(l,f,i,o,null)}function d$1(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u$2:r,__i:-1,__u:0};return null==r&&null!=l$1.vnode&&l$1.vnode(f),f}function g$1(n){return n.children}function b$1(n,l){this.props=n,this.context=l;}function m$1(n,l){if(null==l)return n.__?m$1(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?m$1(n):null}function k$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k$1(n)}}function w$1(n){(!n.__d&&(n.__d=!0)&&i$1.push(n)&&!x.__r++||o$1!==l$1.debounceRendering)&&((o$1=l$1.debounceRendering)||r$1)(x);}function x(){var n,u,t,o,r,e,c,s,a;for(i$1.sort(f$2);n=i$1.shift();)n.__d&&(u=i$1.length,o=void 0,e=(r=(t=n).__v).__e,s=[],a=[],(c=t.__P)&&((o=v$1({},r)).__v=r.__v+1,l$1.vnode&&l$1.vnode(o),L(c,o,r,t.__n,void 0!==c.ownerSVGElement,32&r.__u?[e]:null,s,null==e?m$1(r):e,!!(32&r.__u),a),o.__.__k[o.__i]=o,M(s,o,a),o.__e!=e&&k$1(o)),i$1.length>u&&i$1.sort(f$2));x.__r=0;}function C(n,l,u,t,i,o,r,f,e,a,h){var v,p,y,d,_,g=t&&t.__k||s$1,b=l.length;for(u.__d=e,P(u,l,g),e=u.__d,v=0;v<b;v++)null!=(y=u.__k[v])&&"boolean"!=typeof y&&"function"!=typeof y&&(p=-1===y.__i?c$1:g[y.__i]||c$1,y.__i=v,L(n,y,p,i,o,r,f,e,a,h),d=y.__e,y.ref&&p.ref!=y.ref&&(p.ref&&z$1(p.ref,null,y),h.push(y.ref,y.__c||d,y)),null==_&&null!=d&&(_=d),65536&y.__u||p.__k===y.__k?e=S(y,e,n):"function"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=_;}function P(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)null!=(i=n.__k[t]=null==(i=l[t])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?d$1(null,i,null,null,i):h$1(i)?d$1(g$1,{children:i},null,null,null):i.__b>0?d$1(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=H(i,u,r=t+a,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,"function"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f===r+1?a++:f>r?s>e-r?a+=f-r:a--:a=f<r&&f==r-1?f-r:0,f!==t+a&&(i.__u|=65536))):(o=u[t])&&null==o.key&&o.__e&&(o.__e==n.__d&&(n.__d=m$1(o)),N(o,o,!1),u[t]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=m$1(o)),N(o,o));}function S(n,l,u){var t,i;if("function"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=S(t[i],l,u));return l}return n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e),l&&l.nextSibling}function H(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type)return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--;}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++;}}return -1}function I(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||a$1.test(l)?u:u+"px";}function T$1(n,l,u,t,i){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof t&&(n.style.cssText=t=""),t)for(l in t)u&&l in u||I(n.style,l,"");if(u)for(l in u)t&&u[l]===t[l]||I(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/,"$1")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=Date.now(),n.addEventListener(l,o?D:A,o)):n.removeEventListener(l,o?D:A,o);else {if(i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&"rowSpan"!==l&&"colSpan"!==l&&"role"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u));}}function A(n){var u=this.l[n.type+!1];if(n.t){if(n.t<=u.u)return}else n.t=Date.now();return u(l$1.event?l$1.event(n):n)}function D(n){return this.l[n.type+!0](l$1.event?l$1.event(n):n)}function L(n,u,t,i,o,r,f,e,c,s){var a,p,y,d,_,m,k,w,x,P,S,$,H,I,T,A=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l$1.__b)&&a(u);n:if("function"==typeof A)try{if(w=u.props,x=(a=A.contextType)&&i[a.__c],P=a?x?x.props.value:a.__:i,t.__c?k=(p=u.__c=t.__c).__=p.__E:("prototype"in A&&A.prototype.render?u.__c=p=new A(w,P):(u.__c=p=new b$1(w,P),p.constructor=A,p.render=O),x&&x.sub(p),p.props=w,p.state||(p.state={}),p.context=P,p.__n=i,y=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=A.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=v$1({},p.__s)),v$1(p.__s,A.getDerivedStateFromProps(w,p.__s))),d=p.props,_=p.state,p.__v=u,y)null==A.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else {if(null==A.getDerivedStateFromProps&&w!==d&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,P),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,P)||u.__v===t.__v)){for(u.__v!==t.__v&&(p.props=w,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.forEach(function(n){n&&(n.__=u);}),S=0;S<p._sb.length;S++)p.__h.push(p._sb[S]);p._sb=[],p.__h.length&&f.push(p);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,P),null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(d,_,m);});}if(p.context=P,p.props=w,p.__P=n,p.__e=!1,$=l$1.__r,H=0,"prototype"in A&&A.prototype.render){for(p.state=p.__s,p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),I=0;I<p._sb.length;I++)p.__h.push(p._sb[I]);p._sb=[];}else do{p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),p.state=p.__s;}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=v$1(v$1({},i),p.getChildContext())),y||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(d,_)),C(n,h$1(T=null!=a&&a.type===g$1&&null==a.key?a.props.children:a)?T:[T],u,t,i,o,r,f,e,c,s),p.base=u.__e,u.__u&=-161,p.__h.length&&f.push(p),k&&(p.__E=p.__=null);}catch(n){u.__v=null,c||null!=r?(u.__e=e,u.__u|=c?160:32,r[r.indexOf(e)]=null):(u.__e=t.__e,u.__k=t.__k),l$1.__e(n,u,t);}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=j$1(t.__e,u,t,i,o,r,f,c,s);(a=l$1.diffed)&&a(u);}function M(n,u,t){u.__d=void 0;for(var i=0;i<t.length;i++)z$1(t[i],t[++i],t[++i]);l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function j$1(l,u,t,i,o,r,f,e,s){var a,v,y,d,_,g,b,k=t.props,w=u.props,x=u.type;if("svg"===x&&(o=!0),null!=r)for(a=0;a<r.length;a++)if((_=r[a])&&"setAttribute"in _==!!x&&(x?_.localName===x:3===_.nodeType)){l=_,r[a]=null;break}if(null==l){if(null===x)return document.createTextNode(w);l=o?document.createElementNS("http://www.w3.org/2000/svg",x):document.createElement(x,w.is&&w),r=null,e=!1;}if(null===x)k===w||e&&l.data===w||(l.data=w);else {if(r=r&&n.call(l.childNodes),k=t.props||c$1,!e&&null!=r)for(k={},a=0;a<l.attributes.length;a++)k[(_=l.attributes[a]).name]=_.value;for(a in k)_=k[a],"children"==a||("dangerouslySetInnerHTML"==a?y=_:"key"===a||a in w||T$1(l,a,null,_,o));for(a in w)_=w[a],"children"==a?d=_:"dangerouslySetInnerHTML"==a?v=_:"value"==a?g=_:"checked"==a?b=_:"key"===a||e&&"function"!=typeof _||k[a]===_||T$1(l,a,_,k[a],o);if(v)e||y&&(v.__html===y.__html||v.__html===l.innerHTML)||(l.innerHTML=v.__html),u.__k=[];else if(y&&(l.innerHTML=""),C(l,h$1(d)?d:[d],u,t,i,o&&"foreignObject"!==x,r,f,r?r[0]:t.__k&&m$1(t,0),e,s),null!=r)for(a=r.length;a--;)null!=r[a]&&p$1(r[a]);e||(a="value",void 0!==g&&(g!==l[a]||"progress"===x&&!g||"option"===x&&g!==k[a])&&T$1(l,a,g,k[a],!1),a="checked",void 0!==b&&b!==l[a]&&T$1(l,a,b,k[a],!1));}return l}function z$1(n,u,t){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,t);}}function N(n,u,t){var i,o;if(l$1.unmount&&l$1.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||z$1(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount();}catch(n){l$1.__e(n,u);}i.base=i.__P=null,n.__c=void 0;}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&N(i[o],u,t||"function"!=typeof n.type);t||null==n.__e||p$1(n.__e),n.__=n.__e=n.__d=void 0;}function O(n,l,u){return this.constructor(n,u)}function q$1(u,t,i){var o,r,f,e;l$1.__&&l$1.__(u,t),r=(o="function"==typeof i)?null:i&&i.__k||t.__k,f=[],e=[],L(t,u=(!o&&i||t).__k=y$1(g$1,null,[u]),r||c$1,c$1,void 0!==t.ownerSVGElement,!o&&i?[i]:r?null:t.firstChild?n.call(t.childNodes):null,f,!o&&i?i:r?r.__e:t.firstChild,o,e),M(f,u,e);}function F$1(n,l){var u={__c:l="__cC"+e$1++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=[],(t={})[l]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,w$1(n);});},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=s$1.slice,l$1={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l;}throw n}},u$2=0,b$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=v$1({},this.state),"function"==typeof n&&(n=n(v$1({},u),this.props)),n&&v$1(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),w$1(this));},b$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),w$1(this));},b$1.prototype.render=g$1,i$1=[],r$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f$2=function(n,l){return n.__v.__b-l.__v.__b},x.__r=0,e$1=0;
149
-
150
- var f$1=0;function u$1(e,t,n,o,i,u){var a,c,p={};for(c in t)"ref"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--f$1,__i:-1,__u:0,__source:i,__self:u};if("function"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return l$1.vnode&&l$1.vnode(l),l}
151
-
152
- function count$1(node) {
153
- var sum = 0,
154
- children = node.children,
155
- i = children && children.length;
156
- if (!i) sum = 1;
157
- else while (--i >= 0) sum += children[i].value;
158
- node.value = sum;
159
- }
160
-
161
- function node_count() {
162
- return this.eachAfter(count$1);
163
- }
164
-
165
- function node_each(callback, that) {
166
- let index = -1;
167
- for (const node of this) {
168
- callback.call(that, node, ++index, this);
169
- }
170
- return this;
171
- }
172
-
173
- function node_eachBefore(callback, that) {
174
- var node = this, nodes = [node], children, i, index = -1;
175
- while (node = nodes.pop()) {
176
- callback.call(that, node, ++index, this);
177
- if (children = node.children) {
178
- for (i = children.length - 1; i >= 0; --i) {
179
- nodes.push(children[i]);
180
- }
181
- }
182
- }
183
- return this;
184
- }
185
-
186
- function node_eachAfter(callback, that) {
187
- var node = this, nodes = [node], next = [], children, i, n, index = -1;
188
- while (node = nodes.pop()) {
189
- next.push(node);
190
- if (children = node.children) {
191
- for (i = 0, n = children.length; i < n; ++i) {
192
- nodes.push(children[i]);
193
- }
194
- }
195
- }
196
- while (node = next.pop()) {
197
- callback.call(that, node, ++index, this);
198
- }
199
- return this;
200
- }
201
-
202
- function node_find(callback, that) {
203
- let index = -1;
204
- for (const node of this) {
205
- if (callback.call(that, node, ++index, this)) {
206
- return node;
207
- }
208
- }
209
- }
210
-
211
- function node_sum(value) {
212
- return this.eachAfter(function(node) {
213
- var sum = +value(node.data) || 0,
214
- children = node.children,
215
- i = children && children.length;
216
- while (--i >= 0) sum += children[i].value;
217
- node.value = sum;
218
- });
219
- }
220
-
221
- function node_sort(compare) {
222
- return this.eachBefore(function(node) {
223
- if (node.children) {
224
- node.children.sort(compare);
225
- }
226
- });
227
- }
228
-
229
- function node_path(end) {
230
- var start = this,
231
- ancestor = leastCommonAncestor(start, end),
232
- nodes = [start];
233
- while (start !== ancestor) {
234
- start = start.parent;
235
- nodes.push(start);
236
- }
237
- var k = nodes.length;
238
- while (end !== ancestor) {
239
- nodes.splice(k, 0, end);
240
- end = end.parent;
241
- }
242
- return nodes;
243
- }
244
-
245
- function leastCommonAncestor(a, b) {
246
- if (a === b) return a;
247
- var aNodes = a.ancestors(),
248
- bNodes = b.ancestors(),
249
- c = null;
250
- a = aNodes.pop();
251
- b = bNodes.pop();
252
- while (a === b) {
253
- c = a;
254
- a = aNodes.pop();
255
- b = bNodes.pop();
256
- }
257
- return c;
258
- }
259
-
260
- function node_ancestors() {
261
- var node = this, nodes = [node];
262
- while (node = node.parent) {
263
- nodes.push(node);
264
- }
265
- return nodes;
266
- }
267
-
268
- function node_descendants() {
269
- return Array.from(this);
270
- }
271
-
272
- function node_leaves() {
273
- var leaves = [];
274
- this.eachBefore(function(node) {
275
- if (!node.children) {
276
- leaves.push(node);
277
- }
278
- });
279
- return leaves;
280
- }
281
-
282
- function node_links() {
283
- var root = this, links = [];
284
- root.each(function(node) {
285
- if (node !== root) { // Don’t include the root’s parent, if any.
286
- links.push({source: node.parent, target: node});
287
- }
288
- });
289
- return links;
290
- }
291
-
292
- function* node_iterator() {
293
- var node = this, current, next = [node], children, i, n;
294
- do {
295
- current = next.reverse(), next = [];
296
- while (node = current.pop()) {
297
- yield node;
298
- if (children = node.children) {
299
- for (i = 0, n = children.length; i < n; ++i) {
300
- next.push(children[i]);
301
- }
302
- }
303
- }
304
- } while (next.length);
305
- }
306
-
307
- function hierarchy(data, children) {
308
- if (data instanceof Map) {
309
- data = [undefined, data];
310
- if (children === undefined) children = mapChildren;
311
- } else if (children === undefined) {
312
- children = objectChildren;
313
- }
314
-
315
- var root = new Node$1(data),
316
- node,
317
- nodes = [root],
318
- child,
319
- childs,
320
- i,
321
- n;
322
-
323
- while (node = nodes.pop()) {
324
- if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
325
- node.children = childs;
326
- for (i = n - 1; i >= 0; --i) {
327
- nodes.push(child = childs[i] = new Node$1(childs[i]));
328
- child.parent = node;
329
- child.depth = node.depth + 1;
330
- }
331
- }
332
- }
333
-
334
- return root.eachBefore(computeHeight);
335
- }
336
-
337
- function node_copy() {
338
- return hierarchy(this).eachBefore(copyData);
339
- }
340
-
341
- function objectChildren(d) {
342
- return d.children;
343
- }
344
-
345
- function mapChildren(d) {
346
- return Array.isArray(d) ? d[1] : null;
347
- }
348
-
349
- function copyData(node) {
350
- if (node.data.value !== undefined) node.value = node.data.value;
351
- node.data = node.data.data;
352
- }
353
-
354
- function computeHeight(node) {
355
- var height = 0;
356
- do node.height = height;
357
- while ((node = node.parent) && (node.height < ++height));
358
- }
359
-
360
- function Node$1(data) {
361
- this.data = data;
362
- this.depth =
363
- this.height = 0;
364
- this.parent = null;
365
- }
366
-
367
- Node$1.prototype = hierarchy.prototype = {
368
- constructor: Node$1,
369
- count: node_count,
370
- each: node_each,
371
- eachAfter: node_eachAfter,
372
- eachBefore: node_eachBefore,
373
- find: node_find,
374
- sum: node_sum,
375
- sort: node_sort,
376
- path: node_path,
377
- ancestors: node_ancestors,
378
- descendants: node_descendants,
379
- leaves: node_leaves,
380
- links: node_links,
381
- copy: node_copy,
382
- [Symbol.iterator]: node_iterator
383
- };
384
-
385
- function required(f) {
386
- if (typeof f !== "function") throw new Error;
387
- return f;
388
- }
389
-
390
- function constantZero() {
391
- return 0;
392
- }
393
-
394
- function constant$1(x) {
395
- return function() {
396
- return x;
397
- };
398
- }
399
-
400
- function roundNode(node) {
401
- node.x0 = Math.round(node.x0);
402
- node.y0 = Math.round(node.y0);
403
- node.x1 = Math.round(node.x1);
404
- node.y1 = Math.round(node.y1);
405
- }
406
-
407
- function treemapDice(parent, x0, y0, x1, y1) {
408
- var nodes = parent.children,
409
- node,
410
- i = -1,
411
- n = nodes.length,
412
- k = parent.value && (x1 - x0) / parent.value;
413
-
414
- while (++i < n) {
415
- node = nodes[i], node.y0 = y0, node.y1 = y1;
416
- node.x0 = x0, node.x1 = x0 += node.value * k;
417
- }
418
- }
419
-
420
- function treemapSlice(parent, x0, y0, x1, y1) {
421
- var nodes = parent.children,
422
- node,
423
- i = -1,
424
- n = nodes.length,
425
- k = parent.value && (y1 - y0) / parent.value;
426
-
427
- while (++i < n) {
428
- node = nodes[i], node.x0 = x0, node.x1 = x1;
429
- node.y0 = y0, node.y1 = y0 += node.value * k;
430
- }
431
- }
432
-
433
- var phi = (1 + Math.sqrt(5)) / 2;
434
-
435
- function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
436
- var rows = [],
437
- nodes = parent.children,
438
- row,
439
- nodeValue,
440
- i0 = 0,
441
- i1 = 0,
442
- n = nodes.length,
443
- dx, dy,
444
- value = parent.value,
445
- sumValue,
446
- minValue,
447
- maxValue,
448
- newRatio,
449
- minRatio,
450
- alpha,
451
- beta;
452
-
453
- while (i0 < n) {
454
- dx = x1 - x0, dy = y1 - y0;
455
-
456
- // Find the next non-empty node.
457
- do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
458
- minValue = maxValue = sumValue;
459
- alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
460
- beta = sumValue * sumValue * alpha;
461
- minRatio = Math.max(maxValue / beta, beta / minValue);
462
-
463
- // Keep adding nodes while the aspect ratio maintains or improves.
464
- for (; i1 < n; ++i1) {
465
- sumValue += nodeValue = nodes[i1].value;
466
- if (nodeValue < minValue) minValue = nodeValue;
467
- if (nodeValue > maxValue) maxValue = nodeValue;
468
- beta = sumValue * sumValue * alpha;
469
- newRatio = Math.max(maxValue / beta, beta / minValue);
470
- if (newRatio > minRatio) { sumValue -= nodeValue; break; }
471
- minRatio = newRatio;
472
- }
473
-
474
- // Position and record the row orientation.
475
- rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
476
- if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
477
- else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
478
- value -= sumValue, i0 = i1;
479
- }
480
-
481
- return rows;
482
- }
483
-
484
- var squarify = (function custom(ratio) {
485
-
486
- function squarify(parent, x0, y0, x1, y1) {
487
- squarifyRatio(ratio, parent, x0, y0, x1, y1);
488
- }
489
-
490
- squarify.ratio = function(x) {
491
- return custom((x = +x) > 1 ? x : 1);
492
- };
493
-
494
- return squarify;
495
- })(phi);
496
-
497
- function treemap() {
498
- var tile = squarify,
499
- round = false,
500
- dx = 1,
501
- dy = 1,
502
- paddingStack = [0],
503
- paddingInner = constantZero,
504
- paddingTop = constantZero,
505
- paddingRight = constantZero,
506
- paddingBottom = constantZero,
507
- paddingLeft = constantZero;
508
-
509
- function treemap(root) {
510
- root.x0 =
511
- root.y0 = 0;
512
- root.x1 = dx;
513
- root.y1 = dy;
514
- root.eachBefore(positionNode);
515
- paddingStack = [0];
516
- if (round) root.eachBefore(roundNode);
517
- return root;
518
- }
519
-
520
- function positionNode(node) {
521
- var p = paddingStack[node.depth],
522
- x0 = node.x0 + p,
523
- y0 = node.y0 + p,
524
- x1 = node.x1 - p,
525
- y1 = node.y1 - p;
526
- if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
527
- if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
528
- node.x0 = x0;
529
- node.y0 = y0;
530
- node.x1 = x1;
531
- node.y1 = y1;
532
- if (node.children) {
533
- p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
534
- x0 += paddingLeft(node) - p;
535
- y0 += paddingTop(node) - p;
536
- x1 -= paddingRight(node) - p;
537
- y1 -= paddingBottom(node) - p;
538
- if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
539
- if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
540
- tile(node, x0, y0, x1, y1);
541
- }
542
- }
543
-
544
- treemap.round = function(x) {
545
- return arguments.length ? (round = !!x, treemap) : round;
546
- };
547
-
548
- treemap.size = function(x) {
549
- return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
550
- };
551
-
552
- treemap.tile = function(x) {
553
- return arguments.length ? (tile = required(x), treemap) : tile;
554
- };
555
-
556
- treemap.padding = function(x) {
557
- return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
558
- };
559
-
560
- treemap.paddingInner = function(x) {
561
- return arguments.length ? (paddingInner = typeof x === "function" ? x : constant$1(+x), treemap) : paddingInner;
562
- };
563
-
564
- treemap.paddingOuter = function(x) {
565
- return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
566
- };
567
-
568
- treemap.paddingTop = function(x) {
569
- return arguments.length ? (paddingTop = typeof x === "function" ? x : constant$1(+x), treemap) : paddingTop;
570
- };
571
-
572
- treemap.paddingRight = function(x) {
573
- return arguments.length ? (paddingRight = typeof x === "function" ? x : constant$1(+x), treemap) : paddingRight;
574
- };
575
-
576
- treemap.paddingBottom = function(x) {
577
- return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant$1(+x), treemap) : paddingBottom;
578
- };
579
-
580
- treemap.paddingLeft = function(x) {
581
- return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant$1(+x), treemap) : paddingLeft;
582
- };
583
-
584
- return treemap;
585
- }
586
-
587
- var treemapResquarify = (function custom(ratio) {
588
-
589
- function resquarify(parent, x0, y0, x1, y1) {
590
- if ((rows = parent._squarify) && (rows.ratio === ratio)) {
591
- var rows,
592
- row,
593
- nodes,
594
- i,
595
- j = -1,
596
- n,
597
- m = rows.length,
598
- value = parent.value;
599
-
600
- while (++j < m) {
601
- row = rows[j], nodes = row.children;
602
- for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
603
- if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += (y1 - y0) * row.value / value : y1);
604
- else treemapSlice(row, x0, y0, value ? x0 += (x1 - x0) * row.value / value : x1, y1);
605
- value -= row.value;
606
- }
607
- } else {
608
- parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
609
- rows.ratio = ratio;
610
- }
611
- }
612
-
613
- resquarify.ratio = function(x) {
614
- return custom((x = +x) > 1 ? x : 1);
615
- };
616
-
617
- return resquarify;
618
- })(phi);
619
-
620
- const isModuleTree = (mod) => "children" in mod;
621
-
622
- let count = 0;
623
- class Id {
624
- constructor(id) {
625
- this._id = id;
626
- const url = new URL(window.location.href);
627
- url.hash = id;
628
- this._href = url.toString();
629
- }
630
- get id() {
631
- return this._id;
632
- }
633
- get href() {
634
- return this._href;
635
- }
636
- toString() {
637
- return `url(${this.href})`;
638
- }
639
- }
640
- function generateUniqueId(name) {
641
- count += 1;
642
- const id = ["O", name, count].filter(Boolean).join("-");
643
- return new Id(id);
644
- }
645
-
646
- const LABELS = {
647
- renderedLength: "Rendered",
648
- gzipLength: "Gzip",
649
- brotliLength: "Brotli",
650
- };
651
- const getAvailableSizeOptions = (options) => {
652
- const availableSizeProperties = ["renderedLength"];
653
- if (options.gzip) {
654
- availableSizeProperties.push("gzipLength");
655
- }
656
- if (options.brotli) {
657
- availableSizeProperties.push("brotliLength");
658
- }
659
- return availableSizeProperties;
660
- };
661
-
662
- var t,r,u,i,o=0,f=[],c=[],e=l$1.__b,a=l$1.__r,v=l$1.diffed,l=l$1.__c,m=l$1.unmount;function d(t,u){l$1.__h&&l$1.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:c}),i.__[t]}function h(n){return o=1,s(B,n)}function s(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):B(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}));}],o.__c=r,!r.u)){var f=function(n,t,r){if(!o.__c.__H)return !0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return !n.__N}))return !c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0);}}),!(!i&&o.__c.props===n)&&(!c||c.call(this,n,t,r))};r.u=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u;}e&&e.call(this,n,t,r);},r.shouldComponentUpdate=f;}return o.__N||o.__}function p(u,i){var o=d(t++,3);!l$1.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o));}function y(u,i){var o=d(t++,4);!l$1.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o));}function _(n){return o=5,F(function(){return {current:n}},[])}function F(n,r){var u=d(t++,7);return z(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function b(){for(var t;t=f.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(k),t.__H.__h.forEach(w),t.__H.__h=[];}catch(r){t.__H.__h=[],l$1.__e(r,t.__v);}}l$1.__b=function(n){r=null,e&&e(n);},l$1.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0;})):(i.__h.forEach(k),i.__h.forEach(w),i.__h=[],t=0)),u=r;},l$1.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==f.push(o)&&i===l$1.requestAnimationFrame||((i=l$1.requestAnimationFrame)||j)(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c;})),u=r=null;},l$1.__c=function(t,r){r.some(function(t){try{t.__h.forEach(k),t.__h=t.__h.filter(function(n){return !n.__||w(n)});}catch(u){r.some(function(n){n.__h&&(n.__h=[]);}),r=[],l$1.__e(u,t.__v);}}),l&&l(t,r);},l$1.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{k(n);}catch(n){r=n;}}),u.__H=void 0,r&&l$1.__e(r,u.__v));};var g="function"==typeof requestAnimationFrame;function j(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n);},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r));}function k(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t;}function w(n){var t=r;n.__c=n.__(),r=t;}function z(n,t){return !n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function B(n,t){return "function"==typeof t?t(n):t}
663
-
664
- const PLACEHOLDER = "bundle-*:**/file/**,**/file**, bundle-*:";
665
- const SideBar = ({ availableSizeProperties, sizeProperty, setSizeProperty, onExcludeChange, onIncludeChange, }) => {
666
- const [includeValue, setIncludeValue] = h("");
667
- const [excludeValue, setExcludeValue] = h("");
668
- const handleSizePropertyChange = (sizeProp) => () => {
669
- if (sizeProp !== sizeProperty) {
670
- setSizeProperty(sizeProp);
671
- }
672
- };
673
- const handleIncludeChange = (event) => {
674
- const value = event.currentTarget.value;
675
- setIncludeValue(value);
676
- onIncludeChange(value);
677
- };
678
- const handleExcludeChange = (event) => {
679
- const value = event.currentTarget.value;
680
- setExcludeValue(value);
681
- onExcludeChange(value);
682
- };
683
- return (u$1("aside", { className: "sidebar", children: [u$1("div", { className: "size-selectors", children: availableSizeProperties.length > 1 &&
684
- availableSizeProperties.map((sizeProp) => {
685
- const id = `selector-${sizeProp}`;
686
- return (u$1("div", { className: "size-selector", children: [u$1("input", { type: "radio", id: id, checked: sizeProp === sizeProperty, onChange: handleSizePropertyChange(sizeProp) }), u$1("label", { htmlFor: id, children: LABELS[sizeProp] })] }, sizeProp));
687
- }) }), u$1("div", { className: "module-filters", children: [u$1("div", { className: "module-filter", children: [u$1("label", { htmlFor: "module-filter-exclude", children: "Exclude" }), u$1("input", { type: "text", id: "module-filter-exclude", value: excludeValue, onInput: handleExcludeChange, placeholder: PLACEHOLDER })] }), u$1("div", { className: "module-filter", children: [u$1("label", { htmlFor: "module-filter-include", children: "Include" }), u$1("input", { type: "text", id: "module-filter-include", value: includeValue, onInput: handleIncludeChange, placeholder: PLACEHOLDER })] })] })] }));
688
- };
689
-
690
- function getDefaultExportFromCjs (x) {
691
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
692
- }
693
-
694
- var utils$3 = {};
695
-
696
- const WIN_SLASH = '\\\\/';
697
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
698
-
699
- /**
700
- * Posix glob regex
701
- */
702
-
703
- const DOT_LITERAL = '\\.';
704
- const PLUS_LITERAL = '\\+';
705
- const QMARK_LITERAL = '\\?';
706
- const SLASH_LITERAL = '\\/';
707
- const ONE_CHAR = '(?=.)';
708
- const QMARK = '[^/]';
709
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
710
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
711
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
712
- const NO_DOT = `(?!${DOT_LITERAL})`;
713
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
714
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
715
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
716
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
717
- const STAR = `${QMARK}*?`;
718
- const SEP = '/';
719
-
720
- const POSIX_CHARS = {
721
- DOT_LITERAL,
722
- PLUS_LITERAL,
723
- QMARK_LITERAL,
724
- SLASH_LITERAL,
725
- ONE_CHAR,
726
- QMARK,
727
- END_ANCHOR,
728
- DOTS_SLASH,
729
- NO_DOT,
730
- NO_DOTS,
731
- NO_DOT_SLASH,
732
- NO_DOTS_SLASH,
733
- QMARK_NO_DOT,
734
- STAR,
735
- START_ANCHOR,
736
- SEP
737
- };
738
-
739
- /**
740
- * Windows glob regex
741
- */
742
-
743
- const WINDOWS_CHARS = {
744
- ...POSIX_CHARS,
745
-
746
- SLASH_LITERAL: `[${WIN_SLASH}]`,
747
- QMARK: WIN_NO_SLASH,
748
- STAR: `${WIN_NO_SLASH}*?`,
749
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
750
- NO_DOT: `(?!${DOT_LITERAL})`,
751
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
752
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
753
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
754
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
755
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
756
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
757
- SEP: '\\'
758
- };
759
-
760
- /**
761
- * POSIX Bracket Regex
762
- */
763
-
764
- const POSIX_REGEX_SOURCE$1 = {
765
- alnum: 'a-zA-Z0-9',
766
- alpha: 'a-zA-Z',
767
- ascii: '\\x00-\\x7F',
768
- blank: ' \\t',
769
- cntrl: '\\x00-\\x1F\\x7F',
770
- digit: '0-9',
771
- graph: '\\x21-\\x7E',
772
- lower: 'a-z',
773
- print: '\\x20-\\x7E ',
774
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
775
- space: ' \\t\\r\\n\\v\\f',
776
- upper: 'A-Z',
777
- word: 'A-Za-z0-9_',
778
- xdigit: 'A-Fa-f0-9'
779
- };
780
-
781
- var constants$3 = {
782
- MAX_LENGTH: 1024 * 64,
783
- POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
784
-
785
- // regular expressions
786
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
787
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
788
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
789
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
790
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
791
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
792
-
793
- // Replace globs with equivalent patterns to reduce parsing time.
794
- REPLACEMENTS: {
795
- '***': '*',
796
- '**/**': '**',
797
- '**/**/**': '**'
798
- },
799
-
800
- // Digits
801
- CHAR_0: 48, /* 0 */
802
- CHAR_9: 57, /* 9 */
803
-
804
- // Alphabet chars.
805
- CHAR_UPPERCASE_A: 65, /* A */
806
- CHAR_LOWERCASE_A: 97, /* a */
807
- CHAR_UPPERCASE_Z: 90, /* Z */
808
- CHAR_LOWERCASE_Z: 122, /* z */
809
-
810
- CHAR_LEFT_PARENTHESES: 40, /* ( */
811
- CHAR_RIGHT_PARENTHESES: 41, /* ) */
812
-
813
- CHAR_ASTERISK: 42, /* * */
814
-
815
- // Non-alphabetic chars.
816
- CHAR_AMPERSAND: 38, /* & */
817
- CHAR_AT: 64, /* @ */
818
- CHAR_BACKWARD_SLASH: 92, /* \ */
819
- CHAR_CARRIAGE_RETURN: 13, /* \r */
820
- CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
821
- CHAR_COLON: 58, /* : */
822
- CHAR_COMMA: 44, /* , */
823
- CHAR_DOT: 46, /* . */
824
- CHAR_DOUBLE_QUOTE: 34, /* " */
825
- CHAR_EQUAL: 61, /* = */
826
- CHAR_EXCLAMATION_MARK: 33, /* ! */
827
- CHAR_FORM_FEED: 12, /* \f */
828
- CHAR_FORWARD_SLASH: 47, /* / */
829
- CHAR_GRAVE_ACCENT: 96, /* ` */
830
- CHAR_HASH: 35, /* # */
831
- CHAR_HYPHEN_MINUS: 45, /* - */
832
- CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
833
- CHAR_LEFT_CURLY_BRACE: 123, /* { */
834
- CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
835
- CHAR_LINE_FEED: 10, /* \n */
836
- CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
837
- CHAR_PERCENT: 37, /* % */
838
- CHAR_PLUS: 43, /* + */
839
- CHAR_QUESTION_MARK: 63, /* ? */
840
- CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
841
- CHAR_RIGHT_CURLY_BRACE: 125, /* } */
842
- CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
843
- CHAR_SEMICOLON: 59, /* ; */
844
- CHAR_SINGLE_QUOTE: 39, /* ' */
845
- CHAR_SPACE: 32, /* */
846
- CHAR_TAB: 9, /* \t */
847
- CHAR_UNDERSCORE: 95, /* _ */
848
- CHAR_VERTICAL_LINE: 124, /* | */
849
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
850
-
851
- /**
852
- * Create EXTGLOB_CHARS
853
- */
854
-
855
- extglobChars(chars) {
856
- return {
857
- '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
858
- '?': { type: 'qmark', open: '(?:', close: ')?' },
859
- '+': { type: 'plus', open: '(?:', close: ')+' },
860
- '*': { type: 'star', open: '(?:', close: ')*' },
861
- '@': { type: 'at', open: '(?:', close: ')' }
862
- };
863
- },
864
-
865
- /**
866
- * Create GLOB_CHARS
867
- */
868
-
869
- globChars(win32) {
870
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
871
- }
872
- };
873
-
874
- (function (exports) {
875
-
876
- const {
877
- REGEX_BACKSLASH,
878
- REGEX_REMOVE_BACKSLASH,
879
- REGEX_SPECIAL_CHARS,
880
- REGEX_SPECIAL_CHARS_GLOBAL
881
- } = constants$3;
882
-
883
- exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
884
- exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
885
- exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
886
- exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
887
- exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
888
-
889
- exports.removeBackslashes = str => {
890
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
891
- return match === '\\' ? '' : match;
892
- });
893
- };
894
-
895
- exports.supportsLookbehinds = () => {
896
- const segs = process.version.slice(1).split('.').map(Number);
897
- if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
898
- return true;
899
- }
900
- return false;
901
- };
902
-
903
- exports.escapeLast = (input, char, lastIdx) => {
904
- const idx = input.lastIndexOf(char, lastIdx);
905
- if (idx === -1) return input;
906
- if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
907
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
908
- };
909
-
910
- exports.removePrefix = (input, state = {}) => {
911
- let output = input;
912
- if (output.startsWith('./')) {
913
- output = output.slice(2);
914
- state.prefix = './';
915
- }
916
- return output;
917
- };
918
-
919
- exports.wrapOutput = (input, state = {}, options = {}) => {
920
- const prepend = options.contains ? '' : '^';
921
- const append = options.contains ? '' : '$';
922
-
923
- let output = `${prepend}(?:${input})${append}`;
924
- if (state.negated === true) {
925
- output = `(?:^(?!${output}).*$)`;
926
- }
927
- return output;
928
- };
929
-
930
- exports.basename = (path, { windows } = {}) => {
931
- if (windows) {
932
- return path.replace(/[\\/]$/, '').replace(/.*[\\/]/, '');
933
- } else {
934
- return path.replace(/\/$/, '').replace(/.*\//, '');
935
- }
936
- };
937
- } (utils$3));
938
-
939
- const utils$2 = utils$3;
940
- const {
941
- CHAR_ASTERISK, /* * */
942
- CHAR_AT, /* @ */
943
- CHAR_BACKWARD_SLASH, /* \ */
944
- CHAR_COMMA, /* , */
945
- CHAR_DOT, /* . */
946
- CHAR_EXCLAMATION_MARK, /* ! */
947
- CHAR_FORWARD_SLASH, /* / */
948
- CHAR_LEFT_CURLY_BRACE, /* { */
949
- CHAR_LEFT_PARENTHESES, /* ( */
950
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
951
- CHAR_PLUS, /* + */
952
- CHAR_QUESTION_MARK, /* ? */
953
- CHAR_RIGHT_CURLY_BRACE, /* } */
954
- CHAR_RIGHT_PARENTHESES, /* ) */
955
- CHAR_RIGHT_SQUARE_BRACKET /* ] */
956
- } = constants$3;
957
-
958
- const isPathSeparator = code => {
959
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
960
- };
961
-
962
- const depth = token => {
963
- if (token.isPrefix !== true) {
964
- token.depth = token.isGlobstar ? Infinity : 1;
965
- }
966
- };
967
-
968
- /**
969
- * Quickly scans a glob pattern and returns an object with a handful of
970
- * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
971
- * `glob` (the actual pattern), and `negated` (true if the path starts with `!`).
972
- *
973
- * ```js
974
- * const pm = require('picomatch');
975
- * console.log(pm.scan('foo/bar/*.js'));
976
- * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
977
- * ```
978
- * @param {String} `str`
979
- * @param {Object} `options`
980
- * @return {Object} Returns an object with tokens and regex source string.
981
- * @api public
982
- */
983
-
984
- const scan$1 = (input, options) => {
985
- const opts = options || {};
986
-
987
- const length = input.length - 1;
988
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
989
- const slashes = [];
990
- const tokens = [];
991
- const parts = [];
992
-
993
- let str = input;
994
- let index = -1;
995
- let start = 0;
996
- let lastIndex = 0;
997
- let isBrace = false;
998
- let isBracket = false;
999
- let isGlob = false;
1000
- let isExtglob = false;
1001
- let isGlobstar = false;
1002
- let braceEscaped = false;
1003
- let backslashes = false;
1004
- let negated = false;
1005
- let finished = false;
1006
- let braces = 0;
1007
- let prev;
1008
- let code;
1009
- let token = { value: '', depth: 0, isGlob: false };
1010
-
1011
- const eos = () => index >= length;
1012
- const peek = () => str.charCodeAt(index + 1);
1013
- const advance = () => {
1014
- prev = code;
1015
- return str.charCodeAt(++index);
1016
- };
1017
-
1018
- while (index < length) {
1019
- code = advance();
1020
- let next;
1021
-
1022
- if (code === CHAR_BACKWARD_SLASH) {
1023
- backslashes = token.backslashes = true;
1024
- code = advance();
1025
-
1026
- if (code === CHAR_LEFT_CURLY_BRACE) {
1027
- braceEscaped = true;
1028
- }
1029
- continue;
1030
- }
1031
-
1032
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
1033
- braces++;
1034
-
1035
- while (eos() !== true && (code = advance())) {
1036
- if (code === CHAR_BACKWARD_SLASH) {
1037
- backslashes = token.backslashes = true;
1038
- advance();
1039
- continue;
1040
- }
1041
-
1042
- if (code === CHAR_LEFT_CURLY_BRACE) {
1043
- braces++;
1044
- continue;
1045
- }
1046
-
1047
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1048
- isBrace = token.isBrace = true;
1049
- isGlob = token.isGlob = true;
1050
- finished = true;
1051
-
1052
- if (scanToEnd === true) {
1053
- continue;
1054
- }
1055
-
1056
- break;
1057
- }
1058
-
1059
- if (braceEscaped !== true && code === CHAR_COMMA) {
1060
- isBrace = token.isBrace = true;
1061
- isGlob = token.isGlob = true;
1062
- finished = true;
1063
-
1064
- if (scanToEnd === true) {
1065
- continue;
1066
- }
1067
-
1068
- break;
1069
- }
1070
-
1071
- if (code === CHAR_RIGHT_CURLY_BRACE) {
1072
- braces--;
1073
-
1074
- if (braces === 0) {
1075
- braceEscaped = false;
1076
- isBrace = token.isBrace = true;
1077
- finished = true;
1078
- break;
1079
- }
1080
- }
1081
- }
1082
-
1083
- if (scanToEnd === true) {
1084
- continue;
1085
- }
1086
-
1087
- break;
1088
- }
1089
-
1090
- if (code === CHAR_FORWARD_SLASH) {
1091
- slashes.push(index);
1092
- tokens.push(token);
1093
- token = { value: '', depth: 0, isGlob: false };
1094
-
1095
- if (finished === true) continue;
1096
- if (prev === CHAR_DOT && index === (start + 1)) {
1097
- start += 2;
1098
- continue;
1099
- }
1100
-
1101
- lastIndex = index + 1;
1102
- continue;
1103
- }
1104
-
1105
- if (opts.noext !== true) {
1106
- const isExtglobChar = code === CHAR_PLUS
1107
- || code === CHAR_AT
1108
- || code === CHAR_ASTERISK
1109
- || code === CHAR_QUESTION_MARK
1110
- || code === CHAR_EXCLAMATION_MARK;
1111
-
1112
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
1113
- isGlob = token.isGlob = true;
1114
- isExtglob = token.isExtglob = true;
1115
- finished = true;
1116
-
1117
- if (scanToEnd === true) {
1118
- while (eos() !== true && (code = advance())) {
1119
- if (code === CHAR_BACKWARD_SLASH) {
1120
- backslashes = token.backslashes = true;
1121
- code = advance();
1122
- continue;
1123
- }
1124
-
1125
- if (code === CHAR_RIGHT_PARENTHESES) {
1126
- isGlob = token.isGlob = true;
1127
- finished = true;
1128
- break;
1129
- }
1130
- }
1131
- continue;
1132
- }
1133
- break;
1134
- }
1135
- }
1136
-
1137
- if (code === CHAR_ASTERISK) {
1138
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
1139
- isGlob = token.isGlob = true;
1140
- finished = true;
1141
-
1142
- if (scanToEnd === true) {
1143
- continue;
1144
- }
1145
- break;
1146
- }
1147
-
1148
- if (code === CHAR_QUESTION_MARK) {
1149
- isGlob = token.isGlob = true;
1150
- finished = true;
1151
-
1152
- if (scanToEnd === true) {
1153
- continue;
1154
- }
1155
- break;
1156
- }
1157
-
1158
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
1159
- while (eos() !== true && (next = advance())) {
1160
- if (next === CHAR_BACKWARD_SLASH) {
1161
- backslashes = token.backslashes = true;
1162
- advance();
1163
- continue;
1164
- }
1165
-
1166
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1167
- isBracket = token.isBracket = true;
1168
- isGlob = token.isGlob = true;
1169
- finished = true;
1170
-
1171
- if (scanToEnd === true) {
1172
- continue;
1173
- }
1174
- break;
1175
- }
1176
- }
1177
- }
1178
-
1179
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
1180
- negated = token.negated = true;
1181
- start++;
1182
- continue;
1183
- }
1184
-
1185
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
1186
- isGlob = token.isGlob = true;
1187
-
1188
- if (scanToEnd === true) {
1189
- while (eos() !== true && (code = advance())) {
1190
- if (code === CHAR_LEFT_PARENTHESES) {
1191
- backslashes = token.backslashes = true;
1192
- code = advance();
1193
- continue;
1194
- }
1195
-
1196
- if (code === CHAR_RIGHT_PARENTHESES) {
1197
- finished = true;
1198
- break;
1199
- }
1200
- }
1201
- continue;
1202
- }
1203
- break;
1204
- }
1205
-
1206
- if (isGlob === true) {
1207
- finished = true;
1208
-
1209
- if (scanToEnd === true) {
1210
- continue;
1211
- }
1212
-
1213
- break;
1214
- }
1215
- }
1216
-
1217
- if (opts.noext === true) {
1218
- isExtglob = false;
1219
- isGlob = false;
1220
- }
1221
-
1222
- let base = str;
1223
- let prefix = '';
1224
- let glob = '';
1225
-
1226
- if (start > 0) {
1227
- prefix = str.slice(0, start);
1228
- str = str.slice(start);
1229
- lastIndex -= start;
1230
- }
1231
-
1232
- if (base && isGlob === true && lastIndex > 0) {
1233
- base = str.slice(0, lastIndex);
1234
- glob = str.slice(lastIndex);
1235
- } else if (isGlob === true) {
1236
- base = '';
1237
- glob = str;
1238
- } else {
1239
- base = str;
1240
- }
1241
-
1242
- if (base && base !== '' && base !== '/' && base !== str) {
1243
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
1244
- base = base.slice(0, -1);
1245
- }
1246
- }
1247
-
1248
- if (opts.unescape === true) {
1249
- if (glob) glob = utils$2.removeBackslashes(glob);
1250
-
1251
- if (base && backslashes === true) {
1252
- base = utils$2.removeBackslashes(base);
1253
- }
1254
- }
1255
-
1256
- const state = {
1257
- prefix,
1258
- input,
1259
- start,
1260
- base,
1261
- glob,
1262
- isBrace,
1263
- isBracket,
1264
- isGlob,
1265
- isExtglob,
1266
- isGlobstar,
1267
- negated
1268
- };
1269
-
1270
- if (opts.tokens === true) {
1271
- state.maxDepth = 0;
1272
- if (!isPathSeparator(code)) {
1273
- tokens.push(token);
1274
- }
1275
- state.tokens = tokens;
1276
- }
1277
-
1278
- if (opts.parts === true || opts.tokens === true) {
1279
- let prevIndex;
1280
-
1281
- for (let idx = 0; idx < slashes.length; idx++) {
1282
- const n = prevIndex ? prevIndex + 1 : start;
1283
- const i = slashes[idx];
1284
- const value = input.slice(n, i);
1285
- if (opts.tokens) {
1286
- if (idx === 0 && start !== 0) {
1287
- tokens[idx].isPrefix = true;
1288
- tokens[idx].value = prefix;
1289
- } else {
1290
- tokens[idx].value = value;
1291
- }
1292
- depth(tokens[idx]);
1293
- state.maxDepth += tokens[idx].depth;
1294
- }
1295
- if (idx !== 0 || value !== '') {
1296
- parts.push(value);
1297
- }
1298
- prevIndex = i;
1299
- }
1300
-
1301
- if (prevIndex && prevIndex + 1 < input.length) {
1302
- const value = input.slice(prevIndex + 1);
1303
- parts.push(value);
1304
-
1305
- if (opts.tokens) {
1306
- tokens[tokens.length - 1].value = value;
1307
- depth(tokens[tokens.length - 1]);
1308
- state.maxDepth += tokens[tokens.length - 1].depth;
1309
- }
1310
- }
1311
-
1312
- state.slashes = slashes;
1313
- state.parts = parts;
1314
- }
1315
-
1316
- return state;
1317
- };
1318
-
1319
- var scan_1 = scan$1;
1320
-
1321
- const constants$2 = constants$3;
1322
- const utils$1 = utils$3;
1323
-
1324
- /**
1325
- * Constants
1326
- */
1327
-
1328
- const {
1329
- MAX_LENGTH,
1330
- POSIX_REGEX_SOURCE,
1331
- REGEX_NON_SPECIAL_CHARS,
1332
- REGEX_SPECIAL_CHARS_BACKREF,
1333
- REPLACEMENTS
1334
- } = constants$2;
1335
-
1336
- /**
1337
- * Helpers
1338
- */
1339
-
1340
- const expandRange = (args, options) => {
1341
- if (typeof options.expandRange === 'function') {
1342
- return options.expandRange(...args, options);
1343
- }
1344
-
1345
- args.sort();
1346
- const value = `[${args.join('-')}]`;
1347
-
1348
- try {
1349
- /* eslint-disable-next-line no-new */
1350
- new RegExp(value);
1351
- } catch (ex) {
1352
- return args.map(v => utils$1.escapeRegex(v)).join('..');
1353
- }
1354
-
1355
- return value;
1356
- };
1357
-
1358
- /**
1359
- * Create the message for a syntax error
1360
- */
1361
-
1362
- const syntaxError = (type, char) => {
1363
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
1364
- };
1365
-
1366
- /**
1367
- * Parse the given input string.
1368
- * @param {String} input
1369
- * @param {Object} options
1370
- * @return {Object}
1371
- */
1372
-
1373
- const parse$2 = (input, options) => {
1374
- if (typeof input !== 'string') {
1375
- throw new TypeError('Expected a string');
1376
- }
1377
-
1378
- input = REPLACEMENTS[input] || input;
1379
-
1380
- const opts = { ...options };
1381
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1382
-
1383
- let len = input.length;
1384
- if (len > max) {
1385
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1386
- }
1387
-
1388
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
1389
- const tokens = [bos];
1390
-
1391
- const capture = opts.capture ? '' : '?:';
1392
-
1393
- // create constants based on platform, for windows or posix
1394
- const PLATFORM_CHARS = constants$2.globChars(opts.windows);
1395
- const EXTGLOB_CHARS = constants$2.extglobChars(PLATFORM_CHARS);
1396
-
1397
- const {
1398
- DOT_LITERAL,
1399
- PLUS_LITERAL,
1400
- SLASH_LITERAL,
1401
- ONE_CHAR,
1402
- DOTS_SLASH,
1403
- NO_DOT,
1404
- NO_DOT_SLASH,
1405
- NO_DOTS_SLASH,
1406
- QMARK,
1407
- QMARK_NO_DOT,
1408
- STAR,
1409
- START_ANCHOR
1410
- } = PLATFORM_CHARS;
1411
-
1412
- const globstar = (opts) => {
1413
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1414
- };
1415
-
1416
- const nodot = opts.dot ? '' : NO_DOT;
1417
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
1418
- let star = opts.bash === true ? globstar(opts) : STAR;
1419
-
1420
- if (opts.capture) {
1421
- star = `(${star})`;
1422
- }
1423
-
1424
- // minimatch options support
1425
- if (typeof opts.noext === 'boolean') {
1426
- opts.noextglob = opts.noext;
1427
- }
1428
-
1429
- const state = {
1430
- input,
1431
- index: -1,
1432
- start: 0,
1433
- dot: opts.dot === true,
1434
- consumed: '',
1435
- output: '',
1436
- prefix: '',
1437
- backtrack: false,
1438
- negated: false,
1439
- brackets: 0,
1440
- braces: 0,
1441
- parens: 0,
1442
- quotes: 0,
1443
- globstar: false,
1444
- tokens
1445
- };
1446
-
1447
- input = utils$1.removePrefix(input, state);
1448
- len = input.length;
1449
-
1450
- const extglobs = [];
1451
- const braces = [];
1452
- const stack = [];
1453
- let prev = bos;
1454
- let value;
1455
-
1456
- /**
1457
- * Tokenizing helpers
1458
- */
1459
-
1460
- const eos = () => state.index === len - 1;
1461
- const peek = state.peek = (n = 1) => input[state.index + n];
1462
- const advance = state.advance = () => input[++state.index];
1463
- const remaining = () => input.slice(state.index + 1);
1464
- const consume = (value = '', num = 0) => {
1465
- state.consumed += value;
1466
- state.index += num;
1467
- };
1468
- const append = token => {
1469
- state.output += token.output != null ? token.output : token.value;
1470
- consume(token.value);
1471
- };
1472
-
1473
- const negate = () => {
1474
- let count = 1;
1475
-
1476
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
1477
- advance();
1478
- state.start++;
1479
- count++;
1480
- }
1481
-
1482
- if (count % 2 === 0) {
1483
- return false;
1484
- }
1485
-
1486
- state.negated = true;
1487
- state.start++;
1488
- return true;
1489
- };
1490
-
1491
- const increment = type => {
1492
- state[type]++;
1493
- stack.push(type);
1494
- };
1495
-
1496
- const decrement = type => {
1497
- state[type]--;
1498
- stack.pop();
1499
- };
1500
-
1501
- /**
1502
- * Push tokens onto the tokens array. This helper speeds up
1503
- * tokenizing by 1) helping us avoid backtracking as much as possible,
1504
- * and 2) helping us avoid creating extra tokens when consecutive
1505
- * characters are plain text. This improves performance and simplifies
1506
- * lookbehinds.
1507
- */
1508
-
1509
- const push = tok => {
1510
- if (prev.type === 'globstar') {
1511
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
1512
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
1513
-
1514
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
1515
- state.output = state.output.slice(0, -prev.output.length);
1516
- prev.type = 'star';
1517
- prev.value = '*';
1518
- prev.output = star;
1519
- state.output += prev.output;
1520
- }
1521
- }
1522
-
1523
- if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) {
1524
- extglobs[extglobs.length - 1].inner += tok.value;
1525
- }
1526
-
1527
- if (tok.value || tok.output) append(tok);
1528
- if (prev && prev.type === 'text' && tok.type === 'text') {
1529
- prev.value += tok.value;
1530
- prev.output = (prev.output || '') + tok.value;
1531
- return;
1532
- }
1533
-
1534
- tok.prev = prev;
1535
- tokens.push(tok);
1536
- prev = tok;
1537
- };
1538
-
1539
- const extglobOpen = (type, value) => {
1540
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
1541
-
1542
- token.prev = prev;
1543
- token.parens = state.parens;
1544
- token.output = state.output;
1545
- const output = (opts.capture ? '(' : '') + token.open;
1546
-
1547
- increment('parens');
1548
- push({ type, value, output: state.output ? '' : ONE_CHAR });
1549
- push({ type: 'paren', extglob: true, value: advance(), output });
1550
- extglobs.push(token);
1551
- };
1552
-
1553
- const extglobClose = token => {
1554
- let output = token.close + (opts.capture ? ')' : '');
1555
-
1556
- if (token.type === 'negate') {
1557
- let extglobStar = star;
1558
-
1559
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
1560
- extglobStar = globstar(opts);
1561
- }
1562
-
1563
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
1564
- output = token.close = `)$))${extglobStar}`;
1565
- }
1566
-
1567
- if (token.prev.type === 'bos' && eos()) {
1568
- state.negatedExtglob = true;
1569
- }
1570
- }
1571
-
1572
- push({ type: 'paren', extglob: true, value, output });
1573
- decrement('parens');
1574
- };
1575
-
1576
- /**
1577
- * Fast paths
1578
- */
1579
-
1580
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
1581
- let backslashes = false;
1582
-
1583
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
1584
- if (first === '\\') {
1585
- backslashes = true;
1586
- return m;
1587
- }
1588
-
1589
- if (first === '?') {
1590
- if (esc) {
1591
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
1592
- }
1593
- if (index === 0) {
1594
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
1595
- }
1596
- return QMARK.repeat(chars.length);
1597
- }
1598
-
1599
- if (first === '.') {
1600
- return DOT_LITERAL.repeat(chars.length);
1601
- }
1602
-
1603
- if (first === '*') {
1604
- if (esc) {
1605
- return esc + first + (rest ? star : '');
1606
- }
1607
- return star;
1608
- }
1609
- return esc ? m : `\\${m}`;
1610
- });
1611
-
1612
- if (backslashes === true) {
1613
- if (opts.unescape === true) {
1614
- output = output.replace(/\\/g, '');
1615
- } else {
1616
- output = output.replace(/\\+/g, m => {
1617
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
1618
- });
1619
- }
1620
- }
1621
-
1622
- if (output === input && opts.contains === true) {
1623
- state.output = input;
1624
- return state;
1625
- }
1626
-
1627
- state.output = utils$1.wrapOutput(output, state, options);
1628
- return state;
1629
- }
1630
-
1631
- /**
1632
- * Tokenize input until we reach end-of-string
1633
- */
1634
-
1635
- while (!eos()) {
1636
- value = advance();
1637
-
1638
- if (value === '\u0000') {
1639
- continue;
1640
- }
1641
-
1642
- /**
1643
- * Escaped characters
1644
- */
1645
-
1646
- if (value === '\\') {
1647
- const next = peek();
1648
-
1649
- if (next === '/' && opts.bash !== true) {
1650
- continue;
1651
- }
1652
-
1653
- if (next === '.' || next === ';') {
1654
- continue;
1655
- }
1656
-
1657
- if (!next) {
1658
- value += '\\';
1659
- push({ type: 'text', value });
1660
- continue;
1661
- }
1662
-
1663
- // collapse slashes to reduce potential for exploits
1664
- const match = /^\\+/.exec(remaining());
1665
- let slashes = 0;
1666
-
1667
- if (match && match[0].length > 2) {
1668
- slashes = match[0].length;
1669
- state.index += slashes;
1670
- if (slashes % 2 !== 0) {
1671
- value += '\\';
1672
- }
1673
- }
1674
-
1675
- if (opts.unescape === true) {
1676
- value = advance() || '';
1677
- } else {
1678
- value += advance() || '';
1679
- }
1680
-
1681
- if (state.brackets === 0) {
1682
- push({ type: 'text', value });
1683
- continue;
1684
- }
1685
- }
1686
-
1687
- /**
1688
- * If we're inside a regex character class, continue
1689
- * until we reach the closing bracket.
1690
- */
1691
-
1692
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
1693
- if (opts.posix !== false && value === ':') {
1694
- const inner = prev.value.slice(1);
1695
- if (inner.includes('[')) {
1696
- prev.posix = true;
1697
-
1698
- if (inner.includes(':')) {
1699
- const idx = prev.value.lastIndexOf('[');
1700
- const pre = prev.value.slice(0, idx);
1701
- const rest = prev.value.slice(idx + 2);
1702
- const posix = POSIX_REGEX_SOURCE[rest];
1703
- if (posix) {
1704
- prev.value = pre + posix;
1705
- state.backtrack = true;
1706
- advance();
1707
-
1708
- if (!bos.output && tokens.indexOf(prev) === 1) {
1709
- bos.output = ONE_CHAR;
1710
- }
1711
- continue;
1712
- }
1713
- }
1714
- }
1715
- }
1716
-
1717
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
1718
- value = `\\${value}`;
1719
- }
1720
-
1721
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
1722
- value = `\\${value}`;
1723
- }
1724
-
1725
- if (opts.posix === true && value === '!' && prev.value === '[') {
1726
- value = '^';
1727
- }
1728
-
1729
- prev.value += value;
1730
- append({ value });
1731
- continue;
1732
- }
1733
-
1734
- /**
1735
- * If we're inside a quoted string, continue
1736
- * until we reach the closing double quote.
1737
- */
1738
-
1739
- if (state.quotes === 1 && value !== '"') {
1740
- value = utils$1.escapeRegex(value);
1741
- prev.value += value;
1742
- append({ value });
1743
- continue;
1744
- }
1745
-
1746
- /**
1747
- * Double quotes
1748
- */
1749
-
1750
- if (value === '"') {
1751
- state.quotes = state.quotes === 1 ? 0 : 1;
1752
- if (opts.keepQuotes === true) {
1753
- push({ type: 'text', value });
1754
- }
1755
- continue;
1756
- }
1757
-
1758
- /**
1759
- * Parentheses
1760
- */
1761
-
1762
- if (value === '(') {
1763
- increment('parens');
1764
- push({ type: 'paren', value });
1765
- continue;
1766
- }
1767
-
1768
- if (value === ')') {
1769
- if (state.parens === 0 && opts.strictBrackets === true) {
1770
- throw new SyntaxError(syntaxError('opening', '('));
1771
- }
1772
-
1773
- const extglob = extglobs[extglobs.length - 1];
1774
- if (extglob && state.parens === extglob.parens + 1) {
1775
- extglobClose(extglobs.pop());
1776
- continue;
1777
- }
1778
-
1779
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
1780
- decrement('parens');
1781
- continue;
1782
- }
1783
-
1784
- /**
1785
- * Square brackets
1786
- */
1787
-
1788
- if (value === '[') {
1789
- if (opts.nobracket === true || !remaining().includes(']')) {
1790
- if (opts.nobracket !== true && opts.strictBrackets === true) {
1791
- throw new SyntaxError(syntaxError('closing', ']'));
1792
- }
1793
-
1794
- value = `\\${value}`;
1795
- } else {
1796
- increment('brackets');
1797
- }
1798
-
1799
- push({ type: 'bracket', value });
1800
- continue;
1801
- }
1802
-
1803
- if (value === ']') {
1804
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
1805
- push({ type: 'text', value, output: `\\${value}` });
1806
- continue;
1807
- }
1808
-
1809
- if (state.brackets === 0) {
1810
- if (opts.strictBrackets === true) {
1811
- throw new SyntaxError(syntaxError('opening', '['));
1812
- }
1813
-
1814
- push({ type: 'text', value, output: `\\${value}` });
1815
- continue;
1816
- }
1817
-
1818
- decrement('brackets');
1819
-
1820
- const prevValue = prev.value.slice(1);
1821
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
1822
- value = `/${value}`;
1823
- }
1824
-
1825
- prev.value += value;
1826
- append({ value });
1827
-
1828
- // when literal brackets are explicitly disabled
1829
- // assume we should match with a regex character class
1830
- if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
1831
- continue;
1832
- }
1833
-
1834
- const escaped = utils$1.escapeRegex(prev.value);
1835
- state.output = state.output.slice(0, -prev.value.length);
1836
-
1837
- // when literal brackets are explicitly enabled
1838
- // assume we should escape the brackets to match literal characters
1839
- if (opts.literalBrackets === true) {
1840
- state.output += escaped;
1841
- prev.value = escaped;
1842
- continue;
1843
- }
1844
-
1845
- // when the user specifies nothing, try to match both
1846
- prev.value = `(${capture}${escaped}|${prev.value})`;
1847
- state.output += prev.value;
1848
- continue;
1849
- }
1850
-
1851
- /**
1852
- * Braces
1853
- */
1854
-
1855
- if (value === '{' && opts.nobrace !== true) {
1856
- increment('braces');
1857
-
1858
- const open = {
1859
- type: 'brace',
1860
- value,
1861
- output: '(',
1862
- outputIndex: state.output.length,
1863
- tokensIndex: state.tokens.length
1864
- };
1865
-
1866
- braces.push(open);
1867
- push(open);
1868
- continue;
1869
- }
1870
-
1871
- if (value === '}') {
1872
- const brace = braces[braces.length - 1];
1873
-
1874
- if (opts.nobrace === true || !brace) {
1875
- push({ type: 'text', value, output: value });
1876
- continue;
1877
- }
1878
-
1879
- let output = ')';
1880
-
1881
- if (brace.dots === true) {
1882
- const arr = tokens.slice();
1883
- const range = [];
1884
-
1885
- for (let i = arr.length - 1; i >= 0; i--) {
1886
- tokens.pop();
1887
- if (arr[i].type === 'brace') {
1888
- break;
1889
- }
1890
- if (arr[i].type !== 'dots') {
1891
- range.unshift(arr[i].value);
1892
- }
1893
- }
1894
-
1895
- output = expandRange(range, opts);
1896
- state.backtrack = true;
1897
- }
1898
-
1899
- if (brace.comma !== true && brace.dots !== true) {
1900
- const out = state.output.slice(0, brace.outputIndex);
1901
- const toks = state.tokens.slice(brace.tokensIndex);
1902
- brace.value = brace.output = '\\{';
1903
- value = output = '\\}';
1904
- state.output = out;
1905
- for (const t of toks) {
1906
- state.output += (t.output || t.value);
1907
- }
1908
- }
1909
-
1910
- push({ type: 'brace', value, output });
1911
- decrement('braces');
1912
- braces.pop();
1913
- continue;
1914
- }
1915
-
1916
- /**
1917
- * Pipes
1918
- */
1919
-
1920
- if (value === '|') {
1921
- if (extglobs.length > 0) {
1922
- extglobs[extglobs.length - 1].conditions++;
1923
- }
1924
- push({ type: 'text', value });
1925
- continue;
1926
- }
1927
-
1928
- /**
1929
- * Commas
1930
- */
1931
-
1932
- if (value === ',') {
1933
- let output = value;
1934
-
1935
- const brace = braces[braces.length - 1];
1936
- if (brace && stack[stack.length - 1] === 'braces') {
1937
- brace.comma = true;
1938
- output = '|';
1939
- }
1940
-
1941
- push({ type: 'comma', value, output });
1942
- continue;
1943
- }
1944
-
1945
- /**
1946
- * Slashes
1947
- */
1948
-
1949
- if (value === '/') {
1950
- // if the beginning of the glob is "./", advance the start
1951
- // to the current index, and don't add the "./" characters
1952
- // to the state. This greatly simplifies lookbehinds when
1953
- // checking for BOS characters like "!" and "." (not "./")
1954
- if (prev.type === 'dot' && state.index === state.start + 1) {
1955
- state.start = state.index + 1;
1956
- state.consumed = '';
1957
- state.output = '';
1958
- tokens.pop();
1959
- prev = bos; // reset "prev" to the first token
1960
- continue;
1961
- }
1962
-
1963
- push({ type: 'slash', value, output: SLASH_LITERAL });
1964
- continue;
1965
- }
1966
-
1967
- /**
1968
- * Dots
1969
- */
1970
-
1971
- if (value === '.') {
1972
- if (state.braces > 0 && prev.type === 'dot') {
1973
- if (prev.value === '.') prev.output = DOT_LITERAL;
1974
- const brace = braces[braces.length - 1];
1975
- prev.type = 'dots';
1976
- prev.output += value;
1977
- prev.value += value;
1978
- brace.dots = true;
1979
- continue;
1980
- }
1981
-
1982
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
1983
- push({ type: 'text', value, output: DOT_LITERAL });
1984
- continue;
1985
- }
1986
-
1987
- push({ type: 'dot', value, output: DOT_LITERAL });
1988
- continue;
1989
- }
1990
-
1991
- /**
1992
- * Question marks
1993
- */
1994
-
1995
- if (value === '?') {
1996
- const isGroup = prev && prev.value === '(';
1997
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1998
- extglobOpen('qmark', value);
1999
- continue;
2000
- }
2001
-
2002
- if (prev && prev.type === 'paren') {
2003
- const next = peek();
2004
- let output = value;
2005
-
2006
- if (next === '<' && !utils$1.supportsLookbehinds()) {
2007
- throw new Error('Node.js v10 or higher is required for regex lookbehinds');
2008
- }
2009
-
2010
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
2011
- output = `\\${value}`;
2012
- }
2013
-
2014
- push({ type: 'text', value, output });
2015
- continue;
2016
- }
2017
-
2018
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
2019
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
2020
- continue;
2021
- }
2022
-
2023
- push({ type: 'qmark', value, output: QMARK });
2024
- continue;
2025
- }
2026
-
2027
- /**
2028
- * Exclamation
2029
- */
2030
-
2031
- if (value === '!') {
2032
- if (opts.noextglob !== true && peek() === '(') {
2033
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
2034
- extglobOpen('negate', value);
2035
- continue;
2036
- }
2037
- }
2038
-
2039
- if (opts.nonegate !== true && state.index === 0) {
2040
- negate();
2041
- continue;
2042
- }
2043
- }
2044
-
2045
- /**
2046
- * Plus
2047
- */
2048
-
2049
- if (value === '+') {
2050
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2051
- extglobOpen('plus', value);
2052
- continue;
2053
- }
2054
-
2055
- if ((prev && prev.value === '(') || opts.regex === false) {
2056
- push({ type: 'plus', value, output: PLUS_LITERAL });
2057
- continue;
2058
- }
2059
-
2060
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
2061
- push({ type: 'plus', value });
2062
- continue;
2063
- }
2064
-
2065
- push({ type: 'plus', value: PLUS_LITERAL });
2066
- continue;
2067
- }
2068
-
2069
- /**
2070
- * Plain text
2071
- */
2072
-
2073
- if (value === '@') {
2074
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2075
- push({ type: 'at', extglob: true, value, output: '' });
2076
- continue;
2077
- }
2078
-
2079
- push({ type: 'text', value });
2080
- continue;
2081
- }
2082
-
2083
- /**
2084
- * Plain text
2085
- */
2086
-
2087
- if (value !== '*') {
2088
- if (value === '$' || value === '^') {
2089
- value = `\\${value}`;
2090
- }
2091
-
2092
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
2093
- if (match) {
2094
- value += match[0];
2095
- state.index += match[0].length;
2096
- }
2097
-
2098
- push({ type: 'text', value });
2099
- continue;
2100
- }
2101
-
2102
- /**
2103
- * Stars
2104
- */
2105
-
2106
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
2107
- prev.type = 'star';
2108
- prev.star = true;
2109
- prev.value += value;
2110
- prev.output = star;
2111
- state.backtrack = true;
2112
- state.globstar = true;
2113
- consume(value);
2114
- continue;
2115
- }
2116
-
2117
- let rest = remaining();
2118
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
2119
- extglobOpen('star', value);
2120
- continue;
2121
- }
2122
-
2123
- if (prev.type === 'star') {
2124
- if (opts.noglobstar === true) {
2125
- consume(value);
2126
- continue;
2127
- }
2128
-
2129
- const prior = prev.prev;
2130
- const before = prior.prev;
2131
- const isStart = prior.type === 'slash' || prior.type === 'bos';
2132
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
2133
-
2134
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
2135
- push({ type: 'star', value, output: '' });
2136
- continue;
2137
- }
2138
-
2139
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
2140
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
2141
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
2142
- push({ type: 'star', value, output: '' });
2143
- continue;
2144
- }
2145
-
2146
- // strip consecutive `/**/`
2147
- while (rest.slice(0, 3) === '/**') {
2148
- const after = input[state.index + 4];
2149
- if (after && after !== '/') {
2150
- break;
2151
- }
2152
- rest = rest.slice(3);
2153
- consume('/**', 3);
2154
- }
2155
-
2156
- if (prior.type === 'bos' && eos()) {
2157
- prev.type = 'globstar';
2158
- prev.value += value;
2159
- prev.output = globstar(opts);
2160
- state.output = prev.output;
2161
- state.globstar = true;
2162
- consume(value);
2163
- continue;
2164
- }
2165
-
2166
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
2167
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
2168
- prior.output = `(?:${prior.output}`;
2169
-
2170
- prev.type = 'globstar';
2171
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
2172
- prev.value += value;
2173
- state.globstar = true;
2174
- state.output += prior.output + prev.output;
2175
- consume(value);
2176
- continue;
2177
- }
2178
-
2179
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
2180
- const end = rest[1] !== void 0 ? '|$' : '';
2181
-
2182
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
2183
- prior.output = `(?:${prior.output}`;
2184
-
2185
- prev.type = 'globstar';
2186
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
2187
- prev.value += value;
2188
-
2189
- state.output += prior.output + prev.output;
2190
- state.globstar = true;
2191
-
2192
- consume(value + advance());
2193
-
2194
- push({ type: 'slash', value: '/', output: '' });
2195
- continue;
2196
- }
2197
-
2198
- if (prior.type === 'bos' && rest[0] === '/') {
2199
- prev.type = 'globstar';
2200
- prev.value += value;
2201
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
2202
- state.output = prev.output;
2203
- state.globstar = true;
2204
- consume(value + advance());
2205
- push({ type: 'slash', value: '/', output: '' });
2206
- continue;
2207
- }
2208
-
2209
- // remove single star from output
2210
- state.output = state.output.slice(0, -prev.output.length);
2211
-
2212
- // reset previous token to globstar
2213
- prev.type = 'globstar';
2214
- prev.output = globstar(opts);
2215
- prev.value += value;
2216
-
2217
- // reset output with globstar
2218
- state.output += prev.output;
2219
- state.globstar = true;
2220
- consume(value);
2221
- continue;
2222
- }
2223
-
2224
- const token = { type: 'star', value, output: star };
2225
-
2226
- if (opts.bash === true) {
2227
- token.output = '.*?';
2228
- if (prev.type === 'bos' || prev.type === 'slash') {
2229
- token.output = nodot + token.output;
2230
- }
2231
- push(token);
2232
- continue;
2233
- }
2234
-
2235
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
2236
- token.output = value;
2237
- push(token);
2238
- continue;
2239
- }
2240
-
2241
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
2242
- if (prev.type === 'dot') {
2243
- state.output += NO_DOT_SLASH;
2244
- prev.output += NO_DOT_SLASH;
2245
-
2246
- } else if (opts.dot === true) {
2247
- state.output += NO_DOTS_SLASH;
2248
- prev.output += NO_DOTS_SLASH;
2249
-
2250
- } else {
2251
- state.output += nodot;
2252
- prev.output += nodot;
2253
- }
2254
-
2255
- if (peek() !== '*') {
2256
- state.output += ONE_CHAR;
2257
- prev.output += ONE_CHAR;
2258
- }
2259
- }
2260
-
2261
- push(token);
2262
- }
2263
-
2264
- while (state.brackets > 0) {
2265
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
2266
- state.output = utils$1.escapeLast(state.output, '[');
2267
- decrement('brackets');
2268
- }
2269
-
2270
- while (state.parens > 0) {
2271
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
2272
- state.output = utils$1.escapeLast(state.output, '(');
2273
- decrement('parens');
2274
- }
2275
-
2276
- while (state.braces > 0) {
2277
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
2278
- state.output = utils$1.escapeLast(state.output, '{');
2279
- decrement('braces');
2280
- }
2281
-
2282
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
2283
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
2284
- }
2285
-
2286
- // rebuild the output if we had to backtrack at any point
2287
- if (state.backtrack === true) {
2288
- state.output = '';
2289
-
2290
- for (const token of state.tokens) {
2291
- state.output += token.output != null ? token.output : token.value;
2292
-
2293
- if (token.suffix) {
2294
- state.output += token.suffix;
2295
- }
2296
- }
2297
- }
2298
-
2299
- return state;
2300
- };
2301
-
2302
- /**
2303
- * Fast paths for creating regular expressions for common glob patterns.
2304
- * This can significantly speed up processing and has very little downside
2305
- * impact when none of the fast paths match.
2306
- */
2307
-
2308
- parse$2.fastpaths = (input, options) => {
2309
- const opts = { ...options };
2310
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2311
- const len = input.length;
2312
- if (len > max) {
2313
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2314
- }
2315
-
2316
- input = REPLACEMENTS[input] || input;
2317
-
2318
- // create constants based on platform, for windows or posix
2319
- const {
2320
- DOT_LITERAL,
2321
- SLASH_LITERAL,
2322
- ONE_CHAR,
2323
- DOTS_SLASH,
2324
- NO_DOT,
2325
- NO_DOTS,
2326
- NO_DOTS_SLASH,
2327
- STAR,
2328
- START_ANCHOR
2329
- } = constants$2.globChars(opts.windows);
2330
-
2331
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
2332
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
2333
- const capture = opts.capture ? '' : '?:';
2334
- const state = { negated: false, prefix: '' };
2335
- let star = opts.bash === true ? '.*?' : STAR;
2336
-
2337
- if (opts.capture) {
2338
- star = `(${star})`;
2339
- }
2340
-
2341
- const globstar = (opts) => {
2342
- if (opts.noglobstar === true) return star;
2343
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2344
- };
2345
-
2346
- const create = str => {
2347
- switch (str) {
2348
- case '*':
2349
- return `${nodot}${ONE_CHAR}${star}`;
2350
-
2351
- case '.*':
2352
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
2353
-
2354
- case '*.*':
2355
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2356
-
2357
- case '*/*':
2358
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
2359
-
2360
- case '**':
2361
- return nodot + globstar(opts);
2362
-
2363
- case '**/*':
2364
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
2365
-
2366
- case '**/*.*':
2367
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2368
-
2369
- case '**/.*':
2370
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
2371
-
2372
- default: {
2373
- const match = /^(.*?)\.(\w+)$/.exec(str);
2374
- if (!match) return;
2375
-
2376
- const source = create(match[1]);
2377
- if (!source) return;
2378
-
2379
- return source + DOT_LITERAL + match[2];
2380
- }
2381
- }
2382
- };
2383
-
2384
- const output = utils$1.removePrefix(input, state);
2385
- let source = create(output);
2386
-
2387
- if (source && opts.strictSlashes !== true) {
2388
- source += `${SLASH_LITERAL}?`;
2389
- }
2390
-
2391
- return source;
2392
- };
2393
-
2394
- var parse_1 = parse$2;
2395
-
2396
- const scan = scan_1;
2397
- const parse$1 = parse_1;
2398
- const utils = utils$3;
2399
- const constants$1 = constants$3;
2400
- const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
2401
-
2402
- /**
2403
- * Creates a matcher function from one or more glob patterns. The
2404
- * returned function takes a string to match as its first argument,
2405
- * and returns true if the string is a match. The returned matcher
2406
- * function also takes a boolean as the second argument that, when true,
2407
- * returns an object with additional information.
2408
- *
2409
- * ```js
2410
- * const picomatch = require('picomatch');
2411
- * // picomatch(glob[, options]);
2412
- *
2413
- * const isMatch = picomatch('*.!(*a)');
2414
- * console.log(isMatch('a.a')); //=> false
2415
- * console.log(isMatch('a.b')); //=> true
2416
- * ```
2417
- * @name picomatch
2418
- * @param {String|Array} `globs` One or more glob patterns.
2419
- * @param {Object=} `options`
2420
- * @return {Function=} Returns a matcher function.
2421
- * @api public
2422
- */
2423
-
2424
- const picomatch = (glob, options, returnState = false) => {
2425
- if (Array.isArray(glob)) {
2426
- const fns = glob.map(input => picomatch(input, options, returnState));
2427
- const arrayMatcher = str => {
2428
- for (const isMatch of fns) {
2429
- const state = isMatch(str);
2430
- if (state) return state;
2431
- }
2432
- return false;
2433
- };
2434
- return arrayMatcher;
2435
- }
2436
-
2437
- const isState = isObject(glob) && glob.tokens && glob.input;
2438
-
2439
- if (glob === '' || (typeof glob !== 'string' && !isState)) {
2440
- throw new TypeError('Expected pattern to be a non-empty string');
2441
- }
2442
-
2443
- const opts = options || {};
2444
- const posix = opts.windows;
2445
- const regex = isState
2446
- ? picomatch.compileRe(glob, options)
2447
- : picomatch.makeRe(glob, options, false, true);
2448
-
2449
- const state = regex.state;
2450
- delete regex.state;
2451
-
2452
- let isIgnored = () => false;
2453
- if (opts.ignore) {
2454
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
2455
- isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
2456
- }
2457
-
2458
- const matcher = (input, returnObject = false) => {
2459
- const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
2460
- const result = { glob, state, regex, posix, input, output, match, isMatch };
2461
-
2462
- if (typeof opts.onResult === 'function') {
2463
- opts.onResult(result);
2464
- }
2465
-
2466
- if (isMatch === false) {
2467
- result.isMatch = false;
2468
- return returnObject ? result : false;
2469
- }
2470
-
2471
- if (isIgnored(input)) {
2472
- if (typeof opts.onIgnore === 'function') {
2473
- opts.onIgnore(result);
2474
- }
2475
- result.isMatch = false;
2476
- return returnObject ? result : false;
2477
- }
2478
-
2479
- if (typeof opts.onMatch === 'function') {
2480
- opts.onMatch(result);
2481
- }
2482
- return returnObject ? result : true;
2483
- };
2484
-
2485
- if (returnState) {
2486
- matcher.state = state;
2487
- }
2488
-
2489
- return matcher;
2490
- };
2491
-
2492
- /**
2493
- * Test `input` with the given `regex`. This is used by the main
2494
- * `picomatch()` function to test the input string.
2495
- *
2496
- * ```js
2497
- * const picomatch = require('picomatch');
2498
- * // picomatch.test(input, regex[, options]);
2499
- *
2500
- * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
2501
- * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
2502
- * ```
2503
- * @param {String} `input` String to test.
2504
- * @param {RegExp} `regex`
2505
- * @return {Object} Returns an object with matching info.
2506
- * @api public
2507
- */
2508
-
2509
- picomatch.test = (input, regex, options, { glob, posix } = {}) => {
2510
- if (typeof input !== 'string') {
2511
- throw new TypeError('Expected input to be a string');
2512
- }
2513
-
2514
- if (input === '') {
2515
- return { isMatch: false, output: '' };
2516
- }
2517
-
2518
- const opts = options || {};
2519
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
2520
- let match = input === glob;
2521
- let output = (match && format) ? format(input) : input;
2522
-
2523
- if (match === false) {
2524
- output = format ? format(input) : input;
2525
- match = output === glob;
2526
- }
2527
-
2528
- if (match === false || opts.capture === true) {
2529
- if (opts.matchBase === true || opts.basename === true) {
2530
- match = picomatch.matchBase(input, regex, options, posix);
2531
- } else {
2532
- match = regex.exec(output);
2533
- }
2534
- }
2535
-
2536
- return { isMatch: Boolean(match), match, output };
2537
- };
2538
-
2539
- /**
2540
- * Match the basename of a filepath.
2541
- *
2542
- * ```js
2543
- * const picomatch = require('picomatch');
2544
- * // picomatch.matchBase(input, glob[, options]);
2545
- * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
2546
- * ```
2547
- * @param {String} `input` String to test.
2548
- * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
2549
- * @return {Boolean}
2550
- * @api public
2551
- */
2552
-
2553
- picomatch.matchBase = (input, glob, options) => {
2554
- const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
2555
- return regex.test(utils.basename(input));
2556
- };
2557
-
2558
- /**
2559
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
2560
- *
2561
- * ```js
2562
- * const picomatch = require('picomatch');
2563
- * // picomatch.isMatch(string, patterns[, options]);
2564
- *
2565
- * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
2566
- * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
2567
- * ```
2568
- * @param {String|Array} str The string to test.
2569
- * @param {String|Array} patterns One or more glob patterns to use for matching.
2570
- * @param {Object} [options] See available [options](#options).
2571
- * @return {Boolean} Returns true if any patterns match `str`
2572
- * @api public
2573
- */
2574
-
2575
- picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
2576
-
2577
- /**
2578
- * Parse a glob pattern to create the source string for a regular
2579
- * expression.
2580
- *
2581
- * ```js
2582
- * const picomatch = require('picomatch');
2583
- * const result = picomatch.parse(pattern[, options]);
2584
- * ```
2585
- * @param {String} `pattern`
2586
- * @param {Object} `options`
2587
- * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
2588
- * @api public
2589
- */
2590
-
2591
- picomatch.parse = (pattern, options) => {
2592
- if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
2593
- return parse$1(pattern, { ...options, fastpaths: false });
2594
- };
2595
-
2596
- /**
2597
- * Scan a glob pattern to separate the pattern into segments.
2598
- *
2599
- * ```js
2600
- * const picomatch = require('picomatch');
2601
- * // picomatch.scan(input[, options]);
2602
- *
2603
- * const result = picomatch.scan('!./foo/*.js');
2604
- * console.log(result);
2605
- * { prefix: '!./',
2606
- * input: '!./foo/*.js',
2607
- * start: 3,
2608
- * base: 'foo',
2609
- * glob: '*.js',
2610
- * isBrace: false,
2611
- * isBracket: false,
2612
- * isGlob: true,
2613
- * isExtglob: false,
2614
- * isGlobstar: false,
2615
- * negated: true }
2616
- * ```
2617
- * @param {String} `input` Glob pattern to scan.
2618
- * @param {Object} `options`
2619
- * @return {Object} Returns an object with
2620
- * @api public
2621
- */
2622
-
2623
- picomatch.scan = (input, options) => scan(input, options);
2624
-
2625
- /**
2626
- * Create a regular expression from a parsed glob pattern.
2627
- *
2628
- * ```js
2629
- * const picomatch = require('picomatch');
2630
- * const state = picomatch.parse('*.js');
2631
- * // picomatch.compileRe(state[, options]);
2632
- *
2633
- * console.log(picomatch.compileRe(state));
2634
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2635
- * ```
2636
- * @param {String} `state` The object returned from the `.parse` method.
2637
- * @param {Object} `options`
2638
- * @return {RegExp} Returns a regex created from the given pattern.
2639
- * @api public
2640
- */
2641
-
2642
- picomatch.compileRe = (parsed, options, returnOutput = false, returnState = false) => {
2643
- if (returnOutput === true) {
2644
- return parsed.output;
2645
- }
2646
-
2647
- const opts = options || {};
2648
- const prepend = opts.contains ? '' : '^';
2649
- const append = opts.contains ? '' : '$';
2650
-
2651
- let source = `${prepend}(?:${parsed.output})${append}`;
2652
- if (parsed && parsed.negated === true) {
2653
- source = `^(?!${source}).*$`;
2654
- }
2655
-
2656
- const regex = picomatch.toRegex(source, options);
2657
- if (returnState === true) {
2658
- regex.state = parsed;
2659
- }
2660
-
2661
- return regex;
2662
- };
2663
-
2664
- picomatch.makeRe = (input, options, returnOutput = false, returnState = false) => {
2665
- if (!input || typeof input !== 'string') {
2666
- throw new TypeError('Expected a non-empty string');
2667
- }
2668
-
2669
- const opts = options || {};
2670
- let parsed = { negated: false, fastpaths: true };
2671
- let prefix = '';
2672
- let output;
2673
-
2674
- if (input.startsWith('./')) {
2675
- input = input.slice(2);
2676
- prefix = parsed.prefix = './';
2677
- }
2678
-
2679
- if (opts.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
2680
- output = parse$1.fastpaths(input, options);
2681
- }
2682
-
2683
- if (output === undefined) {
2684
- parsed = parse$1(input, options);
2685
- parsed.prefix = prefix + (parsed.prefix || '');
2686
- } else {
2687
- parsed.output = output;
2688
- }
2689
-
2690
- return picomatch.compileRe(parsed, options, returnOutput, returnState);
2691
- };
2692
-
2693
- /**
2694
- * Create a regular expression from the given regex source string.
2695
- *
2696
- * ```js
2697
- * const picomatch = require('picomatch');
2698
- * // picomatch.toRegex(source[, options]);
2699
- *
2700
- * const { output } = picomatch.parse('*.js');
2701
- * console.log(picomatch.toRegex(output));
2702
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2703
- * ```
2704
- * @param {String} `source` Regular expression source string.
2705
- * @param {Object} `options`
2706
- * @return {RegExp}
2707
- * @api public
2708
- */
2709
-
2710
- picomatch.toRegex = (source, options) => {
2711
- try {
2712
- const opts = options || {};
2713
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
2714
- } catch (err) {
2715
- if (options && options.debug === true) throw err;
2716
- return /$^/;
2717
- }
2718
- };
2719
-
2720
- /**
2721
- * Picomatch constants.
2722
- * @return {Object}
2723
- */
2724
-
2725
- picomatch.constants = constants$1;
2726
-
2727
- /**
2728
- * Expose "picomatch"
2729
- */
2730
-
2731
- var picomatch_1 = picomatch;
2732
-
2733
- var picomatchBrowser = picomatch_1;
2734
-
2735
- var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchBrowser);
2736
-
2737
- function isArray(arg) {
2738
- return Array.isArray(arg);
2739
- }
2740
- function ensureArray(thing) {
2741
- if (isArray(thing))
2742
- return thing;
2743
- if (thing == null)
2744
- return [];
2745
- return [thing];
2746
- }
2747
- const globToTest = (glob) => {
2748
- const pattern = glob;
2749
- const fn = pm(pattern, { dot: true });
2750
- return {
2751
- test: (what) => {
2752
- const result = fn(what);
2753
- return result;
2754
- },
2755
- };
2756
- };
2757
- const testTrue = {
2758
- test: () => true,
2759
- };
2760
- const getMatcher = (filter) => {
2761
- const bundleTest = "bundle" in filter && filter.bundle != null ? globToTest(filter.bundle) : testTrue;
2762
- const fileTest = "file" in filter && filter.file != null ? globToTest(filter.file) : testTrue;
2763
- return { bundleTest, fileTest };
2764
- };
2765
- const createFilter = (include, exclude) => {
2766
- const includeMatchers = ensureArray(include).map(getMatcher);
2767
- const excludeMatchers = ensureArray(exclude).map(getMatcher);
2768
- return (bundleId, id) => {
2769
- for (let i = 0; i < excludeMatchers.length; ++i) {
2770
- const { bundleTest, fileTest } = excludeMatchers[i];
2771
- if (bundleTest.test(bundleId) && fileTest.test(id))
2772
- return false;
2773
- }
2774
- for (let i = 0; i < includeMatchers.length; ++i) {
2775
- const { bundleTest, fileTest } = includeMatchers[i];
2776
- if (bundleTest.test(bundleId) && fileTest.test(id))
2777
- return true;
2778
- }
2779
- return !includeMatchers.length;
2780
- };
2781
- };
2782
-
2783
- const throttleFilter = (callback, limit) => {
2784
- let waiting = false;
2785
- return (val) => {
2786
- if (!waiting) {
2787
- callback(val);
2788
- waiting = true;
2789
- setTimeout(() => {
2790
- waiting = false;
2791
- }, limit);
2792
- }
2793
- };
2794
- };
2795
- const prepareFilter = (filt) => {
2796
- if (filt === "")
2797
- return [];
2798
- return (filt
2799
- .split(",")
2800
- // remove spaces before and after
2801
- .map((entry) => entry.trim())
2802
- // unquote "
2803
- .map((entry) => entry.startsWith('"') && entry.endsWith('"') ? entry.substring(1, entry.length - 1) : entry)
2804
- // unquote '
2805
- .map((entry) => entry.startsWith("'") && entry.endsWith("'") ? entry.substring(1, entry.length - 1) : entry)
2806
- // remove empty strings
2807
- .filter((entry) => entry)
2808
- // parse bundle:file
2809
- .map((entry) => entry.split(":"))
2810
- // normalize entry just in case
2811
- .flatMap((entry) => {
2812
- if (entry.length === 0)
2813
- return [];
2814
- let bundle = null;
2815
- let file = null;
2816
- if (entry.length === 1 && entry[0]) {
2817
- file = entry[0];
2818
- return [{ file, bundle }];
2819
- }
2820
- bundle = entry[0] || null;
2821
- file = entry.slice(1).join(":") || null;
2822
- return [{ bundle, file }];
2823
- }));
2824
- };
2825
- const useFilter = () => {
2826
- const [includeFilter, setIncludeFilter] = h("");
2827
- const [excludeFilter, setExcludeFilter] = h("");
2828
- const setIncludeFilterTrottled = F(() => throttleFilter(setIncludeFilter, 200), []);
2829
- const setExcludeFilterTrottled = F(() => throttleFilter(setExcludeFilter, 200), []);
2830
- const isIncluded = F(() => createFilter(prepareFilter(includeFilter), prepareFilter(excludeFilter)), [includeFilter, excludeFilter]);
2831
- const getModuleFilterMultiplier = T((bundleId, data) => {
2832
- return isIncluded(bundleId, data.id) ? 1 : 0;
2833
- }, [isIncluded]);
2834
- return {
2835
- getModuleFilterMultiplier,
2836
- includeFilter,
2837
- excludeFilter,
2838
- setExcludeFilter: setExcludeFilterTrottled,
2839
- setIncludeFilter: setIncludeFilterTrottled,
2840
- };
2841
- };
2842
-
2843
- function ascending(a, b) {
2844
- return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
2845
- }
2846
-
2847
- function descending(a, b) {
2848
- return a == null || b == null ? NaN
2849
- : b < a ? -1
2850
- : b > a ? 1
2851
- : b >= a ? 0
2852
- : NaN;
2853
- }
2854
-
2855
- function bisector(f) {
2856
- let compare1, compare2, delta;
2857
-
2858
- // If an accessor is specified, promote it to a comparator. In this case we
2859
- // can test whether the search value is (self-) comparable. We can’t do this
2860
- // for a comparator (except for specific, known comparators) because we can’t
2861
- // tell if the comparator is symmetric, and an asymmetric comparator can’t be
2862
- // used to test whether a single value is comparable.
2863
- if (f.length !== 2) {
2864
- compare1 = ascending;
2865
- compare2 = (d, x) => ascending(f(d), x);
2866
- delta = (d, x) => f(d) - x;
2867
- } else {
2868
- compare1 = f === ascending || f === descending ? f : zero$1;
2869
- compare2 = f;
2870
- delta = f;
2871
- }
2872
-
2873
- function left(a, x, lo = 0, hi = a.length) {
2874
- if (lo < hi) {
2875
- if (compare1(x, x) !== 0) return hi;
2876
- do {
2877
- const mid = (lo + hi) >>> 1;
2878
- if (compare2(a[mid], x) < 0) lo = mid + 1;
2879
- else hi = mid;
2880
- } while (lo < hi);
2881
- }
2882
- return lo;
2883
- }
2884
-
2885
- function right(a, x, lo = 0, hi = a.length) {
2886
- if (lo < hi) {
2887
- if (compare1(x, x) !== 0) return hi;
2888
- do {
2889
- const mid = (lo + hi) >>> 1;
2890
- if (compare2(a[mid], x) <= 0) lo = mid + 1;
2891
- else hi = mid;
2892
- } while (lo < hi);
2893
- }
2894
- return lo;
2895
- }
2896
-
2897
- function center(a, x, lo = 0, hi = a.length) {
2898
- const i = left(a, x, lo, hi - 1);
2899
- return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
2900
- }
2901
-
2902
- return {left, center, right};
2903
- }
2904
-
2905
- function zero$1() {
2906
- return 0;
2907
- }
2908
-
2909
- function number$1(x) {
2910
- return x === null ? NaN : +x;
2911
- }
2912
-
2913
- const ascendingBisect = bisector(ascending);
2914
- const bisectRight = ascendingBisect.right;
2915
- bisector(number$1).center;
2916
- var bisect = bisectRight;
2917
-
2918
- class InternMap extends Map {
2919
- constructor(entries, key = keyof) {
2920
- super();
2921
- Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
2922
- if (entries != null) for (const [key, value] of entries) this.set(key, value);
2923
- }
2924
- get(key) {
2925
- return super.get(intern_get(this, key));
2926
- }
2927
- has(key) {
2928
- return super.has(intern_get(this, key));
2929
- }
2930
- set(key, value) {
2931
- return super.set(intern_set(this, key), value);
2932
- }
2933
- delete(key) {
2934
- return super.delete(intern_delete(this, key));
2935
- }
2936
- }
2937
-
2938
- function intern_get({_intern, _key}, value) {
2939
- const key = _key(value);
2940
- return _intern.has(key) ? _intern.get(key) : value;
2941
- }
2942
-
2943
- function intern_set({_intern, _key}, value) {
2944
- const key = _key(value);
2945
- if (_intern.has(key)) return _intern.get(key);
2946
- _intern.set(key, value);
2947
- return value;
2948
- }
2949
-
2950
- function intern_delete({_intern, _key}, value) {
2951
- const key = _key(value);
2952
- if (_intern.has(key)) {
2953
- value = _intern.get(key);
2954
- _intern.delete(key);
2955
- }
2956
- return value;
2957
- }
2958
-
2959
- function keyof(value) {
2960
- return value !== null && typeof value === "object" ? value.valueOf() : value;
2961
- }
2962
-
2963
- function identity$2(x) {
2964
- return x;
2965
- }
2966
-
2967
- function group(values, ...keys) {
2968
- return nest(values, identity$2, identity$2, keys);
2969
- }
2970
-
2971
- function nest(values, map, reduce, keys) {
2972
- return (function regroup(values, i) {
2973
- if (i >= keys.length) return reduce(values);
2974
- const groups = new InternMap();
2975
- const keyof = keys[i++];
2976
- let index = -1;
2977
- for (const value of values) {
2978
- const key = keyof(value, ++index, values);
2979
- const group = groups.get(key);
2980
- if (group) group.push(value);
2981
- else groups.set(key, [value]);
2982
- }
2983
- for (const [key, values] of groups) {
2984
- groups.set(key, regroup(values, i));
2985
- }
2986
- return map(groups);
2987
- })(values, 0);
2988
- }
2989
-
2990
- const e10 = Math.sqrt(50),
2991
- e5 = Math.sqrt(10),
2992
- e2 = Math.sqrt(2);
2993
-
2994
- function tickSpec(start, stop, count) {
2995
- const step = (stop - start) / Math.max(0, count),
2996
- power = Math.floor(Math.log10(step)),
2997
- error = step / Math.pow(10, power),
2998
- factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
2999
- let i1, i2, inc;
3000
- if (power < 0) {
3001
- inc = Math.pow(10, -power) / factor;
3002
- i1 = Math.round(start * inc);
3003
- i2 = Math.round(stop * inc);
3004
- if (i1 / inc < start) ++i1;
3005
- if (i2 / inc > stop) --i2;
3006
- inc = -inc;
3007
- } else {
3008
- inc = Math.pow(10, power) * factor;
3009
- i1 = Math.round(start / inc);
3010
- i2 = Math.round(stop / inc);
3011
- if (i1 * inc < start) ++i1;
3012
- if (i2 * inc > stop) --i2;
3013
- }
3014
- if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2);
3015
- return [i1, i2, inc];
3016
- }
3017
-
3018
- function ticks(start, stop, count) {
3019
- stop = +stop, start = +start, count = +count;
3020
- if (!(count > 0)) return [];
3021
- if (start === stop) return [start];
3022
- const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count);
3023
- if (!(i2 >= i1)) return [];
3024
- const n = i2 - i1 + 1, ticks = new Array(n);
3025
- if (reverse) {
3026
- if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) / -inc;
3027
- else for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) * inc;
3028
- } else {
3029
- if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) / -inc;
3030
- else for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) * inc;
3031
- }
3032
- return ticks;
3033
- }
3034
-
3035
- function tickIncrement(start, stop, count) {
3036
- stop = +stop, start = +start, count = +count;
3037
- return tickSpec(start, stop, count)[2];
3038
- }
3039
-
3040
- function tickStep(start, stop, count) {
3041
- stop = +stop, start = +start, count = +count;
3042
- const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count);
3043
- return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
3044
- }
3045
-
3046
- const TOP_PADDING = 20;
3047
- const PADDING = 2;
3048
-
3049
- const Node = ({ node, onMouseOver, onClick, selected }) => {
3050
- const { getModuleColor } = q(StaticContext);
3051
- const { backgroundColor, fontColor } = getModuleColor(node);
3052
- const { x0, x1, y1, y0, data, children = null } = node;
3053
- const textRef = _(null);
3054
- const textRectRef = _();
3055
- const width = x1 - x0;
3056
- const height = y1 - y0;
3057
- const textProps = {
3058
- "font-size": "0.7em",
3059
- "dominant-baseline": "middle",
3060
- "text-anchor": "middle",
3061
- x: width / 2,
3062
- };
3063
- if (children != null) {
3064
- textProps.y = (TOP_PADDING + PADDING) / 2;
3065
- }
3066
- else {
3067
- textProps.y = height / 2;
3068
- }
3069
- y(() => {
3070
- if (width == 0 || height == 0 || !textRef.current) {
3071
- return;
3072
- }
3073
- if (textRectRef.current == null) {
3074
- textRectRef.current = textRef.current.getBoundingClientRect();
3075
- }
3076
- let scale = 1;
3077
- if (children != null) {
3078
- scale = Math.min((width * 0.9) / textRectRef.current.width, Math.min(height, TOP_PADDING + PADDING) / textRectRef.current.height);
3079
- scale = Math.min(1, scale);
3080
- textRef.current.setAttribute("y", String(Math.min(TOP_PADDING + PADDING, height) / 2 / scale));
3081
- textRef.current.setAttribute("x", String(width / 2 / scale));
3082
- }
3083
- else {
3084
- scale = Math.min((width * 0.9) / textRectRef.current.width, (height * 0.9) / textRectRef.current.height);
3085
- scale = Math.min(1, scale);
3086
- textRef.current.setAttribute("y", String(height / 2 / scale));
3087
- textRef.current.setAttribute("x", String(width / 2 / scale));
3088
- }
3089
- textRef.current.setAttribute("transform", `scale(${scale.toFixed(2)})`);
3090
- }, [children, height, width]);
3091
- if (width == 0 || height == 0) {
3092
- return null;
3093
- }
3094
- return (u$1("g", { className: "node", transform: `translate(${x0},${y0})`, onClick: (event) => {
3095
- event.stopPropagation();
3096
- onClick(node);
3097
- }, onMouseOver: (event) => {
3098
- event.stopPropagation();
3099
- onMouseOver(node);
3100
- }, children: [u$1("rect", { fill: backgroundColor, rx: 2, ry: 2, width: x1 - x0, height: y1 - y0, stroke: selected ? "#fff" : undefined, "stroke-width": selected ? 2 : undefined }), u$1("text", Object.assign({ ref: textRef, fill: fontColor, onClick: (event) => {
3101
- var _a;
3102
- if (((_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString()) !== "") {
3103
- event.stopPropagation();
3104
- }
3105
- } }, textProps, { children: data.name }))] }));
3106
- };
3107
-
3108
- const TreeMap = ({ root, onNodeHover, selectedNode, onNodeClick, }) => {
3109
- const { width, height, getModuleIds } = q(StaticContext);
3110
- console.time("layering");
3111
- // this will make groups by height
3112
- const nestedData = F(() => {
3113
- const nestedDataMap = group(root.descendants(), (d) => d.height);
3114
- const nestedData = Array.from(nestedDataMap, ([key, values]) => ({
3115
- key,
3116
- values,
3117
- }));
3118
- nestedData.sort((a, b) => b.key - a.key);
3119
- return nestedData;
3120
- }, [root]);
3121
- console.timeEnd("layering");
3122
- return (u$1("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${width} ${height}`, children: nestedData.map(({ key, values }) => {
3123
- return (u$1("g", { className: "layer", children: values.map((node) => {
3124
- return (u$1(Node, { node: node, onMouseOver: onNodeHover, selected: selectedNode === node, onClick: onNodeClick }, getModuleIds(node.data).nodeUid.id));
3125
- }) }, key));
3126
- }) }));
3127
- };
3128
-
3129
- var bytes$1 = {exports: {}};
3130
-
3131
- /*!
3132
- * bytes
3133
- * Copyright(c) 2012-2014 TJ Holowaychuk
3134
- * Copyright(c) 2015 Jed Watson
3135
- * MIT Licensed
3136
- */
3137
-
3138
- /**
3139
- * Module exports.
3140
- * @public
3141
- */
3142
-
3143
- bytes$1.exports = bytes;
3144
- var format_1 = bytes$1.exports.format = format$1;
3145
- bytes$1.exports.parse = parse;
3146
-
3147
- /**
3148
- * Module variables.
3149
- * @private
3150
- */
3151
-
3152
- var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
3153
-
3154
- var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
3155
-
3156
- var map$1 = {
3157
- b: 1,
3158
- kb: 1 << 10,
3159
- mb: 1 << 20,
3160
- gb: 1 << 30,
3161
- tb: Math.pow(1024, 4),
3162
- pb: Math.pow(1024, 5),
3163
- };
3164
-
3165
- var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
3166
-
3167
- /**
3168
- * Convert the given value in bytes into a string or parse to string to an integer in bytes.
3169
- *
3170
- * @param {string|number} value
3171
- * @param {{
3172
- * case: [string],
3173
- * decimalPlaces: [number]
3174
- * fixedDecimals: [boolean]
3175
- * thousandsSeparator: [string]
3176
- * unitSeparator: [string]
3177
- * }} [options] bytes options.
3178
- *
3179
- * @returns {string|number|null}
3180
- */
3181
-
3182
- function bytes(value, options) {
3183
- if (typeof value === 'string') {
3184
- return parse(value);
3185
- }
3186
-
3187
- if (typeof value === 'number') {
3188
- return format$1(value, options);
3189
- }
3190
-
3191
- return null;
3192
- }
3193
-
3194
- /**
3195
- * Format the given value in bytes into a string.
3196
- *
3197
- * If the value is negative, it is kept as such. If it is a float,
3198
- * it is rounded.
3199
- *
3200
- * @param {number} value
3201
- * @param {object} [options]
3202
- * @param {number} [options.decimalPlaces=2]
3203
- * @param {number} [options.fixedDecimals=false]
3204
- * @param {string} [options.thousandsSeparator=]
3205
- * @param {string} [options.unit=]
3206
- * @param {string} [options.unitSeparator=]
3207
- *
3208
- * @returns {string|null}
3209
- * @public
3210
- */
3211
-
3212
- function format$1(value, options) {
3213
- if (!Number.isFinite(value)) {
3214
- return null;
3215
- }
3216
-
3217
- var mag = Math.abs(value);
3218
- var thousandsSeparator = (options && options.thousandsSeparator) || '';
3219
- var unitSeparator = (options && options.unitSeparator) || '';
3220
- var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
3221
- var fixedDecimals = Boolean(options && options.fixedDecimals);
3222
- var unit = (options && options.unit) || '';
3223
-
3224
- if (!unit || !map$1[unit.toLowerCase()]) {
3225
- if (mag >= map$1.pb) {
3226
- unit = 'PB';
3227
- } else if (mag >= map$1.tb) {
3228
- unit = 'TB';
3229
- } else if (mag >= map$1.gb) {
3230
- unit = 'GB';
3231
- } else if (mag >= map$1.mb) {
3232
- unit = 'MB';
3233
- } else if (mag >= map$1.kb) {
3234
- unit = 'KB';
3235
- } else {
3236
- unit = 'B';
3237
- }
3238
- }
3239
-
3240
- var val = value / map$1[unit.toLowerCase()];
3241
- var str = val.toFixed(decimalPlaces);
3242
-
3243
- if (!fixedDecimals) {
3244
- str = str.replace(formatDecimalsRegExp, '$1');
3245
- }
3246
-
3247
- if (thousandsSeparator) {
3248
- str = str.split('.').map(function (s, i) {
3249
- return i === 0
3250
- ? s.replace(formatThousandsRegExp, thousandsSeparator)
3251
- : s
3252
- }).join('.');
3253
- }
3254
-
3255
- return str + unitSeparator + unit;
3256
- }
3257
-
3258
- /**
3259
- * Parse the string value into an integer in bytes.
3260
- *
3261
- * If no unit is given, it is assumed the value is in bytes.
3262
- *
3263
- * @param {number|string} val
3264
- *
3265
- * @returns {number|null}
3266
- * @public
3267
- */
3268
-
3269
- function parse(val) {
3270
- if (typeof val === 'number' && !isNaN(val)) {
3271
- return val;
3272
- }
3273
-
3274
- if (typeof val !== 'string') {
3275
- return null;
3276
- }
3277
-
3278
- // Test if the string passed is valid
3279
- var results = parseRegExp.exec(val);
3280
- var floatValue;
3281
- var unit = 'b';
3282
-
3283
- if (!results) {
3284
- // Nothing could be extracted from the given string
3285
- floatValue = parseInt(val, 10);
3286
- unit = 'b';
3287
- } else {
3288
- // Retrieve the value and the unit
3289
- floatValue = parseFloat(results[1]);
3290
- unit = results[4].toLowerCase();
3291
- }
3292
-
3293
- if (isNaN(floatValue)) {
3294
- return null;
3295
- }
3296
-
3297
- return Math.floor(map$1[unit] * floatValue);
3298
- }
3299
-
3300
- const Tooltip_marginX = 10;
3301
- const Tooltip_marginY = 30;
3302
- const SOURCEMAP_RENDERED = (u$1("span", { children: [" ", u$1("b", { children: LABELS.renderedLength }), " is a number of characters in the file after individual and ", u$1("br", {}), " ", "whole bundle transformations according to sourcemap."] }));
3303
- const RENDRED = (u$1("span", { children: [u$1("b", { children: LABELS.renderedLength }), " is a byte size of individual file after transformations and treeshake."] }));
3304
- const COMPRESSED = (u$1("span", { children: [u$1("b", { children: LABELS.gzipLength }), " and ", u$1("b", { children: LABELS.brotliLength }), " is a byte size of individual file after individual transformations,", u$1("br", {}), " treeshake and compression."] }));
3305
- const Tooltip = ({ node, visible, root, sizeProperty, }) => {
3306
- const { availableSizeProperties, getModuleSize, data } = q(StaticContext);
3307
- const ref = _(null);
3308
- const [style, setStyle] = h({});
3309
- const content = F(() => {
3310
- if (!node)
3311
- return null;
3312
- const mainSize = getModuleSize(node.data, sizeProperty);
3313
- const percentageNum = (100 * mainSize) / getModuleSize(root.data, sizeProperty);
3314
- const percentage = percentageNum.toFixed(2);
3315
- const percentageString = percentage + "%";
3316
- const path = node
3317
- .ancestors()
3318
- .reverse()
3319
- .map((d) => d.data.name)
3320
- .join("/");
3321
- let dataNode = null;
3322
- if (!isModuleTree(node.data)) {
3323
- const mainUid = data.nodeParts[node.data.uid].metaUid;
3324
- dataNode = data.nodeMetas[mainUid];
3325
- }
3326
- return (u$1(g$1, { children: [u$1("div", { children: path }), availableSizeProperties.map((sizeProp) => {
3327
- if (sizeProp === sizeProperty) {
3328
- return (u$1("div", { children: [u$1("b", { children: [LABELS[sizeProp], ": ", format_1(mainSize)] }), " ", "(", percentageString, ")"] }, sizeProp));
3329
- }
3330
- else {
3331
- return (u$1("div", { children: [LABELS[sizeProp], ": ", format_1(getModuleSize(node.data, sizeProp))] }, sizeProp));
3332
- }
3333
- }), u$1("br", {}), dataNode && dataNode.importedBy.length > 0 && (u$1("div", { children: [u$1("div", { children: [u$1("b", { children: "Imported By" }), ":"] }), dataNode.importedBy.map(({ uid }) => {
3334
- const id = data.nodeMetas[uid].id;
3335
- return u$1("div", { children: id }, id);
3336
- })] })), u$1("br", {}), u$1("small", { children: data.options.sourcemap ? SOURCEMAP_RENDERED : RENDRED }), (data.options.gzip || data.options.brotli) && (u$1(g$1, { children: [u$1("br", {}), u$1("small", { children: COMPRESSED })] }))] }));
3337
- }, [availableSizeProperties, data, getModuleSize, node, root.data, sizeProperty]);
3338
- const updatePosition = (mouseCoords) => {
3339
- if (!ref.current)
3340
- return;
3341
- const pos = {
3342
- left: mouseCoords.x + Tooltip_marginX,
3343
- top: mouseCoords.y + Tooltip_marginY,
3344
- };
3345
- const boundingRect = ref.current.getBoundingClientRect();
3346
- if (pos.left + boundingRect.width > window.innerWidth) {
3347
- // Shifting horizontally
3348
- pos.left = window.innerWidth - boundingRect.width;
3349
- }
3350
- if (pos.top + boundingRect.height > window.innerHeight) {
3351
- // Flipping vertically
3352
- pos.top = mouseCoords.y - Tooltip_marginY - boundingRect.height;
3353
- }
3354
- setStyle(pos);
3355
- };
3356
- p(() => {
3357
- const handleMouseMove = (event) => {
3358
- updatePosition({
3359
- x: event.pageX,
3360
- y: event.pageY,
3361
- });
3362
- };
3363
- document.addEventListener("mousemove", handleMouseMove, true);
3364
- return () => {
3365
- document.removeEventListener("mousemove", handleMouseMove, true);
3366
- };
3367
- }, []);
3368
- return (u$1("div", { className: `tooltip ${visible ? "" : "tooltip-hidden"}`, ref: ref, style: style, children: content }));
3369
- };
3370
-
3371
- const Chart = ({ root, sizeProperty, selectedNode, setSelectedNode, }) => {
3372
- const [showTooltip, setShowTooltip] = h(false);
3373
- const [tooltipNode, setTooltipNode] = h(undefined);
3374
- p(() => {
3375
- const handleMouseOut = () => {
3376
- setShowTooltip(false);
3377
- };
3378
- document.addEventListener("mouseover", handleMouseOut);
3379
- return () => {
3380
- document.removeEventListener("mouseover", handleMouseOut);
3381
- };
3382
- }, []);
3383
- return (u$1(g$1, { children: [u$1(TreeMap, { root: root, onNodeHover: (node) => {
3384
- setTooltipNode(node);
3385
- setShowTooltip(true);
3386
- }, selectedNode: selectedNode, onNodeClick: (node) => {
3387
- setSelectedNode(selectedNode === node ? undefined : node);
3388
- } }), u$1(Tooltip, { visible: showTooltip, node: tooltipNode, root: root, sizeProperty: sizeProperty })] }));
3389
- };
3390
-
3391
- const Main = () => {
3392
- const { availableSizeProperties, rawHierarchy, getModuleSize, layout, data } = q(StaticContext);
3393
- const [sizeProperty, setSizeProperty] = h(availableSizeProperties[0]);
3394
- const [selectedNode, setSelectedNode] = h(undefined);
3395
- const { getModuleFilterMultiplier, setExcludeFilter, setIncludeFilter } = useFilter();
3396
- console.time("getNodeSizeMultiplier");
3397
- const getNodeSizeMultiplier = F(() => {
3398
- const selectedMultiplier = 1; // selectedSize < rootSize * increaseFactor ? (rootSize * increaseFactor) / selectedSize : rootSize / selectedSize;
3399
- const nonSelectedMultiplier = 0; // 1 / selectedMultiplier
3400
- if (selectedNode === undefined) {
3401
- return () => 1;
3402
- }
3403
- else if (isModuleTree(selectedNode.data)) {
3404
- const leaves = new Set(selectedNode.leaves().map((d) => d.data));
3405
- return (node) => {
3406
- if (leaves.has(node)) {
3407
- return selectedMultiplier;
3408
- }
3409
- return nonSelectedMultiplier;
3410
- };
3411
- }
3412
- else {
3413
- return (node) => {
3414
- if (node === selectedNode.data) {
3415
- return selectedMultiplier;
3416
- }
3417
- return nonSelectedMultiplier;
3418
- };
3419
- }
3420
- }, [getModuleSize, rawHierarchy.data, selectedNode, sizeProperty]);
3421
- console.timeEnd("getNodeSizeMultiplier");
3422
- console.time("root hierarchy compute");
3423
- // root here always be the same as rawHierarchy even after layouting
3424
- const root = F(() => {
3425
- const rootWithSizesAndSorted = rawHierarchy
3426
- .sum((node) => {
3427
- var _a;
3428
- if (isModuleTree(node))
3429
- return 0;
3430
- const meta = data.nodeMetas[data.nodeParts[node.uid].metaUid];
3431
- const bundleId = (_a = Object.entries(meta.moduleParts).find(([bundleId, uid]) => uid == node.uid)) === null || _a === void 0 ? void 0 : _a[0];
3432
- const ownSize = getModuleSize(node, sizeProperty);
3433
- const zoomMultiplier = getNodeSizeMultiplier(node);
3434
- const filterMultiplier = getModuleFilterMultiplier(bundleId, meta);
3435
- return ownSize * zoomMultiplier * filterMultiplier;
3436
- })
3437
- .sort((a, b) => getModuleSize(a.data, sizeProperty) - getModuleSize(b.data, sizeProperty));
3438
- return layout(rootWithSizesAndSorted);
3439
- }, [
3440
- data,
3441
- getModuleFilterMultiplier,
3442
- getModuleSize,
3443
- getNodeSizeMultiplier,
3444
- layout,
3445
- rawHierarchy,
3446
- sizeProperty,
3447
- ]);
3448
- console.timeEnd("root hierarchy compute");
3449
- return (u$1(g$1, { children: [u$1(SideBar, { sizeProperty: sizeProperty, availableSizeProperties: availableSizeProperties, setSizeProperty: setSizeProperty, onExcludeChange: setExcludeFilter, onIncludeChange: setIncludeFilter }), u$1(Chart, { root: root, sizeProperty: sizeProperty, selectedNode: selectedNode, setSelectedNode: setSelectedNode })] }));
3450
- };
3451
-
3452
- function initRange(domain, range) {
3453
- switch (arguments.length) {
3454
- case 0: break;
3455
- case 1: this.range(domain); break;
3456
- default: this.range(range).domain(domain); break;
3457
- }
3458
- return this;
3459
- }
3460
-
3461
- function initInterpolator(domain, interpolator) {
3462
- switch (arguments.length) {
3463
- case 0: break;
3464
- case 1: {
3465
- if (typeof domain === "function") this.interpolator(domain);
3466
- else this.range(domain);
3467
- break;
3468
- }
3469
- default: {
3470
- this.domain(domain);
3471
- if (typeof interpolator === "function") this.interpolator(interpolator);
3472
- else this.range(interpolator);
3473
- break;
3474
- }
3475
- }
3476
- return this;
3477
- }
3478
-
3479
- function define(constructor, factory, prototype) {
3480
- constructor.prototype = factory.prototype = prototype;
3481
- prototype.constructor = constructor;
3482
- }
3483
-
3484
- function extend(parent, definition) {
3485
- var prototype = Object.create(parent.prototype);
3486
- for (var key in definition) prototype[key] = definition[key];
3487
- return prototype;
3488
- }
3489
-
3490
- function Color() {}
3491
-
3492
- var darker = 0.7;
3493
- var brighter = 1 / darker;
3494
-
3495
- var reI = "\\s*([+-]?\\d+)\\s*",
3496
- reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",
3497
- reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
3498
- reHex = /^#([0-9a-f]{3,8})$/,
3499
- reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`),
3500
- reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`),
3501
- reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`),
3502
- reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`),
3503
- reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`),
3504
- reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
3505
-
3506
- var named = {
3507
- aliceblue: 0xf0f8ff,
3508
- antiquewhite: 0xfaebd7,
3509
- aqua: 0x00ffff,
3510
- aquamarine: 0x7fffd4,
3511
- azure: 0xf0ffff,
3512
- beige: 0xf5f5dc,
3513
- bisque: 0xffe4c4,
3514
- black: 0x000000,
3515
- blanchedalmond: 0xffebcd,
3516
- blue: 0x0000ff,
3517
- blueviolet: 0x8a2be2,
3518
- brown: 0xa52a2a,
3519
- burlywood: 0xdeb887,
3520
- cadetblue: 0x5f9ea0,
3521
- chartreuse: 0x7fff00,
3522
- chocolate: 0xd2691e,
3523
- coral: 0xff7f50,
3524
- cornflowerblue: 0x6495ed,
3525
- cornsilk: 0xfff8dc,
3526
- crimson: 0xdc143c,
3527
- cyan: 0x00ffff,
3528
- darkblue: 0x00008b,
3529
- darkcyan: 0x008b8b,
3530
- darkgoldenrod: 0xb8860b,
3531
- darkgray: 0xa9a9a9,
3532
- darkgreen: 0x006400,
3533
- darkgrey: 0xa9a9a9,
3534
- darkkhaki: 0xbdb76b,
3535
- darkmagenta: 0x8b008b,
3536
- darkolivegreen: 0x556b2f,
3537
- darkorange: 0xff8c00,
3538
- darkorchid: 0x9932cc,
3539
- darkred: 0x8b0000,
3540
- darksalmon: 0xe9967a,
3541
- darkseagreen: 0x8fbc8f,
3542
- darkslateblue: 0x483d8b,
3543
- darkslategray: 0x2f4f4f,
3544
- darkslategrey: 0x2f4f4f,
3545
- darkturquoise: 0x00ced1,
3546
- darkviolet: 0x9400d3,
3547
- deeppink: 0xff1493,
3548
- deepskyblue: 0x00bfff,
3549
- dimgray: 0x696969,
3550
- dimgrey: 0x696969,
3551
- dodgerblue: 0x1e90ff,
3552
- firebrick: 0xb22222,
3553
- floralwhite: 0xfffaf0,
3554
- forestgreen: 0x228b22,
3555
- fuchsia: 0xff00ff,
3556
- gainsboro: 0xdcdcdc,
3557
- ghostwhite: 0xf8f8ff,
3558
- gold: 0xffd700,
3559
- goldenrod: 0xdaa520,
3560
- gray: 0x808080,
3561
- green: 0x008000,
3562
- greenyellow: 0xadff2f,
3563
- grey: 0x808080,
3564
- honeydew: 0xf0fff0,
3565
- hotpink: 0xff69b4,
3566
- indianred: 0xcd5c5c,
3567
- indigo: 0x4b0082,
3568
- ivory: 0xfffff0,
3569
- khaki: 0xf0e68c,
3570
- lavender: 0xe6e6fa,
3571
- lavenderblush: 0xfff0f5,
3572
- lawngreen: 0x7cfc00,
3573
- lemonchiffon: 0xfffacd,
3574
- lightblue: 0xadd8e6,
3575
- lightcoral: 0xf08080,
3576
- lightcyan: 0xe0ffff,
3577
- lightgoldenrodyellow: 0xfafad2,
3578
- lightgray: 0xd3d3d3,
3579
- lightgreen: 0x90ee90,
3580
- lightgrey: 0xd3d3d3,
3581
- lightpink: 0xffb6c1,
3582
- lightsalmon: 0xffa07a,
3583
- lightseagreen: 0x20b2aa,
3584
- lightskyblue: 0x87cefa,
3585
- lightslategray: 0x778899,
3586
- lightslategrey: 0x778899,
3587
- lightsteelblue: 0xb0c4de,
3588
- lightyellow: 0xffffe0,
3589
- lime: 0x00ff00,
3590
- limegreen: 0x32cd32,
3591
- linen: 0xfaf0e6,
3592
- magenta: 0xff00ff,
3593
- maroon: 0x800000,
3594
- mediumaquamarine: 0x66cdaa,
3595
- mediumblue: 0x0000cd,
3596
- mediumorchid: 0xba55d3,
3597
- mediumpurple: 0x9370db,
3598
- mediumseagreen: 0x3cb371,
3599
- mediumslateblue: 0x7b68ee,
3600
- mediumspringgreen: 0x00fa9a,
3601
- mediumturquoise: 0x48d1cc,
3602
- mediumvioletred: 0xc71585,
3603
- midnightblue: 0x191970,
3604
- mintcream: 0xf5fffa,
3605
- mistyrose: 0xffe4e1,
3606
- moccasin: 0xffe4b5,
3607
- navajowhite: 0xffdead,
3608
- navy: 0x000080,
3609
- oldlace: 0xfdf5e6,
3610
- olive: 0x808000,
3611
- olivedrab: 0x6b8e23,
3612
- orange: 0xffa500,
3613
- orangered: 0xff4500,
3614
- orchid: 0xda70d6,
3615
- palegoldenrod: 0xeee8aa,
3616
- palegreen: 0x98fb98,
3617
- paleturquoise: 0xafeeee,
3618
- palevioletred: 0xdb7093,
3619
- papayawhip: 0xffefd5,
3620
- peachpuff: 0xffdab9,
3621
- peru: 0xcd853f,
3622
- pink: 0xffc0cb,
3623
- plum: 0xdda0dd,
3624
- powderblue: 0xb0e0e6,
3625
- purple: 0x800080,
3626
- rebeccapurple: 0x663399,
3627
- red: 0xff0000,
3628
- rosybrown: 0xbc8f8f,
3629
- royalblue: 0x4169e1,
3630
- saddlebrown: 0x8b4513,
3631
- salmon: 0xfa8072,
3632
- sandybrown: 0xf4a460,
3633
- seagreen: 0x2e8b57,
3634
- seashell: 0xfff5ee,
3635
- sienna: 0xa0522d,
3636
- silver: 0xc0c0c0,
3637
- skyblue: 0x87ceeb,
3638
- slateblue: 0x6a5acd,
3639
- slategray: 0x708090,
3640
- slategrey: 0x708090,
3641
- snow: 0xfffafa,
3642
- springgreen: 0x00ff7f,
3643
- steelblue: 0x4682b4,
3644
- tan: 0xd2b48c,
3645
- teal: 0x008080,
3646
- thistle: 0xd8bfd8,
3647
- tomato: 0xff6347,
3648
- turquoise: 0x40e0d0,
3649
- violet: 0xee82ee,
3650
- wheat: 0xf5deb3,
3651
- white: 0xffffff,
3652
- whitesmoke: 0xf5f5f5,
3653
- yellow: 0xffff00,
3654
- yellowgreen: 0x9acd32
3655
- };
3656
-
3657
- define(Color, color, {
3658
- copy(channels) {
3659
- return Object.assign(new this.constructor, this, channels);
3660
- },
3661
- displayable() {
3662
- return this.rgb().displayable();
3663
- },
3664
- hex: color_formatHex, // Deprecated! Use color.formatHex.
3665
- formatHex: color_formatHex,
3666
- formatHex8: color_formatHex8,
3667
- formatHsl: color_formatHsl,
3668
- formatRgb: color_formatRgb,
3669
- toString: color_formatRgb
3670
- });
3671
-
3672
- function color_formatHex() {
3673
- return this.rgb().formatHex();
3674
- }
3675
-
3676
- function color_formatHex8() {
3677
- return this.rgb().formatHex8();
3678
- }
3679
-
3680
- function color_formatHsl() {
3681
- return hslConvert(this).formatHsl();
3682
- }
3683
-
3684
- function color_formatRgb() {
3685
- return this.rgb().formatRgb();
3686
- }
3687
-
3688
- function color(format) {
3689
- var m, l;
3690
- format = (format + "").trim().toLowerCase();
3691
- return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
3692
- : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
3693
- : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
3694
- : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
3695
- : null) // invalid hex
3696
- : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
3697
- : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
3698
- : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
3699
- : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
3700
- : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
3701
- : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
3702
- : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
3703
- : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
3704
- : null;
3705
- }
3706
-
3707
- function rgbn(n) {
3708
- return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
3709
- }
3710
-
3711
- function rgba(r, g, b, a) {
3712
- if (a <= 0) r = g = b = NaN;
3713
- return new Rgb(r, g, b, a);
3714
- }
3715
-
3716
- function rgbConvert(o) {
3717
- if (!(o instanceof Color)) o = color(o);
3718
- if (!o) return new Rgb;
3719
- o = o.rgb();
3720
- return new Rgb(o.r, o.g, o.b, o.opacity);
3721
- }
3722
-
3723
- function rgb$1(r, g, b, opacity) {
3724
- return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
3725
- }
3726
-
3727
- function Rgb(r, g, b, opacity) {
3728
- this.r = +r;
3729
- this.g = +g;
3730
- this.b = +b;
3731
- this.opacity = +opacity;
3732
- }
3733
-
3734
- define(Rgb, rgb$1, extend(Color, {
3735
- brighter(k) {
3736
- k = k == null ? brighter : Math.pow(brighter, k);
3737
- return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
3738
- },
3739
- darker(k) {
3740
- k = k == null ? darker : Math.pow(darker, k);
3741
- return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
3742
- },
3743
- rgb() {
3744
- return this;
3745
- },
3746
- clamp() {
3747
- return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
3748
- },
3749
- displayable() {
3750
- return (-0.5 <= this.r && this.r < 255.5)
3751
- && (-0.5 <= this.g && this.g < 255.5)
3752
- && (-0.5 <= this.b && this.b < 255.5)
3753
- && (0 <= this.opacity && this.opacity <= 1);
3754
- },
3755
- hex: rgb_formatHex, // Deprecated! Use color.formatHex.
3756
- formatHex: rgb_formatHex,
3757
- formatHex8: rgb_formatHex8,
3758
- formatRgb: rgb_formatRgb,
3759
- toString: rgb_formatRgb
3760
- }));
3761
-
3762
- function rgb_formatHex() {
3763
- return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
3764
- }
3765
-
3766
- function rgb_formatHex8() {
3767
- return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
3768
- }
3769
-
3770
- function rgb_formatRgb() {
3771
- const a = clampa(this.opacity);
3772
- return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
3773
- }
3774
-
3775
- function clampa(opacity) {
3776
- return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
3777
- }
3778
-
3779
- function clampi(value) {
3780
- return Math.max(0, Math.min(255, Math.round(value) || 0));
3781
- }
3782
-
3783
- function hex(value) {
3784
- value = clampi(value);
3785
- return (value < 16 ? "0" : "") + value.toString(16);
3786
- }
3787
-
3788
- function hsla(h, s, l, a) {
3789
- if (a <= 0) h = s = l = NaN;
3790
- else if (l <= 0 || l >= 1) h = s = NaN;
3791
- else if (s <= 0) h = NaN;
3792
- return new Hsl(h, s, l, a);
3793
- }
3794
-
3795
- function hslConvert(o) {
3796
- if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
3797
- if (!(o instanceof Color)) o = color(o);
3798
- if (!o) return new Hsl;
3799
- if (o instanceof Hsl) return o;
3800
- o = o.rgb();
3801
- var r = o.r / 255,
3802
- g = o.g / 255,
3803
- b = o.b / 255,
3804
- min = Math.min(r, g, b),
3805
- max = Math.max(r, g, b),
3806
- h = NaN,
3807
- s = max - min,
3808
- l = (max + min) / 2;
3809
- if (s) {
3810
- if (r === max) h = (g - b) / s + (g < b) * 6;
3811
- else if (g === max) h = (b - r) / s + 2;
3812
- else h = (r - g) / s + 4;
3813
- s /= l < 0.5 ? max + min : 2 - max - min;
3814
- h *= 60;
3815
- } else {
3816
- s = l > 0 && l < 1 ? 0 : h;
3817
- }
3818
- return new Hsl(h, s, l, o.opacity);
3819
- }
3820
-
3821
- function hsl(h, s, l, opacity) {
3822
- return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
3823
- }
3824
-
3825
- function Hsl(h, s, l, opacity) {
3826
- this.h = +h;
3827
- this.s = +s;
3828
- this.l = +l;
3829
- this.opacity = +opacity;
3830
- }
3831
-
3832
- define(Hsl, hsl, extend(Color, {
3833
- brighter(k) {
3834
- k = k == null ? brighter : Math.pow(brighter, k);
3835
- return new Hsl(this.h, this.s, this.l * k, this.opacity);
3836
- },
3837
- darker(k) {
3838
- k = k == null ? darker : Math.pow(darker, k);
3839
- return new Hsl(this.h, this.s, this.l * k, this.opacity);
3840
- },
3841
- rgb() {
3842
- var h = this.h % 360 + (this.h < 0) * 360,
3843
- s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
3844
- l = this.l,
3845
- m2 = l + (l < 0.5 ? l : 1 - l) * s,
3846
- m1 = 2 * l - m2;
3847
- return new Rgb(
3848
- hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
3849
- hsl2rgb(h, m1, m2),
3850
- hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
3851
- this.opacity
3852
- );
3853
- },
3854
- clamp() {
3855
- return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
3856
- },
3857
- displayable() {
3858
- return (0 <= this.s && this.s <= 1 || isNaN(this.s))
3859
- && (0 <= this.l && this.l <= 1)
3860
- && (0 <= this.opacity && this.opacity <= 1);
3861
- },
3862
- formatHsl() {
3863
- const a = clampa(this.opacity);
3864
- return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
3865
- }
3866
- }));
3867
-
3868
- function clamph(value) {
3869
- value = (value || 0) % 360;
3870
- return value < 0 ? value + 360 : value;
3871
- }
3872
-
3873
- function clampt(value) {
3874
- return Math.max(0, Math.min(1, value || 0));
3875
- }
3876
-
3877
- /* From FvD 13.37, CSS Color Module Level 3 */
3878
- function hsl2rgb(h, m1, m2) {
3879
- return (h < 60 ? m1 + (m2 - m1) * h / 60
3880
- : h < 180 ? m2
3881
- : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
3882
- : m1) * 255;
3883
- }
3884
-
3885
- var constant = x => () => x;
3886
-
3887
- function linear$1(a, d) {
3888
- return function(t) {
3889
- return a + t * d;
3890
- };
3891
- }
3892
-
3893
- function exponential(a, b, y) {
3894
- return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
3895
- return Math.pow(a + t * b, y);
3896
- };
3897
- }
3898
-
3899
- function gamma(y) {
3900
- return (y = +y) === 1 ? nogamma : function(a, b) {
3901
- return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
3902
- };
3903
- }
3904
-
3905
- function nogamma(a, b) {
3906
- var d = b - a;
3907
- return d ? linear$1(a, d) : constant(isNaN(a) ? b : a);
3908
- }
3909
-
3910
- var rgb = (function rgbGamma(y) {
3911
- var color = gamma(y);
3912
-
3913
- function rgb(start, end) {
3914
- var r = color((start = rgb$1(start)).r, (end = rgb$1(end)).r),
3915
- g = color(start.g, end.g),
3916
- b = color(start.b, end.b),
3917
- opacity = nogamma(start.opacity, end.opacity);
3918
- return function(t) {
3919
- start.r = r(t);
3920
- start.g = g(t);
3921
- start.b = b(t);
3922
- start.opacity = opacity(t);
3923
- return start + "";
3924
- };
3925
- }
3926
-
3927
- rgb.gamma = rgbGamma;
3928
-
3929
- return rgb;
3930
- })(1);
3931
-
3932
- function numberArray(a, b) {
3933
- if (!b) b = [];
3934
- var n = a ? Math.min(b.length, a.length) : 0,
3935
- c = b.slice(),
3936
- i;
3937
- return function(t) {
3938
- for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
3939
- return c;
3940
- };
3941
- }
3942
-
3943
- function isNumberArray(x) {
3944
- return ArrayBuffer.isView(x) && !(x instanceof DataView);
3945
- }
3946
-
3947
- function genericArray(a, b) {
3948
- var nb = b ? b.length : 0,
3949
- na = a ? Math.min(nb, a.length) : 0,
3950
- x = new Array(na),
3951
- c = new Array(nb),
3952
- i;
3953
-
3954
- for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]);
3955
- for (; i < nb; ++i) c[i] = b[i];
3956
-
3957
- return function(t) {
3958
- for (i = 0; i < na; ++i) c[i] = x[i](t);
3959
- return c;
3960
- };
3961
- }
3962
-
3963
- function date(a, b) {
3964
- var d = new Date;
3965
- return a = +a, b = +b, function(t) {
3966
- return d.setTime(a * (1 - t) + b * t), d;
3967
- };
3968
- }
3969
-
3970
- function interpolateNumber(a, b) {
3971
- return a = +a, b = +b, function(t) {
3972
- return a * (1 - t) + b * t;
3973
- };
3974
- }
3975
-
3976
- function object(a, b) {
3977
- var i = {},
3978
- c = {},
3979
- k;
3980
-
3981
- if (a === null || typeof a !== "object") a = {};
3982
- if (b === null || typeof b !== "object") b = {};
3983
-
3984
- for (k in b) {
3985
- if (k in a) {
3986
- i[k] = interpolate(a[k], b[k]);
3987
- } else {
3988
- c[k] = b[k];
3989
- }
3990
- }
3991
-
3992
- return function(t) {
3993
- for (k in i) c[k] = i[k](t);
3994
- return c;
3995
- };
3996
- }
3997
-
3998
- var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
3999
- reB = new RegExp(reA.source, "g");
4000
-
4001
- function zero(b) {
4002
- return function() {
4003
- return b;
4004
- };
4005
- }
4006
-
4007
- function one(b) {
4008
- return function(t) {
4009
- return b(t) + "";
4010
- };
4011
- }
4012
-
4013
- function string(a, b) {
4014
- var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
4015
- am, // current match in a
4016
- bm, // current match in b
4017
- bs, // string preceding current number in b, if any
4018
- i = -1, // index in s
4019
- s = [], // string constants and placeholders
4020
- q = []; // number interpolators
4021
-
4022
- // Coerce inputs to strings.
4023
- a = a + "", b = b + "";
4024
-
4025
- // Interpolate pairs of numbers in a & b.
4026
- while ((am = reA.exec(a))
4027
- && (bm = reB.exec(b))) {
4028
- if ((bs = bm.index) > bi) { // a string precedes the next number in b
4029
- bs = b.slice(bi, bs);
4030
- if (s[i]) s[i] += bs; // coalesce with previous string
4031
- else s[++i] = bs;
4032
- }
4033
- if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
4034
- if (s[i]) s[i] += bm; // coalesce with previous string
4035
- else s[++i] = bm;
4036
- } else { // interpolate non-matching numbers
4037
- s[++i] = null;
4038
- q.push({i: i, x: interpolateNumber(am, bm)});
4039
- }
4040
- bi = reB.lastIndex;
4041
- }
4042
-
4043
- // Add remains of b.
4044
- if (bi < b.length) {
4045
- bs = b.slice(bi);
4046
- if (s[i]) s[i] += bs; // coalesce with previous string
4047
- else s[++i] = bs;
4048
- }
4049
-
4050
- // Special optimization for only a single match.
4051
- // Otherwise, interpolate each of the numbers and rejoin the string.
4052
- return s.length < 2 ? (q[0]
4053
- ? one(q[0].x)
4054
- : zero(b))
4055
- : (b = q.length, function(t) {
4056
- for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
4057
- return s.join("");
4058
- });
4059
- }
4060
-
4061
- function interpolate(a, b) {
4062
- var t = typeof b, c;
4063
- return b == null || t === "boolean" ? constant(b)
4064
- : (t === "number" ? interpolateNumber
4065
- : t === "string" ? ((c = color(b)) ? (b = c, rgb) : string)
4066
- : b instanceof color ? rgb
4067
- : b instanceof Date ? date
4068
- : isNumberArray(b) ? numberArray
4069
- : Array.isArray(b) ? genericArray
4070
- : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
4071
- : interpolateNumber)(a, b);
4072
- }
4073
-
4074
- function interpolateRound(a, b) {
4075
- return a = +a, b = +b, function(t) {
4076
- return Math.round(a * (1 - t) + b * t);
4077
- };
4078
- }
4079
-
4080
- function constants(x) {
4081
- return function() {
4082
- return x;
4083
- };
4084
- }
4085
-
4086
- function number(x) {
4087
- return +x;
4088
- }
4089
-
4090
- var unit = [0, 1];
4091
-
4092
- function identity$1(x) {
4093
- return x;
4094
- }
4095
-
4096
- function normalize(a, b) {
4097
- return (b -= (a = +a))
4098
- ? function(x) { return (x - a) / b; }
4099
- : constants(isNaN(b) ? NaN : 0.5);
4100
- }
4101
-
4102
- function clamper(a, b) {
4103
- var t;
4104
- if (a > b) t = a, a = b, b = t;
4105
- return function(x) { return Math.max(a, Math.min(b, x)); };
4106
- }
4107
-
4108
- // normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
4109
- // interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
4110
- function bimap(domain, range, interpolate) {
4111
- var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
4112
- if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
4113
- else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
4114
- return function(x) { return r0(d0(x)); };
4115
- }
4116
-
4117
- function polymap(domain, range, interpolate) {
4118
- var j = Math.min(domain.length, range.length) - 1,
4119
- d = new Array(j),
4120
- r = new Array(j),
4121
- i = -1;
4122
-
4123
- // Reverse descending domains.
4124
- if (domain[j] < domain[0]) {
4125
- domain = domain.slice().reverse();
4126
- range = range.slice().reverse();
4127
- }
4128
-
4129
- while (++i < j) {
4130
- d[i] = normalize(domain[i], domain[i + 1]);
4131
- r[i] = interpolate(range[i], range[i + 1]);
4132
- }
4133
-
4134
- return function(x) {
4135
- var i = bisect(domain, x, 1, j) - 1;
4136
- return r[i](d[i](x));
4137
- };
4138
- }
4139
-
4140
- function copy$1(source, target) {
4141
- return target
4142
- .domain(source.domain())
4143
- .range(source.range())
4144
- .interpolate(source.interpolate())
4145
- .clamp(source.clamp())
4146
- .unknown(source.unknown());
4147
- }
4148
-
4149
- function transformer$1() {
4150
- var domain = unit,
4151
- range = unit,
4152
- interpolate$1 = interpolate,
4153
- transform,
4154
- untransform,
4155
- unknown,
4156
- clamp = identity$1,
4157
- piecewise,
4158
- output,
4159
- input;
4160
-
4161
- function rescale() {
4162
- var n = Math.min(domain.length, range.length);
4163
- if (clamp !== identity$1) clamp = clamper(domain[0], domain[n - 1]);
4164
- piecewise = n > 2 ? polymap : bimap;
4165
- output = input = null;
4166
- return scale;
4167
- }
4168
-
4169
- function scale(x) {
4170
- return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x)));
4171
- }
4172
-
4173
- scale.invert = function(y) {
4174
- return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
4175
- };
4176
-
4177
- scale.domain = function(_) {
4178
- return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
4179
- };
4180
-
4181
- scale.range = function(_) {
4182
- return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
4183
- };
4184
-
4185
- scale.rangeRound = function(_) {
4186
- return range = Array.from(_), interpolate$1 = interpolateRound, rescale();
4187
- };
4188
-
4189
- scale.clamp = function(_) {
4190
- return arguments.length ? (clamp = _ ? true : identity$1, rescale()) : clamp !== identity$1;
4191
- };
4192
-
4193
- scale.interpolate = function(_) {
4194
- return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1;
4195
- };
4196
-
4197
- scale.unknown = function(_) {
4198
- return arguments.length ? (unknown = _, scale) : unknown;
4199
- };
4200
-
4201
- return function(t, u) {
4202
- transform = t, untransform = u;
4203
- return rescale();
4204
- };
4205
- }
4206
-
4207
- function continuous() {
4208
- return transformer$1()(identity$1, identity$1);
4209
- }
4210
-
4211
- function formatDecimal(x) {
4212
- return Math.abs(x = Math.round(x)) >= 1e21
4213
- ? x.toLocaleString("en").replace(/,/g, "")
4214
- : x.toString(10);
4215
- }
4216
-
4217
- // Computes the decimal coefficient and exponent of the specified number x with
4218
- // significant digits p, where x is positive and p is in [1, 21] or undefined.
4219
- // For example, formatDecimalParts(1.23) returns ["123", 0].
4220
- function formatDecimalParts(x, p) {
4221
- if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
4222
- var i, coefficient = x.slice(0, i);
4223
-
4224
- // The string returned by toExponential either has the form \d\.\d+e[-+]\d+
4225
- // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
4226
- return [
4227
- coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
4228
- +x.slice(i + 1)
4229
- ];
4230
- }
4231
-
4232
- function exponent(x) {
4233
- return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
4234
- }
4235
-
4236
- function formatGroup(grouping, thousands) {
4237
- return function(value, width) {
4238
- var i = value.length,
4239
- t = [],
4240
- j = 0,
4241
- g = grouping[0],
4242
- length = 0;
4243
-
4244
- while (i > 0 && g > 0) {
4245
- if (length + g + 1 > width) g = Math.max(1, width - length);
4246
- t.push(value.substring(i -= g, i + g));
4247
- if ((length += g + 1) > width) break;
4248
- g = grouping[j = (j + 1) % grouping.length];
4249
- }
4250
-
4251
- return t.reverse().join(thousands);
4252
- };
4253
- }
4254
-
4255
- function formatNumerals(numerals) {
4256
- return function(value) {
4257
- return value.replace(/[0-9]/g, function(i) {
4258
- return numerals[+i];
4259
- });
4260
- };
4261
- }
4262
-
4263
- // [[fill]align][sign][symbol][0][width][,][.precision][~][type]
4264
- var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
4265
-
4266
- function formatSpecifier(specifier) {
4267
- if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
4268
- var match;
4269
- return new FormatSpecifier({
4270
- fill: match[1],
4271
- align: match[2],
4272
- sign: match[3],
4273
- symbol: match[4],
4274
- zero: match[5],
4275
- width: match[6],
4276
- comma: match[7],
4277
- precision: match[8] && match[8].slice(1),
4278
- trim: match[9],
4279
- type: match[10]
4280
- });
4281
- }
4282
-
4283
- formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
4284
-
4285
- function FormatSpecifier(specifier) {
4286
- this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
4287
- this.align = specifier.align === undefined ? ">" : specifier.align + "";
4288
- this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
4289
- this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
4290
- this.zero = !!specifier.zero;
4291
- this.width = specifier.width === undefined ? undefined : +specifier.width;
4292
- this.comma = !!specifier.comma;
4293
- this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
4294
- this.trim = !!specifier.trim;
4295
- this.type = specifier.type === undefined ? "" : specifier.type + "";
4296
- }
4297
-
4298
- FormatSpecifier.prototype.toString = function() {
4299
- return this.fill
4300
- + this.align
4301
- + this.sign
4302
- + this.symbol
4303
- + (this.zero ? "0" : "")
4304
- + (this.width === undefined ? "" : Math.max(1, this.width | 0))
4305
- + (this.comma ? "," : "")
4306
- + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0))
4307
- + (this.trim ? "~" : "")
4308
- + this.type;
4309
- };
4310
-
4311
- // Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
4312
- function formatTrim(s) {
4313
- out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
4314
- switch (s[i]) {
4315
- case ".": i0 = i1 = i; break;
4316
- case "0": if (i0 === 0) i0 = i; i1 = i; break;
4317
- default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break;
4318
- }
4319
- }
4320
- return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
4321
- }
4322
-
4323
- var prefixExponent;
4324
-
4325
- function formatPrefixAuto(x, p) {
4326
- var d = formatDecimalParts(x, p);
4327
- if (!d) return x + "";
4328
- var coefficient = d[0],
4329
- exponent = d[1],
4330
- i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
4331
- n = coefficient.length;
4332
- return i === n ? coefficient
4333
- : i > n ? coefficient + new Array(i - n + 1).join("0")
4334
- : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
4335
- : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
4336
- }
4337
-
4338
- function formatRounded(x, p) {
4339
- var d = formatDecimalParts(x, p);
4340
- if (!d) return x + "";
4341
- var coefficient = d[0],
4342
- exponent = d[1];
4343
- return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
4344
- : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
4345
- : coefficient + new Array(exponent - coefficient.length + 2).join("0");
4346
- }
4347
-
4348
- var formatTypes = {
4349
- "%": (x, p) => (x * 100).toFixed(p),
4350
- "b": (x) => Math.round(x).toString(2),
4351
- "c": (x) => x + "",
4352
- "d": formatDecimal,
4353
- "e": (x, p) => x.toExponential(p),
4354
- "f": (x, p) => x.toFixed(p),
4355
- "g": (x, p) => x.toPrecision(p),
4356
- "o": (x) => Math.round(x).toString(8),
4357
- "p": (x, p) => formatRounded(x * 100, p),
4358
- "r": formatRounded,
4359
- "s": formatPrefixAuto,
4360
- "X": (x) => Math.round(x).toString(16).toUpperCase(),
4361
- "x": (x) => Math.round(x).toString(16)
4362
- };
4363
-
4364
- function identity(x) {
4365
- return x;
4366
- }
4367
-
4368
- var map = Array.prototype.map,
4369
- prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
4370
-
4371
- function formatLocale(locale) {
4372
- var group = locale.grouping === undefined || locale.thousands === undefined ? identity : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""),
4373
- currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
4374
- currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
4375
- decimal = locale.decimal === undefined ? "." : locale.decimal + "",
4376
- numerals = locale.numerals === undefined ? identity : formatNumerals(map.call(locale.numerals, String)),
4377
- percent = locale.percent === undefined ? "%" : locale.percent + "",
4378
- minus = locale.minus === undefined ? "−" : locale.minus + "",
4379
- nan = locale.nan === undefined ? "NaN" : locale.nan + "";
4380
-
4381
- function newFormat(specifier) {
4382
- specifier = formatSpecifier(specifier);
4383
-
4384
- var fill = specifier.fill,
4385
- align = specifier.align,
4386
- sign = specifier.sign,
4387
- symbol = specifier.symbol,
4388
- zero = specifier.zero,
4389
- width = specifier.width,
4390
- comma = specifier.comma,
4391
- precision = specifier.precision,
4392
- trim = specifier.trim,
4393
- type = specifier.type;
4394
-
4395
- // The "n" type is an alias for ",g".
4396
- if (type === "n") comma = true, type = "g";
4397
-
4398
- // The "" type, and any invalid type, is an alias for ".12~g".
4399
- else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g";
4400
-
4401
- // If zero fill is specified, padding goes after sign and before digits.
4402
- if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
4403
-
4404
- // Compute the prefix and suffix.
4405
- // For SI-prefix, the suffix is lazily computed.
4406
- var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
4407
- suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
4408
-
4409
- // What format function should we use?
4410
- // Is this an integer type?
4411
- // Can this type generate exponential notation?
4412
- var formatType = formatTypes[type],
4413
- maybeSuffix = /[defgprs%]/.test(type);
4414
-
4415
- // Set the default precision if not specified,
4416
- // or clamp the specified precision to the supported range.
4417
- // For significant precision, it must be in [1, 21].
4418
- // For fixed precision, it must be in [0, 20].
4419
- precision = precision === undefined ? 6
4420
- : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
4421
- : Math.max(0, Math.min(20, precision));
4422
-
4423
- function format(value) {
4424
- var valuePrefix = prefix,
4425
- valueSuffix = suffix,
4426
- i, n, c;
4427
-
4428
- if (type === "c") {
4429
- valueSuffix = formatType(value) + valueSuffix;
4430
- value = "";
4431
- } else {
4432
- value = +value;
4433
-
4434
- // Determine the sign. -0 is not less than 0, but 1 / -0 is!
4435
- var valueNegative = value < 0 || 1 / value < 0;
4436
-
4437
- // Perform the initial formatting.
4438
- value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
4439
-
4440
- // Trim insignificant zeros.
4441
- if (trim) value = formatTrim(value);
4442
-
4443
- // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
4444
- if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
4445
-
4446
- // Compute the prefix and suffix.
4447
- valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
4448
- valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
4449
-
4450
- // Break the formatted value into the integer “value” part that can be
4451
- // grouped, and fractional or exponential “suffix” part that is not.
4452
- if (maybeSuffix) {
4453
- i = -1, n = value.length;
4454
- while (++i < n) {
4455
- if (c = value.charCodeAt(i), 48 > c || c > 57) {
4456
- valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
4457
- value = value.slice(0, i);
4458
- break;
4459
- }
4460
- }
4461
- }
4462
- }
4463
-
4464
- // If the fill character is not "0", grouping is applied before padding.
4465
- if (comma && !zero) value = group(value, Infinity);
4466
-
4467
- // Compute the padding.
4468
- var length = valuePrefix.length + value.length + valueSuffix.length,
4469
- padding = length < width ? new Array(width - length + 1).join(fill) : "";
4470
-
4471
- // If the fill character is "0", grouping is applied after padding.
4472
- if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
4473
-
4474
- // Reconstruct the final output based on the desired alignment.
4475
- switch (align) {
4476
- case "<": value = valuePrefix + value + valueSuffix + padding; break;
4477
- case "=": value = valuePrefix + padding + value + valueSuffix; break;
4478
- case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
4479
- default: value = padding + valuePrefix + value + valueSuffix; break;
4480
- }
4481
-
4482
- return numerals(value);
4483
- }
4484
-
4485
- format.toString = function() {
4486
- return specifier + "";
4487
- };
4488
-
4489
- return format;
4490
- }
4491
-
4492
- function formatPrefix(specifier, value) {
4493
- var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
4494
- e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3,
4495
- k = Math.pow(10, -e),
4496
- prefix = prefixes[8 + e / 3];
4497
- return function(value) {
4498
- return f(k * value) + prefix;
4499
- };
4500
- }
4501
-
4502
- return {
4503
- format: newFormat,
4504
- formatPrefix: formatPrefix
4505
- };
4506
- }
4507
-
4508
- var locale;
4509
- var format;
4510
- var formatPrefix;
4511
-
4512
- defaultLocale({
4513
- thousands: ",",
4514
- grouping: [3],
4515
- currency: ["$", ""]
4516
- });
4517
-
4518
- function defaultLocale(definition) {
4519
- locale = formatLocale(definition);
4520
- format = locale.format;
4521
- formatPrefix = locale.formatPrefix;
4522
- return locale;
4523
- }
4524
-
4525
- function precisionFixed(step) {
4526
- return Math.max(0, -exponent(Math.abs(step)));
4527
- }
4528
-
4529
- function precisionPrefix(step, value) {
4530
- return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
4531
- }
4532
-
4533
- function precisionRound(step, max) {
4534
- step = Math.abs(step), max = Math.abs(max) - step;
4535
- return Math.max(0, exponent(max) - exponent(step)) + 1;
4536
- }
4537
-
4538
- function tickFormat(start, stop, count, specifier) {
4539
- var step = tickStep(start, stop, count),
4540
- precision;
4541
- specifier = formatSpecifier(specifier == null ? ",f" : specifier);
4542
- switch (specifier.type) {
4543
- case "s": {
4544
- var value = Math.max(Math.abs(start), Math.abs(stop));
4545
- if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
4546
- return formatPrefix(specifier, value);
4547
- }
4548
- case "":
4549
- case "e":
4550
- case "g":
4551
- case "p":
4552
- case "r": {
4553
- if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
4554
- break;
4555
- }
4556
- case "f":
4557
- case "%": {
4558
- if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
4559
- break;
4560
- }
4561
- }
4562
- return format(specifier);
4563
- }
4564
-
4565
- function linearish(scale) {
4566
- var domain = scale.domain;
4567
-
4568
- scale.ticks = function(count) {
4569
- var d = domain();
4570
- return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
4571
- };
4572
-
4573
- scale.tickFormat = function(count, specifier) {
4574
- var d = domain();
4575
- return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
4576
- };
4577
-
4578
- scale.nice = function(count) {
4579
- if (count == null) count = 10;
4580
-
4581
- var d = domain();
4582
- var i0 = 0;
4583
- var i1 = d.length - 1;
4584
- var start = d[i0];
4585
- var stop = d[i1];
4586
- var prestep;
4587
- var step;
4588
- var maxIter = 10;
4589
-
4590
- if (stop < start) {
4591
- step = start, start = stop, stop = step;
4592
- step = i0, i0 = i1, i1 = step;
4593
- }
4594
-
4595
- while (maxIter-- > 0) {
4596
- step = tickIncrement(start, stop, count);
4597
- if (step === prestep) {
4598
- d[i0] = start;
4599
- d[i1] = stop;
4600
- return domain(d);
4601
- } else if (step > 0) {
4602
- start = Math.floor(start / step) * step;
4603
- stop = Math.ceil(stop / step) * step;
4604
- } else if (step < 0) {
4605
- start = Math.ceil(start * step) / step;
4606
- stop = Math.floor(stop * step) / step;
4607
- } else {
4608
- break;
4609
- }
4610
- prestep = step;
4611
- }
4612
-
4613
- return scale;
4614
- };
4615
-
4616
- return scale;
4617
- }
4618
-
4619
- function linear() {
4620
- var scale = continuous();
4621
-
4622
- scale.copy = function() {
4623
- return copy$1(scale, linear());
4624
- };
4625
-
4626
- initRange.apply(scale, arguments);
4627
-
4628
- return linearish(scale);
4629
- }
4630
-
4631
- function transformer() {
4632
- var x0 = 0,
4633
- x1 = 1,
4634
- t0,
4635
- t1,
4636
- k10,
4637
- transform,
4638
- interpolator = identity$1,
4639
- clamp = false,
4640
- unknown;
4641
-
4642
- function scale(x) {
4643
- return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x));
4644
- }
4645
-
4646
- scale.domain = function(_) {
4647
- return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1];
4648
- };
4649
-
4650
- scale.clamp = function(_) {
4651
- return arguments.length ? (clamp = !!_, scale) : clamp;
4652
- };
4653
-
4654
- scale.interpolator = function(_) {
4655
- return arguments.length ? (interpolator = _, scale) : interpolator;
4656
- };
4657
-
4658
- function range(interpolate) {
4659
- return function(_) {
4660
- var r0, r1;
4661
- return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)];
4662
- };
4663
- }
4664
-
4665
- scale.range = range(interpolate);
4666
-
4667
- scale.rangeRound = range(interpolateRound);
4668
-
4669
- scale.unknown = function(_) {
4670
- return arguments.length ? (unknown = _, scale) : unknown;
4671
- };
4672
-
4673
- return function(t) {
4674
- transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0);
4675
- return scale;
4676
- };
4677
- }
4678
-
4679
- function copy(source, target) {
4680
- return target
4681
- .domain(source.domain())
4682
- .interpolator(source.interpolator())
4683
- .clamp(source.clamp())
4684
- .unknown(source.unknown());
4685
- }
4686
-
4687
- function sequential() {
4688
- var scale = linearish(transformer()(identity$1));
4689
-
4690
- scale.copy = function() {
4691
- return copy(scale, sequential());
4692
- };
4693
-
4694
- return initInterpolator.apply(scale, arguments);
4695
- }
4696
-
4697
- const COLOR_BASE = "#cecece";
4698
-
4699
- // https://www.w3.org/TR/WCAG20/#relativeluminancedef
4700
- const rc = 0.2126;
4701
- const gc = 0.7152;
4702
- const bc = 0.0722;
4703
- // low-gamma adjust coefficient
4704
- const lowc = 1 / 12.92;
4705
- function adjustGamma(p) {
4706
- return Math.pow((p + 0.055) / 1.055, 2.4);
4707
- }
4708
- function relativeLuminance(o) {
4709
- const rsrgb = o.r / 255;
4710
- const gsrgb = o.g / 255;
4711
- const bsrgb = o.b / 255;
4712
- const r = rsrgb <= 0.03928 ? rsrgb * lowc : adjustGamma(rsrgb);
4713
- const g = gsrgb <= 0.03928 ? gsrgb * lowc : adjustGamma(gsrgb);
4714
- const b = bsrgb <= 0.03928 ? bsrgb * lowc : adjustGamma(bsrgb);
4715
- return r * rc + g * gc + b * bc;
4716
- }
4717
- const createRainbowColor = (root) => {
4718
- const colorParentMap = new Map();
4719
- colorParentMap.set(root, COLOR_BASE);
4720
- if (root.children != null) {
4721
- const colorScale = sequential([0, root.children.length], (n) => hsl(360 * n, 0.3, 0.85));
4722
- root.children.forEach((c, id) => {
4723
- colorParentMap.set(c, colorScale(id).toString());
4724
- });
4725
- }
4726
- const colorMap = new Map();
4727
- const lightScale = linear().domain([0, root.height]).range([0.9, 0.3]);
4728
- const getBackgroundColor = (node) => {
4729
- const parents = node.ancestors();
4730
- const colorStr = parents.length === 1
4731
- ? colorParentMap.get(parents[0])
4732
- : colorParentMap.get(parents[parents.length - 2]);
4733
- const hslColor = hsl(colorStr);
4734
- hslColor.l = lightScale(node.depth);
4735
- return hslColor;
4736
- };
4737
- return (node) => {
4738
- if (!colorMap.has(node)) {
4739
- const backgroundColor = getBackgroundColor(node);
4740
- const l = relativeLuminance(backgroundColor.rgb());
4741
- const fontColor = l > 0.19 ? "#000" : "#fff";
4742
- colorMap.set(node, {
4743
- backgroundColor: backgroundColor.toString(),
4744
- fontColor,
4745
- });
4746
- }
4747
- return colorMap.get(node);
4748
- };
4749
- };
4750
-
4751
- const StaticContext = F$1({});
4752
- const drawChart = (parentNode, data, width, height) => {
4753
- const availableSizeProperties = getAvailableSizeOptions(data.options);
4754
- console.time("layout create");
4755
- const layout = treemap()
4756
- .size([width, height])
4757
- .paddingOuter(PADDING)
4758
- .paddingTop(TOP_PADDING)
4759
- .paddingInner(PADDING)
4760
- .round(true)
4761
- .tile(treemapResquarify);
4762
- console.timeEnd("layout create");
4763
- console.time("rawHierarchy create");
4764
- const rawHierarchy = hierarchy(data.tree);
4765
- console.timeEnd("rawHierarchy create");
4766
- const nodeSizesCache = new Map();
4767
- const nodeIdsCache = new Map();
4768
- const getModuleSize = (node, sizeKey) => { var _a, _b; return (_b = (_a = nodeSizesCache.get(node)) === null || _a === void 0 ? void 0 : _a[sizeKey]) !== null && _b !== void 0 ? _b : 0; };
4769
- console.time("rawHierarchy eachAfter cache");
4770
- rawHierarchy.eachAfter((node) => {
4771
- var _a;
4772
- const nodeData = node.data;
4773
- nodeIdsCache.set(nodeData, {
4774
- nodeUid: generateUniqueId("node"),
4775
- clipUid: generateUniqueId("clip"),
4776
- });
4777
- const sizes = { renderedLength: 0, gzipLength: 0, brotliLength: 0 };
4778
- if (isModuleTree(nodeData)) {
4779
- for (const sizeKey of availableSizeProperties) {
4780
- sizes[sizeKey] = nodeData.children.reduce((acc, child) => getModuleSize(child, sizeKey) + acc, 0);
4781
- }
4782
- }
4783
- else {
4784
- for (const sizeKey of availableSizeProperties) {
4785
- sizes[sizeKey] = (_a = data.nodeParts[nodeData.uid][sizeKey]) !== null && _a !== void 0 ? _a : 0;
4786
- }
4787
- }
4788
- nodeSizesCache.set(nodeData, sizes);
4789
- });
4790
- console.timeEnd("rawHierarchy eachAfter cache");
4791
- const getModuleIds = (node) => nodeIdsCache.get(node);
4792
- console.time("color");
4793
- const getModuleColor = createRainbowColor(rawHierarchy);
4794
- console.timeEnd("color");
4795
- q$1(u$1(StaticContext.Provider, { value: {
4796
- data,
4797
- availableSizeProperties,
4798
- width,
4799
- height,
4800
- getModuleSize,
4801
- getModuleIds,
4802
- getModuleColor,
4803
- rawHierarchy,
4804
- layout,
4805
- }, children: u$1(Main, {}) }), parentNode);
4806
- };
4807
-
4808
- exports.StaticContext = StaticContext;
4809
- exports.default = drawChart;
4810
-
4811
- Object.defineProperty(exports, '__esModule', { value: true });
4812
-
4813
- return exports;
4814
-
4815
- })({});
4816
-
4817
- /*-->*/
4818
- </script>
4819
- <script>
4820
- /*<!--*/
4821
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages/history/src/index.ts","uid":"6534-1"}]}],"isRoot":true},"nodeParts":{"6534-1":{"renderedLength":9658,"gzipLength":2791,"brotliLength":0,"metaUid":"6534-0"}},"nodeMetas":{"6534-0":{"id":"/packages/history/src/index.ts","moduleParts":{"index.production.js":"6534-1"},"imported":[],"importedBy":[],"isEntry":true}},"env":{"rollup":"4.6.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4822
-
4823
- const run = () => {
4824
- const width = window.innerWidth;
4825
- const height = window.innerHeight;
4826
-
4827
- const chartNode = document.querySelector("main");
4828
- drawChart.default(chartNode, data, width, height);
4829
- };
4830
-
4831
- window.addEventListener('resize', run);
4832
-
4833
- document.addEventListener('DOMContentLoaded', run);
4834
- /*-->*/
4835
- </script>
4836
- </body>
4837
- </html>
4838
-