|
|
|
|
@@ -317,7 +317,7 @@ const e=this._model.mainSeries().interval();if(null===this._alignerCache||this._
|
|
|
|
|
i.addChild("bar",new A.LineDataSourcePointIndexProperty(this,e))}_createPointsProperties(){this._pointsProperty=new b.Property,this._pointsProperty.addChild("points",new b.Property);for(let e=0;e<this.pointsCount();e++)this._createPointProperty(e)}_alignPointToRangeOfActualData(e){const t=(0,n.ensureNotNull)(this._model.mainSeries().bars().firstIndex()),i=(0,n.ensureNotNull)(this._model.mainSeries().bars().lastIndex());let s=Math.max(e.index,t);return s=Math.min(s,i),{...e,index:s}}_migrateSymbolProperty(e){const t=this._properties.childs();if(t.symbolStateVersion.value()<2){const i=(0,n.ensureNotNull)(this.ownerSource()),s=(0,n.ensureNotNull)(i.symbolSource()),o=this._model.mainSeries();if(s===o)return void t.symbolStateVersion.setValueSilently(2);if(null===o.symbolInfo())return;if(null===s.symbolInfo())return;o.symbolSameAsCurrent(t.symbol.value())&&t.symbol.setValueSilently((0,y.extractLineToolSymbolFromSymbolInfo)(e,s.symbol())),t.symbolStateVersion.setValueSilently(2)}}_migrateZOrder(){const e=this._properties.childs();e.zOrderVersion.value()<2&&(this.ownerSource()===this.model().mainSeries()&&this.setZorder(this.zorder()-this.model().mainSeries().obsoleteZOrder()),e.zOrderVersion.setValueSilently(2))}_preparePoint(e,t){const i=e;return this._snapTo45DegreesApplicable(t)&&this.points().length>=2&&this.snapPoint45Degree(i,this.points()[this.points().length-2]),i}_addPointIntenal(e,t,i){this._points.push({...e,interval:this._model.mainSeries().interval()});const s=this._points.length===this.pointsCount();return s?(this._lastPoint=null,i||(this._normalizePoints(),this.createServerPoints())):this._lastPoint=e,this._pointAdded.fire(this._points.length-1),s}_onSourceHiddenMayChange(){this.isSourceHidden()&&this._model.selectionMacro((e=>{e.removeSourceFromSelection(this)})),this._model.invalidate(p.InvalidationMask.validateAction((()=>{this!==this._model.lineBeingCreated()&&(this._isDestroyed||this.processHibernate())})))}_saveAlertIdInState(){return!0}_onPointsetUpdated(e){if(0===e.length)return;const t=this.properties().childs().interval.value();for(let i=0;i<e.length;i++){const s=e[i],o=this._timePoint[s.index],n={index:s.value[0],time:s.value[1],price:o.price,interval:o.interval??t};this._points.length<=s.index?(this._points.push(n),this._pointAdded.fire(this._points.length-1)):(this._points[s.index]=n,this._pointChanged.fire(s.index))}this._onPointsetUpdatedDelegate.fire(),this.updateAllViewsAndRedraw((0,x.sourceChangeEvent)(this.id()))}_onMainSeriesSymbolResolved(){const e=this.ownerSource();null===e||this._model.mainSeries()===e.symbolSource()||this.isSourceHidden()||this.createServerPoints()}_readyToCreatePointset(){return this._timePoint.length>0}_propertiesStateExclusions(){return[]}_syncLineStyleIfNeeded(e){const t=this.linkKey().value();t&&!this._syncLineStyleMuted&&this._syncLineStyleChanges(t,this.syncLineStyleState(e))}_muteSyncLineStyle(){this._syncLineStyleMuted=!0}_unmuteSyncLineStyleWithoutApplyingChanges(){this.propertiesChanged(),this._syncLineStyleMuted=!1}_applyTemplateImpl(e){
|
|
|
|
|
e.intervalsVisibilities=(0,g.mergeIntervalVisibilitiesDefaults)(e.intervalsVisibilities);const t=this.properties();t.applyTemplate(e,(0,V.factoryDefaults)(this.toolname.toLowerCase())),t.saveDefaults(),this.propertiesChanged()}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_getAlertPlots(){return[]}_getUndoHistory(){return this._model.undoModel().undoHistory()}_synchronizeAlert(e){}_linePointsToAlertPlot(e,t,i,s){return null}_getAlertCreationAvailable(){return!1}_onAnchoredChange(){if(this.isFixed()){const e=(0,n.ensureNotNull)(this.pointToScreenPoint(this.points()[0]));this.addFixedPoint(e)}else{if(!this._fixedPoint)return;const e=(0,n.ensureNotNull)(this.screenPointToPoint(this._fixedPoint));this._points[0]={...e,interval:this._model.mainSeries().interval()},this.startChanging(),this.setPoint(0,e),this.endChanging(!1,!1),this._timePoint[0]=this._normalizePoint(this._points[0],0),this.clearFixedPoint()}const e=this.linkKey().value();null!==e&&this.isSynchronizable()&&(0,w.restoreLineToolState)({model:this._model,linkKey:e,state:this.state()})}_syncLineStyleChanges(e,t,i){this.anchorable()&&this.isFixed()!==Boolean(this._positionPercents)&&this._onAnchoredChange(),(0,w.changeLineStyle)({linkKey:e,state:t,alertId:i,model:this._model})}static _configureProperties(e){if(this._addCollectedProperties(e),e.hasChild("symbolStateVersion")||e.addChild("symbolStateVersion",new b.Property(1)),e.hasChild("zOrderVersion")||e.addChild("zOrderVersion",new b.Property(1)),e.hasChild("visible")||e.addChild("visible",new b.Property(!0)),e.hasChild("frozen")||e.addChild("frozen",new b.Property(!1)),e.hasChild("symbol")||e.addChild("symbol",new b.Property("")),e.hasChild("currencyId")||e.addChild("currencyId",new b.Property(null)),e.hasChild("unitId")||e.addChild("unitId",new b.Property(null)),e.hasChild("intervalsVisibilities")){const t=(0,T.merge)((0,T.clone)(f.intervalsVisibilitiesDefaults),e.childs().intervalsVisibilities.state());e.removeProperty("intervalsVisibilities"),e.addChild("intervalsVisibilities",new P.IntervalsVisibilitiesProperty(t))}else e.addChild("intervalsVisibilities",new P.IntervalsVisibilitiesProperty(f.intervalsVisibilitiesDefaults));e.hasChild("title")||e.addChild("title",new b.Property("")),["symbolStateVersion","zOrderVersion","visible","frozen","symbol","currencyId","unitId","symbolInfo","points","interval","title"].forEach((t=>e.addExcludedKey(t,5))),e.hasChild("singleChartOnly")&&e.removeProperty("singleChartOnly"),e.hasChild("font")&&e.removeProperty("font")}static _addCollectedProperties(e){e.hasChild("linewidth")&&e.addChild("linesWidths",new E.LineToolWidthsProperty([(0,n.ensureDefined)(e.child("linewidth"))])),e.hasChild("linecolor")&&e.addChild("linesColors",new E.LineToolColorsProperty([(0,n.ensureDefined)(e.child("linecolor"))])),e.hasChild("backgroundColor")&&e.addChild("backgroundsColors",new E.LineToolColorsProperty([(0,n.ensureDefined)(e.child("backgroundColor"))])),e.hasChild("textColor")&&e.addChild("textsColors",new E.LineToolColorsProperty([(0,
|
|
|
|
|
n.ensureDefined)(e.child("textColor"))])),e.hasChild("linestyle")&&e.addChild("linesStyles",new E.LineToolCollectedProperty([(0,n.ensureDefined)(e.child("linestyle"))])),["linesWidths","linesColors","backgroundsColors","textsColors","linesStyles"].forEach((t=>{e.addExcludedKey(t,7)}))}_areAlertsOnLineToolProhibited(){return null!==this._ownerSource&&!this._ownerSource.canHasAlertOnLineTools()}_removeAlertSubscriptions(){this._unsubscribeAlertCallbacks?.(),this._unsubscribeAlertCallbacks=void 0}_addAlertSubscriptions(e,t={}){}_destroyPanePaneViews(e){const t=this._paneViews.get(e);if(void 0!==t)for(const e of t)e.destroy&&e.destroy();void 0!==e&&e.onDestroyed().unsubscribeAll(this),this._paneViews.delete(e)}_copyPricesWithoutNormalization(){const e=Math.min(this._points.length,this._timePoint.length);for(let t=0;t<e;t++)this._timePoint[t].price=this._points[t].price}async _getChartAlert(){throw new Error("not implemented")}async _syncAlertWithAlertFacade(e={}){try{const t=await this.getAlert();if(!t)return;if(this._addAlertSubscriptions(t,e),e.syncAlertFocus){const e=this._model.selection().isSelected(this);t.setSelected(e)}}catch(e){if(e instanceof Error&&"not_exists"===e.message&&this.hasAlert().value()){this._alertStatus.setValue(0);return void(await getChartAlertsFacade()).removeAlertFromAllChartsSilently(this.id(),(0,n.ensureDefined)(this._alertId))}N.logError("Failed to set alert, alert will not be saved with drawing in chart")}}}},73305:(e,t,i)=>{"use strict";i.d(t,{LineToolCollectedProperty:()=>c,LineToolColorsProperty:()=>d,LineToolWidthsProperty:()=>h,MultipleLineColorsProperty:()=>p,MultipleLineWidthsProperty:()=>_});var s=i(9343),o=i(34776),n=i(23073);const r=(0,s.getLogger)("Chart.LineToolCollectedProperty");class a{applyValue(e,t){e.setValue(t)}}class l extends n.PropertyBase{constructor(e,t){super(),this._properties=e,e.forEach(((e,t)=>e.subscribe(this,((e,i)=>{this._listeners.fire(this,`${t}.${i}`)})))),this._showIfProperty=t}visible(){return!this._showIfProperty||this._showIfProperty?.value()}value(){if(0===this._properties.length)return r.logError("Incorrect call, should not request value of 0 properties"),"mixed";const e=this._properties[0].value();return 1===this._properties.length||this._properties.every((t=>t.value()===e))?e:"mixed"}setValueSilently(e){"mixed"!==e&&this._properties.forEach((t=>t.setValueSilently(e)))}hasChild(e){const t=parseInt(e,10);return!isNaN(t)&&t>=0&&t<this._properties.length}childCount(){return this._properties.length}childNames(){return this._properties.map(((e,t)=>t.toString()))}child(e){const t=parseInt(e,10);return!isNaN(t)&&t>=0&&t<this._properties.length?this._properties[t]:void 0}destroy(){this._properties.forEach((e=>e.unsubscribeAll(this))),this._listeners.destroy()}storeStateIfUndefined(){return!0}weakReference(){return(0,o.weakReference)(this)}ownership(){return(0,o.ownership)(this)}}class c extends l{setValue(e,t,i){if("mixed"===e)return;const s=i??new a;this._properties.forEach((t=>s.applyValue(t,e)))}}class h extends c{}class d extends c{firstColor(){
|
|
|
|
|
return this._properties[0].value()}}class u extends l{setValue(e,t,i){if("mixed"===e)return;const s=i??new a;this._properties.forEach((t=>t.setValue(e,void 0,s)))}}class _ extends u{}class p extends u{}},77336:(e,t,i)=>{"use strict";i.d(t,{ensureLineToolLoaded:()=>u,getLoadedLineTool:()=>_,isAsyncGenericLineToolName:()=>l,isAsyncStudyLineToolName:()=>c,isLineToolLoaded:()=>h,loadLineTool:()=>d});var s=i(50151);const o=new Map;const n=new Map([["LineToolPriceNote",async()=>(await Promise.all([i.e(8940),i.e(3889),i.e(8009),i.e(380)]).then(i.bind(i,36875))).LineToolPriceNote],["LineToolTextNote",async()=>(await Promise.all([i.e(6645),i.e(3889),i.e(8009),i.e(9116),i.e(9123)]).then(i.bind(i,46902))).LineToolTextNote],["LineToolNote",async()=>(await Promise.all([i.e(3355),i.e(3889),i.e(8009),i.e(9116),i.e(3248)]).then(i.bind(i,40258))).LineToolNote],["LineToolFibSpiral",async()=>(await Promise.all([i.e(3181),i.e(3889),i.e(8009),i.e(8090)]).then(i.bind(i,22717))).LineToolFibSpiral],["LineToolCircleLines",async()=>(await Promise.all([i.e(2787),i.e(3889),i.e(8009),i.e(9445)]).then(i.bind(i,9093))).LineToolCyclicLines],["LineToolNoteAbsolute",async()=>(await Promise.all([i.e(3355),i.e(3889),i.e(8009),i.e(9116),i.e(3248)]).then(i.bind(i,40258))).LineToolNoteAbsolute],["LineToolTable",async()=>(await Promise.all([i.e(9494),i.e(3889),i.e(8009),i.e(9116),i.e(319)]).then(i.bind(i,56176))).LineToolTable],["LineToolFibSpeedResistanceArcs",async()=>(await Promise.all([i.e(1427),i.e(3889),i.e(8009),i.e(9116),i.e(3710)]).then(i.bind(i,49145))).LineToolFibSpeedResistanceArcs],["LineToolPitchfan",async()=>(await Promise.all([i.e(7952),i.e(3889),i.e(8009),i.e(8056),i.e(1313)]).then(i.bind(i,43176))).LineToolPitchfan],["LineToolFibSpeedResistanceFan",async()=>(await Promise.all([i.e(1308),i.e(3889),i.e(8009),i.e(906)]).then(i.bind(i,2662))).LineToolFibSpeedResistanceFan],["LineToolFibWedge",async()=>(await Promise.all([i.e(6760),i.e(3889),i.e(8009),i.e(9116),i.e(3314)]).then(i.bind(i,30051))).LineToolFibWedge],["LineToolEmoji",async()=>(await Promise.all([i.e(6155),i.e(3889),i.e(8009),i.e(1200),i.e(5529)]).then(i.bind(i,39374))).LineToolEmoji],["LineToolBalloon",async()=>(await Promise.all([i.e(3367),i.e(3889),i.e(8009),i.e(3960),i.e(1277)]).then(i.bind(i,69113))).LineToolBalloon],["LineToolComment",async()=>(await Promise.all([i.e(2303),i.e(3889),i.e(8009),i.e(9116),i.e(3960),i.e(3966)]).then(i.bind(i,84738))).LineToolComment],["LineToolBezierCubic",async()=>(await Promise.all([i.e(1432),i.e(3889),i.e(8009),i.e(9014)]).then(i.bind(i,54696))).LineToolBezierCubic],["LineToolInsidePitchfork",async()=>(await Promise.all([i.e(8763),i.e(8468)]).then(i.bind(i,20690))).LineToolInsidePitchfork]]);n.set("LineToolFibRetracement",(async()=>(await Promise.all([i.e(7850),i.e(3723)]).then(i.bind(i,33168))).LineToolFibRetracement)),n.set("LineToolFibChannel",(async()=>(await Promise.all([i.e(7850),i.e(2283)]).then(i.bind(i,42851))).LineToolFibChannel)),
|
|
|
|
|
return this._properties[0].value()}}class u extends l{setValue(e,t,i){if("mixed"===e)return;const s=i??new a;this._properties.forEach((t=>t.setValue(e,void 0,s)))}}class _ extends u{}class p extends u{}},77336:(e,t,i)=>{"use strict";i.d(t,{ensureLineToolLoaded:()=>u,getLoadedLineTool:()=>_,isAsyncGenericLineToolName:()=>l,isAsyncStudyLineToolName:()=>c,isLineToolLoaded:()=>h,loadLineTool:()=>d});var s=i(50151);const o=new Map;const n=new Map([["LineToolPriceNote",async()=>(await Promise.all([i.e(8940),i.e(3889),i.e(8009),i.e(380)]).then(i.bind(i,36875))).LineToolPriceNote],["LineToolTextNote",async()=>(await Promise.all([i.e(6645),i.e(3889),i.e(8009),i.e(9116),i.e(9123)]).then(i.bind(i,95240))).LineToolTextNote],["LineToolNote",async()=>(await Promise.all([i.e(3355),i.e(3889),i.e(8009),i.e(9116),i.e(3248)]).then(i.bind(i,40258))).LineToolNote],["LineToolFibSpiral",async()=>(await Promise.all([i.e(3181),i.e(3889),i.e(8009),i.e(8090)]).then(i.bind(i,22717))).LineToolFibSpiral],["LineToolCircleLines",async()=>(await Promise.all([i.e(2787),i.e(3889),i.e(8009),i.e(9445)]).then(i.bind(i,9093))).LineToolCyclicLines],["LineToolNoteAbsolute",async()=>(await Promise.all([i.e(3355),i.e(3889),i.e(8009),i.e(9116),i.e(3248)]).then(i.bind(i,40258))).LineToolNoteAbsolute],["LineToolTable",async()=>(await Promise.all([i.e(9494),i.e(3889),i.e(8009),i.e(9116),i.e(319)]).then(i.bind(i,56176))).LineToolTable],["LineToolFibSpeedResistanceArcs",async()=>(await Promise.all([i.e(1427),i.e(3889),i.e(8009),i.e(9116),i.e(3710)]).then(i.bind(i,49145))).LineToolFibSpeedResistanceArcs],["LineToolPitchfan",async()=>(await Promise.all([i.e(7952),i.e(3889),i.e(8009),i.e(8056),i.e(1313)]).then(i.bind(i,43176))).LineToolPitchfan],["LineToolFibSpeedResistanceFan",async()=>(await Promise.all([i.e(1308),i.e(3889),i.e(8009),i.e(906)]).then(i.bind(i,2662))).LineToolFibSpeedResistanceFan],["LineToolFibWedge",async()=>(await Promise.all([i.e(6760),i.e(3889),i.e(8009),i.e(9116),i.e(3314)]).then(i.bind(i,30051))).LineToolFibWedge],["LineToolEmoji",async()=>(await Promise.all([i.e(6155),i.e(3889),i.e(8009),i.e(1200),i.e(5529)]).then(i.bind(i,39374))).LineToolEmoji],["LineToolBalloon",async()=>(await Promise.all([i.e(3367),i.e(3889),i.e(8009),i.e(3960),i.e(1277)]).then(i.bind(i,69113))).LineToolBalloon],["LineToolComment",async()=>(await Promise.all([i.e(2303),i.e(3889),i.e(8009),i.e(9116),i.e(3960),i.e(3966)]).then(i.bind(i,84738))).LineToolComment],["LineToolBezierCubic",async()=>(await Promise.all([i.e(1432),i.e(3889),i.e(8009),i.e(9014)]).then(i.bind(i,54696))).LineToolBezierCubic],["LineToolInsidePitchfork",async()=>(await Promise.all([i.e(8763),i.e(8468)]).then(i.bind(i,20690))).LineToolInsidePitchfork]]);n.set("LineToolFibRetracement",(async()=>(await Promise.all([i.e(7850),i.e(3723)]).then(i.bind(i,33168))).LineToolFibRetracement)),n.set("LineToolFibChannel",(async()=>(await Promise.all([i.e(7850),i.e(2283)]).then(i.bind(i,42851))).LineToolFibChannel)),
|
|
|
|
|
n.set("LineToolProjection",(async()=>(await Promise.all([i.e(7122),i.e(3945)]).then(i.bind(i,12120))).LineToolProjection)),n.set("LineToolTrendBasedFibExtension",(async()=>(await Promise.all([i.e(7850),i.e(4731)]).then(i.bind(i,68554))).LineToolTrendBasedFibExtension)),n.set("LineToolElliott",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliott)),n.set("LineToolFibCircles",(async()=>(await Promise.all([i.e(7850),i.e(2816)]).then(i.bind(i,57994))).LineToolFibCircles)),n.set("LineToolVertLine",(async()=>(await Promise.all([i.e(7122),i.e(1282)]).then(i.bind(i,56096))).LineToolVertLine)),n.set("LineToolCrossLine",(async()=>(await i.e(7203).then(i.bind(i,92007))).LineToolCrossLine)),n.set("LineToolBarsPattern",(async()=>(await Promise.all([i.e(4543),i.e(5206)]).then(i.bind(i,81756))).LineToolBarsPattern)),n.set("LineToolTrendBasedFibTime",(async()=>(await Promise.all([i.e(5111),i.e(7127)]).then(i.bind(i,27172))).LineToolTrendBasedFibTime)),n.set("LineToolFibTimeZone",(async()=>(await Promise.all([i.e(5111),i.e(1506)]).then(i.bind(i,8532))).LineToolFibTimeZone)),n.set("LineToolDateRange",(async()=>(await i.e(4273).then(i.bind(i,42214))).LineToolDateRange)),n.set("LineToolPriceRange",(async()=>(await i.e(6477).then(i.bind(i,23234))).LineToolPriceRange)),n.set("LineToolDateAndPriceRange",(async()=>(await i.e(1455).then(i.bind(i,70791))).LineToolDateAndPriceRange)),n.set("LineToolParallelChannel",(async()=>(await i.e(2050).then(i.bind(i,56621))).LineToolParallelChannel)),n.set("LineToolTrendAngle",(async()=>(await Promise.all([i.e(7122),i.e(8372)]).then(i.bind(i,83776))).LineToolTrendAngle)),n.set("LineToolTrendLine",(async()=>(await Promise.all([i.e(7122),i.e(8673)]).then(i.bind(i,99294))).LineToolTrendLine)),n.set("LineToolInfoLine",(async()=>(await Promise.all([i.e(7122),i.e(7488)]).then(i.bind(i,51065))).LineToolInfoLine)),n.set("LineToolArrowMark",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMark)),n.set("LineToolGannSquare",(async()=>(await i.e(9478).then(i.bind(i,9770))).LineToolGannSquare)),n.set("LineToolGannComplex",(async()=>(await i.e(1963).then(i.bind(i,99083))).LineToolGannComplex)),n.set("LineToolGannFixed",(async()=>(await i.e(6336).then(i.bind(i,8308))).LineToolGannFixed)),n.set("LineToolGannFan",(async()=>(await Promise.all([i.e(5111),i.e(4981)]).then(i.bind(i,85259))).LineToolGannFan)),n.set("LineToolPitchfork",(async()=>(await Promise.all([i.e(8763),i.e(5055)]).then(i.bind(i,64002))).LineToolPitchfork)),n.set("LineToolDisjointAngle",(async()=>(await i.e(9581).then(i.bind(i,57897))).LineToolDisjointChannel)),n.set("LineToolFlatBottom",(async()=>(await i.e(9310).then(i.bind(i,90921))).LineToolFlatBottom)),n.set("LineToolIcon",(async()=>(await i.e(7806).then(i.bind(i,15510))).LineToolIcon)),n.set("LineToolSticker",(async()=>(await i.e(8949).then(i.bind(i,86915))).LineToolSticker)),n.set("LineToolRotatedRectangle",(async()=>(await i.e(4015).then(i.bind(i,23550))).LineToolRotatedRectangle)),
|
|
|
|
|
n.set("LineToolHeadAndShoulders",(async()=>(await i.e(3378).then(i.bind(i,47267))).LineToolHeadAndShoulders)),n.set("LineToolTriangle",(async()=>(await i.e(6432).then(i.bind(i,39737))).LineToolTriangle)),n.set("LineToolTrianglePattern",(async()=>(await i.e(3383).then(i.bind(i,33865))).LineToolTrianglePattern)),n.set("LineTool5PointsPattern",(async()=>(await i.e(1155).then(i.bind(i,17658))).LineTool5PointsPattern)),n.set("LineToolThreeDrivers",(async()=>(await i.e(4602).then(i.bind(i,46660))).LineToolThreeDrivers)),n.set("LineToolABCD",(async()=>(await i.e(5283).then(i.bind(i,30906))).LineToolABCD)),n.set("LineToolPolyline",(async()=>(await i.e(3866).then(i.bind(i,51691))).LineToolPolyline)),n.set("LineToolPath",(async()=>(await i.e(961).then(i.bind(i,14150))).LineToolPath)),n.set("LineToolPrediction",(async()=>(await i.e(9534).then(i.bind(i,29356))).LineToolPrediction)),n.set("LineToolPriceLabel",(async()=>(await i.e(6484).then(i.bind(i,83710))).LineToolPriceLabel)),n.set("LineToolArrowMarker",(async()=>(await i.e(1470).then(i.bind(i,66403))).LineToolArrowMarker)),n.set("LineToolSignpost",(async()=>(await Promise.all([i.e(7122),i.e(4674)]).then(i.bind(i,28820))).LineToolSignpost)),n.set("LineToolBrush",(async()=>(await i.e(5122).then(i.bind(i,28462))).LineToolBrush)),n.set("LineToolArc",(async()=>(await i.e(5967).then(i.bind(i,87654))).LineToolArc)),n.set("LineToolCallout",(async()=>(await Promise.all([i.e(7122),i.e(688)]).then(i.bind(i,62828))).LineToolCallout)),n.set("LineToolText",(async()=>(await Promise.all([i.e(7122),i.e(2312)]).then(i.bind(i,424))).LineToolText)),n.set("LineToolHorzLine",(async()=>(await Promise.all([i.e(7122),i.e(4201)]).then(i.bind(i,43636))).LineToolHorzLine)),n.set("LineToolHorzRay",(async()=>(await i.e(574).then(i.bind(i,47845))).LineToolHorzRay)),n.set("LineToolRectangle",(async()=>(await Promise.all([i.e(7122),i.e(8422)]).then(i.bind(i,63397))).LineToolRectangle)),n.set("LineToolCircle",(async()=>(await Promise.all([i.e(7122),i.e(6748)]).then(i.bind(i,17333))).LineToolCircle)),n.set("LineToolEllipse",(async()=>(await Promise.all([i.e(7122),i.e(7660)]).then(i.bind(i,59002))).LineToolEllipse)),n.set("LineToolTimeCycles",(async()=>(await i.e(8334).then(i.bind(i,4741))).LineToolTimeCycles)),n.set("LineToolSineLine",(async()=>(await i.e(1713).then(i.bind(i,8066))).LineToolSineLine)),n.set("LineToolGhostFeed",(async()=>(await i.e(7563).then(i.bind(i,37968))).LineToolGhostFeed)),n.set("LineToolBezierQuadro",(async()=>(await i.e(8061).then(i.bind(i,28904))).LineToolBezierQuadro)),n.set("LineToolArrow",(async()=>(await Promise.all([i.e(7122),i.e(8607)]).then(i.bind(i,96068))).LineToolArrow)),n.set("LineToolRay",(async()=>(await Promise.all([i.e(7122),i.e(4934)]).then(i.bind(i,36224))).LineToolRay)),n.set("LineToolExtended",(async()=>(await Promise.all([i.e(7122),i.e(925)]).then(i.bind(i,6921))).LineToolExtended)),n.set("LineToolSchiffPitchfork",(async()=>(await Promise.all([i.e(8763),i.e(7175)]).then(i.bind(i,63533))).LineToolSchiffPitchfork)),
|
|
|
|
|
n.set("LineToolSchiffPitchfork2",(async()=>(await Promise.all([i.e(8763),i.e(341)]).then(i.bind(i,68802))).LineToolSchiffPitchfork2)),n.set("LineToolTextAbsolute",(async()=>(await Promise.all([i.e(7122),i.e(2312)]).then(i.bind(i,424))).LineToolTextAbsolute)),n.set("LineToolArrowMarkLeft",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkLeft)),n.set("LineToolArrowMarkRight",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkRight)),n.set("LineToolArrowMarkUp",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkUp)),n.set("LineToolArrowMarkDown",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkDown)),n.set("LineToolFlagMark",(async()=>(await i.e(8820).then(i.bind(i,41124))).LineToolFlagMark)),n.set("LineToolCypherPattern",(async()=>(await i.e(6740).then(i.bind(i,16628))).LineToolCypherPattern)),n.set("LineToolElliottImpulse",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottImpulse)),n.set("LineToolElliottTriangle",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottTriangle)),n.set("LineToolElliottTripleCombo",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottTripleCombo)),n.set("LineToolElliottCorrection",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottCorrection)),n.set("LineToolElliottDoubleCombo",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottDoubleCombo)),n.set("LineToolRiskRewardLong",(async()=>(await Promise.all([i.e(2342),i.e(1667),i.e(2277)]).then(i.bind(i,21986))).LineToolRiskRewardLong)),n.set("LineToolRiskRewardShort",(async()=>(await Promise.all([i.e(2342),i.e(1667),i.e(6768)]).then(i.bind(i,65137))).LineToolRiskRewardShort)),n.set("LineToolPosition",(async()=>(await i.e(1314).then(i.t.bind(i,40265,19))).LineToolPosition)),n.set("LineToolOrder",(async()=>(await i.e(2232).then(i.t.bind(i,64732,19))).LineToolOrder)),n.set("LineToolHighlighter",(async()=>(await i.e(2087).then(i.bind(i,65539))).LineToolHighlighter)),n.set("LineToolImage",(async()=>(await Promise.all([i.e(5402),i.e(5231)]).then(i.bind(i,18181))).LineToolImage)),n.set("LineToolExecution",(async()=>(await Promise.resolve().then(i.bind(i,56991))).LineToolExecution));const r=new Map,a=new Map([["LineToolAnchoredVWAP",async()=>(await i.e(5500).then(i.bind(i,13099))).LineToolAnchoredVWAP],["LineToolRegressionTrend",async()=>(await i.e(9748).then(i.bind(i,10986))).LineToolRegressionTrend],["LineToolVbPFixed",async()=>(await i.e(5695).then(i.bind(i,71131))).LineToolVbPFixed],["LineToolFixedRangeVolumeProfile",async()=>(await i.e(5695).then(i.bind(i,25937))).LineToolFixedRangeVolumeProfile]]);function l(e){return n.has(e)||a.has(e)||o.has(e)}function c(e){return a.has(e)}function h(e){return!l(e)||o.has(e)||r.has(e)}async function d(e){if(h(e))return _(e);const t=c(e),i=(0,s.ensureDefined)((t?a:n).get(e)),l=await i();return t?(r.set(e,(0,s.ensureDefined)(l)),_(e)):(o.set(e,(0,s.ensureDefined)(l)),_(e))}async function u(e){l(e)&&!h(e)&&await d(e)}function _(e){return c(e)?(0,
|
|
|
|
|
@@ -709,9 +709,9 @@ Vt.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Do.RecalcVisibleRangeS
|
|
|
|
|
;i.setStretchFactor(t*a);let c=t-l,h=this._panes.length-1;for(const e of this._panes)if(e!==i){const t=Math.min(r,Math.max(30,e.height()-c/h));c-=e.height()-t,h-=1;const i=t*a;e.setStretchFactor(i)}this.fullUpdate()}clearCurrentPosition(){const e=this.crosshairSource();e.clearPosition(),(0,n.ensureNotNull)(e.dataWindowView()).update((0,Vt.sourceChangeEvent)(e.id())),c_(this._panes),this.invalidate(fo.InvalidationMask.cursor()),this._undoModel.syncCrosshair(null),this._phantomSourceContainer.onCursorPositionUpdated()}setAndSaveCurrentPosition(e,t,i,s){this.crosshairSource().saveOriginCoords(e,t),this.setCurrentPosition(e,t,i,s)}setCurrentPosition(e,t,i,s){let o=NaN;const r=this._timeScale.coordinateToVisibleIndex(e),a=(this._lineBeingEdited??this.lineBeingCreated())?.priceScale()??i.defaultPriceScale();let l=null;!a.isEmpty()&&Number.isFinite(t)&&(l=(0,n.ensureNotNull)(i.mainDataSource()).firstValue(),null!==l&&(o=a.coordinateToPrice(t,l)));const c=this._crossHairSelectPointMode.value()!==lt.SelectPointMode.None,h=lt.tool.value(),d=this.mainSeries(),u=this.crosshairSource(),_=u.index,p=u.price,m=c||lt.isStudyEditingNow.value();let g=!1;if(a===this._mainSeries.priceScale())if((0,Ct.isLineDrawnWithPressedButton)(h))g=null===this._lineBeingCreated||(0,Qs.isBrushBasedLineTool)(this._lineBeingCreated.lineDataSource)&&this._lineBeingCreated.lineDataSource.hasOnlyOnePoint();else{g=Boolean(this._lineBeingCreated||this._lineBeingEdited||(0,Ct.isLineToolName)(h)||(0,lt.toolIsMeasure)(h))||m}!this._isSettingsExternalPosition&&g?(o=this._magnet.align(o,r,i),null!==l&&this._setCorrectedPositionToCrosshair(r,o,i)):this._magnet.resetLastValue();let f=null;if(isNaN(o)||(f=i),this._isTimeScrolling){if(!this._isSettingsExternalPosition&&c){const e=d.bars().firstIndex(),t=d.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(r,e),t);s!==r&&this._setCorrectedPositionToCrosshair(s,o,i)}}else u.setPosition(u.index,o,f);return}u.setOnHoveredChartWidget(!0),u.setPosition(r,o,f),(0,n.ensureNotNull)(u.dataWindowView()).update((0,Vt.sourceChangeEvent)(u.id())),c_(this._panes);const y=d.syncModel();this.crosshairSource().startMeasurePoint()||this._lineBeingCreated?this.lightUpdate():this.invalidate(fo.InvalidationMask.cursor());const v=this.lineBeingCreated();if(v){const e=v.linkKey().value();if(!this._isSettingsExternalPosition){const t=v.setLastPoint({index:r,price:o},s);if(v.updateAllViews((0,Vt.sourceChangeEvent)(v.id())),t.price===o&&t.index===r||this._setCorrectedPositionToCrosshair(t.index,t.price,i),y&&e){const i=this._timeScale.points().roughTime(t.index,y.projectTime.bind(y));(0,lt.setLineToolLastPoint)({model:this,linkKey:e,point:{timeStamp:(0,n.ensureNotNull)(i),price:t.price}})}}}if(!this._isSettingsExternalPosition&&null!==this._lineBeingEdited&&null!==this._linePointBeingEdited){const e={index:r,price:o};if(this._linePointBeingChanged?.nonDiscreteIndex){const t=this.crosshairSource().originX();Number.isFinite(t)&&(e.index=this._timeScale.coordinateToFloatIndex(t))}this.changeLinePoint(e,s)
|
|
|
|
|
;const t=this._lineBeingEdited.alignCrossHairToAnchor(this._linePointBeingEdited)?this._lineBeingEdited.getPoint(this._linePointBeingEdited):e;null!==t&&this._setCorrectedPositionToCrosshair(t.index,t.price,i)}if(!this._isSettingsExternalPosition&&1===this._sourcesBeingMoved.length){const e=this._sourcesBeingMoved[0];if(e.alignCrossHairToMovePoint?.()){const t=e.currentMovingPoint?.();t&&t.logical&&this._setCorrectedPositionToCrosshair(t.logical.index,t.logical.price,i)}}if(!this._isSettingsExternalPosition&&m){const e=d.bars().firstIndex(),t=d.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(r,e),t);s!==r&&this._setCorrectedPositionToCrosshair(s,o,i)}}(_!==r||p!==o)&&this._syncCrosshair(s)}setExternalPosition(e,t){let i;const s=this.crosshairSource();if(s.setOnHoveredChartWidget(!1),null!==e&&(0,ut.isNumber)(e.timeStamp)){const t=this.mainSeries().syncModel();if(t){const s=this.createSyncPoint(e.syncSourceTarget,t.syncSourceTarget()).sourceTimeToTargetTime(e.timeStamp);i=this._timeScale.points().roughIndex(s,t.distance.bind(t),1)}}if(null!==e&&null!=i&&Number.isFinite(i)){this._isSettingsExternalPosition=!0;const o=(0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),r=this._timeScale.indexToCoordinate(i),a=(0,n.ensureNotNull)(o.mainDataSource()).firstValue();if(null!==a){let i=NaN;void 0!==e.price&&Number.isFinite(e.price)&&(i=this.mainSeries().priceScale().priceToCoordinate(e.price,a)),s.clearOriginCoords(),this.setCurrentPosition(r,i,o,t)}return s.setOnHoveredChartWidget(!1),void(this._isSettingsExternalPosition=!1)}s.clearPosition(),(0,n.ensureNotNull)(s.dataWindowView()).update((0,Vt.sourceChangeEvent)(s.id())),c_(this._panes),this.invalidate(fo.InvalidationMask.cursor())}startScaleTime(e){this._timeScale.startScale(e)}scaleTimeTo(e){this._timeScale.scaleTo(e),this.recalculateAllPanes((0,Vt.viewportChangeEvent)()),this.lightUpdate()}endScaleTime(){this._timeScale.endScale(),this.lightUpdate(),this.recalcVisibleRangeStudies(Do.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction)}resetTimeScale(){this._timeScale.restoreDefault(),this.recalculateAllPanes((0,Vt.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Do.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction),this.lightUpdate(),this._resetScales.fire()}startScalePrice(e,t,i){e.startScalePrice(t,i)}scalePriceTo(e,t,i){e.scalePriceTo(t,i),this.mainSeries().priceScale().isLockScale()?this.lightUpdate():this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}endScalePrice(e,t){e.endScalePrice(t),this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}startTwoPointsScalePrice(e,t,i,s){t.startTwoPointsScale(i,s)}twoPointsScalePriceTo(e,t,i,s){t.twoPointsScale(i,s),t.updateAllViews((0,Vt.viewportChangeEvent)()),this.invalidate(this._paneInvalidationMask(e))}endTwoPointsScalePrice(e,t){t.endTwoPointsScale(),this.invalidate(this._paneInvalidationMask(e))}resetPriceScale(e,t){e.resetPriceScale(t),this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}
|
|
|
|
|
restorePriceScaleState(e,t,i){e.restorePriceScaleState(t,i),this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}detachSource(e){const t=this.paneForSource(e);return!!t&&(t.removeDataSource(e),t.isEmpty()?(this._lineBeingCreated&&t===this._paneBeingCreatedLineOn&&this.cancelCreatingLine(),this.removePane(t),!0):(this.fullUpdate(),!1))}restoreSource(e,t,i,s,o){const n=e?this.createPane(t):this.panes()[t],r=(0,mt.isStudyState)(s),a=r?n.restoreStudy(s):(0,mt.isLineToolState)(s)?n.restoreLineTool(s):s.id===tpoSummaryDataSourceId&&18===this.mainSeries().style()?n.restoreTpoSummaryDataSource(s):null;if(!a)return null;let l=null;if(o?(l=n.getPriceScaleById(o.id),l||(l=n.createPriceScaleAtPosition(o.position,o.priceScaleIndex),l.setId(o.id))):l=a.ownerSource()?.priceScale()??l,l&&(a.setPriceScale(l),l.addDataSource(a)),!e&&i&&i.overlayPriceScales){const e=this.dataSources().filter((e=>void 0!==i.overlayPriceScales[e.id()]));e.forEach((e=>n.removeSourceFromPriceScale(e)));const t=new Map;e.forEach((e=>{const s=i.overlayPriceScales[e.id()];if(!s)return;let o;t.has(s.id)?o=t.get(s.id):(o=n.createPriceScaleAtPosition("overlay"),o.restoreState(s),t.set(s.id,o)),e.setPriceScale(o),o.addDataSource(e)}))}return e&&i&&n.restoreState({state:i,withData:!1,version:this.version()}),r&&(this.recalculateAllPanes((0,Vt.sourceChangeEvent)(a.id())),this.mainSeries().invalidateBarColorerCache(),this.fullUpdate()),a}children(e,t){return this.dataSources().filter((i=>(0,Xs.isStudy)(i)?!t&&i.parentSources().includes(e):i.ownerSource()===e))}onRearrangePanes(){return this._onRearrangePanes}studyInserted(){return this._studyInserted}finishLineTool(e){const t=e.linkKey().value();(0,lt.drawOnAllCharts)().value()&&null!==t&&e.isSynchronizable()&&(0,lt.finishLineTool)({linkKey:t,model:this})}startChangingLinetool(e,t,i,s,o){this._lineBeingEdited=e,this._linePointBeingChanged=t||null,this._linePointBeingEdited=void 0===i?null:i,this._lineBeingEdited.startChanging(i,t,o),lt.isToolEditingNow.setValue(!0);const r=(0,n.ensureNotNull)(this.paneForSource(e));this._lineBeingEdited.startDragPoint&&void 0!==i&&void 0!==t&&this._lineBeingEdited.startDragPoint(i,t),o||void 0===i||void 0===t||this._lineBeingEdited.setPoint(i,t,s,o),this._lineBeingEdited.updateAllViews((0,Vt.sourceChangeEvent)(this._lineBeingEdited.id()));const a=this._paneInvalidationMask(r,fo.InvalidationLevel.Light);this.invalidate(a);const l=e.linkKey().value();if(l&&e.isSynchronizable()&&void 0!==i&&void 0!==t){const o=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,lt.startChangingLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:o},positionPercents:e.positionPercents(),pointIndex:i,envState:s||null})}}createLineTool(e){const{pane:t,point:i,linetool:s,linkKey:o=null,sharingMode:r=0,id:a,fromExternalModel:l}=e;let{properties:c,ownerSource:h}=e;if((0,n.assert)((0,Ct.isLineToolName)(s),`Cannot create unknown line tool: ${s}`),c){const e={...Ku.intervalsVisibilitiesDefaults},t=c.childs().intervalsVisibilities.state();(0,
|
|
|
|
|
ut.merge)(e,t??{});const i=c.state();i.intervalsVisibilities=e,c=(0,Qs.createLineToolProperties)(this.backgroundTheme().spawnOwnership(),s,!this.readOnly(),i)}const d=(0,Qs.createLineTool)(s,this,c,null,void 0,a);if("LineToolExecution"!==s){let e;switch(s){case"LineToolIcon":e=d.properties().childs().icon.value().toString(16).toUpperCase();break;case"LineToolEmoji":e=d.properties().childs().emoji.value();break;case"LineToolSticker":e=d.properties().childs().sticker.value()}(0,ne.trackEvent)("drawings","Study_Drawing_"+s,e)}(0,Qs.isStudyLineTool)(d)&&(0,ne.trackEvent)("studies",`Study_${d.metaInfo().id}`);const u=!d.linkKey().value()&&!o;h=(0,n.ensureDefined)(h||(0,n.ensureNotNull)(t.mainDataSource())),c||(0,Qs.prepareLineToolPropertiesByOwnerSource)(d.properties(),h),d.setOwnerSource(h);const _=h.priceScale();if(d.setPriceScale(_),r_&&h===this.mainSeries()&&d.share(r),t.addDataSource(d,_,!1),null!==d.preferredZOrder()&&t.insertAfter([d],this.mainSeries()),(0,lt.drawOnAllCharts)().value()){const e=d.isSynchronizable()?o||(0,fe.randomHash)():null;d.linkKey().setValue(e)}else d.linkKey().setValue(o);let p;if(u&&d.enableCurrentIntervalVisibility(),d.isFixed()){const e=(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).firstValue()),s=this._timeScale.indexToCoordinate(i.index),o=(0,n.ensureNotNull)(_).priceToCoordinate(i.price,e);p=d.addFixedPoint(new Lt.Point(s,o))}else p=d.addPoint(i);return p||(this._lineBeingCreated={lineDataSource:d,fromExternal:!!l},this._paneBeingCreatedLineOn=t,lt.isToolCreatingNow.setValue(!0)),this.fullUpdate(),d}endChangingLinetool(e,t){const i=(0,n.ensureNotNull)(this._lineBeingEdited),s=i.endChanging(!1,e,t);this._lineBeingEdited=null,lt.isToolEditingNow.setValue(!1),this._linePointBeingEdited=null,this._linePointBeingChanged=null,this.lightUpdate();const o={points:i.normalizedPoints(),interval:this.mainSeries().interval()},r=i.linkKey().value();null!==r&&i.isSynchronizable()&&!t&&(0,lt.finishChangingLineTool)({model:this,linkKey:r,symbol:this.mainSeries().symbol(),finalState:o,changes:s})}continueCreatingLine(e,t,i,s,o){const r=(0,n.ensureNotNull)(this.lineBeingCreated()),a=r.addPoint(e,t,i,o);r.updateAllViews((0,Vt.sourceChangeEvent)(r.id()));const l=new fo.InvalidationMask(fo.InvalidationLevel.Light);return a&&(this._paneBeingCreatedLineOn=null,this._lineBeingCreated=null,lt.isToolCreatingNow.setValue(!1)),this.invalidate(l),a}cancelCreatingLine(){const e=this.lineBeingCreated();e&&(this.removeSource(e),this._lineBeingCreated=null,this._lineCancelled.fire(),lt.isToolCreatingNow.setValue(!1),(0,lt.drawOnAllCharts)().value()&&e.isSynchronizable()&&(0,lt.cancelLineTool)({model:this}))}lineBeingCreated(){return this._lineBeingCreated?.lineDataSource||null}lineBeingCreateFromExternal(){return this._lineBeingCreated?.fromExternal||!1}paneBeingCreatedLineOn(){return this._paneBeingCreatedLineOn}lineCancelled(){return this._lineCancelled}isPhantomLine(e){return this._phantomSourceContainer.source()===e}alignTo45Degrees(e,t){const[i,s]=t,o={...s};e.snapPoint45Degree(i,o),
|
|
|
|
|
this.startChangingLinetool(e,s,s.pointIndex),this.changeLinePoint(o,Eo.EnvironmentState.create(!0)),this.endChangingLinetool(!1)}changeLinePoint(e,t,i){const s=(0,n.ensureNotNull)(this._lineBeingEdited),o=(0,n.ensureNotNull)(this._linePointBeingEdited);let r=e.price,a=e.index;if(s.setPoint(o,e,t,i),!i){const t=s.alignCrossHairToAnchor(o)?s.getPoint(o):e;null!==t&&(a=t.index,r=t.price)}s.updateAllViews((0,Vt.sourceChangeEvent)(s.id())),this.lightUpdate();const l=s.linkKey().value();if(!i&&null!==l&&s.isSynchronizable()){const e=(0,n.ensureNotNull)(this._linePointBeingChanged),i={indexesChanged:a!==e.index,pricesChanged:r!==e.price},c=s.getChangePointForSync(o);if(null!==c){const e=this.externalTimeStamp(a);null!==e&&(r=c.price,(0,lt.changeLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:r,timeStamp:e},positionPercents:s.positionPercents(),envState:t,changes:i}))}}}changeLinePoints(e,t,i){const s=e.points(),o=e.linkKey().value();!i&&o&&e.isSynchronizable()&&t.forEach(((t,i)=>{const r=s[i],a=r.price!==t.price,l=r.index!==t.index;if(e.getChangePointForSync(i)){const i=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,lt.changeLineTool)({linkKey:o,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:i},positionPercents:e.positionPercents(),changes:{pricesChanged:a,indexesChanged:l}})}})),e.setPoints(t),e.updateAllViews((0,Vt.sourceChangeEvent)(e.id())),this.lightUpdate()}startScrollTime(e){this._timeScale.startScroll(e),this._isTimeScrolling=!0,this.mainSeries().clearGotoDateResult()}scrollTimeTo(e){this._timeScale.scrollTo(e),this.recalculateAllPanes((0,Vt.viewportChangeEvent)()),this.lightUpdate()}endScrollTime(){this._timeScale.endScroll(),this.lightUpdate(),this.recalcVisibleRangeStudies(Do.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction),this._isTimeScrolling=!1}startScrollPrice(e,t,i){e.startScrollPrice(t,i)}scrollPriceTo(e,t,i){e.scrollPriceTo(t,i),this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}endScrollPrice(e,t){e.endScrollPrice(t),this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}addCustomSource(e,t,i=Do.CustomSourceLayer.Foreground){this._customSourcesMap.has(e)&&a_.logWarn(`Attempt to add the same custom source multiple time "${e}"`),a_.logNormal(`Adding custom source "${e}"`);const s=t(e,this);switch(i){case Do.CustomSourceLayer.Background:this._bgCustomSources.push(s);break;case Do.CustomSourceLayer.Foreground:this._fgCustomSources.push(s);break;case Do.CustomSourceLayer.Topmost:this._topmostCustomSources.push(s);break;default:throw new Error(`Unknown custom sources layer ${i}`)}this._allCustomSources.push(s),this._customSourcesMap.set(e,s),this.lightUpdate()}removeCustomSource(e){this._removeCustomSource(e),this.lightUpdate()}hasCustomSource(e){return this._customSourcesMap.has(e)}customSourceForName(e){return this._customSourcesMap.get(e)||null}customSourceName(e){let t=null;return this._customSourcesMap.forEach(((i,s)=>{i===e&&(t=s)})),t}customSources(e){switch(e){
|
|
|
|
|
case Do.CustomSourceLayer.Background:return this._bgCustomSources;case Do.CustomSourceLayer.Foreground:return this._fgCustomSources;case Do.CustomSourceLayer.Topmost:return this._topmostCustomSources;default:return this._allCustomSources}}addMultiPaneSource(e){this._multiPaneSources.push(e),this._onMultipaneSourcesCollectionChanged.fire(),this.lightUpdate()}removeMultiPaneSource(e){const t=this._multiPaneSources.indexOf(e);-1===t?a_.logWarn("Attempt to remove multi-pane source which does not exist in the model"):(this._onMultipaneSourcesCollectionChanged.fire(),this._multiPaneSources.splice(t,1)),this.lightUpdate()}multiPaneSources(e){return this._multiPaneSources.filter((t=>!e.hasDataSource(t)))}onMultipaneSourcesCollectionChanged(){return this._onMultipaneSourcesCollectionChanged}rendererOptionsProvider(){return this._rendererOptionsProvider}magnet(){return this._magnet}priceAxisRendererOptions(){return this._rendererOptionsProvider.options()}priceScaleSlotsCount(){let e=0,t=0;this._panes.forEach((i=>{e=Math.max(i.leftPriceScales().length,e),t=Math.max(i.rightPriceScales().length,t)}));const i=e+t;if(ze.CheckMobile.any()){const e=(0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),t=e.priceScalePosition(this.mainSeries().priceScale());return("overlay"===t?e.rightPriceScales().length>0:"right"===t)?{left:0,right:1,totallySlots:i}:{left:1,right:0,totallySlots:i}}return{left:e,right:t,totallySlots:i}}dateTimeFormatter(){return this._dateTimeFormatter}dateFormatter(){return this._dateFormatter}timeFormatter(){return this._timeFormatter}isUnmergeAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return(0,n.ensureNotNull)(this.paneForSource(e)).dataSources().filter(this._unmergeAvailable,this).length>1}isMergeDownAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;const t=this.paneForSource(e),i=this.panes().filter((e=>e.mode()===Bi.PaneMode.Regular));return t!==i[i.length-1]}isMergeUpAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return this.paneForSource(e)!==this.panes().filter((e=>e.mode()===Bi.PaneMode.Regular))[0]}isPriceScaleVisible(e){const t=e.mainSource();if(!t)return!1;const i=(0,n.ensureNotNull)(this.paneForSource(t)),s=i.priceScalePosition(e);if("overlay"===s)return!0;const o=i.priceScaleIndex(e,s),r=this.priceScaleSlotsCount()[s];return void 0!==o&&o<r}getStudyShiftColorStartOffset(){return this._studyShiftColorStartOffset}setStudyShiftColorStartOffset(e){this._studyShiftColorStartOffset=e}sessions(){return(0,n.ensureNotNull)(this._sessions)}createSessions(e){if(null===this._sessions){const t=function(e){const t=new Ic(e);return(0,h.applyDefaultsOverrides)(t.childs().sessionHighlight,void 0,!1,"sessions"),t.removeDuplicateProperties(),t}((0,e_.createWVFromGetterAndSubscription)((()=>this.mainSeries().symbolInfo()),this.mainSeries().dataEvents().symbolResolved()).ownership());this._sessions=new Mc((async()=>{const s=await Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,83943));return this.addCustomSource("sessions",((i,o)=>{const n=new s.Sessions(i,o,t,e)
|
|
|
|
|
ut.merge)(e,t??{});const i=c.state();i.intervalsVisibilities=e,c=(0,Qs.createLineToolProperties)(this.backgroundTheme().spawnOwnership(),s,!this.readOnly(),i)}const d=(0,Qs.createLineTool)(s,this,c,null,void 0,a);if("LineToolExecution"!==s){let e;switch(s){case"LineToolIcon":e=d.properties().childs().icon.value().toString(16).toUpperCase();break;case"LineToolEmoji":e=d.properties().childs().emoji.value();break;case"LineToolSticker":e=d.properties().childs().sticker.value()}(0,ne.trackEvent)("drawings","Study_Drawing_"+s,e)}(0,Qs.isStudyLineTool)(d)&&(0,ne.trackEvent)("studies",`Study_${d.metaInfo().id}`,d.metaInfo().description);const u=!d.linkKey().value()&&!o;h=(0,n.ensureDefined)(h||(0,n.ensureNotNull)(t.mainDataSource())),c||(0,Qs.prepareLineToolPropertiesByOwnerSource)(d.properties(),h),d.setOwnerSource(h);const _=h.priceScale();if(d.setPriceScale(_),r_&&h===this.mainSeries()&&d.share(r),t.addDataSource(d,_,!1),null!==d.preferredZOrder()&&t.insertAfter([d],this.mainSeries()),(0,lt.drawOnAllCharts)().value()){const e=d.isSynchronizable()?o||(0,fe.randomHash)():null;d.linkKey().setValue(e)}else d.linkKey().setValue(o);let p;if(u&&d.enableCurrentIntervalVisibility(),d.isFixed()){const e=(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).firstValue()),s=this._timeScale.indexToCoordinate(i.index),o=(0,n.ensureNotNull)(_).priceToCoordinate(i.price,e);p=d.addFixedPoint(new Lt.Point(s,o))}else p=d.addPoint(i);return p||(this._lineBeingCreated={lineDataSource:d,fromExternal:!!l},this._paneBeingCreatedLineOn=t,lt.isToolCreatingNow.setValue(!0)),this.fullUpdate(),d}endChangingLinetool(e,t){const i=(0,n.ensureNotNull)(this._lineBeingEdited),s=i.endChanging(!1,e,t);this._lineBeingEdited=null,lt.isToolEditingNow.setValue(!1),this._linePointBeingEdited=null,this._linePointBeingChanged=null,this.lightUpdate();const o={points:i.normalizedPoints(),interval:this.mainSeries().interval()},r=i.linkKey().value();null!==r&&i.isSynchronizable()&&!t&&(0,lt.finishChangingLineTool)({model:this,linkKey:r,symbol:this.mainSeries().symbol(),finalState:o,changes:s})}continueCreatingLine(e,t,i,s,o){const r=(0,n.ensureNotNull)(this.lineBeingCreated()),a=r.addPoint(e,t,i,o);r.updateAllViews((0,Vt.sourceChangeEvent)(r.id()));const l=new fo.InvalidationMask(fo.InvalidationLevel.Light);return a&&(this._paneBeingCreatedLineOn=null,this._lineBeingCreated=null,lt.isToolCreatingNow.setValue(!1)),this.invalidate(l),a}cancelCreatingLine(){const e=this.lineBeingCreated();e&&(this.removeSource(e),this._lineBeingCreated=null,this._lineCancelled.fire(),lt.isToolCreatingNow.setValue(!1),(0,lt.drawOnAllCharts)().value()&&e.isSynchronizable()&&(0,lt.cancelLineTool)({model:this}))}lineBeingCreated(){return this._lineBeingCreated?.lineDataSource||null}lineBeingCreateFromExternal(){return this._lineBeingCreated?.fromExternal||!1}paneBeingCreatedLineOn(){return this._paneBeingCreatedLineOn}lineCancelled(){return this._lineCancelled}isPhantomLine(e){return this._phantomSourceContainer.source()===e}alignTo45Degrees(e,t){const[i,s]=t,o={...s}
|
|
|
|
|
;e.snapPoint45Degree(i,o),this.startChangingLinetool(e,s,s.pointIndex),this.changeLinePoint(o,Eo.EnvironmentState.create(!0)),this.endChangingLinetool(!1)}changeLinePoint(e,t,i){const s=(0,n.ensureNotNull)(this._lineBeingEdited),o=(0,n.ensureNotNull)(this._linePointBeingEdited);let r=e.price,a=e.index;if(s.setPoint(o,e,t,i),!i){const t=s.alignCrossHairToAnchor(o)?s.getPoint(o):e;null!==t&&(a=t.index,r=t.price)}s.updateAllViews((0,Vt.sourceChangeEvent)(s.id())),this.lightUpdate();const l=s.linkKey().value();if(!i&&null!==l&&s.isSynchronizable()){const e=(0,n.ensureNotNull)(this._linePointBeingChanged),i={indexesChanged:a!==e.index,pricesChanged:r!==e.price},c=s.getChangePointForSync(o);if(null!==c){const e=this.externalTimeStamp(a);null!==e&&(r=c.price,(0,lt.changeLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:r,timeStamp:e},positionPercents:s.positionPercents(),envState:t,changes:i}))}}}changeLinePoints(e,t,i){const s=e.points(),o=e.linkKey().value();!i&&o&&e.isSynchronizable()&&t.forEach(((t,i)=>{const r=s[i],a=r.price!==t.price,l=r.index!==t.index;if(e.getChangePointForSync(i)){const i=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,lt.changeLineTool)({linkKey:o,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:i},positionPercents:e.positionPercents(),changes:{pricesChanged:a,indexesChanged:l}})}})),e.setPoints(t),e.updateAllViews((0,Vt.sourceChangeEvent)(e.id())),this.lightUpdate()}startScrollTime(e){this._timeScale.startScroll(e),this._isTimeScrolling=!0,this.mainSeries().clearGotoDateResult()}scrollTimeTo(e){this._timeScale.scrollTo(e),this.recalculateAllPanes((0,Vt.viewportChangeEvent)()),this.lightUpdate()}endScrollTime(){this._timeScale.endScroll(),this.lightUpdate(),this.recalcVisibleRangeStudies(Do.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction),this._isTimeScrolling=!1}startScrollPrice(e,t,i){e.startScrollPrice(t,i)}scrollPriceTo(e,t,i){e.scrollPriceTo(t,i),this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}endScrollPrice(e,t){e.endScrollPrice(t),this.invalidate(this._paneInvalidationMask(e,fo.InvalidationLevel.Light))}addCustomSource(e,t,i=Do.CustomSourceLayer.Foreground){this._customSourcesMap.has(e)&&a_.logWarn(`Attempt to add the same custom source multiple time "${e}"`),a_.logNormal(`Adding custom source "${e}"`);const s=t(e,this);switch(i){case Do.CustomSourceLayer.Background:this._bgCustomSources.push(s);break;case Do.CustomSourceLayer.Foreground:this._fgCustomSources.push(s);break;case Do.CustomSourceLayer.Topmost:this._topmostCustomSources.push(s);break;default:throw new Error(`Unknown custom sources layer ${i}`)}this._allCustomSources.push(s),this._customSourcesMap.set(e,s),this.lightUpdate()}removeCustomSource(e){this._removeCustomSource(e),this.lightUpdate()}hasCustomSource(e){return this._customSourcesMap.has(e)}customSourceForName(e){return this._customSourcesMap.get(e)||null}customSourceName(e){let t=null;return this._customSourcesMap.forEach(((i,s)=>{i===e&&(t=s)})),t}customSources(e){
|
|
|
|
|
switch(e){case Do.CustomSourceLayer.Background:return this._bgCustomSources;case Do.CustomSourceLayer.Foreground:return this._fgCustomSources;case Do.CustomSourceLayer.Topmost:return this._topmostCustomSources;default:return this._allCustomSources}}addMultiPaneSource(e){this._multiPaneSources.push(e),this._onMultipaneSourcesCollectionChanged.fire(),this.lightUpdate()}removeMultiPaneSource(e){const t=this._multiPaneSources.indexOf(e);-1===t?a_.logWarn("Attempt to remove multi-pane source which does not exist in the model"):(this._onMultipaneSourcesCollectionChanged.fire(),this._multiPaneSources.splice(t,1)),this.lightUpdate()}multiPaneSources(e){return this._multiPaneSources.filter((t=>!e.hasDataSource(t)))}onMultipaneSourcesCollectionChanged(){return this._onMultipaneSourcesCollectionChanged}rendererOptionsProvider(){return this._rendererOptionsProvider}magnet(){return this._magnet}priceAxisRendererOptions(){return this._rendererOptionsProvider.options()}priceScaleSlotsCount(){let e=0,t=0;this._panes.forEach((i=>{e=Math.max(i.leftPriceScales().length,e),t=Math.max(i.rightPriceScales().length,t)}));const i=e+t;if(ze.CheckMobile.any()){const e=(0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),t=e.priceScalePosition(this.mainSeries().priceScale());return("overlay"===t?e.rightPriceScales().length>0:"right"===t)?{left:0,right:1,totallySlots:i}:{left:1,right:0,totallySlots:i}}return{left:e,right:t,totallySlots:i}}dateTimeFormatter(){return this._dateTimeFormatter}dateFormatter(){return this._dateFormatter}timeFormatter(){return this._timeFormatter}isUnmergeAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return(0,n.ensureNotNull)(this.paneForSource(e)).dataSources().filter(this._unmergeAvailable,this).length>1}isMergeDownAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;const t=this.paneForSource(e),i=this.panes().filter((e=>e.mode()===Bi.PaneMode.Regular));return t!==i[i.length-1]}isMergeUpAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return this.paneForSource(e)!==this.panes().filter((e=>e.mode()===Bi.PaneMode.Regular))[0]}isPriceScaleVisible(e){const t=e.mainSource();if(!t)return!1;const i=(0,n.ensureNotNull)(this.paneForSource(t)),s=i.priceScalePosition(e);if("overlay"===s)return!0;const o=i.priceScaleIndex(e,s),r=this.priceScaleSlotsCount()[s];return void 0!==o&&o<r}getStudyShiftColorStartOffset(){return this._studyShiftColorStartOffset}setStudyShiftColorStartOffset(e){this._studyShiftColorStartOffset=e}sessions(){return(0,n.ensureNotNull)(this._sessions)}createSessions(e){if(null===this._sessions){const t=function(e){const t=new Ic(e);return(0,h.applyDefaultsOverrides)(t.childs().sessionHighlight,void 0,!1,"sessions"),t.removeDuplicateProperties(),t}((0,e_.createWVFromGetterAndSubscription)((()=>this.mainSeries().symbolInfo()),this.mainSeries().dataEvents().symbolResolved()).ownership());this._sessions=new Mc((async()=>{const s=await Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,83943));return this.addCustomSource("sessions",((i,o)=>{const n=new s.Sessions(i,o,t,e)
|
|
|
|
|
;return n.start(),n}),Do.CustomSourceLayer.Background),this.customSourceForName("sessions")})(),this,t)}}createPrePostMarket(e){this.addCustomSource("prePostMarket",((t,i)=>new gd(t,i,e)))}createIntradayInactivityGaps(){this.addCustomSource("intradayInactivityGaps",((e,t)=>new s_(e,t)))}intradayInactivityGaps(){if(!l.enabled("intraday_inactivity_gaps"))throw new Error("intraday_inactivity_gaps featureset is not enabled");return(0,n.ensureNotNull)(this._intradayInactivityGapsWatchedValue)}setIntradayInactivityGapsSession(e){(0,n.ensureNotNull)(this.customSourceForName("intradayInactivityGaps")).setSession(e||"session")}watermarkSource(){return this._watermarkSource}watermarkContentProvider(){return t_.getInstance().provider()}studiesColorRotatorFactory(){return this._studyColorRotatorFactory}replayStatus(){return this._replayStatus}setReplayStatus(e){this._replayStatus.setValue(e)}isInReplay(){return this._mainSeries.isInReplay()}getSymbolString(){return this._mainSeries.getSymbolString()}interval(){return this._mainSeries.interval()}onInReplayStateChanged(){return new re.Delegate}switchToReplay(e,t){0}switchToRealtime(){0}canChangeResolution(e){return this._mainSeries.canChangeResolution(e)}canChangeSymbol(e){return this._mainSeries.canChangeSymbol(e)}onReplayModified(){return(0,n.assert)(!1,"Replay not implemented"),this._mainSeries.onReplayModified()}mainSeriesScaleRatioProperty(){return this._mainSeriesScaleRatioProperty}mainSeriesScaleRatioPropertyOnChanged(){this._mainSeriesScaleRatioProperty.fireChanged()}getThemeNameIfStdTheme(){const e=this.sessions().properties(),t=this.properties(),i=this.mainSeries().properties();return e.allThemePropertiesAreDefault(so.StdTheme.Light)&&t.allThemePropertiesAreDefault(so.StdTheme.Light)&&i.allThemePropertiesAreDefault(so.StdTheme.Light)?so.StdTheme.Light:e.allThemePropertiesAreDefault(so.StdTheme.Dark)&&t.allThemePropertiesAreDefault(so.StdTheme.Dark)&&i.allThemePropertiesAreDefault(so.StdTheme.Dark)?so.StdTheme.Dark:null}theme(){return{chartProperties:this.properties().themeState(),sessions:this.sessions().properties().themeState(),mainSourceProperties:this.mainSeries().properties().themeState(),version:this.version()}}template(){return{chartProperties:this.properties().template(),sessions:this.sessions().properties().template(),mainSourceProperties:this.mainSeries().properties().template(),version:this.version()}}onChartThemeLoaded(){return this._chartThemeLoaded}chartThemeLoaded(){this._chartThemeLoaded.fire()}async colorStudiesPropertiesReady(){this._recalcColorStudiesImpl(this._recalcVRStudiesParams);const e=this.allStudies(!0).filter((e=>e.metaInfo().inputs.filter(Bs.isStudyInputDependsOnChartColors).length>0));await Promise.all(e.map((e=>e.propertiesPatched())))}state(e,t,i,s){const o=this.publishedChartsTimelineSource(),n=this.properties().childs(),r=n.tradingProperties.state(),a={panes:this._panes.map((o=>o.state(!0,e,!1,t,i,s))),timeScale:this._timeScale.state(e),chartProperties:{
|
|
|
|
|
paneProperties:n.paneProperties.state(["horzGridProperties.style","vertGridProperties.style"]),scalesProperties:n.scalesProperties.state(),publishedChartsTimelineProperties:o?o.state(e):void 0,chartEventsSourceProperties:n.chartEventsSourceProperties?.state(),tradingProperties:r,priceScaleSelectionStrategyName:n.priceScaleSelectionStrategyName.value(),inactivityGaps:n.inactivityGaps.value()},sessions:this.sessions().state(e),version:this.version(),timezone:this.timezone(),shouldBeSavedEvenIfHidden:this._shouldBeSavedEvenIfHidden,linkingGroup:this._linkingGroupIndex.value()};return s||(a.lineToolsGroups=this.lineToolsGroupModel().state(t)),a}isInRestoreState(){return this._restoringState}restoreState(e,t,i){Sh.instance(this).reset();const s={};if(!e.panes)return void a_.logDebug("ChartModel.restoreState: invalid state");if(!Array.isArray(e.panes))return void a_.logDebug("ChartModel.restoreState: invalid state");if(e.panes.length<1)return void a_.logDebug("ChartModel.restoreState: invalid state");this._restoringState=!0;for(const e of this._barsMarksSources)this.detachSource(e);if(this._shouldBeSavedEvenIfHidden=e.shouldBeSavedEvenIfHidden??!0,e.chartProperties&&!e.chartProperties.timezone&&(e.chartProperties.timezone=e.timezone),e.chartProperties){const i=(0,h.factoryDefaults)("chartproperties").scalesProperties;(0,ut.merge)(i,e.chartProperties.scalesProperties),!("showLastValue"in i)||"showSeriesLastValue"in i||"showStudyLastValue"in i||(i.showSeriesLastValueProperty=i.showLastValue,i.showStudyLastValueProperty=i.showLastValue),"showSeriesLastValue"in i&&(s.showSeriesLastValueProperty=!0),"showStudyLastValue"in i&&(s.showStudyLastValueProperty=!0),(!this.isSnapshot()&&!this.readOnly()&&"showCurrency"in i||"showUnit"in i)&&((0,Be.migrateShowCurrencyAndShowUnitProperties)(i.showCurrency,i.showUnit),delete i.showCurrency,delete i.showUnit);{const{paneProperties:t}=e.chartProperties;t.vertGridProperties=t.vertGridProperties||(0,ut.clone)(t.gridProperties),t.horzGridProperties=t.horzGridProperties||(0,ut.clone)(t.gridProperties),"backgroundType"in t||(t.backgroundType=vo.ColorType.Solid),"separatorColor"in t||(t.separatorColor=(0,k.getThemedColor)("color-chart-page-bg")),this._properties.childs().paneProperties.mergeAndFire(t)}this._properties.childs().scalesProperties.mergeAndFire(i),e.chartProperties.timezone&&this._properties.childs().timezone.setValue(e.chartProperties.timezone),e.chartProperties.chartEventsSourceProperties&&this._properties.hasChild("chartEventsSourceProperties")&&this._properties.childs().chartEventsSourceProperties.mergeAndFire(e.chartProperties.chartEventsSourceProperties),e.chartProperties.tradingProperties&&this._properties.hasChild("tradingProperties")&&(void 0===e.chartProperties.tradingProperties.horizontalAlignment&&(e.chartProperties.tradingProperties.horizontalAlignment=(o=e.chartProperties.tradingProperties.lineLength)<=40?Do.TradedGroupHorizontalAlignment.Right:o>=60?Do.TradedGroupHorizontalAlignment.Left:Do.TradedGroupHorizontalAlignment.Center),
|
|
|
|
|
this._properties.childs().tradingProperties.mergeAndFire(e.chartProperties.tradingProperties)),this._timeScale.restoreState(e.timeScale,t),this._updateDateTimeFormatter()}var o;if(e.timeScale&&this._timeScale.restoreState(e.timeScale,t),!this.readOnly()){const t=this._getExceedingChildStudies(e.panes);if(t.length){for(let i=e.panes.length-1;i>=0;--i){const s=e.panes[i];for(let e=s.sources.length-1;e>=0;--e){const i=s.sources[e];~t.indexOf(i)&&s.sources.splice(e,1)}s.sources.length||e.panes.splice(i,1)}0}}const r=e.version||0,a=e.panes;let l="_seriesId",c=1;for(const e of a){const t=e.sources.find((e=>"MainSeries"===e.type));if(t){l=t.id,t.state&&(c=t.state.style);break}}const d=!0,u=a[0];this.panes()[0].restoreState({state:u,withData:t,version:r,seriesId:l,settingsMigration:s,contentOverrides:i,restoreSilently:d,reason:2,targetSeriesStyle:c}),this.panes()[0].mainDataSource()||this.removePane(this.panes()[0]);let _=1;for(let o=1;o<e.panes.length;o++){const n=e.panes[o];if(0===n.sources.length&&(n.mode??Bi.PaneMode.Regular)===Bi.PaneMode.Regular){a_.logWarn("Empty pane detected - restoring is skipped. idx="+o+", state="+JSON.stringify(n));continue}const a=this.panes()[_]||this.createPane();a.restoreState({state:n,withData:t,version:r,seriesId:l,settingsMigration:s,contentOverrides:i,restoreSilently:d,reason:2,targetSeriesStyle:c}),a.mainDataSource()?_+=1:this.removePane(a)}u.isCollapsed&&this._panes[0].collapsed().setValue(!0),this._invalidateBarColorerCaches();const p=this.dataSources();let m=0;for(let e=0;e<p.length;e++){const t=p[e];(0,Qs.isLineTool)(t)&&(m++,t.calcIsActualSymbol())}this.updateTimeScaleBaseIndex(),this.recalculateAllPanes((0,Vt.globalChangeEvent)()),this.fullUpdate(),this.syncLollipopSources();const g=(0,n.ensureNotNull)(this.mainPane());for(const e of this._barsMarksSources)this.detachSource(e),g.addDataSource(e,this._mainSeries.priceScale(),!0);let f=hc.TVLocalStorage.getItem("linetools_limit")||1e3;return window.is_authenticated&&window.user&&window.user.settings&&(f=window.user.settings.linetools_limit||f),e.sessions&&this.sessions().restoreState(e.sessions,t),e.lineToolsGroups&&(this._lineToolsGroupModel=od.fromState(this,e.lineToolsGroups)),m>f&&m%100==0?{lines_limit_exceeded:!0,line_tools_count:m}:(this.panes().forEach((e=>this._dataSourceCollectionChanged.fire(e))),this._lineToolsGroupModel.fireChangedAll(),this._linkingGroupIndex.setValue(e.linkingGroup??null),this._restoringState=!1,{})}shouldBeSavedEvenIfHidden(){return this._shouldBeSavedEvenIfHidden}setShouldBeSavedEvenIfHidden(e){this._shouldBeSavedEvenIfHidden=e}externalTimeStamp(e){const t=this.mainSeries().syncModel();return this.timeScale().points().roughTime(e,t&&t.projectTime.bind(t))}syncLollipopSources(){this._lollipopSourcesWatcherLoader?.callFunction((()=>{null!==this._lollipopSourcesWatcher&&this._lollipopSourcesWatcher.syncSources()}))}restoreChartEvents(e){this._lollipopSourcesWatcherLoader?.callFunction((()=>{
|
|
|
|
|
@@ -731,7 +731,7 @@ const q_=new dt.TranslatedString("send {title} backward",a.t(null,void 0,i(40962
|
|
|
|
|
;const _=this._createLineCommand.startCreatingLine(t,s,o||null,l,a===Ar.CreateLineToolSyncMode.ForceOff),p=(0,n.ensureNotNull)(this._createLineCommand.line());let m=null;if(_&&(u&&this.finishLineTool(p),this._pushUndoCommand(this._createLineCommand),this._createLineCommand=null,m={points:p.normalizedPoints(),interval:this.mainSeries().interval()}),(void 0===o&&a===Ar.CreateLineToolSyncMode.Default&&(0,lt.drawOnAllCharts)().value()||a===Ar.CreateLineToolSyncMode.ForceOn)&&p.isSynchronizable()){const e=(0,n.ensureNotNull)(this.model().externalTimeStamp(t.index)),s={point:{price:t.price,timeStamp:e},linetool:i,properties:p.properties(),symbol:this.mainSeries().symbol(),model:this.model(),linkKey:(0,n.ensureNotNull)(p.linkKey().value()),finalState:m,id:p.id(),sharingMode:p.sharingMode().value()};p.isFixed()&&(s.pointPositionPercents=p.calcPositionPercents()),(0,lt.createLineTool)(s)}return this.endUndoMacro(),p}continueCreatingLine(e,t,i,s){const o=(0,n.ensureNotNull)(this._createLineCommand);this.beginUndoMacro(o.text());const r=(0,n.ensureNotNull)(this._model().lineBeingCreated()),a=o.continueCreatingLine(e,t,i,s);let l=null;if(a&&(this.finishLineTool(r),this._pushUndoCommand(o),this._createLineCommand=null,l={points:r.normalizedPoints(),interval:this.mainSeries().interval()}),o.drawOnAllCharts()&&r.isSynchronizable()){const i=(0,n.ensureNotNull)(this._model().externalTimeStamp(e.index));(0,lt.continueLineTool)({point:{price:e.price,timeStamp:i},envState:t,finalState:l,model:this._model()})}return this.endUndoMacro(),a}continueExternalLine(e,t,i){const s=(0,n.ensureNotNull)(this._createLineCommand),o=s.continueCreatingLine(e,t,i);return o&&(this._pushUndoCommand(s),this._createLineCommand=null),o}finishLineTool(e){this._model().finishLineTool(e)}cancelCreatingLine(){this.m_model.cancelCreatingLine()}lineBeingCreated(){return this.m_model.lineBeingCreated()}pasteImageAsLineTool(e,t,i,s){const o=this._model().timeScale(),r=o.width(),a=i.height(),l=i.defaultPriceScale(),c=(0,n.ensureNotNull)((0,n.ensureNotNull)(l.mainSource()).firstValue()),h={price:l.coordinateToPrice(a/2,c),index:o.coordinateToIndex(r/2)},d=(0,Qs.createLineToolProperties)(i.model().backgroundTheme().spawnOwnership(),"LineToolImage",!i.model().readOnly());void 0!==s&&d.childs().transparency.setValue(s);const u=(0,n.ensureNotNull)(l.mainSource());(0,Qs.prepareLineToolPropertiesByOwnerSource)(d,u);const _=this.createLineTool({pane:i,point:h,linetool:"LineToolImage",properties:d});return _&&(_.setBlobImageUrl(t),this.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(_,null)})),e.then((e=>{_.properties().childs().url.setValue(e)})).catch((e=>{const t=_.linkKey().value(),i=this.model();null!==t&&(0,lt.removeLineTool)({withUndo:!1,model:i,linkKey:t,symbol:_.symbol(),sourceTitle:new dt.TranslatedString(_.name(),_.translatedType()),lineToolState:_.state(!1)}),i.removeSource(_)}))),_}loadRange(e){const t=this._model(),i=t.appliedTimeFrame().value();return(null===i||!kr(i,e))&&(this._pushUndoCommand(new ja(t,e)),(0,W.emit)("timeframe_interval",e),!0)}
|
|
|
|
|
mainSeries(){return this.m_model.mainSeries()}model(){return this.m_model}publishedChartsTimelineSource(){return this.m_model.publishedChartsTimelineSource()}unlinkLines(e){const t=this.model();this.beginUndoMacro(tp);for(const i of e)null!==i.linkKey().value()&&(0,lt.removeLineTool)({withUndo:!0,model:this.model(),symbol:i.symbol(),linkKey:(0,n.ensureNotNull)(i.linkKey().value()),sourceTitle:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,i),lineToolState:i.state(!1),unlink:!0}),this._pushUndoCommand(new P_(t,i));this.endUndoMacro()}zoomFromViewport(){const e=new w_((0,n.ensureDefined)(this._zoomStack.head()),this._zoomStack,!1);this._pushUndoCommand(e)}zoomToViewport(e,t,i,s,o){const n=new v_(this.m_model,e,t,i,s,o),r=new w_(n,this._zoomStack,!0);this._pushUndoCommand(r)}zoomStack(){return this._zoomStack}timeScale(){return this.m_model.timeScale()}selection(){return this.m_model.selection()}selectionMacro(e,t){return this.m_model.selectionMacro(e,t)}onSelectedSourceChanged(){return this.m_model.onSelectedSourceChanged()}onTagsChanged(){return this.m_model.onTagsChanged()}lineCancelled(){return this.m_model.lineCancelled()}hoveredSource(){return this.m_model.hoveredSource()}crosshairSource(){return this.m_model.crosshairSource()}activeStrategySource(){return this.m_model.activeStrategySource()}setProperty(e,t,i,s){if(e&&e.value()!==t){this.beginUndoMacro(i);const o=new za(e,t,i,this.m_model,!s);this._pushUndoCommand(o),this.endUndoMacro(),this.emitEvent("setProperty")}}setProperties(e,t,i,s=!0){this.beginUndoMacro(i),this.m_model.selectionMacro((()=>{for(let o=0;o<e.length;o++)this.setProperty(e[o],t[o],i,!s)})),this.endUndoMacro()}beginUndoMacro(e){return this._undoHistory.beginUndoMacro(e)}endUndoMacro(){this._undoHistory.endUndoMacro()}invertPriceScale(e){const t=e.properties().childs().isInverted;this.setProperty(t,!t.value(),Ip)}togglePriceScaleAutoScaleMode(e){const t={autoScale:!e.isAutoScale()};this.setPriceScaleMode(t,e,Mp)}togglePriceScaleLockScaleMode(e){const t={lockScale:!e.isLockScale()};this.setPriceScaleMode(t,e,Ap)}togglePriceScalePercentageScaleMode(e){const t={percentage:!e.isPercentage()};this.setPriceScaleMode(t,e,Dp)}togglePriceScaleIndexedTo100ScaleMode(e){const t={indexedTo100:!e.isIndexedTo100()};this.setPriceScaleMode(t,e,kp)}togglePriceScaleLogScaleMode(e){const t={log:!e.isLog()};this.setPriceScaleMode(t,e,Ep)}setPriceScaleRegularScaleMode(e){this.setPriceScaleMode({log:!1,percentage:!1,indexedTo100:!1},e,Lp)}withMacro(e,t){const i=this.beginUndoMacro(e);try{t()}finally{this.endUndoMacro()}return i}dataSources(){return this.m_model.dataSources()}orderedDataSources(e){return this.m_model.orderedDataSources(e)}barsMarksSources(){return this.m_model.barsMarksSources()}removeAllDrawingTools(e){this.beginUndoMacro(Fp),this._removeAllDrawingToolsImpl(e),this.endUndoMacro()}removeAllStudiesAndDrawingTools(e){this.beginUndoMacro(Wp),this._removeAllDrawingToolsImpl(e),this._removeAllStudiesImpl(),this.endUndoMacro()}removeAllStudies(){this.beginUndoMacro(Op),
|
|
|
|
|
this._removeAllStudiesImpl(),this.endUndoMacro()}scrollChartByBar(e){if(!this.m_model.scrollEnabled())return;const t=e*this.m_model.timeScale().barSpacing();this.startScrollTime(0),this.scrollTimeTo(t),this.endScrollTime()}canZoomIn(){return this.model().canZoomIn()}canZoomOut(){return this.model().canZoomOut()}zoomOut(){const e=this.timeScale().width();this.canZoomOut()&&(this.changeTimeScale(ip),(0,Dr.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(0),this.scaleTimeTo(e),this.endScaleTime()}}))}zoomIn(){const e=this.timeScale().width();this.canZoomIn()&&(this.changeTimeScale(sp),(0,Dr.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(e),this.scaleTimeTo(0),this.endScaleTime()}}))}scrollChart(e){this.m_model.scrollEnabled()&&(this.startScrollTime(0),this.scrollTimeTo(e),this.endScrollTime())}startMovingSources(e,t,i,s){e.filter((e=>e.doesMovingAffectsUndo())).length&&(this._currentSourceMoveCommand=new Xr(this.model(),e,op,!1)),this.model().startMovingSources(e,t,i,new Map,s)}moveSources(e,t){this.model().moveSources(e,new Map,t)}endMovingSource(e,t){this.model().endMovingSources(e,void 0,t),null!==this._currentSourceMoveCommand&&(this._currentSourceMoveCommand.saveNewState(),this._pushUndoCommand(this._currentSourceMoveCommand)),this._currentSourceMoveCommand=null}startChangingLinetool(e,t,i,s,o){this._currentLineChangeCommand=new Xr(this.model(),[e],e.changePointUndoText(i),!1),this.model().startChangingLinetool(e,t,i,s,o)}changeLinePoint(e,t){this.model().changeLinePoint(e,t)}alignToolTo45Degrees(e){const t=e.alignTo45DegreesPoints();t&&(this._pushUndoCommand(new Xr(this.model(),[e],Rp,!1)),this.model().alignTo45Degrees(e,t))}endChangingLinetool(e){this.model().endChangingLinetool(e),null!==this._currentLineChangeCommand&&(this._currentLineChangeCommand.saveNewState(),this._pushUndoCommand(this._currentLineChangeCommand)),this._currentLineChangeCommand=null}setChartStyleProperty(e,t,i){if(e.value()!==t){const s=void 0,o=()=>{this.beginUndoMacro(i);const s=new Ua(e,t,this.mainSeries(),i,this.model(),this._chartWidget);this._pushUndoCommand(s),this.emitEvent("setChartStyleProperty"),e.value(),this.endUndoMacro()};s?runOrGoPro(o,s.feature,{feature:s.featureName}):o()}}setPriceAutoScale(e,t,i){this._pushUndoCommand(new Rn(this.m_model,e,t,t.state())),this.m_model.setPriceAutoScale(e,t,i)}setPriceScaleMode(e,t,i){if(!(0,ko.default)(t.mode(),e)){const s=new ac(e,t,i,this.m_model);this._pushUndoCommand(s)}}setPriceScaleSelectionStrategy(e){const t=this.m_model.properties().childs();if(t.priceScaleSelectionStrategyName.value()===e)return;(0,ne.trackEvent)("Chart","Change PriceScale Selection Strategy");const i=Np.format({title:e});this.beginUndoMacro(i),this.setProperty(t.priceScaleSelectionStrategyName,e,i);const s=new j_(this.m_model,e,i);this._pushUndoCommand(s),this.endUndoMacro()}setScaleRatioProperty(e,t,i){if(e.value()!==t){const s=new U_(e,t,i,this.m_model);this._pushUndoCommand(s)}}createUndoCheckpoint(){return this._undoHistory.createUndoCheckpoint()}undoToCheckpoint(e){this._undoHistory.undoToCheckpoint(e)}
|
|
|
|
|
restorePropertiesForSource(e){(0,Qs.isLineTool)(e)?this._restoreLineToolFactoryDefaults(e):this._restoreStudyFactoryDefaults(e)}restoreLineToolsFactoryDefaults(e){1===e.length?this._restoreLineToolFactoryDefaults(e[0]):(this.beginUndoMacro(rp),e.forEach((e=>this._restoreLineToolFactoryDefaults(e))),this.endUndoMacro())}restorePreferences(){const e=new z_(this.model());this._pushUndoCommand(e)}restoreState(e,t,i){return this.m_model.restoreState(e,t,i)}async clipboardCopy(e,t=this.selection().dataSources()){if(!(0,l.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;for(const e of i)if((0,Xs.isStudy)(e)&&e.isChildStudy())throw new Error("Can not copy child study");const s=(0,Vr.clipboardDataForSources)(this._model().id(),i);return null!==s?e.write({app:JSON.stringify(s),text:s.title}):void 0}async clipboardCut(e,t=this.selection().dataSources()){if(!(0,l.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;await this.clipboardCopy(e,i);const s=i.filter((e=>e.isUserDeletable()));if(0===s.length)return;const o=(1===s.length?Z_:X_).format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,s[0])});this.beginUndoMacro(o),this.m_model.selectionMacro((()=>this.removeSources(s,!1,o)),!0),this.endUndoMacro()}async clipboardPaste(e,t){let i=null;if((0,l.enabled)("datasource_copypaste")&&(i=i||await e.read(),i.app)){const e=JSON.parse(i.app);if(null!==await this.pasteSourceFromClip(t,e))return}await this._processSpecialLineToolsContents(e,i,t)}applyStudyTemplate(e,t){const i=new Hl(this._model(),e,t);this.beginUndoMacro(i.text());const s=this.m_model.panes().reduce(((e,t)=>e.concat(t.sourcesByGroup().allWithoutMultipaneWithHidden().filter((e=>(0,Qs.isLineTool)(e)&&e.ownerSource()!==this.m_model.mainSeries())))),[]);this.removeSources(s,!1,null),this._pushUndoCommand(i),this.endUndoMacro(),(0,W.emit)("load_study_template")}createStudyInserter(e,t,i={}){const{stubTitle:s,isOverlay:o}=i,n={createStudy:(e,t,i,s,o,n,r,a,l,c,h,d)=>{if(!this.checkIfFeatureAvailable(e,r))return jp.logNormal("Cannot insert study "+e.id),null;(0,ne.trackEvent)("studies","Study_"+e.id),"Compare@tv-basicstudies"===e.id&&(0,ne.trackEvent)("compare","symbol:"+t.symbol),s&&this.m_model.removeSource(s);const u=this._insertStudy(e,t,o,n,r,a,l,c,h,null,d);return u.study.then((e=>(0,W.emit)("study_event",e.id(),"create"))),u},storeFailedStub:e=>{this._storeFailedStub(e)}};void 0!==s&&(n.createStub=()=>this.m_model.insertStudyStub(s,o).id(),n.removeStub=e=>this.m_model.removeStudyStub(e));const r=new Ju(e,n);return r.setParentSources(t),r}applyLineToolTemplate(e,t,i){this.beginUndoMacro(i),this.saveLineToolState(e,i);const s=new O_(e,t,i);this._pushUndoCommand(s),this.saveLineToolState(e,i),this.endUndoMacro(),this.model().updateSource(e)}applyLineToolsTemplate(e){throw new Error("Not implemented")}replayStatus(){return this.m_model.replayStatus()}setReplayStatus(e){return this.m_model.setReplayStatus(e)}isInReplay(){
|
|
|
|
|
restorePropertiesForSource(e){(0,Qs.isLineTool)(e)?this._restoreLineToolFactoryDefaults(e):this._restoreStudyFactoryDefaults(e)}restoreLineToolsFactoryDefaults(e){1===e.length?this._restoreLineToolFactoryDefaults(e[0]):(this.beginUndoMacro(rp),e.forEach((e=>this._restoreLineToolFactoryDefaults(e))),this.endUndoMacro())}restorePreferences(){const e=new z_(this.model());this._pushUndoCommand(e)}restoreState(e,t,i){return this.m_model.restoreState(e,t,i)}async clipboardCopy(e,t=this.selection().dataSources()){if(!(0,l.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;for(const e of i)if((0,Xs.isStudy)(e)&&e.isChildStudy())throw new Error("Can not copy child study");const s=(0,Vr.clipboardDataForSources)(this._model().id(),i);return null!==s?e.write({app:JSON.stringify(s),text:s.title}):void 0}async clipboardCut(e,t=this.selection().dataSources()){if(!(0,l.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;await this.clipboardCopy(e,i);const s=i.filter((e=>e.isUserDeletable()));if(0===s.length)return;const o=(1===s.length?Z_:X_).format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,s[0])});this.beginUndoMacro(o),this.m_model.selectionMacro((()=>this.removeSources(s,!1,o)),!0),this.endUndoMacro()}async clipboardPaste(e,t){let i=null;if((0,l.enabled)("datasource_copypaste")&&(i=i||await e.read(),i.app)){const e=JSON.parse(i.app);if(null!==await this.pasteSourceFromClip(t,e))return}await this._processSpecialLineToolsContents(e,i,t)}applyStudyTemplate(e,t){const i=new Hl(this._model(),e,t);this.beginUndoMacro(i.text());const s=this.m_model.panes().reduce(((e,t)=>e.concat(t.sourcesByGroup().allWithoutMultipaneWithHidden().filter((e=>(0,Qs.isLineTool)(e)&&e.ownerSource()!==this.m_model.mainSeries())))),[]);this.removeSources(s,!1,null),this._pushUndoCommand(i),this.endUndoMacro(),(0,W.emit)("load_study_template")}createStudyInserter(e,t,i={}){const{stubTitle:s,isOverlay:o}=i,n={createStudy:(e,t,i,s,o,n,r,a,l,c,h,d)=>{if(!this.checkIfFeatureAvailable(e,r))return jp.logNormal("Cannot insert study "+e.id),null;(0,ne.trackEvent)("studies","Study_"+e.id,e.description),"Compare@tv-basicstudies"===e.id&&(0,ne.trackEvent)("compare","symbol:"+t.symbol),s&&this.m_model.removeSource(s);const u=this._insertStudy(e,t,o,n,r,a,l,c,h,null,d);return u.study.then((e=>(0,W.emit)("study_event",e.id(),"create"))),u},storeFailedStub:e=>{this._storeFailedStub(e)}};void 0!==s&&(n.createStub=()=>this.m_model.insertStudyStub(s,o).id(),n.removeStub=e=>this.m_model.removeStudyStub(e));const r=new Ju(e,n);return r.setParentSources(t),r}applyLineToolTemplate(e,t,i){this.beginUndoMacro(i),this.saveLineToolState(e,i);const s=new O_(e,t,i);this._pushUndoCommand(s),this.saveLineToolState(e,i),this.endUndoMacro(),this.model().updateSource(e)}applyLineToolsTemplate(e){throw new Error("Not implemented")}replayStatus(){return this.m_model.replayStatus()}setReplayStatus(e){return this.m_model.setReplayStatus(e)}isInReplay(){
|
|
|
|
|
return this.m_model.isInReplay()}getSymbolString(){return this.m_model.getSymbolString()}interval(){return this.m_model.interval()}onInReplayStateChanged(){return this.m_model.onInReplayStateChanged()}switchToReplay(e,t){0}switchToRealtime(){0}canChangeResolution(e){return this.model().canChangeResolution(e)}canChangeSymbol(e){return this.model().canChangeSymbol(e)}onReplayModified(){return this.model().onReplayModified()}startCustomMoving(e,t,i){this._currentCustomMoveCommand=new nc(this.model(),e,t,i)}customMoveBeingProcessed(){return null!==this._currentCustomMoveCommand}processCustomMove(e){(0,n.ensureNotNull)(this._currentCustomMoveCommand).move(e)}endCustomMoving(){null!==this._currentCustomMoveCommand&&this._currentCustomMoveCommand.hasChanges()&&(this._pushUndoCommand(this._currentCustomMoveCommand),this._currentCustomMoveCommand=null)}state(e,t,i,s){return this.m_model.state(e,t,i,s)}panes(){return this.m_model.panes()}cloneLineTools(e,t){for(let t=0;t<Math.min(5,e.length);++t)e[t],Fn();this.beginUndoMacro(cp);const i=new $r(this._model(),e,t,cp);this._pushUndoCommand(i);const s=i.newIds().map((e=>(0,n.ensureNotNull)(this.model().dataSourceForId(e)))).filter((e=>0!==e.sharingMode().value()));return s.length&&this._model().copyToOtherCharts(s,!0),this.endUndoMacro(),this.emitEvent("cloneLineTools"),i.newIds()}removeSource(e,t,i){this.lineBeingCreated()!==e?this.removeSources([e],t,J_.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e)}),i):this.cancelCreatingLine()}removeSelectedSources(){const e=this._model().selection().dataSources();if(!e.length)return;const t=(e.length>1?Q_:J_).format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e[0])});this.removeSources(e,!1,t)}removeSources(e,t,i,s){s||(e=e.filter((e=>e.isUserDeletable())));const o=this._model(),r=o.lineToolsGroupModel();this.beginUndoMacro(i),o.selectionMacro((s=>{const a=new Map;e.forEach((e=>{if((0,Qs.isLineTool)(e)){const t=r.groupForLineTool(e);if(null!==t){const i=a.get(t)||[];i.push(e),a.set(t,i)}null!==e.linkKey().value()&&(0,lt.removeLineTool)({withUndo:!0,model:this.model(),linkKey:(0,n.ensureNotNull)(e.linkKey().value()),symbol:this.model().mainSeries().symbol(),lineToolState:e.state(!1),sourceTitle:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e)})}}));const l=new Kr.RemoveSourcesUndoCommand(o,e,i),c=l.removedIds();this._pushUndoCommand(l),!t&&c.length>0&&(1===c.length?this.emitEvent("removeSource",[c[0]]):this.emitEvent("removeSources",[c]))}),!0),this.endUndoMacro()}async scrollToLineTool(e){const t=this.timeScale().logicalRange();if(null===t)return;const i=e.points().map((e=>e.index)),s=this.timeScale().points().range().value();if(null===s)return;let o=s.firstIndex;const r=s.lastIndex,a=t.length()/2;if(0===i.length||i.some((e=>t.contains(e))))return;const l=()=>{const t=e.points().map((e=>e.index)),i=t.filter((e=>e<=r)).reduce(((e,t)=>null===e?t:Math.max(e,t)),null);return null!==i?i:t.reduce(((e,t)=>Math.min(e,t)))};let c=l();if(o-a>c){
|
|
|
|
|
const t=e.points().map((e=>e.time)).filter(ut.notUndefined).map((e=>1e3*e));if(0===t.length)return;const i=t.reduce(((e,t)=>Math.min(e,t)),t[0]);await this.model().gotoTime(i),c=l();if((0,n.ensureNotNull)(this.timeScale().logicalRange()).contains(c))return;o=(0,n.ensureNotNull)(this.timeScale().points().range().value()).firstIndex}o-a>c&&this.mainSeries().setGotoDateResult({timestamp:(0,n.ensureNotNull)(this.timeScale().points().valueAt(o)),eod:!0});const h=this.timeScale().width()/2,d=this.timeScale().indexToCoordinate(c);this.model().stopTimeScaleAnimation(),this.model().setTimeScaleAnimation(new Br({from:0,to:h-d,duration:Ir.dur,easing:Ir.easingFunc.easeInOutCubic}))}mergeSourceUp(e){const t=new oa(this._model(),e,hp);this._mergeUnmergeSource(e,t)}mergeSourceDown(e){const t=new na(this._model(),e,dp);this._mergeUnmergeSource(e,t)}mergeToPane(e,t,i){const s=this._model().panes().indexOf(t),o=new ra(this._model(),e,s,up,i);this._mergeUnmergeSource(e,o)}unmergeSourceUp(e){const t=new ta(this._model(),e,_p);this._mergeUnmergeSource(e,t)}unmergeSourceDown(e){const t=new ea(this._model(),e,pp);this._mergeUnmergeSource(e,t)}unmergeToNewBottomPane(e){const t=new ia(this._model(),e,mp);this._mergeUnmergeSource(e,t)}moveLeft(){this.beginUndoMacro(Bp),(0,Dr.doAnimate)({to:this.m_model.timeScale().width()/5,onStep:e=>{this.startScrollTime(e),this.scrollTimeTo(0),this.endScrollTime()},onComplete:()=>{this.endUndoMacro()}})}moveRight(){this.beginUndoMacro(Vp),(0,Dr.doAnimate)({to:this.m_model.timeScale().width()/5,onStep:e=>{this.startScrollTime(0),this.scrollTimeTo(e),this.endScrollTime()},onComplete:()=>{this.endUndoMacro()}})}availableZOrderOperations(e){const t=this._model().lineToolsGroupModel(),i=e.filter(Qs.isLineTool),s=i.map((e=>t.groupForLineTool(e)));(0,n.assert)(new Set(s).size<=1,"Cannot move line tools from different group");const o=0===s.length?null:s[0];let r={bringForwardEnabled:!1,bringToFrontEnabled:!1,sendBackwardEnabled:!1,sendToBackEnabled:!1};const a=new Set(i);for(const t of(0,hi.sortSources)(e)){if((0,Qs.isLineTool)(t)&&null!==o){const e=(0,hi.sortSources)(o.lineTools().filter((e=>!a.has(e)||e===t)));r=$p(r,{bringForwardEnabled:t!==e[e.length-1],bringToFrontEnabled:t!==e[e.length-1],sendBackwardEnabled:t!==e[0],sendToBackEnabled:t!==e[0]});continue}const e=(0,n.ensureNotNull)(this._model().paneForSource(t)).sourcesByGroup().allExceptSpecialSources();if(0===e.length)continue;const i=t.zorder(),s=e[0].zorder(),l=e[e.length-1].zorder();r=$p(r,{bringForwardEnabled:i!==l,bringToFrontEnabled:i!==l,sendBackwardEnabled:i!==s,sendToBackEnabled:i!==s})}return r}sendToBack(e){if(!this.availableZOrderOperations(e).sendToBackEnabled)throw new Error("Send to back operation is unavailable");let t=null;const i=e[0];if((0,Qs.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new Ia(this.model(),(0,hi.sortSources)(e),i[0])}}null===t&&(t=new Ca(this.model(),(0,hi.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}bringToFront(e){
|
|
|
|
|
if(!this.availableZOrderOperations(e).bringToFrontEnabled)throw new Error("Bring to front operation is unavailable");let t=null;const i=e[0];if((0,Qs.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new Ta(this.model(),(0,hi.sortSources)(e),i[i.length-1])}}null===t&&(t=new wa(this.model(),(0,hi.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}sendBackward(e){if(!this.availableZOrderOperations(e).sendBackwardEnabled)throw new Error("Send backward operation is unavailable");const t=q_.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,hi.sortSources)(e),((e,t)=>new Aa(this.model(),e,t)))}bringForward(e){if(!this.availableZOrderOperations(e).bringForwardEnabled)throw new Error("Bring forward operation is unavailable");const t=$_.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,hi.sortSources)(e),((e,t)=>new ka(this.model(),e,t)))}insertAfter(e,t){e=(0,hi.sortSources)(e);const i=K_.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e[0]),target:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new Ta(this.model(),e,t)))}insertBefore(e,t){e=(0,hi.sortSources)(e);const i=Y_.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e[0]),target:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new Ia(this.model(),e,t)))}detachToRight(e,t){(0,ne.trackEvent)("Chart","Move to new right scale");const i=gp.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e)}),s=new Yl(this.model(),e,t,"right",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachToLeft(e,t){(0,ne.trackEvent)("Chart","Move to new left scale");const i=fp.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e)}),s=new Yl(this.model(),e,t,"left",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachNoScale(e,t){(0,ne.trackEvent)("Chart","Make source no scale");const i=yp.format({title:(0,ui.getTranslatedStringForSource)(da.TitleDisplayTarget.StatusLine,e)}),s=new Yl(this.model(),e,t,"overlay",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}moveToScale(e,t,i,s,o){(0,ne.trackEvent)("Chart","Move source to target scale"),this.beginUndoMacro(s);const n=new Zl(this.model(),e,t,i,s),r=o?null:Nr(e,i,this._model()),a=o?null:sh(e,i,this._model());this._pushUndoCommand(n),null!==r&&this.setPriceScaleCurrency(i,r),null!==a&&this.setPriceScaleUnit(i,a),this.endUndoMacro(),this.emitEvent("moveSource",[e])}setLinkingGroupIndex(e){const t=this.model().linkingGroupIndex();this._undoHistory.beginUndoMacro(Gp),this._pushUndoCommand(new V_(t,t.value(),e,Gp)),this._model().setShouldBeSavedEvenIfHidden(!0),this._undoHistory.endUndoMacro()}startScrollPrice(e,t,i){
|