"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[3566,24377,5152],{150335:(t,i)=>{function s(t){return Math.round(1e10*t)/1e10}Object.defineProperty(i,"__esModule",{value:!0}),i.alignTo=i.fixComputationError=i.isNaN=i.isInteger=i.isNumber=void 0,i.isNumber=function(t){return"number"==typeof t&&isFinite(t)},i.isInteger=function(t){return"number"==typeof t&&t%1==0},i.isNaN=function(t){return!(t<=0||t>0)},i.fixComputationError=s,i.alignTo=function(t,i){var e=t/i,h=Math.floor(e),n=e-h;return n>2e-10?s(n>.5?(h+1)*i:h*i):t}},130551:(t,i)=>{i.hasProperty=i.isObject=void 0,i.isObject=function(t){var i=typeof t;return null!==t&&("object"===i||"function"===i)},i.hasProperty=function(t,i){return i in t}},724377:(t,i,s)=>{var e=s(150335);function h(t,i,s){return e.isNaN(i)||is?s:Math.round(i)}function n(t,i,s){return e.isNaN(i)||is?s:Math.round(1e4*i)/1e4}function r(t){return h(0,t,255)}function o(t){return h(0,t,255)}function l(t){return h(0,t,255)}function a(t){return n(0,t,1)}function u(t){return n(0,t,1)}function c(t){return n(0,t,1)}function d(t){return n(0,t,1)}function f(t){return n(0,t,1)}function p(t){return n(0,t,1)}function m(t){var i=t[0]/255,s=t[1]/255,e=t[2]/255,h=Math.min(i,s,e),n=Math.max(i,s,e),r=0,o=0,l=(h+n)/2;if(h===n)r=0,o=0;else{var a=n-h;switch(o=l>.5?a/(2-n-h):a/(n+h),n){case i:r=((s-e)/a+(s1&&(s-=1),s<1/6?t+6*(i-t)*s:s<.5?i:s<2/3?t+(i-t)*(2/3-s)*6:t}function v(t){var i,s,e,h=t[0],n=t[1],a=t[2];if(0===n)i=s=e=a;else{var u=a<.5?a*(1+n):a+n-a*n,c=2*a-u;i=g(c,u,h+1/3),s=g(c,u,h),e=g(c,u,h-1/3)}return[r(255*i),o(255*s),l(255*e)]}i.normalizeAlphaComponent=a,i.rgba=function(t,i,s,e){if(Array.isArray(t)){var h=t;return e=i,[h[0],h[1],h[2],a(e)]}var n=i;return s=s||0,e=e||0,[r(t),o(n),l(s),a(e)]};var w=[.199,.687,.114];function b(t){return w[0]*t[0]+w[1]*t[1]+w[2]*t[2]}function y(t,i,s){void 0===s&&(s=.05);var e=m(t),h=e[0]+i*s;return e[0]=u(h-Math.floor(h)),v(e)}function M(t,i,s){void 0===s&&(s=.05);var e=t[0],h=t[1],n=t[2],r=t[3],o=y([e,h,n],i,s);return[o[0],o[1],o[2],r]}var S,x,_,C,k={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",feldspar:"#d19275", firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslateblue:"#8470ff",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",violetred:"#d02090",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function z(t,i){return i in t}function R(t){var i=S.re.exec(t);return null!==i?S.parse(i):null}function N(t){var i=x.re.exec(t);return null!==i?x.parse(i):null}function E(t){var i=_.re.exec(t);return null!==i?_.parse(i):null}function Y(t){var i=C.re.exec(t);return null!==i?C.parse(i):null}function T(t){return"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function P(t){if(t=t.toLowerCase(),z(k,t)){var i=N(k[t]);if(null!==i)return i;throw new Error("Invalid named color definition")}var s=R(t);if(null!==s)return s;var e=N(t);if(null!==e)return e;var h=E(t);if(null!==h)return h;var n=Y(t);return null!==n?[n[0],n[1],n[2]]:null}function V(t){if(t=t.toLowerCase(),z(k,t)){var i=N(k[t]);if(null!==i)return[i[0],i[1],i[2],1];throw new Error("Invalid named color definition")}var s=R(t);if(null!==s)return[s[0],s[1],s[2],1];var e=N(t);if(null!==e)return[e[0],e[1],e[2],1];var h=E(t);if(null!==h)return[h[0],h[1],h[2],1];var n=Y(t);return null!==n?n:null}function B(t){var i=V(t);if(null!==i)return i ;throw new Error("Passed color string does not match any of the known color representations")}!function(t){t.re=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,t.parse=function(t){return[r(parseInt(t[1],10)),o(parseInt(t[2],10)),l(parseInt(t[3],10))]}}(S||(S={})),function(t){t.re=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,t.parse=function(t){return[r(parseInt(t[1],16)),o(parseInt(t[2],16)),l(parseInt(t[3],16))]}}(x||(x={})),function(t){t.re=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/,t.parse=function(t){return[r(parseInt(t[1]+t[1],16)),o(parseInt(t[2]+t[2],16)),l(parseInt(t[3]+t[3],16))]}}(_||(_={})),function(t){t.re=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?[\d]{0,10}(?:\.\d+)?)\s*\)$/,t.parse=function(t){return[r(parseInt(t[1],10)),o(parseInt(t[2],10)),l(parseInt(t[3],10)),a(parseFloat(t[4]))]}}(C||(C={})),i.rgbaToString=T,i.rgbToBlackWhiteString=function(t,i){if(i<0||i>255)throw new Error("invalid threshold value, valid values are [0, 255]");return b(t)>=i?"white":"black"},i.tryParseRgb=P,i.parseRgb=function(t){var i=P(t);if(null!==i)return i;throw new Error("Passed color string does not match any of the known color representations")},i.tryParseRgba=V,i.parseRgba=B},64531:(t,i)=>{var s,e=!("undefined"==typeof window||!window.document||!window.document.createElement);function h(){if(s)return s;if(!e||!window.document.body)return"indeterminate";var t=window.document.createElement("div");return t.appendChild(document.createTextNode("ABCD")),t.dir="rtl",t.style.fontSize="14px",t.style.width="4px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.overflow="scroll",document.body.appendChild(t),s="reverse",t.scrollLeft>0?s="default":(t.scrollLeft=1,0===t.scrollLeft&&(s="negative")),document.body.removeChild(t),s}},638456:(t,i,s)=>{s.d(i,{CheckMobile:()=>l,isDesktopApp:()=>r,isMac:()=>n,isSymphonyEmbed:()=>o,onWidget:()=>u,supportTouch:()=>c});var e=s(23482);const h=window.TradingView=window.TradingView||{};function n(){return e.isMac}function r(){return/TVDesktop/i.test(navigator.userAgent)}function o(){return h.isSymphony||!1}const l={Android:()=>e.isAndroid,BlackBerry:()=>e.isBlackBerry,iOS:()=>e.isIOS,Opera:()=>e.isOperaMini,isIPad:()=>e.isIPad,any:()=>e.isAnyMobile};h.isMobile=l;const a=new Map;function u(){const t=window.location.pathname,i=window.location.host,s=`${i}${t}`;return a.has(s)||a.set(s,function(t,i){const s=["^widget-docs"];for(const t of s)if(new RegExp(t).test(i))return!0 ;const e=["^widgetembed/?$","^cmewidgetembed/?$","^([0-9a-zA-Z-]+)/widgetembed/?$","^([0-9a-zA-Z-]+)/widgetstatic/?$","^([0-9a-zA-Z-]+)?/?mediumwidgetembed/?$","^twitter-chart/?$","^telegram/chart/?$","^embed/([0-9a-zA-Z]{8})/?$","^widgetpopup/?$","^extension/?$","^idea-popup/?$","^hotlistswidgetembed/?$","^([0-9a-zA-Z-]+)/hotlistswidgetembed/?$","^marketoverviewwidgetembed/?$","^([0-9a-zA-Z-]+)/marketoverviewwidgetembed/?$","^eventswidgetembed/?$","^tickerswidgetembed/?$","^forexcrossrateswidgetembed/?$","^forexheatmapwidgetembed/?$","^marketquoteswidgetembed/?$","^screenerwidget/?$","^cryptomktscreenerwidget/?$","^([0-9a-zA-Z-]+)/cryptomktscreenerwidget/?$","^([0-9a-zA-Z-]+)/marketquoteswidgetembed/?$","^technical-analysis-widget-embed/$","^singlequotewidgetembed/?$","^([0-9a-zA-Z-]+)/singlequotewidgetembed/?$","^embed-widget/([0-9a-zA-Z-]+)/(([0-9a-zA-Z-]+)/)?$","^widget-docs/([0-9a-zA-Z-]+)/([0-9a-zA-Z-/]+)?$"],h=t.replace(/^\//,"");let n;for(let t=e.length-1;t>=0;t--)if(n=new RegExp(e[t]),n.test(h))return!0;return!1}(t,i)),a.get(s)??!1}function c(){return e.mobiletouch||e.touch||e.isAnyMobile}h.onWidget=u;e.isChrome,e.isFF,e.isEdge,e.isSafari},871934:(t,i,s)=>{s.d(i,{bindCanvasElementBitmapSizeTo:()=>r,equalSizes:()=>e.equalSizes,size:()=>e.size,tryCreateCanvasRenderingTarget2D:()=>a});var e=s(341161),h=s(340159),n=function(){function t(t,i,s){var h;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=(0,e.size)({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(h=null==s?void 0:s.allowResizeObserver)||void 0===h||h,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return(0,e.size)({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=(0,e.size)(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"), this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter((function(i){return i!==t}))},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter((function(i){return i!==t}))},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;(0,e.equalSizes)(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var s=this;this._bitmapSizeChangedListeners.forEach((function(e){return e.call(s,t,i)}))},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,s=(0,e.size)(this._transformBitmapSize(t,this._canvasElementClientSize)),h=(0,e.equalSizes)(this.bitmapSize,s)?null:s;null===i&&null===h||null!==i&&null!==h&&(0,e.equalSizes)(i,h)||(this._suggestedBitmapSize=h,this._emitSuggestedBitmapSizeChanged(i,h))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var s=this;this._suggestedBitmapSizeChangedListeners.forEach((function(e){return e.call(s,t,i)}))},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise((function(t){var i=new ResizeObserver((function(s){t(s.every((function(t){return"devicePixelContentBoxSize"in t}))),i.disconnect()}));i.observe(document.body,{box:"device-pixel-content-box"})})).catch((function(){return!1})).then((function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()})):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=o(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=(0,h.createObservable)(i),this._devicePixelRatioObservable.subscribe((function(){return t._invalidateBitmapSize()})),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var s=o(this._canvasElement);if(null!==s){var h=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:s.devicePixelRatio,n=this._canvasElement.getClientRects(),r=void 0!==n[0]?function(t,i){return(0,e.size)({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i), height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(n[0],h):(0,e.size)({width:this._canvasElementClientSize.width*h,height:this._canvasElementClientSize.height*h});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver((function(i){var s=i.find((function(i){return i.target===t._canvasElement}));if(s&&s.devicePixelContentBoxSize&&s.devicePixelContentBoxSize[0]){var h=s.devicePixelContentBoxSize[0],n=(0,e.size)({width:h.inlineSize,height:h.blockSize});t._suggestNewBitmapSize(n)}})),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function r(t,i){if("device-pixel-content-box"===i.type)return new n(t,i.transform,i.options);throw new Error("Unsupported binding target")}function o(t){return t.ownerDocument.defaultView}var l=function(){function t(t,i,s){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===s.width||0===s.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return t.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},t.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function a(t,i){var s=t.canvasElementClientSize;if(0===s.width||0===s.height)return null;var e=t.bitmapSize;if(0===e.width||0===e.height)return null;var h=t.canvasElement.getContext("2d",i);return null===h?null:new l(h,s,e)}},305152:(t,i,s)=>{s.d(i,{AreaSeries:()=>th,BarSeries:()=>hh,BaselineSeries:()=>Ge,CandlestickSeries:()=>oh,ColorType:()=>Vi,CrosshairMode:()=>Z,HistogramSeries:()=>uh,LineSeries:()=>Xe,LineStyle:()=>r,PriceScaleMode:()=>pi,TickMarkType:()=>Bi,createChartEx:()=>Te,createTextWatermark:()=>Mh,defaultHorzScaleBehavior:()=>Pe});var e=s(871934);const h={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var n,r,o;function l(t,i){const s={ 0:[],1:[t.lineWidth,t.lineWidth],2:[2*t.lineWidth,2*t.lineWidth],3:[6*t.lineWidth,6*t.lineWidth],4:[t.lineWidth,4*t.lineWidth]}[i];t.setLineDash(s)}function a(t,i,s,e){t.beginPath();const h=t.lineWidth%2?.5:0;t.moveTo(s,i+h),t.lineTo(e,i+h),t.stroke()}function u(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function c(t){if(void 0===t)throw new Error("Value is undefined");return t}function d(t){if(null===t)throw new Error("Value is null");return t}function f(t){return d(c(t))}(o=n||(n={}))[o.Simple=0]="Simple",o[o.WithSteps=1]="WithSteps",o[o.Curved=2]="Curved",function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(r||(r={}));class p{constructor(){this.t=[]}i(t,i,s){const e={h:t,l:i,o:!0===s};this.t.push(e)}_(t){const i=this.t.findIndex((i=>t===i.h));i>-1&&this.t.splice(i,1)}u(t){this.t=this.t.filter((i=>i.l!==t))}p(t,i,s){const e=[...this.t];this.t=this.t.filter((t=>!t.o)),e.forEach((e=>e.h(t,i,s)))}v(){return this.t.length>0}m(){this.t=[]}}function m(t,...i){for(const s of i)for(const i in s)void 0!==s[i]&&Object.prototype.hasOwnProperty.call(s,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof s[i]||void 0===t[i]||Array.isArray(s[i])?t[i]=s[i]:m(t[i],s[i]));return t}function g(t){return"number"==typeof t&&isFinite(t)}function v(t){return"number"==typeof t&&t%1==0}function w(t){return"string"==typeof t}function b(t){return"boolean"==typeof t}function y(t){const i=t;if(!i||"object"!=typeof i)return i;let s,e,h;for(e in s=Array.isArray(i)?[]:{},i)i.hasOwnProperty(e)&&(h=i[e],s[e]=h&&"object"==typeof h?y(h):h);return s}function M(t){return null!==t}function S(t){return null===t?void 0:t}const x="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function _(t,i,s){return void 0===i&&(i=x),`${s=void 0!==s?`${s} `:""}${t}px ${i}`}class C{constructor(t){this.M={S:1,C:5,k:NaN,P:"",T:"",R:"",D:"",V:0,I:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,i=this.W(),s=this.F();return t.k===i&&t.T===s||(t.k=i,t.T=s,t.P=_(i,s),t.A=2.5/12*i,t.V=t.A,t.I=i/12*t.C,t.B=i/12*t.C,t.L=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}W(){return this.O.N().layout.fontSize}F(){return this.O.N().layout.fontFamily}}function k(t){return t<0?0:t>255?255:Math.round(t)||0}function z(t){return.199*t[0]+.687*t[1]+.114*t[2]}class R{constructor(t,i){this.q=new Map,this.Y=t,i&&(this.q=i)}j(t,i){if("transparent"===t)return t;const s=this.K(t),e=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${i*e})`}X(t){const i=this.K(t);return{Z:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,G:z(i)>160?"black":"white"}}J(t){return z(this.K(t))}tt(t,i,s){const[e,h,n,r]=this.K(t),[o,l,a,u]=this.K(i),c=[k(e+s*(o-e)),k(h+s*(l-h)),k(n+s*(a-n)),(d=r+s*(u-r),d<=0||d>1?Math.min(Math.max(d,0),1):Math.round(1e4*d)/1e4)];var d;return`rgba(${c[0]}, ${c[1]}, ${c[2]}, ${c[3]})`}K(t){const i=this.q.get(t);if(i)return i;const s=function(t){const i=document.createElement("div");i.style.display="none", document.body.appendChild(i),i.style.color=t;const s=window.getComputedStyle(i).color;return document.body.removeChild(i),s}(t),e=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!e){if(this.Y.length)for(const i of this.Y){const s=i(t);if(s)return this.q.set(t,s),s}throw new Error(`Failed to parse color: ${t}`)}const h=[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]?parseFloat(e[4]):1];return this.q.set(t,h),h}}class N{constructor(){this.it=[]}st(t){this.it=t}nt(t,i,s){this.it.forEach((e=>{e.nt(t,i,s)}))}}class E{nt(t,i,s){t.useBitmapCoordinateSpace((t=>this.et(t,i,s)))}}class Y extends E{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.rt||null===this.rt.lt)return;const e=this.rt.lt,h=this.rt,n=Math.max(1,Math.floor(i))%2/2,r=r=>{t.beginPath();for(let o=e.to-1;o>=e.from;--o){const e=h.ot[o],l=Math.round(e._t*i)+n,a=e.ut*s,u=r*s+n;t.moveTo(l,a),t.arc(l,a,u,0,2*Math.PI)}t.fill()};h.ct>0&&(t.fillStyle=h.dt,r(h.ft+h.ct)),t.fillStyle=h.vt,r(h.ft)}}function T(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const P={from:0,to:1};class V{constructor(t,i,s){this.Mt=new N,this.bt=[],this.St=[],this.xt=!0,this.O=t,this.Ct=i,this.yt=s,this.Mt.st(this.bt)}kt(t){this.Pt(),this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Mt}Pt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.St=t.map(T),this.bt=this.St.map((t=>{const i=new Y;return i.ht(t),i})),this.Mt.st(this.bt))}Rt(){const t=2===this.Ct.N().mode||!this.Ct.Vt(),i=this.yt.It(),s=this.Ct.Bt(),e=this.O.At();this.Pt(),i.forEach(((i,h)=>{const n=this.St[h],r=i.Et(s),o=i.zt();!t&&null!==r&&i.Vt()&&null!==o?(n.vt=r.Lt,n.ft=r.ft,n.ct=r.Ot,n.ot[0].gt=r.gt,n.ot[0].ut=i.Wt().Nt(r.gt,o.Ft),n.dt=r.Ht??this.O.Ut(n.ot[0].ut/i.Wt().$t()),n.ot[0].wt=s,n.ot[0]._t=e.qt(s),n.lt=P):n.lt=null}))}}class B extends E{constructor(t){super(),this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;const h=this.Yt.jt.Vt,n=this.Yt.Kt.Vt;if(!h&&!n)return;const r=Math.round(this.Yt._t*s),o=Math.round(this.Yt.ut*e);t.lineCap="butt",h&&r>=0&&(t.lineWidth=Math.floor(this.Yt.jt.ct*s),t.strokeStyle=this.Yt.jt.R,t.fillStyle=this.Yt.jt.R,l(t,this.Yt.jt.Xt),function(t,i,s,e){t.beginPath();const h=t.lineWidth%2?.5:0;t.moveTo(i+h,0),t.lineTo(i+h,e),t.stroke()}(t,r,0,i.height)),n&&o>=0&&(t.lineWidth=Math.floor(this.Yt.Kt.ct*e),t.strokeStyle=this.Yt.Kt.R,t.fillStyle=this.Yt.Kt.R,l(t,this.Yt.Kt.Xt),a(t,o,0,i.width))}}class D{constructor(t,i){this.xt=!0,this.Zt={jt:{ct:1,Xt:0,R:"",Vt:!1},Kt:{ct:1,Xt:0,R:"",Vt:!1},_t:0,ut:0},this.Gt=new B(this.Zt),this.Jt=t,this.yt=i}kt(){this.xt=!0}Tt(t){return this.xt&&(this.Rt(),this.xt=!1),this.Gt}Rt(){const t=this.Jt.Vt(),i=this.yt.Qt().N().crosshair,s=this.Zt;if(2===i.mode)return s.Kt.Vt=!1,void(s.jt.Vt=!1);s.Kt.Vt=t&&this.Jt.ti(this.yt),s.jt.Vt=t&&this.Jt.ii(),s.Kt.ct=i.horzLine.width,s.Kt.Xt=i.horzLine.style,s.Kt.R=i.horzLine.color,s.jt.ct=i.vertLine.width, s.jt.Xt=i.vertLine.style,s.jt.R=i.vertLine.color,s._t=this.Jt.si(),s.ut=this.Jt.ni()}}function A(t,i,s,e,h,n){t.fillRect(i+n,s,e-2*n,n),t.fillRect(i+n,s+h-n,e-2*n,n),t.fillRect(i,s,n,h),t.fillRect(i+e-n,s,n,h)}function W(t,i,s,e,h,n){t.save(),t.globalCompositeOperation="copy",t.fillStyle=n,t.fillRect(i,s,e,h),t.restore()}function F(t,i,s,e,h,n){t.beginPath(),t.roundRect?t.roundRect(i,s,e,h,n):(t.lineTo(i+e-n[1],s),0!==n[1]&&t.arcTo(i+e,s,i+e,s+n[1],n[1]),t.lineTo(i+e,s+h-n[2]),0!==n[2]&&t.arcTo(i+e,s+h,i+e-n[2],s+h,n[2]),t.lineTo(i+n[3],s+h),0!==n[3]&&t.arcTo(i,s+h,i,s+h-n[3],n[3]),t.lineTo(i,s+n[0]),0!==n[0]&&t.arcTo(i,s,i+n[0],s,n[0]))}function L(t,i,s,e,h,n,r=0,o=[0,0,0,0],l=""){if(t.save(),!r||!l||l===n)return F(t,i,s,e,h,o),t.fillStyle=n,t.fill(),void t.restore();const a=r/2;var u;F(t,i+a,s+a,e-r,h-r,(u=-a,o.map((t=>0===t?t:t+u)))),"transparent"!==n&&(t.fillStyle=n,t.fill()),"transparent"!==l&&(t.lineWidth=r,t.strokeStyle=l,t.closePath(),t.stroke()),t.restore()}function O(t,i,s,e,h,n,r){t.save(),t.globalCompositeOperation="copy";const o=t.createLinearGradient(0,0,0,h);o.addColorStop(0,n),o.addColorStop(1,r),t.fillStyle=o,t.fillRect(i,s,e,h),t.restore()}class I{constructor(t,i){this.ht(t,i)}ht(t,i){this.Yt=t,this.ei=i}$t(t,i){return this.Yt.Vt?t.k+t.A+t.V:0}nt(t,i,s,e){if(!this.Yt.Vt||0===this.Yt.ri.length)return;const h=this.Yt.R,n=this.ei.Z,r=t.useBitmapCoordinateSpace((t=>{const r=t.context;r.font=i.P;const o=this.hi(t,i,s,e),l=o.ai;return o.li?L(r,l.oi,l._i,l.ui,l.ci,n,l.di,[l.ft,0,0,l.ft],n):L(r,l.fi,l._i,l.ui,l.ci,n,l.di,[0,l.ft,l.ft,0],n),this.Yt.pi&&(r.fillStyle=h,r.fillRect(l.fi,l.mi,l.wi-l.fi,l.gi)),this.Yt.Mi&&(r.fillStyle=i.D,r.fillRect(o.li?l.bi-l.di:0,l._i,l.di,l.Si-l._i)),o}));t.useMediaCoordinateSpace((({context:t})=>{const s=r.xi;t.font=i.P,t.textAlign=r.li?"right":"left",t.textBaseline="middle",t.fillStyle=h,t.fillText(this.Yt.ri,s.Ci,(s._i+s.Si)/2+s.yi)}))}hi(t,i,s,e){const{context:h,bitmapSize:n,mediaSize:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t,a=this.Yt.pi||!this.Yt.ki?i.C:0,u=this.Yt.Pi?i.S:0,c=i.A+this.ei.Ti,d=i.V+this.ei.Ri,f=i.I,p=i.B,m=this.Yt.ri,g=i.k,v=s.Di(h,m),w=Math.ceil(s.Vi(h,m)),b=g+c+d,y=i.S+f+p+w+a,M=Math.max(1,Math.floor(l));let S=Math.round(b*l);S%2!=M%2&&(S+=1);const x=u>0?Math.max(1,Math.floor(u*o)):0,_=Math.round(y*o),C=Math.round(a*o),k=this.ei.Ii??this.ei.Bi,z=Math.round(k*l)-Math.floor(.5*l),R=Math.floor(z+M/2-S/2),N=R+S,E="right"===e,Y=E?r.width-u:u,T=E?n.width-x:x;let P,V,B;return E?(P=T-_,V=T-C,B=Y-a-f-u):(P=T+_,V=T+C,B=Y+a+f),{li:E,ai:{_i:R,mi:z,Si:N,ui:_,ci:S,ft:2*o,di:x,oi:P,fi:T,wi:V,gi:M,bi:n.width},xi:{_i:R/l,Si:N/l,Ci:B,yi:v}}}}class Q{constructor(t){this.Ai={Bi:0,Z:"#000",Ri:0,Ti:0},this.Ei={ri:"",Vt:!1,pi:!0,ki:!1,Ht:"",R:"#FFF",Mi:!1,Pi:!1},this.zi={ri:"",Vt:!1,pi:!1,ki:!0,Ht:"",R:"#FFF",Mi:!0,Pi:!0},this.xt=!0,this.Li=new(t||I)(this.Ei,this.Ai),this.Oi=new(t||I)(this.zi,this.Ai)}ri(){return this.Ni(),this.Ei.ri}Bi(){return this.Ni(),this.Ai.Bi}kt(){this.xt=!0}$t(t,i=!1){return Math.max(this.Li.$t(t,i),this.Oi.$t(t,i))}Wi(){return this.Ai.Ii||0} Fi(t){this.Ai.Ii=t}Hi(){return this.Ni(),this.Ei.Vt||this.zi.Vt}Ui(){return this.Ni(),this.Ei.Vt}Tt(t){return this.Ni(),this.Ei.pi=this.Ei.pi&&t.N().ticksVisible,this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Li.ht(this.Ei,this.Ai),this.Oi.ht(this.zi,this.Ai),this.Li}$i(){return this.Ni(),this.Li.ht(this.Ei,this.Ai),this.Oi.ht(this.zi,this.Ai),this.Oi}Ni(){this.xt&&(this.Ei.pi=!0,this.zi.pi=!1,this.qi(this.Ei,this.zi,this.Ai))}}class X extends Q{constructor(t,i,s){super(),this.Jt=t,this.Yi=i,this.ji=s}qi(t,i,s){if(t.Vt=!1,2===this.Jt.N().mode)return;const e=this.Jt.N().horzLine;if(!e.labelVisible)return;const h=this.Yi.zt();if(!this.Jt.Vt()||this.Yi.Ki()||null===h)return;const n=this.Yi.Xi().X(e.labelBackgroundColor);s.Z=n.Z,t.R=n.G;const r=2/12*this.Yi.k();s.Ti=r,s.Ri=r;const o=this.ji(this.Yi);s.Bi=o.Bi,t.ri=this.Yi.Zi(o.gt,h),t.Vt=!0}}const $=/[1-9]/g;class J{constructor(){this.Yt=null}ht(t){this.Yt=t}nt(t,i){if(null===this.Yt||!1===this.Yt.Vt||0===this.Yt.ri.length)return;const s=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.P,Math.round(i.Gi.Vi(t,d(this.Yt).ri,$)))));if(s<=0)return;const e=i.Ji,h=s+2*e,n=h/2,r=this.Yt.Qi;let o=this.Yt.Bi,l=Math.floor(o-n)+.5;l<0?(o+=Math.abs(0-l),l=Math.floor(o-n)+.5):l+h>r&&(o-=Math.abs(r-(l+h)),l=Math.floor(o-n)+.5);const a=l+h,u=Math.ceil(0+i.S+i.C+i.A+i.k+i.V);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:s,verticalPixelRatio:e})=>{const h=d(this.Yt);t.fillStyle=h.Z;const n=Math.round(l*s),r=Math.round(0*e),o=Math.round(a*s),c=Math.round(u*e),f=Math.round(2*s);if(t.beginPath(),t.moveTo(n,r),t.lineTo(n,c-f),t.arcTo(n,c,n+f,c,f),t.lineTo(o-f,c),t.arcTo(o,c,o,c-f,f),t.lineTo(o,r),t.fill(),h.pi){const n=Math.round(h.Bi*s),o=r,l=Math.round((o+i.C)*e);t.fillStyle=h.R;const a=Math.max(1,Math.floor(s)),u=Math.floor(.5*s);t.fillRect(n-u,o,a,l-o)}})),t.useMediaCoordinateSpace((({context:t})=>{const s=d(this.Yt),h=0+i.S+i.C+i.A+i.k/2;t.font=i.P,t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.R;const n=i.Gi.Di(t,"Apr0");t.translate(l+e,h+n),t.fillText(s.ri,0,0)}))}}class q{constructor(t,i,s){this.xt=!0,this.Gt=new J,this.Zt={Vt:!1,Z:"#4c525e",R:"white",ri:"",Qi:0,Bi:NaN,pi:!0},this.Ct=t,this.ts=i,this.ji=s}kt(){this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Gt.ht(this.Zt),this.Gt}Rt(){const t=this.Zt;if(t.Vt=!1,2===this.Ct.N().mode)return;const i=this.Ct.N().vertLine;if(!i.labelVisible)return;const s=this.ts.At();if(s.Ki())return;t.Qi=s.Qi();const e=this.ji();if(null===e)return;t.Bi=e.Bi;const h=s.ss(this.Ct.Bt());t.ri=s.ns(d(h)),t.Vt=!0;const n=this.ts.Xi().X(i.labelBackgroundColor);t.Z=n.Z,t.R=n.G,t.pi=s.N().ticksVisible}}class U{constructor(){this.es=null,this.rs=0}hs(){return this.rs}ls(t){this.rs=t}Wt(){return this.es}_s(t){this.es=t}us(t){return[]}cs(){return[]}Vt(){return!0}}var Z;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}(Z||(Z={}));class K extends U{constructor(t,i){super(),this.yt=null,this.ds=NaN,this.fs=0,this.ps=!1,this.vs=new Map,this.ws=!1,this.gs=new WeakMap, this.Ms=new WeakMap,this.bs=NaN,this.Ss=NaN,this.xs=NaN,this.Cs=NaN,this.ts=t,this.ys=i,this.ks=((t,i)=>s=>{const e=i(),h=t();if(s===d(this.yt).Ps())return{gt:h,Bi:e};{const t=d(s.zt());return{gt:s.Ts(e,t),Bi:e}}})((()=>this.ds),(()=>this.Ss));const s=((t,i)=>()=>{const s=this.ts.At().Rs(t()),e=i();return s&&Number.isFinite(e)?{wt:s,Bi:e}:null})((()=>this.fs),(()=>this.si()));this.Ds=new q(this,t,s)}N(){return this.ys}Vs(t,i){this.xs=t,this.Cs=i}Is(){this.xs=NaN,this.Cs=NaN}Bs(){return this.xs}As(){return this.Cs}Es(t,i,s){this.ws||(this.ws=!0),this.ps=!0,this.zs(t,i,s)}Bt(){return this.fs}si(){return this.bs}ni(){return this.Ss}Vt(){return this.ps}Ls(){this.ps=!1,this.Os(),this.ds=NaN,this.bs=NaN,this.Ss=NaN,this.yt=null,this.Is(),this.Ns()}Ws(t){let i=this.gs.get(t);i||(i=new D(this,t),this.gs.set(t,i));let s=this.Ms.get(t);return s||(s=new V(this.ts,this,t),this.Ms.set(t,s)),[i,s]}ti(t){return t===this.yt&&this.ys.horzLine.visible}ii(){return this.ys.vertLine.visible}Fs(t,i){this.ps&&this.yt===t||this.vs.clear();const s=[];return this.yt===t&&s.push(this.Hs(this.vs,i,this.ks)),s}cs(){return this.ps?[this.Ds]:[]}Us(){return this.yt}Ns(){this.ts.$s().forEach((t=>{this.gs.get(t)?.kt(),this.Ms.get(t)?.kt()})),this.vs.forEach((t=>t.kt())),this.Ds.kt()}qs(t){return t&&!t.Ps().Ki()?t.Ps():null}zs(t,i,s){this.Ys(t,i,s)&&this.Ns()}Ys(t,i,s){const e=this.bs,h=this.Ss,n=this.ds,r=this.fs,o=this.yt,l=this.qs(s);this.fs=t,this.bs=isNaN(t)?NaN:this.ts.At().qt(t),this.yt=s;const a=null!==l?l.zt():null;return null!==l&&null!==a?(this.ds=i,this.Ss=l.Nt(i,a)):(this.ds=NaN,this.Ss=NaN),e!==this.bs||h!==this.Ss||r!==this.fs||n!==this.ds||o!==this.yt}Os(){const t=this.ts.js().map((t=>t.Xs().Ks())).filter(M),i=0===t.length?null:Math.max(...t);this.fs=null!==i?i:NaN}Hs(t,i,s){let e=t.get(i);return void 0===e&&(e=new X(this,i,s),t.set(i,e)),e}}function G(t){return"left"===t||"right"===t}class H{constructor(t){this.Zs=new Map,this.Gs=[],this.Js=t}Qs(t,i){const s=function(t,i){return void 0===t?i:{tn:Math.max(t.tn,i.tn),sn:t.sn||i.sn}}(this.Zs.get(t),i);this.Zs.set(t,s)}nn(){return this.Js}en(t){const i=this.Zs.get(t);return void 0===i?{tn:this.Js}:{tn:Math.max(this.Js,i.tn),sn:i.sn}}rn(){this.hn(),this.Gs=[{an:0}]}ln(t){this.hn(),this.Gs=[{an:1,Ft:t}]}_n(t){this.un(),this.Gs.push({an:5,Ft:t})}hn(){this.un(),this.Gs.push({an:6})}cn(){this.hn(),this.Gs=[{an:4}]}dn(t){this.hn(),this.Gs.push({an:2,Ft:t})}fn(t){this.hn(),this.Gs.push({an:3,Ft:t})}pn(){return this.Gs}vn(t){for(const i of t.Gs)this.mn(i);this.Js=Math.max(this.Js,t.Js),t.Zs.forEach(((t,i)=>{this.Qs(i,t)}))}static wn(){return new H(2)}static gn(){return new H(3)}mn(t){switch(t.an){case 0:this.rn();break;case 1:this.ln(t.Ft);break;case 2:this.dn(t.Ft);break;case 3:this.fn(t.Ft);break;case 4:this.cn();break;case 5:this._n(t.Ft);break;case 6:this.un()}}un(){const t=this.Gs.findIndex((t=>5===t.an));-1!==t&&this.Gs.splice(t,1)}}function j(t,i){if(!g(t))return"n/a";if(!v(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length") ;return 0===i?t.toString():("0000000000000000"+t.toString()).slice(-i)}class tt{constructor(t,i){if(i||(i=1),g(t)&&v(t)||(t=100),t<0)throw new TypeError("invalid base");this.Yi=t,this.Mn=i,this.bn()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.Sn(t)}bn(){if(this.xn=0,this.Yi>0&&this.Mn>0){let t=this.Yi;for(;t>1;)t/=10,this.xn++}}Sn(t){const i=this.Yi/this.Mn;let s=Math.floor(t),e="";const h=void 0!==this.xn?this.xn:NaN;if(i>1){let n=+(Math.round(t*i)-s*i).toFixed(this.xn);n>=i&&(n-=i,s+=1),e="."+j(+n.toFixed(this.xn)*this.Mn,h)}else s=Math.round(s*i)/i,h>0&&(e="."+j(0,h));return s.toFixed(0)+e}}class it extends tt{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class st{constructor(t){this.Cn=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.yn(t):t<999995?i+this.yn(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.yn(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.yn(t/1e9)+"B")}yn(t){let i;const s=Math.pow(10,this.Cn);return i=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Cn).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const et=/[2-9]/g;class ht{constructor(t=50){this.kn=0,this.Pn=1,this.Tn=1,this.Rn={},this.Dn=new Map,this.Vn=t}In(){this.kn=0,this.Dn.clear(),this.Pn=1,this.Tn=1,this.Rn={}}Vi(t,i,s){return this.Bn(t,i,s).width}Di(t,i,s){const e=this.Bn(t,i,s);return((e.actualBoundingBoxAscent||0)-(e.actualBoundingBoxDescent||0))/2}Bn(t,i,s){const e=s||et,h=String(i).replace(e,"0");if(this.Dn.has(h))return c(this.Dn.get(h)).An;if(this.kn===this.Vn){const t=this.Rn[this.Tn];delete this.Rn[this.Tn],this.Dn.delete(t),this.Tn++,this.kn--}t.save(),t.textBaseline="middle";const n=t.measureText(h);return t.restore(),0===n.width&&i.length||(this.Dn.set(h,{An:n,En:this.Pn}),this.Rn[this.Pn]=h,this.kn++,this.Pn++),n}}class nt{constructor(t){this.zn=null,this.M=null,this.Ln="right",this.On=t}Nn(t,i,s){this.zn=t,this.M=i,this.Ln=s}nt(t){null!==this.M&&null!==this.zn&&this.zn.nt(t,this.M,this.On,this.Ln)}}class rt{constructor(t,i,s){this.Wn=t,this.On=new ht(50),this.Fn=i,this.O=s,this.W=-1,this.Gt=new nt(this.On)}Tt(){const t=this.O.Hn(this.Fn);if(null===t)return null;const i=t.Un(this.Fn)?t.$n():this.Fn.Wt();if(null===i)return null;const s=t.qn(i);if("overlay"===s)return null;const e=this.O.Yn();return e.k!==this.W&&(this.W=e.k,this.On.In()),this.Gt.Nn(this.Wn.$i(),e,s),this.Gt}}class ot extends E{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}jn(t,i){if(!this.Yt?.Vt)return null;const{ut:s,ct:e,Kn:h}=this.Yt;return i>=s-e-7&&i<=s+e+7?{Xn:this.Yt,Kn:h}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;if(!1===this.Yt.Vt)return;const h=Math.round(this.Yt.ut*e);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.Yt.R,t.lineWidth=Math.floor(this.Yt.ct*s),l(t,this.Yt.Xt),a(t,h,0,i.width))}}class lt{constructor(t){this.Zn={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Xt:0,Vt:!1},this.Gn=new ot,this.xt=!0,this.Jn=t,this.Qn=t.Qt(),this.Gn.ht(this.Zn)}kt(){this.xt=!0}Tt(){ return this.Jn.Vt()?(this.xt&&(this.te(),this.xt=!1),this.Gn):null}}class at extends lt{constructor(t){super(t)}te(){this.Zn.Vt=!1;const t=this.Jn.Wt(),i=t.ie().ie;if(2!==i&&3!==i)return;const s=this.Jn.N();if(!s.baseLineVisible||!this.Jn.Vt())return;const e=this.Jn.zt();null!==e&&(this.Zn.Vt=!0,this.Zn.ut=t.Nt(e.Ft,e.Ft),this.Zn.R=s.baseLineColor,this.Zn.ct=s.baseLineWidth,this.Zn.Xt=s.baseLineStyle)}}class ut extends E{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}se(){return this.Yt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){const e=this.Yt;if(null===e)return;const h=Math.max(1,Math.floor(i)),n=h%2/2,r=Math.round(e.ne.x*i)+n,o=e.ne.y*s;t.fillStyle=e.ee,t.beginPath();const l=Math.max(2,1.5*e.re)*i;t.arc(r,o,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=e.he,t.beginPath(),t.arc(r,o,e.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=h,t.strokeStyle=e.ae,t.beginPath(),t.arc(r,o,e.ft*i+h/2,0,2*Math.PI,!1),t.stroke()}}const ct=[{le:0,oe:.25,_e:4,ue:10,ce:.25,de:0,fe:.4,pe:.8},{le:.25,oe:.525,_e:10,ue:14,ce:0,de:0,fe:.8,pe:0},{le:.525,oe:1,_e:14,ue:14,ce:0,de:0,fe:0,pe:0}];class dt{constructor(t){this.Gt=new ut,this.xt=!0,this.ve=!0,this.me=performance.now(),this.we=this.me-1,this.ge=t}Me(){this.we=this.me-1,this.kt()}be(){if(this.kt(),2===this.ge.N().lastPriceAnimation){const t=performance.now(),i=this.we-t;if(i>0)return void(i<650&&(this.we+=2600));this.me=t,this.we=t+2600}}kt(){this.xt=!0}Se(){this.ve=!0}Vt(){return 0!==this.ge.N().lastPriceAnimation}xe(){switch(this.ge.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.we}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ve=!1):this.ve&&(this.Ce(),this.ve=!1),this.Gt}Rt(){this.Gt.ht(null);const t=this.ge.Qt().At(),i=t.ye(),s=this.ge.zt();if(null===i||null===s)return;const e=this.ge.ke(!0);if(e.Pe||!i.Te(e.Re))return;const h={x:t.qt(e.Re),y:this.ge.Wt().Nt(e.gt,s.Ft)},n=e.R,r=this.ge.N().lineWidth,o=this.De(this.Ve(),n);this.Gt.ht({ee:n,re:r,he:o.he,ae:o.ae,ft:o.ft,ne:h})}Ce(){const t=this.Gt.se();if(null!==t){const i=this.De(this.Ve(),t.ee);t.he=i.he,t.ae=i.ae,t.ft=i.ft}}Ve(){return this.xe()?performance.now()-this.me:2599}Ie(t,i,s,e){const h=s+(e-s)*i;return this.ge.Qt().Xi().j(t,h)}De(t,i){const s=t%2600/2600;let e;for(const t of ct)if(s>=t.le&&s<=t.oe){e=t;break}u(void 0!==e,"Last price animation internal logic error");const h=(s-e.le)/(e.oe-e.le);return{he:this.Ie(i,h,e.ce,e.de),ae:this.Ie(i,h,e.fe,e.pe),ft:(n=h,r=e._e,o=e.ue,r+(o-r)*n)};var n,r,o}}class ft extends lt{constructor(t){super(t)}te(){const t=this.Zn;t.Vt=!1;const i=this.Jn.N();if(!i.priceLineVisible||!this.Jn.Vt())return;const s=this.Jn.ke(0===i.priceLineSource);s.Pe||(t.Vt=!0,t.ut=s.Bi,t.R=this.Jn.Be(s.R),t.ct=i.priceLineWidth,t.Xt=i.priceLineStyle)}}class pt extends Q{constructor(t){super(),this.Jt=t}qi(t,i,s){t.Vt=!1,i.Vt=!1;const e=this.Jt;if(!e.Vt())return;const h=e.N(),n=h.lastValueVisible,r=""!==e.Ae(),o=0===h.seriesLastValueMode,l=e.ke(!1);if(l.Pe)return;n&&(t.ri=this.Ee(l,n,o),t.Vt=0!==t.ri.length),(r||o)&&(i.ri=this.ze(l,n,r,o), i.Vt=i.ri.length>0);const a=e.Be(l.R),u=this.Jt.Qt().Xi().X(a);s.Z=u.Z,s.Bi=l.Bi,i.Ht=e.Qt().Ut(l.Bi/e.Wt().$t()),t.Ht=a,t.R=u.G,i.R=u.G}ze(t,i,s,e){let h="";const n=this.Jt.Ae();return s&&0!==n.length&&(h+=`${n} `),i&&e&&(h+=this.Jt.Wt().Le()?t.Oe:t.Ne),h.trim()}Ee(t,i,s){return i?s?this.Jt.Wt().Le()?t.Ne:t.Oe:t.ri:""}}function mt(t,i,s,e){const h=Number.isFinite(i),n=Number.isFinite(s);return h&&n?t(i,s):h||n?h?i:s:e}class gt{constructor(t,i){this.We=t,this.Fe=i}He(t){return null!==t&&this.We===t.We&&this.Fe===t.Fe}Ue(){return new gt(this.We,this.Fe)}$e(){return this.We}qe(){return this.Fe}Ye(){return this.Fe-this.We}Ki(){return this.Fe===this.We||Number.isNaN(this.Fe)||Number.isNaN(this.We)}vn(t){return null===t?this:new gt(mt(Math.min,this.$e(),t.$e(),-1/0),mt(Math.max,this.qe(),t.qe(),1/0))}je(t){if(!g(t))return;if(0==this.Fe-this.We)return;const i=.5*(this.Fe+this.We);let s=this.Fe-i,e=this.We-i;s*=t,e*=t,this.Fe=i+s,this.We=i+e}Ke(t){g(t)&&(this.Fe+=t,this.We+=t)}Xe(){return{minValue:this.We,maxValue:this.Fe}}static Ze(t){return null===t?null:new gt(t.minValue,t.maxValue)}}class vt{constructor(t,i){this.Ge=t,this.Je=i||null}Qe(){return this.Ge}tr(){return this.Je}Xe(){return{priceRange:null===this.Ge?null:this.Ge.Xe(),margins:this.Je||void 0}}static Ze(t){return null===t?null:new vt(gt.Ze(t.priceRange),t.margins)}}class wt extends lt{constructor(t,i){super(t),this.ir=i}te(){const t=this.Zn;t.Vt=!1;const i=this.ir.N();if(!this.Jn.Vt()||!i.lineVisible)return;const s=this.ir.sr();null!==s&&(t.Vt=!0,t.ut=s,t.R=i.color,t.ct=i.lineWidth,t.Xt=i.lineStyle,t.Kn=this.ir.N().id)}}class bt extends Q{constructor(t,i){super(),this.ge=t,this.ir=i}qi(t,i,s){t.Vt=!1,i.Vt=!1;const e=this.ir.N(),h=e.axisLabelVisible,n=""!==e.title,r=this.ge;if(!h||!r.Vt())return;const o=this.ir.sr();if(null===o)return;n&&(i.ri=e.title,i.Vt=!0),i.Ht=r.Qt().Ut(o/r.Wt().$t()),t.ri=this.nr(e.price),t.Vt=!0;const l=this.ge.Qt().Xi().X(e.axisLabelColor||e.color);s.Z=l.Z;const a=e.axisLabelTextColor||l.G;t.R=a,i.R=a,s.Bi=o}nr(t){const i=this.ge.zt();return null===i?"":this.ge.Wt().Zi(t,i.Ft)}}class yt{constructor(t,i){this.ge=t,this.ys=i,this.er=new wt(t,this),this.Wn=new bt(t,this),this.rr=new rt(this.Wn,t,t.Qt())}hr(t){m(this.ys,t),this.kt(),this.ge.Qt().ar()}N(){return this.ys}lr(){return this.er}_r(){return this.rr}ur(){return this.Wn}kt(){this.er.kt(),this.Wn.kt()}sr(){const t=this.ge,i=t.Wt();if(t.Qt().At().Ki()||i.Ki())return null;const s=t.zt();return null===s?null:i.Nt(this.ys.price,s.Ft)}}class Mt extends U{constructor(t){super(),this.ts=t}Qt(){return this.ts}}const St={Bar:(t,i,s,e)=>{const h=i.upColor,n=i.downColor,r=d(t(s,e)),o=f(r.Ft[0])<=f(r.Ft[3]);return{cr:r.R??(o?h:n)}},Candlestick:(t,i,s,e)=>{const h=i.upColor,n=i.downColor,r=i.borderUpColor,o=i.borderDownColor,l=i.wickUpColor,a=i.wickDownColor,u=d(t(s,e)),c=f(u.Ft[0])<=f(u.Ft[3]);return{cr:u.R??(c?h:n),dr:u.Ht??(c?r:o),pr:u.vr??(c?l:a)}},Custom:(t,i,s,e)=>({cr:d(t(s,e)).R??i.color}),Area:(t,i,s,e)=>{const h=d(t(s,e));return{cr:h.vt??i.lineColor,vt:h.vt??i.lineColor, mr:h.mr??i.topColor,wr:h.wr??i.bottomColor}},Baseline:(t,i,s,e)=>{const h=d(t(s,e));return{cr:h.Ft[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,gr:h.gr??i.topLineColor,Mr:h.Mr??i.bottomLineColor,br:h.br??i.topFillColor1,Sr:h.Sr??i.topFillColor2,Cr:h.Cr??i.bottomFillColor1,yr:h.yr??i.bottomFillColor2}},Line:(t,i,s,e)=>{const h=d(t(s,e));return{cr:h.R??i.color,vt:h.R??i.color}},Histogram:(t,i,s,e)=>({cr:d(t(s,e)).R??i.color})};class xt{constructor(t){this.kr=(t,i)=>void 0!==i?i.Ft:this.ge.Xs().Pr(t),this.ge=t,this.Tr=St[t.Rr()]}Dr(t,i){return this.Tr(this.kr,this.ge.N(),t,i)}}function _t(t,i,s,e,h=0,n=i.length){let r=n-h;for(;0>1,o=h+n;e(i[o],s)===t?(h=o+1,r-=n+1):r=n}return h}const Ct=_t.bind(null,!0),kt=_t.bind(null,!1);var zt;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(zt||(zt={}));const Rt=30;class Nt{constructor(){this.Vr=[],this.Ir=new Map,this.Br=new Map,this.Ar=[]}Er(){return this.zr()>0?this.Vr[this.Vr.length-1]:null}Lr(){return this.zr()>0?this.Or(0):null}Ks(){return this.zr()>0?this.Or(this.Vr.length-1):null}zr(){return this.Vr.length}Ki(){return 0===this.zr()}Te(t){return null!==this.Nr(t,0)}Pr(t){return this.Wr(t)}Wr(t,i=0){const s=this.Nr(t,i);return null===s?null:{...this.Fr(s),Re:this.Or(s)}}Hr(){return this.Vr}Ur(t,i,s){if(this.Ki())return null;let e=null;for(const h of s)e=Et(e,this.$r(t,i,h));return e}ht(t){this.Br.clear(),this.Ir.clear(),this.Vr=t,this.Ar=t.map((t=>t.Re))}qr(){return this.Ar}Or(t){return this.Vr[t].Re}Fr(t){return this.Vr[t]}Nr(t,i){const s=this.Yr(t);if(null===s&&0!==i)switch(i){case-1:return this.jr(t);case 1:return this.Kr(t);default:throw new TypeError("Unknown search mode")}return s}jr(t){let i=this.Xr(t);return i>0&&(i-=1),i!==this.Vr.length&&this.Or(i)t.Ret.Re>i))}Gr(t,i,s){let e=null;for(let h=t;he.Qr&&(e.Qr=t)))}return e}$r(t,i,s){if(this.Ki())return null;let e=null;const h=d(this.Lr()),n=d(this.Ks()),r=Math.max(t,h),o=Math.min(i,n),l=Math.ceil(r/Rt)*Rt,a=Math.max(l,Math.floor(o/Rt)*Rt);{const t=this.Xr(r),h=this.Zr(Math.min(o,l,i));e=Et(e,this.Gr(t,h,s))}let u=this.Ir.get(s);void 0===u&&(u=new Map,this.Ir.set(s,u));for(let t=Math.max(l+1,r);tnew Tt(t)));return this.hh={nh:t,eh:i},i}jn(t,i){return this.ah.hitTest?.(t,i)??null}}let Vt=class extends Pt{us(){return[]}};class Bt{constructor(t){this.th=t}nt(t,i,s){this.th.draw(t)}ih(t,i,s){this.th.drawBackground?.(t)}}class Dt{constructor(t){this.Dn=null,this.sh=t}Tt(){const t=this.sh.renderer();if(null===t)return null;if(this.Dn?.nh===t)return this.Dn.eh;const i=new Bt(t);return this.Dn={nh:t,eh:i},i}rh(){return this.sh.zOrder?.()??"normal"}}function At(t){return{ri:t.text(),Bi:t.coordinate(),Ii:t.fixedCoordinate?.(),R:t.textColor(),Z:t.backColor(),Vt:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class Wt{constructor(t,i){this.Gt=new J,this._h=t,this.uh=i}Tt(){return this.Gt.ht({Qi:this.uh.Qi(),...At(this._h)}),this.Gt}}class Ft extends Q{constructor(t,i){super(),this._h=t,this.Yi=i}qi(t,i,s){const e=At(this._h);s.Z=e.Z,t.R=e.R;const h=2/12*this.Yi.k();s.Ti=h,s.Ri=h,s.Bi=e.Bi,s.Ii=e.Ii,t.ri=e.ri,t.Vt=e.Vt,t.pi=e.pi}}class Lt extends Pt{constructor(t,i){super(t),this.dh=null,this.fh=null,this.ph=null,this.mh=null,this.ge=i}cs(){const t=this.ah.timeAxisViews?.()??[];if(this.dh?.nh===t)return this.dh.eh;const i=this.ge.Qt().At(),s=t.map((t=>new Wt(t,i)));return this.dh={nh:t,eh:s},s}Fs(){const t=this.ah.priceAxisViews?.()??[];if(this.fh?.nh===t)return this.fh.eh;const i=this.ge.Wt(),s=t.map((t=>new Ft(t,i)));return this.fh={nh:t,eh:s},s}wh(){const t=this.ah.priceAxisPaneViews?.()??[];if(this.ph?.nh===t)return this.ph.eh;const i=t.map((t=>new Dt(t)));return this.ph={nh:t,eh:i},i}gh(){const t=this.ah.timeAxisPaneViews?.()??[];if(this.mh?.nh===t)return this.mh.eh;const i=t.map((t=>new Dt(t)));return this.mh={nh:t,eh:i},i}Mh(t,i){return this.ah.autoscaleInfo?.(t,i)??null}}function Ot(t,i,s,e){t.forEach((t=>{i(t).forEach((t=>{t.rh()===s&&e.push(t)}))}))}function It(t){return t.Ws()}function Qt(t){return t.wh()}function Xt(t){return t.gh()}const $t=["Area","Line","Baseline"];class Jt extends Mt{constructor(t,i,s,e,h){super(t),this.Yt=new Nt,this.er=new ft(this),this.bh=[],this.Sh=new at(this),this.xh=null,this.Ch=null,this.yh=null,this.kh=[],this.ys=s,this.Ph=i;const n=new pt(this);this.vs=[n],this.rr=new rt(n,this,t),$t.includes(this.Ph)&&(this.xh=new dt(this)),this.Th(),this.sh=e(this,this.Qt(),h)}m(){null!==this.yh&&clearTimeout(this.yh)}Be(t){return this.ys.priceLineColor||t}ke(t){const i={Pe:!0},s=this.Wt();if(this.Qt().At().Ki()||s.Ki()||this.Yt.Ki())return i;const e=this.Qt().At().ye(),h=this.zt();if(null===e||null===h)return i;let n,r;if(t){const t=this.Yt.Er();if(null===t)return i;n=t,r=t.Re}else{const t=this.Yt.Wr(e.bi(),-1);if(null===t)return i;if(n=this.Yt.Pr(t.Re),null===n)return i;r=t.Re}const o=n.Ft[3],l=this.Rh().Dr(r,{Ft:n}),a=s.Nt(o,h.Ft);return{Pe:!1,gt:o,ri:s.Zi(o,h.Ft),Oe:s.Dh(o), Ne:s.Vh(o,h.Ft),R:l.cr,Bi:a,Re:r}}Rh(){return null!==this.Ch||(this.Ch=new xt(this)),this.Ch}N(){return this.ys}hr(t){const i=t.priceScaleId;void 0!==i&&i!==this.ys.priceScaleId&&this.Qt().Ih(this,i),m(this.ys,t),void 0!==t.priceFormat&&(this.Th(),this.Qt().Bh()),this.Qt().Ah(this),this.Qt().Eh(),this.sh.kt("options")}ht(t,i){this.Yt.ht(t),this.sh.kt("data"),null!==this.xh&&(i&&i.zh?this.xh.be():0===t.length&&this.xh.Me());const s=this.Qt().Hn(this);this.Qt().Lh(s),this.Qt().Ah(this),this.Qt().Eh(),this.Qt().ar()}Oh(t){const i=new yt(this,t);return this.bh.push(i),this.Qt().Ah(this),i}Nh(t){const i=this.bh.indexOf(t);-1!==i&&this.bh.splice(i,1),this.Qt().Ah(this)}Wh(){return this.bh}Rr(){return this.Ph}zt(){const t=this.Fh();return null===t?null:{Ft:t.Ft[3],Hh:t.wt}}Fh(){const t=this.Qt().At().ye();if(null===t)return null;const i=t.Uh();return this.Yt.Wr(i,1)}Xs(){return this.Yt}$h(t){const i=this.Yt.Pr(t);return null===i?null:"Bar"===this.Ph||"Candlestick"===this.Ph||"Custom"===this.Ph?{qh:i.Ft[0],Yh:i.Ft[1],jh:i.Ft[2],Kh:i.Ft[3]}:i.Ft[3]}Xh(t){const i=[];Ot(this.kh,It,"top",i);const s=this.xh;return null!==s&&s.Vt()?(null===this.yh&&s.xe()&&(this.yh=setTimeout((()=>{this.yh=null,this.Qt().Zh()}),0)),s.Se(),i.unshift(s),i):i}Ws(){const t=[];this.Gh()||t.push(this.Sh),t.push(this.sh,this.er);const i=this.bh.map((t=>t.lr()));return t.push(...i),Ot(this.kh,It,"normal",t),t}Jh(){return this.Qh(It,"bottom")}ta(t){return this.Qh(Qt,t)}ia(t){return this.Qh(Xt,t)}sa(t,i){return this.kh.map((s=>s.jn(t,i))).filter((t=>null!==t))}us(){return[this.rr,...this.bh.map((t=>t._r()))]}Fs(t,i){if(i!==this.es&&!this.Gh())return[];const s=[...this.vs];for(const t of this.bh)s.push(t.ur());return this.kh.forEach((t=>{s.push(...t.Fs())})),s}cs(){const t=[];return this.kh.forEach((i=>{t.push(...i.cs())})),t}Mh(t,i){if(void 0!==this.ys.autoscaleInfoProvider){const s=this.ys.autoscaleInfoProvider((()=>{const s=this.na(t,i);return null===s?null:s.Xe()}));return vt.Ze(s)}return this.na(t,i)}ea(){return this.ys.priceFormat.minMove}ra(){return this.ha}Ns(){this.sh.kt();for(const t of this.vs)t.kt();for(const t of this.bh)t.kt();this.er.kt(),this.Sh.kt(),this.xh?.kt(),this.kh.forEach((t=>t.Ns()))}Wt(){return d(super.Wt())}Et(t){if("Line"!==this.Ph&&"Area"!==this.Ph&&"Baseline"!==this.Ph||!this.ys.crosshairMarkerVisible)return null;const i=this.Yt.Pr(t);return null===i?null:{gt:i.Ft[3],ft:this.aa(),Ht:this.la(),Ot:this.oa(),Lt:this._a(t)}}Ae(){return this.ys.title}Vt(){return this.ys.visible}ua(t){this.kh.push(new Lt(t,this))}ca(t){this.kh=this.kh.filter((i=>i.oh()!==t))}da(){if("Custom"===this.Ph)return t=>this.sh.fa(t)}pa(){if("Custom"===this.Ph)return t=>this.sh.va(t)}ma(){return this.Yt.qr()}Gh(){return!G(this.Wt().wa())}na(t,i){if(!v(t)||!v(i)||this.Yt.Ki())return null;const s="Line"===this.Ph||"Area"===this.Ph||"Baseline"===this.Ph||"Histogram"===this.Ph?[3]:[2,1],e=this.Yt.Ur(t,i,s);let h=null!==e?new gt(e.Jr,e.Qr):null,n=null;if("Histogram"===this.Rr()){const t=this.ys.base,i=new gt(t,t);h=null!==h?h.vn(i):i}return this.kh.forEach((s=>{ const e=s.Mh(t,i);if(e?.priceRange){const t=new gt(e.priceRange.minValue,e.priceRange.maxValue);h=null!==h?h.vn(t):t}e?.margins&&(n=e.margins)})),new vt(h,n)}aa(){switch(this.Ph){case"Line":case"Area":case"Baseline":return this.ys.crosshairMarkerRadius}return 0}la(){switch(this.Ph){case"Line":case"Area":case"Baseline":{const t=this.ys.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}oa(){switch(this.Ph){case"Line":case"Area":case"Baseline":return this.ys.crosshairMarkerBorderWidth}return 0}_a(t){switch(this.Ph){case"Line":case"Area":case"Baseline":{const t=this.ys.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Rh().Dr(t).cr}Th(){switch(this.ys.priceFormat.type){case"custom":this.ha={format:this.ys.priceFormat.formatter};break;case"volume":this.ha=new st(this.ys.priceFormat.precision);break;case"percent":this.ha=new it(this.ys.priceFormat.precision);break;default:{const t=Math.pow(10,this.ys.priceFormat.precision);this.ha=new tt(t,this.ys.priceFormat.minMove*t)}}null!==this.es&&this.es.ga()}Qh(t,i){const s=[];return Ot(this.kh,t,i,s),s}}const qt=[3],Ut=[0,1,2,3];class Zt{constructor(t){this.ys=t}Ma(t,i,s){let e=t;if(0===this.ys.mode)return e;const h=s.Ps(),n=h.zt();if(null===n)return e;const r=h.Nt(t,n),o=s.ba().filter((t=>t instanceof Jt)).reduce(((t,e)=>{if(s.Un(e)||!e.Vt())return t;const h=e.Wt(),n=e.Xs();if(h.Ki()||!n.Te(i))return t;const r=n.Pr(i);if(null===r)return t;const o=f(e.zt()),l=3===this.ys.mode?Ut:qt;return t.concat(l.map((t=>h.Nt(r.Ft[t],o.Ft))))}),[]);if(0===o.length)return e;o.sort(((t,i)=>Math.abs(t-r)-Math.abs(i-r)));const l=o[0];return e=h.Ts(l,n),e}}function Kt(t,i,s){return Math.min(Math.max(t,i),s)}function Gt(t,i,s){return i-t<=s}class Ht extends E{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;const h=Math.max(1,Math.floor(s));t.lineWidth=h,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const n=d(this.Yt);if(n.Sa){t.strokeStyle=n.xa,l(t,n.Ca),t.beginPath();for(const e of n.ya){const n=Math.round(e.ka*s);t.moveTo(n,-h),t.lineTo(n,i.height+h)}t.stroke()}if(n.Pa){t.strokeStyle=n.Ta,l(t,n.Ra),t.beginPath();for(const s of n.Da){const n=Math.round(s.ka*e);t.moveTo(-h,n),t.lineTo(i.width+h,n)}t.stroke()}}))}}class jt{constructor(t){this.Gt=new Ht,this.xt=!0,this.yt=t}kt(){this.xt=!0}Tt(){if(this.xt){const t=this.yt.Qt().N().grid,i={Pa:t.horzLines.visible,Sa:t.vertLines.visible,Ta:t.horzLines.color,xa:t.vertLines.color,Ra:t.horzLines.style,Ca:t.vertLines.style,Da:this.yt.Ps().Va(),ya:(this.yt.Qt().At().Va()||[]).map((t=>({ka:t.coord})))};this.Gt.ht(i),this.xt=!1}return this.Gt}}class ti{constructor(t){this.sh=new jt(t)}lr(){return this.sh}}const ii={Ia:4,Ba:1e-4};function si(t,i){const s=100*(t-i)/i;return i<0?-s:s}function ei(t,i){const s=si(t.$e(),i),e=si(t.qe(),i);return new gt(s,e)}function hi(t,i){const s=100*(t-i)/i+100;return i<0?-s:s}function ni(t,i){const s=hi(t.$e(),i),e=hi(t.qe(),i);return new gt(s,e)} function ri(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const e=Math.log10(s+i.Ba)+i.Ia;return t<0?-e:e}function oi(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const e=Math.pow(10,s-i.Ia)-i.Ba;return t<0?-e:e}function li(t,i){if(null===t)return null;const s=ri(t.$e(),i),e=ri(t.qe(),i);return new gt(s,e)}function ai(t,i){if(null===t)return null;const s=oi(t.$e(),i),e=oi(t.qe(),i);return new gt(s,e)}function ui(t){if(null===t)return ii;const i=Math.abs(t.qe()-t.$e());if(i>=1||i<1e-15)return ii;const s=Math.ceil(Math.abs(Math.log10(i))),e=ii.Ia+s;return{Ia:e,Ba:1/Math.pow(10,e)}}class ci{constructor(t,i){if(this.Aa=t,this.Ea=i,function(t){if(t<0)return!1;for(let i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Aa))this.za=[2,2.5,2];else{this.za=[];for(let t=this.Aa;1!==t;){if(t%2==0)this.za.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.za.push(2,2.5),t/=5}if(this.za.length>100)throw new Error("something wrong with base")}}}La(t,i,s){const e=0===this.Aa?0:1/this.Aa;let h=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),n=0,r=this.Ea[0];for(;;){const t=Gt(h,e,1e-14)&&h>e+1e-14,i=Gt(h,s*r,1e-14),o=Gt(h,1,1e-14);if(!(t&&i&&o))break;h/=r,r=this.Ea[++n%this.Ea.length]}if(h<=e+1e-14&&(h=e),h=Math.max(1,h),this.za.length>0&&(o=h,Math.abs(o-1)<1e-14))for(n=0,r=this.za[0];Gt(h,s*r,1e-14)&&h>e+1e-14;)h/=r,r=this.za[++n%this.za.length];var o;return h}}class di{constructor(t,i,s,e){this.Oa=[],this.Yi=t,this.Aa=i,this.Na=s,this.Wa=e}La(t,i){if(t=e?1:-1;let u=null,c=0;for(let d=s-l;d>e;d-=i){const s=this.Wa(d,t,!0);null!==u&&Math.abs(s-u)n||(c0&&r[0].ka-o.ka0&&l.ka-r[r.length-1].kad(t.hs())-d(i.hs())))}var pi;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(pi||(pi={}));const mi=new it,gi=new tt(100,1);class vi{constructor(t,i,s,e,h){this.tl=0,this.il=null,this.Ge=null,this.sl=null,this.nl={el:!1,rl:null},this.hl=!1,this.al=0,this.ll=0,this.ol=new p,this._l=new p,this.ul=[],this.cl=null,this.dl=null,this.fl=null,this.pl=null,this.vl=null,this.ha=gi,this.ml=ui(null),this.wl=t,this.ys=i,this.gl=s,this.Ml=e,this.bl=h,this.Sl=new di(this,100,this.xl.bind(this),this.Cl.bind(this))}wa(){return this.wl}N(){return this.ys}hr(t){if(m(this.ys,t),this.ga(),void 0!==t.mode&&this.yl({ie:t.mode}),void 0!==t.scaleMargins){const i=c(t.scaleMargins.top),s=c(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(i+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+s}`);this.kl(),this.fl=null}}Pl(){return this.ys.autoScale}Tl(){return this.hl}Ga(){return 1===this.ys.mode}Le(){return 2===this.ys.mode}Rl(){return 3===this.ys.mode}Qa(){return this.ml}ie(){return{sn:this.ys.autoScale,Dl:this.ys.invertScale,ie:this.ys.mode}}yl(t){const i=this.ie();let s=null;void 0!==t.sn&&(this.ys.autoScale=t.sn),void 0!==t.ie&&(this.ys.mode=t.ie,2!==t.ie&&3!==t.ie||(this.ys.autoScale=!0),this.nl.el=!1),1===i.ie&&t.ie!==i.ie&&(function(t,i){if(null===t)return!1;const s=oi(t.$e(),i),e=oi(t.qe(),i);return isFinite(s)&&isFinite(e)}(this.Ge,this.ml)?(s=ai(this.Ge,this.ml),null!==s&&this.Vl(s)):this.ys.autoScale=!0),1===t.ie&&t.ie!==i.ie&&(s=li(this.Ge,this.ml),null!==s&&this.Vl(s));const e=i.ie!==this.ys.mode;e&&(2===i.ie||this.Le())&&this.ga(),e&&(3===i.ie||this.Rl())&&this.ga(),void 0!==t.Dl&&i.Dl!==t.Dl&&(this.ys.invertScale=t.Dl,this.Il()),this._l.p(i,this.ie())}Bl(){return this._l}k(){return this.gl.fontSize}$t(){return this.tl}Al(t){this.tl!==t&&(this.tl=t,this.kl(),this.fl=null)}El(){if(this.il)return this.il;const t=this.$t()-this.zl()-this.Ll();return this.il=t,t}Qe(){return this.Ol(),this.Ge}Vl(t,i){const s=this.Ge;(i||null===s&&null!==t||null!==s&&!s.He(t))&&(this.fl=null,this.Ge=t)}Nl(t){this.Vl(t),this.Wl(null!==t)}Ki(){return this.Ol(),0===this.tl||!this.Ge||this.Ge.Ki()}Fl(t){return this.Dl()?t:this.$t()-1-t}Nt(t,i){return this.Le()?t=si(t,i):this.Rl()&&(t=hi(t,i)),this.Cl(t,i)}Hl(t,i,s){this.Ol();const e=this.Ll(),h=d(this.Qe()),n=h.$e(),r=h.qe(),o=this.El()-1,l=this.Dl(),a=o/(r-n),u=void 0===s?0:s.from,c=void 0===s?t.length:s.to,f=this.Ul();for(let s=u;st.Ns()))}qa(){return this.ys.ensureEdgeTickMarksVisible&&this.Pl()}ja(){return this.k()/2}ga(){this.fl=null;let t=1/0;this.cl=null;for(const i of this.ul)i.hs()ri(t,this.ml):null}co(t,i,s){return void 0===i?(void 0===s&&(s=this.ra()),s.format(t)):i(t)}nr(t,i){return this.co(t,this.Ml.priceFormatter,i)}lo(t,i){return this.co(t,this.Ml.percentageFormatter,i)}}function wi(t){return t instanceof Jt}class bi{constructor(t,i){this.ul=[],this.do=new Map,this.tl=0,this.fo=0,this.po=1e3,this.dl=null,this.vo=new p,this.kh=[],this.uh=t,this.ts=i,this.mo=new ti(this);const s=i.N();this.wo=this.Mo("left",s.leftPriceScale),this.bo=this.Mo("right",s.rightPriceScale),this.wo.Bl().i(this.So.bind(this,this.wo),this),this.bo.Bl().i(this.So.bind(this,this.bo),this),this.xo(s)}xo(t){if(t.leftPriceScale&&this.wo.hr(t.leftPriceScale),t.rightPriceScale&&this.bo.hr(t.rightPriceScale),t.localization&&(this.wo.ga(),this.bo.ga()),t.overlayPriceScales){const i=Array.from(this.do.values());for(const s of i){const i=d(s[0].Wt());i.hr(t.overlayPriceScales),t.localization&&i.ga()}}}Co(t){switch(t){case"left":return this.wo;case"right":return this.bo}return this.do.has(t)?c(this.do.get(t))[0].Wt():null}m(){this.Qt().yo().u(this),this.wo.Bl().u(this),this.bo.Bl().u(this),this.ul.forEach((t=>{t.m&&t.m()})),this.kh=this.kh.filter((t=>{const i=t.oh();return i.detached&&i.detached(),!1})),this.vo.p()}ko(){return this.po}Po(t){this.po=t}Qt(){return this.ts}Qi(){return this.fo}$t(){return this.tl}To(t){this.fo=t,this.Ro()}Al(t){this.tl=t,this.wo.Al(t),this.bo.Al(t),this.ul.forEach((i=>{if(this.Un(i)){const s=i.Wt();null!==s&&s.Al(t)}})),this.Ro()}Do(){return this.ul.filter(wi)}ba(){return this.ul}Un(t){const i=t.Wt();return null===i||this.wo!==i&&this.bo!==i}Zl(t,i,s){this.Vo(t,i,s?t.hs():this.ul.length)}Jl(t,i){ const s=this.ul.indexOf(t);u(-1!==s,"removeDataSource: invalid data source"),this.ul.splice(s,1),i||this.ul.forEach(((t,i)=>t.ls(i)));const e=d(t.Wt()).wa();if(this.do.has(e)){const i=c(this.do.get(e)),s=i.indexOf(t);-1!==s&&(i.splice(s,1),0===i.length&&this.do.delete(e))}const h=t.Wt();h&&h.ba().indexOf(t)>=0&&(h.Jl(t),this.Io(h)),this.dl=null}qn(t){return t===this.wo?"left":t===this.bo?"right":"overlay"}Bo(){return this.wo}Ao(){return this.bo}Eo(t,i){t.so(i)}zo(t,i){t.no(i),this.Ro()}Lo(t){t.eo()}Oo(t,i){t.ro(i)}No(t,i){t.ho(i),this.Ro()}Wo(t){t.ao()}Ro(){this.ul.forEach((t=>{t.Ns()}))}Ps(){let t=null;return this.ts.N().rightPriceScale.visible&&0!==this.bo.ba().length?t=this.bo:this.ts.N().leftPriceScale.visible&&0!==this.wo.ba().length?t=this.wo:0!==this.ul.length&&(t=this.ul[0].Wt()),null===t&&(t=this.bo),t}$n(){let t=null;return this.ts.N().rightPriceScale.visible?t=this.bo:this.ts.N().leftPriceScale.visible&&(t=this.wo),t}Io(t){null!==t&&t.Pl()&&this.Fo(t)}Ho(t){const i=this.uh.ye();t.yl({sn:!0}),null!==i&&t._o(i),this.Ro()}Uo(){this.Fo(this.wo),this.Fo(this.bo)}$o(){this.Io(this.wo),this.Io(this.bo),this.ul.forEach((t=>{this.Un(t)&&this.Io(t.Wt())})),this.Ro(),this.ts.ar()}Dt(){return null===this.dl&&(this.dl=fi(this.ul)),this.dl}qo(t,i){i=Kt(i,0,this.ul.length-1);const s=this.ul.indexOf(t);u(-1!==s,"setSeriesOrder: invalid data source"),this.ul.splice(s,1),this.ul.splice(i,0,t),this.ul.forEach(((t,i)=>t.ls(i))),this.dl=null;for(const t of[this.wo,this.bo])t.Gl(),t.ga();this.ts.ar()}It(){return this.Dt().filter(wi)}Yo(){return this.vo}jo(){return this.mo}ua(t){this.kh.push(new Vt(t))}ca(t){this.kh=this.kh.filter((i=>i.oh()!==t)),t.detached&&t.detached(),this.ts.ar()}Ko(){return this.kh}sa(t,i){return this.kh.map((s=>s.jn(t,i))).filter((t=>null!==t))}Fo(t){const i=t.oo();if(i&&i.length>0&&!this.uh.Ki()){const i=this.uh.ye();null!==i&&t._o(i)}t.Ns()}Vo(t,i,s){let e=this.Co(i);if(null===e&&(e=this.Mo(i,this.ts.N().overlayPriceScales)),this.ul.splice(s,0,t),!G(i)){const s=this.do.get(i)||[];s.push(t),this.do.set(i,s)}t.ls(s),e.Zl(t),t._s(e),this.Io(e),this.dl=null}So(t,i,s){i.ie!==s.ie&&this.Fo(t)}Mo(t,i){const s={visible:!0,autoScale:!0,...y(i)},e=new vi(t,s,this.ts.N().layout,this.ts.N().localization,this.ts.Xi());return e.Al(this.$t()),e}}function yi(t){return{Xo:t.Xo,Zo:{Kn:t.Go.externalId},Jo:t.Go.cursorStyle}}function Mi(t,i,s,e){for(const h of t){const t=h.Tt(e);if(null!==t&&t.jn){const e=t.jn(i,s);if(null!==e)return{Qo:h,Zo:e}}}return null}function Si(t){return void 0!==t.Ws}function xi(t,i,s){const e=[t,...t.Dt()],h=function(t,i,s){let e,h;for(const o of t){const t=o.sa?.(i,s)??[];for(const i of t)n=i.zOrder,r=e?.zOrder,(!r||"top"===n&&"top"!==r||"normal"===n&&"bottom"===r)&&(e=i,h=o)}var n,r;return e&&h?{Go:e,Xo:h}:null}(e,i,s);if("top"===h?.Go.zOrder)return yi(h);for(const n of e){if(h&&h.Xo===n&&"bottom"!==h.Go.zOrder&&!h.Go.isBackground)return yi(h);if(Si(n)){const e=Mi(n.Ws(t),i,s,t);if(null!==e)return{Xo:n,Qo:e.Qo,Zo:e.Zo}}if(h&&h.Xo===n&&"bottom"!==h.Go.zOrder&&h.Go.isBackground)return yi(h)} return h?.Go?yi(h):null}class _i{constructor(t,i,s=50){this.kn=0,this.Pn=1,this.Tn=1,this.Dn=new Map,this.Rn=new Map,this.t_=t,this.i_=i,this.Vn=s}s_(t){const i=t.time,s=this.i_.cacheKey(i),e=this.Dn.get(s);if(void 0!==e)return e.n_;if(this.kn===this.Vn){const t=this.Rn.get(this.Tn);this.Rn.delete(this.Tn),this.Dn.delete(c(t)),this.Tn++,this.kn--}const h=this.t_(t);return this.Dn.set(s,{n_:h,En:this.Pn}),this.Rn.set(this.Pn,s),this.kn++,this.Pn++,h}}class Ci{constructor(t,i){u(t<=i,"right should be >= left"),this.e_=t,this.r_=i}Uh(){return this.e_}bi(){return this.r_}h_(){return this.r_-this.e_+1}Te(t){return this.e_<=t&&t<=this.r_}He(t){return this.e_===t.Uh()&&this.r_===t.bi()}}function ki(t,i){return null===t||null===i?t===i:t.He(i)}class zi{constructor(){this.a_=new Map,this.Dn=null,this.l_=!1}o_(t){this.l_=t,this.Dn=null}__(t,i){this.u_(i),this.Dn=null;for(let s=i;s{t<=s[0].index?i.push(e):s.splice(Ct(s,t,(i=>i.index!i||s.has(t.index);for(const i of Array.from(this.a_.keys()).sort(((t,i)=>i-t))){if(!this.a_.get(i))continue;const s=e;e=[];const n=s.length;let r=0;const o=c(this.a_.get(i)),l=o.length;let a=1/0,u=-1/0;for(let i=0;i=t&&c-u>=t&&h(l))e.push(l),u=c;else if(this.l_)return s}for(;ri.weight?t:i}class Ei{constructor(t,i,s,e){this.fo=0,this.b_=null,this.S_=[],this.vl=null,this.pl=null,this.x_=new zi,this.C_=new Map,this.y_=Ri.M_(),this.k_=!0,this.P_=new p,this.T_=new p,this.R_=new p,this.D_=null,this.V_=null,this.I_=new Map,this.B_=-1,this.A_=[],this.ys=i,this.Ml=s,this.E_=i.rightOffset,this.z_=i.barSpacing,this.ts=t,this.i_=e,this.L_(),this.x_.o_(i.uniformDistribution),this.O_()}N(){return this.ys}N_(t){m(this.Ml,t),this.W_(),this.L_()}hr(t,i){m(this.ys,t),this.ys.fixLeftEdge&&this.F_(),this.ys.fixRightEdge&&this.H_(),void 0!==t.barSpacing&&this.ts.dn(t.barSpacing),void 0!==t.rightOffset&&this.ts.fn(t.rightOffset),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.ts.dn(t.barSpacing??this.z_),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.ys.ignoreWhitespaceIndices&&this.O_(),this.W_(),this.L_(),this.R_.p()}Rs(t){return this.S_[t]?.time??null}ss(t){return this.S_[t]??null}U_(t,i){if(this.S_.length<1)return null ;if(this.i_.key(t)>this.i_.key(this.S_[this.S_.length-1].time))return i?this.S_.length-1:null;const s=Ct(this.S_,this.i_.key(t),((t,i)=>this.i_.key(t.time)0}ye(){return this.Y_(),this.y_.w_()}j_(){return this.Y_(),this.y_.g_()}K_(){const t=this.ye();if(null===t)return null;const i={from:t.Uh(),to:t.bi()};return this.X_(i)}X_(t){const i=Math.round(t.from),s=Math.round(t.to),e=d(this.Z_()),h=d(this.G_());return{from:d(this.ss(Math.max(e,i))),to:d(this.ss(Math.min(h,s)))}}J_(t){return{from:d(this.U_(t.from,!0)),to:d(this.U_(t.to,!0))}}Qi(){return this.fo}To(t){if(!isFinite(t)||t<=0)return;if(this.fo===t)return;const i=this.j_(),s=this.fo;if(this.fo=t,this.k_=!0,this.ys.lockVisibleTimeRangeOnResize&&0!==s){const i=this.z_*t/s;this.z_=i}if(this.ys.fixLeftEdge&&null!==i&&i.Uh()<=0){const i=s-t;this.E_-=Math.round(i/this.z_)+1,this.k_=!0}this.Q_(),this.tu()}qt(t){if(this.Ki()||!v(t))return 0;const i=this.iu()+this.E_-t;return this.fo-(i+.5)*this.z_-1}su(t,i){const s=this.iu(),e=void 0===i?0:i.from,h=void 0===i?t.length:i.to;for(let i=e;ii/2&&!a?s.needAlignCoordinate=!1:s.needAlignCoordinate=u&&t.index<=o||c&&t.index>=l,f++}return this.A_.length=f,this.V_=this.A_,this.A_}du(){this.k_=!0,this.dn(this.ys.barSpacing),this.fn(this.ys.rightOffset)}fu(t){this.k_=!0,this.b_=t,this.tu(),this.F_()}pu(t,i){const s=this.eu(t),e=this.lu(),h=e+i*(e/10);this.dn(h),this.ys.rightBarStaysOnScroll||this.fn(this._u()+(s-this.eu(t)))}so(t){this.vl&&this.ao(),null===this.pl&&null===this.D_&&(this.Ki()||(this.pl=t,this.vu()))}no(t){if(null===this.D_)return;const i=Kt(this.fo-t,0,this.fo),s=Kt(this.fo-d(this.pl),0,this.fo);0!==i&&0!==s&&this.dn(this.D_.lu*i/s)}eo(){null!==this.pl&&(this.pl=null,this.mu())}ro(t){null===this.vl&&null===this.D_&&(this.Ki()||(this.vl=t,this.vu()))}ho(t){if(null===this.vl)return;const i=(this.vl-t)/this.lu();this.E_=d(this.D_)._u+i,this.k_=!0,this.tu()}ao(){ null!==this.vl&&(this.vl=null,this.mu())}wu(){this.gu(this.ys.rightOffset)}gu(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.E_,e=performance.now();this.ts._n({Mu:t=>(t-e)/i>=1,bu:h=>{const n=(h-e)/i;return n>=1?t:s+(t-s)*n}})}kt(t,i){this.k_=!0,this.S_=t,this.x_.__(t,i),this.tu()}Su(){return this.P_}xu(){return this.T_}Cu(){return this.R_}iu(){return this.b_||0}yu(t){const i=t.h_();this.ou(this.fo/i),this.E_=t.bi()-this.iu(),this.tu(),this.k_=!0,this.ts.au(),this.ts.ar()}ku(){const t=this.Z_(),i=this.G_();null!==t&&null!==i&&this.yu(new Ci(t,i+this.ys.rightOffset))}Pu(t){const i=new Ci(t.from,t.to);this.yu(i)}ns(t){return void 0!==this.Ml.timeFormatter?this.Ml.timeFormatter(t.originalTime):this.i_.formatHorzItem(t.time)}O_(){if(!this.ys.ignoreWhitespaceIndices)return;this.I_.clear();const t=this.ts.js();for(const i of t)for(const t of i.ma())this.I_.set(t,!0);this.B_++}uu(){const t=this.ts.N().handleScroll,i=this.ts.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}Z_(){return 0===this.S_.length?null:0}G_(){return 0===this.S_.length?null:this.S_.length-1}Tu(t){return(this.fo-1-t)/this.z_}eu(t){const i=this.Tu(t),s=this.iu()+this.E_-i;return Math.round(1e6*s)/1e6}ou(t){const i=this.z_;this.z_=t,this.Q_(),i!==this.z_&&(this.k_=!0,this.Ru())}Y_(){if(!this.k_)return;if(this.k_=!1,this.Ki())return void this.Du(Ri.M_());const t=this.iu(),i=this.fo/this.z_,s=this.E_+t,e=new Ci(s-i+1,s);this.Du(new Ri(e))}Q_(){const t=Kt(this.z_,this.Vu(),this.Iu());this.z_!==t&&(this.z_=t,this.k_=!0)}Iu(){return this.ys.maxBarSpacing>0?this.ys.maxBarSpacing:.5*this.fo}Vu(){return this.ys.fixLeftEdge&&this.ys.fixRightEdge&&0!==this.S_.length?this.fo/this.S_.length:this.ys.minBarSpacing}tu(){const t=this.Bu();null!==t&&this.E_i&&(this.E_=i,this.k_=!0)}Bu(){const t=this.Z_(),i=this.b_;return null===t||null===i?null:t-i-1+(this.ys.fixLeftEdge?this.fo/this.z_:Math.min(2,this.S_.length))}Au(){return this.ys.fixRightEdge?0:this.fo/this.z_-Math.min(2,this.S_.length)}vu(){this.D_={lu:this.lu(),_u:this._u()}}mu(){this.D_=null}cu(t){let i=this.C_.get(t.weight);return void 0===i&&(i=new _i((t=>this.Eu(t)),this.i_),this.C_.set(t.weight,i)),i.s_(t)}Eu(t){return this.i_.formatTickmark(t,this.Ml)}Du(t){const i=this.y_;this.y_=t,ki(i.w_(),this.y_.w_())||this.P_.p(),ki(i.g_(),this.y_.g_())||this.T_.p(),this.Ru()}Ru(){this.V_=null}W_(){this.Ru(),this.C_.clear()}L_(){this.i_.updateFormatter(this.Ml)}F_(){if(!this.ys.fixLeftEdge)return;const t=this.Z_();if(null===t)return;const i=this.ye();if(null===i)return;const s=i.Uh()-t;if(s<0){const t=this.E_-s-1;this.fn(t)}this.Q_()}H_(){this.tu(),this.Q_()}ru(t){return!this.ys.ignoreWhitespaceIndices||this.I_.get(t)||!1}hu(t){const i=function*(t){const i=Math.round(t),s=is)break}return t}}var Yi,Ti,Pi,Vi,Bi;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Yi||(Yi={}));class Di{constructor(t,i,s){this.zu=[],this.Lu=[],this.fo=0,this.Ou=null,this.Nu=new p,this.Wu=new p,this.Fu=null,this.Hu=t,this.ys=i,this.i_=s,this.bl=new R(this.ys.layout.colorParsers),this.Uu=new C(this),this.uh=new Ei(this,i.timeScale,this.ys.localization,s),this.Ct=new K(this,i.crosshair),this.$u=new Zt(i.crosshair),this.qu(0),this.zu[0].Po(2e3),this.Yu=this.ju(0),this.Ku=this.ju(1)}Bh(){this.Xu(H.gn())}ar(){this.Xu(H.wn())}Zh(){this.Xu(new H(1))}Ah(t){const i=this.Zu(t);this.Xu(i)}Gu(){return this.Ou}Ju(t){if(this.Ou?.Xo===t?.Xo&&this.Ou?.Zo?.Kn===t?.Zo?.Kn)return;const i=this.Ou;this.Ou=t,null!==i&&this.Ah(i.Xo),null!==t&&t.Xo!==i?.Xo&&this.Ah(t.Xo)}N(){return this.ys}hr(t){m(this.ys,t),this.zu.forEach((i=>i.xo(t))),void 0!==t.timeScale&&this.uh.hr(t.timeScale),void 0!==t.localization&&this.uh.N_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Nu.p(),this.Yu=this.ju(0),this.Ku=this.ju(1),this.Bh()}Qu(t,i,s=0){const e=this.zu[s];if(void 0===e)return;if("left"===t)return m(this.ys,{leftPriceScale:i}),e.xo({leftPriceScale:i}),this.Nu.p(),void this.Bh();if("right"===t)return m(this.ys,{rightPriceScale:i}),e.xo({rightPriceScale:i}),this.Nu.p(),void this.Bh();const h=this.tc(t,s);null!==h&&(h.Wt.hr(i),this.Nu.p())}tc(t,i){const s=this.zu[i];if(void 0===s)return null;const e=s.Co(t);return null!==e?{Us:s,Wt:e}:null}At(){return this.uh}$s(){return this.zu}sc(){return this.Ct}nc(){return this.Wu}ec(t,i){t.Al(i),this.au()}To(t){this.fo=t,this.uh.To(this.fo),this.zu.forEach((i=>i.To(t))),this.au()}rc(t){1!==this.zu.length&&(u(t>=0&&t=0&&tt+i.ko()),0),h=this.zu.reduce(((t,i)=>t+i.$t()),0),n=h-30*(this.zu.length-1);i=Math.min(n,Math.max(30,i));const r=e/h,o=s.$t();s.Po(i*r);let l=i-o,a=this.zu.length-1;for(const t of this.zu)if(t!==s){const i=Math.min(n,Math.max(30,t.$t()-l/a));l-=t.$t()-i,a-=1;const s=i*r;t.Po(s)}this.Bh()}ac(t,i){u(t>=0&&t=0&&ithis.i_.key(h),l=null!==t&&t>n&&!o,a=this.uh.N().allowShiftVisibleRangeOnWhitespaceReplacement,u=i&&(!(void 0===s)||a)&&this.uh.N().shiftVisibleRangeOnNewBar;if(l&&!u){const i=t-n;this.uh.fn(this.uh._u()-i)}}this.uh.fu(t)}Lh(t){null!==t&&t.$o()}Hn(t){if(function(t){return t instanceof bi}(t))return t;const i=this.zu.find((i=>i.Dt().includes(t)));return void 0===i?null:i}au(){this.zu.forEach((t=>t.$o())),this.Eh()}m(){this.zu.forEach((t=>t.m())),this.zu.length=0,this.ys.localization.priceFormatter=void 0,this.ys.localization.percentageFormatter=void 0,this.ys.localization.timeFormatter=void 0}Sc(){return this.Uu}Yn(){return this.Uu.N()}yo(){return this.Nu}xc(t,i){const s=this.qu(i);this.Cc(t,s),this.Lu.push(t),1===this.Lu.length?this.Bh():this.ar()}yc(t){const i=this.Hn(t),s=this.Lu.indexOf(t);u(-1!==s,"Series not found");const e=d(i);this.Lu.splice(s,1),e.Jl(t),t.m&&t.m(),this.uh.O_(),this.kc(e)}Ih(t,i){const s=d(this.Hn(t));s.Jl(t,!0),s.Zl(t,i,!0)}ku(){const t=H.wn();t.rn(),this.Xu(t)}Pc(t){const i=H.wn();i.ln(t),this.Xu(i)}cn(){const t=H.wn();t.cn(),this.Xu(t)}dn(t){const i=H.wn();i.dn(t),this.Xu(i)}fn(t){const i=H.wn();i.fn(t),this.Xu(i)}_n(t){const i=H.wn();i._n(t),this.Xu(i)}hn(){const t=H.wn();t.hn(),this.Xu(t)}Tc(){return this.ys.rightPriceScale.visible?"right":"left"}Rc(t,i){if(u(i>=0,"Index should be greater or equal to 0"),i===this.Dc(t))return;const s=d(this.Hn(t));s.Jl(t);const e=this.qu(i);this.Cc(t,e),0===s.ba().length&&this.kc(s)}Vc(){return this.Ku}$(){return this.Yu}Ut(t){const i=this.Ku,s=this.Yu;if(i===s)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Fu||this.Fu.mr!==s||this.Fu.wr!==i)this.Fu={mr:s,wr:i,Ic:new Map};else{const i=this.Fu.Ic.get(t);if(void 0!==i)return i}const e=this.bl.tt(s,i,t/100);return this.Fu.Ic.set(t,e),e}Bc(t){return this.zu.indexOf(t)}Xi(){return this.bl}qu(t){if(u(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.zu.length,t))i.Do().includes(t)))}lc(t,i){const s=new H(i);if(null!==t){const e=this.zu.indexOf(t);s.Qs(e,{tn:i})}return s}Zu(t,i){return void 0===i&&(i=2), this.lc(this.Hn(t),i)}Xu(t){this.Hu&&this.Hu(t),this.zu.forEach((t=>t.jo().lr().kt()))}Cc(t,i){const s=t.N().priceScaleId,e=void 0!==s?s:this.Tc();i.Zl(t,e),G(e)||t.hr(t.N())}ju(t){const i=this.ys.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}kc(t){0===t.ba().length&&this.zu.length>1&&(this.zu.splice(this.Bc(t),1),this.Bh())}}function Ai(t){return!g(t)&&!w(t)}function Wi(t){return g(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Ti||(Ti={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Pi||(Pi={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Vi||(Vi={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Bi||(Bi={}));const Fi=t=>t.getUTCFullYear();class Li{constructor(t="yyyy-MM-dd",i="default"){this.Ac=t,this.Ec=i}s_(t){return function(t,i,s){return i.replace(/yyyy/g,(t=>j(Fi(t),4))(t)).replace(/yy/g,(t=>j(Fi(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,s)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,s)).replace(/MM/g,(t=>j((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>j((t=>t.getUTCDate())(t),2))(t))}(t,this.Ac,this.Ec)}}class Oi{constructor(t){this.zc=t||"%h:%m:%s"}s_(t){return this.zc.replace("%h",j(t.getUTCHours(),2)).replace("%m",j(t.getUTCMinutes(),2)).replace("%s",j(t.getUTCSeconds(),2))}}const Ii={Lc:"yyyy-MM-dd",Oc:"%h:%m:%s",Nc:" ",Wc:"default"};class Qi{constructor(t={}){const i={...Ii,...t};this.Fc=new Li(i.Lc,i.Wc),this.Hc=new Oi(i.Oc),this.Uc=i.Nc}s_(t){return`${this.Fc.s_(t)}${this.Uc}${this.Hc.s_(t)}`}}function Xi(t){return 60*t*60*1e3}function $i(t){return 60*t*1e3}const Ji=[{$c:1e3,qc:10},{$c:$i(1),qc:20},{$c:$i(5),qc:21},{$c:$i(30),qc:22},{$c:Xi(1),qc:30},{$c:Xi(3),qc:31},{$c:Xi(6),qc:32},{$c:Xi(12),qc:33}];function qi(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let s=Ji.length-1;s>=0;--s)if(Math.floor(i.getTime()/Ji[s].$c)!==Math.floor(t.getTime()/Ji[s].$c))return Ji[s].qc;return 0}function Ui(t){let i=t;if(w(t)&&(i=Ki(t)),!Ai(i))throw new Error("time must be of type BusinessDay");const s=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{Yc:Math.round(s.getTime()/1e3),jc:i}}function Zi(t){if(!Wi(t))throw new Error("time must be of type isUTCTimestamp");return{Yc:t}}function Ki(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function Gi(t){w(t.time)&&(t.time=Ki(t.time))}class Hi{options(){return this.ys}setOptions(t){this.ys=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(Gi)}(t):Gi(t)} createConverterToInternalObj(t){return d(function(t){return 0===t.length?null:Ai(t[0].time)||w(t[0].time)?Ui:Zi}(t))}key(t){return"object"==typeof t&&"Yc"in t?t.Yc:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.jc?new Date(1e3*i.Yc).getTime():new Date(Date.UTC(i.jc.year,i.jc.month-1,i.jc.day)).getTime()}convertHorzItemToInternal(t){return Wi(i=t)?Zi(i):Ai(i)?Ui(i):Ui(Ki(i));var i}updateFormatter(t){if(!this.ys)return;const i=t.dateFormat;this.ys.timeScale.timeVisible?this.Kc=new Qi({Lc:i,Oc:this.ys.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",Nc:" ",Wc:t.locale}):this.Kc=new Li(i,t.locale)}formatHorzItem(t){const i=t;return this.Kc.s_(new Date(1e3*i.Yc))}formatTickmark(t,i){const s=function(t,i,s){switch(t){case 0:case 10:return i?s?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.ys.timeScale.timeVisible,this.ys.timeScale.secondsVisible),e=this.ys.timeScale;if(void 0!==e.tickMarkFormatter){const h=e.tickMarkFormatter(t.originalTime,s,i.locale);if(null!==h)return h}return function(t,i,s){const e={};switch(i){case 0:e.year="numeric";break;case 1:e.month="short";break;case 2:e.day="numeric";break;case 3:e.hour12=!1,e.hour="2-digit",e.minute="2-digit";break;case 4:e.hour12=!1,e.hour="2-digit",e.minute="2-digit",e.second="2-digit"}const h=void 0===t.jc?new Date(1e3*t.Yc):new Date(Date.UTC(t.jc.year,t.jc.month-1,t.jc.day));return new Date(h.getUTCFullYear(),h.getUTCMonth(),h.getUTCDate(),h.getUTCHours(),h.getUTCMinutes(),h.getUTCSeconds(),h.getUTCMilliseconds()).toLocaleString(s,e)}(t.time,s,i.locale)}maxTickMarkWeight(t){let i=t.reduce(Ni,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let s=0===i?null:t[i-1].time.Yc,e=null!==s?new Date(1e3*s):null,h=0;for(let n=i;n1){const i=Math.ceil(h/(t.length-1)),s=new Date(1e3*(t[0].time.Yc-i));t[0].timeWeight=qi(new Date(1e3*t[0].time.Yc),s)}}(t,i)}static Xc(t){return m({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const ji="undefined"!=typeof window;function ts(){return!!ji&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function is(){return!!ji&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ss(t){return t+t%2}class es{constructor(t,i,s){this.Zc=0,this.Gc=null,this.Jc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Qc=0,this.td=null,this.sd={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.nd=null,this.ed=!1,this.rd=null,this.hd=null,this.ad=!1,this.ld=!1,this.od=!1,this._d=null,this.ud=null,this.dd=null,this.fd=null,this.pd=null,this.vd=null,this.md=null,this.wd=0,this.gd=!1,this.Md=!1,this.bd=!1,this.Sd=0,this.xd=null,this.Cd=!is(),this.yd=t=>{this.kd(t)},this.Pd=t=>{if(this.Td(t)){const i=this.Rd(t);if(++this.Qc,this.td&&this.Qc>1){const{Dd:s}=this.Vd(rs(t),this.sd) ;s<30&&!this.od&&this.Id(i,this.Ad.Bd),this.Ed()}}else{const i=this.Rd(t);if(++this.Zc,this.Gc&&this.Zc>1){const{Dd:s}=this.Vd(rs(t),this.Jc);s<5&&!this.ld&&this.zd(i,this.Ad.Ld),this.Od()}}},this.Nd=t,this.Ad=i,this.ys=s,this.Wd()}m(){null!==this._d&&(this._d(),this._d=null),null!==this.ud&&(this.ud(),this.ud=null),null!==this.fd&&(this.fd(),this.fd=null),null!==this.pd&&(this.pd(),this.pd=null),null!==this.vd&&(this.vd(),this.vd=null),null!==this.dd&&(this.dd(),this.dd=null),this.Fd(),this.Od()}Hd(t){this.fd&&this.fd();const i=this.Ud.bind(this);if(this.fd=()=>{this.Nd.removeEventListener("mousemove",i)},this.Nd.addEventListener("mousemove",i),this.Td(t))return;const s=this.Rd(t);this.zd(s,this.Ad.$d),this.Cd=!0}Od(){null!==this.Gc&&clearTimeout(this.Gc),this.Zc=0,this.Gc=null,this.Jc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Ed(){null!==this.td&&clearTimeout(this.td),this.Qc=0,this.td=null,this.sd={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Ud(t){if(this.bd||null!==this.hd)return;if(this.Td(t))return;const i=this.Rd(t);this.zd(i,this.Ad.qd),this.Cd=!0}Yd(t){const i=ls(t.changedTouches,d(this.xd));if(null===i)return;if(this.Sd=os(t),null!==this.md)return;if(this.Md)return;this.gd=!0;const s=this.Vd(rs(i),d(this.hd)),{jd:e,Kd:h,Dd:n}=s;if(this.ad||!(n<5)){if(!this.ad){const t=.5*e,i=h>=t&&!this.ys.Xd(),s=t>h&&!this.ys.Zd();i||s||(this.Md=!0),this.ad=!0,this.od=!0,this.Fd(),this.Ed()}if(!this.Md){const s=this.Rd(t,i);this.Id(s,this.Ad.Gd),ns(t)}}}Jd(t){if(0!==t.button)return;const i=this.Vd(rs(t),d(this.rd)),{Dd:s}=i;if(s>=5&&(this.ld=!0,this.Od()),this.ld){const i=this.Rd(t);this.zd(i,this.Ad.Qd)}}Vd(t,i){const s=Math.abs(i._t-t._t),e=Math.abs(i.ut-t.ut);return{jd:s,Kd:e,Dd:s+e}}tf(t){let i=ls(t.changedTouches,d(this.xd));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.xd=null,this.Sd=os(t),this.Fd(),this.hd=null,this.vd&&(this.vd(),this.vd=null);const s=this.Rd(t,i);if(this.Id(s,this.Ad.if),++this.Qc,this.td&&this.Qc>1){const{Dd:t}=this.Vd(rs(i),this.sd);t<30&&!this.od&&this.Id(s,this.Ad.Bd),this.Ed()}else this.od||(this.Id(s,this.Ad.sf),this.Ad.sf&&ns(t));0===this.Qc&&ns(t),0===t.touches.length&&this.ed&&(this.ed=!1,ns(t))}kd(t){if(0!==t.button)return;const i=this.Rd(t);if(this.rd=null,this.bd=!1,this.pd&&(this.pd(),this.pd=null),ts()&&this.Nd.ownerDocument.documentElement.removeEventListener("mouseleave",this.yd),!this.Td(t))if(this.zd(i,this.Ad.nf),++this.Zc,this.Gc&&this.Zc>1){const{Dd:s}=this.Vd(rs(t),this.Jc);s<5&&!this.ld&&this.zd(i,this.Ad.Ld),this.Od()}else this.ld||this.zd(i,this.Ad.ef)}Fd(){null!==this.nd&&(clearTimeout(this.nd),this.nd=null)}rf(t){if(null!==this.xd)return;const i=t.changedTouches[0];this.xd=i.identifier,this.Sd=os(t);const s=this.Nd.ownerDocument.documentElement;this.od=!1,this.ad=!1,this.Md=!1,this.hd=rs(i),this.vd&&(this.vd(),this.vd=null);{const i=this.Yd.bind(this),e=this.tf.bind(this);this.vd=()=>{s.removeEventListener("touchmove",i),s.removeEventListener("touchend",e)},s.addEventListener("touchmove",i,{passive:!1}), s.addEventListener("touchend",e,{passive:!1}),this.Fd(),this.nd=setTimeout(this.hf.bind(this,t),240)}const e=this.Rd(t,i);this.Id(e,this.Ad.af),this.td||(this.Qc=0,this.td=setTimeout(this.Ed.bind(this),500),this.sd=rs(i))}lf(t){if(0!==t.button)return;const i=this.Nd.ownerDocument.documentElement;ts()&&i.addEventListener("mouseleave",this.yd),this.ld=!1,this.rd=rs(t),this.pd&&(this.pd(),this.pd=null);{const t=this.Jd.bind(this),s=this.kd.bind(this);this.pd=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",s)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",s)}if(this.bd=!0,this.Td(t))return;const s=this.Rd(t);this.zd(s,this.Ad._f),this.Gc||(this.Zc=0,this.Gc=setTimeout(this.Od.bind(this),500),this.Jc=rs(t))}Wd(){this.Nd.addEventListener("mouseenter",this.Hd.bind(this)),this.Nd.addEventListener("touchcancel",this.Fd.bind(this));{const t=this.Nd.ownerDocument,i=t=>{this.Ad.uf&&(t.composed&&this.Nd.contains(t.composedPath()[0])||t.target&&this.Nd.contains(t.target)||this.Ad.uf())};this.ud=()=>{t.removeEventListener("touchstart",i)},this._d=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}is()&&(this.dd=()=>{this.Nd.removeEventListener("dblclick",this.Pd)},this.Nd.addEventListener("dblclick",this.Pd)),this.Nd.addEventListener("mouseleave",this.cf.bind(this)),this.Nd.addEventListener("touchstart",this.rf.bind(this),{passive:!0}),function(t){ji&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}(this.Nd),this.Nd.addEventListener("mousedown",this.lf.bind(this)),this.df(),this.Nd.addEventListener("touchmove",(()=>{}),{passive:!1})}df(){void 0===this.Ad.ff&&void 0===this.Ad.pf&&void 0===this.Ad.vf||(this.Nd.addEventListener("touchstart",(t=>this.mf(t.touches)),{passive:!0}),this.Nd.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.md&&void 0!==this.Ad.pf){const i=hs(t.touches[0],t.touches[1])/this.wd;this.Ad.pf(this.md,i),ns(t)}}),{passive:!1}),this.Nd.addEventListener("touchend",(t=>{this.mf(t.touches)})))}mf(t){1===t.length&&(this.gd=!1),2!==t.length||this.gd||this.ed?this.wf():this.gf(t)}gf(t){const i=this.Nd.getBoundingClientRect()||{left:0,top:0};this.md={_t:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.wd=hs(t[0],t[1]),void 0!==this.Ad.ff&&this.Ad.ff(),this.Fd()}wf(){null!==this.md&&(this.md=null,void 0!==this.Ad.vf&&this.Ad.vf())}cf(t){if(this.fd&&this.fd(),this.Td(t))return;if(!this.Cd)return;const i=this.Rd(t);this.zd(i,this.Ad.Mf),this.Cd=!is()}hf(t){const i=ls(t.touches,d(this.xd));if(null===i)return;const s=this.Rd(t,i);this.Id(s,this.Ad.bf),this.od=!0,this.ed=!0}Td(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:os(t){"touchstart"!==t.type&&ns(t)}}}}function hs(t,i){const s=t.clientX-i.clientX,e=t.clientY-i.clientY;return Math.sqrt(s*s+e*e)}function ns(t){t.cancelable&&t.preventDefault()}function rs(t){return{_t:t.pageX,ut:t.pageY}}function os(t){return t.timeStamp||performance.now()}function ls(t,i){for(let s=0;s!1,Zd:()=>!0}),this.kf={Uf:s,Hf:t}}zf(){this.Ef.style.background=this.Df.N().layout.panes.separatorColor}$f(t){null!==this.kf&&(this.kf.Uf.style.backgroundColor=this.Df.N().layout.panes.separatorHoverColor)}qf(t){null!==this.kf&&null===this.Rf&&(this.kf.Uf.style.backgroundColor="")}Yf(t){if(null===this.kf)return;const i=this.Vf.Xf().ko()+this.Bf.Xf().ko(),s=i/(this.Vf.Nf().height+this.Bf.Nf().height),e=30*s;i<=2*e||(this.Rf={Zf:t.pageY,Gf:this.Vf.Xf().ko(),Jf:i-e,Qf:i,tp:s,ip:e},this.kf.Hf.style.display="block")}jf(t){const i=this.Rf;if(null===i)return;const s=(t.pageY-i.Zf)*i.tp,e=Kt(i.Gf+s,i.ip,i.Jf);this.Vf.Xf().Po(e),this.Bf.Xf().Po(i.Qf-e),this.Df.Qt().Bh()}Kf(t){null!==this.Rf&&null!==this.kf&&(this.Rf=null,this.kf.Hf.style.display="none")}} function us(t,i){return t.sp-i.sp}function cs(t,i,s){const e=(t.sp-i.sp)/(t.wt-i.wt);return Math.sign(e)*Math.min(Math.abs(e),s)}class ds{constructor(t,i,s,e){this.np=null,this.ep=null,this.rp=null,this.hp=null,this.ap=null,this.lp=0,this.op=0,this._p=t,this.up=i,this.cp=s,this.Mn=e}dp(t,i){if(null!==this.np){if(this.np.wt===i)return void(this.np.sp=t);if(Math.abs(this.np.sp-t)50)return;let s=0;const e=cs(this.np,this.ep,this.up),h=us(this.np,this.ep),n=[e],r=[h];if(s+=h,null!==this.rp){const t=cs(this.ep,this.rp,this.up);if(Math.sign(t)===Math.sign(e)){const i=us(this.ep,this.rp);if(n.push(t),r.push(i),s+=i,null!==this.hp){const t=cs(this.rp,this.hp,this.up);if(Math.sign(t)===Math.sign(e)){const i=us(this.rp,this.hp);n.push(t),r.push(i),s+=i}}}}let o=0;for(let t=0;t160?"dark":"light"}xp(){return this.gp.N().layout.attributionLogo}yp(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Mp(){this.Sp()&&(this.bp(),this.ps=this.xp(),this.ps&&(this.mp=this.Cp(),this.vp=document.createElement("style"),this.vp.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.pp=document.createElement("a"),this.pp.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.yp()}`,this.pp.title="Charting by TradingView",this.pp.id="tv-attr-logo",this.pp.target="_blank",this.pp.innerHTML='',this.pp.toggleAttribute("data-dark","dark"===this.mp),this.wp.appendChild(this.vp), this.wp.appendChild(this.pp)))}}function ps(t,i){const s=d(t.ownerDocument).createElement("canvas");t.appendChild(s);const h=(0,e.bindCanvasElementBitmapSizeTo)(s,{type:"device-pixel-content-box",options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})});return h.resizeCanvasElement(i),h}function ms(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function gs(t,i,s,e){t.ih&&t.ih(i,s,e)}function vs(t,i,s,e){t.nt(i,s,e)}function ws(t,i,s,e){const h=t(s,e);for(const t of h){const s=t.Tt(e);null!==s&&i(s)}}function bs(t,i){return s=>function(t){return void 0!==t.Wt}(s)?(s.Wt()?.wa()??"")!==i?[]:s.ta?.(t)??[]:[]}function ys(t,i,s,e){if(!t.length)return;let h=0;const n=t[0].$t(e,!0);let r=1===i?s/2-(t[0].Wi()-n/2):t[0].Wi()-n/2-s/2;r=Math.max(0,r);for(let n=1;nc-a:us)&&r>0){const e=1===i?-1-n:n-s,o=Math.min(e,r);for(let s=h;s{this.Vp||this.yt.Bp().Qt().ar()},this.Ap=()=>{this.Vp||this.yt.Bp().Qt().ar()},this.yt=t,this.ys=i,this.gl=i.layout,this.Uu=s,this.Ep="left"===h,this.zp=bs("normal",h),this.Lp=bs("top",h),this.Op=bs("bottom",h),this.Ef=document.createElement("div"),this.Ef.style.height="100%",this.Ef.style.overflow="hidden",this.Ef.style.width="25px",this.Ef.style.left="0",this.Ef.style.position="relative",this.Np=ps(this.Ef,e.size({width:16,height:16})),this.Np.subscribeSuggestedBitmapSizeChanged(this.Ip);const n=this.Np.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Wp=ps(this.Ef,e.size({width:16,height:16})),this.Wp.subscribeSuggestedBitmapSizeChanged(this.Ap);const r=this.Wp.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const o={_f:this.Yf.bind(this),af:this.Yf.bind(this),Qd:this.jf.bind(this),Gd:this.jf.bind(this),uf:this.Fp.bind(this),nf:this.Kf.bind(this),if:this.Kf.bind(this),Ld:this.Hp.bind(this),Bd:this.Hp.bind(this),$d:this.Up.bind(this),Mf:this.qf.bind(this)};this.Pf=new es(this.Wp.canvasElement,o,{Xd:()=>!this.ys.handleScroll.vertTouchDrag,Zd:()=>!0})}m(){this.Pf.m(),this.Wp.unsubscribeSuggestedBitmapSizeChanged(this.Ap),ms(this.Wp.canvasElement),this.Wp.dispose(),this.Np.unsubscribeSuggestedBitmapSizeChanged(this.Ip),ms(this.Np.canvasElement),this.Np.dispose(),null!==this.Yi&&this.Yi.io().u(this),this.Yi=null}Of(){return this.Ef}k(){return this.gl.fontSize}$p(){const t=this.Uu.N();return this.Rp!==t.P&&(this.Tp.In(),this.Rp=t.P),t}qp(){if(null===this.Yi)return 0;let t=0;const i=this.$p(),s=d(this.Np.canvasElement.getContext("2d",{colorSpace:this.yt.Bp().N().layout.colorSpace}));s.save();const e=this.Yi.Va();s.font=this.Yp(), e.length>0&&(t=Math.max(this.Tp.Vi(s,e[0].Xa),this.Tp.Vi(s,e[e.length-1].Xa)));const h=this.jp();for(let i=h.length;i--;){const e=this.Tp.Vi(s,h[i].ri());e>t&&(t=e)}const n=this.Yi.zt();if(null!==n&&null!==this.kp&&2!==(r=this.ys.crosshair).mode&&r.horzLine.visible&&r.horzLine.labelVisible){const i=this.Yi.Ts(1,n),e=this.Yi.Ts(this.kp.height-2,n);t=Math.max(t,this.Tp.Vi(s,this.Yi.Zi(Math.floor(Math.min(i,e))+.11111111111111,n)),this.Tp.Vi(s,this.Yi.Zi(Math.ceil(Math.max(i,e))-.11111111111111,n)))}var r;s.restore();const o=t||34;return ss(Math.ceil(i.S+i.C+i.I+i.B+5+o))}Kp(t){null!==this.kp&&(0,e.equalSizes)(this.kp,t)||(this.kp=t,this.Vp=!0,this.Np.resizeCanvasElement(t),this.Wp.resizeCanvasElement(t),this.Vp=!1,this.Ef.style.width=`${t.width}px`,this.Ef.style.height=`${t.height}px`)}Xp(){return d(this.kp).width}_s(t){this.Yi!==t&&(null!==this.Yi&&this.Yi.io().u(this),this.Yi=t,t.io().i(this.ol.bind(this),this))}Wt(){return this.Yi}In(){const t=this.yt.Xf();this.yt.Bp().Qt().Ho(t,d(this.Wt()))}Zp(t){if(null===this.kp)return;const i={colorSpace:this.yt.Bp().N().layout.colorSpace};if(1!==t){this.Gp(),this.Np.applySuggestedBitmapSize();const t=(0,e.tryCreateCanvasRenderingTarget2D)(this.Np,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Jp(t),this.Qp(t)})),this.yt.tv(t,this.Op),this.iv(t),this.yt.tv(t,this.zp),this.sv(t))}this.Wp.applySuggestedBitmapSize();const s=(0,e.tryCreateCanvasRenderingTarget2D)(this.Wp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.nv(s),this.yt.tv(s,this.Lp))}Wf(){return this.Np.bitmapSize}Ff(t,i,s){const e=this.Wf();e.width>0&&e.height>0&&t.drawImage(this.Np.canvasElement,i,s)}kt(){this.Yi?.Va()}Yf(t){if(null===this.Yi||this.Yi.Ki()||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Bp().Qt(),s=this.yt.Xf();this.Pp=!0,i.Eo(s,this.Yi,t.localY)}jf(t){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Bp().Qt(),s=this.yt.Xf(),e=this.Yi;i.zo(s,e,t.localY)}Fp(){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const t=this.yt.Bp().Qt(),i=this.yt.Xf(),s=this.Yi;this.Pp&&(this.Pp=!1,t.Lo(i,s))}Kf(t){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.yt.Bp().Qt(),s=this.yt.Xf();this.Pp=!1,i.Lo(s,this.Yi)}Hp(t){this.ys.handleScale.axisDoubleClickReset.price&&this.In()}Up(t){null!==this.Yi&&(!this.yt.Bp().Qt().N().handleScale.axisPressedMouseMove.price||this.Yi.Le()||this.Yi.Rl()||this.ev(1))}qf(t){this.ev(0)}jp(){const t=[],i=null===this.Yi?void 0:this.Yi;return(s=>{for(let e=0;e{t.fillStyle=s.borderColor;const o=Math.max(1,Math.floor(r)),l=Math.floor(.5*r),a=Math.round(e.C*n);t.beginPath();for(const s of i)t.rect(Math.floor(h*n),Math.round(s.ka*r)-l,a,o);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{t.font=this.Yp(),t.fillStyle=s.textColor??this.gl.textColor,t.textAlign=this.Ep?"right":"left",t.textBaseline="middle";const n=this.Ep?Math.round(h-e.I):Math.round(h+e.C+e.I),r=i.map((i=>this.Tp.Di(t,i.Xa)));for(let s=i.length;s--;){const e=i[s];t.fillText(e.Xa,n,e.ka+r[s])}}))}Gp(){if(null===this.kp||null===this.Yi)return;let t=this.kp.height/2;const i=[],s=this.Yi.Dt().slice(),e=this.yt.Xf(),h=this.$p();this.Yi===e.$n()&&this.yt.Xf().Dt().forEach((t=>{e.Un(t)&&s.push(t)}));const n=this.Yi.ba()[0],r=this.Yi;s.forEach((s=>{const h=s.Fs(e,r);h.forEach((t=>{t.Fi(null),t.Hi()&&i.push(t)})),n===s&&h.length>0&&(t=h[0].Bi())})),i.forEach((t=>t.Fi(t.Bi()))),this.Yi.N().alignLabels&&this.rv(i,h,t)}rv(t,i,s){if(null===this.kp)return;const e=t.filter((t=>t.Bi()<=s)),h=t.filter((t=>t.Bi()>s));e.sort(((t,i)=>i.Bi()-t.Bi())),e.length&&h.length&&h.push(e[0]),h.sort(((t,i)=>t.Bi()-i.Bi()));for(const s of t){const t=Math.floor(s.$t(i)/2),e=s.Bi();e>-t&&ethis.kp.height-t&&e{i.Ui()&&i.Tt(d(this.Yi)).nt(t,s,this.Tp,e)}))}nv(t){if(null===this.kp||null===this.Yi)return;const i=this.yt.Bp().Qt(),s=[],e=this.yt.Xf(),h=i.sc().Fs(e,this.Yi);h.length&&s.push(h);const n=this.$p(),r=this.Ep?"right":"left";s.forEach((i=>{i.forEach((i=>{i.Tt(d(this.Yi)).nt(t,n,this.Tp,r)}))}))}ev(t){this.Ef.style.cursor=1===t?"ns-resize":"default"}ol(){const t=this.qp();this.Dp{this.Vp||null===this.gv||this.ts().ar()},this.Ap=()=>{this.Vp||null===this.gv||this.ts().ar()},this.gp=t,this.gv=i,this.gv.Yo().i(this.Mv.bind(this),this,!0),this.bv=document.createElement("td"),this.bv.style.padding="0",this.bv.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.Sv=document.createElement("td"),this.Sv.style.padding="0", this.xv=document.createElement("td"),this.xv.style.padding="0",this.bv.appendChild(s),this.Np=ps(s,e.size({width:16,height:16})),this.Np.subscribeSuggestedBitmapSizeChanged(this.Ip);const h=this.Np.canvasElement;h.style.position="absolute",h.style.zIndex="1",h.style.left="0",h.style.top="0",this.Wp=ps(s,e.size({width:16,height:16})),this.Wp.subscribeSuggestedBitmapSizeChanged(this.Ap);const n=this.Wp.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.Af=document.createElement("tr"),this.Af.appendChild(this.Sv),this.Af.appendChild(this.bv),this.Af.appendChild(this.xv),this.Cv(),this.Pf=new es(this.Wp.canvasElement,this,{Xd:()=>null===this.pv&&!this.gp.N().handleScroll.vertTouchDrag,Zd:()=>null===this.pv&&!this.gp.N().handleScroll.horzTouchDrag})}m(){null!==this.hv&&this.hv.m(),null!==this.av&&this.av.m(),this.lv=null,this.Wp.unsubscribeSuggestedBitmapSizeChanged(this.Ap),ms(this.Wp.canvasElement),this.Wp.dispose(),this.Np.unsubscribeSuggestedBitmapSizeChanged(this.Ip),ms(this.Np.canvasElement),this.Np.dispose(),null!==this.gv&&(this.gv.Yo().u(this),this.gv.m()),this.Pf.m()}Xf(){return d(this.gv)}yv(t){null!==this.gv&&this.gv.Yo().u(this),this.gv=t,null!==this.gv&&this.gv.Yo().i(ks.prototype.Mv.bind(this),this,!0),this.Cv(),this.gp.If().indexOf(this)===this.gp.If().length-1?(this.lv=this.lv??new fs(this.bv,this.gp),this.lv.kt()):(this.lv?.bp(),this.lv=null)}Bp(){return this.gp}Of(){return this.Af}Cv(){if(null!==this.gv&&(this.kv(),0!==this.ts().js().length)){if(null!==this.hv){const t=this.gv.Bo();this.hv._s(d(t))}if(null!==this.av){const t=this.gv.Ao();this.av._s(d(t))}}}Pv(){null!==this.hv&&this.hv.kt(),null!==this.av&&this.av.kt()}ko(){return null!==this.gv?this.gv.ko():0}Po(t){this.gv&&this.gv.Po(t)}$d(t){if(!this.gv)return;this.Tv();const i=t.localX,s=t.localY;this.Rv(i,s,t)}_f(t){this.Tv(),this.Dv(),this.Rv(t.localX,t.localY,t)}qd(t){if(!this.gv)return;this.Tv();const i=t.localX,s=t.localY;this.Rv(i,s,t)}ef(t){null!==this.gv&&(this.Tv(),this.Vv(t))}Ld(t){null!==this.gv&&this.Iv(this.cv,t)}Bd(t){this.Ld(t)}Qd(t){this.Tv(),this.Bv(t),this.Rv(t.localX,t.localY,t)}nf(t){null!==this.gv&&(this.Tv(),this.fv=!1,this.Av(t))}sf(t){null!==this.gv&&this.Vv(t)}bf(t){if(this.fv=!0,null===this.pv){const i={x:t.localX,y:t.localY};this.Ev(i,i,t)}}Mf(t){null!==this.gv&&(this.Tv(),this.gv.Qt().Ju(null),this.zv())}Lv(){return this.uv}Ov(){return this.cv}ff(){this.dv=1,this.ts().hn()}pf(t,i){if(!this.gp.N().handleScale.pinch)return;const s=5*(i-this.dv);this.dv=i,this.ts()._c(t._t,s)}af(t){this.fv=!1,this.vv=null!==this.pv,this.Dv();const i=this.ts().sc();null!==this.pv&&i.Vt()&&(this.mv={x:i.si(),y:i.ni()},this.pv={x:t.localX,y:t.localY})}Gd(t){if(null===this.gv)return;const i=t.localX,s=t.localY;if(null===this.pv)this.Bv(t);else{this.vv=!1;const e=d(this.mv),h=e.x+(i-this.pv.x),n=e.y+(s-this.pv.y);this.Rv(h,n,t)}}if(t){0===this.Bp().N().trackingMode.exitMode&&(this.vv=!0),this.Nv(),this.Av(t)}jn(t,i){const s=this.gv;return null===s?null:xi(s,t,i)}Wv(t,i){ d("left"===i?this.hv:this.av).Kp(e.size({width:t,height:this.kp.height}))}Nf(){return this.kp}Kp(t){(0,e.equalSizes)(this.kp,t)||(this.kp=t,this.Vp=!0,this.Np.resizeCanvasElement(t),this.Wp.resizeCanvasElement(t),this.Vp=!1,this.bv.style.width=t.width+"px",this.bv.style.height=t.height+"px")}Fv(){const t=d(this.gv);t.Io(t.Bo()),t.Io(t.Ao());for(const i of t.ba())if(t.Un(i)){const s=i.Wt();null!==s&&t.Io(s),i.Ns()}for(const i of t.Ko())i.Ns()}Wf(){return this.Np.bitmapSize}Ff(t,i,s){const e=this.Wf();e.width>0&&e.height>0&&t.drawImage(this.Np.canvasElement,i,s)}Zp(t){if(0===t)return;if(null===this.gv)return;t>1&&this.Fv(),null!==this.hv&&this.hv.Zp(t),null!==this.av&&this.av.Zp(t);const i={colorSpace:this.gp.N().layout.colorSpace};if(1!==t){this.Np.applySuggestedBitmapSize();const t=(0,e.tryCreateCanvasRenderingTarget2D)(this.Np,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Jp(t)})),this.gv&&(this.Hv(t,Ss),this.Uv(t),this.Hv(t,xs),this.Hv(t,_s)))}this.Wp.applySuggestedBitmapSize();const s=(0,e.tryCreateCanvasRenderingTarget2D)(this.Wp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.$v(s),this.Hv(s,Cs),this.Hv(s,_s))}qv(){return this.hv}Yv(){return this.av}tv(t,i){this.Hv(t,i)}Mv(){null!==this.gv&&this.gv.Yo().u(this),this.gv=null}Vv(t){this.Iv(this.uv,t)}Iv(t,i){const s=i.localX,e=i.localY;t.v()&&t.p(this.ts().At().nu(s),{x:s,y:e},i)}Jp({context:t,bitmapSize:i}){const{width:s,height:e}=i,h=this.ts(),n=h.$(),r=h.Vc();n===r?W(t,0,0,s,e,r):O(t,0,0,s,e,n,r)}Uv(t){const i=d(this.gv),s=i.jo().lr().Tt(i);null!==s&&s.nt(t,!1)}$v(t){this.jv(t,xs,vs,this.ts().sc())}Hv(t,i){const s=d(this.gv),e=s.Dt(),h=s.Ko();for(const s of h)this.jv(t,i,gs,s);for(const s of e)this.jv(t,i,gs,s);for(const s of h)this.jv(t,i,vs,s);for(const s of e)this.jv(t,i,vs,s)}jv(t,i,s,e){const h=d(this.gv),n=h.Qt().Gu(),r=null!==n&&n.Xo===e,o=null!==n&&r&&void 0!==n.Zo?n.Zo.Xn:void 0;ws(i,(i=>s(i,t,r,o)),e,h)}kv(){if(null===this.gv)return;const t=this.gp,i=this.gv.Bo().N().visible,s=this.gv.Ao().N().visible;i||null===this.hv||(this.Sv.removeChild(this.hv.Of()),this.hv.m(),this.hv=null),s||null===this.av||(this.xv.removeChild(this.av.Of()),this.av.m(),this.av=null);const e=t.Qt().Sc();i&&null===this.hv&&(this.hv=new Ms(this,t.N(),e,"left"),this.Sv.appendChild(this.hv.Of())),s&&null===this.av&&(this.av=new Ms(this,t.N(),e,"right"),this.xv.appendChild(this.av.Of()))}Kv(t){return t.Sf&&this.fv||null!==this.pv}Xv(t){return Math.max(0,Math.min(t,this.kp.width-1))}Zv(t){return Math.max(0,Math.min(t,this.kp.height-1))}Rv(t,i,s){this.ts().wc(this.Xv(t),this.Zv(i),s,d(this.gv))}zv(){this.ts().Mc()}Nv(){this.vv&&(this.pv=null,this.zv())}Ev(t,i,s){this.pv=t,this.vv=!1,this.Rv(i.x,i.y,s);const e=this.ts().sc();this.mv={x:e.si(),y:e.ni()}}ts(){return this.gp.Qt()}Av(t){if(!this._v)return;const i=this.ts(),s=this.Xf();if(i.Wo(s,s.Ps()),this.ov=null,this._v=!1,i.fc(),null!==this.wv){const t=performance.now(),s=i.At();this.wv.le(s._u(),t),this.wv.Mu(t)||i._n(this.wv)}}Tv(){this.pv=null}Dv(){if(this.gv){ if(this.ts().hn(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)d(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.gv.Ps().Ki()&&this.ts().At().Ki()}}Bv(t){if(null===this.gv)return;const i=this.ts(),s=i.At();if(s.Ki())return;const e=this.gp.N(),h=e.handleScroll,n=e.kineticScroll;if((!h.pressedMouseMove||t.Sf)&&(!h.horzTouchDrag&&!h.vertTouchDrag||!t.Sf))return;const r=this.gv.Ps(),o=performance.now();if(null!==this.ov||this.Kv(t)||(this.ov={x:t.clientX,y:t.clientY,Yc:o,Gv:t.localX,Jv:t.localY}),null!==this.ov&&!this._v&&(this.ov.x!==t.clientX||this.ov.y!==t.clientY)){if(t.Sf&&n.touch||!t.Sf&&n.mouse){const t=s.lu();this.wv=new ds(.2/t,7/t,.997,15/t),this.wv.dp(s._u(),this.ov.Yc)}else this.wv=null;r.Ki()||i.Oo(this.gv,r,t.localY),i.cc(t.localX),this._v=!0}this._v&&(r.Ki()||i.No(this.gv,r,t.localY),i.dc(t.localX),null!==this.wv&&this.wv.dp(s._u(),o))}}class zs{constructor(t,i,s,h,n){this.xt=!0,this.kp=e.size({width:0,height:0}),this.Ip=()=>this.Zp(3),this.Ep="left"===t,this.Uu=s.Sc,this.ys=i,this.Qv=h,this.tm=n,this.Ef=document.createElement("div"),this.Ef.style.width="25px",this.Ef.style.height="100%",this.Ef.style.overflow="hidden",this.Np=ps(this.Ef,e.size({width:16,height:16})),this.Np.subscribeSuggestedBitmapSizeChanged(this.Ip)}m(){this.Np.unsubscribeSuggestedBitmapSizeChanged(this.Ip),ms(this.Np.canvasElement),this.Np.dispose()}Of(){return this.Ef}Nf(){return this.kp}Kp(t){(0,e.equalSizes)(this.kp,t)||(this.kp=t,this.Np.resizeCanvasElement(t),this.Ef.style.width=`${t.width}px`,this.Ef.style.height=`${t.height}px`,this.xt=!0)}Zp(t){if(t<3&&!this.xt)return;if(0===this.kp.width||0===this.kp.height)return;this.xt=!1,this.Np.applySuggestedBitmapSize();const i=(0,e.tryCreateCanvasRenderingTarget2D)(this.Np,{colorSpace:this.ys.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace((t=>{this.Jp(t),this.Qp(t)}))}Wf(){return this.Np.bitmapSize}Ff(t,i,s){const e=this.Wf();e.width>0&&e.height>0&&t.drawImage(this.Np.canvasElement,i,s)}Qp({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(!this.Qv())return;t.fillStyle=this.ys.timeScale.borderColor;const h=Math.floor(this.Uu.N().S*s),n=Math.floor(this.Uu.N().S*e),r=this.Ep?i.width-h:0;t.fillRect(r,0,h,n)}Jp({context:t,bitmapSize:i}){W(t,0,0,i.width,i.height,this.tm())}}function Rs(t){return i=>i.ia?.(t)??[]}const Ns=Rs("normal"),Es=Rs("top"),Ys=Rs("bottom");class Ts{constructor(t,i){this.im=null,this.sm=null,this.M=null,this.nm=!1,this.kp=e.size({width:0,height:0}),this.rm=new p,this.Tp=new ht(5),this.Vp=!1,this.Ip=()=>{this.Vp||this.gp.Qt().ar()},this.Ap=()=>{this.Vp||this.gp.Qt().ar()},this.gp=t,this.i_=i,this.ys=t.N().layout,this.pp=document.createElement("tr"),this.hm=document.createElement("td"),this.hm.style.padding="0",this.am=document.createElement("td"),this.am.style.padding="0",this.Ef=document.createElement("td"),this.Ef.style.height="25px",this.Ef.style.padding="0",this.lm=document.createElement("div"),this.lm.style.width="100%", this.lm.style.height="100%",this.lm.style.position="relative",this.lm.style.overflow="hidden",this.Ef.appendChild(this.lm),this.Np=ps(this.lm,e.size({width:16,height:16})),this.Np.subscribeSuggestedBitmapSizeChanged(this.Ip);const s=this.Np.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Wp=ps(this.lm,e.size({width:16,height:16})),this.Wp.subscribeSuggestedBitmapSizeChanged(this.Ap);const h=this.Wp.canvasElement;h.style.position="absolute",h.style.zIndex="2",h.style.left="0",h.style.top="0",this.pp.appendChild(this.hm),this.pp.appendChild(this.Ef),this.pp.appendChild(this.am),this.om(),this.gp.Qt().yo().i(this.om.bind(this),this),this.Pf=new es(this.Wp.canvasElement,this,{Xd:()=>!0,Zd:()=>!this.gp.N().handleScroll.horzTouchDrag})}m(){this.Pf.m(),null!==this.im&&this.im.m(),null!==this.sm&&this.sm.m(),this.Wp.unsubscribeSuggestedBitmapSizeChanged(this.Ap),ms(this.Wp.canvasElement),this.Wp.dispose(),this.Np.unsubscribeSuggestedBitmapSizeChanged(this.Ip),ms(this.Np.canvasElement),this.Np.dispose()}Of(){return this.pp}_m(){return this.im}um(){return this.sm}_f(t){if(this.nm)return;this.nm=!0;const i=this.gp.Qt();!i.At().Ki()&&this.gp.N().handleScale.axisPressedMouseMove.time&&i.oc(t.localX)}af(t){this._f(t)}uf(){const t=this.gp.Qt();!t.At().Ki()&&this.nm&&(this.nm=!1,this.gp.N().handleScale.axisPressedMouseMove.time&&t.mc())}Qd(t){const i=this.gp.Qt();!i.At().Ki()&&this.gp.N().handleScale.axisPressedMouseMove.time&&i.vc(t.localX)}Gd(t){this.Qd(t)}nf(){this.nm=!1;const t=this.gp.Qt();t.At().Ki()&&!this.gp.N().handleScale.axisPressedMouseMove.time||t.mc()}if(){this.nf()}Ld(){this.gp.N().handleScale.axisDoubleClickReset.time&&this.gp.Qt().cn()}Bd(){this.Ld()}$d(){this.gp.Qt().N().handleScale.axisPressedMouseMove.time&&this.ev(1)}Mf(){this.ev(0)}Nf(){return this.kp}dm(){return this.rm}fm(t,i,s){(0,e.equalSizes)(this.kp,t)||(this.kp=t,this.Vp=!0,this.Np.resizeCanvasElement(t),this.Wp.resizeCanvasElement(t),this.Vp=!1,this.Ef.style.width=`${t.width}px`,this.Ef.style.height=`${t.height}px`,this.rm.p(t)),null!==this.im&&this.im.Kp(e.size({width:i,height:t.height})),null!==this.sm&&this.sm.Kp(e.size({width:s,height:t.height}))}pm(){const t=this.vm();return Math.ceil(t.S+t.C+t.k+t.A+t.V+t.wm)}kt(){this.gp.Qt().At().Va()}Wf(){return this.Np.bitmapSize}Ff(t,i,s){const e=this.Wf();e.width>0&&e.height>0&&t.drawImage(this.Np.canvasElement,i,s)}Zp(t){if(0===t)return;const i={colorSpace:this.ys.colorSpace};if(1!==t){this.Np.applySuggestedBitmapSize();const s=(0,e.tryCreateCanvasRenderingTarget2D)(this.Np,i);null!==s&&(s.useBitmapCoordinateSpace((t=>{this.Jp(t),this.Qp(t),this.gm(s,Ys)})),this.iv(s),this.gm(s,Ns)),null!==this.im&&this.im.Zp(t),null!==this.sm&&this.sm.Zp(t)}this.Wp.applySuggestedBitmapSize();const s=(0,e.tryCreateCanvasRenderingTarget2D)(this.Wp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Mm([...this.gp.Qt().js(),this.gp.Qt().sc()],s),this.gm(s,Es))}gm(t,i){const s=this.gp.Qt().js() ;for(const e of s)ws(i,(i=>gs(i,t,!1,void 0)),e,void 0);for(const e of s)ws(i,(i=>vs(i,t,!1,void 0)),e,void 0)}Jp({context:t,bitmapSize:i}){W(t,0,0,i.width,i.height,this.gp.Qt().Vc())}Qp({context:t,bitmapSize:i,verticalPixelRatio:s}){if(this.gp.N().timeScale.borderVisible){t.fillStyle=this.bm();const e=Math.max(1,Math.floor(this.vm().S*s));t.fillRect(0,0,i.width,e)}}iv(t){const i=this.gp.Qt().At(),s=i.Va();if(!s||0===s.length)return;const e=this.i_.maxTickMarkWeight(s),h=this.vm(),n=i.N();n.borderVisible&&n.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:e})=>{t.strokeStyle=this.bm(),t.fillStyle=this.bm();const n=Math.max(1,Math.floor(i)),r=Math.floor(.5*i);t.beginPath();const o=Math.round(h.C*e);for(let e=s.length;e--;){const h=Math.round(s[e].coord*i);t.rect(h-r,0,n,o)}t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{const i=h.S+h.C+h.A+h.k/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.H(),t.font=this.Yp();for(const h of s)if(h.weight=e){const s=h.needAlignCoordinate?this.Sm(t,h.coord,h.label):h.coord;t.fillText(h.label,s,i)}}))}Sm(t,i,s){const e=this.Tp.Vi(t,s),h=e/2,n=Math.floor(i-h)+.5;return n<0?i+=Math.abs(0-n):n+e>this.kp.width&&(i-=Math.abs(this.kp.width-(n+e))),i}Mm(t,i){const s=this.vm();for(const e of t)for(const t of e.cs())t.Tt().nt(i,s)}bm(){return this.gp.N().timeScale.borderColor}H(){return this.ys.textColor}W(){return this.ys.fontSize}Yp(){return _(this.W(),this.ys.fontFamily)}xm(){return _(this.W(),this.ys.fontFamily,"bold")}vm(){null===this.M&&(this.M={S:1,L:NaN,A:NaN,V:NaN,Ji:NaN,C:5,k:NaN,P:"",Gi:new ht,wm:0});const t=this.M,i=this.Yp();if(t.P!==i){const s=this.W();t.k=s,t.P=i,t.A=3*s/12,t.V=3*s/12,t.Ji=9*s/12,t.L=0,t.wm=4*s/12,t.Gi.In()}return this.M}ev(t){this.Ef.style.cursor=1===t?"ew-resize":"default"}om(){const t=this.gp.Qt(),i=t.N();i.leftPriceScale.visible||null===this.im||(this.hm.removeChild(this.im.Of()),this.im.m(),this.im=null),i.rightPriceScale.visible||null===this.sm||(this.am.removeChild(this.sm.Of()),this.sm.m(),this.sm=null);const s={Sc:this.gp.Qt().Sc()},e=()=>i.leftPriceScale.borderVisible&&t.At().N().borderVisible,h=()=>t.Vc();i.leftPriceScale.visible&&null===this.im&&(this.im=new zs("left",i,s,e,h),this.hm.appendChild(this.im.Of())),i.rightPriceScale.visible&&null===this.sm&&(this.sm=new zs("right",i,s,e,h),this.am.appendChild(this.sm.Of()))}}const Ps=!!ji&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!ji&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class Vs{constructor(t,i,s){var e;this.Cm=[],this.ym=[],this.km=0,this.tl=0,this.fo=0,this.Pm=0,this.Tm=0,this.Rm=null,this.Dm=!1,this.uv=new p,this.cv=new p,this.Wu=new p,this.Vm=null,this.Im=null,this.wp=t,this.ys=i,this.i_=s, this.pp=document.createElement("div"),this.pp.classList.add("tv-lightweight-charts"),this.pp.style.overflow="hidden",this.pp.style.direction="ltr",this.pp.style.width="100%",this.pp.style.height="100%",(e=this.pp).style.userSelect="none",e.style.webkitUserSelect="none",e.style.msUserSelect="none",e.style.MozUserSelect="none",e.style.webkitTapHighlightColor="transparent",this.Bm=document.createElement("table"),this.Bm.setAttribute("cellspacing","0"),this.pp.appendChild(this.Bm),this.Am=this.Em.bind(this),Bs(this.ys)&&this.zm(!0),this.ts=new Di(this.Hu.bind(this),this.ys,s),this.Qt().nc().i(this.Lm.bind(this),this),this.Om=new Ts(this,this.i_),this.Bm.appendChild(this.Om.Of());const h=i.autoSize&&this.Nm();let n=this.ys.width,r=this.ys.height;if(h||0===n||0===r){const i=t.getBoundingClientRect();n=n||i.width,r=r||i.height}this.Wm(n,r),this.Fm(),t.appendChild(this.pp),this.Hm(),this.ts.At().Cu().i(this.ts.Bh.bind(this.ts),this),this.ts.yo().i(this.ts.Bh.bind(this.ts),this)}Qt(){return this.ts}N(){return this.ys}If(){return this.Cm}Um(){return this.Om}m(){this.zm(!1),0!==this.km&&window.cancelAnimationFrame(this.km),this.ts.nc().u(this),this.ts.At().Cu().u(this),this.ts.yo().u(this),this.ts.m();for(const t of this.Cm)this.Bm.removeChild(t.Of()),t.Lv().u(this),t.Ov().u(this),t.m();this.Cm=[];for(const t of this.ym)this.$m(t);this.ym=[],d(this.Om).m(),null!==this.pp.parentElement&&this.pp.parentElement.removeChild(this.pp),this.Wu.m(),this.uv.m(),this.cv.m(),this.qm()}Wm(t,i,s=!1){if(this.tl===i&&this.fo===t)return;const h=function(t){const i=Math.floor(t.width),s=Math.floor(t.height);return e.size({width:i-i%2,height:s-s%2})}(e.size({width:t,height:i}));this.tl=h.height,this.fo=h.width;const n=this.tl+"px",r=this.fo+"px";d(this.pp).style.height=n,d(this.pp).style.width=r,this.Bm.style.height=n,this.Bm.style.width=r,s?this.Ym(H.gn(),performance.now()):this.ts.Bh()}Zp(t){void 0===t&&(t=H.gn());for(let i=0;i{t.kt()}))}Km(t){(void 0!==t.autoSize||!this.Vm||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.Vm&&this.Nm(),!1===t.autoSize&&null!==this.Vm&&this.qm(),t.autoSize||void 0===t.width&&void 0===t.height||this.Wm(t.width||this.fo,t.height||this.tl))}Zm(t){ let i=0,s=0;const h=this.Cm[0],n=(i,s)=>{let e=0;for(let h=0;h{d("left"===i?this.Om._m():this.Om.um()).Ff(d(t),s,e)};if(this.ys.timeScale.visible){const i=this.Om.Wf();if(null!==t){let e=0;this.Jm()&&(r("left",e,s),e=d(h.qv()).Wf().width),this.Om.Ff(t,e,s),e+=i.width,this.Qm()&&r("right",e,s)}s+=i.height}return e.size({width:i,height:s})}ew(){let t=0,i=0,s=0;for(const e of this.Cm)this.Jm()&&(i=Math.max(i,d(e.qv()).qp(),this.ys.leftPriceScale.minimumWidth)),this.Qm()&&(s=Math.max(s,d(e.Yv()).qp(),this.ys.rightPriceScale.minimumWidth)),t+=e.ko();i=ss(i),s=ss(s);const h=this.fo,n=this.tl,r=Math.max(h-i-s,0),o=1*this.ym.length,l=this.ys.timeScale.visible;let a=l?Math.max(this.Om.pm(),this.ys.timeScale.minimumHeight):0;var u;a=(u=a)+u%2;const c=o+a,f=n{t.Pv()})),3===this.Rm?.nn()&&(this.Rm.vn(t),this.hw(),this.aw(this.Rm),this.lw(this.Rm,i),t=this.Rm,this.Rm=null)),this.Zp(t)}lw(t,i){for(const s of t.pn())this.mn(s,i)}aw(t){const i=this.ts.$s();for(let s=0;s{if(this.Dm=!1,this.km=0, null!==this.Rm){const i=this.Rm;this.Rm=null,this.Ym(i,t);for(const s of i.pn())if(5===s.an&&!s.Ft.Mu(t)){this.Qt()._n(s.Ft);break}}})))}hw(){this.Fm()}$m(t){this.Bm.removeChild(t.Of()),t.m()}Fm(){const t=this.ts.$s(),i=t.length,s=this.Cm.length;for(let t=i;t0){const t=new as(this,e-1,e);this.ym.push(t),this.Bm.insertBefore(t.Of(),this.Om.Of())}this.Bm.insertBefore(i.Of(),this.Om.Of())}for(let s=0;s{const s=i.Xs().Wr(t);null!==s&&h.set(i,s)})),null!==t){const i=this.ts.At().ss(t)?.originalTime;void 0!==i&&(n=i)}const r=this.Qt().Gu(),o=null!==r&&r.Xo instanceof Jt?r.Xo:void 0,l=null!==r&&void 0!==r.Zo?r.Zo.Kn:void 0,a=this.cw(e);return{dw:n,Re:t??void 0,fw:i??void 0,pw:-1!==a?a:void 0,mw:o,ww:h,gw:l,Mw:s??void 0}}cw(t){let i=-1;if(t)i=this.Cm.indexOf(t);else{const t=this.Qt().sc().Us();null!==t&&(i=this.Qt().$s().indexOf(t))}return i}ow(t,i,s,e){this.uv.p((()=>this.uw(i,s,e,t)))}_w(t,i,s,e){this.cv.p((()=>this.uw(i,s,e,t)))}Lm(t,i,s){this.iw(this.Qt().Gu()?.Jo??null),this.Wu.p((()=>this.uw(t,i,s)))}Hm(){const t=this.ys.timeScale.visible?"":"none";this.Om.Of().style.display=t}Jm(){return this.Cm[0].Xf().Bo().N().visible}Qm(){return this.Cm[0].Xf().Ao().N().visible}Nm(){return"ResizeObserver"in window&&(this.Vm=new ResizeObserver((t=>{const i=t[t.length-1];i&&this.Wm(i.contentRect.width,i.contentRect.height)})),this.Vm.observe(this.wp,{box:"border-box"}),!0)}qm(){null!==this.Vm&&this.Vm.disconnect(),this.Vm=null}}function Bs(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Ds(t){return void 0===t.open&&void 0===t.value}function As(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function Ws(t,i,s,e){const h=s.value,n={Re:i,wt:t,Ft:[h,h,h,h],dw:e};return void 0!==s.color&&(n.R=s.color),n}function Fs(t,i,s,e){const h=s.value,n={Re:i,wt:t,Ft:[h,h,h,h],dw:e};return void 0!==s.lineColor&&(n.vt=s.lineColor),void 0!==s.topColor&&(n.mr=s.topColor),void 0!==s.bottomColor&&(n.wr=s.bottomColor),n}function Ls(t,i,s,e){const h=s.value,n={Re:i,wt:t,Ft:[h,h,h,h],dw:e};return void 0!==s.topLineColor&&(n.gr=s.topLineColor),void 0!==s.bottomLineColor&&(n.Mr=s.bottomLineColor),void 0!==s.topFillColor1&&(n.br=s.topFillColor1),void 0!==s.topFillColor2&&(n.Sr=s.topFillColor2),void 0!==s.bottomFillColor1&&(n.Cr=s.bottomFillColor1),void 0!==s.bottomFillColor2&&(n.yr=s.bottomFillColor2),n}function Os(t,i,s,e){const h={Re:i,wt:t,Ft:[s.open,s.high,s.low,s.close],dw:e};return void 0!==s.color&&(h.R=s.color),h}function Is(t,i,s,e){const h={Re:i,wt:t,Ft:[s.open,s.high,s.low,s.close],dw:e};return void 0!==s.color&&(h.R=s.color), void 0!==s.borderColor&&(h.Ht=s.borderColor),void 0!==s.wickColor&&(h.vr=s.wickColor),h}function Qs(t,i,s,e,h){const n=c(h)(s),r=Math.max(...n),o=Math.min(...n),l=n[n.length-1],a=[l,r,o,l],{time:u,color:d,...f}=s;return{Re:i,wt:t,Ft:a,dw:e,se:f,R:d}}function Xs(t){return void 0!==t.Ft}function $s(t,i){return void 0!==i.customValues&&(t.bw=i.customValues),t}function Js(t){return(i,s,e,h,n,r)=>function(t,i){return i?i(t):Ds(t)}(e,r)?$s({wt:i,Re:s,dw:h},e):$s(t(i,s,e,h,n),e)}function qs(t){return{Candlestick:Js(Is),Bar:Js(Os),Area:Js(Fs),Baseline:Js(Ls),Histogram:Js(Ws),Line:Js(Ws),Custom:Js(Qs)}[t]}function Us(t){return{Re:0,Sw:new Map,Hh:t}}function Zs(t,i){if(void 0!==t&&0!==t.length)return{xw:i.key(t[0].wt),Cw:i.key(t[t.length-1].wt)}}function Ks(t){let i;return t.forEach((t=>{void 0===i&&(i=t.dw)})),c(i)}class Gs{constructor(t){this.yw=new Map,this.kw=new Map,this.Pw=new Map,this.Tw=[],this.i_=t}m(){this.yw.clear(),this.kw.clear(),this.Pw.clear(),this.Tw=[]}Rw(t,i){let s=0!==this.yw.size,e=!1;const h=this.kw.get(t);if(void 0!==h)if(1===this.kw.size)s=!1,e=!0,this.yw.clear();else for(const i of this.Tw)i.pointData.Sw.delete(t)&&(e=!0);let n=[];if(0!==i.length){const s=i.map((t=>t.time)),h=this.i_.createConverterToInternalObj(i),r=qs(t.Rr()),o=t.da(),l=t.pa();n=i.map(((i,n)=>{const a=h(i.time),u=this.i_.key(a);let c=this.yw.get(u);void 0===c&&(c=Us(a),this.yw.set(u,c),e=!0);const d=r(a,c.Re,i,s[n],o,l);return c.Sw.set(t,d),d}))}s&&this.Dw(),this.Vw(t,n);let r=-1;if(e){const t=[];this.yw.forEach((i=>{t.push({timeWeight:0,time:i.Hh,pointData:i,originalTime:Ks(i.Sw)})})),t.sort(((t,i)=>this.i_.key(t.time)-this.i_.key(i.time))),r=this.Iw(t)}return this.Bw(t,r,function(t,i,s){const e=Zs(t,s),h=Zs(i,s);if(void 0!==e&&void 0!==h)return{Aw:!1,zh:e.Cw>=h.Cw&&e.xw>=h.xw}}(this.kw.get(t),h,this.i_))}yc(t){return this.Rw(t,[])}Ew(t,i,s){const e=i;!function(t){void 0===t.dw&&(t.dw=t.time)}(e),this.i_.preprocessData(i);const h=this.i_.createConverterToInternalObj([i])(i.time),n=this.Pw.get(t);if(!s&&void 0!==n&&this.i_.key(h)this.i_.key(t.time)this.i_.key(e.wt)?Xs(i)&&s.push(i):Xs(i)?s[s.length-1]=i:s.splice(-1,1),this.Pw.set(t,i.wt)}zw(t,i,s){const e=this.kw.get(t);if(void 0===e)return ;const h=Ct(e,s,((t,i)=>t.Re{0!==i.length&&(t=Math.max(t,i[i.length-1].Re))})),t}Bw(t,i,s){const e={Do:new Map,At:{iu:this.Ow()}};if(-1!==i)this.kw.forEach(((i,h)=>{e.Do.set(h,{se:i,Nw:h===t?s:void 0})})),this.kw.has(t)||e.Do.set(t,{se:[],Nw:s}),e.At.Ww=this.Tw,e.At.Fw=i;else{const i=this.kw.get(t);e.Do.set(t,{se:i||[],Nw:s})}return e}}function Hs(t,i){t.Re=i,t.Sw.forEach((t=>{t.Re=i}))}function js(t,i){return t.wt0&&n=e&&(o=n-1),r>0&&r({...t,...this.Jn.Rh().Dr(t.wt)})))}Gw(){this.Yw=null}Kw(){this.Uw&&(this.Jw(),this.Uw=!1),this.$w&&(this.Zw(),this.$w=!1),this.Hw&&(this.Qw(),this.Hw=!1)}Qw(){const t=this.Jn.Wt(),i=this.Qn.At();if(this.Gw(),i.Ki()||t.Ki())return;const s=i.ye();if(null===s)return;if(0===this.Jn.Xs().zr())return;const e=this.Jn.zt();null!==e&&(this.Yw=ie(this.qw,s,this.jw),this.tg(t,i,e.Ft),this.ig())}}class ee{constructor(t,i){this.sg=t,this.Yi=i}nt(t,i,s){this.sg.draw(t,this.Yi,i,s)}}class he extends se{constructor(t,i,s){super(t,i,!1),this.sh=s,this.Xw=new ee(this.sh.renderer(),(i=>{const s=t.zt();return null===s?null:t.Wt().Nt(i,s.Ft)}))}fa(t){return this.sh.priceValueBuilder(t)}va(t){return this.sh.isWhitespace(t)}Jw(){const t=this.Jn.Rh();this.qw=this.Jn.Xs().Hr().map((i=>({wt:i.Re,_t:NaN,...t.Dr(i.Re),ng:i.se})))}tg(t,i){i.su(this.qw,S(this.Yw))}ig(){this.sh.update({bars:this.qw.map(ne),barSpacing:this.Qn.At().lu(),visibleRange:this.Yw},this.Jn.N())}}function ne(t){return{x:t._t,time:t.wt,originalData:t.ng,barColor:t.cr}}const re={color:"#2196f3"},oe=(t,i,s)=>{const e=f(s);return new he(t,i,e)};function le(t){const i={value:t.Ft[3],time:t.dw};return void 0!==t.bw&&(i.customValues=t.bw),i}function ae(t){const i=le(t);return void 0!==t.R&&(i.color=t.R),i}function ue(t){const i=le(t);return void 0!==t.vt&&(i.lineColor=t.vt),void 0!==t.mr&&(i.topColor=t.mr),void 0!==t.wr&&(i.bottomColor=t.wr),i}function ce(t){const i=le(t) ;return void 0!==t.gr&&(i.topLineColor=t.gr),void 0!==t.Mr&&(i.bottomLineColor=t.Mr),void 0!==t.br&&(i.topFillColor1=t.br),void 0!==t.Sr&&(i.topFillColor2=t.Sr),void 0!==t.Cr&&(i.bottomFillColor1=t.Cr),void 0!==t.yr&&(i.bottomFillColor2=t.yr),i}function de(t){const i={open:t.Ft[0],high:t.Ft[1],low:t.Ft[2],close:t.Ft[3],time:t.dw};return void 0!==t.bw&&(i.customValues=t.bw),i}function fe(t){const i=de(t);return void 0!==t.R&&(i.color=t.R),i}function pe(t){const i=de(t),{R:s,Ht:e,vr:h}=t;return void 0!==s&&(i.color=s),void 0!==e&&(i.borderColor=e),void 0!==h&&(i.wickColor=h),i}function me(t){return{Area:ue,Line:ae,Baseline:ce,Histogram:ae,Bar:fe,Candlestick:pe,Custom:ge}[t]}function ge(t){const i=t.dw;return{...t.se,time:i}}const ve={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1},we={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},be={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:x,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},ye={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1},Me={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1};function Se(){return{width:0,height:0,autoSize:!1,layout:be,crosshair:ve,grid:we,overlayPriceScales:{...ye},leftPriceScale:{...ye,visible:!1},rightPriceScale:{...ye,visible:!0},timeScale:Me,localization:{locale:ji?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class xe{constructor(t,i,s){this.Df=t,this.eg=i,this.rg=s??0}applyOptions(t){this.Df.Qt().Qu(this.eg,t,this.rg)}options(){return this.Yi().N()}width(){return G(this.eg)?this.Df.Gm(this.eg):0}setVisibleRange(t){this.setAutoScale(!1),this.Yi().Nl(new gt(t.from,t.to))}getVisibleRange(){const t=this.Yi().Qe();return null===t?null:{from:t.$e(),to:t.qe()}}setAutoScale(t){this.applyOptions({autoScale:t})}Yi(){return d(this.Df.Qt().tc(this.eg,this.rg)).Wt}}class _e{constructor(t,i,s,e){this.Df=t,this.yt=s,this.hg=i,this.ag=e}getHeight(){return this.yt.$t()}setHeight(t){const i=this.Df.Qt(),s=i.Bc(this.yt);i.hc(s,t)}paneIndex(){ return this.Df.Qt().Bc(this.yt)}moveTo(t){const i=this.paneIndex();i!==t&&(u(t>=0&&tthis.hg(t)))??[]}getHTMLElement(){return this.Df.If()[this.paneIndex()].Of()}attachPrimitive(t){this.yt.ua(t),t.attached&&t.attached({chart:this.ag,requestUpdate:()=>this.yt.Qt().Bh()})}detachPrimitive(t){this.yt.ca(t)}priceScale(t){if(null===this.yt.Co(t))throw new Error(`Cannot find price scale with id: ${t}`);return new xe(this.Df,t,this.paneIndex())}}const Ce={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class ke{constructor(t){this.ir=t}applyOptions(t){this.ir.hr(t)}options(){return this.ir.N()}lg(){return this.ir}}class ze{constructor(t,i,s,e,h,n){this.og=new p,this.Jn=t,this._g=i,this.ug=s,this.i_=h,this.ag=e,this.cg=n}m(){this.og.m()}priceFormatter(){return this.Jn.ra()}priceToCoordinate(t){const i=this.Jn.zt();return null===i?null:this.Jn.Wt().Nt(t,i.Ft)}coordinateToPrice(t){const i=this.Jn.zt();return null===i?null:this.Jn.Wt().Ts(t,i.Ft)}barsInLogicalRange(t){if(null===t)return null;const i=new Ri(new Ci(t.from,t.to)).w_(),s=this.Jn.Xs();if(s.Ki())return null;const e=s.Wr(i.Uh(),1),h=s.Wr(i.bi(),-1),n=d(s.Lr()),r=d(s.Ks());if(null!==e&&null!==h&&e.Re>h.Re)return{barsBefore:t.from-n,barsAfter:r-t.to};const o={barsBefore:null===e||e.Re===n?t.from-n:e.Re-n,barsAfter:null===h||h.Re===r?r-t.to:r-h.Re};return null!==e&&null!==h&&(o.from=e.dw,o.to=h.dw),o}setData(t){this.i_,this.Jn.Rr(),this._g.dg(this.Jn,t),this.fg("full")}update(t,i=!1){this.Jn.Rr(),this._g.pg(this.Jn,t,i),this.fg("update")}dataByIndex(t,i){const s=this.Jn.Xs().Wr(t,i);return null===s?null:me(this.seriesType())(s)}data(){const t=me(this.seriesType());return this.Jn.Xs().Hr().map((i=>t(i)))}subscribeDataChanged(t){this.og.i(t)}unsubscribeDataChanged(t){this.og._(t)}applyOptions(t){this.Jn.hr(t)}options(){return y(this.Jn.N())}priceScale(){return this.ug.priceScale(this.Jn.Wt().wa(),this.getPane().paneIndex())}createPriceLine(t){const i=m(y(Ce),t),s=this.Jn.Oh(i);return new ke(s)}removePriceLine(t){this.Jn.Nh(t.lg())}priceLines(){return this.Jn.Wh().map((t=>new ke(t)))}seriesType(){return this.Jn.Rr()}attachPrimitive(t){this.Jn.ua(t),t.attached&&t.attached({chart:this.ag,series:this,requestUpdate:()=>this.Jn.Qt().Bh(),horzScaleBehavior:this.i_})}detachPrimitive(t){this.Jn.ca(t),t.detached&&t.detached(),this.Jn.Qt().Bh()}getPane(){const t=this.Jn,i=d(this.Jn.Qt().Hn(t));return this.cg(i)}moveToPane(t){this.Jn.Qt().Rc(this.Jn,t)}seriesOrder(){const t=this.Jn.Qt().Hn(this.Jn);return null===t?-1:t.Do().indexOf(this.Jn)}setSeriesOrder(t){const i=this.Jn.Qt().Hn(this.Jn);null!==i&&i.qo(this.Jn,t)}fg(t){this.og.v()&&this.og.p(t)}}class Re{constructor(t,i,s){this.vg=new p,this.T_=new p,this.rm=new p,this.ts=t,this.uh=t.At(),this.Om=i,this.uh.Su().i(this.mg.bind(this)),this.uh.xu().i(this.wg.bind(this)),this.Om.dm().i(this.gg.bind(this)),this.i_=s}m(){this.uh.Su().u(this), this.uh.xu().u(this),this.Om.dm().u(this),this.vg.m(),this.T_.m(),this.rm.m()}scrollPosition(){return this.uh._u()}scrollToPosition(t,i){i?this.uh.gu(t,1e3):this.ts.fn(t)}scrollToRealTime(){this.uh.wu()}getVisibleRange(){const t=this.uh.K_();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.i_.convertHorzItemToInternal(t.from),to:this.i_.convertHorzItemToInternal(t.to)},s=this.uh.J_(i);this.ts.Pc(s)}getVisibleLogicalRange(){const t=this.uh.j_();return null===t?null:{from:t.Uh(),to:t.bi()}}setVisibleLogicalRange(t){u(t.from<=t.to,"The from index cannot be after the to index."),this.ts.Pc(t)}resetTimeScale(){this.ts.cn()}fitContent(){this.ts.ku()}logicalToCoordinate(t){const i=this.ts.At();return i.Ki()?null:i.qt(t)}coordinateToLogical(t){return this.uh.Ki()?null:this.uh.nu(t)}timeToIndex(t,i){const s=this.i_.convertHorzItemToInternal(t);return this.uh.U_(s,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this.uh.qt(i)}coordinateToTime(t){const i=this.ts.At(),s=i.nu(t),e=i.ss(s);return null===e?null:e.originalTime}width(){return this.Om.Nf().width}height(){return this.Om.Nf().height}subscribeVisibleTimeRangeChange(t){this.vg.i(t)}unsubscribeVisibleTimeRangeChange(t){this.vg._(t)}subscribeVisibleLogicalRangeChange(t){this.T_.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.T_._(t)}subscribeSizeChange(t){this.rm.i(t)}unsubscribeSizeChange(t){this.rm._(t)}applyOptions(t){this.uh.hr(t)}options(){return{...y(this.uh.N()),barSpacing:this.uh.lu()}}mg(){this.vg.v()&&this.vg.p(this.getVisibleRange())}wg(){this.T_.v()&&this.T_.p(this.getVisibleLogicalRange())}gg(t){this.rm.p(t.width,t.height)}}function Ne(t){return function(t){if(b(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:s}=t.handleScale;b(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),b(s)&&(t.handleScale.axisDoubleClickReset={time:s,price:s})}const i=t.handleScroll;b(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class Ee{constructor(t,i,s){this.Mg=new Map,this.bg=new Map,this.Sg=new p,this.xg=new p,this.Cg=new p,this.zu=new WeakMap,this.yg=new Gs(i);const e=void 0===s?y(Se()):m(y(Se()),Ne(s));this.kg=i,this.Df=new Vs(t,e,i),this.Df.Lv().i((t=>{this.Sg.v()&&this.Sg.p(this.Pg(t()))}),this),this.Df.Ov().i((t=>{this.xg.v()&&this.xg.p(this.Pg(t()))}),this),this.Df.nc().i((t=>{this.Cg.v()&&this.Cg.p(this.Pg(t()))}),this);const h=this.Df.Qt();this.Tg=new Re(h,this.Df.Um(),this.kg)}remove(){this.Df.Lv().u(this),this.Df.Ov().u(this),this.Df.nc().u(this),this.Tg.m(),this.Df.m(),this.Mg.clear(),this.bg.clear(),this.Sg.m(),this.xg.m(),this.Cg.m(),this.yg.m()}resize(t,i,s){this.autoSizeActive()||this.Df.Wm(t,i,s)}addCustomSeries(t,i={},s=0){const e=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...re,...t.defaultOptions()},Rg:oe,Dg:t}))(f(t)) ;return this.Vg(e,i,s)}addSeries(t,i={},s=0){return this.Vg(t,i,s)}removeSeries(t){const i=c(this.Mg.get(t)),s=this.yg.yc(i);this.Df.Qt().yc(i),this.Ig(s),this.Mg.delete(t),this.bg.delete(i)}dg(t,i){this.Ig(this.yg.Rw(t,i))}pg(t,i,s){this.Ig(this.yg.Ew(t,i,s))}subscribeClick(t){this.Sg.i(t)}unsubscribeClick(t){this.Sg._(t)}subscribeCrosshairMove(t){this.Cg.i(t)}unsubscribeCrosshairMove(t){this.Cg._(t)}subscribeDblClick(t){this.xg.i(t)}unsubscribeDblClick(t){this.xg._(t)}priceScale(t,i=0){return new xe(this.Df,t,i)}timeScale(){return this.Tg}applyOptions(t){this.Df.hr(Ne(t))}options(){return this.Df.N()}takeScreenshot(){return this.Df.Xm()}removePane(t){this.Df.Qt().rc(t)}swapPanes(t,i){this.Df.Qt().ac(t,i)}autoSizeActive(){return this.Df.tw()}chartElement(){return this.Df.Uf()}panes(){return this.Df.Qt().$s().map((t=>this.Bg(t)))}paneSize(t=0){const i=this.Df.nw(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,s){const e=this.Mg.get(s);if(void 0===e)return;const h=this.Df.Qt().Hn(e);null!==h&&this.Df.Qt().gc(t,i,h)}clearCrosshairPosition(){this.Df.Qt().Mc(!0)}horzBehaviour(){return this.kg}Vg(t,i={},s=0){u(void 0!==t.Rg),function(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=function(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const s=Math.round(t);if(Math.abs(s-t)<1e-8)return i;t*=10}return i}(i.minMove))}(i.priceFormat),"Candlestick"===t.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(i);const e=m(y(h),y(t.defaultOptions),i),n=t.Rg,r=new Jt(this.Df.Qt(),t.type,e,n,t.Dg);this.Df.Qt().xc(r,s);const o=new ze(r,this,this,this,this.kg,(t=>this.Bg(t)));return this.Mg.set(o,r),this.bg.set(r,o),o}Ig(t){const i=this.Df.Qt();i.bc(t.At.iu,t.At.Ww,t.At.Fw),t.Do.forEach(((t,i)=>i.ht(t.se,t.Nw))),i.At().O_(),i.au()}Ag(t){return c(this.bg.get(t))}Pg(t){const i=new Map;t.ww.forEach(((t,s)=>{const e=s.Rr(),h=me(e)(t);if("Custom"!==e)u(As(h));else{const t=s.pa();u(!t||!1===t(h))}i.set(this.Ag(s),h)}));const s=void 0!==t.mw&&this.bg.has(t.mw)?this.Ag(t.mw):void 0;return{time:t.dw,logical:t.Re,point:t.fw,paneIndex:t.pw,hoveredSeries:s,hoveredObjectId:t.gw,seriesData:i,sourceEvent:t.Mw}}Bg(t){let i=this.zu.get(t);return i||(i=new _e(this.Df,(t=>this.Ag(t)),t,this),this.zu.set(t,i)),i}}function Ye(t){if(w(t)){const i=document.getElementById(t);return u(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}function Te(t,i,s){const e=Ye(t),h=new Ee(e,i,s);return i.setOptions(h.options()),h}function Pe(){return Hi}class Ve extends se{constructor(t,i){super(t,i,!0)}tg(t,i,s){i.su(this.qw,S(this.Yw)),t.Hl(this.qw,s,S(this.Yw))}Eg(t,i){return{wt:t,gt:i,_t:NaN,ut:NaN}}Jw(){const t=this.Jn.Rh();this.qw=this.Jn.Xs().Hr().map((i=>{const s=i.Ft[3];return this.zg(i.Re,s,t)}))}}function Be(t,i,s,e,h,n,r){if(0===i.length||e.from>=i.length||e.to<=0)return;const{context:o,horizontalPixelRatio:l,verticalPixelRatio:a}=t,u=i[e.from] ;let c=n(t,u),d=u;if(e.to-e.from<2){const i=h/2;o.beginPath();const s={_t:u._t-i,ut:u.ut},e={_t:u._t+i,ut:u.ut};o.moveTo(s._t*l,s.ut*a),o.lineTo(e._t*l,e.ut*a),r(t,c,s,e)}else{const h=(i,s)=>{r(t,c,d,s),o.beginPath(),c=i,d=s};let f=d;o.beginPath(),o.moveTo(u._t*l,u.ut*a);for(let r=e.from+1;r=e.from;--s){const e=i[s];if(e){const i=h(t,e);i!==l&&(o.beginPath(),null!==l&&o.fill(),o.fillStyle=i,l=i);const s=Math.round(e._t*n)+a,c=e.ut*r;o.moveTo(s,c),o.arc(s,c,u,0,2*Math.PI)}}o.fill()}(t,i,o,s,u)}}class Ie extends Oe{Wg(t,i){return i.vt}}class Qe extends Ve{constructor(){super(...arguments),this.Xw=new Ie}zg(t,i,s){return{...this.Eg(t,i),...s.Dr(t)}}ig(){const t=this.Jn.N(),i={ot:this.qw,Xt:t.lineStyle,Og:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Ng:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Yw,Lg:this.Qn.At().lu()};this.Xw.ht(i)}}const Xe={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},Rg:(t,i)=>new Qe(t,i)};function $e(t,i,s,e,h){const{context:n,horizontalPixelRatio:r,verticalPixelRatio:o}=i;n.lineTo(h._t*r,t*o),n.lineTo(e._t*r,t*o),n.closePath(),n.fillStyle=s,n.fill()}class Je extends E{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:s,Lg:e,ct:h,Xt:n,Og:r}=this.rt,o=this.rt.jg??(this.rt.Kg?0:t.mediaSize.height);if(null===s)return;const a=t.context;a.lineCap="butt",a.lineJoin="round",a.lineWidth=h,l(a,n),a.lineWidth=1,Be(t,i,r,s,e,this.Xg.bind(this),$e.bind(null,o))}}class qe{Zg(t,i){const s=this.Gg,{Jg:e,Qg:h,tM:n,iM:r,jg:o,sM:l,nM:a}=i ;if(void 0===this.eM||void 0===s||s.Jg!==e||s.Qg!==h||s.tM!==n||s.iM!==r||s.jg!==o||s.sM!==l||s.nM!==a){const{verticalPixelRatio:s}=t,u=o||l>0?s:1,c=l*u,d=a===t.bitmapSize.height?a:a*u,f=(o??0)*u,p=t.context.createLinearGradient(0,c,0,d);if(p.addColorStop(0,e),null!=o){const t=Kt((f-c)/(d-c),0,1);p.addColorStop(t,h),p.addColorStop(t,n)}p.addColorStop(1,r),this.eM=p,this.Gg=i}return this.eM}}class Ue extends Je{constructor(){super(...arguments),this.rM=new qe}Xg(t,i){const s=this.rt;return this.rM.Zg(t,{Jg:i.br,Qg:i.Sr,tM:i.Cr,iM:i.yr,jg:s.jg,sM:s.sM??0,nM:s.nM??t.bitmapSize.height})}}class Ze extends Oe{constructor(){super(...arguments),this.hM=new qe}Wg(t,i){const s=this.rt;return this.hM.Zg(t,{Jg:i.gr,Qg:i.gr,tM:i.Mr,iM:i.Mr,jg:s.jg,sM:s.sM??0,nM:s.nM??t.bitmapSize.height})}}class Ke extends Ve{constructor(t,i){super(t,i),this.Xw=new N,this.aM=new Ue,this.lM=new Ze,this.Xw.st([this.aM,this.lM])}zg(t,i,s){return{...this.Eg(t,i),...s.Dr(t)}}ig(){const t=this.Jn.zt();if(null===t)return;const i=this.Jn.N(),s=this.Jn.Wt().Nt(i.baseValue.price,t.Ft),e=this.Qn.At().lu();if(null===this.Yw||0===this.qw.length)return;let h,n;if(i.relativeGradient){h=this.qw[this.Yw.from].ut,n=this.qw[this.Yw.from].ut;for(let t=this.Yw.from;tn&&(n=i.ut)}}this.aM.ht({ot:this.qw,ct:i.lineWidth,Xt:i.lineStyle,Og:i.lineType,jg:s,sM:h,nM:n,Kg:!1,lt:this.Yw,Lg:e}),this.lM.ht({ot:this.qw,ct:i.lineWidth,Xt:i.lineStyle,Og:i.lineVisible?i.lineType:void 0,Ng:i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,jg:s,sM:h,nM:n,lt:this.Yw,Lg:e})}}const Ge={type:"Baseline",isBuiltIn:!0,defaultOptions:{baseValue:{type:"price",price:0},relativeGradient:!1,topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",topLineColor:"rgba(38, 166, 154, 1)",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",bottomLineColor:"rgba(239, 83, 80, 1)",lineWidth:3,lineStyle:0,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},Rg:(t,i)=>new Ke(t,i)};class He extends Je{constructor(){super(...arguments),this.rM=new qe}Xg(t,i){return this.rM.Zg(t,{Jg:i.mr,Qg:"",tM:"",iM:i.wr,sM:this.rt?.sM??0,nM:t.bitmapSize.height})}}class je extends Ve{constructor(t,i){super(t,i),this.Xw=new N,this.oM=new He,this._M=new Ie,this.Xw.st([this.oM,this._M])}zg(t,i,s){return{...this.Eg(t,i),...s.Dr(t)}}ig(){const t=this.Jn.N();if(null===this.Yw||0===this.qw.length)return;let i;if(t.relativeGradient){i=this.qw[this.Yw.from].ut;for(let t=this.Yw.from;tnew je(t,i)};class ih extends E{constructor(){super(...arguments),this.Yt=null,this.uM=0,this.cM=0}ht(t){this.Yt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Yt||0===this.Yt.Xs.length||null===this.Yt.lt)return;this.uM=this.dM(i),this.uM>=2&&Math.max(1,Math.floor(i))%2!=this.uM%2&&this.uM--,this.cM=this.Yt.fM?Math.min(this.uM,Math.floor(i)):this.uM;let e=null;const h=this.cM<=this.uM&&this.Yt.lu>=Math.floor(1.5*i);for(let n=this.Yt.lt.from;np+g-1&&(h=p+g-1,e=h-u+1),t.fillRect(i,e,a-i,h-e+1)}const i=l+v;let e=Math.max(p,Math.round(r.Kl*s)-o),h=e+u-1;h>p+g-1&&(h=p+g-1,e=h-u+1),t.fillRect(c+1,e,i-c,h-e+1)}}}dM(t){const i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(d(this.Yt).lu,t)))}}class sh extends se{constructor(t,i){super(t,i,!1)}tg(t,i,s){i.su(this.qw,S(this.Yw)),t.$l(this.qw,s,S(this.Yw))}vM(t,i,s){return{wt:t,qh:i.Ft[0],Yh:i.Ft[1],jh:i.Ft[2],Kh:i.Ft[3],_t:NaN,ql:NaN,Yl:NaN,jl:NaN,Kl:NaN}}Jw(){const t=this.Jn.Rh();this.qw=this.Jn.Xs().Hr().map((i=>this.zg(i.Re,i,t)))}}class eh extends sh{constructor(){super(...arguments),this.Xw=new ih}zg(t,i,s){return{...this.vM(t,i,s),...s.Dr(t)}}ig(){const t=this.Jn.N();this.Xw.ht({Xs:this.qw,lu:this.Qn.At().lu(),pM:t.openVisible,fM:t.thinBars,lt:this.Yw})}}const hh={type:"Bar",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},Rg:(t,i)=>new eh(t,i)};class nh extends E{constructor(){super(...arguments),this.Yt=null,this.uM=0}ht(t){this.Yt=t}et(t){if(null===this.Yt||0===this.Yt.Xs.length||null===this.Yt.lt)return;const{horizontalPixelRatio:i}=t;this.uM=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const s=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),e=Math.floor(t*s*i),h=Math.floor(t*i),n=Math.min(e,h);return Math.max(Math.floor(i),n)}(this.Yt.lu,i),this.uM>=2&&Math.floor(i)%2!=this.uM%2&&this.uM--;const s=this.Yt.Xs;this.Yt.mM&&this.wM(t,s,this.Yt.lt),this.Yt.Mi&&this.Qp(t,s,this.Yt.lt);const e=this.gM(i);(!this.Yt.Mi||this.uM>2*e)&&this.MM(t,s,this.Yt.lt)}wM(t,i,s){if(null===this.Yt)return;const{context:e,horizontalPixelRatio:h,verticalPixelRatio:n}=t ;let r="",o=Math.min(Math.floor(h),Math.floor(this.Yt.lu*h));o=Math.max(Math.floor(h),Math.min(o,this.uM));const l=Math.floor(.5*o);let a=null;for(let t=s.from;t2*o)A(e,a,c,u-a+1,d-c+1,o);else{const t=u-a+1;e.fillRect(a,c,t,d-c+1)}l=u}}MM(t,i,s){if(null===this.Yt)return;const{context:e,horizontalPixelRatio:h,verticalPixelRatio:n}=t;let r="";const o=this.gM(h);for(let t=s.from;ta||e.fillRect(u,l,c-u+1,a-l+1)}}}class rh extends sh{constructor(){super(...arguments),this.Xw=new nh}zg(t,i,s){return{...this.vM(t,i,s),...s.Dr(t)}}ig(){const t=this.Jn.N();this.Xw.ht({Xs:this.qw,lu:this.Qn.At().lu(),mM:t.wickVisible,Mi:t.borderVisible,lt:this.Yw})}}const oh={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},Rg:(t,i)=>new rh(t,i)};class lh extends E{constructor(){super(...arguments),this.Yt=null,this.bM=[]}ht(t){this.Yt=t,this.bM=[]}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Yt||0===this.Yt.ot.length||null===this.Yt.lt)return;this.bM.length||this.SM(i);const e=Math.max(1,Math.floor(s)),h=Math.round(this.Yt.xM*s)-Math.floor(e/2),n=h+e;for(let i=this.Yt.lt.from;ie.ne?e.bi=s.Uh-i-1:s.Uh=e.bi+i+1)}let e=Math.ceil(this.Yt.lu*t);for(let t=this.Yt.lt.from;t0&&e<4)for(let t=this.Yt.lt.from;te&&(i.CM>i.ne?i.bi-=1:i.Uh+=1)}}}class ah extends Ve{constructor(){super(...arguments),this.Xw=new lh}zg(t,i,s){return{...this.Eg(t,i),...s.Dr(t)}}ig(){const t={ot:this.qw,lu:this.Qn.At().lu(),lt:this.Yw,xM:this.Jn.Wt().Nt(this.Jn.N().base,d(this.Jn.zt()).Ft)};this.Xw.ht(t)}}const uh={type:"Histogram",isBuiltIn:!0,defaultOptions:{color:"#26a69a",base:0},Rg:(t,i)=>new ah(t,i)};class ch{constructor(t,i){this.yt=t,this.yM=i,this.kM()}detach(){this.yt.detachPrimitive(this.yM)}getPane(){return this.yt}applyOptions(t){this.yM.hr?.(t)}kM(){this.yt.attachPrimitive(this.yM)}}const dh={visible:!0,horzAlign:"center",vertAlign:"center",lines:[]},fh={color:"rgba(0, 0, 0, 0.5)",fontSize:48,fontFamily:x,fontStyle:"",text:""};class ph{constructor(t){this.PM=new Map,this.Yt=t}draw(t){t.useMediaCoordinateSpace((t=>{if(!this.Yt.visible)return;const{context:i,mediaSize:s}=t;let e=0;for(const t of this.Yt.lines){if(0===t.text.length)continue;i.font=t.P;const h=this.TM(i,t.text);h>s.width?t.pu=s.width/h:t.pu=1,e+=t.lineHeight*t.pu}let h=0;switch(this.Yt.vertAlign){case"top":h=0;break;case"center":h=Math.max((s.height-e)/2,0);break;case"bottom":h=Math.max(s.height-e,0)}for(const t of this.Yt.lines){i.save(),i.fillStyle=t.color;let e=0;switch(this.Yt.horzAlign){case"left":i.textAlign="left",e=t.lineHeight/2;break;case"center":i.textAlign="center",e=s.width/2;break;case"right":i.textAlign="right",e=s.width-1-t.lineHeight/2}i.translate(e,h),i.textBaseline="top",i.font=t.P,i.scale(t.pu,t.pu),i.fillText(t.text,0,t.RM),i.restore(),h+=t.lineHeight*t.pu}}))}TM(t,i){const s=this.DM(t.font);let e=s.get(i);return void 0===e&&(e=t.measureText(i).width,s.set(i,e)),e}DM(t){let i=this.PM.get(t);return void 0===i&&(i=new Map,this.PM.set(t,i)),i}}class mh{constructor(t){this.ys=vh(t)}kt(t){this.ys=vh(t)}renderer(){return new ph(this.ys)}}function gh(t){return{...t,P:_(t.fontSize,t.fontFamily,t.fontStyle),lineHeight:t.lineHeight||1.2*t.fontSize,RM:0,pu:0}}function vh(t){return{...t,lines:t.lines.map(gh)}}function wh(t){return{...fh,...t}}function bh(t){return{...dh,...t,lines:t.lines?.map(wh)??[]}}class yh{constructor(t){this.ys=bh(t),this.VM=[new mh(this.ys)]}updateAllViews(){this.VM.forEach((t=>t.kt(this.ys)))}paneViews(){return this.VM}attached({requestUpdate:t}){this.IM=t}detached(){this.IM=void 0}hr(t){this.ys=bh({...this.ys,...t}),this.IM&&this.IM()}}function Mh(t,i){return new ch(t,new yh(i))}}}]);