"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[5248],{45135:(s,e,t)=>{t.r(e),t.d(e,{study_MovingAverage:()=>c});var r=t(67455),l=t(22613),o=t(43337),i=t(95059),n=t(92211),u=t(11485),a=t(36597),y=t(77380),m=t(48943);class c extends u.Study{constructor(s,e,t,i,n,u){super(s,function(s){return s.hasChild("currencyId")||s.addChild("currencyId",new o.Property(null)),s.hasChild("unitId")||s.addChild("unitId",new o.Property(null)),s.addExcludedKey("currencyId",1),s.addExcludedKey("unitId",1),s}(e),t,i,n,u),this._isActingAsSymbolSource=new l.WatchedValue(!1),this._symbolHibernated=new l.WatchedValue(!1),this._symbolResolvingActive=new l.WatchedValue(!1),this._realignToolsLastParams=null,this._lastResolvedSymbolSource="",this._onIsActingAsSymbolSourceChanged=()=>{this._recreatePriceFormattingDependencies(),this._realignLineToolsIfParamsChanged()},this._recalculateIsActingAsSymbolSource(),this._isActingAsSymbolSource.subscribe(this._onIsActingAsSymbolSourceChanged);const a=this.properties().childs().inputs.childs().symbol;this._previousSymbolInputValue=a.value(),this._symbolInfoWV=(0,r.createWVFromGetterAndSubscriptions)((()=>this.symbolInfo()),[this.symbolResolved(),this.onStatusChanged()]),this._symbolSourceWV=(0,m.combine)((s=>s?this:super.symbolSource()),this._isActingAsSymbolSource.weakReference())}destroy(){this._symbolInfoWV.destroy(),this._symbolSourceWV.destroy(),super.destroy()}isActingAsSymbolSource(){return this._isActingAsSymbolSource.readonly()}properties(){return this._properties}symbol(){return this._isActingAsSymbolSource.value()?this.properties().childs().inputs.childs().symbol.value():this.symbolSource().symbol()}symbolOrAlias(){return this.symbol()}symbolChanged(){return this._isActingAsSymbolSource.value()?this.properties().childs().inputs.childs().symbol:this.symbolSource().symbolChanged()}onSymbolIntervalChanged(){return this.symbolChanged()}interval(){return this.model().mainSeries().interval()}style(){return this._firstSourceOrSeries().symbolSource().style()}currency(){return this._isActingAsSymbolSource.value()?this.properties().childs().currencyId.value()||null:this.symbolSource().currency()}unit(){return this._isActingAsSymbolSource.value()?this.properties().childs().unitId.value()||null:this.symbolSource().unit()}symbolParams(){return(0,a.symbolParams)(this)}compareSymbolParams(s){return(0,a.compareSymbolParams)(this,s,this._model.unitConversionEnabled())}async setSymbolParams(s){this._setSymbolParamsInternal(s)}setSymbol(s){this.setSymbolParams({symbol:s})}symbolInfo(){if(!this._isActingAsSymbolSource.value())return super.symbolSource().symbolInfo();const s=this._getSymbolForResolve(this.symbol());return this._resolvedSymbols[s]??null}symbolInfoWV(){return this._symbolInfoWV.readonly()}aliasSymbolInfo(){return this.symbolInfo()}symbolSource(){return this._isActingAsSymbolSource.value()?this:super.symbolSource()}symbolSourceWV(){return this._symbolSourceWV}symbolResolved(){return this.symbolsResolved()}symbolResolvingActive(){return this._symbolResolvingActive}
symbolHibernated(){return this._symbolHibernated}isVisible(){const s=super.isVisible();return this._symbolHibernated.setValue(!s),s}symbolSameAsCurrent(s){return(0,a.symbolSameAsCurrent)(s,this.symbolInfo())}symbolSameAsResolved(s){return(0,y.symbolSameAsResolved)(s,this._lastResolvedSymbolSource,this.symbol())}setCurrency(s){this.setSymbolParams({currency:s})}isConvertedToOtherCurrency(){return(0,i.isConvertedToOtherCurrency)(this.symbolInfo())}setUnit(s){this.setSymbolParams({unit:s})}isConvertedToOtherUnit(){return(0,i.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}setInterval(s){}setStyle(s){}symbolTitle(s,e,t){return this.title(s,!0,{},!1,e)}measureUnitId(){return(0,i.measureUnitId)(this.symbolInfo())}bars(){return super.data()}dataUpdated(){return this._dataUpdated}_onPropertiesChanged(){this._recalculateIsActingAsSymbolSource(),super._onPropertiesChanged(),this._realignLineToolsIfParamsChanged()}async _tryChangeInputs(){const s=this._resolvedSymbolsByInput[this.symbol()]||null;(0,a.symbolSameAsCurrent)(this._previousSymbolInputValue,s)||this._setSymbolParamsInternal({currency:null,unit:null}),await super._tryChangeInputs(),this._formatter=null,this._defaultFormatter=null,this.priceScale()?.updateFormatter(),this._previousSymbolInputValue=this.properties().childs().inputs.childs().symbol.value()}_getSymbolObject(s){const e={symbol:s},t=this.currency();null!==t&&(e["currency-id"]=t);const r=this.unit();return this._model.unitConversionEnabled()&&null!==r&&(e["unit-id"]=r),e}_onSymbolResolved(s,e,t){super._onSymbolResolved(s,e,t),this._recreatePriceFormattingDependencies();const r=e===this.symbol()?(0,n.extractSymbolNameFromSymbolInfo)(t,this.symbol()):null;null!==r&&(this._previousSymbolInputValue=r);const l=(0,i.symbolCurrency)(t),o=(0,i.symbolUnit)(t,this._model.unitConversionEnabled());this._setSymbolParamsInternal({symbol:r??void 0,currency:l,unit:o},t),this._symbolResolvingActive.setValue(!1)}_onSymbolResolvingStart(s,e){this._lastResolvedSymbolSource=e,super._onSymbolResolvingStart(s,e),this._symbolResolvingActive.setValue(!0)}_onSymbolError(){super._onSymbolError(),this._symbolResolvingActive.setValue(!1)}_onCurrencyMayChange(){this.isActingAsSymbolSource()?super._onCurrencyMayChange():this._onCurrencyChanged()}_recalculateIsActingAsSymbolSource(){const s=""!==this._currencySourceSymbolInputProperty?.value()??!1;this._isActingAsSymbolSource.setValue(s)}_setSymbolParamsInternal(s,e){const{symbol:t,currency:r,unit:l}=s,o=this.properties().childs(),n=o.inputs.childs().symbol.value(),u=o.currencyId.value(),a=o.unitId.value();if(void 0!==t&&o.inputs.childs().symbol.setValueSilently(t),void 0!==r&&o.currencyId.setValueSilently(r),void 0!==l&&o.unitId.setValueSilently(l),e)this._resolvedSymbolsByInput[this.symbol()]=e,this._resolvedSymbols[this._getSymbolForResolve(this.symbol())]=e,this._realignToolsLastParams=null;else{const s=this.symbolInfo();null!==s&&(o.currencyId.setValueSilently((0,i.symbolCurrency)(s)),o.unitId.setValueSilently((0,
i.symbolUnit)(s,this._model.unitConversionEnabled())))}o.inputs.childs().symbol.value()!==n&&o.inputs.childs().symbol.fireChanged(),o.currencyId.value()!==u&&o.currencyId.fireChanged(),o.unitId.value()!==a&&o.unitId.fireChanged(),this._realignLineToolsIfParamsChanged()}_realignLineToolsIfParamsChanged(){let s=null===this._realignToolsLastParams;if(null!==this._realignToolsLastParams){const e=this.compareSymbolParams(this._realignToolsLastParams);s=e.symbolChanged||e.intervalChanged||e.currencyChanged||e.unitChanged}s&&(this._model.realignLineTools(this),this._realignToolsLastParams=this.symbolParams())}}}}]);