"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[360],{84682:(e,t,i)=>{i.d(t,{BrushBasePaneView:()=>d});var n=i(10555),r=i(17773),o=i(45801),s=i(94602),a=i(73914),l=i(2383),h=i(54707);class d extends h.LineSourcePaneView{constructor(){super(...arguments),this._polygonRenderer=new r.PolygonRenderer,this._renderer=new s.CompositeRenderer}renderer(e){return this._invalidated&&this._updateImpl(e),this._renderer}_updateImpl(e){super._updateImpl(e);const t=Math.max(1,this._source.smooth()),i=this._points;if(0===i.length)return void this._renderer.clear();const n=[i[0]];for(let e=1;e0){const t=1!==e?[r.points[0],r.points[e-1]]:[r.points[0]],i=new o.SelectionRenderer({points:t.map(a.mapLineSourcePaneViewPointToLineAnchorPoint),bgColors:this._lineAnchorColors(t),visible:this.areAnchorsVisible(),hittestResult:l.HitTarget.Regular,barSpacing:this._getModel().timeScale().barSpacing()});this._renderer.append(i)}}}_addAnchors(){return!0}_smoothArray(e,t){if(1===e.length)return e;const i=new Array(e.length);for(let r=0;r{i.r(t),i.d(t,{LineToolDemonstrationHighlighter:()=>h});var n=i(4226),r=i(78176),o=i(55393),s=i(69558),a=i(84682);class l extends a.BrushBasePaneView{_createPolygonRendererData(){return{points:this._points,color:this._source.color(),linewidth:this._source.width(),backcolor:"rgba(0, 0, 0, 0)",fillBackground:!1,linestyle:s.LINESTYLE_SOLID,filled:!1,globalAlpha:1-this._source.animationProgress(),disableInteractions:!0}}_addAnchors(){return!1}}class h extends o.LineToolBrushBase{constructor(e,t,i,r){super(e,h.createProperties(e.backgroundTheme().spawnOwnership()),!1,(0,n.randomHash)()),this._creationTime=null,this._color=t,this._width=i,this._visibilityTime=r,this._setPaneViews([new l(this,e)])}smooth(){return 5}color(){return this._color}width(){return this._width}name(){return"Presentation highlighter"}canBeHidden(){return!1}finish(){super.finish(),this._creationTime=performance.now()}animationProgress(){if(null===this._creationTime)return 0;const e=(performance.now()-this._creationTime)/this._visibilityTime;return Math.min(1,e)}static createProperties(e){const t=new r.DefaultProperty({defaultName:"",useUserPreferences:!1,state:void 0,theme:e});return this._configureProperties(t),t}_ignoreSourceEvent(e){return"data-source-change"===e.type&&e.sourceId!==this.model().crosshairSource().id()}}},54707:(e,t,i)=>{i.d(t,{ LineSourcePaneView:()=>P,anchorResizeCursorType:()=>p,createLineSourcePaneViewPoint:()=>g});var n=i(58978),r=i(50151),o=i(39612),s=i(2383),a=i(45801),l=i(73914),h=i(43838),d=i(4753);const c=n.colorsPalette["color-tv-blue-600"];var u,_;function p(e,t){const i=e.x-t.x,n=e.y-t.y;if(!Number.isFinite(i)||!Number.isFinite(n)||0===i&&0===n)return h.PaneCursorType.Default;let o=Math.atan2(n,i);return o<0&&(o+=2*Math.PI),o>=_.deg337_5||o<_.deg22_5||o>=_.deg157_5&&o<_.deg202_5?h.PaneCursorType.HorizontalResize:o>=_.deg22_5&&o<_.deg67_5||o>=_.deg202_5&&o<_.deg247_5?h.PaneCursorType.DiagonalNwSeResize:o>=_.deg67_5&&o<_.deg112_5||o>=_.deg247_5&&o<_.deg292_5?h.PaneCursorType.VerticalResize:o>=_.deg112_5&&o<_.deg157_5||o>=_.deg292_5&&o<_.deg337_5?h.PaneCursorType.DiagonalNeSwResize:void(0,r.assert)(!1,"unexpected angle")}function g(e,t){return e.pointIndex=t,e}!function(e){e[e.RegularAnchorRadius=6]="RegularAnchorRadius",e[e.TouchAnchorRadius=13]="TouchAnchorRadius",e[e.RegularStrokeWidth=1]="RegularStrokeWidth",e[e.TouchStrokeWidth=3]="TouchStrokeWidth",e[e.RegularSelectedStrokeWidth=3]="RegularSelectedStrokeWidth",e[e.TouchSelectedStrokeWidth=0]="TouchSelectedStrokeWidth"}(u||(u={})),function(e){e[e.deg22_5=Math.PI/8]="deg22_5",e[e.deg67_5=3*Math.PI/8]="deg67_5",e[e.deg112_5=5*Math.PI/8]="deg112_5",e[e.deg157_5=7*Math.PI/8]="deg157_5",e[e.deg202_5=9*Math.PI/8]="deg202_5",e[e.deg247_5=11*Math.PI/8]="deg247_5",e[e.deg292_5=13*Math.PI/8]="deg292_5",e[e.deg337_5=15*Math.PI/8]="deg337_5"}(_||(_={}));class P{constructor(e,t,i){this._invalidated=!0,this._points=[],this._middlePoint=null,this._selectionRenderers=[],this._lineAnchorRenderers=[],this._source=e,this._model=t,this._ownerSource=i??null}priceToCoordinate(e){const t=this._getOwnerSource(),i=t?.priceScale();if(null==i)return null;const n=null!==t?t.firstValue():null;return null===n?null:i.priceToCoordinate(e,n)}anchorColor(){return c}isHoveredSource(){return this._source===this._model.hoveredSource()}isSelectedSource(){return this._model.selection().isSelected(this._source)}isBeingEdited(){return this._model.lineBeingEdited()===this._source}isEditMode(){return!this._model.isSnapshot()}areAnchorsVisible(){return(this.isHoveredSource()&&!this.isLocked()||this.isSelectedSource())&&this.isEditMode()}update(){this._invalidated=!0}isLocked(){return Boolean(this._source.isLocked&&this._source.isLocked())}addAnchors(e,t={}){let i=this._getPoints();this._model.lineBeingCreated()===this._source&&(i=i.slice(0,-1));const n=this._source.points(),r=i.map(((e,t)=>{const i=n[t],r=(0,l.lineSourcePaneViewPointToLineAnchorPoint)(e);return i&&(r.snappingPrice=i.price,r.snappingIndex=i.index),r}));e.append(this.createLineAnchor({...t,points:r},0))}createLineAnchor(e,t){const i=e.points.map((e=>e.point)),n=this._getOwnerSource();if(this.isLocked()){const r=this._getSelectionRenderer(t);return r.setData({bgColors:this._lineAnchorColors(i),points:e.points,visible:this.areAnchorsVisible(),hittestResult:s.HitTarget.Regular,ownerSourceId:n?.id(),barSpacing:this._model.timeScale().barSpacing()}),r} const r=(0,o.lastMouseOrTouchEventInfo)().isTouch,a=this._getLineAnchorRenderer(t),l=this.isHoveredSource()?this._model.lastHittestData()?.pointIndex??null:null;return a.setData({...e,color:this.anchorColor(),backgroundColors:this._lineAnchorColors(i),hoveredPointIndex:l,linePointBeingEdited:this.isBeingEdited()?this._model.linePointBeingEdited():null,radius:this._anchorRadius(),strokeWidth:r?u.TouchStrokeWidth:u.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:r?u.TouchSelectedStrokeWidth:u.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible(),clickHandler:e.clickHandler,ownerSourceId:n?.id()}),a}_getOwnerSource(){return this._ownerSource??this._source.ownerSource()}_anchorRadius(){return(0,o.lastMouseOrTouchEventInfo)().isTouch?u.TouchAnchorRadius:u.RegularAnchorRadius}_lineAnchorColors(e){const t=(0,r.ensureNotNull)(this._model.paneForSource(this._source)).height();return e.map((e=>this._model.backgroundColorAtYPercentFromTop(e.y/t)))}_updateImpl(e){this._points=[];this._model.timeScale().isEmpty()||this._validatePriceScale()&&(this._source.points().forEach(((e,t)=>{const i=this._source.pointToScreenPoint(e,this._ownerSource??void 0);i&&this._points.push(g(i,t))})),2===this._points.length&&(this._middlePoint=this._source.calcMiddlePoint(this._points[0],this._points[1])),this._invalidated=!1)}_validatePriceScale(){const e=this._getOwnerSource()?.priceScale();return null!=e&&!e.isEmpty()}_getSource(){return this._source}_getPoints(){return this._points}_getModel(){return this._model}_height(){const e=this._getOwnerSource()?.priceScale();return null!=e?e.height():0}_width(){return this._model.timeScale().width()}_needLabelExclusionPath(e,t){const i=this._source.properties().childs();return"middle"===(t??i.vertLabelsAlign.value())&&(0,d.needTextExclusionPath)(e)}_addAlertRenderer(e,t,i=this._source.properties().linecolor.value()){}_getAlertRenderer(e,t=this._source.properties().linecolor.value(),i){return null}_getSelectionRenderer(e){for(;this._selectionRenderers.length<=e;)this._selectionRenderers.push(new a.SelectionRenderer);return this._selectionRenderers[e]}_getLineAnchorRenderer(e){for(;this._lineAnchorRenderers.length<=e;)this._lineAnchorRenderers.push(new l.LineAnchorRenderer);return this._lineAnchorRenderers[e]}}},73914:(e,t,i)=>{i.d(t,{LineAnchorRenderer:()=>f,lineSourcePaneViewPointToLineAnchorPoint:()=>S,lineSourcePaneViewPointToLineAnchorPoint2:()=>m,mapLineSourcePaneViewPointToLineAnchorPoint:()=>w});var n=i(10555),r=i(6453),o=i(50151),s=i(58221),a=i(87465),l=i(2383),h=i(43838),d=i(4539),c=i(10307);function u(e,t,i,n){const{point:r}=t,o=i+n/2;(0,s.drawRoundRect)(e,r.x-o,r.y-o,2*o,2*o,(i+n)/2),e.closePath(),e.lineWidth=n}function _(e,t,i,n){e.globalAlpha=.2,u(e,t,i,n),e.stroke(),e.globalAlpha=1}function p(e,t,i,n){u(e,t,i-n,n),e.fill(),e.stroke()}function g(e,t,i,n){const{point:r}=t;e.globalAlpha=.2,e.beginPath(),e.arc(r.x,r.y,i+n/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=n,e.stroke(),e.globalAlpha=1}function P(e,t,i,n){const{point:r}=t;e.beginPath(), e.arc(r.x,r.y,i-n/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=n,e.fill(),e.stroke()}class f extends c.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e??null}setData(e){this._data=e}hitTest(e){if(null===this._data||this._data.disableInteractions)return null;const{radius:t,points:i}=this._data,n=t+(0,d.interactionTolerance)().anchor;for(const t of i){if(t.point.subtract(e).length()<=n)return new l.HitTestResult(t.hitTarget??l.HitTarget.ChangePoint,{areaName:l.AreaName.AnchorPoint,pointIndex:t.pointIndex,cursorType:t.cursorType??h.PaneCursorType.Default,activeItem:t.activeItem,snappingPrice:t.snappingPrice,snappingIndex:t.snappingIndex,nonDiscreteIndex:t.nonDiscreteIndex,possibleMovingDirections:t.possibleMovingDirections,clickHandler:this._data.clickHandler,tapHandler:this._data.clickHandler,ownerSourceId:this._data.ownerSourceId})}return null}doesIntersectWithBox(e){return null!==this._data&&this._data.points.some((t=>(0,r.pointInBox)(t.point,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const t=[],i=[],n=[],r=[];for(let e=0;e{i.d(t,{PolygonRenderer:()=>p});var n=i(6453),r=i(2624),o=i(80819),s=i(25672),a=i(2383),l=i(52859),h=i(20820),d=i(4539),c=i(58221),u=i(69558),_=i(33065);class p extends h.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._backHittest=new a.HitTestResult(a.HitTarget.MovePointBackground),this._points=[],this._hittest=e??new a.HitTestResult(a.HitTarget.MovePoint)}setData(e){this._data=e,this._points=e.points}hitTest(e){if(null===this._data||this._data.disableInteractions)return null ;const t=Math.max((0,d.interactionTolerance)().line,Math.ceil(this._data.linewidth/2)),i=this._points.length;if(1===i){return(0,n.pointInCircle)(e,this._points[0],t)?this._hittest:null}for(let n=1;n0){const n=this._points[0],o=this._points[i-1];if((0,r.distanceToSegment)(n,o,e).distance<=t)return this._hittest}return this._data.filled&&this._data.fillBackground&&(0,n.pointInPolygon)(e,this._data.points)?this._backHittest:null}_drawImpl(e){const t=e.context,i=this._points.length;if(null===this._data||0===i)return;const n=t.globalAlpha;try{if(void 0!==this._data.globalAlpha&&(t.globalAlpha=this._data.globalAlpha),1===i)return void this._drawPoint(t,this._points[0],this._data.linewidth/2,this._data.color);t.beginPath();const e=this._data.linestyle===u.LINESTYLE_SOLID?"round":"butt",n=this._data.linecap??e;t.lineCap=n,t.strokeStyle=this._data.color,t.lineWidth=this._data.linewidth,t.lineJoin=this._data.linejoin??"round",(0,c.setLineStyle)(t,this._data.linestyle);const r=this._points[0];t.moveTo(r.x,r.y);for(const e of this._points)t.lineTo(e.x,e.y);if(this._data.filled&&this._data.fillBackground&&(t.fillStyle=(0,l.generateColor)(this._data.backcolor,this._data.transparency),t.fill()),this._data.filled&&!this._data.skipClosePath&&t.closePath(),i>1){if(this._data.leftend===s.LineEnd.Arrow){const e=this._correctArrowPoints(this._points[1],this._points[0],t.lineWidth,n);(0,o.drawArrow)(e[0],e[1],t,t.lineWidth,_.dpr1PixelRatioInfo)}if(this._data.rightend===s.LineEnd.Arrow){const e=this._correctArrowPoints(this._points[i-2],this._points[i-1],t.lineWidth,n);(0,o.drawArrow)(e[0],e[1],t,t.lineWidth,_.dpr1PixelRatioInfo)}}this._data.linewidth>0&&t.stroke()}finally{t.globalAlpha=n}}_drawPoint(e,t,i,n){0!==i&&(e.beginPath(),e.fillStyle=n,e.arc(t.x,t.y,i,0,2*Math.PI,!0),e.fill(),e.closePath())}_correctArrowPoints(e,t,i,n){const r=t.subtract(e),o=r.length();if("butt"===n||o<1)return[e,t];const s=o+i/2;return[e,r.scaled(s/o).add(e)]}}}}]);