summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteh_coderer <me@tehcoderer.com>2023-05-16 12:25:04 -0500
committerGitHub <noreply@github.com>2023-05-16 17:25:04 +0000
commitfd0ad2187369dca6ed81827f82ae42173486488b (patch)
tree1827bbf21f8a35ab7b651d5112c9bee3da47f7c5
parent549613c821cd31f172f2e04973c87dfde5a6a0b3 (diff)
fix modebar hide/show on hotkeys (#5026)
Co-authored-by: James Maslek <jmaslek11@gmail.com>
-rw-r--r--frontend-components/plotly/src/components/PlotlyConfig.tsx4
-rw-r--r--openbb_terminal/core/plots/plotly.html2
2 files changed, 3 insertions, 3 deletions
diff --git a/frontend-components/plotly/src/components/PlotlyConfig.tsx b/frontend-components/plotly/src/components/PlotlyConfig.tsx
index d18fcab9f52..822987812ae 100644
--- a/frontend-components/plotly/src/components/PlotlyConfig.tsx
+++ b/frontend-components/plotly/src/components/PlotlyConfig.tsx
@@ -13,7 +13,7 @@ export function hideModebar(hide: boolean = true) {
}
let includes_text = "display: none";
if (window.MODEBAR) {
- if (window.MODEBAR.style.cssText.includes("display: none") && !hide) {
+ if (window.MODEBAR.style.cssText.includes("display: none") || !hide) {
includes_text = "display: flex";
window.MODEBAR.style.cssText = `${window.MODEBAR.style.cssText}; display:flex;`;
} else {
@@ -61,7 +61,7 @@ export function PlotConfig({
{ preventDefault: true }
);
useHotkeys(
- "ctrl+shift+h",
+ ["ctrl+shift+h", "ctrl+h"],
() => {
hideModebar();
},
diff --git a/openbb_terminal/core/plots/plotly.html b/openbb_terminal/core/plots/plotly.html
index 30ee83b46b3..46f9e898d01 100644
--- a/openbb_terminal/core/plots/plotly.html
+++ b/openbb_terminal/core/plots/plotly.html
@@ -3698,7 +3698,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
`).map(N=>N.replace(/\r/g,""));const C=A[0].split(","),L=C.map(N=>N.trim().toLowerCase());let O={};for(let N=0;N<c.length;N++)L.includes(c[N])?O[c[N]]=C[L.indexOf(c[N])]:c[N]=="x"&&L.includes("date")&&(O[c[N]]=C[L.indexOf("date")]);["open","high","low","close"].every(N=>L.includes(N))&&E("candlestick"),L.includes("close")&&(v({...d,y:C[L.indexOf("close")]}),O.y=C[L.indexOf("close")]);let U=[];for(let N=1;N<A.length;N++){let j={},V=A[N].split(",");for(let H=0;H<C.length;H++)j[C[H]]=V[H];U.push(j)}let B=m.target.files[0].name.split(".")[0];try{if(B.includes("_")){let N=B.split("_"),j=new RegExp("^[0-9]{8}$");N.length>2&&(j.test(N[0])?N.splice(0,2):j.test(N[N.length-2])&&N.splice(N.length-2,2),B=N.join("_").replace(/openbb_/g,""))}}catch(N){console.log(N)}l(B),v(O),n(C),i(U)},Fb.readAsText(m.target.files[0])},type:"file",id:"csv_file",accept:".csv",style:{marginLeft:10}})]}),ni("div",{style:{marginTop:15},children:[br("label",{htmlFor:"csv_trace_type",children:br("b",{children:"Display data type:"})}),ni("select",{onChange:m=>{E(m.target.value)},id:"csv_trace_type",style:Rw,defaultValue:b[D],children:[D&&br("option",{value:D,children:b[D]},D),Object.keys(b).map(m=>D!==m&&br("option",{value:m,children:b[m]},m))]})]}),ni("div",{style:{marginTop:12},children:[br("label",{htmlFor:"csv_name",children:br("b",{children:"Trace Name:"})}),br("textarea",{id:"csv_name",value:f,onChange:m=>{l(m.target.value)},style:{padding:"5px 2px 2px 5px",width:"100%",maxWidth:"100%",maxHeight:200,marginTop:2},rows:2,cols:20,placeholder:"Enter a name to give this trace"})]}),r.length>0&&ni(tg,{children:[["scatter","bar"].includes(D)&&br("div",{style:{marginTop:15,marginBottom:10},id:"csv_columns",className:"csv_column_container",children:["x","y"].map(m=>ni("div",{style:{marginTop:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[ni("label",{htmlFor:`csv_${m}`,style:{width:"100px"},children:[m.toUpperCase()," Axis"]}),ni("select",{onChange:k=>{a({...o,[m]:k.target.value}),v({...d,[m]:k.target.value})},id:`csv_${m}`,style:{width:"100%"},defaultValue:d[m],children:[d[m]&&br("option",{value:d[m],children:d[m]},m),r.map(k=>br("option",{value:k,children:k},k))]})]},m))}),D==="candlestick"&&br("div",{id:"csv_columns",className:"csv_column_container",style:{marginTop:15},children:["x","open","high","low","close"].map(m=>ni("div",{style:{marginTop:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[br("label",{htmlFor:`csv_${m}`,style:{width:"100px"},children:m.charAt(0).toUpperCase()+m.slice(1)}),ni("select",{onChange:k=>{a({...o,[m]:k.target.value}),v({...d,[m]:k.target.value})},id:`csv_${m}`,style:{width:"100%"},children:[d[m]&&br("option",{value:d[m],children:d[m]},m),r.map(k=>k!=d[k]&&br("option",{value:k,children:k},k))]})]},m))}),ni("div",{style:{marginTop:20},id:"csv_colors",children:[["scatter","bar"].includes(D)&&ni("div",{children:[br("label",{htmlFor:"csv_color",children:`${D.charAt(0).toUpperCase()}${D.slice(1)} color`}),br("input",{type:"color",id:"csv_color",defaultValue:"#FFDD00",style:{margin:"2px 2px 2px 10px"},onChange:m=>{console.log(m.target.value),_(m.target.value)}})]}),D==="candlestick"&&ni(tg,{children:[br("label",{htmlFor:"csv_increasing",children:"Increasing color"}),br("input",{type:"color",id:"csv_increasing",defaultValue:"#00ACFF",style:{margin:"2px 0px 2px 10px"},onChange:m=>{s(m.target.value)}}),br("label",{htmlFor:"csv_decreasing",style:{marginLeft:15},children:"Decreasing color"}),br("input",{style:{margin:"2px 0px 2px 10px"},type:"color",id:"csv_decreasing",defaultValue:"#FF0000",onChange:m=>{y(m.target.value)}})]})]}),ni("div",{style:{marginTop:20},id:"csv_plot_yaxis_options",children:[D!=="candlestick"&&ni(tg,{children:[br("input",{type:"checkbox",id:"csv_percent_change",name:"csv_plot_yaxis_check",style:{marginBottom:2},onChange:m=>{p({...u,percentChange:m.target.checked,sameYaxis:!1})},checked:!u.sameYaxis&&u.percentChange}),br("label",{htmlFor:"csv_percent_change",style:{marginLeft:5},children:"Plot as percent change from first value"}),br("br",{})]}),br("input",{style:{marginTop:2},type:"checkbox",id:"csv_same_yaxis",name:"csv_plot_yaxis_check",onChange:m=>{p({...u,sameYaxis:m.target.checked,percentChange:!1})},checked:!u.percentChange&&u.sameYaxis}),br("label",{htmlFor:"csv_same_yaxis",style:{marginLeft:5},children:"Share Y-axis"}),D==="bar"&&ni("div",{style:{marginTop:2},id:"csv_bar_orientation",children:[br("input",{type:"checkbox",id:"csv_bar_horizontal",onChange:m=>{v({...d,orientation:m.target.checked?"h":"v"})}}),br("label",{htmlFor:"csv_bar_horizontal",style:{marginLeft:5},children:"Plot horizontally"})]})]})]}),br("br",{}),ni("div",{style:{float:"right",marginTop:20},children:[br("button",{className:"_btn-tertiary",id:"csv_cancel",onClick:x,children:"Cancel"}),br("button",{className:"_btn",id:"csv_submit",onClick:g,children:"Submit"})]})]})})}function F7({csvData:P,plotlyData:F,yaxisOptions:J,traceType:ce,traceColor:Pe,traceName:D,options:E,increasingColor:e,decreasingColor:_}){let w=F.data[0];w.xaxis==null&&(w.xaxis="x"),w.yaxis==null&&(w.yaxis="y");let s=w.yaxis,T,f=Object.keys(F.layout).filter(r=>r.startsWith("yaxis")).map(r=>F.layout[r]).filter(r=>r.side=="left"&&(r.overlaying=="y"||r.fixedrange!=null&&r.fixedrange==!0)).length>0?" ":"";if(J.sameYaxis!==!0){const r=Object.keys(F.layout).filter(n=>n.startsWith("yaxis")).map(n=>F.layout[n]);T=`y${r.length+1}`,s=`yaxis${r.length+1}`,console.log(`yaxis: ${T} ${s}`),F.layout[s]={...z7,title:{text:D,font:{size:14},standoff:0},ticksuffix:f,layer:"below traces"}}else T=w.yaxis.replace("yaxis","y");const l={type:ce,name:D,showlegend:!0,yaxis:T};let t={};if(["scatter","bar"].includes(ce)){const r=P.findIndex(n=>n[E.y]!=null&&n[E.y]!=0);t={...l,x:P.map(n=>n[E.x]),y:P.map(function(n){return J.percentChange&&ce==="scatter"?(n[E.y]-P[r][E.y])/P[r][E.y]:n[E.y]}),customdata:P.map(n=>n[E.y]),hovertemplate:"%{customdata:.2f}<extra></extra>",connectgaps:!0,marker:{color:Pe}},ce==="bar"&&(t.orientation=E.orientation,t.marker.opacity=.7,delete t.connectgaps,delete t.hovertemplate,delete t.customdata)}else ce==="candlestick"&&(t={...l,x:P.map(r=>r[E.x]),open:P.map(r=>r[E.open]),high:P.map(r=>r[E.high]),low:P.map(r=>r[E.low]),close:P.map(r=>r[E.close]),increasing:{line:{color:e}},decreasing:{line:{color:_}}});return{...F,data:[...F.data,t]}}function B7({plotlyData:P,open:F,close:J,defaultTitle:ce,updateTitle:Pe,updateAxesTitles:D}){const[E,e]=Un.useState(ce),_=Object.keys(P.layout||{}).filter(y=>y.startsWith("yaxis")&&P.layout[y].range!=null),w=Object.keys(P.layout||{}).filter(y=>{var f;return y.startsWith("xaxis")&&P.layout[y].showticklabels!=null&&((f=P.layout[y])==null?void 0:f.anchor)}),[s,T]=Un.useState({});return br(h1,{title:"Chart Titles",description:"Change the titles on the chart.",open:F,close:J,children:ni("div",{id:"popup_title",className:"popup_content",children:[ni("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[ni("div",{children:[br("label",{htmlFor:"title_text",children:br("b",{children:"Title:"})}),br("textarea",{id:"title_text",style:{...Rw,width:"100%",maxWidth:"100%",maxHeight:"200px",marginTop:"8px",marginLeft:"0px"},rows:2,cols:20,value:E,onChange:y=>e(y.target.value)})]}),br("div",{id:"xaxis_div",className:"csv_column_container",style:{marginTop:5,marginBottom:-5},children:w.map((y,f)=>{var l,t;return ni("div",{style:{marginTop:5,marginBottom:5},children:[br("label",{htmlFor:`title_${y}`,children:f===0?br("b",{children:"X axis:"}):ni("b",{children:["X axis ",f+1,":"]})}),br("input",{id:`title_${y}`,style:{marginLeft:"0px",padding:"5px 2px 2px 5px"},type:"text",defaultValue:((t=(l=P==null?void 0:P.layout[y])==null?void 0:l.title)==null?void 0:t.text)||"",onChange:i=>{T({...s,[y]:i.target.value})}})]},y)})}),br("div",{id:"yaxis_div",className:"csv_column_container",style:{marginTop:5,marginBottom:5},children:_.map((y,f)=>{var l,t;return ni("div",{style:{marginTop:10},children:[br("label",{htmlFor:`title_${y}`,children:f===0?br("b",{children:"Y axis:"}):ni("b",{children:["Y axis ",f+1,":"]})}),br("input",{id:`title_${y}`,style:{marginLeft:"0px",padding:"5px 2px 2px 5px"},type:"text",defaultValue:((t=(l=P==null?void 0:P.layout[y])==null?void 0:l.title)==null?void 0:t.text)||"",onChange:i=>{T({...s,[y]:i.target.value})}})]},y)})})]}),ni("div",{style:{float:"right",marginTop:20},children:[br("button",{className:"_btn-tertiary ph-capture",id:"title_cancel",onClick:J,children:"Cancel"}),br("button",{className:"_btn ph-capture",id:"title_submit",onClick:()=>{Pe(E),D(s),J()},children:"Submit"})]})]})})}const Bb={padding:"5px 2px 2px 5px",margin:"2px 0"};function N7({open:P,close:F,addAnnotation:J,deleteAnnotation:ce,popupData:Pe}){var l,t,i,r,n;const D={text:"",color:"#0088CC",size:18,bordercolor:"#822661",yanchor:"above"},[E,e]=Un.useState(D),[_,w]=Un.useState(D);Pe&&Pe!==E&&Pe.annotation&&(Pe.annotation=(Pe==null?void 0:Pe.annotation)||{},e(Pe),w(Pe));function s(){console.log("closing"),e(D),w(D),F()}function T(o){console.log(o.target.id.replace("addtext_",""),o.target.value);const a=o.target.id.replace("addtext_",""),u=o.target.value;w({..._,[a]:u})}function y(){console.log("submitting",_),_.text!==""?(E!=null&&E.annotation&&w({..._,annotation:E.annotation}),J(_),F()):(document.getElementById("popup_textarea_warning").style.display="block",document.getElementById("addtext_text").style.border="1px solid red")}function f(){ce(E),s()}return br(h1,{title:"Add Text to Chart",description:"Change the titles on the chart.",open:P,close:s,children:ni("div",{id:"popup_title",className:"popup_content",children:[ni("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[ni("div",{style:{marginBottom:20},children:[ni("label",{htmlFor:"popup_text",children:[br("b",{children:"Text:"}),br("div",{id:"popup_textarea_warning",className:"popup_warning",children:"Text is required"})]}),br("textarea",{id:"addtext_text",style:{...Bb,width:"100%",maxWidth:"100%",maxHeight:"200px",marginTop:"8px"},rows:4,cols:50,placeholder:"Enter text here",onChange:T,defaultValue:((l=E==null?void 0:E.annotation)==null?void 0:l.text)||(_==null?void 0:_.text)})]}),ni("div",{style:{display:"flex",gap:15,alignItems:"center",flexWrap:"wrap",columnCount:2,justifyContent:"space-between",marginBottom:20},children:[br("label",{htmlFor:"addtext_color",children:br("b",{children:"Font color"})}),br("input",{type:"color",id:"addtext_color",style:{margin:"2px 2px 2px 15px"},defaultValue:((t=E==null?void 0:E.annotation)==null?void 0:t.color)||(_==null?void 0:_.color),onChange:T}),br("label",{htmlFor:"addtext_bordercolor",style:{marginLeft:20},children:br("b",{children:"Border color"})}),br("input",{type:"color",id:"addtext_bordercolor",style:{margin:"2px 2px 10px 15px"},defaultValue:((i=E==null?void 0:E.annotation)==null?void 0:i.bordercolor)||(_==null?void 0:_.bordercolor),onChange:T}),br("label",{htmlFor:"addtext_size",children:br("b",{children:"Font size"})}),br("input",{style:{...Bb,width:"52px",margin:"0px 0px 0px 2px"},type:"number",id:"addtext_size",onChange:T,defaultValue:((r=E==null?void 0:E.annotation)==null?void 0:r.size)||(_==null?void 0:_.size)}),ni("div",{children:[br("label",{htmlFor:"addtext_yanchor",style:{marginRight:31},children:br("b",{children:"Position"})}),ni("select",{id:"addtext_yanchor",name:"yanchor",style:{width:"100px"},defaultValue:((n=E==null?void 0:E.annotation)==null?void 0:n.yanchor)||(_==null?void 0:_.yanchor),onChange:T,children:[br("option",{value:"above",children:"Above"}),br("option",{value:"below",children:"Below"})]})]})]})]}),ni("div",{style:{float:"right",marginTop:20},children:[br("button",{className:"_btn-tertiary ph-capture",id:"title_cancel",onClick:s,children:"Cancel"}),br("button",{className:"_btn ph-capture",id:"title_delete",onClick:f,children:"Delete"}),br("button",{className:"_btn ph-capture",id:"title_submit",onClick:y,children:"Submit"})]})]})})}function j7({plotData:P,popup_data:F,current_text:J}){var _;let ce=F.x,Pe=F.y,D=F.yref,E=((_=P==null?void 0:P.layout)==null?void 0:_.annotations)||[],e=-1;for(let w=0;w<E.length;w++)if(E[w].x==ce&&E[w].y==Pe&&E[w].text==J){e=w;break}if(F.high!=null&&(Pe=F.yanchor=="above"?F.high:F.low),e==-1){let w={x:ce,y:Pe,xref:"x",yref:D,xanchor:"center",text:F.text,showarrow:!0,arrowhead:2,arrowsize:1,arrowwidth:2,ax:ce,ay:Pe+F.yshift,ayref:D,axref:"x",bordercolor:F.bordercolor,bgcolor:"#000000",borderwidth:2,borderpad:4,opacity:.8,font:{color:F.color,size:F.size},clicktoshow:"onoff",captureevents:!0,high:F.high||void 0,low:F.low||void 0};E.push(w)}else E[e].y=Pe,E[e].text=F.text,E[e].font.color=F.color,E[e].font.size=F.size,E[e].ay=Pe+F.yshift,E[e].bordercolor=F.bordercolor,E[e].high=F.high||void 0,E[e].low=F.low||void 0;return{annotations:E,annotation:E[e]}}function Nb({plotData:P,popup_data:F,current_text:J}){console.log("plot_text: current_text",J);let ce,Pe=F.yref.replace("y","yaxis"),D=P.layout[Pe].range,E=(D[1]-D[0])*.2;F.yanchor=="below"&&(E=-E),F.yshift=E,ce=j7({plotData:P,popup_data:F,current_text:J});let e={annotations:ce.annotations,dragmode:"pan"};return e[Pe+".type"]="linear",{update:e,annotation:ce.annotation}}function U7({plotData:P,popupData:F,setPlotData:J,setModal:ce,setOnAnnotationClick:Pe,setAnnotations:D,onAnnotationClick:E,ohlcAnnotation:e,setOhlcAnnotation:_,annotations:w,plotDiv:s}){if(F.text!=null&&F.text!=""){let T=function(l){var u,p,c,b,d,v;console.log("plotly_click",l);let t=l.points[0].x,i=l.points[0].fullData.yaxis,r=0,n,o;l.points[0].y!=null?r=l.points[0].y:l.points[0].low!=null&&(n=l.points[0].high,o=l.points[0].low,(y==null?void 0:y.yanchor)=="below"?r=l.points[0].low:r=l.points[0].high),y={x:((u=E==null?void 0:E.annotation)==null?void 0:u.x)??t,y:((p=E==null?void 0:E.annotation)==null?void 0:p.y)??r,yref:((c=E==null?void 0:E.annotation)==null?void 0:c.yref)??i,high:((b=E==null?void 0:E.annotation)==null?void 0:b.high)??n,low:((d=E==null?void 0:E.annotation)==null?void 0:d.low)??o,...F},n!=null&&(e.push(y),_(e),console.log("ohlcAnnotation",e));let a=Nb({plotData:P,popup_data:y,current_text:(v=E==null?void 0:E.annotation)==null?void 0:v.text});D([...w,a.annotation].filter(x=>x!=null)),P.layout.dragmode="pan",J({...P,...a.update}),s.removeAllListeners("plotly_click")};F.text=F.text.replace(/\n/g,"<br>");let y,f=!1;if(F.annotation){console.log("data",F),y={x:F.annotation.x,y:F.annotation.y,yref:F.annotation.yref,yanchor:F.annotation.y<F.annotation.ay?"above":"below",...F},F.annotation.high!=null&&(f=!0),console.log("popup_data",y);let l=Nb({plotData:P,popup_data:y,current_text:F.annotation.text});if(f){let t=e.findIndex(i=>i.x==F.annotation.x&&i.y==F.annotation.y&&i.yref==F.annotation.yref);console.log("ohlcAnnotationIndex",t),t==-1?_([...e,l.annotation]):(e[t]=l.annotation,_(e))}D([...w,l.annotation].filter(t=>t!=null)),P.layout.dragmode="pan",J({...P,...l.update}),Pe({});return}s.on("plotly_clickannotation",l=>{console.log("plotly_clickannotation",l);let t=l.annotation;if(t.text==null){console.log("annotation.text is undefined");return}console.log("annotation.text",t.text),t.text=t.text.replace(/<br>/g,`
`);let i={x:t.x,y:t.y,high:(t==null?void 0:t.high)??void 0,low:(t==null?void 0:t.low)??void 0,yanchor:t.y<t.ay?"above":"below",text:t.text,color:t.font.color,size:t.font.size,bordercolor:t.bordercolor,annotation:t};console.log("popup_data_clickannotation",i),Pe(i),ce({name:"textDialog",data:i}),Pe({})}),P.layout.dragmode="select",J({...P}),s.on("plotly_click",T)}}function Wv(){return Wv=Object.assign?Object.assign.bind():function(P){for(var F=1;F<arguments.length;F++){var J=arguments[F];for(var ce in J)Object.prototype.hasOwnProperty.call(J,ce)&&(P[ce]=J[ce])}return P},Wv.apply(this,arguments)}var zw=["shift","alt","meta","mod","ctrl"],V7={esc:"escape",return:"enter",".":"period",",":"comma","-":"slash"," ":"space","`":"backquote","#":"backslash","+":"bracketright",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function sc(P){return(V7[P]||P).trim().toLowerCase().replace(/key|digit|numpad|arrow/,"")}function H7(P){return zw.includes(P)}function Bg(P,F){return F===void 0&&(F=","),P.split(F)}function Ng(P,F,J){F===void 0&&(F="+");var ce=P.toLocaleLowerCase().split(F).map(function(E){return sc(E)}),Pe={alt:ce.includes("alt"),ctrl:ce.includes("ctrl")||ce.includes("control"),shift:ce.includes("shift"),meta:ce.includes("meta"),mod:ce.includes("mod")},D=ce.filter(function(E){return!zw.includes(E)});return Wv({},Pe,{keys:D,description:J})}(function(){typeof document<"u"&&(document.addEventListener("keydown",function(P){P.key!==void 0&&Dw([sc(P.key),sc(P.code)])}),document.addEventListener("keyup",function(P){P.key!==void 0&&Fw([sc(P.key),sc(P.code)])})),typeof window<"u"&&window.addEventListener("blur",function(){lc.clear()})})();var lc=new Set;function q7(P,F){F===void 0&&(F=",");var J=Array.isArray(P)?P:P.split(F);return J.every(function(ce){return lc.has(ce.trim().toLowerCase())})}function Dw(P){var F=Array.isArray(P)?P:[P];lc.has("meta")&&lc.forEach(function(J){return!H7(J)&&lc.delete(J.toLowerCase())}),F.forEach(function(J){return lc.add(J.toLowerCase())})}function Fw(P){var F=Array.isArray(P)?P:[P];P==="meta"?lc.clear():F.forEach(function(J){return lc.delete(J.toLowerCase())})}function G7(P,F,J){(typeof J=="function"&&J(P,F)||J===!0)&&P.preventDefault()}function W7(P,F,J){return typeof J=="function"?J(P,F):J===!0||J===void 0}function Z7(P){return Bw(P,["input","textarea","select"])}function Bw(P,F){var J=P.target;F===void 0&&(F=!1);var ce=J&&J.tagName;return F instanceof Array?!!(ce&&F&&F.some(function(Pe){return Pe.toLowerCase()===ce.toLowerCase()})):!!(ce&&F&&F===!0)}function Y7(P,F){return P.length===0&&F?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):F?P.some(function(J){return F.includes(J)})||P.includes("*"):!0}var X7=function(F,J,ce){ce===void 0&&(ce=!1);var Pe=J.alt,D=J.meta,E=J.mod,e=J.shift,_=J.ctrl,w=J.keys,s=F.key,T=F.code,y=F.ctrlKey,f=F.metaKey,l=F.shiftKey,t=F.altKey,i=sc(T),r=s.toLowerCase();if(!ce){if(Pe===!t&&r!=="alt"||e===!l&&r!=="shift")return!1;if(E){if(!f&&!y)return!1}else if(D===!f&&r!=="meta"&&r!=="os"||_===!y&&r!=="ctrl"&&r!=="control")return!1}return w&&w.length===1&&(w.includes(r)||w.includes(i))?!0:w?q7(w):!w},$7=Un.createContext(void 0),J7=function(){return Un.useContext($7)};function Nw(P,F){return P&&F&&typeof P=="object"&&typeof F=="object"?Object.keys(P).length===Object.keys(F).length&&Object.keys(P).reduce(function(J,ce){return J&&Nw(P[ce],F[ce])},!0):P===F}var K7=Un.createContext({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),Q7=function(){return Un.useContext(K7)};function e9(P){var F=Un.useRef(void 0);return Nw(F.current,P)||(F.current=P),F.current}var jb=function(F){F.stopPropagation(),F.preventDefault(),F.stopImmediatePropagation()},t9=typeof window<"u"?Un.useLayoutEffect:Un.useEffect;function Ku(P,F,J,ce){var Pe=Un.useRef(null),D=Un.useRef(!1),E=J instanceof Array?ce instanceof Array?void 0:ce:J,e=P instanceof Array?P.join(E==null?void 0:E.splitKey):P,_=J instanceof Array?J:ce instanceof Array?ce:void 0,w=Un.useCallback(F,_??[]),s=Un.useRef(w);_?s.current=w:s.current=F;var T=e9(E),y=Q7(),f=y.enabledScopes,l=J7();return t9(function(){if(!((T==null?void 0:T.enabled)===!1||!Y7(f,T==null?void 0:T.scopes))){var t=function(a,u){var p;if(u===void 0&&(u=!1),!(Z7(a)&&!Bw(a,T==null?void 0:T.enableOnFormTags))&&!(T!=null&&T.ignoreEventWhen!=null&&T.ignoreEventWhen(a))){if(Pe.current!==null&&document.activeElement!==Pe.current&&!Pe.current.contains(document.activeElement)){jb(a);return}(p=a.target)!=null&&p.isContentEditable&&!(T!=null&&T.enableOnContentEditable)||Bg(e,T==null?void 0:T.splitKey).forEach(function(c){var b,d=Ng(c,T==null?void 0:T.combinationKey);if(X7(a,d,T==null?void 0:T.ignoreModifiers)||(b=d.keys)!=null&&b.includes("*")){if(u&&D.current)return;if(G7(a,d,T==null?void 0:T.preventDefault),!W7(a,d,T==null?void 0:T.enabled)){jb(a);return}s.current(a,d),u||(D.current=!0)}})}},i=function(a){a.key!==void 0&&(Dw(sc(a.code)),((T==null?void 0:T.keydown)===void 0&&(T==null?void 0:T.keyup)!==!0||T!=null&&T.keydown)&&t(a))},r=function(a){a.key!==void 0&&(Fw(sc(a.code)),D.current=!1,T!=null&&T.keyup&&t(a,!0))},n=Pe.current||(E==null?void 0:E.document)||document;return n.addEventListener("keyup",r),n.addEventListener("keydown",i),l&&Bg(e,T==null?void 0:T.splitKey).forEach(function(o){return l.addHotkey(Ng(o,T==null?void 0:T.combinationKey,T==null?void 0:T.description))}),function(){n.removeEventListener("keyup",r),n.removeEventListener("keydown",i),l&&Bg(e,T==null?void 0:T.splitKey).forEach(function(o){return l.removeHotkey(Ng(o,T==null?void 0:T.combinationKey,T==null?void 0:T.description))})}}},[e,T,f]),Pe}var jw={exports:{}};(function(P){(function(F){var J=o(),ce=a(),Pe=u(),D=p(),E={imagePlaceholder:void 0,cacheBust:!1},e={toSvg:_,toPng:s,toJpeg:T,toBlob:y,toPixelData:w,impl:{fontFaces:Pe,images:D,util:J,inliner:ce,options:{}}};P.exports=e;function _(c,b){return b=b||{},f(b),Promise.resolve(c).then(function(v){return t(v,b.filter,!0)}).then(i).then(r).then(d).then(function(v){return n(v,b.width||J.width(c),b.height||J.height(c))});function d(v){return b.bgcolor&&(v.style.backgroundColor=b.bgcolor),b.width&&(v.style.width=b.width+"px"),b.height&&(v.style.height=b.height+"px"),b.style&&Object.keys(b.style).forEach(function(x){v.style[x]=b.style[x]}),v}}function w(c,b){return l(c,b||{}).then(function(d){return d.getContext("2d").getImageData(0,0,J.width(c),J.height(c)).data})}function s(c,b){return l(c,b||{}).then(function(d){return d.toDataURL()})}function T(c,b){return b=b||{},l(c,b).then(function(d){return d.toDataURL("image/jpeg",b.quality||1)})}function y(c,b){return l(c,b||{}).then(J.canvasToBlob)}function f(c){typeof c.imagePlaceholder>"u"?e.impl.options.imagePlaceholder=E.imagePlaceholder:e.impl.options.imagePlaceholder=c.imagePlaceholder,typeof c.cacheBust>"u"?e.impl.options.cacheBust=E.cacheBust:e.impl.options.cacheBust=c.cacheBust}function l(c,b){return _(c,b).then(J.makeImage).then(J.delay(100)).then(function(v){var x=d(c);return x.getContext("2d").drawImage(v,0,0),x});function d(v){var x=document.createElement("canvas");if(x.width=b.width||J.width(v),x.height=b.height||J.height(v),b.bgcolor){var g=x.getContext("2d");g.fillStyle=b.bgcolor,g.fillRect(0,0,x.width,x.height)}return x}}function t(c,b,d){if(!d&&b&&!b(c))return Promise.resolve();return Promise.resolve(c).then(v).then(function(m){return x(c,m,b)}).then(function(m){return g(c,m)});function v(m){return m instanceof HTMLCanvasElement?J.makeImage(m.toDataURL()):m.cloneNode(!1)}function x(m,k,h){var M=m.childNodes;if(M.length===0)return Promise.resolve(k);return A(k,J.asArray(M),h).then(function(){return k});function A(C,L,O){var I=Promise.resolve();return L.forEach(function(R){I=I.then(function(){return t(R,O)}).then(function(U){U&&C.appendChild(U)})}),I}}function g(m,k){if(!(k instanceof Element))return k;return Promise.resolve().then(h).then(M).then(A).then(C).then(function(){return k});function h(){L(window.getComputedStyle(m),k.style);function L(O,I){O.cssText?I.cssText=O.cssText:R(O,I);function R(U,B){J.asArray(U).forEach(function(G){B.setProperty(G,U.getPropertyValue(G),U.getPropertyPriority(G))})}}}function M(){[":before",":after"].forEach(function(O){L(O)});function L(O){var I=window.getComputedStyle(m,O),R=I.getPropertyValue("content");if(R===""||R==="none")return;var U=J.uid();k.className=k.className+" "+U;var B=document.createElement("style");B.appendChild(G(U,O,I)),k.appendChild(B);function G(N,j,V){var H="."+N+":"+j,ee=V.cssText?Q(V):X(V);return document.createTextNode(H+"{"+ee+"}");function Q(Y){var K=Y.getPropertyValue("content");return Y.cssText+" content: "+K+";"}function X(Y){return J.asArray(Y).map(K).join("; ")+";";function K(te){return te+": "+Y.getPropertyValue(te)+(Y.getPropertyPriority(te)?" !important":"")}}}}}function A(){m instanceof HTMLTextAreaElement&&(k.innerHTML=m.value),m instanceof HTMLInputElement&&k.setAttribute("value",m.value)}function C(){k instanceof SVGElement&&(k.setAttribute("xmlns","http://www.w3.org/2000/svg"),k instanceof SVGRectElement&&["width","height"].forEach(function(L){var O=k.getAttribute(L);O&&k.style.setProperty(L,O)}))}}}function i(c){return Pe.resolveAll().then(function(b){var d=document.createElement("style");return c.appendChild(d),d.appendChild(document.createTextNode(b)),c})}function r(c){return D.inlineAll(c).then(function(){return c})}function n(c,b,d){return Promise.resolve(c).then(function(v){return v.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(v)}).then(J.escapeXhtml).then(function(v){return'<foreignObject x="0" y="0" width="100%" height="100%">'+v+"</foreignObject>"}).then(function(v){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+b+'" height="'+d+'">'+v+"</svg>"}).then(function(v){return"data:image/svg+xml;charset=utf-8,"+v})}function o(){return{escape:C,parseExtension:b,mimeType:d,dataAsUrl:A,isDataUrl:v,canvasToBlob:g,resolveUrl:m,getAndEncode:M,uid:k(),delay:L,asArray:O,escapeXhtml:I,makeImage:h,width:R,height:U};function c(){var G="application/font-woff",N="image/jpeg";return{woff:G,woff2:G,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:N,jpeg:N,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}function b(G){var N=/\.([^\.\/]*?)$/g.exec(G);return N?N[1]:""}function d(G){var N=b(G).toLowerCase();return c()[N]||""}function v(G){return G.search(/^(data:)/)!==-1}function x(G){return new Promise(function(N){for(var j=window.atob(G.toDataURL().split(",")[1]),V=j.length,H=new Uint8Array(V),ee=0;ee<V;ee++)H[ee]=j.charCodeAt(ee);N(new Blob([H],{type:"image/png"}))})}function g(G){return G.toBlob?new Promise(function(N){G.toBlob(N)}):x(G)}function m(G,N){var j=document.implementation.createHTMLDocument(),V=j.createElement("base");j.head.appendChild(V);var H=j.createElement("a");return j.body.appendChild(H),V.href=N,H.href=G,H.href}function k(){var G=0;return function(){return"u"+N()+G++;function N(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}}}function h(G){return new Promise(function(N,j){var V=new Image;V.onload=function(){N(V)},V.onerror=j,V.src=G})}function M(G){var N=3e4;return e.impl.options.cacheBust&&(G+=(/\?/.test(G)?"&":"?")+new Date().getTime()),new Promise(function(j){var V=new XMLHttpRequest;V.onreadystatechange=Q,V.ontimeout=X,V.responseType="blob",V.timeout=N,V.open("GET",G,!0),V.send();var H;if(e.impl.options.imagePlaceholder){var ee=e.impl.options.imagePlaceholder.split(/,/);ee&&ee[1]&&(H=ee[1])}function Q(){if(V.readyState===4){if(V.status!==200){H?j(H):Y("cannot fetch resource: "+G+", status: "+V.status);return}var K=new FileReader;K.onloadend=function(){var te=K.result.split(/,/)[1];j(te)},K.readAsDataURL(V.response)}}function X(){H?j(H):Y("timeout of "+N+"ms occured while fetching resource: "+G)}function Y(K){console.error(K),j("")}})}function A(G,N){return"data:"+N+";base64,"+G}function C(G){return G.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")}function L(G){return function(N){return new Promise(function(j){setTimeout(function(){j(N)},G)})}}function O(G){for(var N=[],j=G.length,V=0;V<j;V++)N.push(G[V]);return N}function I(G){return G.replace(/#/g,"%23").replace(/\n/g,"%0A")}function R(G){var N=B(G,"border-left-width"),j=B(G,"border-right-width");return G.scrollWidth+N+j}function U(G){var N=B(G,"border-top-width"),j=B(G,"border-bottom-width");return G.scrollHeight+N+j}function B(G,N){var j=window.getComputedStyle(G).getPropertyValue(N);return parseFloat(j.replace("px",""))}}function a(){var c=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:x,shouldProcess:b,impl:{readUrls:d,inline:v}};function b(g){return g.search(c)!==-1}function d(g){for(var m=[],k;(k=c.exec(g))!==null;)m.push(k[1]);return m.filter(function(h){return!J.isDataUrl(h)})}function v(g,m,k,h){return Promise.resolve(m).then(function(A){return k?J.resolveUrl(A,k):A}).then(h||J.getAndEncode).then(function(A){return J.dataAsUrl(A,J.mimeType(m))}).then(function(A){return g.replace(M(m),"$1"+A+"$3")});function M(A){return new RegExp(`(url\\(['"]?)(`+J.escape(A)+`)(['"]?\\))`,"g")}}function x(g,m,k){if(h())return Promise.resolve(g);return Promise.resolve(g).then(d).then(function(M){var A=Promise.resolve(g);return M.forEach(function(C){A=A.then(function(L){return v(L,C,m,k)})}),A});function h(){return!b(g)}}}function u(){return{resolveAll:c,impl:{readAll:b}};function c(){return b().then(function(d){return Promise.all(d.map(function(v){return v.resolve()}))}).then(function(d){return d.join(`
`)})}function b(){return Promise.resolve(J.asArray(document.styleSheets)).then(v).then(d).then(function(g){return g.map(x)});function d(g){return g.filter(function(m){return m.type===CSSRule.FONT_FACE_RULE}).filter(function(m){return ce.shouldProcess(m.style.getPropertyValue("src"))})}function v(g){var m=[];return g.forEach(function(k){try{J.asArray(k.cssRules||[]).forEach(m.push.bind(m))}catch(h){console.log("Error while reading CSS rules from "+k.href,h.toString())}}),m}function x(g){return{resolve:function(){var k=(g.parentStyleSheet||{}).href;return ce.inlineAll(g.cssText,k)},src:function(){return g.style.getPropertyValue("src")}}}}}function p(){return{inlineAll:b,impl:{newImage:c}};function c(d){return{inline:v};function v(x){return J.isDataUrl(d.src)?Promise.resolve():Promise.resolve(d.src).then(x||J.getAndEncode).then(function(g){return J.dataAsUrl(g,J.mimeType(d.src))}).then(function(g){return new Promise(function(m,k){d.onload=m,d.onerror=k,d.src=g})})}}function b(d){if(!(d instanceof Element))return Promise.resolve(d);return v(d).then(function(){return d instanceof HTMLImageElement?c(d).inline():Promise.all(J.asArray(d.childNodes).map(function(x){return b(x)}))});function v(x){var g=x.style.getPropertyValue("background");return g?ce.inlineAll(g).then(function(m){x.style.setProperty("background",m,x.style.getPropertyPriority("background"))}).then(function(){return x}):Promise.resolve(x)}}}})()})(jw);var n9=jw.exports;const Uw=jp(n9),r9=async({fileHandle:P,blob:F})=>{if(P)return i9({fileHandle:P,blob:F})},i9=async({fileHandle:P,blob:F})=>{const J=await P.createWritable();await J.write(F),await J.close()},a9=[{description:"PNG Image",accept:{"image/png":[".png"]}},{description:"JPEG Image",accept:{"image/jpeg":[".jpeg"]}},{description:"SVG Image",accept:{"image/svg+xml":[".svg"]}}],Vw=({filename:P,is_image:F})=>{try{if("showSaveFilePicker"in window){const J={suggestedName:P,types:F?a9:[{description:"CSV File",accept:{"image/csv":[".csv"]}}],excludeAcceptAllOption:!0};return showSaveFilePicker(J)}}catch(J){console.error(J)}return new Promise(J=>{J(null)})},ty=(P,F,J)=>{try{if(J===null)throw new Error("Cannot access filesystem");return r9({fileHandle:J,blob:P})}catch(ce){console.error("oops, something went wrong!",ce);const Pe=URL.createObjectURL(P),D=document.createElement("a");D.setAttribute("href",Pe),D.setAttribute("download",F),D.style.visibility="hidden",document.body.appendChild(D),D.click(),document.body.removeChild(D)}return new Promise(ce=>{ce(!0)})};async function Ub(P,F){const J=P.data;let ce=[];const Pe=[],D="title"in P.layout.xaxis&&P.layout.xaxis.title.text!==void 0?P.layout.xaxis.title.text:"x",E="title"in P.layout.yaxis&&P.layout.yaxis.title.text!==void 0?P.layout.yaxis.title.text:"y";return J.forEach(function(e){e.type==="candlestick"&&(ce.length===0&&(ce=["Date","Open","High","Low","Close"]),e.x.forEach(function(_,w){Pe.push([_,e.open[w],e.high[w],e.low[w],e.close[w]])})),["scatter","bar"].includes(e.type)&&(ce.length===0&&ce.push(D),ce.push(e.name!==void 0?e.name:E),e.x.forEach(function(_,w){Pe[w]===void 0&&(Pe[w]=[_]),Pe[w].push(e.y[w])}))}),await o9(ce,Pe,F)}async function o9(P,F,J){const ce=P,Pe=F.map(w=>w.map(s=>s==null?"":typeof s=="object"?JSON.stringify(s):s.toString().replace(/"/g,'""'))),E=[ce,...Pe].map(w=>w.join(",")).join(`
-`),e=new Blob([E],{type:"text/csv;charset=utf-8;"}),_=`${window.title}.csv`;try{const w=await Vw({filename:_});await Bp("Saving CSV"),Np(async function(){ty(e,_,w).then(async function(){await new Promise(s=>setTimeout(s,1500)),w||J(!0),await Bp("",!0)})},2)()}catch(w){console.error(w)}}function Bp(P,F){const J=window.document.getElementById("loading"),ce=window.document.getElementById("loading_text");return new Promise(Pe=>{F?J.classList.remove("show"):(ce.innerHTML=P,J.classList.add("show"));const D=setInterval(function(){(F?!J.classList.contains("show"):J.classList.contains("show"))&&(clearInterval(D),Pe(!0))},.01)})}const Np=(P,F)=>{let J;return function(){const ce=this,Pe=arguments;clearTimeout(J),J=setTimeout(()=>P.apply(ce,Pe),F)}},s9={yref:"paper",xref:"paper",x:1,y:0,text:"OpenBB Terminal",font_size:17,font_color:"gray",opacity:.5,xanchor:"right",yanchor:"bottom",yshift:-80,xshift:40};async function Vb(P,F,J=!1){const ce=document.getElementById("plotlyChart");J&&(ce.layout.annotations.push(s9),ce.globals.cmd_idx!==void 0&&ce.globals.cmd_src!==void 0&&(ce.layout.annotations[ce.globals.cmd_idx].text=ce.globals.cmd_src),Gs.relayout(ce,{"title.text":ce.globals.title,margin:ce.globals.old_margin})),J||(ce.globals.cmd_idx!==void 0&&ce.globals.cmd_src!==void 0&&(ce.layout.annotations[ce.globals.cmd_idx].text=""),ce.layout.annotations.splice(F,1),Gs.relayout(ce,{"title.text":"",margin:P}))}async function Hw(P,F,J){const ce=document.getElementById(P);if(["svg","pdf"].includes(J)){const Pe=document.getElementById("plotlyChart"),D=Pe.layout.margin,E=Pe.layout.annotations.length;await Vb(D,E,!0),Gs.downloadImage(Pe,{format:"svg",height:Pe.clientHeight,width:Pe.clientWidth,filename:window.title}),await Vb(D,E,!1),await Bp("",!0);return}Np(async function(){Uw.toBlob(ce).then(function(Pe){ty(Pe,F,null)})},2)()}async function Hb(P,F,J,ce){const Pe=document.getElementById(P),D=`${window.title}.png`;try{J(!0);const E=await Vw({filename:D,is_image:!0});let e="png";if(E!==null&&(e=E.name.split(".").pop()),await Bp(`Saving ${e.toUpperCase()}`),["svg","pdf"].includes(e)){await Hw(P,D,e),F(!1),J(!1),E||ce(!0);return}Np(async function(){Uw.toBlob(Pe).then(function(_){ty(_,D,E).then(async function(){await Bp("",!0),F(!1),J(!1),E||ce(!0)})})},2)()}catch(E){console.error(E),F(!1),J(!1)}}function rc(P=!0){return new Promise(F=>{window.MODEBAR||(window.MODEBAR=window.document.getElementsByClassName("modebar-container")[0],window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`),window.MODEBAR&&(window.MODEBAR.style.cssText.includes("display: none")&&!P?window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`:window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:none;`,F(!0))})}function l9({setModal:P,changeTheme:F,autoScaling:J,Loading:ce,changeColor:Pe,downloadFinished:D}){return Ku("ctrl+shift+t",()=>{P({name:"titleDialog"})},{preventDefault:!0}),Ku("ctrl+t",()=>{P({name:"textDialog"})},{preventDefault:!0}),Ku("ctrl+o",()=>{P({name:"overlayChart"})},{preventDefault:!0}),Ku("ctrl+shift+h",()=>{rc()},{preventDefault:!0}),Ku("ctrl+e",()=>{Pe(!0)},{preventDefault:!0}),Ku("ctrl+shift+s",async()=>{P({name:"downloadCsv"}),await Ub(document.getElementById("plotlyChart"),D)},{preventDefault:!0}),Ku("ctrl+s",async()=>{rc(),Hb("MainChart",rc,ce,D)},{preventDefault:!0}),Ku("ctrl+w",()=>{window.close()},{preventDefault:!0}),{plotGlPixelRatio:1,scrollZoom:!0,responsive:!0,displaylogo:!1,displayModeBar:!0,modeBarButtonsToRemove:["lasso2d","select2d","downloadImage"],modeBarButtons:[[{name:"Download CSV (Ctrl+Shift+S)",icon:Pu.downloadCsv,click:async function(e){await Ub(e,D)}},{name:"Download Chart as Image (Ctrl+S)",icon:Pu.downloadImage,click:async function(){rc(),await Hb("MainChart",rc,ce,D)}}],[{name:"Edit Color (Ctrl+E)",icon:Pu.changeColor,click:function(){Pe(!0)}},"drawline","drawopenpath","drawcircle","drawrect","eraseshape"],[{name:"Overlay chart from CSV (Ctrl+O)",icon:Pu.plotCsv,click:function(){P({name:"overlayChart"})}},{name:"Add Text (Ctrl+T)",icon:Pu.addText,click:function(){P({name:"textDialog",data:{text:""}})}},{name:"Change Titles (Ctrl+Shift+T)",icon:Pu.changeTitle,click:function(){P({name:"titleDialog"})}},{name:"Change Theme",icon:Pu.sunIcon,click:function(){F(!0)}}],["hoverClosestCartesian","hoverCompareCartesian","toggleSpikelines"],[{name:"Auto Scale (Ctrl+Shift+A)",icon:Gs.Icons.autoscale,click:function(){J(!0)}},"zoomIn2d","zoomOut2d","autoScale2d","zoom2d","pan2d"]]}}async function u9(P,F){try{if(P["xaxis.range[0]"]!=null){const J=P["xaxis.range[0]"],ce=P["xaxis.range[1]"];let Pe={},D,E;const e=F.data.filter(s=>s.yaxis!=null),_=[...new Set(e.map(s=>s.yaxis||s.y!=null||s.type=="candlestick"))],w=s=>F.data.filter(T=>T.yaxis==s&&(T.y||T.type=="candlestick"));return _.forEach(s=>{if(typeof s!="string")return;let T="yaxis"+s.replace("y",""),y=[],f=[],l=F.layout[T].type=="log";w(s).forEach(r=>{let n=r.x;l=F.layout[T].type=="log";let o=r.y!=null?r.y:[],a=r.type=="candlestick"?r.low:[],u=r.type=="candlestick"?r.high:[];l&&(o=o.map(Math.log10),r.type=="candlestick"&&(a=r.low.map(Math.log10),u=r.high.map(Math.log10)));let p=n.map((c,b)=>{let d=null;return c>=J&&c<=ce&&(r.y!=null&&(d=o[b]),r.type=="candlestick"&&(y.push(a[b]),y.push(u[b]))),d});f=f.concat(p)}),f=f.filter(r=>r!=null&&r!=null),D=Math.min(...f),E=Math.max(...f),y.length>0&&(y=y.filter(r=>r!=null&&r!=null),D=Math.min(...y),E=Math.max(...y));let t=E,i=F.layout[T].fixedrange!=null&&F.layout[T].fixedrange==!0;if(D!=null&&E!=null){let r=E-D,n=.15;if(y.length>0&&(n=.3),D-=r*n,E+=r*n,i){if(F.layout[T].tickvals!=null){let a=t,u=-3,p=Math.round(a*.2,u),c=[2,5,6,7,8,9,10],b=[1,4,5,6,7,8,9];for(let x=0;x<c.length;x++)String(a).length>c[x]&&(u=-b[x],p=Math.round(a*.2,u));let d=[Math.floor(p),Math.floor(p*2),Math.floor(p*3),Math.floor(p*4)],v=[0,Math.floor(a*7)];Pe[T+".tickvals"]=d,Pe[T+".range"]=v,Pe[T+".tickformat"]=".2s";return}D=0,E=F.layout[T].range[1]}Pe[T+".range"]=[D,E]}}),Pe}}catch(J){console.log(`Error in AutoScaling: ${J}`)}return{}}async function c9({plotData:P,volumeBars:F,setMaximizePlot:J}){const ce=Object.keys(P.layout).filter(s=>s.startsWith("xaxis")).filter(s=>P.layout[s].showticklabels||P.layout[s].matches==null),Pe=P.data.filter(s=>{var T;return(T=s==null?void 0:s.name)==null?void 0:T.startsWith("Volume")});let D={},E=F||{old_nticks:{}};const e=window.innerWidth,_=window.innerHeight;let w=_>420&&e<920?8:_>420&&e<500?9:7;return e<750?(Pe.forEach(s=>{s.type=="bar"&&(s.opacity=1,s.marker.line.width=.09,F.yaxis==null&&(E.yaxis="yaxis"+s.yaxis.replace("y",""),D[E.yaxis+".tickfont.size"]=w,E.tickfont=P.layout[E.yaxis].tickfont||{},P.layout.margin.l-=40))}),ce.forEach(s=>{var T;((T=F.old_nticks)==null?void 0:T[s])==null&&(D[s+".nticks"]=6,E.old_nticks[s]=P.layout[s].nticks||10)}),J(!0),await rc()):window.MODEBAR.style.cssText.includes("display: none")&&(await rc(!1),J(!1),F.old_nticks!=null&&ce.forEach(s=>{F.old_nticks[s]!=null&&(D[s+".nticks"]=E.old_nticks[s],E.old_nticks[s]=void 0)}),F.yaxis!=null&&Pe.forEach(s=>{s.type=="bar"&&(s.opacity=.5,s.marker.line.width=.2,D[E.yaxis+".tickfont.size"]=E.tickfont.size+3,P.layout.margin.l+=40,E.yaxis=void 0)})),{volume_update:E,layout_update:D,plotData:P}}function f9({open:P,onColorChange:F}){const[J,ce]=Un.useState(!1);function Pe(D){F(D)}return P&&!J&&ce(!0),!P&&J&&ce(!1),Un.useEffect(()=>{if(J){let D=function(e){let _=0,w=0,s=0,T=0;document.getElementById(e.id+"_header")?document.getElementById(e.id+"_header").onmousedown=y:e.onmousedown=y;function y(t){t=t||window.event,t.preventDefault(),s=t.clientX,T=t.clientY,document.onmouseup=l,document.onmousemove=f}function f(t){t=t||window.event,t.preventDefault(),_=s-t.clientX,w=T-t.clientY,s=t.clientX,T=t.clientY,e.style.top=e.offsetTop-w+"px",e.style.left=e.offsetLeft-_+"px"}function l(){document.onmouseup=null,document.onmousemove=null}},E=document.getElementById("changecolor");E.style.display="block",E.style.width=null,D(E)}else document.getElementById("changecolor").style.display="none"},[J]),br("div",{id:"changecolor",children:br("div",{id:"changecolor_header",children:br("input",{type:"color",id:"picked_color",value:"#00ACFF",onChange:D=>{let E=D.target.value;Pe(E)}})})})}function qw(P){var F,J,ce="";if(typeof P=="string"||typeof P=="number")ce+=P;else if(typeof P=="object")if(Array.isArray(P))for(F=0;F<P.length;F++)P[F]&&(J=qw(P[F]))&&(ce&&(ce+=" "),ce+=J);else for(F in P)P[F]&&(ce&&(ce+=" "),ce+=F);return ce}function h9(){for(var P,F,J=0,ce="";J<arguments.length;)(P=arguments[J++])&&(F=qw(P))&&(ce&&(ce+=" "),ce+=F);return ce}function p9({open:P,close:F}){const J=window.download_path||"~/OpenBBUserData/exports";return br(h1,{title:"Success",description:"",open:P,close:F,children:ni("div",{id:"popup_title",className:"popup_content",style:{padding:"0px 2px 2px 5px",marginTop:5},children:[br("div",{style:{display:"flex",flexDirection:"column",gap:0},children:br("div",{children:ni("label",{htmlFor:"title_text",children:[br("b",{children:window.title})," has been downloaded to",br("br",{}),br("br",{}),br("a",{style:{color:"#FFDD00",marginTop:15},href:`${J}`,onClick:ce=>{ce.preventDefault(),window.pywry.open_file(J)},children:J})]})})}),br("div",{style:{float:"right",marginTop:20},children:br("button",{className:"_btn",style:{padding:"8px 16px",width:"100%"},onClick:F,children:"Close"})})]})})}const d9=QT(ZT);function g9({json:P,date:F,cmd:J,title:ce,globals:Pe,info:D}){var se,fe;const E=GT();Un.useEffect(()=>{E&&E.capture("chart",D)},[]),delete P.layout.width,delete P.layout.height,(fe=(se=P.layout)==null?void 0:se.title)!=null&&fe.text&&(P.layout.title.text="");const[e,_]=Un.useState({}),[w,s]=Un.useState(!1),[T,y]=Un.useState(ce),[f,l]=Un.useState({}),[t,i]=Un.useState(!1),[r,n]=Un.useState({name:""}),[o,a]=Un.useState(!1),[u,p]=Un.useState(null),[c,b]=Un.useState({old_nticks:{}}),[d,v]=Un.useState(!1),[x,g]=Un.useState(!1),[m,k]=Un.useState(P),[h,M]=Un.useState([]),[A,C]=Un.useState(!1),[L,O]=Un.useState(!0),[I,R]=Un.useState(!1),[U,B]=Un.useState(!1),[G,N]=Un.useState(!1),[j,V]=Un.useState({}),[H,ee]=Un.useState([]),Q=()=>n({name:""});function X(ye){var de,he,xe,Re,we;console.log("onDeleteAnnotation",ye);const pe=(he=(de=m==null?void 0:m.layout)==null?void 0:de.annotations)==null?void 0:he.findIndex(Ae=>Ae.text===ye.text);console.log("index",pe),pe>-1&&((Re=(xe=m==null?void 0:m.layout)==null?void 0:xe.annotations)==null||Re.splice(pe,1),k({...m}),M((we=m==null?void 0:m.layout)==null?void 0:we.annotations))}function Y(ye){U7({plotData:m,popupData:ye,setPlotData:k,setModal:n,setOnAnnotationClick:V,setAnnotations:M,onAnnotationClick:j,ohlcAnnotation:H,setOhlcAnnotation:ee,annotations:h,plotDiv:u})}Un.useEffect(()=>{x&&(n({name:"downloadFinished"}),g(!1))},[x]),Un.useEffect(()=>{f&&Object.keys(f).length>0&&(Object.keys(f).forEach(ye=>{m.layout[ye].title={...m.layout[ye].title||{},text:f[ye]},m.layout[ye].showticklabels=!0}),l({}))},[f]);function K(ye){let pe=u.layout.shapes;if(!pe||pe.length==0)return;let de=pe[pe.length-1];de.line.color=ye,Gs.update(u,{},{shapes:pe})}function te(ye,pe=!1){let de=e[ye]||document.querySelector(`[data-title="${ye}"]`);pe?(de.style.border="transparent",de.style.boxShadow="none"):(de.style.border="1px solid rgba(0, 151, 222, 1.0)",de.style.borderRadius="5px",de.style.borderpadding="5px",de.style.boxShadow="0 0 5px rgba(0, 151, 222, 1.0)"),_({...e,[ye]:de})}function ae(){let ye="Auto Scale (Ctrl+Shift+A)",pe=e[ye]||document.querySelector(`[data-title="${ye}"]`),de=!0;pe.style.border=="transparent"?(de=!1,u.on("plotly_relayout",Np(async function(he){if(he["xaxis.range[0]"]==null)return;let xe