/*! For license information please see streamer.3e58029f08028243887d.mjs.LICENSE.txt */ (()=>{var e={8277:(e,t,r)=>{"use strict";r.r(t);var s=r(3379),i=r.n(s),n=r(9037),o=r.n(n),a=r(569),c=r.n(a),l=r(3565),u=r.n(l),h=r(9216),f=r.n(h),b=r(1603),d={};d.setAttributes=u(),d.insert=c().bind(null,"head"),d.domAPI=o(),d.insertStyleElement=f(),i()(b.Z,d);const m=b.Z&&b.Z.locals?b.Z.locals:void 0;var p=r(4149),g=r.n(p);function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(this.isIntersecting=e,e&&!this.subscribed){const e=this.getAttribute(w),t=this.getAttribute(S);this.value=parseFloat(this.getAttribute(P)||this.getAttribute(C)||""),t&&e&&(this.subscribe({symbols:[t],fields:[e]}),this.subscribed=!0)}},(t="symbol"==typeof(s=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t="onView"))?s:String(s))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,this.initialized=!1,this.subscribed=!1,this.isIntersecting=!1,this.cssToggle=!1,this.value=void 0,this.transform=null,this.onUpdate=this.onUpdate.bind(this)}static get observedAttributes(){return[S,w,T]}onUpdate(e,{field:t,quote:r}={}){if(!e&&"number"!=typeof e)return;if(null!=r&&r.symbol&&r.symbol!==this.getAttribute(S))return;const s="object"!=typeof e?{raw:e,fmt:e}:e,{raw:i}=s;if(this.value!==i){const e=this.getAttribute("changeev");e&&this.dispatchEvent(new CustomEvent(`finWebCore_${e}`,{detail:y({},s,{field:t,quote:r}),bubbles:!0})),this.cssToggle=!this.cssToggle;const n=i-this.value;this.value=i,this.render(y({},s,{trend:n}))}}subscribe({symbols:e,fields:t}){var r;e&&t&&e.length&&t.length&&this.hasAttribute(T)&&"function"==typeof(null==(r=window.finQuoteStreamer)?void 0:r.subscribe)&&window.finQuoteStreamer.subscribe({symbols:e,fields:t,userId:this.getAttribute("data-userid")||"",type:this.getAttribute(M)||v,priceHint:this.getAttribute("data-pricehint"),formatStyle:this.getAttribute("data-fstyle"),callback:this.onUpdate})}unsubscribe({symbols:e,fields:t}){var r;e&&t&&e.length&&t.length&&"function"==typeof(null==(r=window.finQuoteStreamer)?void 0:r.unsubscribe)&&window.finQuoteStreamer.unsubscribe({symbols:e,fields:t,type:this.getAttribute(M)||v,callback:this.onUpdate})}connectedCallback(){var e;this.initialized||(null==(e=window.finQuoteStreamer)||e.observe(this,{cb:this.onView}),this.initialized=!0)}disconnectedCallback(){var e;const t=this.getAttribute(w),r=this.getAttribute(S);r&&t&&this.unsubscribe({symbols:[r],fields:[t]}),null==(e=window.finQuoteStreamer)||e.unobserve(this),this.initialized=!1,this.isIntersecting=!1,this.subscribed=!1}attributeChangedCallback(e,t,r){if(this.initialized)switch(e){case S:t!==r&&r&&(this.unsubscribe({symbols:[t],fields:[this.getAttribute(w)]}),this.subscribe({symbols:[r],fields:[this.getAttribute(w)]}));break;case w:t!==r&&r&&(this.unsubscribe({symbols:[this.getAttribute(S)],fields:[t]}),this.subscribe({symbols:[this.getAttribute(S)],fields:[r]}));break;case T:{const e=null!==t,s=null!==r;e&&!s?this.unsubscribe({symbols:[this.getAttribute(S)],fields:[this.getAttribute(w)]}):!e&&s&&this.subscribe({symbols:[this.getAttribute(S)],fields:[this.getAttribute(w)]})}break;case C:case P:if(this.hasAttribute(P)&&e===C)break;this.value=parseFloat(r)}}render(e){if(!this.isIntersecting)return;"function"==typeof this.transform&&(e=this.transform(e));const{raw:t,trend:r}=e,s=this.getAttribute("data-trend")||k,i=this.getAttribute("data-template"),n=this.getAttribute("data-dfield")||"fmt";let o=m.base,a="";if(t>0)switch(s){case"bg":o+=` ${m.posBgColor}`,a="+";break;case k:o+=` ${m.posColor}`,a="+"}else if(t<0)switch(s){case"bg":o+=` ${m.negBgColor}`;break;case k:o+=` ${m.negColor}`}r>0?o+=` ${this.cssToggle?m.trendUp1:m.trendUp2}`:r<0&&(o+=` ${this.cssToggle?m.trendDown1:m.trendDown2}`);let c=a+(e[n]||"");i&&(c=function(e,t){let r=e,s=!1;return Object.keys(t).forEach((e=>{t[e]&&(s=!0),r=r.replace(new RegExp(`{${e}}`,"g"),t[e])})),s?r:""}(i,{raw:t,fmt:c})),this.children[0]?g().mutate((()=>{this.children[0].className=o,this.children[0].textContent=c})):this.innerHTML=`${c}`}}window.customElements&&!window.customElements.get("fin-streamer")&&window.customElements.define("fin-streamer",x)},1603:(e,t,r)=>{"use strict";r.d(t,{Z:()=>a});var s=r(8081),i=r.n(s),n=r(3645),o=r.n(n)()(i());o.push([e.id,':root{--finc-text1:var(--text1,#232a31);--finc-text2:var(--text2,#464e56);--finc-text3:var(--text3,#5b636a);--finc-separator:var(--separator,#e0e4e9);--finc-link:var(--link,#0f69ff);--finc-link-active:var(--link-active,#125bd4);--finc-link-selected:var(--link-selected,#7e1fff);--finc-link-inverse:var(--link-inverse,#e0f0ff);--finc-surface1:var(--surface1,#fff) #fff;--finc-surface2:var(--surface2,#f0f3f5);--finc-surface3:var(--surface3,#fff);--finc-surface4:var(--surface4,#fff);--finc-positive:var(--positive,#037b4b);--finc-negative:var(--negative,#d60a22);--finc-neutral:var(--neutral,#5b636a);--finc-positive-bg:var(--positive-bg,rgba(0,133,60,.102));--finc-negative-bg:var(--negative-bg,rgba(189,20,20,.102))}.a405bf5d{color:blue}.e3b14781{contain:strict;position:relative;white-space:nowrap;z-index:0}.e3b14781:after,.e3b14781:before,.a7c78a61{content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;width:100%;z-index:-1}.e3b14781:after,.e3b14781:before{pointer-events:none;will-change:opacity}.e3b14781:before{background-color:rgba(0,133,60,.102);background-color:var(--finc-positive-bg)}.e3b14781:after{background-color:rgba(189,20,20,.102);background-color:var(--finc-negative-bg)}.f4be3290{color:#037b4b;color:var(--finc-positive)}.ee3e99dd{color:#d60a22;color:var(--finc-negative)}.b3c3f2ca{background-color:#037b4b;background-color:var(--finc-positive)}.cd7d43ff,.b3c3f2ca{border-radius:3px;color:#fff;padding:2px 10px}.cd7d43ff{background-color:#d60a22;background-color:var(--finc-negative)}.a6c2a027{font-size:0.75rem}.f5193b25{font-size:0.875rem;font-weight:700}.bf673e9a{font-weight:500;margin-left:4px}@keyframes ed961825{25%{opacity:1}75%{opacity:1}to{opacity:0}}@keyframes de628db8{25%{opacity:1}75%{opacity:1}to{opacity:0}}@keyframes e816a496{25%{opacity:1}75%{opacity:1}to{opacity:0}}@keyframes f90c4216{25%{opacity:1}75%{opacity:1}to{opacity:0}}.e887be10{background-color:rgba(0,133,60,.102);background-color:var(--finc-positive-bg)}.b0e44130{background-color:rgba(189,20,20,.102);background-color:var(--finc-negative-bg)}.f5a023e1:before{animation:ed961825 .7s}.e983cf79:before{animation:de628db8 .7s}.e59c8479:after{animation:e816a496 .7s}.dde7f18a:after{animation:f90c4216 .7s}',""]),o.locals={activeMarketColor:"#ff7b12","c-fuji-blurple":"#5d5eff","c-fuji-grape-jelly":"#6001d2",boxShadow:"0 2px 4px rgba(0,0,0,.2)",overlayModalBgColor:"rgba(50,50,50,0.6)",newsItemWidth:"calc(100% - 50px)",xs:"0.688rem",xss:"0.75rem",s:"0.813rem",sm:"0.875rem",m:"0.938rem",ml:"1rem",l:"1.125rem",dummy:"a405bf5d",base:"e3b14781",baseCommon:"a7c78a61",posColor:"f4be3290",negColor:"ee3e99dd",posBgColor:"b3c3f2ca",negBgColor:"cd7d43ff",marketNotice:"a6c2a027",prepostCont:"f5193b25",prepostChange:"bf673e9a",trendUp:"e887be10",trendDown:"b0e44130",trendUp1:"f5a023e1",trendAnimUp1:"ed961825",trendUp2:"e983cf79",trendAnimUp2:"de628db8",trendDown1:"e59c8479",trendAnimDown1:"e816a496",trendDown2:"dde7f18a",trendAnimDown2:"f90c4216"};const a=o},3645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r="",s=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),s&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),s&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r})).join("")},t.i=function(e,r,s,i,n){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(s)for(var a=0;a0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=n),r&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=r):u[2]=r),i&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=i):u[4]="".concat(i)),t.push(u))}},t}},8081:e=>{"use strict";e.exports=function(e){return e[1]}},4149:function(e,t,r){var s;!function(t){"use strict";var i=function(){},n=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.msRequestAnimationFrame||function(e){return setTimeout(e,16)};function o(){var e=this;e.reads=[],e.writes=[],e.raf=n.bind(t),i("initialized",e)}function a(e){e.scheduled||(e.scheduled=!0,e.raf(c.bind(null,e)),i("flush scheduled"))}function c(e){i("flush");var t,r=e.writes,s=e.reads;try{i("flushing reads",s.length),e.runTasks(s),i("flushing writes",r.length),e.runTasks(r)}catch(e){t=e}if(e.scheduled=!1,(s.length||r.length)&&a(e),t){if(i("task errored",t.message),!e.catch)throw t;e.catch(t)}}function l(e,t){var r=e.indexOf(t);return!!~r&&!!e.splice(r,1)}o.prototype={constructor:o,runTasks:function(e){var t;for(i("run tasks");t=e.shift();)t()},measure:function(e,t){i("measure");var r=t?e.bind(t):e;return this.reads.push(r),a(this),r},mutate:function(e,t){i("mutate");var r=t?e.bind(t):e;return this.writes.push(r),a(this),r},clear:function(e){return i("clear",e),l(this.reads,e)||l(this.writes,e)},extend:function(e){if(i("extend",e),"object"!=typeof e)throw new Error("expected object");var t=Object.create(this);return function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])}(t,e),t.fastdom=this,t.initialize&&t.initialize(),t},catch:null};var u=t.fastdom=t.fastdom||new o;void 0===(s=function(){return u}.call(u,r,u,e))||(e.exports=s)}("undefined"!=typeof window?window:this)},3379:e=>{"use strict";var t=[];function r(e){for(var r=-1,s=0;s{"use strict";var t={};e.exports=function(e,r){var s=function(e){if(void 0===t[e]){var r=document.querySelector(e);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}t[e]=r}return t[e]}(e);if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(r)}},9216:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},3565:(e,t,r)=>{"use strict";e.exports=function(e){var t=r.nc;t&&e.setAttribute("nonce",t)}},9037:e=>{"use strict";var t,r=(t=[],function(e,r){return t[e]=r,t.filter(Boolean).join("\n")});function s(e,t,s,i){var n;if(s)n="";else{n="",i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}")}if(e.styleSheet)e.styleSheet.cssText=r(t,n);else{var a=document.createTextNode(n),c=e.childNodes;c[t]&&e.removeChild(c[t]),c.length?e.insertBefore(a,c[t]):e.appendChild(a)}}var i={singleton:null,singletonCounter:0};e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=i.singletonCounter++,r=i.singleton||(i.singleton=e.insertStyleElement(e));return{update:function(e){s(r,t,!1,e)},remove:function(e){s(r,t,!0,e)}}}},477:e=>{"use strict";e.exports=function(e,t,r,s){var i=self||window;try{try{var n;try{n=new i.Blob([e])}catch(t){(n=new(i.BlobBuilder||i.WebKitBlobBuilder||i.MozBlobBuilder||i.MSBlobBuilder)).append(e),n=n.getBlob()}var o=i.URL||i.webkitURL,a=o.createObjectURL(n),c=new i[t](a,r);return o.revokeObjectURL(a),c}catch(s){return new i[t]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch(e){if(!s)throw Error("Inline worker is not supported");return new i[t](s,r)}}}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var n=t[s]={id:s,exports:{}};return e[s].call(n.exports,n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.p="https://s.yimg.com/uc/finance/webcore/",r.nc=void 0,(()=>{"use strict";var e=r(477),t=r.n(e);function s(){return t()('/*! For license information please see portfolio.worker.a333421d7870ffcf5aed.worker.mjs.LICENSE.txt */\n(()=>{"use strict";function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e{clearTimeout(a),a=setTimeout((()=>t(...r)),e)}}class n{constructor({enableStreaming:n=!0,messagePort:o,streamerPort:l}={messagePort:null,streamerPort:null}){var c=this;e(this,"getCurrentMarketValue",(({quantity:t,price:e,exchangeRate:a=1})=>t&&e?t*e/a:0)),e(this,"getDailyGain",(({quantity:t,change:e,exchangeRate:a=1})=>t&&e?t*e/a:0)),e(this,"getTotalGain",(({quantity:t,purchasePrice:e,price:a,exchangeRate:r=1})=>t&&e&&a?t*(a-e)/r:0)),e(this,"getTotalPercentGain",(({totalGain:t,marketValue:e})=>{const a=Math.abs(e-t);return 0===a?100*t:t?100*t/a:0})),e(this,"getDailyPercentGain",(({dailyGain:t,marketValue:e})=>{const a=Math.abs(e-t);return 0===a?100*t:t?100*t/a:0})),e(this,"getPurchasedMarketValue",(({purchasePrice:t,quantity:e,exchangeRate:a=1})=>Math.abs(e)*t/a)),e(this,"getAnnualGain",((t,e,a,r)=>{if(!t)return 0;let s;if(a)s=new Date(+a.slice(0,4),+a.slice(4,6)-1,+a.slice(6,8)).getTime();else{const t=new Date;t.setHours(0,0,0,0),t.setMonth(0,1),s=t.getTime()}return(e/t)**(365/((r-s)/864e5|0))-1})),e(this,"getExchangeRateSymbol",((t,e)=>`${"USD"===e?"":e}${t}=X`)),e(this,"getExchangeRate",((t,e,a)=>{let r=1;if(t!==e){var s;const i=this.getExchangeRateSymbol(t,e);null!=(s=a[i])&&s.regularMarketPrice&&(r=a[i].regularMarketPrice,"GBp"===t&&(r*=100))}return r})),e(this,"getSymbolExchangeRate",((t,e,a)=>{const r=a[e];return this.getExchangeRate(r.currency,t,a)})),e(this,"getSubscriptionSymbols",(()=>{const t=[],e=[],{quotes:a}=this.portfolios,r=this.portfolios.baseCurrency||"USD",s=Object.keys(this.portfolios.portfolios);for(let n=0;n0&&a[i]){const{currency:r}=a[i];r&&r!==c&&(e.push(this.getExchangeRateSymbol(c,r)),e.push(this.getExchangeRateSymbol(r,c))),t.push(i)}}"number"==typeof u&&h!==c&&(e.push(this.getExchangeRateSymbol(c,h)),e.push(this.getExchangeRateSymbol(h,c))),c!==r&&(e.push(this.getExchangeRateSymbol(r,c)),e.push(this.getExchangeRateSymbol(c,r)))}return[...new Set(t.concat(e))]})),e(this,"getPortfolioQuotes",(()=>{const t={all:{price:{priceHint:2}}},e=new Set(this.symbolList.map((t=>t.split(":")[0]))),a=Object.keys(this.portfolios.portfolios);for(let r=0;r{o&&(t[i].price[e]=n[e]||0)}))}return s.forEach((e=>{t.all.price[e]=this.portfolios[e]||0})),t})),e(this,"computePortfolios",(t=>{const e={currentMarketValue:0,purchasedMarketValue:0,totalGain:0,dailyGain:0,totalPercentGain:0,dailyPercentGain:0,annualGainPercentage:0},{baseCurrency:a="USD"}=this.portfolios,i=Object.keys(this.portfolios.portfolios);for(let s=0;s{e[t]+="number"==typeof o[t]?o[t]/l:0}))}e.dailyPercentGain=this.getDailyPercentGain({dailyGain:e.dailyGain,marketValue:e.currentMarketValue}),e.totalPercentGain=this.getTotalPercentGain({marketValue:e.currentMarketValue,totalGain:e.totalGain}),s.forEach((t=>{this.portfolios[t]=e[t]}))})),e(this,"computePortfolio",((e,a)=>{if(!e||!e.includeInTotalCalculation)return;const{positions:i=[],baseCurrency:n="USD",pfId:o}=null!=e?e:{},l={currentMarketValue:0,purchasedMarketValue:0,totalGain:0,dailyGain:0,totalPercentGain:0,dailyPercentGain:0};if("number"==typeof e.cashPosition){const t=this.getExchangeRate(e.cashCurrency,n,a);l.currentMarketValue+=e.cashPosition/t}for(let e=0;e0){const s=f?this.getSymbolExchangeRate(n,c,a):1,l=Date.now();for(let a=0;a{h[t]+="number"==typeof o[a][t]?o[a][t]:0}))}}r.forEach((t=>{i[e][t]=h[t],l[t]+="number"==typeof i[e][t]?i[e][t]:0})),i[e].dailyPercentGain=this.getDailyPercentGain({dailyGain:i[e].dailyGain,marketValue:i[e].currentMarketValue}),i[e].totalPercentGain=this.getTotalPercentGain({totalGain:i[e].totalGain,marketValue:i[e].currentMarketValue})}l.dailyPercentGain=this.getDailyPercentGain({dailyGain:l.dailyGain,marketValue:l.currentMarketValue}),l.totalPercentGain=this.getTotalPercentGain({totalGain:l.totalGain,marketValue:l.currentMarketValue}),s.forEach((t=>{this.portfolios.portfolios[o][t]=l[t]}))})),e(this,"onStreamerMessage",i((e=>{var a;const{data:r}=e,{quoteData:s}=r||{};s&&0!==this.symbolList.length&&null!=(a=this.portfolios)&&a.portfolios&&this.enableStreaming&&(this.portfolios.quotes=t({},this.portfolios.quotes,s),this.computePortfolios(this.portfolios.quotes),this.sendUpdate())}),500)),e(this,"sendUpdate",(()=>{if(this._recentlyPolled)return;const t=this.getPortfolioQuotes();this.messagePort.postMessage({quoteData:t})})),e(this,"parsePfResponse",(e=>{const[a]=e.finance.result,r={},{portfolios:i}=a;for(let t=0;t{"number"==typeof this.portfolios[`${t}WithBeta`]&&(this.portfolios[t]=this.portfolios[`${t}WithBeta`])}))})),e(this,"resetPolling",(()=>{this.intervalHandle&&(clearInterval(this.intervalHandle),this.intervalHandle=null),this._fetching=!1})),e(this,"fetchPortfolios",(async function({crumb:t="",userId:e="",shouldSendUpdate:r=!0}={}){if(c._fetching)return;c._fetching=!0;const s=c.crumb||t||"",i=c.userId||e||"";try{const t=await function(t,{method:e="GET",body:a,timeout:r=1e4}={}){return new Promise(((s,i)=>{const n=new XMLHttpRequest;n.open(e,t,!0),n.timeout=r,n.withCredentials=!0,n.onload=()=>{let t=n.responseText;if(n.status>=200&&n.status<300&&t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){return void i({status:502,message:t.message})}s(t)}else i({status:n.status||502,message:n.responseText})},n.onerror=()=>{i({status:n.status||500,message:n.responseText})},n.send(a)}))}(`https://query2.finance.yahoo.com/v7/finance/desktop/portfolio?formatted=false&fields=${a.join(",")}&crumb=${s}&userId=${i}&includeBetaVersion=1&lotCount=10&userIdType=guid`);c._fetching=!1,c.parsePfResponse(t),c.messagePort.postMessage({cmd:"subscribe",symbols:c.getSubscriptionSymbols()}),r&&(c.sendUpdate(),c._recentlyPolled=!0,setTimeout((()=>{c._recentlyPolled=!1}),500))}catch(t){c._fetching=!1,console.error("> finance portfolio.streamer:",t)}})),e(this,"loadPortfolios",i((async function({crumb:t="",userId:e=""}={}){c.fetchPortfolios({crumb:t,shouldSendUpdate:!1,userId:e}),c.resetPolling(),c.intervalHandle||(c.intervalHandle=setInterval((()=>{c.fetchPortfolios({crumb:t,userId:e})}),c.enableStreaming?3e4:15e3))}),1e3)),e(this,"subscribe",(async function({crumb:t="",userId:e="",symbols:a=[],fields:r=[]}={}){const s=new Set(a),i=c.symbolList.length>0?c.symbolList.filter((t=>!s.has(t))):[...s];0!==i.length&&(c.update({crumb:t,symbols:a,fields:r,userId:e}),i.length>0&&await c.loadPortfolios({crumb:t,userId:e}))})),e(this,"unsubscribe",(({crumb:t="",fields:e=[],symbols:a=[]}={})=>{if(!this.symbolList.length)return;const r=new Set(a),s=this.symbolList.filter((t=>!r.has(t)));this.update({crumb:t,symbols:a,fields:e,userId:""}),s.length>0&&this.messagePort.postMessage({cmd:"unsubscribe",type:"streamer",symbols:this.getSubscriptionSymbols()}),0===this.symbolList.length&&this.resetPolling()})),e(this,"destroy",(()=>{this.portfolios={portfolios:{},quotes:{}},this.symbolList=[],this.fieldList=[],this.userId="",this.crumb=""})),e(this,"update",(({crumb:t,symbols:e,fields:a,userId:r})=>{this.crumb=t||"",this.symbolList=e,this.fieldList=a,r&&(this.userId=r)})),this.portfolios={portfolios:{},quotes:{}},this.messagePort=o,this.enableStreaming=n,this.streamerPort=l,this.symbolList=[],this.fieldList=[],this.crumb="",this.userId="",this.intervalHandle=null,this._fetching=!1,this._recentlyPolled=!1}}let o=null,l=null,c=!0,u=null;function h(t){const{data:e}=t;switch(e.cmd){case"subscribe":u||(u=new n({messagePort:o,enableStreaming:c,streamerPort:l})),u.subscribe(e);break;case"unsubscribe":u.unsubscribe(e);break;case"destroy":u&&(u.destroy(),u=null)}}addEventListener("message",(t=>{const{data:e}=t;switch(e.cmd){case"init":[o]=t.ports,c=e.enableStreaming,o.onmessage=h;break;case"init-qpf":[l]=t.ports,l.onmessage=t=>{u&&u.onStreamerMessage.call(u,t)}}}),!1)})();',"Worker",void 0,r.p+"js/portfolio.worker.a333421d7870ffcf5aed.worker.mjs")}function i(){return t()('/*! For license information please see streamer.worker.aab38e33775cc0bf0abb.worker.mjs.LICENSE.txt */\n(()=>{function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t Finance Streamer: Importing protobuff failed.",e)}const s="https://query1.finance.yahoo.com/v7/finance/quote?";let r=null,n=null,i=null,o=null;const a={id:"symbol",dayVolume:"volume",dayHigh:"high",dayLow:"low",marketcap:"marketCap",marketHours:"marketState",openPrice:"regularMarketOpen",fromcurrency:"fromCurrency",vol_24hr:"volume24Hr",volAllCurrencies:"volumeAllCurrencies"},c={ask:!0,askSize:!0,bid:!0,bidSize:!0,dayLow:!0,dayHigh:!0,expireDate:!0},l={},u={change:!0,changePercent:!0,previousClose:!0,price:!0},h={_permanent:!0};function m(e,t){let s;return(...r)=>{clearTimeout(s),s=setTimeout((()=>e(...r)),t)}}function d(e,t){if(isNaN(e))return e;const s=Math.pow(10,t);return+Math.round(e*s)/s}function b(e){const t={},s={},{marketHours:r}=e,n=e.priceHint||2;let i,o="";switch(r){case"PRE_MARKET":o="preMarket",i="PRE";break;case"REGULAR_MARKET":o="regularMarket",i="REGULAR";break;case"POST_MARKET":o="postMarket",i="POST";break;case"EXTENDED_HOURS_MARKET":o="extendedMarket",i="EXTENDED"}for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const h=a[r]||r;let m=e[r];if(null==m||""===m)continue;let b=h;switch(h){case"previousClose":case"price":case"time":case"dayHigh":case"dayLow":case"volume":case"changePercent":case"change":u[h]&&!isNaN(m)&&(m=d(m,n)),"time"===h&&(m/=1e3),b=o+h[0].toUpperCase()+h.substr(1);break;case"marketState":m=i}c[b]?(s[b]=m,b!==h&&(s[h]=m)):l[b]||(t[b]=m,b!==h&&(t[h]=m))}return{price:t,summaryDetail:s}}function f(e,{timeout:t=1e3,callback:s}){const r=new XMLHttpRequest;r.timeout=t,r.withCredentials=!0,r.open("GET",e,!0),r.onload=()=>{let e=r.responseText;if(r.status>=200&&r.status<300&&e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return void s({status:502,message:e.message})}s(null,e)}else s({status:r.status||502,message:r.responseText})},r.onerror=()=>{s({status:r.status||500,message:r.responseText})},r.send()}class p{constructor(){this.crumb="",this.symbolList=[],this.fieldList=[],this.connection=null}update({crumb:e,symbols:t,fields:s}){this.crumb=e||"",this.symbolList=t,this.fieldList=s}reset(){this.fieldList=[],this.symbolList=[]}}class y extends p{constructor(){super(),this.intervalHandle=null,this.handleQuoteRequest=this.handleQuoteRequest.bind(this),this.subscribe=m(this.subscribe.bind(this),1e3)}resetPoller(){this.intervalHandle&&clearInterval(this.intervalHandle),this.intervalHandle=setInterval((()=>{f(`${s}&symbols=${this.symbolList.sort().join(",")}&fields=${this.fieldList.filter((e=>!h[e])).join(",")}&crumb=${this.crumb||""}`,{callback:this.handleQuoteRequest})}),5e3)}subscribe(e){const{crumb:t,symbols:s=[],fields:r=[]}=e||{},n=s.length>this.symbolList.length,i=r.length>this.fieldList.length;this.update({crumb:t,symbols:s,fields:r}),(n||i)&&this.resetPoller()}unsubscribe(e){const{crumb:t,symbols:s=[],fields:r=[]}=e||{},n=s.length Error from Finance Quote Streamer:",e)}}const g=["currency","fromCurrency","toCurrency","exchangeTimezoneName","exchangeTimezoneShortName","gmtOffSetMilliseconds","regularMarketChange","regularMarketChangePercent","regularMarketPrice","regularMarketTime","preMarketTime","postMarketTime","extendedMarketTime"];class v extends p{constructor(){super(),t(this,"handleWebSocketUpdate",(t=>{try{const{PricingData:r}=protobuf.roots.default.quotefeeder,n=function(e){const t=atob(e),s=t.length,r=new Uint8Array(s);for(let e=0;e Error from Finance Quote Streamer:",e)}})),t(this,"handleQuoteRequest",((t,s)=>{if(!t&&s){var r;const t=null==(r=s.quoteResponse)?void 0:r.result;if(!t)return;for(let s=0;s Error from Finance Quote Streamer:",t)})),this.connection=null,this.retries=0,this.quoteData={},this.sendConnection=m(this.sendConnection.bind(this),1e3)}seedQuoteData(){const e=this.symbolList.filter((e=>{var t;return!(null!=(t=this.quoteData[e])&&t.exchangeTimezoneName)}));if(e.length>0&&this.crumb){e.sort();const r=[[]];let n=0;for(let s=0;s{f(`${s}&symbols=${e.join(",")}&fields=${g.join(",")}&crumb=${this.crumb||""}&formatted=false®ion=US&lang=en-US`,{callback:this.handleQuoteRequest})}))}}subscribe(e){var t,s;const{crumb:r,symbols:n=[],fields:i=[]}=e||{};if(this.update({crumb:r,symbols:n,fields:i}),!this.connection||(null==(t=this.connection)?void 0:t.readyState)!==WebSocket.OPEN&&(null==(s=this.connection)?void 0:s.readyState)!==WebSocket.CONNECTING){const e=()=>{this.retries>10||(this.connection=new WebSocket("wss://streamer.finance.yahoo.com"),this.connection.addEventListener("open",(()=>{this.sendConnection(JSON.stringify({subscribe:this.symbolList}))})),this.connection.addEventListener("error",(t=>{t&&"ECONNREFUSED"===t.code&&(this.retries++,e())})),this.connection.addEventListener("close",(t=>{t&&1e3!==t.code&&(this.retries++,e())})),this.connection.addEventListener("message",this.handleWebSocketUpdate))};e()}else this.connection.readyState===WebSocket.OPEN&&this.symbolList.length>0&&this.sendConnection(JSON.stringify({subscribe:this.symbolList}))}unsubscribe(e){var t;const{crumb:s,symbols:r=[],fields:n=[]}=e||{},i=new Set(r),o=this.symbolList.filter((e=>!i.has(e)));this.update({crumb:s,symbols:r,fields:n}),(null==(t=this.connection)?void 0:t.readyState)===WebSocket.OPEN&&o.length>0&&this.sendConnection(JSON.stringify({unsubscribe:o}))}destroy(){this.reset(),this.connection&&(this.connection.close(),this.connection=null)}sendConnection(e){this.connection.send(e),e.includes("subscribe")&&this.seedQuoteData()}}function S(e="streamer"){return"poller"===e?(n||(n=new y),n):(r||(r=new v),r)}function k(e){const{data:t}=e,{type:s}=t||{};switch(t.cmd){case"subscribe":S(s).subscribe(t);break;case"unsubscribe":S(s).unsubscribe(t);break;case"destroy":"poller"===s&&n&&(n.destroy(),n=null),"streamer"===s&&r&&(r.destroy(),r=null)}}function E(){}protobuf||console.error("> Finance Streamer: Protobuff library missing so cannot use streamer"),addEventListener("message",(e=>{const{data:t}=e;switch(t.cmd){case"init":[i]=e.ports,i.onmessage=k;break;case"init-qpf":[o]=e.ports,o.onmessage=E,o.postMessage({cmd:"Hello Portfolio worker from streamer worker"})}}),!1)})();',"Worker",void 0,r.p+"js/streamer.worker.aab38e33775cc0bf0abb.worker.mjs")}function n(e="error",t,r={}){try{var s;if("function"==typeof(null==(s=window.context)?void 0:s.getActionContext)){const s=window.context.getActionContext();"function"==typeof s.beacon&&s.beacon(e,t,r)}else console["error"===e?"error":"log"](e,t,JSON.stringify(r))}catch(e){console.error(e)}}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const m=Date.now();function p(t={}){"object"==typeof t&&t&&(t.timestamp=m),n("info",u,{code:200,surl:e}),b(t)}function g(t={}){t.status=t.status||500,t.message=t.message||l,n("error",u,{code:t.status,msg:t.message,surl:e}),d(t)}h||void 0===window.fetch?function(e,{method:t="GET",withCredentials:r=!0,headers:s={},body:i,timeout:n=c,successCb:a,errorCb:l}){const u=new window.XMLHttpRequest;u.open(t,e,!0),u.timeout=n,u.withCredentials=r,u.onload=()=>{let e=u.responseText;if(u.status>=200&&u.status<300){if("string"==typeof e)try{e=""!==e?JSON.parse(e):{}}catch(e){return void l({status:502,message:e.message})}a(e)}else l({status:u.status||502,message:u.responseText})},u.onerror=()=>{l({status:u.status||500,message:u.responseText})};const h=o({},"GET"!==t?{"Content-Type":"application/json"}:{},s);Object.keys(h).forEach((e=>{u.setRequestHeader(e,h[e])})),u.send(i?JSON.stringify(i):void 0)}(e,{method:t,withCredentials:r,headers:s,body:i,timeout:a,successCb:p,errorCb:g}):function(e,{method:t="GET",withCredentials:r=!0,headers:s={},body:i,returnErrorInfo:n,timeout:a=c,successCb:l,errorCb:u}){const h=new window.AbortController;let f=!1;const b=setTimeout((function(){f=!0,h.abort(),clearTimeout(b),u({status:502,message:"Request Timeout"})}),a);window.fetch(e,{method:t,mode:"cors",credentials:r?"include":"omit",headers:o({},"GET"!==t?{"Content-Type":"application/json"}:{},s),signal:h.signal,body:i?JSON.stringify(i):null}).then((async e=>{if(!f){if(clearTimeout(b),!e.ok){let s;var t,r;throw n&&(s=null==(r=((null==(t=e.headers)||null==t.get||null==(t=t.get("content-type"))?void 0:t.includes("application/json"))?await e.json():{}).finance)?void 0:r.error),o({status:e.status||502,message:e.statusText},s&&{info:s})}return e.text()}})).then((e=>{let t=e;"application/json"===((null==s?void 0:s["Content-Type"])||"application/json")&&(t=""!==e?JSON.parse(e):{}),l(t)})).catch((e=>{f||u(o({status:e.status||502,message:e.message},e.info&&{info:e.info}))}))}(e,{method:t,withCredentials:r,headers:s,body:i,returnErrorInfo:f,timeout:a,successCb:p,errorCb:g})}))}(t.toString(),{errorMsg:"crumb fetch failed",headers:{"Content-Type":"text/plain"},timeout:1e3});return window.finWebCore.crumb=r,r}const u={};function h(e,t="en-US",r={}){const s=`${t}${e}`;return u[s]||(u[s]=Intl.NumberFormat(t,r)),u[s]}function f({field:e,value:t,lang:r="en-US",priceHint:s,gmtOffSetMilliseconds:i,timeZoneShort:n,formatStyle:o}){const a={raw:t};switch(e){case"regularMarketVolume":case"marketCap":{a.fmt=function(e,t=3){const r=Math.abs(e);return r>=1e12?`${(e/1e12).toFixed(t)}T`:r>=1e9?`${(e/1e9).toFixed(t)}B`:r>=1e6?`${(e/1e6).toFixed(t)}M`:r>=1e3?`${(e/1e3).toFixed(t)}k`:e.toFixed(0)}(t);const e=h("marketCap",r,{maximumFractionDigits:0});a.longFmt=e.format(t);break}case"dailyPercentGain":case"totalPercentGain":case"extendedMarketChangePercent":case"postMarketChangePercent":case"preMarketChangePercent":case"regularMarketChangePercent":{let e=t;isNaN(t)||(e=t/100);const i=s?{minimumFractionDigits:s,maximumFractionDigits:s}:{minimumFractionDigits:2,maximumFractionDigits:4};i.style="percent";const n=h(`regularMarketChangePercent${s}`,r,i);a.fmt=n.format(e);break}case"extendedMarketTime":case"preMarketTime":case"postMarketTime":case"regularMarketTime":a.fmt=n&&"number"==typeof i?function(e,t,r){let s="string"==typeof(i=t)?Number(i):"number"==typeof i?i:"object"==typeof i&&i instanceof Date?i.getTime():Date.now();var i;return void 0!==e.gmtOffSetMilliseconds&&("string"==typeof e.gmtOffSetMilliseconds&&(e.gmtOffSetMilliseconds=Number(e.gmtOffSetMilliseconds)),n=s,o=e.gmtOffSetMilliseconds,s=isNaN(o)?n:n+6e4*new Date(n).getTimezoneOffset()+o),function(e,t={}){const{useUTC:r=!1,fmt:s="%I:%M%P",timeZoneShort:i=""}=t;let n="",o="",a="",c="",l=0,u=0,h="";for(;-1!==(u=s.indexOf("%",u));){switch(l!==u&&(c+=s.substring(l,u)),u+=1,h=s[u],h){case"l":case"I":o||(o=r?e.getUTCHours():e.getHours(),o<12?(o=0===o?"12":String(o),n="am"):(o>12&&(o-=12),o=String(o),n="pm")),"I"===h&&1===o.length?c+=`0${o}`:c+=o;break;case"M":a||(a=String(r?e.getUTCMinutes():e.getMinutes()),1===a.length&&(a=`0${a}`)),c+=a;break;case"p":case"P":n||(n=(r?e.getUTCHours():e.getHours())<12?"am":"pm"),c+="p"===h?"am"===n?"AM":"PM":n;break;case"Z":c+=i;break;case"%":c+="%";break;case"Y":c+=e.getFullYear();break;case"m":c+=`0${e.getMonth()+1}`.slice(-2);break;case"d":c+=`0${e.getDate()}`.slice(-2)}u+=1,l=u}return le)),s=null==e?void 0:e.filter((e=>e));return{symbols:null!=s?s:[],fields:null!=r?r:[]}}function w(e){return e.filter((e=>p[e]))}"undefined"!=typeof window&&(window.finQuoteStreamer=new class{constructor(){var e=this;d(this,"updateSubscribers",(async function(t,{symbols:r,fields:s,callback:i,priceHint:n,formatStyle:o,permanent:a=!1}){const c=[];for(let h=0;h{const{data:t}=e,{finWebCore:r}=window,{cmd:s,symbols:i,quoteData:n}=t||{};if("subscribe"===s)return void this.subscribe({callback:Function.prototype,symbols:i,fields:["currency","regularMarketPrice","regularMarketChange"],type:"streamer"});if("unsubscribe"===s)return void this.unsubscribe({callback:Function.prototype,symbols:i,fields:["currency","regularMarketPrice","regularMarketChange"],type:"streamer"});if(!n)return;const o=[];Object.entries(n).forEach((([e,t])=>{if(!t)return;const{price:s={},summaryDetail:i={}}=t,n=t.price?b({},s,i):t;this.quoteData[e]=Object.assign({},this.quoteData[e],n);const a=this.subscriberMap[e];a&&Object.entries(n).forEach((([t,s])=>{const i=a[t]||[],n={};for(const a of i){const{priceHint:i,gmtOffSetMilliseconds:c,exchangeTimezoneShortName:l,timeZoneShortName:u}=this.quoteData[e],{priceHint:h,formatStyle:b}=a,d=`${h||i}${b}`;let p=n[d];void 0===p&&(p=m[t]?s:f({field:t,value:s,lang:(null==r?void 0:r.lang)||"en-US",priceHint:h||i,gmtOffSetMilliseconds:c,timeZoneShort:l||u,formatStyle:a.formatStyle}),n[d]=p),this.quoteData[e][t]=p,o.push([a,p,{field:t,quote:this.quoteData[e]}])}}))})),o.forEach((e=>{e[0].callback(e[1],e[2])}))})),d(this,"getSymbols",((e=!1)=>{const t=[];for(const r in this.subscriberMap){const s=e?this.subscriberMap[r][g]:!this.subscriberMap[r][g];Object.prototype.hasOwnProperty.call(this.subscriberMap,r)&&s&&t.push(r)}return t})),d(this,"handleFocus",(()=>{this.pauseSubscription({symbols:this.getSymbols()},!0)})),d(this,"handleBlur",(()=>{this.pauseSubscription({symbols:this.getSymbols()})})),d(this,"subscribe",(({symbols:e,fields:t,type:r="streamer",userId:s,callback:i,priceHint:n,formatStyle:o,permanent:a=!1})=>{var c,l;const u=k({symbols:e,fields:t}),{finWebCore:h}=window;if((null==(c=u.symbols)?void 0:c.length)>0&&(null==(l=u.fields)?void 0:l.length)>0){this.updateSubscribers("add",{symbols:u.symbols,fields:u.fields,priceHint:n,formatStyle:o,permanent:a,callback:i});const e=(null==h?void 0:h.crumb)||"",t=this.getSymbols(),c=this.getSymbols(!0),l=Object.keys(this.fieldMap);t.length>0&&this.messageToWorker({cmd:"subscribe",type:r,crumb:e,symbols:t,fields:l}),c.length>0&&(null!=h&&h.userId||(h.userId=s),this.messageToWorker({cmd:"subscribe",crumb:e,userId:(null==h?void 0:h.userId)||"",symbols:c,fields:w(l)},"portfolio"))}})),d(this,"unsubscribe",(({symbols:e,fields:t,type:r="streamer",callback:s})=>{var i,n;const{finWebCore:o}=window,a=k({symbols:e,fields:t});if((null==(i=a.symbols)?void 0:i.length)>0&&(null==(n=a.fields)?void 0:n.length)>0){this.updateSubscribers("remove",{symbols:a.symbols,fields:a.fields,callback:s});const e=(null==o?void 0:o.crumb)||"",t=this.getSymbols(),i=this.getSymbols(!0),n=Object.keys(this.fieldMap);t.length>0&&this.messageToWorker({cmd:"unsubscribe",type:r,crumb:e,symbols:t,fields:n}),i.length>0&&this.messageToWorker({cmd:"unsubscribe",crumb:e,symbols:i,fields:w(n)},"portfolio")}})),d(this,"pauseSubscription",(({symbols:e},t=!1)=>{var r;const{finWebCore:s}=window,i=k({symbols:e,fields:[]});if((null==(r=i.symbols)?void 0:r.length)>0){const e=[],r=[];let n=[];const o=new Set(i.symbols);Object.entries(this.subscriberMap).forEach((([s,i])=>{const{_permanent:a}=i;(a||(t?o.has(s):!o.has(s)))&&(n=[...n,...Object.keys(i)],i[g]?r.push(s):e.push(s))}));const a=(null==s?void 0:s.crumb)||"";e.length>0&&this.messageToWorker({cmd:t?"subscribe":"unsubscribe",type:"streamer",crumb:a,symbols:e,fields:Array.from(new Set(n))})}})),d(this,"messageToWorker",((e,t="quote")=>{this.channels[t].port1.postMessage(e)})),d(this,"observe",((e,t)=>{this.intersectSubscribers.set(e,t),this.intersectObserver.observe(e)})),d(this,"unobserve",(e=>{this.intersectSubscribers.delete(e),this.intersectObserver.unobserve(e)})),d(this,"handleIntersection",(e=>{for(let t=0;t{if(new URLSearchParams(window.location.search).has("disableStreaming"))return;const{finWebCore:e}=window;var t,n;this.intersectSubscribers=new Map,this.subscriberMap={},this.intersectObserver||"undefined"==typeof IntersectionObserver||(this.intersectObserver=new IntersectionObserver(this.handleIntersection,{root:null,rootMargin:"0px",threshold:[0]})),void 0===i||this.worker||(this.worker=new i,this.channels.quote.port1.onmessage=this.onUpdate,this.worker.postMessage({cmd:"init"},[this.channels.quote.port2]),this.worker.postMessage({cmd:"init-qpf"},[this.channels["quote:pf"].port2])),void 0===i||this.portfolioWorker||(this.portfolioWorker=new s,this.channels.portfolio.port1.onmessage=this.onUpdate,this.portfolioWorker.postMessage({cmd:"init",enableStreaming:null!=(t=null==e||null==(n=e.features)?void 0:n.includes("enablePfStreaming"))&&t},[this.channels.portfolio.port2]),this.portfolioWorker.postMessage({cmd:"init-qpf"},[this.channels["quote:pf"].port1])),addEventListener("focus",this.handleFocus),addEventListener("blur",this.handleBlur),this.initialized||(Promise.resolve().then(r.bind(r,8277)).then((()=>{this.initialized=!0})),l())})),this.subscriberMap={},this.fieldMap={},this.worker=null,this.portfolioWorker=null,this.channels={portfolio:new MessageChannel,quote:new MessageChannel,"quote:pf":new MessageChannel},this.quoteData={},this.initialized=!1}},window.finQuoteStreamer.init())})()})();