"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[1313],{54707:(e,t,n)=>{n.d(t,{LineSourcePaneView:()=>P,anchorResizeCursorType:()=>_,createLineSourcePaneViewPoint:()=>g});var i=n(58978),o=n(50151),r=n(39612),s=n(2383),l=n(45801),d=n(73914),a=n(43838),c=n(4753);const h=i.colorsPalette["color-tv-blue-600"];var u,p;function _(e,t){const n=e.x-t.x,i=e.y-t.y;if(!Number.isFinite(n)||!Number.isFinite(i)||0===n&&0===i)return a.PaneCursorType.Default;let r=Math.atan2(i,n);return r<0&&(r+=2*Math.PI),r>=p.deg337_5||r=p.deg157_5&&r=p.deg22_5&&r=p.deg202_5&&r=p.deg67_5&&r=p.deg247_5&&r=p.deg112_5&&r=p.deg292_5&&r{const n=i[t],o=(0,d.lineSourcePaneViewPointToLineAnchorPoint)(e);return n&&(o.snappingPrice=n.price,o.snappingIndex=n.index),o}));e.append(this.createLineAnchor({...t,points:o},0))}createLineAnchor(e,t){const n=e.points.map((e=>e.point)),i=this._getOwnerSource();if(this.isLocked()){const o=this._getSelectionRenderer(t);return o.setData({bgColors:this._lineAnchorColors(n),points:e.points,visible:this.areAnchorsVisible(), hittestResult:s.HitTarget.Regular,ownerSourceId:i?.id(),barSpacing:this._model.timeScale().barSpacing()}),o}const o=(0,r.lastMouseOrTouchEventInfo)().isTouch,l=this._getLineAnchorRenderer(t),d=this.isHoveredSource()?this._model.lastHittestData()?.pointIndex??null:null;return l.setData({...e,color:this.anchorColor(),backgroundColors:this._lineAnchorColors(n),hoveredPointIndex:d,linePointBeingEdited:this.isBeingEdited()?this._model.linePointBeingEdited():null,radius:this._anchorRadius(),strokeWidth:o?u.TouchStrokeWidth:u.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:o?u.TouchSelectedStrokeWidth:u.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible(),clickHandler:e.clickHandler,ownerSourceId:i?.id()}),l}_getOwnerSource(){return this._ownerSource??this._source.ownerSource()}_anchorRadius(){return(0,r.lastMouseOrTouchEventInfo)().isTouch?u.TouchAnchorRadius:u.RegularAnchorRadius}_lineAnchorColors(e){const t=(0,o.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 n=this._source.pointToScreenPoint(e,this._ownerSource??void 0);n&&this._points.push(g(n,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 n=this._source.properties().childs();return"middle"===(t??n.vertLabelsAlign.value())&&(0,c.needTextExclusionPath)(e)}_addAlertRenderer(e,t,n=this._source.properties().linecolor.value()){}_getAlertRenderer(e,t=this._source.properties().linecolor.value(),n){return null}_getSelectionRenderer(e){for(;this._selectionRenderers.length<=e;)this._selectionRenderers.push(new l.SelectionRenderer);return this._selectionRenderers[e]}_getLineAnchorRenderer(e){for(;this._lineAnchorRenderers.length<=e;)this._lineAnchorRenderers.push(new d.LineAnchorRenderer);return this._lineAnchorRenderers[e]}}},23712:(e,t,n)=>{n.r(t),n.d(t,{LineToolPitchfan:()=>w});var i=n(50151),o=n(11542),r=n(40226),s=n(95804),l=n(13896),d=n(41414),a=n(65045),c=n(87997),h=n(2383),u=n(39723),p=n(94602),_=n(73914),g=n(25672),P=n(80819),f=n(54707);class v extends f.LineSourcePaneView{constructor(){super(...arguments),this._medianRenderer=new P.TrendLineRenderer,this._sideRenderer=new P.TrendLineRenderer,this._renderer=null,this._medianPoint=null}renderer(e){return this._invalidated&&this._updateImpl(e),this._renderer}_updateImpl(e){super._updateImpl(e),this._renderer=null;const t=this._points.length;if(0===t)return;const[n]=this._points;if(this._medianPoint=(0, _.lineSourcePaneViewPointToLineAnchorPoint)(3===t?this._points[1].add(this._points[2]).scaled(.5):2===t?this._points[1]:n,3),t<2)return;if(!this._medianPoint)return;const i=new p.CompositeRenderer,o=this._source.properties().childs(),r=o.median.childs(),s={points:[n,this._medianPoint.point],color:r.color.value(),linewidth:r.linewidth.value(),linestyle:r.linestyle.value(),extendleft:!1,extendright:!0,leftend:g.LineEnd.Normal,rightend:g.LineEnd.Normal};if(this._medianRenderer.setData(s),i.append(this._medianRenderer),t<3)return this.addAnchors(i),void(this._renderer=i);const l={points:[this._points[1],this._points[2]],color:r.color.value(),linewidth:r.linewidth.value(),linestyle:r.linestyle.value(),extendleft:!1,extendright:!1,leftend:g.LineEnd.Normal,rightend:g.LineEnd.Normal};this._sideRenderer.setData(l),i.append(this._sideRenderer);let d=0;const a=this._points[2].subtract(this._points[1]).scaled(.5),c=o.fillBackground.value(),f=o.transparency.value();for(let e=0;e<=8;e++){const t="level"+e,o=this._source.properties().child(t);if(o?.childs().visible.value()){const t=this._medianPoint.point.addScaled(a,o.childs().coeff.value()),r=this._medianPoint.point.addScaled(a,-o.childs().coeff.value());if(c){{const e={p1:n,p2:t,p3:n,p4:this._medianPoint.point.addScaled(a,d),color:o.childs().color.value(),transparency:f,hittestOnBackground:!0,extendLeft:!1},r=new u.ChannelRenderer;r.setData(e),i.append(r)}{const e={p1:n,p2:r,p3:n,p4:this._medianPoint.point.addScaled(a,-d),color:o.childs().color.value(),transparency:f,hittestOnBackground:!0,extendLeft:!1},t=new u.ChannelRenderer;t.setData(e),i.append(t)}}d=o.childs().coeff.value();{const r={points:[n,t],color:o.childs().color.value(),linewidth:o.childs().linewidth.value(),linestyle:o.childs().linestyle.value(),extendleft:!1,extendright:!0,leftend:g.LineEnd.Normal,rightend:g.LineEnd.Normal},s=new P.TrendLineRenderer;s.setData(r),s.setHitTest(new h.HitTestResult(h.HitTarget.MovePoint,void 0,e)),i.append(s)}{const t={points:[n,r],color:o.childs().color.value(),linewidth:o.childs().linewidth.value(),linestyle:o.childs().linestyle.value(),extendleft:!1,extendright:!0,leftend:g.LineEnd.Normal,rightend:g.LineEnd.Normal},s=new P.TrendLineRenderer;s.setData(t),s.setHitTest(new h.HitTestResult(h.HitTarget.MovePoint,void 0,e)),i.append(s)}}}this.addAnchors(i),this._renderer=i}}const S=new s.TranslatedString("erase level line",o.t(null,void 0,n(77114)));var m;!function(e){e[e.LevelsCount=8]="LevelsCount"}(m||(m={}));class w extends d.LineDataSource{constructor(e,t,n,i){super(e,t??w.createProperties(e.backgroundTheme().spawnOwnership()),n,i),this._setPaneViews([new v(this,this._model)])}levelsCount(){return 8}pointsCount(){return 3}name(){return"Pitchfan"}processErase(e,t){const n="level"+t,o=(0,i.ensureDefined)(this.properties().child(n)).childs().visible;e.setProperty(o,!1,S,l.lineToolsDoNotAffectChartInvalidation)}static createProperties(e,t){const n=new r.LevelsProperty({defaultName:"linetoolpitchfan",state:t,map:{range:[0,8]},theme:e});return this._configureProperties(n),n} async _getPropertyDefinitionsViewModelClass(){return c.PitchBaseDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=[e.childs().median.childs().linewidth],n=[e.childs().median.childs().color];for(let o=0;o<=8;o++){const r=(0,i.ensureDefined)(e.child("level"+o));t.push((0,i.ensureDefined)(r.child("linewidth"))),n.push((0,i.ensureDefined)(r.child("color")))}e.addChild("linesColors",new a.LineToolColorsProperty(n)),e.addChild("linesWidths",new a.LineToolWidthsProperty(t))}}},39723:(e,t,n)=>{n.d(t,{ChannelRenderer:()=>h});var i=n(50151),o=n(10555),r=n(6453),s=n(2624),l=n(2383),d=n(58221),a=n(52859),c=n(20820);class h extends c.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e,t){if(null===this._data||!this._data.hittestOnBackground)return null;const n=this._visiblePolygon(t.mediaSize);return null!==n&&(0,r.pointInPolygon)(e,n)?new l.HitTestResult(l.HitTarget.MovePointBackground):null}_drawImpl(e){if(null===this._data)return;const t=e.context,n=this._visiblePolygon(e.mediaSize);if(null!==n){t.beginPath(),t.moveTo(n[0].x,n[0].y);for(let e=1;e{n.d(t,{LineAnchorRenderer:()=>f,lineSourcePaneViewPointToLineAnchorPoint:()=>v,lineSourcePaneViewPointToLineAnchorPoint2:()=>S,mapLineSourcePaneViewPointToLineAnchorPoint:()=>m});var i=n(10555),o=n(6453),r=n(50151),s=n(58221),l=n(87465),d=n(2383),a=n(43838),c=n(4539),h=n(10307);function u(e,t,n,i){const{point:o}=t,r=n+i/2;(0,s.drawRoundRect)(e,o.x-r,o.y-r,2*r,2*r,(n+i)/2),e.closePath(),e.lineWidth=i}function p(e,t,n,i){e.globalAlpha=.2,u(e,t,n,i),e.stroke(),e.globalAlpha=1}function _(e,t,n,i){u(e,t,n-i,i),e.fill(),e.stroke()}function g(e,t,n,i){const{point:o}=t;e.globalAlpha=.2,e.beginPath(),e.arc(o.x,o.y,n+i/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=i,e.stroke(),e.globalAlpha=1}function P(e,t,n,i){const{point:o}=t;e.beginPath(),e.arc(o.x,o.y,n-i/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=i,e.fill(),e.stroke()}class f extends h.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:n}=this._data,i=t+(0,c.interactionTolerance)().anchor;for(const t of n){if(t.point.subtract(e).length()<=i)return new d.HitTestResult(t.hitTarget??d.HitTarget.ChangePoint,{ areaName:d.AreaName.AnchorPoint,pointIndex:t.pointIndex,cursorType:t.cursorType??a.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,o.pointInBox)(t.point,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const t=[],n=[],i=[],o=[];for(let e=0;e