katucharts.js 0.2.21 → 0.2.22
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.
- package/README.md +18 -3
- package/dist/core/Chart.d.ts +12 -0
- package/dist/core/StackComputer.d.ts +11 -0
- package/dist/katucharts-bio.es.js +1277 -1237
- package/dist/katucharts-bio.umd.js +1 -1
- package/dist/katucharts-finance.es.js +1741 -1512
- package/dist/katucharts-finance.umd.js +1 -1
- package/dist/katucharts.es.js +5416 -4956
- package/dist/katucharts.umd.js +5 -5
- package/dist/layout/LayoutEngine.d.ts +6 -0
- package/dist/series/BaseSeries.d.ts +9 -1
- package/dist/series/cartesian/ColumnChart.d.ts +5 -5
- package/dist/series/financial/AreaRangeChart.d.ts +14 -0
- package/dist/series/hierarchical/TreegraphChart.d.ts +7 -0
- package/dist/series/pictorial/PictorialChart.d.ts +32 -0
- package/dist/series/pie/PieChart.d.ts +31 -0
- package/dist/types/options.d.ts +10 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(b,vt){typeof exports=="object"&&typeof module<"u"?vt(exports):typeof define=="function"&&define.amd?define(["exports"],vt):(b=typeof globalThis<"u"?globalThis:b||self,vt(b.KatuChartsFinance={}))})(this,function(b){"use strict";class vt{constructor(){this.types=new Map}registerType(t,n){this.types.set(t,n)}getType(t){return this.types.get(t)}hasType(t){return this.types.has(t)}getRegisteredTypes(){return Array.from(this.types.keys())}}const Te=globalThis,G=Te.__katuChartRegistry||(Te.__katuChartRegistry=new vt);var ee="http://www.w3.org/1999/xhtml";const $e={svg:"http://www.w3.org/2000/svg",xhtml:ee,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),$e.hasOwnProperty(t)?{space:$e[t],local:e}:e}function Qi(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ee&&t.documentElement.namespaceURI===ee?t.createElement(e):t.createElementNS(n,e)}}function ji(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ne(e){var t=Vt(e);return(t.local?ji:Qi)(t)}function tr(){}function ne(e){return e==null?tr:function(){return this.querySelector(e)}}function er(e){typeof e!="function"&&(e=ne(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=new Array(o),c,l,u=0;u<o;++u)(c=s[u])&&(l=e.call(c,c.__data__,u,s))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new K(i,this._parents)}function nr(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ir(){return[]}function Fe(e){return e==null?ir:function(){return this.querySelectorAll(e)}}function rr(e){return function(){return nr(e.apply(this,arguments))}}function sr(e){typeof e=="function"?e=rr(e):e=Fe(e);for(var t=this._groups,n=t.length,i=[],r=[],s=0;s<n;++s)for(var o=t[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&(i.push(e.call(c,c.__data__,l,o)),r.push(c));return new K(i,r)}function Re(e){return function(){return this.matches(e)}}function Ve(e){return function(t){return t.matches(e)}}var or=Array.prototype.find;function ar(e){return function(){return or.call(this.children,e)}}function lr(){return this.firstElementChild}function cr(e){return this.select(e==null?lr:ar(typeof e=="function"?e:Ve(e)))}var hr=Array.prototype.filter;function ur(){return Array.from(this.children)}function fr(e){return function(){return hr.call(this.children,e)}}function dr(e){return this.selectAll(e==null?ur:fr(typeof e=="function"?e:Ve(e)))}function gr(e){typeof e!="function"&&(e=Re(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,l=0;l<o;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new K(i,this._parents)}function De(e){return new Array(e.length)}function pr(){return new K(this._enter||this._groups.map(De),this._parents)}function Dt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Dt.prototype={constructor:Dt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function xr(e){return function(){return e}}function yr(e,t,n,i,r,s){for(var o=0,a,c=t.length,l=s.length;o<l;++o)(a=t[o])?(a.__data__=s[o],i[o]=a):n[o]=new Dt(e,s[o]);for(;o<c;++o)(a=t[o])&&(r[o]=a)}function mr(e,t,n,i,r,s,o){var a,c,l=new Map,u=t.length,h=s.length,f=new Array(u),g;for(a=0;a<u;++a)(c=t[a])&&(f[a]=g=o.call(c,c.__data__,a,t)+"",l.has(g)?r[a]=c:l.set(g,c));for(a=0;a<h;++a)g=o.call(e,s[a],a,s)+"",(c=l.get(g))?(i[a]=c,c.__data__=s[a],l.delete(g)):n[a]=new Dt(e,s[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(r[a]=c)}function _r(e){return e.__data__}function wr(e,t){if(!arguments.length)return Array.from(this,_r);var n=t?mr:yr,i=this._parents,r=this._groups;typeof e!="function"&&(e=xr(e));for(var s=r.length,o=new Array(s),a=new Array(s),c=new Array(s),l=0;l<s;++l){var u=i[l],h=r[l],f=h.length,g=vr(e.call(u,u&&u.__data__,l,i)),d=g.length,y=a[l]=new Array(d),m=o[l]=new Array(d),p=c[l]=new Array(f);n(u,h,y,m,p,g,t);for(var x=0,_=0,w,v;x<d;++x)if(w=y[x]){for(x>=_&&(_=x+1);!(v=m[_])&&++_<d;);w._next=v||null}}return o=new K(o,i),o._enter=a,o._exit=c,o}function vr(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function br(){return new K(this._exit||this._groups.map(De),this._parents)}function kr(e,t,n){var i=this.enter(),r=this,s=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),i&&r?i.merge(r).order():r}function Mr(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,s=i.length,o=Math.min(r,s),a=new Array(r),c=0;c<o;++c)for(var l=n[c],u=i[c],h=l.length,f=a[c]=new Array(h),g,d=0;d<h;++d)(g=l[d]||u[d])&&(f[d]=g);for(;c<r;++c)a[c]=n[c];return new K(a,this._parents)}function Ar(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,s=i[r],o;--r>=0;)(o=i[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Cr(e){e||(e=Pr);function t(h,f){return h&&f?e(h.__data__,f.__data__):!h-!f}for(var n=this._groups,i=n.length,r=new Array(i),s=0;s<i;++s){for(var o=n[s],a=o.length,c=r[s]=new Array(a),l,u=0;u<a;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new K(r,this._parents).order()}function Pr(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Er(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ir(){return Array.from(this)}function Sr(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length;r<s;++r){var o=i[r];if(o)return o}return null}function Tr(){let e=0;for(const t of this)++e;return e}function $r(){return!this.node()}function Nr(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],s=0,o=r.length,a;s<o;++s)(a=r[s])&&e.call(a,a.__data__,s,r);return this}function Fr(e){return function(){this.removeAttribute(e)}}function Rr(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vr(e,t){return function(){this.setAttribute(e,t)}}function Dr(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Lr(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Or(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Br(e,t){var n=Vt(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?Rr:Fr:typeof t=="function"?n.local?Or:Lr:n.local?Dr:Vr)(n,t))}function Le(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function zr(e){return function(){this.style.removeProperty(e)}}function Hr(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Xr(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function Wr(e,t,n){return arguments.length>1?this.each((t==null?zr:typeof t=="function"?Xr:Hr)(e,t,n??"")):xt(this.node(),e)}function xt(e,t){return e.style.getPropertyValue(t)||Le(e).getComputedStyle(e,null).getPropertyValue(t)}function Ur(e){return function(){delete this[e]}}function Yr(e,t){return function(){this[e]=t}}function qr(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Gr(e,t){return arguments.length>1?this.each((t==null?Ur:typeof t=="function"?qr:Yr)(e,t)):this.node()[e]}function Oe(e){return e.trim().split(/^|\s+/)}function ie(e){return e.classList||new Be(e)}function Be(e){this._node=e,this._names=Oe(e.getAttribute("class")||"")}Be.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ze(e,t){for(var n=ie(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function He(e,t){for(var n=ie(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function Kr(e){return function(){ze(this,e)}}function Zr(e){return function(){He(this,e)}}function Jr(e,t){return function(){(t.apply(this,arguments)?ze:He)(this,e)}}function Qr(e,t){var n=Oe(e+"");if(arguments.length<2){for(var i=ie(this.node()),r=-1,s=n.length;++r<s;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Jr:t?Kr:Zr)(n,t))}function jr(){this.textContent=""}function ts(e){return function(){this.textContent=e}}function es(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ns(e){return arguments.length?this.each(e==null?jr:(typeof e=="function"?es:ts)(e)):this.node().textContent}function is(){this.innerHTML=""}function rs(e){return function(){this.innerHTML=e}}function ss(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function os(e){return arguments.length?this.each(e==null?is:(typeof e=="function"?ss:rs)(e)):this.node().innerHTML}function as(){this.nextSibling&&this.parentNode.appendChild(this)}function ls(){return this.each(as)}function cs(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hs(){return this.each(cs)}function us(e){var t=typeof e=="function"?e:Ne(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function fs(){return null}function ds(e,t){var n=typeof e=="function"?e:Ne(e),i=t==null?fs:typeof t=="function"?t:ne(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function gs(){var e=this.parentNode;e&&e.removeChild(this)}function ps(){return this.each(gs)}function xs(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ys(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ms(e){return this.select(e?ys:xs)}function _s(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ws(e){return function(t){e.call(this,t,this.__data__)}}function vs(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function bs(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++i]=s;++i?t.length=i:delete this.__on}}}function ks(e,t,n){return function(){var i=this.__on,r,s=ws(t);if(i){for(var o=0,a=i.length;o<a;++o)if((r=i[o]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},i?i.push(r):this.__on=[r]}}function Ms(e,t,n){var i=vs(e+""),r,s=i.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<s;++r)if((o=i[r]).type===u.type&&o.name===u.name)return u.value}return}for(a=t?ks:bs,r=0;r<s;++r)this.each(a(i[r],t,n));return this}function Xe(e,t,n){var i=Le(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function As(e,t){return function(){return Xe(this,e,t)}}function Cs(e,t){return function(){return Xe(this,e,t.apply(this,arguments))}}function Ps(e,t){return this.each((typeof t=="function"?Cs:As)(e,t))}function*Es(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,s=i.length,o;r<s;++r)(o=i[r])&&(yield o)}var We=[null];function K(e,t){this._groups=e,this._parents=t}function bt(){return new K([[document.documentElement]],We)}function Is(){return this}K.prototype=bt.prototype={constructor:K,select:er,selectAll:sr,selectChild:cr,selectChildren:dr,filter:gr,data:wr,enter:pr,exit:br,join:kr,merge:Mr,selection:Is,order:Ar,sort:Cr,call:Er,nodes:Ir,node:Sr,size:Tr,empty:$r,each:Nr,attr:Br,style:Wr,property:Gr,classed:Qr,text:ns,html:os,raise:ls,lower:hs,append:us,insert:ds,remove:ps,clone:ms,datum:_s,on:Ms,dispatch:Ps,[Symbol.iterator]:Es};function Ss(e){return typeof e=="string"?new K([[document.querySelector(e)]],[document.documentElement]):new K([[e]],We)}var Ts={value:()=>{}};function Ue(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new Lt(n)}function Lt(e){this._=e}function $s(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}Lt.prototype=Ue.prototype={constructor:Lt,on:function(e,t){var n=this._,i=$s(e+"",n),r,s=-1,o=i.length;if(arguments.length<2){for(;++s<o;)if((r=(e=i[s]).type)&&(r=Ns(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<o;)if(r=(e=i[s]).type)n[r]=Ye(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ye(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Lt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,s;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],i=0,r=s.length;i<r;++i)s[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)}};function Ns(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Ye(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=Ts,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var yt=0,kt=0,Mt=0,qe=1e3,Ot,At,Bt=0,ht=0,zt=0,Ct=typeof performance=="object"&&performance.now?performance:Date,Ge=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function re(){return ht||(Ge(Fs),ht=Ct.now()+zt)}function Fs(){ht=0}function Ht(){this._call=this._time=this._next=null}Ht.prototype=Ke.prototype={constructor:Ht,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?re():+n)+(t==null?0:+t),!this._next&&At!==this&&(At?At._next=this:Ot=this,At=this),this._call=e,this._time=n,se()},stop:function(){this._call&&(this._call=null,this._time=1/0,se())}};function Ke(e,t,n){var i=new Ht;return i.restart(e,t,n),i}function Rs(){re(),++yt;for(var e=Ot,t;e;)(t=ht-e._time)>=0&&e._call.call(void 0,t),e=e._next;--yt}function Ze(){ht=(Bt=Ct.now())+zt,yt=kt=0;try{Rs()}finally{yt=0,Ds(),ht=0}}function Vs(){var e=Ct.now(),t=e-Bt;t>qe&&(zt-=t,Bt=e)}function Ds(){for(var e,t=Ot,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Ot=n);At=e,se(i)}function se(e){if(!yt){kt&&(kt=clearTimeout(kt));var t=e-ht;t>24?(e<1/0&&(kt=setTimeout(Ze,e-Ct.now()-zt)),Mt&&(Mt=clearInterval(Mt))):(Mt||(Bt=Ct.now(),Mt=setInterval(Vs,qe)),yt=1,Ge(Ze))}}function Je(e,t,n){var i=new Ht;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var Ls=Ue("start","end","cancel","interrupt"),Os=[],Qe=0,je=1,oe=2,Xt=3,tn=4,ae=5,Wt=6;function Ut(e,t,n,i,r,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Bs(e,n,{name:t,index:i,group:r,on:Ls,tween:Os,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Qe})}function le(e,t){var n=Q(e,t);if(n.state>Qe)throw new Error("too late; already scheduled");return n}function tt(e,t){var n=Q(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function Q(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Bs(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=Ke(s,0,n.time);function s(l){n.state=je,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var u,h,f,g;if(n.state!==je)return c();for(u in i)if(g=i[u],g.name===n.name){if(g.state===Xt)return Je(o);g.state===tn?(g.state=Wt,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete i[u]):+u<t&&(g.state=Wt,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete i[u])}if(Je(function(){n.state===Xt&&(n.state=tn,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=oe,n.on.call("start",e,e.__data__,n.index,n.group),n.state===oe){for(n.state=Xt,r=new Array(f=n.tween.length),u=0,h=-1;u<f;++u)(g=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++h]=g);r.length=h+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=ae,1),h=-1,f=r.length;++h<f;)r[h].call(e,u);n.state===ae&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete i[t];for(var l in i)return;delete e.__transition}}function zs(e,t){var n=e.__transition,i,r,s=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((i=n[o]).name!==t){s=!1;continue}r=i.state>oe&&i.state<ae,i.state=Wt,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}s&&delete e.__transition}}function Hs(e){return this.each(function(){zs(this,e)})}function ce(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function en(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Pt(){}var Et=.7,Yt=1/Et,mt="\\s*([+-]?\\d+)\\s*",It="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Xs=/^#([0-9a-f]{3,8})$/,Ws=new RegExp(`^rgb\\(${mt},${mt},${mt}\\)$`),Us=new RegExp(`^rgb\\(${et},${et},${et}\\)$`),Ys=new RegExp(`^rgba\\(${mt},${mt},${mt},${It}\\)$`),qs=new RegExp(`^rgba\\(${et},${et},${et},${It}\\)$`),Gs=new RegExp(`^hsl\\(${It},${et},${et}\\)$`),Ks=new RegExp(`^hsla\\(${It},${et},${et},${It}\\)$`),nn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ce(Pt,_t,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:rn,formatHex:rn,formatHex8:Zs,formatHsl:Js,formatRgb:sn,toString:sn});function rn(){return this.rgb().formatHex()}function Zs(){return this.rgb().formatHex8()}function Js(){return hn(this).formatHsl()}function sn(){return this.rgb().formatRgb()}function _t(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Xs.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?on(t):n===3?new Y(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?qt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?qt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Ws.exec(e))?new Y(t[1],t[2],t[3],1):(t=Us.exec(e))?new Y(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ys.exec(e))?qt(t[1],t[2],t[3],t[4]):(t=qs.exec(e))?qt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Gs.exec(e))?cn(t[1],t[2]/100,t[3]/100,1):(t=Ks.exec(e))?cn(t[1],t[2]/100,t[3]/100,t[4]):nn.hasOwnProperty(e)?on(nn[e]):e==="transparent"?new Y(NaN,NaN,NaN,0):null}function on(e){return new Y(e>>16&255,e>>8&255,e&255,1)}function qt(e,t,n,i){return i<=0&&(e=t=n=NaN),new Y(e,t,n,i)}function Qs(e){return e instanceof Pt||(e=_t(e)),e?(e=e.rgb(),new Y(e.r,e.g,e.b,e.opacity)):new Y}function he(e,t,n,i){return arguments.length===1?Qs(e):new Y(e,t,n,i??1)}function Y(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}ce(Y,he,en(Pt,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new Y(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Et:Math.pow(Et,e),new Y(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Y(ut(this.r),ut(this.g),ut(this.b),Gt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:an,formatHex:an,formatHex8:js,formatRgb:ln,toString:ln}));function an(){return`#${ft(this.r)}${ft(this.g)}${ft(this.b)}`}function js(){return`#${ft(this.r)}${ft(this.g)}${ft(this.b)}${ft((isNaN(this.opacity)?1:this.opacity)*255)}`}function ln(){const e=Gt(this.opacity);return`${e===1?"rgb(":"rgba("}${ut(this.r)}, ${ut(this.g)}, ${ut(this.b)}${e===1?")":`, ${e})`}`}function Gt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ut(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ft(e){return e=ut(e),(e<16?"0":"")+e.toString(16)}function cn(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new j(e,t,n,i)}function hn(e){if(e instanceof j)return new j(e.h,e.s,e.l,e.opacity);if(e instanceof Pt||(e=_t(e)),!e)return new j;if(e instanceof j)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),s=Math.max(t,n,i),o=NaN,a=s-r,c=(s+r)/2;return a?(t===s?o=(n-i)/a+(n<i)*6:n===s?o=(i-t)/a+2:o=(t-n)/a+4,a/=c<.5?s+r:2-s-r,o*=60):a=c>0&&c<1?0:o,new j(o,a,c,e.opacity)}function to(e,t,n,i){return arguments.length===1?hn(e):new j(e,t,n,i??1)}function j(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}ce(j,to,en(Pt,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new j(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Et:Math.pow(Et,e),new j(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new Y(ue(e>=240?e-240:e+120,r,i),ue(e,r,i),ue(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new j(un(this.h),Kt(this.s),Kt(this.l),Gt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Gt(this.opacity);return`${e===1?"hsl(":"hsla("}${un(this.h)}, ${Kt(this.s)*100}%, ${Kt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function un(e){return e=(e||0)%360,e<0?e+360:e}function Kt(e){return Math.max(0,Math.min(1,e||0))}function ue(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const fn=e=>()=>e;function eo(e,t){return function(n){return e+n*t}}function no(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function io(e){return(e=+e)==1?dn:function(t,n){return n-t?no(t,n,e):fn(isNaN(t)?n:t)}}function dn(e,t){var n=t-e;return n?eo(e,n):fn(isNaN(e)?t:e)}const gn=function e(t){var n=io(t);function i(r,s){var o=n((r=he(r)).r,(s=he(s)).r),a=n(r.g,s.g),c=n(r.b,s.b),l=dn(r.opacity,s.opacity);return function(u){return r.r=o(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return i.gamma=e,i}(1);function ot(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var fe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,de=new RegExp(fe.source,"g");function ro(e){return function(){return e}}function so(e){return function(t){return e(t)+""}}function oo(e,t){var n=fe.lastIndex=de.lastIndex=0,i,r,s,o=-1,a=[],c=[];for(e=e+"",t=t+"";(i=fe.exec(e))&&(r=de.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(i=i[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:ot(i,r)})),n=de.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?so(c[0].x):ro(t):(t=c.length,function(l){for(var u=0,h;u<t;++u)a[(h=c[u]).i]=h.x(l);return a.join("")})}var pn=180/Math.PI,ge={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xn(e,t,n,i,r,s){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*i)&&(n-=e*c,i-=t*c),(a=Math.sqrt(n*n+i*i))&&(n/=a,i/=a,c/=a),e*i<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*pn,skewX:Math.atan(c)*pn,scaleX:o,scaleY:a}}var Zt;function ao(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ge:xn(t.a,t.b,t.c,t.d,t.e,t.f)}function lo(e){return e==null||(Zt||(Zt=document.createElementNS("http://www.w3.org/2000/svg","g")),Zt.setAttribute("transform",e),!(e=Zt.transform.baseVal.consolidate()))?ge:(e=e.matrix,xn(e.a,e.b,e.c,e.d,e.e,e.f))}function yn(e,t,n,i){function r(l){return l.length?l.pop()+" ":""}function s(l,u,h,f,g,d){if(l!==h||u!==f){var y=g.push("translate(",null,t,null,n);d.push({i:y-4,x:ot(l,h)},{i:y-2,x:ot(u,f)})}else(h||f)&&g.push("translate("+h+t+f+n)}function o(l,u,h,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:h.push(r(h)+"rotate(",null,i)-2,x:ot(l,u)})):u&&h.push(r(h)+"rotate("+u+i)}function a(l,u,h,f){l!==u?f.push({i:h.push(r(h)+"skewX(",null,i)-2,x:ot(l,u)}):u&&h.push(r(h)+"skewX("+u+i)}function c(l,u,h,f,g,d){if(l!==h||u!==f){var y=g.push(r(g)+"scale(",null,",",null,")");d.push({i:y-4,x:ot(l,h)},{i:y-2,x:ot(u,f)})}else(h!==1||f!==1)&&g.push(r(g)+"scale("+h+","+f+")")}return function(l,u){var h=[],f=[];return l=e(l),u=e(u),s(l.translateX,l.translateY,u.translateX,u.translateY,h,f),o(l.rotate,u.rotate,h,f),a(l.skewX,u.skewX,h,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,h,f),l=u=null,function(g){for(var d=-1,y=f.length,m;++d<y;)h[(m=f[d]).i]=m.x(g);return h.join("")}}}var co=yn(ao,"px, ","px)","deg)"),ho=yn(lo,", ",")",")");function uo(e,t){var n,i;return function(){var r=tt(this,e),s=r.tween;if(s!==n){i=n=s;for(var o=0,a=i.length;o<a;++o)if(i[o].name===t){i=i.slice(),i.splice(o,1);break}}r.tween=i}}function fo(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var s=tt(this,e),o=s.tween;if(o!==i){r=(i=o).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}s.tween=r}}function go(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Q(this.node(),n).tween,r=0,s=i.length,o;r<s;++r)if((o=i[r]).name===e)return o.value;return null}return this.each((t==null?uo:fo)(n,e,t))}function pe(e,t,n){var i=e._id;return e.each(function(){var r=tt(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Q(r,i).value[t]}}function mn(e,t){var n;return(typeof t=="number"?ot:t instanceof _t?gn:(n=_t(t))?(t=n,gn):oo)(e,t)}function po(e){return function(){this.removeAttribute(e)}}function xo(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yo(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttribute(e);return o===r?null:o===i?s:s=t(i=o,n)}}function mo(e,t,n){var i,r=n+"",s;return function(){var o=this.getAttributeNS(e.space,e.local);return o===r?null:o===i?s:s=t(i=o,n)}}function _o(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function wo(e,t,n){var i,r,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a)))}}function vo(e,t){var n=Vt(e),i=n==="transform"?ho:mn;return this.attrTween(e,typeof t=="function"?(n.local?wo:_o)(n,i,pe(this,"attr."+e,t)):t==null?(n.local?xo:po)(n):(n.local?mo:yo)(n,i,t))}function bo(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ko(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Mo(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&ko(e,s)),n}return r._value=t,r}function Ao(e,t){var n,i;function r(){var s=t.apply(this,arguments);return s!==i&&(n=(i=s)&&bo(e,s)),n}return r._value=t,r}function Co(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=Vt(e);return this.tween(n,(i.local?Mo:Ao)(i,t))}function Po(e,t){return function(){le(this,e).delay=+t.apply(this,arguments)}}function Eo(e,t){return t=+t,function(){le(this,e).delay=t}}function Io(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Po:Eo)(t,e)):Q(this.node(),t).delay}function So(e,t){return function(){tt(this,e).duration=+t.apply(this,arguments)}}function To(e,t){return t=+t,function(){tt(this,e).duration=t}}function $o(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?So:To)(t,e)):Q(this.node(),t).duration}function No(e,t){if(typeof t!="function")throw new Error;return function(){tt(this,e).ease=t}}function Fo(e){var t=this._id;return arguments.length?this.each(No(t,e)):Q(this.node(),t).ease}function Ro(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;tt(this,e).ease=n}}function Vo(e){if(typeof e!="function")throw new Error;return this.each(Ro(this._id,e))}function Do(e){typeof e!="function"&&(e=Re(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var s=t[r],o=s.length,a=i[r]=[],c,l=0;l<o;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new it(i,this._parents,this._name,this._id)}function Lo(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,s=Math.min(i,r),o=new Array(i),a=0;a<s;++a)for(var c=t[a],l=n[a],u=c.length,h=o[a]=new Array(u),f,g=0;g<u;++g)(f=c[g]||l[g])&&(h[g]=f);for(;a<i;++a)o[a]=t[a];return new it(o,this._parents,this._name,this._id)}function Oo(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Bo(e,t,n){var i,r,s=Oo(t)?le:tt;return function(){var o=s(this,e),a=o.on;a!==i&&(r=(i=a).copy()).on(t,n),o.on=r}}function zo(e,t){var n=this._id;return arguments.length<2?Q(this.node(),n).on.on(e):this.each(Bo(n,e,t))}function Ho(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Xo(){return this.on("end.remove",Ho(this._id))}function Wo(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ne(e));for(var i=this._groups,r=i.length,s=new Array(r),o=0;o<r;++o)for(var a=i[o],c=a.length,l=s[o]=new Array(c),u,h,f=0;f<c;++f)(u=a[f])&&(h=e.call(u,u.__data__,f,a))&&("__data__"in u&&(h.__data__=u.__data__),l[f]=h,Ut(l[f],t,n,f,l,Q(u,n)));return new it(s,this._parents,t,n)}function Uo(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fe(e));for(var i=this._groups,r=i.length,s=[],o=[],a=0;a<r;++a)for(var c=i[a],l=c.length,u,h=0;h<l;++h)if(u=c[h]){for(var f=e.call(u,u.__data__,h,c),g,d=Q(u,n),y=0,m=f.length;y<m;++y)(g=f[y])&&Ut(g,t,n,y,f,d);s.push(f),o.push(u)}return new it(s,o,t,n)}var Yo=bt.prototype.constructor;function qo(){return new Yo(this._groups,this._parents)}function Go(e,t){var n,i,r;return function(){var s=xt(this,e),o=(this.style.removeProperty(e),xt(this,e));return s===o?null:s===n&&o===i?r:r=t(n=s,i=o)}}function _n(e){return function(){this.style.removeProperty(e)}}function Ko(e,t,n){var i,r=n+"",s;return function(){var o=xt(this,e);return o===r?null:o===i?s:s=t(i=o,n)}}function Zo(e,t,n){var i,r,s;return function(){var o=xt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),xt(this,e))),o===c?null:o===i&&c===r?s:(r=c,s=t(i=o,a))}}function Jo(e,t){var n,i,r,s="style."+t,o="end."+s,a;return function(){var c=tt(this,e),l=c.on,u=c.value[s]==null?a||(a=_n(t)):void 0;(l!==n||r!==u)&&(i=(n=l).copy()).on(o,r=u),c.on=i}}function Qo(e,t,n){var i=(e+="")=="transform"?co:mn;return t==null?this.styleTween(e,Go(e,i)).on("end.style."+e,_n(e)):typeof t=="function"?this.styleTween(e,Zo(e,i,pe(this,"style."+e,t))).each(Jo(this._id,e)):this.styleTween(e,Ko(e,i,t),n).on("end.style."+e,null)}function jo(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function ta(e,t,n){var i,r;function s(){var o=t.apply(this,arguments);return o!==r&&(i=(r=o)&&jo(e,o,n)),i}return s._value=t,s}function ea(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,ta(e,t,n??""))}function na(e){return function(){this.textContent=e}}function ia(e){return function(){var t=e(this);this.textContent=t??""}}function ra(e){return this.tween("text",typeof e=="function"?ia(pe(this,"text",e)):na(e==null?"":e+""))}function sa(e){return function(t){this.textContent=e.call(this,t)}}function oa(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&sa(r)),t}return i._value=e,i}function aa(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,oa(e))}function la(){for(var e=this._name,t=this._id,n=wn(),i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,l=0;l<a;++l)if(c=o[l]){var u=Q(c,t);Ut(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new it(i,this._parents,e,n)}function ca(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--r===0&&s()}};n.each(function(){var l=tt(this,i),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&s()})}var ha=0;function it(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function wn(){return++ha}var rt=bt.prototype;it.prototype={constructor:it,select:Wo,selectAll:Uo,selectChild:rt.selectChild,selectChildren:rt.selectChildren,filter:Do,merge:Lo,selection:qo,transition:la,call:rt.call,nodes:rt.nodes,node:rt.node,size:rt.size,empty:rt.empty,each:rt.each,on:zo,attr:vo,attrTween:Co,style:Qo,styleTween:ea,text:ra,textTween:aa,remove:Xo,tween:go,delay:Io,duration:$o,ease:Fo,easeVarying:Vo,end:ca,[Symbol.iterator]:rt[Symbol.iterator]};function vn(e){return--e*e*e+1}function ua(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var fa={time:null,delay:0,duration:250,ease:ua};function da(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function ga(e){var t,n;e instanceof it?(t=e._id,e=e._name):(t=wn(),(n=fa).time=re(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,s=0;s<r;++s)for(var o=i[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&Ut(c,e,t,l,o,n||da(c,t));return new it(i,this._parents,e,t)}bt.prototype.interrupt=Hs,bt.prototype.transition=ga;function pa(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Jt(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function xa(e){return e=Jt(Math.abs(e)),e?e[1]:NaN}function ya(e,t){return function(n,i){for(var r=n.length,s=[],o=0,a=e[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),s.push(n.substring(r-=a,r+a)),!((c+=a+1)>i));)a=e[o=(o+1)%e.length];return s.reverse().join(t)}}function ma(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var _a=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function xe(e){if(!(t=_a.exec(e)))throw new Error("invalid format: "+e);var t;return new ye({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}xe.prototype=ye.prototype;function ye(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}ye.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function wa(e){t:for(var t=e.length,n=1,i=-1,r;n<t;++n)switch(e[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+e[n])break t;i>0&&(i=0);break}return i>0?e.slice(0,i)+e.slice(r+1):e}var Qt;function va(e,t){var n=Jt(e,t);if(!n)return Qt=void 0,e.toPrecision(t);var i=n[0],r=n[1],s=r-(Qt=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,o=i.length;return s===o?i:s>o?i+new Array(s-o+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+Jt(e,Math.max(0,t+s-1))[0]}function bn(e,t){var n=Jt(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const kn={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:pa,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>bn(e*100,t),r:bn,s:va,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Mn(e){return e}var An=Array.prototype.map,Cn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ba(e){var t=e.grouping===void 0||e.thousands===void 0?Mn:ya(An.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",i=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?Mn:ma(An.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function l(h,f){h=xe(h);var g=h.fill,d=h.align,y=h.sign,m=h.symbol,p=h.zero,x=h.width,_=h.comma,w=h.precision,v=h.trim,k=h.type;k==="n"?(_=!0,k="g"):kn[k]||(w===void 0&&(w=12),v=!0,k="g"),(p||g==="0"&&d==="=")&&(p=!0,g="0",d="=");var M=(f&&f.prefix!==void 0?f.prefix:"")+(m==="$"?n:m==="#"&&/[boxX]/.test(k)?"0"+k.toLowerCase():""),I=(m==="$"?i:/[%p]/.test(k)?o:"")+(f&&f.suffix!==void 0?f.suffix:""),E=kn[k],P=/[defgprs%]/.test(k);w=w===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function O(A){var R=M,N=I,V,S,C;if(k==="c")N=E(A)+N,A="";else{A=+A;var L=A<0||1/A<0;if(A=isNaN(A)?c:E(Math.abs(A),w),v&&(A=wa(A)),L&&+A==0&&y!=="+"&&(L=!1),R=(L?y==="("?y:a:y==="-"||y==="("?"":y)+R,N=(k==="s"&&!isNaN(A)&&Qt!==void 0?Cn[8+Qt/3]:"")+N+(L&&y==="("?")":""),P){for(V=-1,S=A.length;++V<S;)if(C=A.charCodeAt(V),48>C||C>57){N=(C===46?r+A.slice(V+1):A.slice(V))+N,A=A.slice(0,V);break}}}_&&!p&&(A=t(A,1/0));var B=R.length+A.length+N.length,D=B<x?new Array(x-B+1).join(g):"";switch(_&&p&&(A=t(D+A,D.length?x-N.length:1/0),D=""),d){case"<":A=R+A+N+D;break;case"=":A=R+D+A+N;break;case"^":A=D.slice(0,B=D.length>>1)+R+A+N+D.slice(B);break;default:A=D+R+A+N;break}return s(A)}return O.toString=function(){return h+""},O}function u(h,f){var g=Math.max(-8,Math.min(8,Math.floor(xa(f)/3)))*3,d=Math.pow(10,-g),y=l((h=xe(h),h.type="f",h),{suffix:Cn[8+g/3]});return function(m){return y(d*m)}}return{format:l,formatPrefix:u}}var jt,Pn;ka({thousands:",",grouping:[3],currency:["$",""]});function ka(e){return jt=ba(e),Pn=jt.format,jt.formatPrefix,jt}Object.entries({"%A":"%A","%a":"%a","%d":"%d","%e":"%-d","%b":"%b","%B":"%B","%m":"%m","%y":"%y","%Y":"%Y","%H":"%H","%I":"%I","%k":"%-H","%l":"%-I","%M":"%M","%p":"%p","%P":"%p","%S":"%S","%L":"%L"}).map(([e,t])=>[new RegExp(e.replace("%","\\%"),"g"),t]);const Ma=/\{([^}]+)\}/g;function En(e,t,n=!1){return e.replace(Ma,(i,r)=>{const s=r.indexOf(":");let o=r,a=null;s!==-1&&(o=r.slice(0,s),a=r.slice(s+1));const c=o.trim().split(".");let l=t;for(const h of c){if(l==null)return"";l=l[h]}if(l==null)return"";let u;if(a){const h=typeof l=="number"?l:parseFloat(String(l));if(isNaN(h))u=String(l);else try{u=Pn(a)(h)}catch{u=String(l)}}else u=String(l);return n?Pa(u):u})}const Aa=/[&<>"']/g,Ca={"&":"&","<":"<",">":">",'"':""","'":"'"};function Pa(e){return String(e).replace(Aa,t=>Ca[t])}const Ea=/<\/?[^>]+(>|$)/g,Ia=/<br\s*\/?>/gi;function In(e){return e.replace(Ia," ").replace(Ea,"").trim()}const F=600,q=8,Sa=F+100,$=300,me=250,W=vn,T=vn,Sn="12px",Tn="#000000",$n="#1a1a1a",Ta="#ffffff",$a=3;function _e(e){const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Nn(e,t,n){return .2126*_e(e)+.7152*_e(t)+.0722*_e(n)}function Fn(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}const Na=Nn(26,26,26);function Rn(e,t){var o;if(t)return t;const n=e?(o=_t(e))==null?void 0:o.rgb():null;if(!n||isNaN(n.r)||n.opacity===0)return Tn;const i=Nn(n.r,n.g,n.b),r=Fn(i,Na);return r>=$a?$n:Fn(i,1)>=r?Ta:$n}const Fa=500;function at(e,t,n,i){return i>Fa?t:t+e*n}class J{constructor(t){this.selectedPoints=new Set,this._cachedExtents=null,this.config=t,this.visible=t.visible!==!1,this.data=t._processedData||[]}init(t){this.context=t,this.group=t.chartGroup.append("g").attr("class",`katucharts-series katucharts-series-${this.config._internalType}`).attr("data-series-index",this.config.index),this.config.opacity!==void 0&&this.config.opacity!==1&&this.group.attr("opacity",this.config.opacity),this.config.zIndex!==void 0&&this.group.style("z-index",String(this.config.zIndex)),this.config.className&&this.group.classed(this.config.className,!0),this.config.shadow&&this.applyShadowFilter(),this.visible||this.group.style("display","none"),this.config.allowPointSelect&&this.data.forEach((n,i)=>{n.selected&&this.selectedPoints.add(i)}),this.group.on("mouseenter",()=>{var n,i;(i=(n=this.config.events)==null?void 0:n.mouseOver)==null||i.call(this,new Event("mouseOver")),this.context.events.emit("series:mouseenter",this)}).on("mouseleave",()=>{var n,i;(i=(n=this.config.events)==null?void 0:n.mouseOut)==null||i.call(this,new Event("mouseOut")),this.context.events.emit("series:mouseleave",this)})}setOnVisibilityChange(t){this._onVisibilityChange=t}processData(){this.data=this.config._processedData||[],this._cachedExtents=null}getColor(){return this.config.color||this.context.colors[this.context.colorIndex%this.context.colors.length]}autoLabelColor(t){return Rn(this.context.backgroundColor,t)}labelHalo(){const t=this.labelHaloColor();return`0 0 3px ${t}, 0 0 3px ${t}`}labelHaloColor(){return Rn(this.context.backgroundColor)==="#ffffff"?"rgba(0,0,0,0.85)":"#ffffff"}autoBorderColor(){const t=this.context.backgroundColor;return!t||t==="transparent"||t==="none"?"#ffffff":t}getMultiLegendItems(){return null}toggleLegendItem(t){return null}getLegendSymbolShape(){return null}getBubbleLegendInfo(){return null}animateUpdate(t){this.group.selectAll("*").remove(),this.render()}updateContext(t){Object.assign(this.context,t)}redraw(){this.group.selectAll("*").remove(),this.render()}setVisible(t,n=!0){var i,r,s,o;this.visible=t,t?(r=(i=this.config.events)==null?void 0:i.show)==null||r.call(this,new Event("show")):(o=(s=this.config.events)==null?void 0:s.hide)==null||o.call(this,new Event("hide")),n&&this._onVisibilityChange?(t?this.group.style("display","").attr("opacity",0).transition().duration(300).attr("opacity",this.config.opacity??1):this.group.transition().duration(300).attr("opacity",0).on("end",()=>{this.group.style("display","none")}),this._onVisibilityChange(500)):this.group.style("display",t?"":"none"),this.context.events.emit("series:visibilityChanged",this,t)}toggleVisible(){this.setVisible(!this.visible)}getDataExtents(){if(this._cachedExtents)return this._cachedExtents;let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of this.data)s.x!==void 0&&s.x!==null&&(s.x<t&&(t=s.x),s.x>n&&(n=s.x)),s.y!==void 0&&s.y!==null&&(s.y<i&&(i=s.y),s.y>r&&(r=s.y));return this._cachedExtents={xMin:t,xMax:n,yMin:i,yMax:r},this._cachedExtents}getCategories(){return this.data.filter(t=>t.name!==void 0).map(t=>t.name)}destroy(){var t;(t=this.group)==null||t.remove()}setData(t,n=!0,i=!0){this.data=t,this.config._processedData=t,this._cachedExtents=null,n&&(i?this.animateUpdate(500):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoint(t,n=!0,i=!1,r=!0){if(this.data.push(t),this.config._processedData=this.data,i&&this.data.length>1)this.data.shift(),this.config._processedData=this.data,this._cachedExtents=null;else if(this._cachedExtents){const s=this._cachedExtents;t.x!==void 0&&t.x!==null&&(t.x<s.xMin&&(s.xMin=t.x),t.x>s.xMax&&(s.xMax=t.x)),t.y!==void 0&&t.y!==null&&(t.y<s.yMin&&(s.yMin=t.y),t.y>s.yMax&&(s.yMax=t.y))}n&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoints(t,n=!0,i=!1,r=!0){for(const s of t)this.data.push(s);i&&this.data.length>t.length&&this.data.splice(0,t.length),this.config._processedData=this.data,this._cachedExtents=null,n&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}removePoint(t,n=!0,i=!0){t>=0&&t<this.data.length&&(this.data.splice(t,1),this.config._processedData=this.data,this._cachedExtents=null,n&&(i?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this)))}updateSeries(t,n=!0){Object.assign(this.config,t),t.data&&(this.config._processedData=t.data,this.data=this.config._processedData,this._cachedExtents=null),n&&this.redraw()}applyBatch(t){for(const n of t.entries)switch(n.type){case"setData":this.data=n.payload,this.config._processedData=this.data;break;case"addPoint":this.data.push(n.payload.point),n.payload.shift&&this.data.length>1&&this.data.shift();break;case"addPoints":for(const i of n.payload.points)this.data.push(i);n.payload.shift&&this.data.splice(0,n.payload.points.length);break;case"removePoint":n.payload.index>=0&&n.payload.index<this.data.length&&this.data.splice(n.payload.index,1);break}this.config._processedData=this.data,this._cachedExtents=null,this.redraw(),this.context.events.emit("series:dataChanged",this)}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}getSelectedPoints(){return Array.from(this.selectedPoints).map(t=>({index:t,point:this.data[t]})).filter(t=>t.point!==void 0)}applyClipPath(){const{plotArea:t}=this.context;this.clipId=`katucharts-clip-${this.config.index}-${Date.now()}`;const n=this.group.select(function(){return this.ownerSVGElement});if(!n.empty()){let i=n.select("defs");i.empty()&&(i=n.append("defs")),i.append("clipPath").attr("id",this.clipId).append("rect").attr("x",0).attr("y",0).attr("width",t.width).attr("height",t.height),this.group.attr("clip-path",`url(#${this.clipId})`)}}applyShadowFilter(){const t=this.config.shadow;if(!t)return;const n=`katucharts-shadow-${this.config.index}-${Date.now()}`,i=this.group.select(function(){return this.ownerSVGElement});if(!i.empty()){let r=i.select("defs");r.empty()&&(r=i.append("defs"));const s=typeof t=="object"?t:{},o=s.offsetX??1,a=s.offsetY??1,c=s.width??3,l=s.opacity??.15;r.append("filter").attr("id",n).append("feDropShadow").attr("dx",o).attr("dy",a).attr("stdDeviation",c).attr("flood-opacity",l),this.group.style("filter",`url(#${n})`)}}applyInactiveState(){var r,s,o,a,c;const t=this.context.allSeries;if(!t||t.length<=1)return;const n=((s=(r=this.config.states)==null?void 0:r.inactive)==null?void 0:s.opacity)??.2,i=((c=(a=(o=this.config.states)==null?void 0:o.inactive)==null?void 0:a.animation)==null?void 0:c.duration)??me;for(const l of t)l!==this&&l.visible&&l.group.transition("inactive").duration(i).ease(T).attr("opacity",n)}clearInactiveState(){var i,r,s,o,a,c;const t=this.context.allSeries;if(!t||t.length<=1)return;const n=((s=(r=(i=this.config.states)==null?void 0:i.normal)==null?void 0:r.animation)==null?void 0:s.duration)??((c=(a=(o=this.config.states)==null?void 0:o.inactive)==null?void 0:a.animation)==null?void 0:c.duration)??me;for(const l of t)l!==this&&l.visible&&l.group.transition("inactive").duration(n).ease(T).attr("opacity",l.config.opacity??1)}emitAfterAnimate(t){var s;const n=!!((s=this.config.events)!=null&&s.afterAnimate),i=typeof this.config.animation=="object"?this.config.animation:null,r=!!(i!=null&&i.complete);(n||r)&&setTimeout(()=>{var o,a,c;(a=(o=this.config.events)==null?void 0:o.afterAnimate)==null||a.call(this,new Event("afterAnimate")),(c=i==null?void 0:i.complete)==null||c.call(i)},t)}renderDataLabels(t,n,i){const r=this.config.dataLabels;if(!(r!=null&&r.enabled))return;this.group.selectAll(".katucharts-data-labels").remove();const s=this.group.append("g").attr("class","katucharts-data-labels");this.getColor(),t.forEach((o,a)=>{var y,m;if(o.y===null||o.y===void 0)return;const c=o.dataLabels,l={...r,...c};let u;if(l.formatter?u=l.formatter.call({point:{...o,index:a},series:this,x:o.x??a,y:o.y,percentage:o._percentage}):l.format?u=In(En(l.format,{point:o,series:{name:this.config.name??""},x:o.x,y:o.y,percentage:o._percentage??o.percentage})):u=String(o.y),l.filter){const p=o[l.filter.property??"y"]??0,x=l.filter.operator??">",_=l.filter.value??0;if(!(x===">"?p>_:x==="<"?p<_:x===">="?p>=_:x==="<="?p<=_:x==="=="?p===_:!0))return}const h=n(o,a)+(l.x??0),f=i(o,a)+(l.y??-10),g=s.append("text").attr("x",h).attr("y",f).attr("text-anchor",l.align==="left"?"start":l.align==="right"?"end":"middle").attr("dominant-baseline",l.verticalAlign==="top"?"text-before-edge":l.verticalAlign==="bottom"?"text-after-edge":"central").text(u),d=l.style||{};if(g.style("font-size",d.fontSize??Sn).style("font-weight",d.fontWeight??"bold").style("fill",l.color||d.color||this.autoLabelColor()),d.textOutline&&g.style("text-shadow",d.textOutline),l.rotation&&g.attr("transform",`rotate(${l.rotation},${h},${f})`),l.backgroundColor||l.borderWidth){const p=(m=(y=g.node()).getBBox)==null?void 0:m.call(y);if(p){const x=l.padding??5,_=l.borderRadius??0;s.insert("rect",":last-child").attr("x",p.x-x).attr("y",p.y-x).attr("width",p.width+x*2).attr("height",p.height+x*2).attr("rx",_).attr("fill",l.backgroundColor||"none").attr("stroke",l.borderColor||"none").attr("stroke-width",l.borderWidth??0)}}this.context.animate&&l.defer!==!1&&g.attr("opacity",0).transition().delay(Sa+a*q).duration(400).ease(W).attr("opacity",1)})}handlePointSelect(t,n,i,r){var o,a,c,l;if(!this.config.allowPointSelect)return;const s=this.selectedPoints.has(i);if(s){if(((a=(o=n.events)==null?void 0:o.unselect)==null?void 0:a.call(n,r))===!1)return;this.selectedPoints.delete(i),n.selected=!1,this.clearSelectStyle(t)}else{if(((l=(c=n.events)==null?void 0:c.select)==null?void 0:l.call(n,r))===!1)return;this.selectedPoints.add(i),n.selected=!0,this.applySelectStyle(t)}this.context.events.emit("point:select",{point:n,index:i,series:this,selected:!s})}applySelectStyle(t){var i;const n=(i=this.config.states)==null?void 0:i.select;n!=null&&n.color&&t.attr("fill",n.color),n!=null&&n.borderColor&&t.attr("stroke",n.borderColor),(n==null?void 0:n.borderWidth)!==void 0&&t.attr("stroke-width",n.borderWidth)}clearSelectStyle(t){t.attr("fill",null).attr("stroke",null).attr("stroke-width",null)}attachPointEvents(t,n,i){var o;if(this.config.enableMouseTracking===!1)return;const r=n.events||{},s=((o=this.config.point)==null?void 0:o.events)||{};t.on("mouseover",a=>{var c,l;this.context.events.emit("point:mouseover",{point:n,index:i,series:this,event:a,plotX:this.context.xAxis.getPixelForValue(n.x??i),plotY:this.context.yAxis.getPixelForValue(n.y??0)}),(c=r.mouseOver)==null||c.call(n,a),(l=s.mouseOver)==null||l.call(n,a)}).on("mouseout",a=>{var c,l;this.context.events.emit("point:mouseout",{point:n,index:i,series:this,event:a}),(c=r.mouseOut)==null||c.call(n,a),(l=s.mouseOut)==null||l.call(n,a)}).on("click",a=>{var c,l,u,h;this.context.events.emit("point:click",{point:n,index:i,series:this,event:a}),(c=r.click)==null||c.call(n,a),(l=s.click)==null||l.call(n,a),(h=(u=this.config.events)==null?void 0:u.click)==null||h.call(this,a),this.handlePointSelect(t,n,i,a)}),t.style("cursor",this.config.cursor||"pointer")}applyJitter(t,n,i){return i?t+(Math.random()-.5)*i*n:t}}class we extends J{constructor(t){super(t),this.selectedIndices=new Set}getCandleStyle(t){const n=t.isUp?t.upLineColor:t.downLineColor;return{fill:t.isUp?t.upColor:t.downColor,stroke:n,wick:n}}getCandleClass(){return"katucharts-candlestick"}render(){var I,E,P,O,A,R,N,V;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.data,o=this.applyDataGrouping(s),a=this.config.pointRange,c=this.config.groupPadding??.2,l=this.config.pointPadding??.1,u=c+l,h=this.config.maxPointWidth??1/0,f=a?Math.max(1,Math.min(h,i.width/Math.max(1,((I=t.domain)==null?void 0:I[1])-((E=t.domain)==null?void 0:E[0])||o.length)*a*(1-u))):Math.max(1,Math.min(h,i.width/o.length*(1-u))),g=this.config.pointWidth??f,d=this.config.color||"#f45b5b",y=this.config.upColor||"#2f7ed8",m=this.config.lineColor||d,p=this.config.upLineColor||y,x=this.config.lineWidth??1,_=((O=(P=this.config.states)==null?void 0:P.inactive)==null?void 0:O.opacity)??.4,w=this.config.allowPointSelect===!0,v=(R=(A=this.config.states)==null?void 0:A.select)==null?void 0:R.color,k=(V=(N=this.config.states)==null?void 0:N.select)==null?void 0:V.borderColor,M=[];for(let S=0;S<o.length;S++){const C=o[S];if(C.y===null&&C.open===void 0)continue;const L=C.open??C.y??0,B=C.high??L,D=C.low??L,Nt=C.close??L,wt=t.getPixelForValue(C.x??S),Ie=Nt>=L,Se=this.getCandleStyle({open:L,high:B,low:D,close:Nt,isUp:Ie,index:S,data:o,upColor:y,downColor:d,upLineColor:p,downLineColor:m}),Ui=Se.fill,Ua=Se.stroke,Z=this.group.append("g").attr("class",this.getCandleClass()).style("cursor",this.config.cursor||"pointer");M.push(Z);const Yi=Z.append("line").attr("x1",wt).attr("x2",wt).attr("stroke",Se.wick).attr("stroke-width",x),qi=Ie?Nt:L,Ya=Ie?L:Nt,Gi=n.getPixelForValue(qi),Ki=Math.max(1,Math.abs(n.getPixelForValue(Ya)-n.getPixelForValue(qi))),Zi=Z.append("rect").attr("x",wt-g/2).attr("width",g).attr("stroke",Ua).attr("stroke-width",x).attr("rx",2);if(r){const U=n.getPixelForValue((B+D)/2),nt=at(S,0,q,o.length);Yi.attr("y1",U).attr("y2",U).transition().duration(F).ease(W).delay(nt).attr("y1",n.getPixelForValue(B)).attr("y2",n.getPixelForValue(D)),Zi.attr("y",U).attr("height",0).attr("fill",Ui).transition().duration(F).ease(W).delay(nt).attr("y",Gi).attr("height",Ki)}else Yi.attr("y1",n.getPixelForValue(B)).attr("y2",n.getPixelForValue(D)),Zi.attr("y",Gi).attr("height",Ki).attr("fill",Ui);this.config.enableMouseTracking!==!1&&Z.on("mouseover",U=>{var lt,st,Ft,Rt;const nt=((st=(lt=this.config.states)==null?void 0:lt.hover)==null?void 0:st.lineWidthPlus)??2;Z.select("rect").transition("size").duration($).ease(T).attr("x",wt-g*.7).attr("width",g*1.4),Z.select("line").transition("size").duration($).ease(T).attr("stroke-width",x+nt),Z.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),M.forEach(ct=>ct.interrupt("highlight")),M.forEach(ct=>ct.attr("opacity",1)),M.forEach((ct,te)=>{te!==S&&ct.transition("highlight").duration($).ease(T).attr("opacity",_)}),this.context.events.emit("point:mouseover",{point:{...C,open:L,high:B,low:D,close:Nt},index:S,series:this,event:U,plotX:wt,plotY:n.getPixelForValue((B+D)/2)}),(Rt=(Ft=C.events)==null?void 0:Ft.mouseOver)==null||Rt.call(C,U)}).on("mouseout",U=>{var nt,lt;Z.select("rect").transition("size").duration($).ease(T).attr("x",wt-g/2).attr("width",g),Z.select("line").transition("size").duration($).ease(T).attr("stroke-width",x),Z.style("filter",""),M.forEach(st=>st.interrupt("highlight")),M.forEach(st=>st.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:C,index:S,series:this,event:U}),(lt=(nt=C.events)==null?void 0:nt.mouseOut)==null||lt.call(C,U)}).on("click",U=>{var nt,lt,st,Ft,Rt,ct,te,Ji;w&&(this.selectedIndices.has(S)?(this.selectedIndices.delete(S),Z.select("rect").attr("stroke-width",x),(lt=(nt=C.events)==null?void 0:nt.unselect)==null||lt.call(C,U)):(this.selectedIndices.add(S),Z.select("rect").attr("stroke",k||"#000").attr("stroke-width",v?2:x+1),v&&Z.select("rect").attr("fill",v),(Ft=(st=C.events)==null?void 0:st.select)==null||Ft.call(C,U))),this.context.events.emit("point:click",{point:C,index:S,series:this,event:U}),(ct=(Rt=C.events)==null?void 0:Rt.click)==null||ct.call(C,U),(Ji=(te=this.config.events)==null?void 0:te.click)==null||Ji.call(this,U)})}this.renderCandlestickLabels(o,t,n)}renderCandlestickLabels(t,n,i){var a,c;const r=this.config.dataLabels;if(!(r!=null&&r.enabled))return;const s=((a=r.style)==null?void 0:a.fontSize)||Sn,o=r.color||((c=r.style)==null?void 0:c.color)||Tn;t.forEach((l,u)=>{if(l.y===null&&l.open===void 0)return;const h=l.high??l.open??l.y??0,f=n.getPixelForValue(l.x??u),g=i.getPixelForValue(h);let d;r.formatter?d=r.formatter.call({point:l,series:{name:this.config.name},x:l.x,y:l.y}):r.format?d=In(En(r.format,{point:l,series:{name:this.config.name},x:l.x,y:l.y})):d=String(l.close??l.y??""),this.group.append("text").attr("class","katucharts-candlestick-label").attr("x",f+(r.x??0)).attr("y",g-6+(r.y??0)).attr("text-anchor","middle").attr("font-size",s).attr("fill",o).style("pointer-events","none").text(d)})}applyDataGrouping(t){const n=this.config.dataGrouping;if(!(n!=null&&n.enabled)||!n.units||t.length===0)return t;const i=n.groupPixelWidth??10,{plotArea:r}=this.context,s=r.width/Math.max(1,t.length);if(s>=i)return t;const o=Math.ceil(i/s),a=[];for(let c=0;c<t.length;c+=o){const l=t.slice(c,c+o);if(l.length===0)continue;const u=l[0].open??l[0].y??0,h=l[l.length-1].close??l[l.length-1].y??0;let f=-1/0,g=1/0;for(const d of l)f=Math.max(f,d.high??d.y??0),g=Math.min(g,d.low??d.y??0);a.push({...l[0],x:l[0].x,open:u,high:f,low:g,close:h,y:h})}return a}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of this.data){const o=s.x??0;t=Math.min(t,o),n=Math.max(n,o);const a=s.high??s.y??0,c=s.low??s.y??0;i=Math.min(i,c),r=Math.max(r,a)}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class Ra extends J{constructor(t){super(t)}render(){var h,f;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.data,o=Math.max(2,Math.min(10,i.width/s.length*.3)),a=this.config.color||"#f45b5b",c=this.config.upColor||"#2f7ed8",l=((f=(h=this.config.states)==null?void 0:h.inactive)==null?void 0:f.opacity)??.4,u=[];for(let g=0;g<s.length;g++){const d=s[g];if(d.y===null&&d.open===void 0)continue;const y=d.open??d.y??0,m=d.high??y,p=d.low??y,x=d.close??y,_=t.getPixelForValue(d.x??g),w=x>=y?c:a,v=this.group.append("g").attr("class","katucharts-ohlc").style("cursor",this.config.cursor||"pointer");u.push(v),r&&v.attr("opacity",0).transition().duration(F).ease(W).delay(at(g,0,q,s.length)).attr("opacity",1),v.append("line").attr("x1",_).attr("x2",_).attr("y1",n.getPixelForValue(m)).attr("y2",n.getPixelForValue(p)).attr("stroke",w).attr("stroke-width",1.5),v.append("line").attr("x1",_-o).attr("x2",_).attr("y1",n.getPixelForValue(y)).attr("y2",n.getPixelForValue(y)).attr("stroke",w).attr("stroke-width",1.5),v.append("line").attr("x1",_).attr("x2",_+o).attr("y1",n.getPixelForValue(x)).attr("y2",n.getPixelForValue(x)).attr("stroke",w).attr("stroke-width",1.5),this.config.enableMouseTracking!==!1&&v.on("mouseover",k=>{var M,I;v.selectAll("line").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",3),v.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),u.forEach(E=>E.interrupt("highlight")),u.forEach(E=>E.attr("opacity",1)),u.forEach((E,P)=>{P!==g&&E.transition("highlight").duration($).ease(T).attr("opacity",l)}),this.context.events.emit("point:mouseover",{point:{...d,open:y,high:m,low:p,close:x},index:g,series:this,event:k,plotX:_,plotY:n.getPixelForValue((m+p)/2)}),(I=(M=d.events)==null?void 0:M.mouseOver)==null||I.call(d,k)}).on("mouseout",k=>{var M,I;v.selectAll("line").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",1.5),v.style("filter",""),u.forEach(E=>E.interrupt("highlight")),u.forEach(E=>E.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:d,index:g,series:this,event:k}),(I=(M=d.events)==null?void 0:M.mouseOut)==null||I.call(d,k)}).on("click",k=>{var M,I,E,P;this.context.events.emit("point:click",{point:d,index:g,series:this,event:k}),(I=(M=d.events)==null?void 0:M.click)==null||I.call(d,k),(P=(E=this.config.events)==null?void 0:E.click)==null||P.call(this,k)})}}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of this.data){const o=s.x??0;t=Math.min(t,o),n=Math.max(n,o);const a=s.high??s.y??0,c=s.low??s.y??0;i=Math.min(i,c),r=Math.max(r,a)}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class Vn extends we{constructor(t){super(t)}processData(){if(super.processData(),this.data.length===0)return;const t=[];for(let n=0;n<this.data.length;n++){const i=this.data[n],r=i.open??i.y??0,s=i.high??r,o=i.low??r,a=i.close??r,c=(r+s+o+a)/4;let l;if(n===0)l=(r+a)/2;else{const f=t[n-1];l=(f.open+f.close)/2}const u=Math.max(s,l,c),h=Math.min(o,l,c);t.push({...i,open:l,high:u,low:h,close:c,y:c})}this.data=t}}class Dn extends we{getCandleStyle(t){const n=t.index>0?t.data[t.index-1].close??t.data[t.index-1].y??0:t.open,i=t.close>n,r=i?t.upColor:t.downColor;return{fill:i?"none":t.downColor,stroke:r,wick:r}}getCandleClass(){return"katucharts-candlestick katucharts-hollow-candlestick"}}class Ln extends J{constructor(t){super(t)}render(){var m,p,x,_;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.data,o=this.config.groupPadding??.2,a=this.config.pointPadding??.1,c=o+a,l=this.config.maxPointWidth??1/0,u=Math.max(1,Math.min(l,i.width/Math.max(1,s.length)*(1-c))),h=this.config.pointWidth??u,f=this.config.upColor||"#2f7ed8",g=this.config.color||"#f45b5b",d=((p=(m=this.config.states)==null?void 0:m.inactive)==null?void 0:p.opacity)??.4;(_=(x=this.config.states)==null?void 0:x.hover)==null||_.brightness;const y=[];for(let w=0;w<s.length;w++){const v=s[w];if(v.y===null||v.y===void 0)continue;const k=v.y,M=v.open??0,P=(v.close??0)>=M?f:g,O=t.getPixelForValue(v.x??w),A=n.getPixelForValue(k),R=n.getPixelForValue(0),N=Math.max(0,R-A),V=this.group.append("rect").attr("class","katucharts-volume-bar").attr("x",O-h/2).attr("width",h).attr("fill",P).attr("rx",1);r?V.attr("y",R).attr("height",0).transition().duration(F).ease(W).delay(at(w,0,q,s.length)).attr("y",A).attr("height",N):V.attr("y",A).attr("height",N),y.push(V),this.config.enableMouseTracking!==!1&&V.style("cursor",this.config.cursor||"pointer").on("mouseover",S=>{var C,L;V.transition("hover").duration($).ease(T).attr("opacity",.8),y.forEach((B,D)=>{D!==w&&B.interrupt("highlight")}),y.forEach((B,D)=>{D!==w&&B.transition("highlight").duration($).ease(T).attr("opacity",d)}),this.context.events.emit("point:mouseover",{point:v,index:w,series:this,event:S,plotX:O,plotY:A}),(L=(C=v.events)==null?void 0:C.mouseOver)==null||L.call(v,S)}).on("mouseout",S=>{var C,L;V.transition("hover").duration($).ease(T).attr("opacity",1),y.forEach(B=>{B.interrupt("highlight"),B.transition("highlight").duration($).ease(T).attr("opacity",1)}),this.context.events.emit("point:mouseout",{point:v,index:w,series:this,event:S}),(L=(C=v.events)==null?void 0:C.mouseOut)==null||L.call(v,S)}).on("click",S=>{var C,L,B,D;this.context.events.emit("point:click",{point:v,index:w,series:this,event:S}),(L=(C=v.events)==null?void 0:C.click)==null||L.call(v,S),(D=(B=this.config.events)==null?void 0:B.click)==null||D.call(this,S)})}r&&this.emitAfterAnimate(F+s.length*q),this.renderDataLabels(s,(w,v)=>t.getPixelForValue(w.x??v),(w,v)=>n.getPixelForValue(w.y??0))}getDataExtents(){let t=1/0,n=-1/0,i=-1/0;for(const r of this.data){const s=r.x??0;s<t&&(t=s),s>n&&(n=s);const o=r.y??0;o>i&&(i=o)}return{xMin:t,xMax:n,yMin:0,yMax:i}}}function X(e){return function(){return e}}const On=1e-12,ve=Math.PI,be=2*ve,dt=1e-6,Va=be-dt;function Bn(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function Da(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return Bn;const n=10**t;return function(i){this._+=i[0];for(let r=1,s=i.length;r<s;++r)this._+=Math.round(arguments[r]*n)/n+i[r]}}class La{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Bn:Da(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,i,r){this._append`Q${+t},${+n},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,n,i,r,s,o){this._append`C${+t},${+n},${+i},${+r},${this._x1=+s},${this._y1=+o}`}arcTo(t,n,i,r,s){if(t=+t,n=+n,i=+i,r=+r,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,a=this._y1,c=i-t,l=r-n,u=o-t,h=a-n,f=u*u+h*h;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(f>dt)if(!(Math.abs(h*c-l*u)>dt)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let g=i-o,d=r-a,y=c*c+l*l,m=g*g+d*d,p=Math.sqrt(y),x=Math.sqrt(f),_=s*Math.tan((ve-Math.acos((y+f-m)/(2*p*x)))/2),w=_/x,v=_/p;Math.abs(w-1)>dt&&this._append`L${t+w*u},${n+w*h}`,this._append`A${s},${s},0,0,${+(h*g>u*d)},${this._x1=t+v*c},${this._y1=n+v*l}`}}arc(t,n,i,r,s,o){if(t=+t,n=+n,i=+i,o=!!o,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),c=i*Math.sin(r),l=t+a,u=n+c,h=1^o,f=o?r-s:s-r;this._x1===null?this._append`M${l},${u}`:(Math.abs(this._x1-l)>dt||Math.abs(this._y1-u)>dt)&&this._append`L${l},${u}`,i&&(f<0&&(f=f%be+be),f>Va?this._append`A${i},${i},0,1,${h},${t-a},${n-c}A${i},${i},0,1,${h},${this._x1=l},${this._y1=u}`:f>dt&&this._append`A${i},${i},0,${+(f>=ve)},${h},${this._x1=t+i*Math.cos(s)},${this._y1=n+i*Math.sin(s)}`)}rect(t,n,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}}function zn(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);t=i}return e},()=>new La(t)}function Hn(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xn(e){this._context=e}Xn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function St(e){return new Xn(e)}function Wn(e){return e[0]}function Un(e){return e[1]}function gt(e,t){var n=X(!0),i=null,r=St,s=null,o=zn(a);e=typeof e=="function"?e:e===void 0?Wn:X(e),t=typeof t=="function"?t:t===void 0?Un:X(t);function a(c){var l,u=(c=Hn(c)).length,h,f=!1,g;for(i==null&&(s=r(g=o())),l=0;l<=u;++l)!(l<u&&n(h=c[l],l,c))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+e(h,l,c),+t(h,l,c));if(g)return s=null,g+""||null}return a.x=function(c){return arguments.length?(e=typeof c=="function"?c:X(+c),a):e},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:X(+c),a):t},a.defined=function(c){return arguments.length?(n=typeof c=="function"?c:X(!!c),a):n},a.curve=function(c){return arguments.length?(r=c,i!=null&&(s=r(i)),a):r},a.context=function(c){return arguments.length?(c==null?i=s=null:s=r(i=c),a):i},a}function ke(e,t,n){var i=null,r=X(!0),s=null,o=St,a=null,c=zn(l);e=typeof e=="function"?e:e===void 0?Wn:X(+e),t=typeof t=="function"?t:X(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?Un:X(+n);function l(h){var f,g,d,y=(h=Hn(h)).length,m,p=!1,x,_=new Array(y),w=new Array(y);for(s==null&&(a=o(x=c())),f=0;f<=y;++f){if(!(f<y&&r(m=h[f],f,h))===p)if(p=!p)g=f,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),d=f-1;d>=g;--d)a.point(_[d],w[d]);a.lineEnd(),a.areaEnd()}p&&(_[f]=+e(m,f,h),w[f]=+t(m,f,h),a.point(i?+i(m,f,h):_[f],n?+n(m,f,h):w[f]))}if(x)return a=null,x+""||null}function u(){return gt().defined(r).curve(o).context(s)}return l.x=function(h){return arguments.length?(e=typeof h=="function"?h:X(+h),i=null,l):e},l.x0=function(h){return arguments.length?(e=typeof h=="function"?h:X(+h),l):e},l.x1=function(h){return arguments.length?(i=h==null?null:typeof h=="function"?h:X(+h),l):i},l.y=function(h){return arguments.length?(t=typeof h=="function"?h:X(+h),n=null,l):t},l.y0=function(h){return arguments.length?(t=typeof h=="function"?h:X(+h),l):t},l.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:X(+h),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(i).y(t)},l.defined=function(h){return arguments.length?(r=typeof h=="function"?h:X(!!h),l):r},l.curve=function(h){return arguments.length?(o=h,s!=null&&(a=o(s)),l):o},l.context=function(h){return arguments.length?(h==null?s=a=null:a=o(s=h),l):s},l}function Yn(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Me(e,t){this._context=e,this._k=(1-t)/6}Me.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Yn(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:Yn(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},function e(t){function n(i){return new Me(i,t)}return n.tension=function(i){return e(+i)},n}(0);function Oa(e,t,n){var i=e._x1,r=e._y1,s=e._x2,o=e._y2;if(e._l01_a>On){var a=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);i=(i*a-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,r=(r*a-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>On){var l=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,u=3*e._l23_a*(e._l23_a+e._l12_a);s=(s*l+e._x1*e._l23_2a-t*e._l12_2a)/u,o=(o*l+e._y1*e._l23_2a-n*e._l12_2a)/u}e._context.bezierCurveTo(i,r,s,o,e._x2,e._y2)}function qn(e,t){this._context=e,this._alpha=t}qn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:Oa(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Ba=function e(t){function n(i){return t?new qn(i,t):new Me(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);class Ae extends J{constructor(t){super(t)}getCurve(){return St}render(){const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.data,o=this.getColor(),a=this.config.fillOpacity??.3,c=this.config.fillColor||o,l=this.config.lineColor||o,u=this.config.lineWidth??1,h=s.filter(p=>{const x=p.low,_=p.high??p.y;return x!=null&&_!==void 0&&_!==null});if(h.length===0)return;const f=(p,x)=>t.getPixelForValue(p.x??x),g=p=>n.getPixelForValue(p.low),d=p=>n.getPixelForValue(p.high??p.y),y=ke().x((p,x)=>f(p,x)).y0(p=>g(p)).y1(p=>d(p)).curve(this.getCurve()),m=this.group.append("path").datum(h).attr("class","katucharts-arearange-fill").attr("d",y).attr("fill",c).attr("fill-opacity",a).attr("stroke","none");if(u>0){const p=gt().x((_,w)=>f(_,w)).y(_=>d(_)).curve(this.getCurve()),x=gt().x((_,w)=>f(_,w)).y(_=>g(_)).curve(this.getCurve());this.group.append("path").datum(h).attr("class","katucharts-arearange-line-top").attr("d",p).attr("fill","none").attr("stroke",l).attr("stroke-width",u),this.group.append("path").datum(h).attr("class","katucharts-arearange-line-bottom").attr("d",x).attr("fill","none").attr("stroke",l).attr("stroke-width",u)}if(r){const p=i.height/2,x=ke().x((_,w)=>f(_,w)).y0(()=>p).y1(()=>p).curve(this.getCurve());if(m.attr("d",x).transition().duration(F).ease(W).attr("d",y),u>0){const w=gt().x((M,I)=>f(M,I)).y(()=>p).curve(this.getCurve())(h)||"",v=gt().x((M,I)=>f(M,I)).y(M=>d(M)).curve(this.getCurve())(h)||"",k=gt().x((M,I)=>f(M,I)).y(M=>g(M)).curve(this.getCurve())(h)||"";this.group.select(".katucharts-arearange-line-top").attr("d",w).transition().duration(F).ease(W).attr("d",v),this.group.select(".katucharts-arearange-line-bottom").attr("d",w).transition().duration(F).ease(W).attr("d",k)}this.emitAfterAnimate(F)}}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of this.data){const o=s.x??0;o<t&&(t=o),o>n&&(n=o);const a=s.low,c=s.high??s.y;a!=null&&(a<i&&(i=a),a>r&&(r=a)),c!=null&&(c<i&&(i=c),c>r&&(r=c))}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class Gn extends Ae{getCurve(){return Ba.alpha(.5)}}class Kn extends J{constructor(t){super(t)}render(){var m,p;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.data,o=this.config.groupPadding??.2,a=this.config.pointPadding??.1,c=o+a,l=this.config.maxPointWidth??1/0,u=Math.max(1,Math.min(l,i.width/Math.max(1,s.length)*(1-c))),h=this.config.pointWidth??u,f=this.getColor(),g=this.config.borderRadius??0,d=((p=(m=this.config.states)==null?void 0:m.inactive)==null?void 0:p.opacity)??.4,y=[];for(let x=0;x<s.length;x++){const _=s[x],w=_.low,v=_.high??_.y;if(w==null||v===void 0||v===null)continue;const k=t.getPixelForValue(_.x??x),M=n.getPixelForValue(v),I=n.getPixelForValue(w),E=Math.min(M,I),P=Math.max(1,Math.abs(I-M)),O=_.color||f,A=this.group.append("rect").attr("class","katucharts-columnrange-bar").attr("x",k-h/2).attr("width",h).attr("fill",O).attr("rx",g).style("cursor",this.config.cursor||"pointer");if(r){const R=E+P/2;A.attr("y",R).attr("height",0).transition().duration(F).ease(W).delay(at(x,0,q,s.length)).attr("y",E).attr("height",P)}else A.attr("y",E).attr("height",P);y.push(A),this.config.enableMouseTracking!==!1&&A.on("mouseover",R=>{var N,V;A.transition("hover").duration($).ease(T).attr("opacity",.85),y.forEach((S,C)=>{C!==x&&S.interrupt("highlight"),C!==x&&S.transition("highlight").duration($).ease(T).attr("opacity",d)}),this.context.events.emit("point:mouseover",{point:_,index:x,series:this,event:R,plotX:k,plotY:M}),(V=(N=_.events)==null?void 0:N.mouseOver)==null||V.call(_,R)}).on("mouseout",R=>{var N,V;A.transition("hover").duration($).ease(T).attr("opacity",1),y.forEach(S=>{S.interrupt("highlight"),S.transition("highlight").duration($).ease(T).attr("opacity",1)}),this.context.events.emit("point:mouseout",{point:_,index:x,series:this,event:R}),(V=(N=_.events)==null?void 0:N.mouseOut)==null||V.call(_,R)}).on("click",R=>{var N,V,S,C;this.context.events.emit("point:click",{point:_,index:x,series:this,event:R}),(V=(N=_.events)==null?void 0:N.click)==null||V.call(_,R),(C=(S=this.config.events)==null?void 0:S.click)==null||C.call(this,R)})}r&&this.emitAfterAnimate(F+s.length*q)}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of this.data){const o=s.x??0;o<t&&(t=o),o>n&&(n=o);const a=s.low,c=s.high??s.y;a!=null&&(a<i&&(i=a),a>r&&(r=a)),c!=null&&(c<i&&(i=c),c>r&&(r=c))}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class Zn extends J{constructor(t){super(t)}render(){const{yAxis:t,plotArea:n}=this.context,i=this.context.animate,r=this.data;if(r.length===0)return;const s=Math.max(...r.map(h=>h.volume??0))||1,o=this.config.zoneWidth??.3,a=n.width*o,c=this.config.color||"rgba(120,150,200,0.45)",l=this.config.upColor,u=this.config.fillOpacity??.5;for(const h of r){const f=h.low,g=h.high,d=h.volume??0;if(f===void 0||g===void 0)continue;const y=t.getPixelForValue(g),m=t.getPixelForValue(f),p=Math.min(y,m),x=Math.max(1,Math.abs(m-y)-1),_=d/s*a,w=this.group.append("rect").attr("class","katucharts-vbp-bar").attr("x",0).attr("y",p).attr("height",x).attr("fill",l||c).attr("opacity",u);i?w.attr("width",0).transition().duration(F).ease(W).attr("width",_):w.attr("width",_),this.config.enableMouseTracking!==!1&&w.on("mouseover",v=>{this.context.events.emit("point:mouseover",{point:{x:h.x,y:h.y,low:f,high:g,volume:d},index:0,series:this,event:v,plotX:_,plotY:p})}).on("mouseout",v=>{this.context.events.emit("point:mouseout",{point:h,index:0,series:this,event:v})})}}getDataExtents(){return{xMin:1/0,xMax:-1/0,yMin:1/0,yMax:-1/0}}}class Jn extends J{constructor(t){super(t)}render(){var w,v,k,M,I,E;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.data,o=this.config.threshold??0,a=n.getPixelForValue(o),c={color:((w=this.config.topLine)==null?void 0:w.color)??"#2f7ed8",fillColor:((v=this.config.topLine)==null?void 0:v.fillColor)??"rgba(47,126,216,0.2)",fillOpacity:((k=this.config.topLine)==null?void 0:k.fillOpacity)??1},l={color:((M=this.config.bottomLine)==null?void 0:M.color)??"#f45b5b",fillColor:((I=this.config.bottomLine)==null?void 0:I.fillColor)??"rgba(244,91,91,0.2)",fillOpacity:((E=this.config.bottomLine)==null?void 0:E.fillOpacity)??1},u=this.config.lineWidth??2,h=s.filter(P=>P.y!==null&&P.y!==void 0);if(h.length===0)return;const f=(P,O)=>t.getPixelForValue(P.x??O),g=P=>n.getPixelForValue(P.y??0),d=`katucharts-baseline-top-${this.config.index}-${Date.now()}`,y=`katucharts-baseline-bottom-${this.config.index}-${Date.now()}`,m=this.group.select(function(){return this.ownerSVGElement});if(m.empty())return;let p=m.select("defs");p.empty()&&(p=m.append("defs")),p.append("clipPath").attr("id",d).append("rect").attr("x",0).attr("y",0).attr("width",i.width).attr("height",Math.max(0,a)),p.append("clipPath").attr("id",y).append("rect").attr("x",0).attr("y",a).attr("width",i.width).attr("height",Math.max(0,i.height-a));const x=ke().x((P,O)=>f(P,O)).y0(()=>a).y1(P=>g(P)).curve(St),_=gt().x((P,O)=>f(P,O)).y(P=>g(P)).curve(St);this.renderZone(h,x,_,d,c,u,"top"),this.renderZone(h,x,_,y,l,u,"bottom"),this.config.lineWidth!==0&&this.group.append("line").attr("class","katucharts-baseline-threshold").attr("x1",0).attr("x2",i.width).attr("y1",a).attr("y2",a).attr("stroke","#999").attr("stroke-width",1).attr("stroke-dasharray","4,3").attr("opacity",.6),r&&this.animateDrawIn(u)}renderZone(t,n,i,r,s,o,a){const c=this.group.append("g").attr("class",`katucharts-baseline-zone-${a}`).attr("clip-path",`url(#${r})`);c.append("path").datum(t).attr("class",`katucharts-baseline-area-${a}`).attr("d",n).attr("fill",s.fillColor).attr("fill-opacity",s.fillOpacity).attr("stroke","none"),c.append("path").datum(t).attr("class",`katucharts-baseline-line-${a}`).attr("d",i).attr("fill","none").attr("stroke",s.color).attr("stroke-width",o)}animateDrawIn(t){this.group.selectAll('[class*="katucharts-baseline-line-"]').each(function(){var s;const n=this,i=((s=n.getTotalLength)==null?void 0:s.call(n))??0;if(i===0)return;const r=Ss(n);r.attr("stroke-dasharray",`${i} ${i}`).attr("stroke-dashoffset",i).transition().duration(F).ease(W).attr("stroke-dashoffset",0).on("end",()=>{r.attr("stroke-dasharray",null)})}),this.group.selectAll('[class*="katucharts-baseline-area-"]').attr("opacity",0).transition().duration(F).ease(W).attr("opacity",1),this.emitAfterAnimate(F)}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;const s=this.config.threshold??0;for(const o of this.data){const a=o.x??0;a<t&&(t=a),a>n&&(n=a);const c=o.y??0;c<i&&(i=c),c>r&&(r=c)}return s<i&&(i=s),s>r&&(r=s),{xMin:t,xMax:n,yMin:i,yMax:r}}}const Qn=30,Tt=20,Ce=25,Pe=8,pt=12,Ee="9px";class jn extends J{constructor(t){super(t)}render(){const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.data,o=this.config.shape||"flag",a=this.getColor(),c=this.resolveOnSeries();for(let l=0;l<s.length;l++){const u=s[l];if(u.x===void 0||u.x===null)continue;const h=t.getPixelForValue(u.x??l),f=this.resolveAnchorY(u,l,c,n,i),g=u.shape||o,d=u.color||this.config.color||a,y=u.title??"",m=this.group.append("g").attr("class","katucharts-flag").style("cursor",this.config.cursor||"pointer"),p=f-Ce;if(m.append("line").attr("x1",h).attr("x2",h).attr("y1",f).attr("y2",p).attr("stroke",d).attr("stroke-width",1),this.renderShape(m,g,h,p,d,y),r){const x=at(l,0,q,s.length);m.attr("opacity",0).transition().duration(F).ease(W).delay(x).attr("opacity",1)}this.attachFlagEvents(m,u,l,h,p)}}getDataExtents(){let t=1/0,n=-1/0;for(const i of this.data)i.x!==void 0&&i.x!==null&&(i.x<t&&(t=i.x),i.x>n&&(n=i.x));return{xMin:t,xMax:n,yMin:1/0,yMax:-1/0}}resolveOnSeries(){const t=this.config.onSeries;return this.context.allSeries?t?this.context.allSeries.find(n=>n.config.id===t)??null:this.context.allSeries.find(n=>n!==this&&n.config._internalType!=="flags")??null:null}resolveAnchorY(t,n,i,r,s){if(!i)return Ce+Tt;const o=t.x??n,a=i.data;let c=null,l=1/0;for(const u of a){const h=u.x??0,f=Math.abs(h-o);f<l&&(l=f,c=u)}if(c){const u=c.high??c.y;if(u!=null)return r.getPixelForValue(u)}return Ce+Tt}renderShape(t,n,i,r,s,o){switch(n){case"circlepin":t.append("circle").attr("cx",i).attr("cy",r-Pe).attr("r",Pe).attr("fill",s).attr("stroke",s).attr("stroke-width",1),o&&t.append("text").attr("x",i).attr("y",r-Pe).attr("text-anchor","middle").attr("dominant-baseline","central").attr("fill","#ffffff").attr("font-size",Ee).style("pointer-events","none").text(o);break;case"squarepin":t.append("rect").attr("x",i-pt/2).attr("y",r-pt-pt/2).attr("width",pt).attr("height",pt).attr("fill",s).attr("stroke",s).attr("stroke-width",1).attr("transform",`rotate(45,${i},${r-pt})`),o&&t.append("text").attr("x",i).attr("y",r-pt).attr("text-anchor","middle").attr("dominant-baseline","central").attr("fill","#ffffff").attr("font-size",Ee).style("pointer-events","none").text(o);break;case"flag":default:t.append("rect").attr("x",i).attr("y",r-Tt).attr("width",Qn).attr("height",Tt).attr("fill",s).attr("stroke",s).attr("stroke-width",1).attr("rx",2),o&&t.append("text").attr("x",i+Qn/2).attr("y",r-Tt/2).attr("text-anchor","middle").attr("dominant-baseline","central").attr("fill","#ffffff").attr("font-size",Ee).style("pointer-events","none").text(o);break}}attachFlagEvents(t,n,i,r,s){var c;if(this.config.enableMouseTracking===!1)return;const o=n.events||{},a=((c=this.config.point)==null?void 0:c.events)||{};t.on("mouseover",l=>{var u,h;t.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),this.context.events.emit("point:mouseover",{point:n,index:i,series:this,event:l,plotX:r,plotY:s}),(u=o.mouseOver)==null||u.call(n,l),(h=a.mouseOver)==null||h.call(n,l)}).on("mouseout",l=>{var u,h;t.style("filter",""),this.context.events.emit("point:mouseout",{point:n,index:i,series:this,event:l}),(u=o.mouseOut)==null||u.call(n,l),(h=a.mouseOut)==null||h.call(n,l)}).on("click",l=>{var u,h,f,g;this.context.events.emit("point:click",{point:n,index:i,series:this,event:l}),(u=o.click)==null||u.call(n,l),(h=a.click)==null||h.call(n,l),(g=(f=this.config.events)==null?void 0:f.click)==null||g.call(this,l)})}}class ti extends J{constructor(t){super(t),this.bricks=[]}processData(){super.processData();const t=this.config.brickSize??1,n=this.data.map(s=>s.close??s.y).filter(s=>s!=null);if(this.bricks=[],n.length<2)return;let i=Math.floor(n[0]/t)*t,r=0;for(let s=1;s<n.length;s++){const a=n[s]-i,c=Math.floor(Math.abs(a)/t);if(c>=1){const l=a>0?"up":"down";for(let u=0;u<c;u++){const h=l==="up"?i+u*t:i-(u+1)*t;this.bricks.push({index:r++,direction:l,bottom:h,top:h+t})}i+=(l==="up"?1:-1)*c*t}}}render(){var h,f;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.bricks;if(s.length===0)return;const o=this.config.upColor||"#2f7ed8",a=this.config.downColor||this.config.color||"#f45b5b",c=((f=(h=this.config.states)==null?void 0:h.inactive)==null?void 0:f.opacity)??.4,l=Math.max(1,i.width/Math.max(1,s.length)*.8),u=[];for(let g=0;g<s.length;g++){const d=s[g],y=t.getPixelForValue(d.index),m=n.getPixelForValue(d.top),p=n.getPixelForValue(d.bottom),x=Math.max(1,Math.abs(p-m)),_=d.direction==="up"?o:a,w=this.group.append("rect").attr("class","katucharts-renko-brick").attr("x",y-l/2).attr("y",Math.min(m,p)).attr("width",l).attr("height",x).attr("fill",_).attr("stroke",_).attr("stroke-width",.5).style("cursor",this.config.cursor||"pointer");u.push(w),r&&w.attr("opacity",0).transition().duration(F).ease(W).delay(at(g,0,q,s.length)).attr("opacity",1),this.config.enableMouseTracking!==!1&&w.on("mouseover",v=>{w.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),u.forEach((k,M)=>{M!==g&&k.transition("highlight").duration($).ease(T).attr("opacity",c)}),this.context.events.emit("point:mouseover",{point:{x:d.index,y:d.top,low:d.bottom,high:d.top,direction:d.direction},index:g,series:this,event:v,plotX:y,plotY:m})}).on("mouseout",v=>{w.style("filter",""),u.forEach(k=>k.interrupt("highlight")),u.forEach(k=>k.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:{x:d.index,y:d.top},index:g,series:this,event:v})}).on("click",v=>{var k,M;this.context.events.emit("point:click",{point:{x:d.index,y:d.top,direction:d.direction},index:g,series:this,event:v}),(M=(k=this.config.events)==null?void 0:k.click)==null||M.call(this,v)})}r&&this.emitAfterAnimate(F+s.length*q)}getDataExtents(){if(this.bricks.length===0&&this.processData(),this.bricks.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};let t=1/0,n=-1/0;for(const i of this.bricks)i.bottom<t&&(t=i.bottom),i.top>n&&(n=i.top);return{xMin:0,xMax:this.bricks.length-1,yMin:t,yMax:n}}}class ei extends J{constructor(t){super(t),this.segments=[]}processData(){super.processData();const t=this.data.map(f=>f.close??f.y).filter(f=>f!=null);if(this.segments=[],t.length<2)return;const n=Math.max(...t)-Math.min(...t),i=this.config.reversalAmount??n*.04;let r=t[1]>=t[0]?"up":"down",s=t[0],o=t[1],a=0;const c=[],l=[];let u="yin";const h=(f,g)=>{if(r==="up"){const d=c.length>0?c[c.length-1]:-1/0;g>d&&(u="yang"),c.push(g)}else{const d=l.length>0?l[l.length-1]:1/0;g<d&&(u="yin"),l.push(g)}this.segments.push({x:a++,startPrice:f,endPrice:g,type:u})};for(let f=2;f<t.length;f++){const g=t[f];r==="up"?g>o?o=g:o-g>=i&&(h(s,o),s=o,o=g,r="down"):g<o?o=g:g-o>=i&&(h(s,o),s=o,o=g,r="up")}h(s,o)}render(){var f,g;const{xAxis:t,yAxis:n}=this.context,i=this.context.animate,r=this.segments;if(r.length===0)return;const s=this.config.upColor||"#2f7ed8",o=this.config.downColor||this.config.color||"#f45b5b";for(let d=0;d<r.length;d++){const y=r[d];t.getPixelForValue(y.x),n.getPixelForValue(y.startPrice),n.getPixelForValue(y.endPrice)}const a=[];let c="",l=r[0].type,u=null,h=null;for(let d=0;d<r.length;d++){const y=r[d],m=t.getPixelForValue(y.x),p=n.getPixelForValue(y.startPrice),x=n.getPixelForValue(y.endPrice);y.type!==l&&c&&(a.push({d:c,type:l}),c=`M${u},${h}L${m},${h}`,l=y.type),c?u!==null&&(c+=`L${m},${h}`):c=`M${m},${p}`,c+=`L${m},${x}`,u=m,h=x}c&&a.push({d:c,type:l});for(const d of a){const y=d.type==="yang"?s:o,m=d.type==="yang"?3:1,p=this.group.append("path").attr("class",`katucharts-kagi-${d.type}`).attr("d",d.d).attr("fill","none").attr("stroke",y).attr("stroke-width",m).attr("stroke-linejoin","miter");if(i){const x=((g=(f=p.node()).getTotalLength)==null?void 0:g.call(f))||0;x>0&&p.attr("stroke-dasharray",`${x} ${x}`).attr("stroke-dashoffset",x).transition().duration(F).ease(W).attr("stroke-dashoffset",0).on("end",()=>{p.attr("stroke-dasharray",null)})}}if(this.config.enableMouseTracking!==!1)for(let d=0;d<r.length;d++){const y=r[d],m=t.getPixelForValue(y.x),p=n.getPixelForValue(y.startPrice),x=n.getPixelForValue(y.endPrice),_=Math.abs(x-p);this.group.append("rect").attr("class","katucharts-kagi-hitarea").attr("x",m-8).attr("y",Math.min(p,x)).attr("width",16).attr("height",Math.max(_,4)).attr("fill","transparent").style("cursor",this.config.cursor||"pointer").on("mouseover",w=>{const v=`katucharts-kagi-${y.type}`,k=y.type==="yang"?3:1;this.group.selectAll(`path.${v}`).interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",k+1.5);const M=y.type==="yang"?"katucharts-kagi-yin":"katucharts-kagi-yang";this.group.selectAll(`path.${M}`).interrupt("hover").transition("hover").duration(me).ease(T).attr("opacity",.3),this.context.events.emit("point:mouseover",{point:{x:y.x,y:y.endPrice,open:y.startPrice,close:y.endPrice,type:y.type},index:d,series:this,event:w,plotX:m,plotY:x})}).on("mouseout",w=>{this.group.selectAll("path.katucharts-kagi-yang").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",3).attr("opacity",1),this.group.selectAll("path.katucharts-kagi-yin").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",1).attr("opacity",1),this.context.events.emit("point:mouseout",{point:{x:y.x,y:y.endPrice},index:d,series:this,event:w})}).on("click",w=>{var v,k;this.context.events.emit("point:click",{point:{x:y.x,y:y.endPrice,type:y.type},index:d,series:this,event:w}),(k=(v=this.config.events)==null?void 0:v.click)==null||k.call(this,w)})}i&&this.emitAfterAnimate(F)}getDataExtents(){if(this.segments.length===0&&this.processData(),this.segments.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};let t=1/0,n=-1/0;for(const i of this.segments){const r=Math.min(i.startPrice,i.endPrice),s=Math.max(i.startPrice,i.endPrice);r<t&&(t=r),s>n&&(n=s)}return{xMin:0,xMax:this.segments.length-1,yMin:t,yMax:n}}}class ni extends J{constructor(t){super(t),this.columns=[]}processData(){super.processData();const t=this.config.boxSize??1,i=(this.config.reversalAmount??3)*t,r=this.data.map(f=>f.close??f.y).filter(f=>f!=null);if(this.columns=[],r.length<2)return;const s=f=>Math.floor(f/t)*t;let o=r[1]>=r[0]?"X":"O",a=s(r[0])+t,c=s(r[0]),l=0;const u=(f,g)=>{const d=[];for(let y=f;y<g;y+=t)d.push(y);return d},h=()=>{this.columns.push({index:l++,direction:o,startPrice:o==="X"?c:a,endPrice:o==="X"?a:c,boxes:u(c,a)})};for(let f=1;f<r.length;f++){const g=r[f],d=s(g);o==="X"?d+t>a?a=d+t:a-d>=i&&(h(),o="O",a=a-t,c=d):d<c?c=d:d-c>=i&&(h(),o="X",c=c+t,a=d+t)}h()}render(){var g,d;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.columns;if(s.length===0)return;const o=this.config.boxSize??1,a=this.config.upColor||"#2f7ed8",c=this.config.downColor||this.config.color||"#f45b5b",l=((d=(g=this.config.states)==null?void 0:g.inactive)==null?void 0:d.opacity)??.4,u=Math.max(8,Math.min(16,i.width/Math.max(1,s.length)*.6)),h=[];let f=0;for(let y=0;y<s.length;y++){const m=s[y],p=m.direction==="X"?a:c,x=m.direction==="X"?"X":"O",_=this.group.append("g").attr("class",`katucharts-pnf-column katucharts-pnf-${m.direction}`).style("cursor",this.config.cursor||"pointer");h.push(_);for(const w of m.boxes){const v=t.getPixelForValue(m.index),k=n.getPixelForValue(w+o/2),M=_.append("text").attr("x",v).attr("y",k).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",`${u}px`).attr("font-weight","bold").attr("fill",p).style("pointer-events","none").text(x);r&&(M.attr("opacity",0).transition().duration(F).ease(W).delay(at(f,0,q,this.getTotalBoxCount())).attr("opacity",1),f++)}if(this.config.enableMouseTracking!==!1){const w=t.getPixelForValue(m.index),v=n.getPixelForValue(Math.max(m.startPrice,m.endPrice)),k=n.getPixelForValue(Math.min(m.startPrice,m.endPrice)),M=Math.max(u*1.5,20),I=Math.max(Math.abs(k-v),4);_.append("rect").attr("x",w-M/2).attr("y",Math.min(v,k)).attr("width",M).attr("height",I).attr("fill","transparent").style("cursor",this.config.cursor||"pointer").on("mouseover",E=>{_.selectAll("text").interrupt("hover").transition("hover").duration($).ease(T).attr("font-size",`${u*1.2}px`),h.forEach((P,O)=>{O!==y&&P.transition("highlight").duration($).ease(T).attr("opacity",l)}),this.context.events.emit("point:mouseover",{point:{x:m.index,y:m.endPrice,direction:m.direction,startPrice:m.startPrice,endPrice:m.endPrice,boxCount:m.boxes.length},index:y,series:this,event:E,plotX:w,plotY:v})}).on("mouseout",E=>{_.selectAll("text").interrupt("hover").transition("hover").duration($).ease(T).attr("font-size",`${u}px`),h.forEach(P=>P.interrupt("highlight")),h.forEach(P=>P.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:{x:m.index,y:m.endPrice},index:y,series:this,event:E})}).on("click",E=>{var P,O;this.context.events.emit("point:click",{point:{x:m.index,y:m.endPrice,direction:m.direction},index:y,series:this,event:E}),(O=(P=this.config.events)==null?void 0:P.click)==null||O.call(this,E)})}}if(r){const y=this.getTotalBoxCount();this.emitAfterAnimate(F+y*q)}}getTotalBoxCount(){return this.columns.reduce((t,n)=>t+n.boxes.length,0)}getDataExtents(){if(this.columns.length===0&&this.processData(),this.columns.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};const t=this.config.boxSize??1;let n=1/0,i=-1/0;for(const r of this.columns)for(const s of r.boxes)s<n&&(n=s),s+t>i&&(i=s+t);return{xMin:0,xMax:this.columns.length-1,yMin:n,yMax:i}}}class ii extends J{constructor(t){super(t),this.blocks=[]}processData(){super.processData();const t=this.config.lineBreakCount??3,n=this.data.map(r=>r.close??r.y).filter(r=>r!=null);if(this.blocks=[],n.length<2)return;const i={index:0,open:n[0],close:n[1],direction:n[1]>=n[0]?"up":"down"};this.blocks.push(i);for(let r=2;r<n.length;r++){const s=n[r],o=this.blocks.slice(-t),a=this.blocks[this.blocks.length-1];let c=-1/0,l=1/0;for(const u of o){const h=Math.max(u.open,u.close),f=Math.min(u.open,u.close);h>c&&(c=h),f<l&&(l=f)}s>c?this.blocks.push({index:this.blocks.length,open:a.close,close:s,direction:"up"}):s<l&&this.blocks.push({index:this.blocks.length,open:a.close,close:s,direction:"down"})}}render(){var h,f;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,s=this.blocks;if(s.length===0)return;const o=this.config.upColor||"#2f7ed8",a=this.config.downColor||this.config.color||"#f45b5b",c=((f=(h=this.config.states)==null?void 0:h.inactive)==null?void 0:f.opacity)??.4,l=Math.max(1,i.width/Math.max(1,s.length)*.8),u=[];for(let g=0;g<s.length;g++){const d=s[g],y=t.getPixelForValue(d.index),m=n.getPixelForValue(d.open),p=n.getPixelForValue(d.close),x=Math.min(m,p),_=Math.max(1,Math.abs(m-p)),w=d.direction==="up"?o:a,v=x+_/2,k=this.group.append("rect").attr("class","katucharts-linebreak-block").attr("x",y-l/2).attr("width",l).attr("fill",w).attr("stroke",w).attr("stroke-width",.5).style("cursor",this.config.cursor||"pointer");u.push(k),r?k.attr("y",v).attr("height",0).transition().duration(F).ease(W).delay(at(g,0,q,s.length)).attr("y",x).attr("height",_):k.attr("y",x).attr("height",_),this.config.enableMouseTracking!==!1&&k.on("mouseover",M=>{k.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),u.forEach((I,E)=>{E!==g&&I.transition("highlight").duration($).ease(T).attr("opacity",c)}),this.context.events.emit("point:mouseover",{point:{x:d.index,y:d.close,open:d.open,close:d.close,direction:d.direction},index:g,series:this,event:M,plotX:y,plotY:p})}).on("mouseout",M=>{k.style("filter",""),u.forEach(I=>I.interrupt("highlight")),u.forEach(I=>I.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:{x:d.index,y:d.close},index:g,series:this,event:M})}).on("click",M=>{var I,E;this.context.events.emit("point:click",{point:{x:d.index,y:d.close,direction:d.direction},index:g,series:this,event:M}),(E=(I=this.config.events)==null?void 0:I.click)==null||E.call(this,M)})}r&&this.emitAfterAnimate(F+s.length*q)}getDataExtents(){if(this.blocks.length===0&&this.processData(),this.blocks.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};let t=1/0,n=-1/0;for(const i of this.blocks){const r=Math.min(i.open,i.close),s=Math.max(i.open,i.close);r<t&&(t=r),s>n&&(n=s)}return{xMin:0,xMax:this.blocks.length-1,yMin:t,yMax:n}}}function ri(){G.registerType("heikinashi",Vn),G.registerType("hollowcandlestick",Dn),G.registerType("volume",Ln),G.registerType("arearange",Ae),G.registerType("areasplinerange",Gn),G.registerType("columnrange",Kn),G.registerType("vbp",Zn),G.registerType("baseline",Jn),G.registerType("flags",jn),G.registerType("renko",ti),G.registerType("kagi",ei),G.registerType("pointandfigure",ni),G.registerType("linebreak",ii)}class z{}class za{constructor(){this.indicators=new Map}register(t){this.indicators.set(t.name.toLowerCase(),t)}get(t){return this.indicators.get(t.toLowerCase())}getAll(){return new Map(this.indicators)}}const si=globalThis,H=si.__katuIndicatorRegistry||(si.__katuIndicatorRegistry=new za);class oi extends z{constructor(){super(...arguments),this.name="sma"}calculate(t,n){const i=n.period??14,r=new Array(t.length);let s=0;for(let o=0;o<t.length;o++)s+=t[o].close,o>=i&&(s-=t[o-i].close),o<i-1?r[o]={x:t[o].x,y:null}:r[o]={x:t[o].x,y:s/i};return{values:r}}}const ai=new oi;H.register(ai);class li extends z{constructor(){super(...arguments),this.name="ema"}calculate(t,n){const i=n.period??14,r=2/(i+1),s=new Array(t.length);let o=0,a=0;for(let c=0;c<t.length;c++)c<i-1?(a+=t[c].close,s[c]={x:t[c].x,y:null}):c===i-1?(a+=t[c].close,o=a/i,s[c]={x:t[c].x,y:o}):(o=t[c].close*r+o*(1-r),s[c]={x:t[c].x,y:o});return{values:s}}}const ci=new li;H.register(ci);class hi extends z{constructor(){super(...arguments),this.name="wma"}calculate(t,n){const i=n.period??14,r=i*(i+1)/2,s=new Array(t.length);for(let o=0;o<t.length;o++){if(o<i-1){s[o]={x:t[o].x,y:null};continue}let a=0;for(let c=0;c<i;c++)a+=t[o-i+1+c].close*(c+1);s[o]={x:t[o].x,y:a/r}}return{values:s}}}const ui=new hi;H.register(ui);function $t(e,t){const n=2/(t+1),i=new Array(e.length).fill(null);let r=null,s=0,o=0;for(let a=0;a<e.length;a++){const c=e[a];c!=null&&(r===null?(s+=c,o++,o===t&&(r=s/t,i[a]=r)):(r=c*n+r*(1-n),i[a]=r))}return i}class fi extends z{constructor(){super(...arguments),this.name="dema"}calculate(t,n){const i=n.period??14,r=t.map(c=>c.close),s=$t(r,i),o=$t(s,i);return{values:t.map((c,l)=>{const u=s[l],h=o[l];return{x:c.x,y:u!==null&&h!==null?2*u-h:null}})}}}const di=new fi;H.register(di);class gi extends z{constructor(){super(...arguments),this.name="tema"}calculate(t,n){const i=n.period??14,r=t.map(l=>l.close),s=$t(r,i),o=$t(s,i),a=$t(o,i);return{values:t.map((l,u)=>{const h=s[u],f=o[u],g=a[u];return{x:l.x,y:h!==null&&f!==null&&g!==null?3*h-3*f+g:null}})}}}const pi=new gi;H.register(pi);class xi extends z{constructor(){super(...arguments),this.name="rsi"}calculate(t,n){const i=n.period??14,r=new Array(t.length);for(let c=0;c<i;c++)r[c]={x:t[c].x,y:null};let s=0,o=0;for(let c=1;c<=i;c++){const l=t[c].close-t[c-1].close;s+=Math.max(0,l),o+=Math.max(0,-l)}s/=i,o/=i;const a=o===0?1/0:s/o;r[i]={x:t[i].x,y:o===0?100:100-100/(1+a)};for(let c=i+1;c<t.length;c++){const l=t[c].close-t[c-1].close,u=Math.max(0,l),h=Math.max(0,-l);s=(s*(i-1)+u)/i,o=(o*(i-1)+h)/i;const f=o===0?100:100-100/(1+s/o);r[c]={x:t[c].x,y:f}}return{values:r}}}const yi=new xi;H.register(yi);class mi extends z{constructor(){super(...arguments),this.name="stochastic"}calculate(t,n){const i=n.kPeriod??14,r=n.dPeriod??3,s=n.smoothK??3,o=this.computeRawK(t,i),a=this.sma(o,s),c=this.sma(a,r),l=new Array(t.length),u=new Array(t.length);for(let h=0;h<t.length;h++)l[h]={x:t[h].x,y:a[h]},u[h]={x:t[h].x,y:c[h]};return{values:l,signal:u}}computeRawK(t,n){const i=new Array(t.length);for(let r=0;r<t.length;r++){if(r<n-1){i[r]=null;continue}let s=1/0,o=-1/0;for(let c=r-n+1;c<=r;c++)t[c].low<s&&(s=t[c].low),t[c].high>o&&(o=t[c].high);const a=o-s;i[r]=a===0?50:100*(t[r].close-s)/a}return i}sma(t,n){const i=new Array(t.length).fill(null),r=[];for(let s=0;s<t.length;s++)if(t[s]!==null&&r.push(s),r.length>=n){let o=0;for(let a=r.length-n;a<r.length;a++)o+=t[r[a]];i[s]=o/n}return i}}const _i=new mi;H.register(_i);class wi extends z{constructor(){super(...arguments),this.name="macd"}calculate(t,n){const i=n.fastPeriod??12,r=n.slowPeriod??26,s=n.signalPeriod??9,o=t.map(m=>m.close),a=this.ema(o,i),c=this.ema(o,r),l=new Array(t.length);for(let m=0;m<t.length;m++)a[m]===null||c[m]===null?l[m]=null:l[m]=a[m]-c[m];const u=this.extractNonNull(l),h=this.ema(u.values,s),f=new Array(t.length),g=new Array(t.length),d=new Array(t.length);let y=0;for(let m=0;m<t.length;m++){const p=t[m].x;if(l[m]===null)f[m]={x:p,y:null},g[m]={x:p,y:null},d[m]={x:p,y:null};else{const x=l[m],_=h[y];f[m]={x:p,y:x},g[m]={x:p,y:_},d[m]={x:p,y:_===null?null:x-_},y++}}return{values:f,signal:g,histogram:d}}ema(t,n){const i=new Array(t.length).fill(null);if(t.length<n)return i;let r=0;for(let o=0;o<n;o++)r+=t[o];const s=2/(n+1);i[n-1]=r/n;for(let o=n;o<t.length;o++)i[o]=t[o]*s+i[o-1]*(1-s);return i}extractNonNull(t){const n=[],i=[];for(let r=0;r<t.length;r++)t[r]!==null&&(n.push(t[r]),i.push(r));return{values:n,indices:i}}}const vi=new wi;H.register(vi);class bi extends z{constructor(){super(...arguments),this.name="cci"}calculate(t,n){const i=n.period??20,r=t.map(o=>(o.high+o.low+o.close)/3),s=new Array(t.length);for(let o=0;o<t.length;o++){if(o<i-1){s[o]={x:t[o].x,y:null};continue}let a=0;for(let h=o-i+1;h<=o;h++)a+=r[h];const c=a/i;let l=0;for(let h=o-i+1;h<=o;h++)l+=Math.abs(r[h]-c);const u=l/i;s[o]={x:t[o].x,y:u===0?0:(r[o]-c)/(.015*u)}}return{values:s}}}const ki=new bi;H.register(ki);class Mi extends z{constructor(){super(...arguments),this.name="roc"}calculate(t,n){const i=n.period??9;return{values:t.map((s,o)=>{if(o<i)return{x:s.x,y:null};const a=t[o-i].close;return{x:s.x,y:a===0?0:(s.close-a)/a*100}})}}}const Ai=new Mi;H.register(Ai);class Ci extends z{constructor(){super(...arguments),this.name="momentum"}calculate(t,n){const i=n.period??14;return{values:t.map((s,o)=>o<i?{x:s.x,y:null}:{x:s.x,y:s.close-t[o-i].close})}}}const Pi=new Ci;H.register(Pi);class Ei extends z{constructor(){super(...arguments),this.name="bollingerbands"}calculate(t,n){const i=n.period??20,r=n.stdDev??2,s=new Array(t.length),o=new Array(t.length),a=new Array(t.length),c=new Array(t.length);for(let l=0;l<t.length;l++){const u=t[l].x;if(l<i-1){s[l]={x:u,y:null},o[l]={x:u,y:null},a[l]={x:u,y:null},c[l]={x:u,y:null};continue}let h=0;for(let p=l-i+1;p<=l;p++)h+=t[p].close;const f=h/i;let g=0;for(let p=l-i+1;p<=l;p++){const x=t[p].close-f;g+=x*x}const d=Math.sqrt(g/i),y=f+r*d,m=f-r*d;s[l]={x:u,y:f},o[l]={x:u,y},a[l]={x:u,y:f},c[l]={x:u,y:m}}return{values:s,bands:{upper:o,middle:a,lower:c}}}}const Ii=new Ei;H.register(Ii);class Si extends z{constructor(){super(...arguments),this.name="atr"}calculate(t,n){const i=n.period??14,r=new Array(t.length);r[0]={x:t[0].x,y:null};const s=new Array(t.length);s[0]=t[0].high-t[0].low;for(let a=1;a<t.length;a++){const c=t[a].high,l=t[a].low,u=t[a-1].close;s[a]=Math.max(c-l,Math.abs(c-u),Math.abs(l-u))}for(let a=1;a<i;a++)r[a]={x:t[a].x,y:null};let o=0;for(let a=0;a<i;a++)o+=s[a];o/=i,r[i-1]={x:t[i-1].x,y:o};for(let a=i;a<t.length;a++)o=(o*(i-1)+s[a])/i,r[a]={x:t[a].x,y:o};return{values:r}}}const Ti=new Si;H.register(Ti);class $i extends z{constructor(){super(...arguments),this.name="vwap"}calculate(t,n){const i=new Array(t.length);let r=0,s=0,o=null;for(let a=0;a<t.length;a++){const c=t[a],l=c.volume??0;if(l>0){const u=(c.high+c.low+c.close)/3;r+=u*l,s+=l,o=r/s}i[a]={x:c.x,y:o}}return{values:i}}}const Ni=new $i;H.register(Ni);class Fi extends z{constructor(){super(...arguments),this.name="obv"}calculate(t,n){const i=new Array(t.length);if(t.length===0)return{values:[]};let r=0;i[0]={x:t[0].x,y:r};for(let s=1;s<t.length;s++){const o=t[s].volume??0;t[s].close>t[s-1].close?r+=o:t[s].close<t[s-1].close&&(r-=o),i[s]={x:t[s].x,y:r}}return{values:i}}}const Ri=new Fi;H.register(Ri);class Vi extends z{constructor(){super(...arguments),this.name="vbp"}calculate(t,n){const i=Math.max(1,n.ranges??12);if(t.length===0)return{values:[]};let r=1/0,s=-1/0;for(const u of t)r=Math.min(r,u.low??u.close),s=Math.max(s,u.high??u.close);const o=(s-r)/i||1,a=new Array(i).fill(0),c=new Array(i).fill(0);for(const u of t){let h=Math.floor((u.close-r)/o);h<0&&(h=0),h>=i&&(h=i-1);const f=u.volume??0;a[h]+=f,u.close>=u.open&&(c[h]+=f)}return{values:a.map((u,h)=>({x:h,y:r+(h+.5)*o,low:r+h*o,high:r+(h+1)*o,volume:u,volumeUp:c[h]}))}}}const Di=new Vi;H.register(Di);class Li extends z{constructor(){super(...arguments),this.name="ichimoku"}calculate(t,n){const i=n.tenkanPeriod??9,r=n.kijunPeriod??26,s=n.senkouBPeriod??52,o=n.displacement??26,a=t.length;if(a===0)return{values:[],signal:[],bands:{upper:[],lower:[],middle:[]}};const c=new Array(a),l=new Array(a),u=new Array(a);for(let x=0;x<a;x++)c[x]=x>=i-1?this.midpoint(t,x-i+1,i):null,l[x]=x>=r-1?this.midpoint(t,x-r+1,r):null,u[x]=x>=s-1?this.midpoint(t,x-s+1,s):null;const h=a>1?(t[a-1].x-t[0].x)/(a-1):0,f=new Array(a),g=new Array(a);for(let x=0;x<a;x++)f[x]={x:t[x].x,y:c[x]},g[x]={x:t[x].x,y:l[x]};const d=a+o,y=new Array(d),m=new Array(d);for(let x=0;x<d;x++){const _=x-o,w=_>=0&&_<a?t[_].x+o*h:t[0].x+x*h;let v=null;_>=0&&_<a&&c[_]!==null&&l[_]!==null&&(v=(c[_]+l[_])/2);let k=null;_>=0&&_<a&&(k=u[_]),y[x]={x:w,y:v},m[x]={x:w,y:k}}const p=new Array(a);for(let x=0;x<a;x++){const _=t[x].x-o*h;p[x]={x:_,y:t[x].close}}return{values:f,signal:g,bands:{upper:y,lower:m,middle:p}}}midpoint(t,n,i){let r=-1/0,s=1/0;const o=n+i;for(let a=n;a<o;a++)t[a].high>r&&(r=t[a].high),t[a].low<s&&(s=t[a].low);return(r+s)/2}}const Oi=new Li;H.register(Oi);class Bi extends z{constructor(){super(...arguments),this.name="adx"}calculate(t,n){const i=n.period??14,r=t.length,s=t.map(p=>({x:p.x,y:null}));if(r<i*2)return{values:s};const o=new Array(r).fill(0),a=new Array(r).fill(0),c=new Array(r).fill(0);for(let p=1;p<r;p++){const x=t[p].high-t[p-1].high,_=t[p-1].low-t[p].low;o[p]=x>_&&x>0?x:0,a[p]=_>x&&_>0?_:0,c[p]=Math.max(t[p].high-t[p].low,Math.abs(t[p].high-t[p-1].close),Math.abs(t[p].low-t[p-1].close))}let l=0,u=0,h=0;for(let p=1;p<=i;p++)l+=o[p],u+=a[p],h+=c[p];const f=new Array(r).fill(NaN),g=p=>{const x=h===0?0:100*l/h,_=h===0?0:100*u/h,w=x+_;f[p]=w===0?0:100*Math.abs(x-_)/w};g(i);for(let p=i+1;p<r;p++)l=l-l/i+o[p],u=u-u/i+a[p],h=h-h/i+c[p],g(p);let d=0;const y=i*2-1;let m=0;for(let p=i;p<=y;p++)m+=f[p];d=m/i,s[y]={x:t[y].x,y:d};for(let p=y+1;p<r;p++)d=(d*(i-1)+f[p])/i,s[p]={x:t[p].x,y:d};return{values:s}}}const zi=new Bi;H.register(zi);class Hi extends z{constructor(){super(...arguments),this.name="psar"}calculate(t,n){const i=n.increment??.02,r=n.maximum??.2,s=t.length,o=t.map(h=>({x:h.x,y:null}));if(s<2)return{values:o};let a=t[1].close>=t[0].close,c=a?t[0].low:t[0].high,l=a?t[0].high:t[0].low,u=i;o[0]={x:t[0].x,y:c};for(let h=1;h<s;h++){let f=c+u*(l-c);a?(f=Math.min(f,t[h-1].low,h>=2?t[h-2].low:t[h-1].low),t[h].low<f?(a=!1,f=l,l=t[h].low,u=i):t[h].high>l&&(l=t[h].high,u=Math.min(u+i,r))):(f=Math.max(f,t[h-1].high,h>=2?t[h-2].high:t[h-1].high),t[h].high>f?(a=!0,f=l,l=t[h].high,u=i):t[h].low<l&&(l=t[h].low,u=Math.min(u+i,r))),c=f,o[h]={x:t[h].x,y:c}}return{values:o}}}const Xi=new Hi;H.register(Xi);class Ha{static fromWebSocket(t,n,i,r){const s=(r==null?void 0:r.shift)??!1,o=a=>{let c;try{c=JSON.parse(a.data)}catch{return}const l=i(c);if(Array.isArray(l))if(n.addPoints)n.addPoints(l,!0,s);else{for(const u of l)n.addPoint(u,!1,s);n.addPoint(l[l.length-1],!0,s)}else n.addPoint(l,!0,s)};return t.addEventListener("message",o),{unsubscribe:()=>t.removeEventListener("message",o)}}static fromEventSource(t,n,i,r,s){const o=(s==null?void 0:s.shift)??!1,a=c=>{const l=r(c.data);n.addPoint(l,!0,o)};return t.addEventListener(i,a),{unsubscribe:()=>t.removeEventListener(i,a)}}static fromPolling(t,n,i,r){const s=(r==null?void 0:r.shift)??!1;let o=!0;const a=async()=>{if(o){try{const c=await t();if(!o)return;if(Array.isArray(c))if(n.addPoints)n.addPoints(c,!0,s);else for(const l of c)n.addPoint(l,!0,s);else n.addPoint(c,!0,s)}catch{}o&&setTimeout(a,i)}};return setTimeout(a,i),{unsubscribe:()=>{o=!1}}}}class Xa{constructor(t){this.head=0,this._size=0,this.capacity=t,this.buffer=new Array(t)}push(t){const n=this._size===this.capacity?this.buffer[this.head]:void 0,i=(this.head+this._size)%this.capacity;return this.buffer[i]=t,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity,n}pushMany(t){const n=[];for(const i of t){const r=this.push(i);r!==void 0&&n.push(r)}return n}get size(){return this._size}get isFull(){return this._size===this.capacity}get(t){if(!(t<0||t>=this._size))return this.buffer[(this.head+t)%this.capacity]}toArray(){const t=new Array(this._size);for(let n=0;n<this._size;n++)t[n]=this.buffer[(this.head+n)%this.capacity];return t}clear(){this.head=0,this._size=0}}class Wi{constructor(){this.entries=[]}add(t,n){if(t==="setData"){this.entries=[{type:t,payload:n}];return}this.entries.push({type:t,payload:n})}get isEmpty(){return this.entries.length===0}}class Wa{constructor(t,n){this.pendingUpdates=new Map,this.rafId=null,this.lastFrameTime=0,this.maxFps=t.maxFps??30,this.flushCallback=n}schedule(t,n,i){let r=this.pendingUpdates.get(t);r||(r=new Wi,this.pendingUpdates.set(t,r)),r.add(n,i),this.requestFrame()}requestFrame(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const t=performance.now(),n=1e3/this.maxFps;if(t-this.lastFrameTime<n){this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.lastFrameTime=performance.now(),this.flush()});return}this.lastFrameTime=t,this.flush()}))}flush(){if(this.pendingUpdates.size!==0){for(const[t,n]of this.pendingUpdates)n.isEmpty||t.applyBatch(n);this.pendingUpdates.clear(),this.flushCallback()}}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingUpdates.clear()}get hasPending(){return this.pendingUpdates.size>0}}ri(),b.ADX=zi,b.ADXIndicator=Bi,b.ATR=Ti,b.ATRIndicator=Si,b.AreaRangeChart=Ae,b.AreaSplineRangeChart=Gn,b.BaselineChart=Jn,b.BollingerBands=Ii,b.BollingerBandsIndicator=Ei,b.CCI=ki,b.CCIIndicator=bi,b.CandlestickChart=we,b.CircularBuffer=Xa,b.ColumnRangeChart=Kn,b.DEMA=di,b.DEMAIndicator=fi,b.EMA=ci,b.EMAIndicator=li,b.FlagsChart=jn,b.HeikinAshiChart=Vn,b.HollowCandlestickChart=Dn,b.IchimokuCloud=Oi,b.IchimokuCloudIndicator=Li,b.Indicator=z,b.IndicatorRegistry=H,b.KagiChart=ei,b.LineBreakChart=ii,b.MACD=vi,b.MACDIndicator=wi,b.Momentum=Pi,b.MomentumIndicator=Ci,b.OBV=Ri,b.OBVIndicator=Fi,b.OHLCChart=Ra,b.PSAR=Xi,b.PSARIndicator=Hi,b.PointAndFigureChart=ni,b.ROC=Ai,b.ROCIndicator=Mi,b.RSI=yi,b.RSIIndicator=xi,b.RenkoChart=ti,b.SMA=ai,b.SMAIndicator=oi,b.Stochastic=_i,b.StochasticIndicator=mi,b.StreamAdapter=Ha,b.TEMA=pi,b.TEMAIndicator=gi,b.UpdateBatch=Wi,b.UpdateScheduler=Wa,b.VBP=Di,b.VBPChart=Zn,b.VBPIndicator=Vi,b.VWAP=Ni,b.VWAPIndicator=$i,b.VolumeChart=Ln,b.WMA=ui,b.WMAIndicator=hi,b.registerFinanceSeriesTypes=ri,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(k,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(k=typeof globalThis<"u"?globalThis:k||self,bt(k.KatuChartsFinance={}))})(this,function(k){"use strict";class bt{constructor(){this.types=new Map}registerType(t,n){this.types.set(t,n)}getType(t){return this.types.get(t)}hasType(t){return this.types.has(t)}getRegisteredTypes(){return Array.from(this.types.keys())}}const Le=globalThis,q=Le.__katuChartRegistry||(Le.__katuChartRegistry=new bt);var oe="http://www.w3.org/1999/xhtml";const Oe={svg:"http://www.w3.org/2000/svg",xhtml:oe,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Dt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Oe.hasOwnProperty(t)?{space:Oe[t],local:e}:e}function cr(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===oe&&t.documentElement.namespaceURI===oe?t.createElement(e):t.createElementNS(n,e)}}function hr(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Be(e){var t=Dt(e);return(t.local?hr:cr)(t)}function fr(){}function se(e){return e==null?fr:function(){return this.querySelector(e)}}function ur(e){typeof e!="function"&&(e=se(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],s=o.length,a=i[r]=new Array(s),l,c,f=0;f<s;++f)(l=o[f])&&(c=e.call(l,l.__data__,f,o))&&("__data__"in l&&(c.__data__=l.__data__),a[f]=c);return new K(i,this._parents)}function dr(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function gr(){return[]}function He(e){return e==null?gr:function(){return this.querySelectorAll(e)}}function pr(e){return function(){return dr(e.apply(this,arguments))}}function xr(e){typeof e=="function"?e=pr(e):e=He(e);for(var t=this._groups,n=t.length,i=[],r=[],o=0;o<n;++o)for(var s=t[o],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(i.push(e.call(l,l.__data__,c,s)),r.push(l));return new K(i,r)}function ze(e){return function(){return this.matches(e)}}function We(e){return function(t){return t.matches(e)}}var yr=Array.prototype.find;function mr(e){return function(){return yr.call(this.children,e)}}function _r(){return this.firstElementChild}function wr(e){return this.select(e==null?_r:mr(typeof e=="function"?e:We(e)))}var vr=Array.prototype.filter;function br(){return Array.from(this.children)}function kr(e){return function(){return vr.call(this.children,e)}}function Mr(e){return this.selectAll(e==null?br:kr(typeof e=="function"?e:We(e)))}function Ar(e){typeof e!="function"&&(e=ze(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],s=o.length,a=i[r]=[],l,c=0;c<s;++c)(l=o[c])&&e.call(l,l.__data__,c,o)&&a.push(l);return new K(i,this._parents)}function Xe(e){return new Array(e.length)}function Cr(){return new K(this._enter||this._groups.map(Xe),this._parents)}function Lt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Lt.prototype={constructor:Lt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Pr(e){return function(){return e}}function Sr(e,t,n,i,r,o){for(var s=0,a,l=t.length,c=o.length;s<c;++s)(a=t[s])?(a.__data__=o[s],i[s]=a):n[s]=new Lt(e,o[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Er(e,t,n,i,r,o,s){var a,l,c=new Map,f=t.length,h=o.length,u=new Array(f),g;for(a=0;a<f;++a)(l=t[a])&&(u[a]=g=s.call(l,l.__data__,a,t)+"",c.has(g)?r[a]=l:c.set(g,l));for(a=0;a<h;++a)g=s.call(e,o[a],a,o)+"",(l=c.get(g))?(i[a]=l,l.__data__=o[a],c.delete(g)):n[a]=new Lt(e,o[a]);for(a=0;a<f;++a)(l=t[a])&&c.get(u[a])===l&&(r[a]=l)}function Ir(e){return e.__data__}function Tr(e,t){if(!arguments.length)return Array.from(this,Ir);var n=t?Er:Sr,i=this._parents,r=this._groups;typeof e!="function"&&(e=Pr(e));for(var o=r.length,s=new Array(o),a=new Array(o),l=new Array(o),c=0;c<o;++c){var f=i[c],h=r[c],u=h.length,g=$r(e.call(f,f&&f.__data__,c,i)),d=g.length,p=a[c]=new Array(d),y=s[c]=new Array(d),x=l[c]=new Array(u);n(f,h,p,y,x,g,t);for(var m=0,v=0,_,w;m<d;++m)if(_=p[m]){for(m>=v&&(v=m+1);!(w=y[v])&&++v<d;);_._next=w||null}}return s=new K(s,i),s._enter=a,s._exit=l,s}function $r(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Fr(){return new K(this._exit||this._groups.map(Xe),this._parents)}function Nr(e,t,n){var i=this.enter(),r=this,o=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?o.remove():n(o),i&&r?i.merge(r).order():r}function Rr(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,o=i.length,s=Math.min(r,o),a=new Array(r),l=0;l<s;++l)for(var c=n[l],f=i[l],h=c.length,u=a[l]=new Array(h),g,d=0;d<h;++d)(g=c[d]||f[d])&&(u[d]=g);for(;l<r;++l)a[l]=n[l];return new K(a,this._parents)}function Vr(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,o=i[r],s;--r>=0;)(s=i[r])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function Dr(e){e||(e=Lr);function t(h,u){return h&&u?e(h.__data__,u.__data__):!h-!u}for(var n=this._groups,i=n.length,r=new Array(i),o=0;o<i;++o){for(var s=n[o],a=s.length,l=r[o]=new Array(a),c,f=0;f<a;++f)(c=s[f])&&(l[f]=c);l.sort(t)}return new K(r,this._parents).order()}function Lr(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Or(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Br(){return Array.from(this)}function Hr(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,o=i.length;r<o;++r){var s=i[r];if(s)return s}return null}function zr(){let e=0;for(const t of this)++e;return e}function Wr(){return!this.node()}function Xr(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],o=0,s=r.length,a;o<s;++o)(a=r[o])&&e.call(a,a.__data__,o,r);return this}function Ur(e){return function(){this.removeAttribute(e)}}function Gr(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Yr(e,t){return function(){this.setAttribute(e,t)}}function qr(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Kr(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Zr(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Jr(e,t){var n=Dt(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?Gr:Ur:typeof t=="function"?n.local?Zr:Kr:n.local?qr:Yr)(n,t))}function Ue(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Qr(e){return function(){this.style.removeProperty(e)}}function jr(e,t,n){return function(){this.style.setProperty(e,t,n)}}function to(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function eo(e,t,n){return arguments.length>1?this.each((t==null?Qr:typeof t=="function"?to:jr)(e,t,n??"")):mt(this.node(),e)}function mt(e,t){return e.style.getPropertyValue(t)||Ue(e).getComputedStyle(e,null).getPropertyValue(t)}function no(e){return function(){delete this[e]}}function io(e,t){return function(){this[e]=t}}function ro(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function oo(e,t){return arguments.length>1?this.each((t==null?no:typeof t=="function"?ro:io)(e,t)):this.node()[e]}function Ge(e){return e.trim().split(/^|\s+/)}function ae(e){return e.classList||new Ye(e)}function Ye(e){this._node=e,this._names=Ge(e.getAttribute("class")||"")}Ye.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qe(e,t){for(var n=ae(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function Ke(e,t){for(var n=ae(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function so(e){return function(){qe(this,e)}}function ao(e){return function(){Ke(this,e)}}function lo(e,t){return function(){(t.apply(this,arguments)?qe:Ke)(this,e)}}function co(e,t){var n=Ge(e+"");if(arguments.length<2){for(var i=ae(this.node()),r=-1,o=n.length;++r<o;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?lo:t?so:ao)(n,t))}function ho(){this.textContent=""}function fo(e){return function(){this.textContent=e}}function uo(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function go(e){return arguments.length?this.each(e==null?ho:(typeof e=="function"?uo:fo)(e)):this.node().textContent}function po(){this.innerHTML=""}function xo(e){return function(){this.innerHTML=e}}function yo(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function mo(e){return arguments.length?this.each(e==null?po:(typeof e=="function"?yo:xo)(e)):this.node().innerHTML}function _o(){this.nextSibling&&this.parentNode.appendChild(this)}function wo(){return this.each(_o)}function vo(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function bo(){return this.each(vo)}function ko(e){var t=typeof e=="function"?e:Be(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Mo(){return null}function Ao(e,t){var n=typeof e=="function"?e:Be(e),i=t==null?Mo:typeof t=="function"?t:se(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Co(){var e=this.parentNode;e&&e.removeChild(this)}function Po(){return this.each(Co)}function So(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Eo(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Io(e){return this.select(e?Eo:So)}function To(e){return arguments.length?this.property("__data__",e):this.node().__data__}function $o(e){return function(t){e.call(this,t,this.__data__)}}function Fo(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function No(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,o;n<r;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++i]=o;++i?t.length=i:delete this.__on}}}function Ro(e,t,n){return function(){var i=this.__on,r,o=$o(t);if(i){for(var s=0,a=i.length;s<a;++s)if((r=i[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),r.value=t;return}}this.addEventListener(e.type,o,n),r={type:e.type,name:e.name,value:t,listener:o,options:n},i?i.push(r):this.__on=[r]}}function Vo(e,t,n){var i=Fo(e+""),r,o=i.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,f;l<c;++l)for(r=0,f=a[l];r<o;++r)if((s=i[r]).type===f.type&&s.name===f.name)return f.value}return}for(a=t?Ro:No,r=0;r<o;++r)this.each(a(i[r],t,n));return this}function Ze(e,t,n){var i=Ue(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Do(e,t){return function(){return Ze(this,e,t)}}function Lo(e,t){return function(){return Ze(this,e,t.apply(this,arguments))}}function Oo(e,t){return this.each((typeof t=="function"?Lo:Do)(e,t))}function*Bo(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,o=i.length,s;r<o;++r)(s=i[r])&&(yield s)}var Je=[null];function K(e,t){this._groups=e,this._parents=t}function kt(){return new K([[document.documentElement]],Je)}function Ho(){return this}K.prototype=kt.prototype={constructor:K,select:ur,selectAll:xr,selectChild:wr,selectChildren:Mr,filter:Ar,data:Tr,enter:Cr,exit:Fr,join:Nr,merge:Rr,selection:Ho,order:Vr,sort:Dr,call:Or,nodes:Br,node:Hr,size:zr,empty:Wr,each:Xr,attr:Jr,style:eo,property:oo,classed:co,text:go,html:mo,raise:wo,lower:bo,append:ko,insert:Ao,remove:Po,clone:Io,datum:To,on:Vo,dispatch:Oo,[Symbol.iterator]:Bo};function zo(e){return typeof e=="string"?new K([[document.querySelector(e)]],[document.documentElement]):new K([[e]],Je)}var Wo={value:()=>{}};function Qe(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new Ot(n)}function Ot(e){this._=e}function Xo(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}Ot.prototype=Qe.prototype={constructor:Ot,on:function(e,t){var n=this._,i=Xo(e+"",n),r,o=-1,s=i.length;if(arguments.length<2){for(;++o<s;)if((r=(e=i[o]).type)&&(r=Uo(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<s;)if(r=(e=i[o]).type)n[r]=je(n[r],e.name,t);else if(t==null)for(r in n)n[r]=je(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ot(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,o;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],i=0,r=o.length;i<r;++i)o[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)}};function Uo(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function je(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=Wo,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var _t=0,Mt=0,At=0,tn=1e3,Bt,Ct,Ht=0,ft=0,zt=0,Pt=typeof performance=="object"&&performance.now?performance:Date,en=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function le(){return ft||(en(Go),ft=Pt.now()+zt)}function Go(){ft=0}function Wt(){this._call=this._time=this._next=null}Wt.prototype=nn.prototype={constructor:Wt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?le():+n)+(t==null?0:+t),!this._next&&Ct!==this&&(Ct?Ct._next=this:Bt=this,Ct=this),this._call=e,this._time=n,ce()},stop:function(){this._call&&(this._call=null,this._time=1/0,ce())}};function nn(e,t,n){var i=new Wt;return i.restart(e,t,n),i}function Yo(){le(),++_t;for(var e=Bt,t;e;)(t=ft-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_t}function rn(){ft=(Ht=Pt.now())+zt,_t=Mt=0;try{Yo()}finally{_t=0,Ko(),ft=0}}function qo(){var e=Pt.now(),t=e-Ht;t>tn&&(zt-=t,Ht=e)}function Ko(){for(var e,t=Bt,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Bt=n);Ct=e,ce(i)}function ce(e){if(!_t){Mt&&(Mt=clearTimeout(Mt));var t=e-ft;t>24?(e<1/0&&(Mt=setTimeout(rn,e-Pt.now()-zt)),At&&(At=clearInterval(At))):(At||(Ht=Pt.now(),At=setInterval(qo,tn)),_t=1,en(rn))}}function on(e,t,n){var i=new Wt;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var Zo=Qe("start","end","cancel","interrupt"),Jo=[],sn=0,an=1,he=2,Xt=3,ln=4,fe=5,Ut=6;function Gt(e,t,n,i,r,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Qo(e,n,{name:t,index:i,group:r,on:Zo,tween:Jo,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:sn})}function ue(e,t){var n=Q(e,t);if(n.state>sn)throw new Error("too late; already scheduled");return n}function tt(e,t){var n=Q(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function Q(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Qo(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=nn(o,0,n.time);function o(c){n.state=an,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var f,h,u,g;if(n.state!==an)return l();for(f in i)if(g=i[f],g.name===n.name){if(g.state===Xt)return on(s);g.state===ln?(g.state=Ut,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete i[f]):+f<t&&(g.state=Ut,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete i[f])}if(on(function(){n.state===Xt&&(n.state=ln,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=he,n.on.call("start",e,e.__data__,n.index,n.group),n.state===he){for(n.state=Xt,r=new Array(u=n.tween.length),f=0,h=-1;f<u;++f)(g=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++h]=g);r.length=h+1}}function a(c){for(var f=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=fe,1),h=-1,u=r.length;++h<u;)r[h].call(e,f);n.state===fe&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Ut,n.timer.stop(),delete i[t];for(var c in i)return;delete e.__transition}}function jo(e,t){var n=e.__transition,i,r,o=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((i=n[s]).name!==t){o=!1;continue}r=i.state>he&&i.state<fe,i.state=Ut,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[s]}o&&delete e.__transition}}function ts(e){return this.each(function(){jo(this,e)})}function de(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function cn(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function St(){}var Et=.7,Yt=1/Et,wt="\\s*([+-]?\\d+)\\s*",It="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",es=/^#([0-9a-f]{3,8})$/,ns=new RegExp(`^rgb\\(${wt},${wt},${wt}\\)$`),is=new RegExp(`^rgb\\(${et},${et},${et}\\)$`),rs=new RegExp(`^rgba\\(${wt},${wt},${wt},${It}\\)$`),os=new RegExp(`^rgba\\(${et},${et},${et},${It}\\)$`),ss=new RegExp(`^hsl\\(${It},${et},${et}\\)$`),as=new RegExp(`^hsla\\(${It},${et},${et},${It}\\)$`),hn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};de(St,ut,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:fn,formatHex:fn,formatHex8:ls,formatHsl:cs,formatRgb:un,toString:un});function fn(){return this.rgb().formatHex()}function ls(){return this.rgb().formatHex8()}function cs(){return yn(this).formatHsl()}function un(){return this.rgb().formatRgb()}function ut(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=es.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?dn(t):n===3?new G(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?qt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?qt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ns.exec(e))?new G(t[1],t[2],t[3],1):(t=is.exec(e))?new G(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rs.exec(e))?qt(t[1],t[2],t[3],t[4]):(t=os.exec(e))?qt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ss.exec(e))?xn(t[1],t[2]/100,t[3]/100,1):(t=as.exec(e))?xn(t[1],t[2]/100,t[3]/100,t[4]):hn.hasOwnProperty(e)?dn(hn[e]):e==="transparent"?new G(NaN,NaN,NaN,0):null}function dn(e){return new G(e>>16&255,e>>8&255,e&255,1)}function qt(e,t,n,i){return i<=0&&(e=t=n=NaN),new G(e,t,n,i)}function hs(e){return e instanceof St||(e=ut(e)),e?(e=e.rgb(),new G(e.r,e.g,e.b,e.opacity)):new G}function st(e,t,n,i){return arguments.length===1?hs(e):new G(e,t,n,i??1)}function G(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}de(G,st,cn(St,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new G(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Et:Math.pow(Et,e),new G(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new G(dt(this.r),dt(this.g),dt(this.b),Kt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:gn,formatHex:gn,formatHex8:fs,formatRgb:pn,toString:pn}));function gn(){return`#${gt(this.r)}${gt(this.g)}${gt(this.b)}`}function fs(){return`#${gt(this.r)}${gt(this.g)}${gt(this.b)}${gt((isNaN(this.opacity)?1:this.opacity)*255)}`}function pn(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${dt(this.r)}, ${dt(this.g)}, ${dt(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function dt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function gt(e){return e=dt(e),(e<16?"0":"")+e.toString(16)}function xn(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new j(e,t,n,i)}function yn(e){if(e instanceof j)return new j(e.h,e.s,e.l,e.opacity);if(e instanceof St||(e=ut(e)),!e)return new j;if(e instanceof j)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),o=Math.max(t,n,i),s=NaN,a=o-r,l=(o+r)/2;return a?(t===o?s=(n-i)/a+(n<i)*6:n===o?s=(i-t)/a+2:s=(t-n)/a+4,a/=l<.5?o+r:2-o-r,s*=60):a=l>0&&l<1?0:s,new j(s,a,l,e.opacity)}function mn(e,t,n,i){return arguments.length===1?yn(e):new j(e,t,n,i??1)}function j(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}de(j,mn,cn(St,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new j(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Et:Math.pow(Et,e),new j(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new G(ge(e>=240?e-240:e+120,r,i),ge(e,r,i),ge(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new j(_n(this.h),Zt(this.s),Zt(this.l),Kt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${_n(this.h)}, ${Zt(this.s)*100}%, ${Zt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _n(e){return e=(e||0)%360,e<0?e+360:e}function Zt(e){return Math.max(0,Math.min(1,e||0))}function ge(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const wn=e=>()=>e;function us(e,t){return function(n){return e+n*t}}function ds(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function gs(e){return(e=+e)==1?vn:function(t,n){return n-t?ds(t,n,e):wn(isNaN(t)?n:t)}}function vn(e,t){var n=t-e;return n?us(e,n):wn(isNaN(e)?t:e)}const bn=function e(t){var n=gs(t);function i(r,o){var s=n((r=st(r)).r,(o=st(o)).r),a=n(r.g,o.g),l=n(r.b,o.b),c=vn(r.opacity,o.opacity);return function(f){return r.r=s(f),r.g=a(f),r.b=l(f),r.opacity=c(f),r+""}}return i.gamma=e,i}(1);function at(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var pe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xe=new RegExp(pe.source,"g");function ps(e){return function(){return e}}function xs(e){return function(t){return e(t)+""}}function ys(e,t){var n=pe.lastIndex=xe.lastIndex=0,i,r,o,s=-1,a=[],l=[];for(e=e+"",t=t+"";(i=pe.exec(e))&&(r=xe.exec(t));)(o=r.index)>n&&(o=t.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(i=i[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:at(i,r)})),n=xe.lastIndex;return n<t.length&&(o=t.slice(n),a[s]?a[s]+=o:a[++s]=o),a.length<2?l[0]?xs(l[0].x):ps(t):(t=l.length,function(c){for(var f=0,h;f<t;++f)a[(h=l[f]).i]=h.x(c);return a.join("")})}var kn=180/Math.PI,ye={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Mn(e,t,n,i,r,o){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*i)&&(n-=e*l,i-=t*l),(a=Math.sqrt(n*n+i*i))&&(n/=a,i/=a,l/=a),e*i<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:o,rotate:Math.atan2(t,e)*kn,skewX:Math.atan(l)*kn,scaleX:s,scaleY:a}}var Jt;function ms(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ye:Mn(t.a,t.b,t.c,t.d,t.e,t.f)}function _s(e){return e==null||(Jt||(Jt=document.createElementNS("http://www.w3.org/2000/svg","g")),Jt.setAttribute("transform",e),!(e=Jt.transform.baseVal.consolidate()))?ye:(e=e.matrix,Mn(e.a,e.b,e.c,e.d,e.e,e.f))}function An(e,t,n,i){function r(c){return c.length?c.pop()+" ":""}function o(c,f,h,u,g,d){if(c!==h||f!==u){var p=g.push("translate(",null,t,null,n);d.push({i:p-4,x:at(c,h)},{i:p-2,x:at(f,u)})}else(h||u)&&g.push("translate("+h+t+u+n)}function s(c,f,h,u){c!==f?(c-f>180?f+=360:f-c>180&&(c+=360),u.push({i:h.push(r(h)+"rotate(",null,i)-2,x:at(c,f)})):f&&h.push(r(h)+"rotate("+f+i)}function a(c,f,h,u){c!==f?u.push({i:h.push(r(h)+"skewX(",null,i)-2,x:at(c,f)}):f&&h.push(r(h)+"skewX("+f+i)}function l(c,f,h,u,g,d){if(c!==h||f!==u){var p=g.push(r(g)+"scale(",null,",",null,")");d.push({i:p-4,x:at(c,h)},{i:p-2,x:at(f,u)})}else(h!==1||u!==1)&&g.push(r(g)+"scale("+h+","+u+")")}return function(c,f){var h=[],u=[];return c=e(c),f=e(f),o(c.translateX,c.translateY,f.translateX,f.translateY,h,u),s(c.rotate,f.rotate,h,u),a(c.skewX,f.skewX,h,u),l(c.scaleX,c.scaleY,f.scaleX,f.scaleY,h,u),c=f=null,function(g){for(var d=-1,p=u.length,y;++d<p;)h[(y=u[d]).i]=y.x(g);return h.join("")}}}var ws=An(ms,"px, ","px)","deg)"),vs=An(_s,", ",")",")");function bs(e,t){var n,i;return function(){var r=tt(this,e),o=r.tween;if(o!==n){i=n=o;for(var s=0,a=i.length;s<a;++s)if(i[s].name===t){i=i.slice(),i.splice(s,1);break}}r.tween=i}}function ks(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var o=tt(this,e),s=o.tween;if(s!==i){r=(i=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}o.tween=r}}function Ms(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Q(this.node(),n).tween,r=0,o=i.length,s;r<o;++r)if((s=i[r]).name===e)return s.value;return null}return this.each((t==null?bs:ks)(n,e,t))}function me(e,t,n){var i=e._id;return e.each(function(){var r=tt(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Q(r,i).value[t]}}function Cn(e,t){var n;return(typeof t=="number"?at:t instanceof ut?bn:(n=ut(t))?(t=n,bn):ys)(e,t)}function As(e){return function(){this.removeAttribute(e)}}function Cs(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ps(e,t,n){var i,r=n+"",o;return function(){var s=this.getAttribute(e);return s===r?null:s===i?o:o=t(i=s,n)}}function Ss(e,t,n){var i,r=n+"",o;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===i?o:o=t(i=s,n)}}function Es(e,t,n){var i,r,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===i&&l===r?o:(r=l,o=t(i=s,a)))}}function Is(e,t,n){var i,r,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===i&&l===r?o:(r=l,o=t(i=s,a)))}}function Ts(e,t){var n=Dt(e),i=n==="transform"?vs:Cn;return this.attrTween(e,typeof t=="function"?(n.local?Is:Es)(n,i,me(this,"attr."+e,t)):t==null?(n.local?Cs:As)(n):(n.local?Ss:Ps)(n,i,t))}function $s(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Fs(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ns(e,t){var n,i;function r(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&Fs(e,o)),n}return r._value=t,r}function Rs(e,t){var n,i;function r(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&$s(e,o)),n}return r._value=t,r}function Vs(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=Dt(e);return this.tween(n,(i.local?Ns:Rs)(i,t))}function Ds(e,t){return function(){ue(this,e).delay=+t.apply(this,arguments)}}function Ls(e,t){return t=+t,function(){ue(this,e).delay=t}}function Os(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ds:Ls)(t,e)):Q(this.node(),t).delay}function Bs(e,t){return function(){tt(this,e).duration=+t.apply(this,arguments)}}function Hs(e,t){return t=+t,function(){tt(this,e).duration=t}}function zs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Bs:Hs)(t,e)):Q(this.node(),t).duration}function Ws(e,t){if(typeof t!="function")throw new Error;return function(){tt(this,e).ease=t}}function Xs(e){var t=this._id;return arguments.length?this.each(Ws(t,e)):Q(this.node(),t).ease}function Us(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;tt(this,e).ease=n}}function Gs(e){if(typeof e!="function")throw new Error;return this.each(Us(this._id,e))}function Ys(e){typeof e!="function"&&(e=ze(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],s=o.length,a=i[r]=[],l,c=0;c<s;++c)(l=o[c])&&e.call(l,l.__data__,c,o)&&a.push(l);return new it(i,this._parents,this._name,this._id)}function qs(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,o=Math.min(i,r),s=new Array(i),a=0;a<o;++a)for(var l=t[a],c=n[a],f=l.length,h=s[a]=new Array(f),u,g=0;g<f;++g)(u=l[g]||c[g])&&(h[g]=u);for(;a<i;++a)s[a]=t[a];return new it(s,this._parents,this._name,this._id)}function Ks(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Zs(e,t,n){var i,r,o=Ks(t)?ue:tt;return function(){var s=o(this,e),a=s.on;a!==i&&(r=(i=a).copy()).on(t,n),s.on=r}}function Js(e,t){var n=this._id;return arguments.length<2?Q(this.node(),n).on.on(e):this.each(Zs(n,e,t))}function Qs(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function js(){return this.on("end.remove",Qs(this._id))}function ta(e){var t=this._name,n=this._id;typeof e!="function"&&(e=se(e));for(var i=this._groups,r=i.length,o=new Array(r),s=0;s<r;++s)for(var a=i[s],l=a.length,c=o[s]=new Array(l),f,h,u=0;u<l;++u)(f=a[u])&&(h=e.call(f,f.__data__,u,a))&&("__data__"in f&&(h.__data__=f.__data__),c[u]=h,Gt(c[u],t,n,u,c,Q(f,n)));return new it(o,this._parents,t,n)}function ea(e){var t=this._name,n=this._id;typeof e!="function"&&(e=He(e));for(var i=this._groups,r=i.length,o=[],s=[],a=0;a<r;++a)for(var l=i[a],c=l.length,f,h=0;h<c;++h)if(f=l[h]){for(var u=e.call(f,f.__data__,h,l),g,d=Q(f,n),p=0,y=u.length;p<y;++p)(g=u[p])&&Gt(g,t,n,p,u,d);o.push(u),s.push(f)}return new it(o,s,t,n)}var na=kt.prototype.constructor;function ia(){return new na(this._groups,this._parents)}function ra(e,t){var n,i,r;return function(){var o=mt(this,e),s=(this.style.removeProperty(e),mt(this,e));return o===s?null:o===n&&s===i?r:r=t(n=o,i=s)}}function Pn(e){return function(){this.style.removeProperty(e)}}function oa(e,t,n){var i,r=n+"",o;return function(){var s=mt(this,e);return s===r?null:s===i?o:o=t(i=s,n)}}function sa(e,t,n){var i,r,o;return function(){var s=mt(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),mt(this,e))),s===l?null:s===i&&l===r?o:(r=l,o=t(i=s,a))}}function aa(e,t){var n,i,r,o="style."+t,s="end."+o,a;return function(){var l=tt(this,e),c=l.on,f=l.value[o]==null?a||(a=Pn(t)):void 0;(c!==n||r!==f)&&(i=(n=c).copy()).on(s,r=f),l.on=i}}function la(e,t,n){var i=(e+="")=="transform"?ws:Cn;return t==null?this.styleTween(e,ra(e,i)).on("end.style."+e,Pn(e)):typeof t=="function"?this.styleTween(e,sa(e,i,me(this,"style."+e,t))).each(aa(this._id,e)):this.styleTween(e,oa(e,i,t),n).on("end.style."+e,null)}function ca(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function ha(e,t,n){var i,r;function o(){var s=t.apply(this,arguments);return s!==r&&(i=(r=s)&&ca(e,s,n)),i}return o._value=t,o}function fa(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,ha(e,t,n??""))}function ua(e){return function(){this.textContent=e}}function da(e){return function(){var t=e(this);this.textContent=t??""}}function ga(e){return this.tween("text",typeof e=="function"?da(me(this,"text",e)):ua(e==null?"":e+""))}function pa(e){return function(t){this.textContent=e.call(this,t)}}function xa(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&pa(r)),t}return i._value=e,i}function ya(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,xa(e))}function ma(){for(var e=this._name,t=this._id,n=Sn(),i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var f=Q(l,t);Gt(l,e,n,c,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new it(i,this._parents,e,n)}function _a(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(o,s){var a={value:s},l={value:function(){--r===0&&o()}};n.each(function(){var c=tt(this,i),f=c.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&o()})}var wa=0;function it(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function Sn(){return++wa}var rt=kt.prototype;it.prototype={constructor:it,select:ta,selectAll:ea,selectChild:rt.selectChild,selectChildren:rt.selectChildren,filter:Ys,merge:qs,selection:ia,transition:ma,call:rt.call,nodes:rt.nodes,node:rt.node,size:rt.size,empty:rt.empty,each:rt.each,on:Js,attr:Ts,attrTween:Vs,style:la,styleTween:fa,text:ga,textTween:ya,remove:js,tween:Ms,delay:Os,duration:zs,ease:Xs,easeVarying:Gs,end:_a,[Symbol.iterator]:rt[Symbol.iterator]};function En(e){return--e*e*e+1}function va(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ba={time:null,delay:0,duration:250,ease:va};function ka(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Ma(e){var t,n;e instanceof it?(t=e._id,e=e._name):(t=Sn(),(n=ba).time=le(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Gt(l,e,t,c,s,n||ka(l,t));return new it(i,this._parents,e,t)}kt.prototype.interrupt=ts,kt.prototype.transition=Ma;function Aa(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Qt(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function Ca(e){return e=Qt(Math.abs(e)),e?e[1]:NaN}function Pa(e,t){return function(n,i){for(var r=n.length,o=[],s=0,a=e[0],l=0;r>0&&a>0&&(l+a+1>i&&(a=Math.max(1,i-l)),o.push(n.substring(r-=a,r+a)),!((l+=a+1)>i));)a=e[s=(s+1)%e.length];return o.reverse().join(t)}}function Sa(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var Ea=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function _e(e){if(!(t=Ea.exec(e)))throw new Error("invalid format: "+e);var t;return new we({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}_e.prototype=we.prototype;function we(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}we.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Ia(e){t:for(var t=e.length,n=1,i=-1,r;n<t;++n)switch(e[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+e[n])break t;i>0&&(i=0);break}return i>0?e.slice(0,i)+e.slice(r+1):e}var jt;function Ta(e,t){var n=Qt(e,t);if(!n)return jt=void 0,e.toPrecision(t);var i=n[0],r=n[1],o=r-(jt=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,s=i.length;return o===s?i:o>s?i+new Array(o-s+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+Qt(e,Math.max(0,t+o-1))[0]}function In(e,t){var n=Qt(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const Tn={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Aa,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>In(e*100,t),r:In,s:Ta,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function $n(e){return e}var Fn=Array.prototype.map,Nn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function $a(e){var t=e.grouping===void 0||e.thousands===void 0?$n:Pa(Fn.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",i=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",o=e.numerals===void 0?$n:Sa(Fn.call(e.numerals,String)),s=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",l=e.nan===void 0?"NaN":e.nan+"";function c(h,u){h=_e(h);var g=h.fill,d=h.align,p=h.sign,y=h.symbol,x=h.zero,m=h.width,v=h.comma,_=h.precision,w=h.trim,b=h.type;b==="n"?(v=!0,b="g"):Tn[b]||(_===void 0&&(_=12),w=!0,b="g"),(x||g==="0"&&d==="=")&&(x=!0,g="0",d="=");var M=(u&&u.prefix!==void 0?u.prefix:"")+(y==="$"?n:y==="#"&&/[boxX]/.test(b)?"0"+b.toLowerCase():""),I=(y==="$"?i:/[%p]/.test(b)?s:"")+(u&&u.suffix!==void 0?u.suffix:""),S=Tn[b],A=/[defgprs%]/.test(b);_=_===void 0?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function F(C){var V=M,N=I,D,E,P;if(b==="c")N=S(C)+N,C="";else{C=+C;var O=C<0||1/C<0;if(C=isNaN(C)?l:S(Math.abs(C),_),w&&(C=Ia(C)),O&&+C==0&&p!=="+"&&(O=!1),V=(O?p==="("?p:a:p==="-"||p==="("?"":p)+V,N=(b==="s"&&!isNaN(C)&&jt!==void 0?Nn[8+jt/3]:"")+N+(O&&p==="("?")":""),A){for(D=-1,E=C.length;++D<E;)if(P=C.charCodeAt(D),48>P||P>57){N=(P===46?r+C.slice(D+1):C.slice(D))+N,C=C.slice(0,D);break}}}v&&!x&&(C=t(C,1/0));var B=V.length+C.length+N.length,L=B<m?new Array(m-B+1).join(g):"";switch(v&&x&&(C=t(L+C,L.length?m-N.length:1/0),L=""),d){case"<":C=V+C+N+L;break;case"=":C=V+L+C+N;break;case"^":C=L.slice(0,B=L.length>>1)+V+C+N+L.slice(B);break;default:C=L+V+C+N;break}return o(C)}return F.toString=function(){return h+""},F}function f(h,u){var g=Math.max(-8,Math.min(8,Math.floor(Ca(u)/3)))*3,d=Math.pow(10,-g),p=c((h=_e(h),h.type="f",h),{suffix:Nn[8+g/3]});return function(y){return p(d*y)}}return{format:c,formatPrefix:f}}var te,Rn;Fa({thousands:",",grouping:[3],currency:["$",""]});function Fa(e){return te=$a(e),Rn=te.format,te.formatPrefix,te}Object.entries({"%A":"%A","%a":"%a","%d":"%d","%e":"%-d","%b":"%b","%B":"%B","%m":"%m","%y":"%y","%Y":"%Y","%H":"%H","%I":"%I","%k":"%-H","%l":"%-I","%M":"%M","%p":"%p","%P":"%p","%S":"%S","%L":"%L"}).map(([e,t])=>[new RegExp(e.replace("%","\\%"),"g"),t]);const Na=/\{([^}]+)\}/g;function Vn(e,t,n=!1){return e.replace(Na,(i,r)=>{const o=r.indexOf(":");let s=r,a=null;o!==-1&&(s=r.slice(0,o),a=r.slice(o+1));const l=s.trim().split(".");let c=t;for(const h of l){if(c==null)return"";c=c[h]}if(c==null)return"";let f;if(a){const h=typeof c=="number"?c:parseFloat(String(c));if(isNaN(h))f=String(c);else try{f=Rn(a)(h)}catch{f=String(c)}}else f=String(c);return n?Da(f):f})}const Ra=/[&<>"']/g,Va={"&":"&","<":"<",">":">",'"':""","'":"'"};function Da(e){return String(e).replace(Ra,t=>Va[t])}const La=/<\/?[^>]+(>|$)/g,Oa=/<br\s*\/?>/gi;function ve(e){return e.replace(Oa," ").replace(La,"").trim()}const R=600,Y=8,Ba=R+100,$=300,be=250,X=En,T=En,ke="12px",Dn="#000000",Ln="#1a1a1a",Ha="#ffffff",za=3;function Me(e){const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function On(e,t,n){return .2126*Me(e)+.7152*Me(t)+.0722*Me(n)}function Bn(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}const Wa=On(26,26,26);function Hn(e,t){var s;if(t)return t;const n=e?(s=ut(e))==null?void 0:s.rgb():null;if(!n||isNaN(n.r)||n.opacity===0)return Dn;const i=On(n.r,n.g,n.b),r=Bn(i,Wa);return r>=za?Ln:Bn(i,1)>=r?Ha:Ln}function zn(){if(typeof document>"u")return 16;const e=parseFloat(getComputedStyle(document.documentElement).fontSize);return e>0?e:16}function Wn(e){if(!e)return 12;const t=e.trim();if(/^(clamp|min|max)\s*\(/i.test(t)){const r=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).match(/-?\d*\.?\d+\s*(px|rem|em)/gi)||[];let o=0;for(const s of r){const a=Wn(s.trim());a>o&&(o=a)}return o>0?o:12}if(t.endsWith("px"))return parseFloat(t)||12;if(t.endsWith("rem")||t.endsWith("em"))return(parseFloat(t)||1)*zn();const n=parseFloat(t);return isNaN(n)?12:n}let ee=null;function Xa(){return ee||(typeof document>"u"?null:(ee=document.createElement("canvas").getContext("2d"),ee))}function Ua(e,t,n="normal",i="sans-serif"){const r=Xa();return r?(r.font=`${n} ${t}px ${i}`,r.measureText(e).width):e.length*t*.62}const Ga=500;function lt(e,t,n,i){return i>Ga?t:t+e*n}class J{constructor(t){this.selectedPoints=new Set,this._cachedExtents=null,this.config=t,this.visible=t.visible!==!1,this.data=t._processedData||[]}init(t){this.context=t,this.group=t.chartGroup.append("g").attr("class",`katucharts-series katucharts-series-${this.config._internalType}`).attr("data-series-index",this.config.index),this.config.opacity!==void 0&&this.config.opacity!==1&&this.group.attr("opacity",this.config.opacity),this.config.zIndex!==void 0&&this.group.style("z-index",String(this.config.zIndex)),this.config.className&&this.group.classed(this.config.className,!0),this.config.shadow&&this.applyShadowFilter(),this.visible||this.group.style("display","none"),this.config.allowPointSelect&&this.data.forEach((n,i)=>{n.selected&&this.selectedPoints.add(i)}),this.group.on("mouseenter",()=>{var n,i;(i=(n=this.config.events)==null?void 0:n.mouseOver)==null||i.call(this,new Event("mouseOver")),this.context.events.emit("series:mouseenter",this)}).on("mouseleave",()=>{var n,i;(i=(n=this.config.events)==null?void 0:n.mouseOut)==null||i.call(this,new Event("mouseOut")),this.context.events.emit("series:mouseleave",this)})}setOnVisibilityChange(t){this._onVisibilityChange=t}processData(){this.data=this.config._processedData||[],this._cachedExtents=null}getColor(){return this.config.color||this.context.colors[this.context.colorIndex%this.context.colors.length]}autoLabelColor(t){return Hn(this.context.backgroundColor,t)}labelHalo(){const t=this.labelHaloColor();return`0 0 3px ${t}, 0 0 3px ${t}`}labelHaloColor(){return Hn(this.context.backgroundColor)==="#ffffff"?"rgba(0,0,0,0.85)":"#ffffff"}autoBorderColor(){const t=this.context.backgroundColor;return!t||t==="transparent"||t==="none"?"#ffffff":t}getMultiLegendItems(){return null}toggleLegendItem(t){return null}getLegendSymbolShape(){return null}getBubbleLegendInfo(){return null}animateUpdate(t){this.group.selectAll("*").remove(),this.render()}updateContext(t){Object.assign(this.context,t)}redraw(){this.group.selectAll("*").remove(),this.render()}setVisible(t,n=!0){var i,r,o,s;this.visible=t,t?(r=(i=this.config.events)==null?void 0:i.show)==null||r.call(this,new Event("show")):(s=(o=this.config.events)==null?void 0:o.hide)==null||s.call(this,new Event("hide")),n&&this._onVisibilityChange?(t?this.group.style("display","").attr("opacity",0).transition().duration(300).attr("opacity",this.config.opacity??1):this.group.transition().duration(300).attr("opacity",0).on("end",()=>{this.group.style("display","none")}),this._onVisibilityChange(500)):this.group.style("display",t?"":"none"),this.context.events.emit("series:visibilityChanged",this,t)}toggleVisible(){this.setVisible(!this.visible)}getDataExtents(){if(this._cachedExtents)return this._cachedExtents;let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const o of this.data)o.x!==void 0&&o.x!==null&&(o.x<t&&(t=o.x),o.x>n&&(n=o.x)),o.y!==void 0&&o.y!==null&&(o.y<i&&(i=o.y),o.y>r&&(r=o.y));return this._cachedExtents={xMin:t,xMax:n,yMin:i,yMax:r},this._cachedExtents}getCategories(){return this.data.filter(t=>t.name!==void 0).map(t=>t.name)}destroy(){var t;(t=this.group)==null||t.remove()}setData(t,n=!0,i=!0){this.data=t,this.config._processedData=t,this._cachedExtents=null,n&&(i?this.animateUpdate(500):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoint(t,n=!0,i=!1,r=!0){if(this.data.push(t),this.config._processedData=this.data,i&&this.data.length>1)this.data.shift(),this.config._processedData=this.data,this._cachedExtents=null;else if(this._cachedExtents){const o=this._cachedExtents;t.x!==void 0&&t.x!==null&&(t.x<o.xMin&&(o.xMin=t.x),t.x>o.xMax&&(o.xMax=t.x)),t.y!==void 0&&t.y!==null&&(t.y<o.yMin&&(o.yMin=t.y),t.y>o.yMax&&(o.yMax=t.y))}n&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoints(t,n=!0,i=!1,r=!0){for(const o of t)this.data.push(o);i&&this.data.length>t.length&&this.data.splice(0,t.length),this.config._processedData=this.data,this._cachedExtents=null,n&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}removePoint(t,n=!0,i=!0){t>=0&&t<this.data.length&&(this.data.splice(t,1),this.config._processedData=this.data,this._cachedExtents=null,n&&(i?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this)))}updateSeries(t,n=!0){Object.assign(this.config,t),t.data&&(this.config._processedData=t.data,this.data=this.config._processedData,this._cachedExtents=null),n&&this.redraw()}applyBatch(t){for(const n of t.entries)switch(n.type){case"setData":this.data=n.payload,this.config._processedData=this.data;break;case"addPoint":this.data.push(n.payload.point),n.payload.shift&&this.data.length>1&&this.data.shift();break;case"addPoints":for(const i of n.payload.points)this.data.push(i);n.payload.shift&&this.data.splice(0,n.payload.points.length);break;case"removePoint":n.payload.index>=0&&n.payload.index<this.data.length&&this.data.splice(n.payload.index,1);break}this.config._processedData=this.data,this._cachedExtents=null,this.redraw(),this.context.events.emit("series:dataChanged",this)}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}getSelectedPoints(){return Array.from(this.selectedPoints).map(t=>({index:t,point:this.data[t]})).filter(t=>t.point!==void 0)}applyClipPath(){const{plotArea:t}=this.context;this.clipId=`katucharts-clip-${this.config.index}-${Date.now()}`;const n=this.group.select(function(){return this.ownerSVGElement});if(!n.empty()){let i=n.select("defs");i.empty()&&(i=n.append("defs")),i.append("clipPath").attr("id",this.clipId).append("rect").attr("x",0).attr("y",0).attr("width",t.width).attr("height",t.height),this.group.attr("clip-path",`url(#${this.clipId})`)}}applyShadowFilter(){const t=this.config.shadow;if(!t)return;const n=`katucharts-shadow-${this.config.index}-${Date.now()}`,i=this.group.select(function(){return this.ownerSVGElement});if(!i.empty()){let r=i.select("defs");r.empty()&&(r=i.append("defs"));const o=typeof t=="object"?t:{},s=o.offsetX??1,a=o.offsetY??1,l=o.width??3,c=o.opacity??.15;r.append("filter").attr("id",n).append("feDropShadow").attr("dx",s).attr("dy",a).attr("stdDeviation",l).attr("flood-opacity",c),this.group.style("filter",`url(#${n})`)}}applyInactiveState(){var r,o,s,a,l;const t=this.context.allSeries;if(!t||t.length<=1)return;const n=((o=(r=this.config.states)==null?void 0:r.inactive)==null?void 0:o.opacity)??.2,i=((l=(a=(s=this.config.states)==null?void 0:s.inactive)==null?void 0:a.animation)==null?void 0:l.duration)??be;for(const c of t)c!==this&&c.visible&&c.group.transition("inactive").duration(i).ease(T).attr("opacity",n)}clearInactiveState(){var i,r,o,s,a,l;const t=this.context.allSeries;if(!t||t.length<=1)return;const n=((o=(r=(i=this.config.states)==null?void 0:i.normal)==null?void 0:r.animation)==null?void 0:o.duration)??((l=(a=(s=this.config.states)==null?void 0:s.inactive)==null?void 0:a.animation)==null?void 0:l.duration)??be;for(const c of t)c!==this&&c.visible&&c.group.transition("inactive").duration(n).ease(T).attr("opacity",c.config.opacity??1)}emitAfterAnimate(t){var o;const n=!!((o=this.config.events)!=null&&o.afterAnimate),i=typeof this.config.animation=="object"?this.config.animation:null,r=!!(i!=null&&i.complete);(n||r)&&setTimeout(()=>{var s,a,l;(a=(s=this.config.events)==null?void 0:s.afterAnimate)==null||a.call(this,new Event("afterAnimate")),(l=i==null?void 0:i.complete)==null||l.call(i)},t)}renderDataLabels(t,n,i,r,o=-10){const s=this.config.dataLabels;if(!(s!=null&&s.enabled))return;this.group.selectAll(".katucharts-data-labels").remove();const a=this.group.append("g").attr("class","katucharts-data-labels");this.getColor(),t.forEach((l,c)=>{var m,v;if(l.y===null||l.y===void 0)return;const f=l.dataLabels,h={...s,...f};let u;h.formatter?u=h.formatter.call({point:{...l,index:c},series:this,x:l.x??c,y:l.y,percentage:l._percentage}):h.format?u=ve(Vn(h.format,{point:l,series:{name:this.config.name??""},x:l.x,y:l.y,percentage:l._percentage??l.percentage})):u=String(l.y);let g;if(typeof u=="string"&&u.indexOf("<")!==-1){const _=u.match(/color:\s*([^;"')]+)/i);_&&(g=_[1].trim()),u=ve(u)}if(h.filter){const _=l[h.filter.property??"y"]??0,w=h.filter.operator??">",b=h.filter.value??0;if(!(w===">"?_>b:w==="<"?_<b:w===">="?_>=b:w==="<="?_<=b:w==="=="?_===b:!0))return}const d=n(l,c)+(h.x??0),p=i(l,c)+(h.y??o),y=a.append("text").attr("x",d).attr("y",p).attr("text-anchor",h.align==="left"?"start":h.align==="right"?"end":"middle").attr("dominant-baseline",h.verticalAlign==="top"?"text-before-edge":h.verticalAlign==="bottom"?"text-after-edge":"central").text(u),x=h.style||{};if(y.style("font-size",x.fontSize??ke).style("font-weight",x.fontWeight??"bold").style("fill",h.color||g||x.color||this.autoLabelColor()),x.textOutline&&y.style("text-shadow",x.textOutline),r){const _=Ua(u,Wn(x.fontSize||ke)),w=r(l,c,_);w&&y.attr("x",w.x).attr("text-anchor",w.anchor)}if(h.rotation&&y.attr("transform",`rotate(${h.rotation},${d},${p})`),h.backgroundColor||h.borderWidth){const _=(v=(m=y.node()).getBBox)==null?void 0:v.call(m);if(_){const w=h.padding??5,b=h.borderRadius??0;a.insert("rect",":last-child").attr("x",_.x-w).attr("y",_.y-w).attr("width",_.width+w*2).attr("height",_.height+w*2).attr("rx",b).attr("fill",h.backgroundColor||"none").attr("stroke",h.borderColor||"none").attr("stroke-width",h.borderWidth??0)}}this.context.animate&&h.defer!==!1&&y.attr("opacity",0).transition().delay(Ba+c*Y).duration(400).ease(X).attr("opacity",1)})}handlePointSelect(t,n,i,r){var s,a,l,c;if(!this.config.allowPointSelect)return;const o=this.selectedPoints.has(i);if(o){if(((a=(s=n.events)==null?void 0:s.unselect)==null?void 0:a.call(n,r))===!1)return;this.selectedPoints.delete(i),n.selected=!1,this.clearSelectStyle(t)}else{if(((c=(l=n.events)==null?void 0:l.select)==null?void 0:c.call(n,r))===!1)return;this.selectedPoints.add(i),n.selected=!0,this.applySelectStyle(t)}this.context.events.emit("point:select",{point:n,index:i,series:this,selected:!o})}applySelectStyle(t){var i;const n=(i=this.config.states)==null?void 0:i.select;n!=null&&n.color&&t.attr("fill",n.color),n!=null&&n.borderColor&&t.attr("stroke",n.borderColor),(n==null?void 0:n.borderWidth)!==void 0&&t.attr("stroke-width",n.borderWidth)}clearSelectStyle(t){t.attr("fill",null).attr("stroke",null).attr("stroke-width",null)}attachPointEvents(t,n,i){var s;if(this.config.enableMouseTracking===!1)return;const r=n.events||{},o=((s=this.config.point)==null?void 0:s.events)||{};t.on("mouseover",a=>{var l,c;this.context.events.emit("point:mouseover",{point:n,index:i,series:this,event:a,plotX:this.context.xAxis.getPixelForValue(n.x??i),plotY:this.context.yAxis.getPixelForValue(n.y??0)}),(l=r.mouseOver)==null||l.call(n,a),(c=o.mouseOver)==null||c.call(n,a)}).on("mouseout",a=>{var l,c;this.context.events.emit("point:mouseout",{point:n,index:i,series:this,event:a}),(l=r.mouseOut)==null||l.call(n,a),(c=o.mouseOut)==null||c.call(n,a)}).on("click",a=>{var l,c,f,h;this.context.events.emit("point:click",{point:n,index:i,series:this,event:a}),(l=r.click)==null||l.call(n,a),(c=o.click)==null||c.call(n,a),(h=(f=this.config.events)==null?void 0:f.click)==null||h.call(this,a),this.handlePointSelect(t,n,i,a)}),t.style("cursor",this.config.cursor||"pointer")}applyJitter(t,n,i){return i?t+(Math.random()-.5)*i*n:t}}class Ae extends J{constructor(t){super(t),this.selectedIndices=new Set}getCandleStyle(t){const n=t.isUp?t.upLineColor:t.downLineColor;return{fill:t.isUp?t.upColor:t.downColor,stroke:n,wick:n}}getCandleClass(){return"katucharts-candlestick"}render(){var I,S,A,F,C,V,N,D;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.applyDataGrouping(o),a=this.config.pointRange,l=this.config.groupPadding??.2,c=this.config.pointPadding??.1,f=l+c,h=this.config.maxPointWidth??1/0,u=a?Math.max(1,Math.min(h,i.width/Math.max(1,((I=t.domain)==null?void 0:I[1])-((S=t.domain)==null?void 0:S[0])||s.length)*a*(1-f))):Math.max(1,Math.min(h,i.width/s.length*(1-f))),g=this.config.pointWidth??u,d=this.config.color||"#f45b5b",p=this.config.upColor||"#2f7ed8",y=this.config.lineColor||d,x=this.config.upLineColor||p,m=this.config.lineWidth??1,v=((F=(A=this.config.states)==null?void 0:A.inactive)==null?void 0:F.opacity)??.4,_=this.config.allowPointSelect===!0,w=(V=(C=this.config.states)==null?void 0:C.select)==null?void 0:V.color,b=(D=(N=this.config.states)==null?void 0:N.select)==null?void 0:D.borderColor,M=[];for(let E=0;E<s.length;E++){const P=s[E];if(P.y===null&&P.open===void 0)continue;const O=P.open??P.y??0,B=P.high??O,L=P.low??O,Nt=P.close??O,vt=t.getPixelForValue(P.x??E),Ve=Nt>=O,De=this.getCandleStyle({open:O,high:B,low:L,close:Nt,isUp:Ve,index:E,data:s,upColor:p,downColor:d,upLineColor:x,downLineColor:y}),nr=De.fill,ll=De.stroke,Z=this.group.append("g").attr("class",this.getCandleClass()).style("cursor",this.config.cursor||"pointer");M.push(Z);const ir=Z.append("line").attr("x1",vt).attr("x2",vt).attr("stroke",De.wick).attr("stroke-width",m),rr=Ve?Nt:O,cl=Ve?O:Nt,or=n.getPixelForValue(rr),sr=Math.max(1,Math.abs(n.getPixelForValue(cl)-n.getPixelForValue(rr))),ar=Z.append("rect").attr("x",vt-g/2).attr("width",g).attr("stroke",ll).attr("stroke-width",m).attr("rx",2);if(r){const U=n.getPixelForValue((B+L)/2),nt=lt(E,0,Y,s.length);ir.attr("y1",U).attr("y2",U).transition().duration(R).ease(X).delay(nt).attr("y1",n.getPixelForValue(B)).attr("y2",n.getPixelForValue(L)),ar.attr("y",U).attr("height",0).attr("fill",nr).transition().duration(R).ease(X).delay(nt).attr("y",or).attr("height",sr)}else ir.attr("y1",n.getPixelForValue(B)).attr("y2",n.getPixelForValue(L)),ar.attr("y",or).attr("height",sr).attr("fill",nr);this.config.enableMouseTracking!==!1&&Z.on("mouseover",U=>{var ct,ot,Rt,Vt;const nt=((ot=(ct=this.config.states)==null?void 0:ct.hover)==null?void 0:ot.lineWidthPlus)??2;Z.select("rect").transition("size").duration($).ease(T).attr("x",vt-g*.7).attr("width",g*1.4),Z.select("line").transition("size").duration($).ease(T).attr("stroke-width",m+nt),Z.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),M.forEach(ht=>ht.interrupt("highlight")),M.forEach(ht=>ht.attr("opacity",1)),M.forEach((ht,re)=>{re!==E&&ht.transition("highlight").duration($).ease(T).attr("opacity",v)}),this.context.events.emit("point:mouseover",{point:{...P,open:O,high:B,low:L,close:Nt},index:E,series:this,event:U,plotX:vt,plotY:n.getPixelForValue((B+L)/2)}),(Vt=(Rt=P.events)==null?void 0:Rt.mouseOver)==null||Vt.call(P,U)}).on("mouseout",U=>{var nt,ct;Z.select("rect").transition("size").duration($).ease(T).attr("x",vt-g/2).attr("width",g),Z.select("line").transition("size").duration($).ease(T).attr("stroke-width",m),Z.style("filter",""),M.forEach(ot=>ot.interrupt("highlight")),M.forEach(ot=>ot.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:P,index:E,series:this,event:U}),(ct=(nt=P.events)==null?void 0:nt.mouseOut)==null||ct.call(P,U)}).on("click",U=>{var nt,ct,ot,Rt,Vt,ht,re,lr;_&&(this.selectedIndices.has(E)?(this.selectedIndices.delete(E),Z.select("rect").attr("stroke-width",m),(ct=(nt=P.events)==null?void 0:nt.unselect)==null||ct.call(P,U)):(this.selectedIndices.add(E),Z.select("rect").attr("stroke",b||"#000").attr("stroke-width",w?2:m+1),w&&Z.select("rect").attr("fill",w),(Rt=(ot=P.events)==null?void 0:ot.select)==null||Rt.call(P,U))),this.context.events.emit("point:click",{point:P,index:E,series:this,event:U}),(ht=(Vt=P.events)==null?void 0:Vt.click)==null||ht.call(P,U),(lr=(re=this.config.events)==null?void 0:re.click)==null||lr.call(this,U)})}this.renderCandlestickLabels(s,t,n)}renderCandlestickLabels(t,n,i){var a,l;const r=this.config.dataLabels;if(!(r!=null&&r.enabled))return;const o=((a=r.style)==null?void 0:a.fontSize)||ke,s=r.color||((l=r.style)==null?void 0:l.color)||Dn;t.forEach((c,f)=>{if(c.y===null&&c.open===void 0)return;const h=c.high??c.open??c.y??0,u=n.getPixelForValue(c.x??f),g=i.getPixelForValue(h);let d;r.formatter?d=r.formatter.call({point:c,series:{name:this.config.name},x:c.x,y:c.y}):r.format?d=ve(Vn(r.format,{point:c,series:{name:this.config.name},x:c.x,y:c.y})):d=String(c.close??c.y??""),this.group.append("text").attr("class","katucharts-candlestick-label").attr("x",u+(r.x??0)).attr("y",g-6+(r.y??0)).attr("text-anchor","middle").attr("font-size",o).attr("fill",s).style("pointer-events","none").text(d)})}applyDataGrouping(t){const n=this.config.dataGrouping;if(!(n!=null&&n.enabled)||!n.units||t.length===0)return t;const i=n.groupPixelWidth??10,{plotArea:r}=this.context,o=r.width/Math.max(1,t.length);if(o>=i)return t;const s=Math.ceil(i/o),a=[];for(let l=0;l<t.length;l+=s){const c=t.slice(l,l+s);if(c.length===0)continue;const f=c[0].open??c[0].y??0,h=c[c.length-1].close??c[c.length-1].y??0;let u=-1/0,g=1/0;for(const d of c)u=Math.max(u,d.high??d.y??0),g=Math.min(g,d.low??d.y??0);a.push({...c[0],x:c[0].x,open:f,high:u,low:g,close:h,y:h})}return a}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;t=Math.min(t,s),n=Math.max(n,s);const a=o.high??o.y??0,l=o.low??o.y??0;i=Math.min(i,l),r=Math.max(r,a)}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class Ya extends J{constructor(t){super(t)}render(){var h,u;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=Math.max(2,Math.min(10,i.width/o.length*.3)),a=this.config.color||"#f45b5b",l=this.config.upColor||"#2f7ed8",c=((u=(h=this.config.states)==null?void 0:h.inactive)==null?void 0:u.opacity)??.4,f=[];for(let g=0;g<o.length;g++){const d=o[g];if(d.y===null&&d.open===void 0)continue;const p=d.open??d.y??0,y=d.high??p,x=d.low??p,m=d.close??p,v=t.getPixelForValue(d.x??g),_=m>=p?l:a,w=this.group.append("g").attr("class","katucharts-ohlc").style("cursor",this.config.cursor||"pointer");f.push(w),r&&w.attr("opacity",0).transition().duration(R).ease(X).delay(lt(g,0,Y,o.length)).attr("opacity",1),w.append("line").attr("x1",v).attr("x2",v).attr("y1",n.getPixelForValue(y)).attr("y2",n.getPixelForValue(x)).attr("stroke",_).attr("stroke-width",1.5),w.append("line").attr("x1",v-s).attr("x2",v).attr("y1",n.getPixelForValue(p)).attr("y2",n.getPixelForValue(p)).attr("stroke",_).attr("stroke-width",1.5),w.append("line").attr("x1",v).attr("x2",v+s).attr("y1",n.getPixelForValue(m)).attr("y2",n.getPixelForValue(m)).attr("stroke",_).attr("stroke-width",1.5),this.config.enableMouseTracking!==!1&&w.on("mouseover",b=>{var M,I;w.selectAll("line").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",3),w.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),f.forEach(S=>S.interrupt("highlight")),f.forEach(S=>S.attr("opacity",1)),f.forEach((S,A)=>{A!==g&&S.transition("highlight").duration($).ease(T).attr("opacity",c)}),this.context.events.emit("point:mouseover",{point:{...d,open:p,high:y,low:x,close:m},index:g,series:this,event:b,plotX:v,plotY:n.getPixelForValue((y+x)/2)}),(I=(M=d.events)==null?void 0:M.mouseOver)==null||I.call(d,b)}).on("mouseout",b=>{var M,I;w.selectAll("line").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",1.5),w.style("filter",""),f.forEach(S=>S.interrupt("highlight")),f.forEach(S=>S.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:d,index:g,series:this,event:b}),(I=(M=d.events)==null?void 0:M.mouseOut)==null||I.call(d,b)}).on("click",b=>{var M,I,S,A;this.context.events.emit("point:click",{point:d,index:g,series:this,event:b}),(I=(M=d.events)==null?void 0:M.click)==null||I.call(d,b),(A=(S=this.config.events)==null?void 0:S.click)==null||A.call(this,b)})}}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;t=Math.min(t,s),n=Math.max(n,s);const a=o.high??o.y??0,l=o.low??o.y??0;i=Math.min(i,l),r=Math.max(r,a)}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class Xn extends Ae{constructor(t){super(t)}processData(){if(super.processData(),this.data.length===0)return;const t=[];for(let n=0;n<this.data.length;n++){const i=this.data[n],r=i.open??i.y??0,o=i.high??r,s=i.low??r,a=i.close??r,l=(r+o+s+a)/4;let c;if(n===0)c=(r+a)/2;else{const u=t[n-1];c=(u.open+u.close)/2}const f=Math.max(o,c,l),h=Math.min(s,c,l);t.push({...i,open:c,high:f,low:h,close:l,y:l})}this.data=t}}class Un extends Ae{getCandleStyle(t){const n=t.index>0?t.data[t.index-1].close??t.data[t.index-1].y??0:t.open,i=t.close>n,r=i?t.upColor:t.downColor;return{fill:i?"none":t.downColor,stroke:r,wick:r}}getCandleClass(){return"katucharts-candlestick katucharts-hollow-candlestick"}}class Gn extends J{constructor(t){super(t)}render(){var y,x,m,v;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.config.groupPadding??.2,a=this.config.pointPadding??.1,l=s+a,c=this.config.maxPointWidth??1/0,f=Math.max(1,Math.min(c,i.width/Math.max(1,o.length)*(1-l))),h=this.config.pointWidth??f,u=this.config.upColor||"#2f7ed8",g=this.config.color||"#f45b5b",d=((x=(y=this.config.states)==null?void 0:y.inactive)==null?void 0:x.opacity)??.4;(v=(m=this.config.states)==null?void 0:m.hover)==null||v.brightness;const p=[];for(let _=0;_<o.length;_++){const w=o[_];if(w.y===null||w.y===void 0)continue;const b=w.y,M=w.open??0,A=(w.close??0)>=M?u:g,F=t.getPixelForValue(w.x??_),C=n.getPixelForValue(b),V=n.getPixelForValue(0),N=Math.max(0,V-C),D=this.group.append("rect").attr("class","katucharts-volume-bar").attr("x",F-h/2).attr("width",h).attr("fill",A).attr("rx",1);r?D.attr("y",V).attr("height",0).transition().duration(R).ease(X).delay(lt(_,0,Y,o.length)).attr("y",C).attr("height",N):D.attr("y",C).attr("height",N),p.push(D),this.config.enableMouseTracking!==!1&&D.style("cursor",this.config.cursor||"pointer").on("mouseover",E=>{var P,O;D.transition("hover").duration($).ease(T).attr("opacity",.8),p.forEach((B,L)=>{L!==_&&B.interrupt("highlight")}),p.forEach((B,L)=>{L!==_&&B.transition("highlight").duration($).ease(T).attr("opacity",d)}),this.context.events.emit("point:mouseover",{point:w,index:_,series:this,event:E,plotX:F,plotY:C}),(O=(P=w.events)==null?void 0:P.mouseOver)==null||O.call(w,E)}).on("mouseout",E=>{var P,O;D.transition("hover").duration($).ease(T).attr("opacity",1),p.forEach(B=>{B.interrupt("highlight"),B.transition("highlight").duration($).ease(T).attr("opacity",1)}),this.context.events.emit("point:mouseout",{point:w,index:_,series:this,event:E}),(O=(P=w.events)==null?void 0:P.mouseOut)==null||O.call(w,E)}).on("click",E=>{var P,O,B,L;this.context.events.emit("point:click",{point:w,index:_,series:this,event:E}),(O=(P=w.events)==null?void 0:P.click)==null||O.call(w,E),(L=(B=this.config.events)==null?void 0:B.click)==null||L.call(this,E)})}r&&this.emitAfterAnimate(R+o.length*Y),this.renderDataLabels(o,(_,w)=>t.getPixelForValue(_.x??w),(_,w)=>n.getPixelForValue(_.y??0))}getDataExtents(){let t=1/0,n=-1/0,i=-1/0;for(const r of this.data){const o=r.x??0;o<t&&(t=o),o>n&&(n=o);const s=r.y??0;s>i&&(i=s)}return{xMin:t,xMax:n,yMin:0,yMax:i}}}function W(e){return function(){return e}}const Yn=1e-12,Ce=Math.PI,Pe=2*Ce,pt=1e-6,qa=Pe-pt;function qn(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function Ka(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return qn;const n=10**t;return function(i){this._+=i[0];for(let r=1,o=i.length;r<o;++r)this._+=Math.round(arguments[r]*n)/n+i[r]}}class Za{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?qn:Ka(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,i,r){this._append`Q${+t},${+n},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,n,i,r,o,s){this._append`C${+t},${+n},${+i},${+r},${this._x1=+o},${this._y1=+s}`}arcTo(t,n,i,r,o){if(t=+t,n=+n,i=+i,r=+r,o=+o,o<0)throw new Error(`negative radius: ${o}`);let s=this._x1,a=this._y1,l=i-t,c=r-n,f=s-t,h=a-n,u=f*f+h*h;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(u>pt)if(!(Math.abs(h*l-c*f)>pt)||!o)this._append`L${this._x1=t},${this._y1=n}`;else{let g=i-s,d=r-a,p=l*l+c*c,y=g*g+d*d,x=Math.sqrt(p),m=Math.sqrt(u),v=o*Math.tan((Ce-Math.acos((p+u-y)/(2*x*m)))/2),_=v/m,w=v/x;Math.abs(_-1)>pt&&this._append`L${t+_*f},${n+_*h}`,this._append`A${o},${o},0,0,${+(h*g>f*d)},${this._x1=t+w*l},${this._y1=n+w*c}`}}arc(t,n,i,r,o,s){if(t=+t,n=+n,i=+i,s=!!s,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),l=i*Math.sin(r),c=t+a,f=n+l,h=1^s,u=s?r-o:o-r;this._x1===null?this._append`M${c},${f}`:(Math.abs(this._x1-c)>pt||Math.abs(this._y1-f)>pt)&&this._append`L${c},${f}`,i&&(u<0&&(u=u%Pe+Pe),u>qa?this._append`A${i},${i},0,1,${h},${t-a},${n-l}A${i},${i},0,1,${h},${this._x1=c},${this._y1=f}`:u>pt&&this._append`A${i},${i},0,${+(u>=Ce)},${h},${this._x1=t+i*Math.cos(o)},${this._y1=n+i*Math.sin(o)}`)}rect(t,n,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}}function Kn(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);t=i}return e},()=>new Za(t)}function Zn(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Jn(e){this._context=e}Jn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Tt(e){return new Jn(e)}function Qn(e){return e[0]}function jn(e){return e[1]}function xt(e,t){var n=W(!0),i=null,r=Tt,o=null,s=Kn(a);e=typeof e=="function"?e:e===void 0?Qn:W(e),t=typeof t=="function"?t:t===void 0?jn:W(t);function a(l){var c,f=(l=Zn(l)).length,h,u=!1,g;for(i==null&&(o=r(g=s())),c=0;c<=f;++c)!(c<f&&n(h=l[c],c,l))===u&&((u=!u)?o.lineStart():o.lineEnd()),u&&o.point(+e(h,c,l),+t(h,c,l));if(g)return o=null,g+""||null}return a.x=function(l){return arguments.length?(e=typeof l=="function"?l:W(+l),a):e},a.y=function(l){return arguments.length?(t=typeof l=="function"?l:W(+l),a):t},a.defined=function(l){return arguments.length?(n=typeof l=="function"?l:W(!!l),a):n},a.curve=function(l){return arguments.length?(r=l,i!=null&&(o=r(i)),a):r},a.context=function(l){return arguments.length?(l==null?i=o=null:o=r(i=l),a):i},a}function Se(e,t,n){var i=null,r=W(!0),o=null,s=Tt,a=null,l=Kn(c);e=typeof e=="function"?e:e===void 0?Qn:W(+e),t=typeof t=="function"?t:W(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?jn:W(+n);function c(h){var u,g,d,p=(h=Zn(h)).length,y,x=!1,m,v=new Array(p),_=new Array(p);for(o==null&&(a=s(m=l())),u=0;u<=p;++u){if(!(u<p&&r(y=h[u],u,h))===x)if(x=!x)g=u,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),d=u-1;d>=g;--d)a.point(v[d],_[d]);a.lineEnd(),a.areaEnd()}x&&(v[u]=+e(y,u,h),_[u]=+t(y,u,h),a.point(i?+i(y,u,h):v[u],n?+n(y,u,h):_[u]))}if(m)return a=null,m+""||null}function f(){return xt().defined(r).curve(s).context(o)}return c.x=function(h){return arguments.length?(e=typeof h=="function"?h:W(+h),i=null,c):e},c.x0=function(h){return arguments.length?(e=typeof h=="function"?h:W(+h),c):e},c.x1=function(h){return arguments.length?(i=h==null?null:typeof h=="function"?h:W(+h),c):i},c.y=function(h){return arguments.length?(t=typeof h=="function"?h:W(+h),n=null,c):t},c.y0=function(h){return arguments.length?(t=typeof h=="function"?h:W(+h),c):t},c.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:W(+h),c):n},c.lineX0=c.lineY0=function(){return f().x(e).y(t)},c.lineY1=function(){return f().x(e).y(n)},c.lineX1=function(){return f().x(i).y(t)},c.defined=function(h){return arguments.length?(r=typeof h=="function"?h:W(!!h),c):r},c.curve=function(h){return arguments.length?(s=h,o!=null&&(a=s(o)),c):s},c.context=function(h){return arguments.length?(h==null?o=a=null:a=s(o=h),c):o},c}function ti(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Ee(e,t){this._context=e,this._k=(1-t)/6}Ee.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:ti(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:ti(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},function e(t){function n(i){return new Ee(i,t)}return n.tension=function(i){return e(+i)},n}(0);function Ja(e,t,n){var i=e._x1,r=e._y1,o=e._x2,s=e._y2;if(e._l01_a>Yn){var a=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,l=3*e._l01_a*(e._l01_a+e._l12_a);i=(i*a-e._x0*e._l12_2a+e._x2*e._l01_2a)/l,r=(r*a-e._y0*e._l12_2a+e._y2*e._l01_2a)/l}if(e._l23_a>Yn){var c=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,f=3*e._l23_a*(e._l23_a+e._l12_a);o=(o*c+e._x1*e._l23_2a-t*e._l12_2a)/f,s=(s*c+e._y1*e._l23_2a-n*e._l12_2a)/f}e._context.bezierCurveTo(i,r,o,s,e._x2,e._y2)}function ei(e,t){this._context=e,this._alpha=t}ei.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:Ja(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Qa=function e(t){function n(i){return t?new ei(i,t):new Ee(i,0)}return n.alpha=function(i){return e(+i)},n}(.5),ne=new Map,ja=256;function Ie(e){const t=e||"rgba(0,0,0,0)",n=ne.get(t);if(n)return n;const i="rgba(0,0,0,0)",r=ut(e||i),o=st(r||i),s={r:Math.round(o.r),g:Math.round(o.g),b:Math.round(o.b),a:o.opacity,get(a){return a==="rgba"?this.toString():this.toString()},brighten(a){const l=mn(st(this.r,this.g,this.b,this.a));l.l+=a*.1,l.l=Math.max(0,Math.min(1,l.l));const c=st(l);return Ie(c.formatRgb())},setOpacity(a){return Ie(`rgba(${this.r},${this.g},${this.b},${a})`)},toString(){return this.a<1?`rgba(${this.r},${this.g},${this.b},${this.a})`:st(this.r,this.g,this.b).formatHex()}};return ne.size>=ja&&ne.clear(),ne.set(t,s),s}const tl={textStrong:"#1f2933",textSoft:"#52606d",axis:"#6b7280",line:"#c8ccd2",grid:"#e6e8eb",tooltipBg:"rgba(255,255,255,0.96)",tooltipBorder:"#d8dce0",legend:"#52606d"},el={textStrong:"#f3f4f6",textSoft:"#b8bfc7",axis:"#9aa3ad",line:"#3a414a",grid:"rgba(255,255,255,0.08)",tooltipBg:"#20262e",tooltipBorder:"#39414b",legend:"#c2c9d1"};function ni(e,t,n){const i={gridLineColor:n.grid,lineColor:n.line,tickColor:n.line,labels:{style:{color:n.axis}},title:{style:{color:n.axis}}};return{colors:e,chart:{backgroundColor:t},title:{style:{color:n.textStrong}},subtitle:{style:{color:n.textSoft}},xAxis:i,yAxis:i,tooltip:{backgroundColor:n.tooltipBg,borderColor:n.tooltipBorder,style:{color:n.textStrong}},legend:{itemStyle:{color:n.legend},itemHoverStyle:{color:n.textStrong}}}}const Te={tupi:{light:["#b43417","#1b1a15","#a85429","#ce9a3a","#33503a","#8c2810","#6b6a45","#d97b3f","#5b5240","#7a3b2e"],dark:["#e0673f","#e7dbc0","#d08a4e","#e8c45f","#6fa37a","#c84c2c","#c9b27a","#f0a06a","#a9a07e","#d98b6a"]},ocean:{light:["#0466c8","#0353a4","#3a86ff","#00b4d8","#0096c7","#48cae4","#023e8a","#5e60ce","#0077b6","#90e0ef"],dark:["#48cae4","#4895ef","#56cfe1","#64dfdf","#80ffdb","#5390d9","#7400b8","#4cc9f0","#56cfe1","#72efdd"]},sunset:{light:["#ff6b35","#f7522f","#ff9e00","#ffbf69","#e85d75","#d1495b","#ffd166","#9e2a2b","#f3722c","#bc4749"],dark:["#ff7b54","#ffb26b","#ffd56b","#ff9e7d","#ff6b6b","#feca57","#ff9ff3","#f368e0","#ffa07a","#ffd56b"]},forest:{light:["#2d6a4f","#40916c","#52b788","#74c69d","#1b4332","#95d5b2","#b7e4c7","#344e41","#588157","#a3b18a"],dark:["#74c69d","#52b788","#95d5b2","#40916c","#b7e4c7","#2d6a4f","#d8f3dc","#588157","#a3b18a","#80ed99"]},corporate:{light:["#2c3e50","#3498db","#16a085","#f39c12","#8e44ad","#e74c3c","#34495e","#27ae60","#2980b9","#d35400"],dark:["#5dade2","#48c9b0","#f5b041","#bb8fce","#ec7063","#58d68d","#85c1e9","#76d7c4","#f8c471","#aed6f1"]},vivid:{light:["#ff006e","#fb5607","#ffbe0b","#8338ec","#3a86ff","#06d6a0","#ef476f","#118ab2","#ff70a6","#9b5de5"],dark:["#ff5d8f","#ff7b00","#ffd60a","#9d4edd","#4cc9f0","#06d6a0","#ff70a6","#48cae4","#fb5607","#b5179e"]},monochrome:{light:["#1f2933","#3e4c59","#52606d","#7b8794","#9aa5b1","#616e7c","#cbd2d9","#323f4b","#46545f","#a7b0b8"],dark:["#e4e7eb","#cbd2d9","#9aa5b1","#7b8794","#616e7c","#b8c0c9","#52606d","#d3d9de","#8a949e","#3e4c59"]},nordic:{light:["#5e81ac","#81a1c1","#88c0d0","#8fbcbb","#bf616a","#d08770","#ebcb8b","#a3be8c","#b48ead","#4c566a"],dark:["#88c0d0","#81a1c1","#8fbcbb","#a3be8c","#ebcb8b","#d08770","#bf616a","#b48ead","#5e81ac","#d8dee9"]},pastel:{light:["#a8e6cf","#ffd3b6","#ffaaa5","#c7ceea","#b5ead7","#ff8b94","#dcedc1","#e2afff","#ffdac1","#b5c7ed"],dark:["#a8e6cf","#ffd3b6","#ffaaa5","#c7ceea","#b5ead7","#ff8b94","#dcedc1","#e2afff","#ffdac1","#b5c7ed"]}},ii={tupi:{light:"#ecdfc4",dark:"#1c1814"},ocean:{light:"#ffffff",dark:"#0b1622"},sunset:{light:"#ffffff",dark:"#1f1410"},forest:{light:"#ffffff",dark:"#0f1f17"},corporate:{light:"#ffffff",dark:"#1a1f26"},vivid:{light:"#ffffff",dark:"#14101c"},monochrome:{light:"#ffffff",dark:"#1a1f24"},nordic:{light:"#eceff4",dark:"#2e3440"},pastel:{light:"#ffffff",dark:"#232026"}};(()=>{const e={};for(const t of Object.keys(Te))e[t]=ni(Te[t].light,ii[t].light,tl),e[`${t}-dark`]=ni(Te[t].dark,ii[t].dark,el);return e.light=e.monochrome,e.dark=e["monochrome-dark"],e})();function ie(e){return!!e&&typeof e=="object"&&("linearGradient"in e||"radialGradient"in e)}let nl=0;function ri(e,t,n){const i=Ie(n);e.append("stop").attr("offset",String(t)).attr("stop-color",`rgb(${i.r}, ${i.g}, ${i.b})`).attr("stop-opacity",i.a)}function il(e,t,n){if(e==null)return n;if(typeof e=="string")return e;if(!ie(e))return n;const i=`katucharts-fill-grad-${++nl}`,r=t.append("defs");if("radialGradient"in e){const o=e.radialGradient,s=r.append("radialGradient").attr("id",i).attr("cx",String(o.cx??.5)).attr("cy",String(o.cy??.5)).attr("r",String(o.r??.5));for(const[a,l]of e.stops)ri(s,a,l)}else{const o=e.linearGradient,s=r.append("linearGradient").attr("id",i).attr("x1",String(o.x1??0)).attr("y1",String(o.y1??0)).attr("x2",String(o.x2??0)).attr("y2",String(o.y2??1));for(const[a,l]of e.stops)ri(s,a,l)}return`url(#${i})`}class $e extends J{constructor(t){super(t)}getCurve(){return Tt}render(){const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.config.color,a=this.context.colors[this.context.colorIndex%this.context.colors.length],l=this.gradientBaseColor(s)??(ie(s)?a:s||a),c=this.config.fillColor??s,f=il(c,this.group,l),h=this.config.fillOpacity??(ie(c)?1:.3),u=this.config.lineColor||l,g=this.config.lineWidth??1,d=o.filter(_=>{const w=_.low,b=_.high??_.y;return w!=null&&b!==void 0&&b!==null});if(d.length===0)return;const p=(_,w)=>t.getPixelForValue(_.x??w),y=_=>n.getPixelForValue(_.low),x=_=>n.getPixelForValue(_.high??_.y),m=Se().x((_,w)=>p(_,w)).y0(_=>y(_)).y1(_=>x(_)).curve(this.getCurve()),v=this.group.append("path").datum(d).attr("class","katucharts-arearange-fill").attr("d",m).attr("fill",f).attr("fill-opacity",h).attr("stroke","none");if(g>0){const _=xt().x((b,M)=>p(b,M)).y(b=>x(b)).curve(this.getCurve()),w=xt().x((b,M)=>p(b,M)).y(b=>y(b)).curve(this.getCurve());this.group.append("path").datum(d).attr("class","katucharts-arearange-line-top").attr("d",_).attr("fill","none").attr("stroke",u).attr("stroke-width",g),this.group.append("path").datum(d).attr("class","katucharts-arearange-line-bottom").attr("d",w).attr("fill","none").attr("stroke",u).attr("stroke-width",g)}if(r){const _=i.height/2,w=Se().x((b,M)=>p(b,M)).y0(()=>_).y1(()=>_).curve(this.getCurve());if(v.attr("d",w).transition().duration(R).ease(X).attr("d",m),g>0){const M=xt().x((A,F)=>p(A,F)).y(()=>_).curve(this.getCurve())(d)||"",I=xt().x((A,F)=>p(A,F)).y(A=>x(A)).curve(this.getCurve())(d)||"",S=xt().x((A,F)=>p(A,F)).y(A=>y(A)).curve(this.getCurve())(d)||"";this.group.select(".katucharts-arearange-line-top").attr("d",M).transition().duration(R).ease(X).attr("d",I),this.group.select(".katucharts-arearange-line-bottom").attr("d",M).transition().duration(R).ease(X).attr("d",S)}this.emitAfterAnimate(R)}this.setupHoverMarkers(d,p,y,x,l)}gradientBaseColor(t){var i;if(!ie(t))return null;const n=t.stops;if(!Array.isArray(n)||n.length===0)return null;for(const[,r]of n)if(typeof r=="string"&&!/rgba?\([^)]*,\s*0?\.\d+\s*\)/.test(r))return r;return((i=n[Math.floor(n.length/2)])==null?void 0:i[1])??null}setupHoverMarkers(t,n,i,r,o){var p;const s=this.context.events;if(this.hoverHandlers&&(s.off("point:mouseover",this.hoverHandlers.over),s.off("point:mouseout",this.hoverHandlers.out),s.off("series:mouseleave",this.hoverHandlers.out)),this.config.enableMouseTracking===!1)return;const a=this.group.append("g").attr("class","katucharts-arearange-hover").style("pointer-events","none"),l=((p=this.config.marker)==null?void 0:p.radius)??4,c=()=>a.append("circle").attr("r",l).attr("fill",o).attr("stroke","#ffffff").attr("stroke-width",1).attr("opacity",0),f=c(),h=c(),u=new Map;t.forEach((y,x)=>u.set(y.x??x,{x:n(y,x),hi:r(y),lo:i(y)}));const g=y=>{var m;const x=u.get((m=y==null?void 0:y.point)==null?void 0:m.x);if(!x){f.attr("opacity",0),h.attr("opacity",0);return}f.attr("cx",x.x).attr("cy",x.hi).attr("opacity",1),h.attr("cx",x.x).attr("cy",x.lo).attr("opacity",1)},d=()=>{f.attr("opacity",0),h.attr("opacity",0)};s.on("point:mouseover",g),s.on("point:mouseout",d),s.on("series:mouseleave",d),this.hoverHandlers={over:g,out:d}}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;s<t&&(t=s),s>n&&(n=s);const a=o.low,l=o.high??o.y;a!=null&&(a<i&&(i=a),a>r&&(r=a)),l!=null&&(l<i&&(i=l),l>r&&(r=l))}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class oi extends $e{getCurve(){return Qa.alpha(.5)}}class si extends J{constructor(t){super(t)}render(){var y,x;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.config.groupPadding??.2,a=this.config.pointPadding??.1,l=s+a,c=this.config.maxPointWidth??1/0,f=Math.max(1,Math.min(c,i.width/Math.max(1,o.length)*(1-l))),h=this.config.pointWidth??f,u=this.getColor(),g=this.config.borderRadius??0,d=((x=(y=this.config.states)==null?void 0:y.inactive)==null?void 0:x.opacity)??.4,p=[];for(let m=0;m<o.length;m++){const v=o[m],_=v.low,w=v.high??v.y;if(_==null||w===void 0||w===null)continue;const b=t.getPixelForValue(v.x??m),M=n.getPixelForValue(w),I=n.getPixelForValue(_),S=Math.min(M,I),A=Math.max(1,Math.abs(I-M)),F=v.color||u,C=this.group.append("rect").attr("class","katucharts-columnrange-bar").attr("x",b-h/2).attr("width",h).attr("fill",F).attr("rx",g).style("cursor",this.config.cursor||"pointer");if(r){const V=S+A/2;C.attr("y",V).attr("height",0).transition().duration(R).ease(X).delay(lt(m,0,Y,o.length)).attr("y",S).attr("height",A)}else C.attr("y",S).attr("height",A);p.push(C),this.config.enableMouseTracking!==!1&&C.on("mouseover",V=>{var N,D;C.transition("hover").duration($).ease(T).attr("opacity",.85),p.forEach((E,P)=>{P!==m&&E.interrupt("highlight"),P!==m&&E.transition("highlight").duration($).ease(T).attr("opacity",d)}),this.context.events.emit("point:mouseover",{point:v,index:m,series:this,event:V,plotX:b,plotY:M}),(D=(N=v.events)==null?void 0:N.mouseOver)==null||D.call(v,V)}).on("mouseout",V=>{var N,D;C.transition("hover").duration($).ease(T).attr("opacity",1),p.forEach(E=>{E.interrupt("highlight"),E.transition("highlight").duration($).ease(T).attr("opacity",1)}),this.context.events.emit("point:mouseout",{point:v,index:m,series:this,event:V}),(D=(N=v.events)==null?void 0:N.mouseOut)==null||D.call(v,V)}).on("click",V=>{var N,D,E,P;this.context.events.emit("point:click",{point:v,index:m,series:this,event:V}),(D=(N=v.events)==null?void 0:N.click)==null||D.call(v,V),(P=(E=this.config.events)==null?void 0:E.click)==null||P.call(this,V)})}r&&this.emitAfterAnimate(R+o.length*Y)}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;s<t&&(t=s),s>n&&(n=s);const a=o.low,l=o.high??o.y;a!=null&&(a<i&&(i=a),a>r&&(r=a)),l!=null&&(l<i&&(i=l),l>r&&(r=l))}return{xMin:t,xMax:n,yMin:i,yMax:r}}}class ai extends J{constructor(t){super(t)}render(){const{yAxis:t,plotArea:n}=this.context,i=this.context.animate,r=this.data;if(r.length===0)return;const o=Math.max(...r.map(h=>h.volume??0))||1,s=this.config.zoneWidth??.3,a=n.width*s,l=this.config.color||"rgba(120,150,200,0.45)",c=this.config.upColor,f=this.config.fillOpacity??.5;for(const h of r){const u=h.low,g=h.high,d=h.volume??0;if(u===void 0||g===void 0)continue;const p=t.getPixelForValue(g),y=t.getPixelForValue(u),x=Math.min(p,y),m=Math.max(1,Math.abs(y-p)-1),v=d/o*a,_=this.group.append("rect").attr("class","katucharts-vbp-bar").attr("x",0).attr("y",x).attr("height",m).attr("fill",c||l).attr("opacity",f);i?_.attr("width",0).transition().duration(R).ease(X).attr("width",v):_.attr("width",v),this.config.enableMouseTracking!==!1&&_.on("mouseover",w=>{this.context.events.emit("point:mouseover",{point:{x:h.x,y:h.y,low:u,high:g,volume:d},index:0,series:this,event:w,plotX:v,plotY:x})}).on("mouseout",w=>{this.context.events.emit("point:mouseout",{point:h,index:0,series:this,event:w})})}}getDataExtents(){return{xMin:1/0,xMax:-1/0,yMin:1/0,yMax:-1/0}}}class li extends J{constructor(t){super(t)}render(){var _,w,b,M,I,S;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.config.threshold??0,a=n.getPixelForValue(s),l={color:((_=this.config.topLine)==null?void 0:_.color)??"#2f7ed8",fillColor:((w=this.config.topLine)==null?void 0:w.fillColor)??"rgba(47,126,216,0.2)",fillOpacity:((b=this.config.topLine)==null?void 0:b.fillOpacity)??1},c={color:((M=this.config.bottomLine)==null?void 0:M.color)??"#f45b5b",fillColor:((I=this.config.bottomLine)==null?void 0:I.fillColor)??"rgba(244,91,91,0.2)",fillOpacity:((S=this.config.bottomLine)==null?void 0:S.fillOpacity)??1},f=this.config.lineWidth??2,h=o.filter(A=>A.y!==null&&A.y!==void 0);if(h.length===0)return;const u=(A,F)=>t.getPixelForValue(A.x??F),g=A=>n.getPixelForValue(A.y??0),d=`katucharts-baseline-top-${this.config.index}-${Date.now()}`,p=`katucharts-baseline-bottom-${this.config.index}-${Date.now()}`,y=this.group.select(function(){return this.ownerSVGElement});if(y.empty())return;let x=y.select("defs");x.empty()&&(x=y.append("defs")),x.append("clipPath").attr("id",d).append("rect").attr("x",0).attr("y",0).attr("width",i.width).attr("height",Math.max(0,a)),x.append("clipPath").attr("id",p).append("rect").attr("x",0).attr("y",a).attr("width",i.width).attr("height",Math.max(0,i.height-a));const m=Se().x((A,F)=>u(A,F)).y0(()=>a).y1(A=>g(A)).curve(Tt),v=xt().x((A,F)=>u(A,F)).y(A=>g(A)).curve(Tt);this.renderZone(h,m,v,d,l,f,"top"),this.renderZone(h,m,v,p,c,f,"bottom"),this.config.lineWidth!==0&&this.group.append("line").attr("class","katucharts-baseline-threshold").attr("x1",0).attr("x2",i.width).attr("y1",a).attr("y2",a).attr("stroke","#999").attr("stroke-width",1).attr("stroke-dasharray","4,3").attr("opacity",.6),r&&this.animateDrawIn(f)}renderZone(t,n,i,r,o,s,a){const l=this.group.append("g").attr("class",`katucharts-baseline-zone-${a}`).attr("clip-path",`url(#${r})`);l.append("path").datum(t).attr("class",`katucharts-baseline-area-${a}`).attr("d",n).attr("fill",o.fillColor).attr("fill-opacity",o.fillOpacity).attr("stroke","none"),l.append("path").datum(t).attr("class",`katucharts-baseline-line-${a}`).attr("d",i).attr("fill","none").attr("stroke",o.color).attr("stroke-width",s)}animateDrawIn(t){this.group.selectAll('[class*="katucharts-baseline-line-"]').each(function(){var o;const n=this,i=((o=n.getTotalLength)==null?void 0:o.call(n))??0;if(i===0)return;const r=zo(n);r.attr("stroke-dasharray",`${i} ${i}`).attr("stroke-dashoffset",i).transition().duration(R).ease(X).attr("stroke-dashoffset",0).on("end",()=>{r.attr("stroke-dasharray",null)})}),this.group.selectAll('[class*="katucharts-baseline-area-"]').attr("opacity",0).transition().duration(R).ease(X).attr("opacity",1),this.emitAfterAnimate(R)}getDataExtents(){let t=1/0,n=-1/0,i=1/0,r=-1/0;const o=this.config.threshold??0;for(const s of this.data){const a=s.x??0;a<t&&(t=a),a>n&&(n=a);const l=s.y??0;l<i&&(i=l),l>r&&(r=l)}return o<i&&(i=o),o>r&&(r=o),{xMin:t,xMax:n,yMin:i,yMax:r}}}const ci=30,$t=20,Fe=25,Ne=8,yt=12,Re="9px";class hi extends J{constructor(t){super(t)}render(){const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.config.shape||"flag",a=this.getColor(),l=this.resolveOnSeries();for(let c=0;c<o.length;c++){const f=o[c];if(f.x===void 0||f.x===null)continue;const h=t.getPixelForValue(f.x??c),u=this.resolveAnchorY(f,c,l,n,i),g=f.shape||s,d=f.color||this.config.color||a,p=f.title??"",y=this.group.append("g").attr("class","katucharts-flag").style("cursor",this.config.cursor||"pointer"),x=u-Fe;if(y.append("line").attr("x1",h).attr("x2",h).attr("y1",u).attr("y2",x).attr("stroke",d).attr("stroke-width",1),this.renderShape(y,g,h,x,d,p),r){const m=lt(c,0,Y,o.length);y.attr("opacity",0).transition().duration(R).ease(X).delay(m).attr("opacity",1)}this.attachFlagEvents(y,f,c,h,x)}}getDataExtents(){let t=1/0,n=-1/0;for(const i of this.data)i.x!==void 0&&i.x!==null&&(i.x<t&&(t=i.x),i.x>n&&(n=i.x));return{xMin:t,xMax:n,yMin:1/0,yMax:-1/0}}resolveOnSeries(){const t=this.config.onSeries;return this.context.allSeries?t?this.context.allSeries.find(n=>n.config.id===t)??null:this.context.allSeries.find(n=>n!==this&&n.config._internalType!=="flags")??null:null}resolveAnchorY(t,n,i,r,o){if(!i)return Fe+$t;const s=t.x??n,a=i.data;let l=null,c=1/0;for(const f of a){const h=f.x??0,u=Math.abs(h-s);u<c&&(c=u,l=f)}if(l){const f=l.high??l.y;if(f!=null)return r.getPixelForValue(f)}return Fe+$t}renderShape(t,n,i,r,o,s){switch(n){case"circlepin":t.append("circle").attr("cx",i).attr("cy",r-Ne).attr("r",Ne).attr("fill",o).attr("stroke",o).attr("stroke-width",1),s&&t.append("text").attr("x",i).attr("y",r-Ne).attr("text-anchor","middle").attr("dominant-baseline","central").attr("fill","#ffffff").attr("font-size",Re).style("pointer-events","none").text(s);break;case"squarepin":t.append("rect").attr("x",i-yt/2).attr("y",r-yt-yt/2).attr("width",yt).attr("height",yt).attr("fill",o).attr("stroke",o).attr("stroke-width",1).attr("transform",`rotate(45,${i},${r-yt})`),s&&t.append("text").attr("x",i).attr("y",r-yt).attr("text-anchor","middle").attr("dominant-baseline","central").attr("fill","#ffffff").attr("font-size",Re).style("pointer-events","none").text(s);break;case"flag":default:t.append("rect").attr("x",i).attr("y",r-$t).attr("width",ci).attr("height",$t).attr("fill",o).attr("stroke",o).attr("stroke-width",1).attr("rx",2),s&&t.append("text").attr("x",i+ci/2).attr("y",r-$t/2).attr("text-anchor","middle").attr("dominant-baseline","central").attr("fill","#ffffff").attr("font-size",Re).style("pointer-events","none").text(s);break}}attachFlagEvents(t,n,i,r,o){var l;if(this.config.enableMouseTracking===!1)return;const s=n.events||{},a=((l=this.config.point)==null?void 0:l.events)||{};t.on("mouseover",c=>{var f,h;t.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),this.context.events.emit("point:mouseover",{point:n,index:i,series:this,event:c,plotX:r,plotY:o}),(f=s.mouseOver)==null||f.call(n,c),(h=a.mouseOver)==null||h.call(n,c)}).on("mouseout",c=>{var f,h;t.style("filter",""),this.context.events.emit("point:mouseout",{point:n,index:i,series:this,event:c}),(f=s.mouseOut)==null||f.call(n,c),(h=a.mouseOut)==null||h.call(n,c)}).on("click",c=>{var f,h,u,g;this.context.events.emit("point:click",{point:n,index:i,series:this,event:c}),(f=s.click)==null||f.call(n,c),(h=a.click)==null||h.call(n,c),(g=(u=this.config.events)==null?void 0:u.click)==null||g.call(this,c)})}}class fi extends J{constructor(t){super(t),this.bricks=[]}processData(){super.processData();const t=this.config.brickSize??1,n=this.data.map(o=>o.close??o.y).filter(o=>o!=null);if(this.bricks=[],n.length<2)return;let i=Math.floor(n[0]/t)*t,r=0;for(let o=1;o<n.length;o++){const a=n[o]-i,l=Math.floor(Math.abs(a)/t);if(l>=1){const c=a>0?"up":"down";for(let f=0;f<l;f++){const h=c==="up"?i+f*t:i-(f+1)*t;this.bricks.push({index:r++,direction:c,bottom:h,top:h+t})}i+=(c==="up"?1:-1)*l*t}}}render(){var h,u;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.bricks;if(o.length===0)return;const s=this.config.upColor||"#2f7ed8",a=this.config.downColor||this.config.color||"#f45b5b",l=((u=(h=this.config.states)==null?void 0:h.inactive)==null?void 0:u.opacity)??.4,c=Math.max(1,i.width/Math.max(1,o.length)*.8),f=[];for(let g=0;g<o.length;g++){const d=o[g],p=t.getPixelForValue(d.index),y=n.getPixelForValue(d.top),x=n.getPixelForValue(d.bottom),m=Math.max(1,Math.abs(x-y)),v=d.direction==="up"?s:a,_=this.group.append("rect").attr("class","katucharts-renko-brick").attr("x",p-c/2).attr("y",Math.min(y,x)).attr("width",c).attr("height",m).attr("fill",v).attr("stroke",v).attr("stroke-width",.5).style("cursor",this.config.cursor||"pointer");f.push(_),r&&_.attr("opacity",0).transition().duration(R).ease(X).delay(lt(g,0,Y,o.length)).attr("opacity",1),this.config.enableMouseTracking!==!1&&_.on("mouseover",w=>{_.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),f.forEach((b,M)=>{M!==g&&b.transition("highlight").duration($).ease(T).attr("opacity",l)}),this.context.events.emit("point:mouseover",{point:{x:d.index,y:d.top,low:d.bottom,high:d.top,direction:d.direction},index:g,series:this,event:w,plotX:p,plotY:y})}).on("mouseout",w=>{_.style("filter",""),f.forEach(b=>b.interrupt("highlight")),f.forEach(b=>b.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:{x:d.index,y:d.top},index:g,series:this,event:w})}).on("click",w=>{var b,M;this.context.events.emit("point:click",{point:{x:d.index,y:d.top,direction:d.direction},index:g,series:this,event:w}),(M=(b=this.config.events)==null?void 0:b.click)==null||M.call(this,w)})}r&&this.emitAfterAnimate(R+o.length*Y)}getDataExtents(){if(this.bricks.length===0&&this.processData(),this.bricks.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};let t=1/0,n=-1/0;for(const i of this.bricks)i.bottom<t&&(t=i.bottom),i.top>n&&(n=i.top);return{xMin:0,xMax:this.bricks.length-1,yMin:t,yMax:n}}}class ui extends J{constructor(t){super(t),this.segments=[]}processData(){super.processData();const t=this.data.map(u=>u.close??u.y).filter(u=>u!=null);if(this.segments=[],t.length<2)return;const n=Math.max(...t)-Math.min(...t),i=this.config.reversalAmount??n*.04;let r=t[1]>=t[0]?"up":"down",o=t[0],s=t[1],a=0;const l=[],c=[];let f="yin";const h=(u,g)=>{if(r==="up"){const d=l.length>0?l[l.length-1]:-1/0;g>d&&(f="yang"),l.push(g)}else{const d=c.length>0?c[c.length-1]:1/0;g<d&&(f="yin"),c.push(g)}this.segments.push({x:a++,startPrice:u,endPrice:g,type:f})};for(let u=2;u<t.length;u++){const g=t[u];r==="up"?g>s?s=g:s-g>=i&&(h(o,s),o=s,s=g,r="down"):g<s?s=g:g-s>=i&&(h(o,s),o=s,s=g,r="up")}h(o,s)}render(){var u,g;const{xAxis:t,yAxis:n}=this.context,i=this.context.animate,r=this.segments;if(r.length===0)return;const o=this.config.upColor||"#2f7ed8",s=this.config.downColor||this.config.color||"#f45b5b";for(let d=0;d<r.length;d++){const p=r[d];t.getPixelForValue(p.x),n.getPixelForValue(p.startPrice),n.getPixelForValue(p.endPrice)}const a=[];let l="",c=r[0].type,f=null,h=null;for(let d=0;d<r.length;d++){const p=r[d],y=t.getPixelForValue(p.x),x=n.getPixelForValue(p.startPrice),m=n.getPixelForValue(p.endPrice);p.type!==c&&l&&(a.push({d:l,type:c}),l=`M${f},${h}L${y},${h}`,c=p.type),l?f!==null&&(l+=`L${y},${h}`):l=`M${y},${x}`,l+=`L${y},${m}`,f=y,h=m}l&&a.push({d:l,type:c});for(const d of a){const p=d.type==="yang"?o:s,y=d.type==="yang"?3:1,x=this.group.append("path").attr("class",`katucharts-kagi-${d.type}`).attr("d",d.d).attr("fill","none").attr("stroke",p).attr("stroke-width",y).attr("stroke-linejoin","miter");if(i){const m=((g=(u=x.node()).getTotalLength)==null?void 0:g.call(u))||0;m>0&&x.attr("stroke-dasharray",`${m} ${m}`).attr("stroke-dashoffset",m).transition().duration(R).ease(X).attr("stroke-dashoffset",0).on("end",()=>{x.attr("stroke-dasharray",null)})}}if(this.config.enableMouseTracking!==!1)for(let d=0;d<r.length;d++){const p=r[d],y=t.getPixelForValue(p.x),x=n.getPixelForValue(p.startPrice),m=n.getPixelForValue(p.endPrice),v=Math.abs(m-x);this.group.append("rect").attr("class","katucharts-kagi-hitarea").attr("x",y-8).attr("y",Math.min(x,m)).attr("width",16).attr("height",Math.max(v,4)).attr("fill","transparent").style("cursor",this.config.cursor||"pointer").on("mouseover",_=>{const w=`katucharts-kagi-${p.type}`,b=p.type==="yang"?3:1;this.group.selectAll(`path.${w}`).interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",b+1.5);const M=p.type==="yang"?"katucharts-kagi-yin":"katucharts-kagi-yang";this.group.selectAll(`path.${M}`).interrupt("hover").transition("hover").duration(be).ease(T).attr("opacity",.3),this.context.events.emit("point:mouseover",{point:{x:p.x,y:p.endPrice,open:p.startPrice,close:p.endPrice,type:p.type},index:d,series:this,event:_,plotX:y,plotY:m})}).on("mouseout",_=>{this.group.selectAll("path.katucharts-kagi-yang").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",3).attr("opacity",1),this.group.selectAll("path.katucharts-kagi-yin").interrupt("hover").transition("hover").duration($).ease(T).attr("stroke-width",1).attr("opacity",1),this.context.events.emit("point:mouseout",{point:{x:p.x,y:p.endPrice},index:d,series:this,event:_})}).on("click",_=>{var w,b;this.context.events.emit("point:click",{point:{x:p.x,y:p.endPrice,type:p.type},index:d,series:this,event:_}),(b=(w=this.config.events)==null?void 0:w.click)==null||b.call(this,_)})}i&&this.emitAfterAnimate(R)}getDataExtents(){if(this.segments.length===0&&this.processData(),this.segments.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};let t=1/0,n=-1/0;for(const i of this.segments){const r=Math.min(i.startPrice,i.endPrice),o=Math.max(i.startPrice,i.endPrice);r<t&&(t=r),o>n&&(n=o)}return{xMin:0,xMax:this.segments.length-1,yMin:t,yMax:n}}}class di extends J{constructor(t){super(t),this.columns=[]}processData(){super.processData();const t=this.config.boxSize??1,i=(this.config.reversalAmount??3)*t,r=this.data.map(u=>u.close??u.y).filter(u=>u!=null);if(this.columns=[],r.length<2)return;const o=u=>Math.floor(u/t)*t;let s=r[1]>=r[0]?"X":"O",a=o(r[0])+t,l=o(r[0]),c=0;const f=(u,g)=>{const d=[];for(let p=u;p<g;p+=t)d.push(p);return d},h=()=>{this.columns.push({index:c++,direction:s,startPrice:s==="X"?l:a,endPrice:s==="X"?a:l,boxes:f(l,a)})};for(let u=1;u<r.length;u++){const g=r[u],d=o(g);s==="X"?d+t>a?a=d+t:a-d>=i&&(h(),s="O",a=a-t,l=d):d<l?l=d:d-l>=i&&(h(),s="X",l=l+t,a=d+t)}h()}render(){var g,d;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.columns;if(o.length===0)return;const s=this.config.boxSize??1,a=this.config.upColor||"#2f7ed8",l=this.config.downColor||this.config.color||"#f45b5b",c=((d=(g=this.config.states)==null?void 0:g.inactive)==null?void 0:d.opacity)??.4,f=Math.max(8,Math.min(16,i.width/Math.max(1,o.length)*.6)),h=[];let u=0;for(let p=0;p<o.length;p++){const y=o[p],x=y.direction==="X"?a:l,m=y.direction==="X"?"X":"O",v=this.group.append("g").attr("class",`katucharts-pnf-column katucharts-pnf-${y.direction}`).style("cursor",this.config.cursor||"pointer");h.push(v);for(const _ of y.boxes){const w=t.getPixelForValue(y.index),b=n.getPixelForValue(_+s/2),M=v.append("text").attr("x",w).attr("y",b).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",`${f}px`).attr("font-weight","bold").attr("fill",x).style("pointer-events","none").text(m);r&&(M.attr("opacity",0).transition().duration(R).ease(X).delay(lt(u,0,Y,this.getTotalBoxCount())).attr("opacity",1),u++)}if(this.config.enableMouseTracking!==!1){const _=t.getPixelForValue(y.index),w=n.getPixelForValue(Math.max(y.startPrice,y.endPrice)),b=n.getPixelForValue(Math.min(y.startPrice,y.endPrice)),M=Math.max(f*1.5,20),I=Math.max(Math.abs(b-w),4);v.append("rect").attr("x",_-M/2).attr("y",Math.min(w,b)).attr("width",M).attr("height",I).attr("fill","transparent").style("cursor",this.config.cursor||"pointer").on("mouseover",S=>{v.selectAll("text").interrupt("hover").transition("hover").duration($).ease(T).attr("font-size",`${f*1.2}px`),h.forEach((A,F)=>{F!==p&&A.transition("highlight").duration($).ease(T).attr("opacity",c)}),this.context.events.emit("point:mouseover",{point:{x:y.index,y:y.endPrice,direction:y.direction,startPrice:y.startPrice,endPrice:y.endPrice,boxCount:y.boxes.length},index:p,series:this,event:S,plotX:_,plotY:w})}).on("mouseout",S=>{v.selectAll("text").interrupt("hover").transition("hover").duration($).ease(T).attr("font-size",`${f}px`),h.forEach(A=>A.interrupt("highlight")),h.forEach(A=>A.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:{x:y.index,y:y.endPrice},index:p,series:this,event:S})}).on("click",S=>{var A,F;this.context.events.emit("point:click",{point:{x:y.index,y:y.endPrice,direction:y.direction},index:p,series:this,event:S}),(F=(A=this.config.events)==null?void 0:A.click)==null||F.call(this,S)})}}if(r){const p=this.getTotalBoxCount();this.emitAfterAnimate(R+p*Y)}}getTotalBoxCount(){return this.columns.reduce((t,n)=>t+n.boxes.length,0)}getDataExtents(){if(this.columns.length===0&&this.processData(),this.columns.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};const t=this.config.boxSize??1;let n=1/0,i=-1/0;for(const r of this.columns)for(const o of r.boxes)o<n&&(n=o),o+t>i&&(i=o+t);return{xMin:0,xMax:this.columns.length-1,yMin:n,yMax:i}}}class gi extends J{constructor(t){super(t),this.blocks=[]}processData(){super.processData();const t=this.config.lineBreakCount??3,n=this.data.map(r=>r.close??r.y).filter(r=>r!=null);if(this.blocks=[],n.length<2)return;const i={index:0,open:n[0],close:n[1],direction:n[1]>=n[0]?"up":"down"};this.blocks.push(i);for(let r=2;r<n.length;r++){const o=n[r],s=this.blocks.slice(-t),a=this.blocks[this.blocks.length-1];let l=-1/0,c=1/0;for(const f of s){const h=Math.max(f.open,f.close),u=Math.min(f.open,f.close);h>l&&(l=h),u<c&&(c=u)}o>l?this.blocks.push({index:this.blocks.length,open:a.close,close:o,direction:"up"}):o<c&&this.blocks.push({index:this.blocks.length,open:a.close,close:o,direction:"down"})}}render(){var h,u;const{xAxis:t,yAxis:n,plotArea:i}=this.context,r=this.context.animate,o=this.blocks;if(o.length===0)return;const s=this.config.upColor||"#2f7ed8",a=this.config.downColor||this.config.color||"#f45b5b",l=((u=(h=this.config.states)==null?void 0:h.inactive)==null?void 0:u.opacity)??.4,c=Math.max(1,i.width/Math.max(1,o.length)*.8),f=[];for(let g=0;g<o.length;g++){const d=o[g],p=t.getPixelForValue(d.index),y=n.getPixelForValue(d.open),x=n.getPixelForValue(d.close),m=Math.min(y,x),v=Math.max(1,Math.abs(y-x)),_=d.direction==="up"?s:a,w=m+v/2,b=this.group.append("rect").attr("class","katucharts-linebreak-block").attr("x",p-c/2).attr("width",c).attr("fill",_).attr("stroke",_).attr("stroke-width",.5).style("cursor",this.config.cursor||"pointer");f.push(b),r?b.attr("y",w).attr("height",0).transition().duration(R).ease(X).delay(lt(g,0,Y,o.length)).attr("y",m).attr("height",v):b.attr("y",m).attr("height",v),this.config.enableMouseTracking!==!1&&b.on("mouseover",M=>{b.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),f.forEach((I,S)=>{S!==g&&I.transition("highlight").duration($).ease(T).attr("opacity",l)}),this.context.events.emit("point:mouseover",{point:{x:d.index,y:d.close,open:d.open,close:d.close,direction:d.direction},index:g,series:this,event:M,plotX:p,plotY:x})}).on("mouseout",M=>{b.style("filter",""),f.forEach(I=>I.interrupt("highlight")),f.forEach(I=>I.transition("highlight").duration($).ease(T).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:{x:d.index,y:d.close},index:g,series:this,event:M})}).on("click",M=>{var I,S;this.context.events.emit("point:click",{point:{x:d.index,y:d.close,direction:d.direction},index:g,series:this,event:M}),(S=(I=this.config.events)==null?void 0:I.click)==null||S.call(this,M)})}r&&this.emitAfterAnimate(R+o.length*Y)}getDataExtents(){if(this.blocks.length===0&&this.processData(),this.blocks.length===0)return{xMin:0,xMax:0,yMin:0,yMax:0};let t=1/0,n=-1/0;for(const i of this.blocks){const r=Math.min(i.open,i.close),o=Math.max(i.open,i.close);r<t&&(t=r),o>n&&(n=o)}return{xMin:0,xMax:this.blocks.length-1,yMin:t,yMax:n}}}function pi(){q.registerType("heikinashi",Xn),q.registerType("hollowcandlestick",Un),q.registerType("volume",Gn),q.registerType("arearange",$e),q.registerType("areasplinerange",oi),q.registerType("columnrange",si),q.registerType("vbp",ai),q.registerType("baseline",li),q.registerType("flags",hi),q.registerType("renko",fi),q.registerType("kagi",ui),q.registerType("pointandfigure",di),q.registerType("linebreak",gi)}class H{}class rl{constructor(){this.indicators=new Map}register(t){this.indicators.set(t.name.toLowerCase(),t)}get(t){return this.indicators.get(t.toLowerCase())}getAll(){return new Map(this.indicators)}}const xi=globalThis,z=xi.__katuIndicatorRegistry||(xi.__katuIndicatorRegistry=new rl);class yi extends H{constructor(){super(...arguments),this.name="sma"}calculate(t,n){const i=n.period??14,r=new Array(t.length);let o=0;for(let s=0;s<t.length;s++)o+=t[s].close,s>=i&&(o-=t[s-i].close),s<i-1?r[s]={x:t[s].x,y:null}:r[s]={x:t[s].x,y:o/i};return{values:r}}}const mi=new yi;z.register(mi);class _i extends H{constructor(){super(...arguments),this.name="ema"}calculate(t,n){const i=n.period??14,r=2/(i+1),o=new Array(t.length);let s=0,a=0;for(let l=0;l<t.length;l++)l<i-1?(a+=t[l].close,o[l]={x:t[l].x,y:null}):l===i-1?(a+=t[l].close,s=a/i,o[l]={x:t[l].x,y:s}):(s=t[l].close*r+s*(1-r),o[l]={x:t[l].x,y:s});return{values:o}}}const wi=new _i;z.register(wi);class vi extends H{constructor(){super(...arguments),this.name="wma"}calculate(t,n){const i=n.period??14,r=i*(i+1)/2,o=new Array(t.length);for(let s=0;s<t.length;s++){if(s<i-1){o[s]={x:t[s].x,y:null};continue}let a=0;for(let l=0;l<i;l++)a+=t[s-i+1+l].close*(l+1);o[s]={x:t[s].x,y:a/r}}return{values:o}}}const bi=new vi;z.register(bi);function Ft(e,t){const n=2/(t+1),i=new Array(e.length).fill(null);let r=null,o=0,s=0;for(let a=0;a<e.length;a++){const l=e[a];l!=null&&(r===null?(o+=l,s++,s===t&&(r=o/t,i[a]=r)):(r=l*n+r*(1-n),i[a]=r))}return i}class ki extends H{constructor(){super(...arguments),this.name="dema"}calculate(t,n){const i=n.period??14,r=t.map(l=>l.close),o=Ft(r,i),s=Ft(o,i);return{values:t.map((l,c)=>{const f=o[c],h=s[c];return{x:l.x,y:f!==null&&h!==null?2*f-h:null}})}}}const Mi=new ki;z.register(Mi);class Ai extends H{constructor(){super(...arguments),this.name="tema"}calculate(t,n){const i=n.period??14,r=t.map(c=>c.close),o=Ft(r,i),s=Ft(o,i),a=Ft(s,i);return{values:t.map((c,f)=>{const h=o[f],u=s[f],g=a[f];return{x:c.x,y:h!==null&&u!==null&&g!==null?3*h-3*u+g:null}})}}}const Ci=new Ai;z.register(Ci);class Pi extends H{constructor(){super(...arguments),this.name="rsi"}calculate(t,n){const i=n.period??14,r=new Array(t.length);for(let l=0;l<i;l++)r[l]={x:t[l].x,y:null};let o=0,s=0;for(let l=1;l<=i;l++){const c=t[l].close-t[l-1].close;o+=Math.max(0,c),s+=Math.max(0,-c)}o/=i,s/=i;const a=s===0?1/0:o/s;r[i]={x:t[i].x,y:s===0?100:100-100/(1+a)};for(let l=i+1;l<t.length;l++){const c=t[l].close-t[l-1].close,f=Math.max(0,c),h=Math.max(0,-c);o=(o*(i-1)+f)/i,s=(s*(i-1)+h)/i;const u=s===0?100:100-100/(1+o/s);r[l]={x:t[l].x,y:u}}return{values:r}}}const Si=new Pi;z.register(Si);class Ei extends H{constructor(){super(...arguments),this.name="stochastic"}calculate(t,n){const i=n.kPeriod??14,r=n.dPeriod??3,o=n.smoothK??3,s=this.computeRawK(t,i),a=this.sma(s,o),l=this.sma(a,r),c=new Array(t.length),f=new Array(t.length);for(let h=0;h<t.length;h++)c[h]={x:t[h].x,y:a[h]},f[h]={x:t[h].x,y:l[h]};return{values:c,signal:f}}computeRawK(t,n){const i=new Array(t.length);for(let r=0;r<t.length;r++){if(r<n-1){i[r]=null;continue}let o=1/0,s=-1/0;for(let l=r-n+1;l<=r;l++)t[l].low<o&&(o=t[l].low),t[l].high>s&&(s=t[l].high);const a=s-o;i[r]=a===0?50:100*(t[r].close-o)/a}return i}sma(t,n){const i=new Array(t.length).fill(null),r=[];for(let o=0;o<t.length;o++)if(t[o]!==null&&r.push(o),r.length>=n){let s=0;for(let a=r.length-n;a<r.length;a++)s+=t[r[a]];i[o]=s/n}return i}}const Ii=new Ei;z.register(Ii);class Ti extends H{constructor(){super(...arguments),this.name="macd"}calculate(t,n){const i=n.fastPeriod??12,r=n.slowPeriod??26,o=n.signalPeriod??9,s=t.map(y=>y.close),a=this.ema(s,i),l=this.ema(s,r),c=new Array(t.length);for(let y=0;y<t.length;y++)a[y]===null||l[y]===null?c[y]=null:c[y]=a[y]-l[y];const f=this.extractNonNull(c),h=this.ema(f.values,o),u=new Array(t.length),g=new Array(t.length),d=new Array(t.length);let p=0;for(let y=0;y<t.length;y++){const x=t[y].x;if(c[y]===null)u[y]={x,y:null},g[y]={x,y:null},d[y]={x,y:null};else{const m=c[y],v=h[p];u[y]={x,y:m},g[y]={x,y:v},d[y]={x,y:v===null?null:m-v},p++}}return{values:u,signal:g,histogram:d}}ema(t,n){const i=new Array(t.length).fill(null);if(t.length<n)return i;let r=0;for(let s=0;s<n;s++)r+=t[s];const o=2/(n+1);i[n-1]=r/n;for(let s=n;s<t.length;s++)i[s]=t[s]*o+i[s-1]*(1-o);return i}extractNonNull(t){const n=[],i=[];for(let r=0;r<t.length;r++)t[r]!==null&&(n.push(t[r]),i.push(r));return{values:n,indices:i}}}const $i=new Ti;z.register($i);class Fi extends H{constructor(){super(...arguments),this.name="cci"}calculate(t,n){const i=n.period??20,r=t.map(s=>(s.high+s.low+s.close)/3),o=new Array(t.length);for(let s=0;s<t.length;s++){if(s<i-1){o[s]={x:t[s].x,y:null};continue}let a=0;for(let h=s-i+1;h<=s;h++)a+=r[h];const l=a/i;let c=0;for(let h=s-i+1;h<=s;h++)c+=Math.abs(r[h]-l);const f=c/i;o[s]={x:t[s].x,y:f===0?0:(r[s]-l)/(.015*f)}}return{values:o}}}const Ni=new Fi;z.register(Ni);class Ri extends H{constructor(){super(...arguments),this.name="roc"}calculate(t,n){const i=n.period??9;return{values:t.map((o,s)=>{if(s<i)return{x:o.x,y:null};const a=t[s-i].close;return{x:o.x,y:a===0?0:(o.close-a)/a*100}})}}}const Vi=new Ri;z.register(Vi);class Di extends H{constructor(){super(...arguments),this.name="momentum"}calculate(t,n){const i=n.period??14;return{values:t.map((o,s)=>s<i?{x:o.x,y:null}:{x:o.x,y:o.close-t[s-i].close})}}}const Li=new Di;z.register(Li);class Oi extends H{constructor(){super(...arguments),this.name="bollingerbands"}calculate(t,n){const i=n.period??20,r=n.stdDev??2,o=new Array(t.length),s=new Array(t.length),a=new Array(t.length),l=new Array(t.length);for(let c=0;c<t.length;c++){const f=t[c].x;if(c<i-1){o[c]={x:f,y:null},s[c]={x:f,y:null},a[c]={x:f,y:null},l[c]={x:f,y:null};continue}let h=0;for(let x=c-i+1;x<=c;x++)h+=t[x].close;const u=h/i;let g=0;for(let x=c-i+1;x<=c;x++){const m=t[x].close-u;g+=m*m}const d=Math.sqrt(g/i),p=u+r*d,y=u-r*d;o[c]={x:f,y:u},s[c]={x:f,y:p},a[c]={x:f,y:u},l[c]={x:f,y}}return{values:o,bands:{upper:s,middle:a,lower:l}}}}const Bi=new Oi;z.register(Bi);class Hi extends H{constructor(){super(...arguments),this.name="atr"}calculate(t,n){const i=n.period??14,r=new Array(t.length);r[0]={x:t[0].x,y:null};const o=new Array(t.length);o[0]=t[0].high-t[0].low;for(let a=1;a<t.length;a++){const l=t[a].high,c=t[a].low,f=t[a-1].close;o[a]=Math.max(l-c,Math.abs(l-f),Math.abs(c-f))}for(let a=1;a<i;a++)r[a]={x:t[a].x,y:null};let s=0;for(let a=0;a<i;a++)s+=o[a];s/=i,r[i-1]={x:t[i-1].x,y:s};for(let a=i;a<t.length;a++)s=(s*(i-1)+o[a])/i,r[a]={x:t[a].x,y:s};return{values:r}}}const zi=new Hi;z.register(zi);class Wi extends H{constructor(){super(...arguments),this.name="vwap"}calculate(t,n){const i=new Array(t.length);let r=0,o=0,s=null;for(let a=0;a<t.length;a++){const l=t[a],c=l.volume??0;if(c>0){const f=(l.high+l.low+l.close)/3;r+=f*c,o+=c,s=r/o}i[a]={x:l.x,y:s}}return{values:i}}}const Xi=new Wi;z.register(Xi);class Ui extends H{constructor(){super(...arguments),this.name="obv"}calculate(t,n){const i=new Array(t.length);if(t.length===0)return{values:[]};let r=0;i[0]={x:t[0].x,y:r};for(let o=1;o<t.length;o++){const s=t[o].volume??0;t[o].close>t[o-1].close?r+=s:t[o].close<t[o-1].close&&(r-=s),i[o]={x:t[o].x,y:r}}return{values:i}}}const Gi=new Ui;z.register(Gi);class Yi extends H{constructor(){super(...arguments),this.name="vbp"}calculate(t,n){const i=Math.max(1,n.ranges??12);if(t.length===0)return{values:[]};let r=1/0,o=-1/0;for(const f of t)r=Math.min(r,f.low??f.close),o=Math.max(o,f.high??f.close);const s=(o-r)/i||1,a=new Array(i).fill(0),l=new Array(i).fill(0);for(const f of t){let h=Math.floor((f.close-r)/s);h<0&&(h=0),h>=i&&(h=i-1);const u=f.volume??0;a[h]+=u,f.close>=f.open&&(l[h]+=u)}return{values:a.map((f,h)=>({x:h,y:r+(h+.5)*s,low:r+h*s,high:r+(h+1)*s,volume:f,volumeUp:l[h]}))}}}const qi=new Yi;z.register(qi);class Ki extends H{constructor(){super(...arguments),this.name="ichimoku"}calculate(t,n){const i=n.tenkanPeriod??9,r=n.kijunPeriod??26,o=n.senkouBPeriod??52,s=n.displacement??26,a=t.length;if(a===0)return{values:[],signal:[],bands:{upper:[],lower:[],middle:[]}};const l=new Array(a),c=new Array(a),f=new Array(a);for(let m=0;m<a;m++)l[m]=m>=i-1?this.midpoint(t,m-i+1,i):null,c[m]=m>=r-1?this.midpoint(t,m-r+1,r):null,f[m]=m>=o-1?this.midpoint(t,m-o+1,o):null;const h=a>1?(t[a-1].x-t[0].x)/(a-1):0,u=new Array(a),g=new Array(a);for(let m=0;m<a;m++)u[m]={x:t[m].x,y:l[m]},g[m]={x:t[m].x,y:c[m]};const d=a+s,p=new Array(d),y=new Array(d);for(let m=0;m<d;m++){const v=m-s,_=v>=0&&v<a?t[v].x+s*h:t[0].x+m*h;let w=null;v>=0&&v<a&&l[v]!==null&&c[v]!==null&&(w=(l[v]+c[v])/2);let b=null;v>=0&&v<a&&(b=f[v]),p[m]={x:_,y:w},y[m]={x:_,y:b}}const x=new Array(a);for(let m=0;m<a;m++){const v=t[m].x-s*h;x[m]={x:v,y:t[m].close}}return{values:u,signal:g,bands:{upper:p,lower:y,middle:x}}}midpoint(t,n,i){let r=-1/0,o=1/0;const s=n+i;for(let a=n;a<s;a++)t[a].high>r&&(r=t[a].high),t[a].low<o&&(o=t[a].low);return(r+o)/2}}const Zi=new Ki;z.register(Zi);class Ji extends H{constructor(){super(...arguments),this.name="adx"}calculate(t,n){const i=n.period??14,r=t.length,o=t.map(x=>({x:x.x,y:null}));if(r<i*2)return{values:o};const s=new Array(r).fill(0),a=new Array(r).fill(0),l=new Array(r).fill(0);for(let x=1;x<r;x++){const m=t[x].high-t[x-1].high,v=t[x-1].low-t[x].low;s[x]=m>v&&m>0?m:0,a[x]=v>m&&v>0?v:0,l[x]=Math.max(t[x].high-t[x].low,Math.abs(t[x].high-t[x-1].close),Math.abs(t[x].low-t[x-1].close))}let c=0,f=0,h=0;for(let x=1;x<=i;x++)c+=s[x],f+=a[x],h+=l[x];const u=new Array(r).fill(NaN),g=x=>{const m=h===0?0:100*c/h,v=h===0?0:100*f/h,_=m+v;u[x]=_===0?0:100*Math.abs(m-v)/_};g(i);for(let x=i+1;x<r;x++)c=c-c/i+s[x],f=f-f/i+a[x],h=h-h/i+l[x],g(x);let d=0;const p=i*2-1;let y=0;for(let x=i;x<=p;x++)y+=u[x];d=y/i,o[p]={x:t[p].x,y:d};for(let x=p+1;x<r;x++)d=(d*(i-1)+u[x])/i,o[x]={x:t[x].x,y:d};return{values:o}}}const Qi=new Ji;z.register(Qi);class ji extends H{constructor(){super(...arguments),this.name="psar"}calculate(t,n){const i=n.increment??.02,r=n.maximum??.2,o=t.length,s=t.map(h=>({x:h.x,y:null}));if(o<2)return{values:s};let a=t[1].close>=t[0].close,l=a?t[0].low:t[0].high,c=a?t[0].high:t[0].low,f=i;s[0]={x:t[0].x,y:l};for(let h=1;h<o;h++){let u=l+f*(c-l);a?(u=Math.min(u,t[h-1].low,h>=2?t[h-2].low:t[h-1].low),t[h].low<u?(a=!1,u=c,c=t[h].low,f=i):t[h].high>c&&(c=t[h].high,f=Math.min(f+i,r))):(u=Math.max(u,t[h-1].high,h>=2?t[h-2].high:t[h-1].high),t[h].high>u?(a=!0,u=c,c=t[h].high,f=i):t[h].low<c&&(c=t[h].low,f=Math.min(f+i,r))),l=u,s[h]={x:t[h].x,y:l}}return{values:s}}}const tr=new ji;z.register(tr);class ol{static fromWebSocket(t,n,i,r){const o=(r==null?void 0:r.shift)??!1,s=a=>{let l;try{l=JSON.parse(a.data)}catch{return}const c=i(l);if(Array.isArray(c))if(n.addPoints)n.addPoints(c,!0,o);else{for(const f of c)n.addPoint(f,!1,o);n.addPoint(c[c.length-1],!0,o)}else n.addPoint(c,!0,o)};return t.addEventListener("message",s),{unsubscribe:()=>t.removeEventListener("message",s)}}static fromEventSource(t,n,i,r,o){const s=(o==null?void 0:o.shift)??!1,a=l=>{const c=r(l.data);n.addPoint(c,!0,s)};return t.addEventListener(i,a),{unsubscribe:()=>t.removeEventListener(i,a)}}static fromPolling(t,n,i,r){const o=(r==null?void 0:r.shift)??!1;let s=!0;const a=async()=>{if(s){try{const l=await t();if(!s)return;if(Array.isArray(l))if(n.addPoints)n.addPoints(l,!0,o);else for(const c of l)n.addPoint(c,!0,o);else n.addPoint(l,!0,o)}catch{}s&&setTimeout(a,i)}};return setTimeout(a,i),{unsubscribe:()=>{s=!1}}}}class sl{constructor(t){this.head=0,this._size=0,this.capacity=t,this.buffer=new Array(t)}push(t){const n=this._size===this.capacity?this.buffer[this.head]:void 0,i=(this.head+this._size)%this.capacity;return this.buffer[i]=t,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity,n}pushMany(t){const n=[];for(const i of t){const r=this.push(i);r!==void 0&&n.push(r)}return n}get size(){return this._size}get isFull(){return this._size===this.capacity}get(t){if(!(t<0||t>=this._size))return this.buffer[(this.head+t)%this.capacity]}toArray(){const t=new Array(this._size);for(let n=0;n<this._size;n++)t[n]=this.buffer[(this.head+n)%this.capacity];return t}clear(){this.head=0,this._size=0}}class er{constructor(){this.entries=[]}add(t,n){if(t==="setData"){this.entries=[{type:t,payload:n}];return}this.entries.push({type:t,payload:n})}get isEmpty(){return this.entries.length===0}}class al{constructor(t,n){this.pendingUpdates=new Map,this.rafId=null,this.lastFrameTime=0,this.maxFps=t.maxFps??30,this.flushCallback=n}schedule(t,n,i){let r=this.pendingUpdates.get(t);r||(r=new er,this.pendingUpdates.set(t,r)),r.add(n,i),this.requestFrame()}requestFrame(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const t=performance.now(),n=1e3/this.maxFps;if(t-this.lastFrameTime<n){this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.lastFrameTime=performance.now(),this.flush()});return}this.lastFrameTime=t,this.flush()}))}flush(){if(this.pendingUpdates.size!==0){for(const[t,n]of this.pendingUpdates)n.isEmpty||t.applyBatch(n);this.pendingUpdates.clear(),this.flushCallback()}}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingUpdates.clear()}get hasPending(){return this.pendingUpdates.size>0}}pi(),k.ADX=Qi,k.ADXIndicator=Ji,k.ATR=zi,k.ATRIndicator=Hi,k.AreaRangeChart=$e,k.AreaSplineRangeChart=oi,k.BaselineChart=li,k.BollingerBands=Bi,k.BollingerBandsIndicator=Oi,k.CCI=Ni,k.CCIIndicator=Fi,k.CandlestickChart=Ae,k.CircularBuffer=sl,k.ColumnRangeChart=si,k.DEMA=Mi,k.DEMAIndicator=ki,k.EMA=wi,k.EMAIndicator=_i,k.FlagsChart=hi,k.HeikinAshiChart=Xn,k.HollowCandlestickChart=Un,k.IchimokuCloud=Zi,k.IchimokuCloudIndicator=Ki,k.Indicator=H,k.IndicatorRegistry=z,k.KagiChart=ui,k.LineBreakChart=gi,k.MACD=$i,k.MACDIndicator=Ti,k.Momentum=Li,k.MomentumIndicator=Di,k.OBV=Gi,k.OBVIndicator=Ui,k.OHLCChart=Ya,k.PSAR=tr,k.PSARIndicator=ji,k.PointAndFigureChart=di,k.ROC=Vi,k.ROCIndicator=Ri,k.RSI=Si,k.RSIIndicator=Pi,k.RenkoChart=fi,k.SMA=mi,k.SMAIndicator=yi,k.Stochastic=Ii,k.StochasticIndicator=Ei,k.StreamAdapter=ol,k.TEMA=Ci,k.TEMAIndicator=Ai,k.UpdateBatch=er,k.UpdateScheduler=al,k.VBP=qi,k.VBPChart=ai,k.VBPIndicator=Yi,k.VWAP=Xi,k.VWAPIndicator=Wi,k.VolumeChart=Gn,k.WMA=bi,k.WMAIndicator=vi,k.registerFinanceSeriesTypes=pi,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|