From 62ee6d6b4b356bd31342ce81dc5192669879b97b Mon Sep 17 00:00:00 2001 From: teh_coderer Date: Wed, 3 May 2023 17:10:52 -0400 Subject: [PATCH] update --- frontend-components/plotly/src/index.css | 48 ++++++++++++++----- frontend-components/plotly/src/utils/utils.ts | 8 +--- openbb_terminal/core/plots/plotly.html | 4 +- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/frontend-components/plotly/src/index.css b/frontend-components/plotly/src/index.css index de932d6d8d1..d65491ec632 100644 --- a/frontend-components/plotly/src/index.css +++ b/frontend-components/plotly/src/index.css @@ -54,15 +54,13 @@ ._header { background: #062d48; - background: linear-gradient( - 90deg, - #062d48, - #0b3054 15%, - #0e386c 45%, - #0b203d 64%, - #06101a 82%, - #060709 - ); + background: linear-gradient(90deg, + #062d48, + #0b3054 15%, + #0e386c 45%, + #0b203d 64%, + #06101a 82%, + #060709); } /* custom scrollbar */ @@ -89,9 +87,10 @@ background: rgba(0, 0, 0, 0); } -body, html { +body, +html { height: 100%; - overflow:hidden; + overflow: hidden; background: #000; } @@ -187,7 +186,10 @@ code { margin-left: 45px; } -._modal {font-size: 0.65rem !important; animation: popup 0.3s ease-in-out;} +._modal { + font-size: 0.65rem !important; + animation: popup 0.3s ease-in-out; +} #changecolor { position: absolute; @@ -317,7 +319,12 @@ code { } @media screen and (max-width: 900px) { - ._modal {font-size: 0.65rem !important; animation: popup 0.3s ease-in-out; height: 70% !important; overflow: auto !important;} + ._modal { + font-size: 0.65rem !important; + animation: popup 0.3s ease-in-out; + height: 70% !important; + overflow: auto !important; + } } .modebar-group { @@ -481,3 +488,18 @@ code { background-color: #1f1f1f !important; border-radius: 8px; } + + +@media screen and (max-height: 1000px) and (max-width: 1100px) { + ._header strong { + font-size: 0.8rem !important; + } + + ._header p { + font-size: 0.7rem !important; + } + + ._header span { + font-size: 0.5rem !important; + } +} diff --git a/frontend-components/plotly/src/utils/utils.ts b/frontend-components/plotly/src/utils/utils.ts index 8e26317005a..9b87340a5a8 100644 --- a/frontend-components/plotly/src/utils/utils.ts +++ b/frontend-components/plotly/src/utils/utils.ts @@ -179,12 +179,8 @@ export async function downloadData(columns: any, data: any) { let fileHandle = await getNewFileHandle({ filename: filename, }); - let ext: string = "png"; - if (fileHandle !== null) { - // @ts-ignore - ext = fileHandle.name.split(".").pop(); - } - await loadingOverlay(`Saving ${ext.toUpperCase()}`); + + await loadingOverlay("Saving CSV"); await new Promise((resolve) => setTimeout(resolve, 1500)); non_blocking(async function () { // @ts-ignore diff --git a/openbb_terminal/core/plots/plotly.html b/openbb_terminal/core/plots/plotly.html index 2737432c60a..6a4650e1711 100644 --- a/openbb_terminal/core/plots/plotly.html +++ b/openbb_terminal/core/plots/plotly.html @@ -3698,11 +3698,11 @@ 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 P={};for(let N=0;NL.includes(N))&&E("candlestick"),L.includes("close")&&(v({...d,y:C[L.indexOf("close")]}),P.y=C[L.indexOf("close")]);let U=[];for(let N=1;N2&&(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(P),n(C),i(U)},Fb.readAsText(y.target.files[0])},type:"file",id:"csv_file",accept:".csv",style:{marginLeft:10}})]}),ri("div",{style:{marginTop:15},children:[Ar("label",{htmlFor:"csv_trace_type",children:Ar("b",{children:"Display data type:"})}),ri("select",{onChange:y=>{E(y.target.value)},id:"csv_trace_type",style:Rw,defaultValue:b[D],children:[D&&Ar("option",{value:D,children:b[D]},D),Object.keys(b).map(y=>D!==y&&Ar("option",{value:y,children:b[y]},y))]})]}),ri("div",{style:{marginTop:12},children:[Ar("label",{htmlFor:"csv_name",children:Ar("b",{children:"Trace Name:"})}),Ar("textarea",{id:"csv_name",value:f,onChange:y=>{l(y.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&&ri(eg,{children:[["scatter","bar"].includes(D)&&Ar("div",{style:{marginTop:15,marginBottom:10},id:"csv_columns",className:"csv_column_container",children:["x","y"].map(y=>ri("div",{style:{marginTop:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[ri("label",{htmlFor:`csv_${y}`,style:{width:"100px"},children:[y.toUpperCase()," Axis"]}),ri("select",{onChange:k=>{a({...o,[y]:k.target.value}),v({...d,[y]:k.target.value})},id:`csv_${y}`,style:{width:"100%"},defaultValue:d[y],children:[d[y]&&Ar("option",{value:d[y],children:d[y]},y),r.map(k=>Ar("option",{value:k,children:k},k))]})]},y))}),D==="candlestick"&&Ar("div",{id:"csv_columns",className:"csv_column_container",style:{marginTop:15},children:["x","open","high","low","close"].map(y=>ri("div",{style:{marginTop:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Ar("label",{htmlFor:`csv_${y}`,style:{width:"100px"},children:y.charAt(0).toUpperCase()+y.slice(1)}),ri("select",{onChange:k=>{a({...o,[y]:k.target.value}),v({...d,[y]:k.target.value})},id:`csv_${y}`,style:{width:"100%"},children:[d[y]&&Ar("option",{value:d[y],children:d[y]},y),r.map(k=>k!=d[k]&&Ar("option",{value:k,children:k},k))]})]},y))}),ri("div",{style:{marginTop:20},id:"csv_colors",children:[["scatter","bar"].includes(D)&&ri("div",{children:[Ar("label",{htmlFor:"csv_color",children:`${D.charAt(0).toUpperCase()}${D.slice(1)} color`}),Ar("input",{type:"color",id:"csv_color",defaultValue:"#FFDD00",style:{margin:"2px 2px 2px 10px"},onChange:y=>{console.log(y.target.value),_(y.target.value)}})]}),D==="candlestick"&&ri(eg,{children:[Ar("label",{htmlFor:"csv_increasing",children:"Increasing color"}),Ar("input",{type:"color",id:"csv_increasing",defaultValue:"#00ACFF",style:{margin:"2px 0px 2px 10px"},onChange:y=>{s(y.target.value)}}),Ar("label",{htmlFor:"csv_decreasing",style:{marginLeft:15},children:"Decreasing color"}),Ar("input",{style:{margin:"2px 0px 2px 10px"},type:"color",id:"csv_decreasing",defaultValue:"#FF0000",onChange:y=>{m(y.target.value)}})]})]}),ri("div",{style:{marginTop:20},id:"csv_plot_yaxis_options",children:[D!=="candlestick"&&ri(eg,{children:[Ar("input",{type:"checkbox",id:"csv_percent_change",name:"csv_plot_yaxis_check",style:{marginBottom:2},onChange:y=>{p({...u,percentChange:y.target.checked,sameYaxis:!1})},checked:!u.sameYaxis&&u.percentChange}),Ar("label",{htmlFor:"csv_percent_change",style:{marginLeft:5},children:"Plot as percent change from first value"}),Ar("br",{})]}),Ar("input",{style:{marginTop:2},type:"checkbox",id:"csv_same_yaxis",name:"csv_plot_yaxis_check",onChange:y=>{p({...u,sameYaxis:y.target.checked,percentChange:!1})},checked:!u.percentChange&&u.sameYaxis}),Ar("label",{htmlFor:"csv_same_yaxis",style:{marginLeft:5},children:"Share Y-axis"}),D==="bar"&&ri("div",{style:{marginTop:2},id:"csv_bar_orientation",children:[Ar("input",{type:"checkbox",id:"csv_bar_horizontal",onChange:y=>{v({...d,orientation:y.target.checked?"h":"v"})}}),Ar("label",{htmlFor:"csv_bar_horizontal",style:{marginLeft:5},children:"Plot horizontally"})]})]})]}),Ar("br",{}),ri("div",{style:{float:"right",marginTop:20},children:[Ar("button",{className:"_btn-tertiary",id:"csv_cancel",onClick:x,children:"Cancel"}),Ar("button",{className:"_btn",id:"csv_submit",onClick:g,children:"Submit"})]})]})})}function F7({csvData:O,plotlyData:F,yaxisOptions:J,traceType:fe,traceColor:Pe,traceName:D,options:E,increasingColor:e,decreasingColor:_}){let T=F.data[0];T.xaxis==null&&(T.xaxis="x"),T.yaxis==null&&(T.yaxis="y");let s=T.yaxis,w,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]);w=`y${r.length+1}`,s=`yaxis${r.length+1}`,console.log(`yaxis: ${w} ${s}`),F.layout[s]={...z7,title:{text:D,font:{size:14},standoff:0},ticksuffix:f,layer:"below traces"}}else w=T.yaxis.replace("yaxis","y");const l={type:fe,name:D,showlegend:!0,yaxis:w};let t={};if(["scatter","bar"].includes(fe)){const r=O.findIndex(n=>n[E.y]!=null&&n[E.y]!=0);t={...l,x:O.map(n=>n[E.x]),y:O.map(function(n){return J.percentChange&&fe==="scatter"?(n[E.y]-O[r][E.y])/O[r][E.y]:n[E.y]}),customdata:O.map(n=>n[E.y]),hovertemplate:"%{customdata:.2f}",connectgaps:!0,marker:{color:Pe}},fe==="bar"&&(t.orientation=E.orientation,t.marker.opacity=.7,delete t.connectgaps,delete t.hovertemplate,delete t.customdata)}else fe==="candlestick"&&(t={...l,x:O.map(r=>r[E.x]),open:O.map(r=>r[E.open]),high:O.map(r=>r[E.high]),low:O.map(r=>r[E.low]),close:O.map(r=>r[E.close]),increasing:{line:{color:e}},decreasing:{line:{color:_}}});return{...F,data:[...F.data,t]}}function B7({plotlyData:O,open:F,close:J,defaultTitle:fe,updateTitle:Pe,updateAxesTitles:D}){const[E,e]=Un.useState(fe),_=Object.keys(O.layout||{}).filter(m=>m.startsWith("yaxis")&&O.layout[m].range!=null),T=Object.keys(O.layout||{}).filter(m=>{var f;return m.startsWith("xaxis")&&O.layout[m].showticklabels!=null&&((f=O.layout[m])==null?void 0:f.anchor)}),[s,w]=Un.useState({});return Ar(ey,{title:"Chart Titles",description:"Change the titles on the chart.",open:F,close:J,children:ri("div",{id:"popup_title",className:"popup_content",children:[ri("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[ri("div",{children:[Ar("label",{htmlFor:"title_text",children:Ar("b",{children:"Title:"})}),Ar("textarea",{id:"title_text",style:{...Rw,width:"100%",maxWidth:"100%",maxHeight:"200px",marginTop:"8px",marginLeft:"0px"},rows:2,cols:20,value:E,onChange:m=>e(m.target.value)})]}),Ar("div",{id:"xaxis_div",className:"csv_column_container",style:{marginTop:5,marginBottom:-5},children:T.map((m,f)=>{var l,t;return ri("div",{style:{marginTop:5,marginBottom:5},children:[Ar("label",{htmlFor:`title_${m}`,children:f===0?Ar("b",{children:"X axis:"}):ri("b",{children:["X axis ",f+1,":"]})}),Ar("input",{id:`title_${m}`,style:{marginLeft:"0px",padding:"5px 2px 2px 5px"},type:"text",defaultValue:((t=(l=O==null?void 0:O.layout[m])==null?void 0:l.title)==null?void 0:t.text)||"",onChange:i=>{w({...s,[m]:i.target.value})}})]},m)})}),Ar("div",{id:"yaxis_div",className:"csv_column_container",style:{marginTop:5,marginBottom:5},children:_.map((m,f)=>{var l,t;return ri("div",{style:{marginTop:10},children:[Ar("label",{htmlFor:`title_${m}`,children:f===0?Ar("b",{children:"Y axis:"}):ri("b",{children:["Y axis ",f+1,":"]})}),Ar("input",{id:`title_${m}`,style:{marginLeft:"0px",padding:"5px 2px 2px 5px"},type:"text",defaultValue:((t=(l=O==null?void 0:O.layout[m])==null?void 0:l.title)==null?void 0:t.text)||"",onChange:i=>{w({...s,[m]:i.target.value})}})]},m)})})]}),ri("div",{style:{float:"right",marginTop:20},children:[Ar("button",{className:"_btn-tertiary ph-capture",id:"title_cancel",onClick:J,children:"Cancel"}),Ar("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:O,close:F,addAnnotation:J,deleteAnnotation:fe,popupData:Pe}){var l,t,i,r,n;const D={text:"",color:"#0088CC",size:18,bordercolor:"#822661",yanchor:"above"},[E,e]=Un.useState(D),[_,T]=Un.useState(D);Pe&&Pe!==E&&Pe.annotation&&(Pe.annotation=(Pe==null?void 0:Pe.annotation)||{},e(Pe),T(Pe));function s(){console.log("closing"),e(D),T(D),F()}function w(o){console.log(o.target.id.replace("addtext_",""),o.target.value);const a=o.target.id.replace("addtext_",""),u=o.target.value;T({..._,[a]:u})}function m(){console.log("submitting",_),_.text!==""?(E!=null&&E.annotation&&T({..._,annotation:E.annotation}),J(_),F()):(document.getElementById("popup_textarea_warning").style.display="block",document.getElementById("addtext_text").style.border="1px solid red")}function f(){fe(E),s()}return Ar(ey,{title:"Add Text to Chart",description:"Change the titles on the chart.",open:O,close:s,children:ri("div",{id:"popup_title",className:"popup_content",children:[ri("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[ri("div",{style:{marginBottom:20},children:[ri("label",{htmlFor:"popup_text",children:[Ar("b",{children:"Text:"}),Ar("div",{id:"popup_textarea_warning",className:"popup_warning",children:"Text is required"})]}),Ar("textarea",{id:"addtext_text",style:{...Bb,width:"100%",maxWidth:"100%",maxHeight:"200px",marginTop:"8px"},rows:4,cols:50,placeholder:"Enter text here",onChange:w,defaultValue:((l=E==null?void 0:E.annotation)==null?void 0:l.text)||(_==null?void 0:_.text)})]}),ri("div",{style:{display:"flex",gap:15,alignItems:"center",flexWrap:"wrap",columnCount:2,justifyContent:"space-between",marginBottom:20},children:[Ar("label",{htmlFor:"addtext_color",children:Ar("b",{children:"Font color"})}),Ar("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:w}),Ar("label",{htmlFor:"addtext_bordercolor",style:{marginLeft:20},children:Ar("b",{children:"Border color"})}),Ar("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:w}),Ar("label",{htmlFor:"addtext_size",children:Ar("b",{children:"Font size"})}),Ar("input",{style:{...Bb,width:"52px",margin:"0px 0px 0px 2px"},type:"number",id:"addtext_size",onChange:w,defaultValue:((r=E==null?void 0:E.annotation)==null?void 0:r.size)||(_==null?void 0:_.size)}),ri("div",{children:[Ar("label",{htmlFor:"addtext_yanchor",style:{marginRight:31},children:Ar("b",{children:"Position"})}),ri("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:w,children:[Ar("option",{value:"above",children:"Above"}),Ar("option",{value:"below",children:"Below"})]})]})]})]}),ri("div",{style:{float:"right",marginTop:20},children:[Ar("button",{className:"_btn-tertiary ph-capture",id:"title_cancel",onClick:s,children:"Cancel"}),Ar("button",{className:"_btn ph-capture",id:"title_delete",onClick:f,children:"Delete"}),Ar("button",{className:"_btn ph-capture",id:"title_submit",onClick:m,children:"Submit"})]})]})})}function j7({plotData:O,popup_data:F,current_text:J}){var _;let fe=F.x,Pe=F.y,D=F.yref,E=((_=O==null?void 0:O.layout)==null?void 0:_.annotations)||[],e=-1;for(let T=0;Tx!=null)),O.layout.dragmode="pan",J({...O,...a.update}),s.removeAllListeners("plotly_click")};F.text=F.text.replace(/\n/g,"
");let m,f=!1;if(F.annotation){console.log("data",F),m={x:F.annotation.x,y:F.annotation.y,yref:F.annotation.yref,yanchor:F.annotation.yi.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([...T,l.annotation].filter(t=>t!=null)),O.layout.dragmode="pan",J({...O,...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(/
/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'),!0):F?O.some(function(J){return F.includes(J)})||O.includes("*"):!0}var X7=function(F,J,fe){fe===void 0&&(fe=!1);var Pe=J.alt,D=J.meta,E=J.mod,e=J.shift,_=J.ctrl,T=J.keys,s=F.key,w=F.code,m=F.ctrlKey,f=F.metaKey,l=F.shiftKey,t=F.altKey,i=sc(w),r=s.toLowerCase();if(!fe){if(Pe===!t&&r!=="alt"||e===!l&&r!=="shift")return!1;if(E){if(!f&&!m)return!1}else if(D===!f&&r!=="meta"&&r!=="os"||_===!m&&r!=="ctrl"&&r!=="control")return!1}return T&&T.length===1&&(T.includes(r)||T.includes(i))?!0:T?q7(T):!T},$7=Un.createContext(void 0),J7=function(){return Un.useContext($7)};function Nw(O,F){return O&&F&&typeof O=="object"&&typeof F=="object"?Object.keys(O).length===Object.keys(F).length&&Object.keys(O).reduce(function(J,fe){return J&&Nw(O[fe],F[fe])},!0):O===F}var K7=Un.createContext({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),Q7=function(){return Un.useContext(K7)};function e9(O){var F=Un.useRef(void 0);return Nw(F.current,O)||(F.current=O),F.current}var jb=function(F){F.stopPropagation(),F.preventDefault(),F.stopImmediatePropagation()},t9=typeof window<"u"?Un.useLayoutEffect:Un.useEffect;function Ku(O,F,J,fe){var Pe=Un.useRef(null),D=Un.useRef(!1),E=J instanceof Array?fe instanceof Array?void 0:fe:J,e=O instanceof Array?O.join(E==null?void 0:E.splitKey):O,_=J instanceof Array?J:fe instanceof Array?fe:void 0,T=Un.useCallback(F,_??[]),s=Un.useRef(T);_?s.current=T:s.current=F;var w=e9(E),m=Q7(),f=m.enabledScopes,l=J7();return t9(function(){if(!((w==null?void 0:w.enabled)===!1||!Y7(f,w==null?void 0:w.scopes))){var t=function(a,u){var p;if(u===void 0&&(u=!1),!(Z7(a)&&!Bw(a,w==null?void 0:w.enableOnFormTags))&&!(w!=null&&w.ignoreEventWhen!=null&&w.ignoreEventWhen(a))){if(Pe.current!==null&&document.activeElement!==Pe.current&&!Pe.current.contains(document.activeElement)){jb(a);return}(p=a.target)!=null&&p.isContentEditable&&!(w!=null&&w.enableOnContentEditable)||Fg(e,w==null?void 0:w.splitKey).forEach(function(c){var b,d=Bg(c,w==null?void 0:w.combinationKey);if(X7(a,d,w==null?void 0:w.ignoreModifiers)||(b=d.keys)!=null&&b.includes("*")){if(u&&D.current)return;if(G7(a,d,w==null?void 0:w.preventDefault),!W7(a,d,w==null?void 0:w.enabled)){jb(a);return}s.current(a,d),u||(D.current=!0)}})}},i=function(a){a.key!==void 0&&(Dw(sc(a.code)),((w==null?void 0:w.keydown)===void 0&&(w==null?void 0:w.keyup)!==!0||w!=null&&w.keydown)&&t(a))},r=function(a){a.key!==void 0&&(Fw(sc(a.code)),D.current=!1,w!=null&&w.keyup&&t(a,!0))},n=Pe.current||(E==null?void 0:E.document)||document;return n.addEventListener("keyup",r),n.addEventListener("keydown",i),l&&Fg(e,w==null?void 0:w.splitKey).forEach(function(o){return l.addHotkey(Bg(o,w==null?void 0:w.combinationKey,w==null?void 0:w.description))}),function(){n.removeEventListener("keyup",r),n.removeEventListener("keydown",i),l&&Fg(e,w==null?void 0:w.splitKey).forEach(function(o){return l.removeHotkey(Bg(o,w==null?void 0:w.combinationKey,w==null?void 0:w.description))})}}},[e,w,f]),Pe}var jw={exports:{}};(function(O){(function(F){var J=o(),fe=a(),Pe=u(),D=p(),E={imagePlaceholder:void 0,cacheBust:!1},e={toSvg:_,toPng:s,toJpeg:w,toBlob:m,toPixelData:T,impl:{fontFaces:Pe,images:D,util:J,inliner:fe,options:{}}};O.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 T(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 w(c,b){return b=b||{},l(c,b).then(function(d){return d.toDataURL("image/jpeg",b.quality||1)})}function m(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(y){return x(c,y,b)}).then(function(y){return g(c,y)});function v(y){return y instanceof HTMLCanvasElement?J.makeImage(y.toDataURL()):y.cloneNode(!1)}function x(y,k,h){var M=y.childNodes;if(M.length===0)return Promise.resolve(k);return A(k,J.asArray(M),h).then(function(){return k});function A(C,L,P){var I=Promise.resolve();return L.forEach(function(R){I=I.then(function(){return t(R,P)}).then(function(U){U&&C.appendChild(U)})}),I}}function g(y,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(y),k.style);function L(P,I){P.cssText?I.cssText=P.cssText:R(P,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(P){L(P)});function L(P){var I=window.getComputedStyle(y,P),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,P,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(){y instanceof HTMLTextAreaElement&&(k.innerHTML=y.value),y instanceof HTMLInputElement&&k.setAttribute("value",y.value)}function C(){k instanceof SVGElement&&(k.setAttribute("xmlns","http://www.w3.org/2000/svg"),k instanceof SVGRectElement&&["width","height"].forEach(function(L){var P=k.getAttribute(L);P&&k.style.setProperty(L,P)}))}}}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''+v+""}).then(function(v){return''+v+""}).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:y,getAndEncode:M,uid:k(),delay:L,asArray:P,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{if(O)return i9({fileHandle:O,blob:F})},i9=async({fileHandle:O,blob:F})=>{const J=await O.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:O,is_image:F})=>{if("showSaveFilePicker"in window){const J={suggestedName:O,types:F?a9:[{description:"CSV File",accept:{"image/csv":[".csv"]}}],excludeAcceptAllOption:!0};return showSaveFilePicker(J)}return new Promise(J=>{J(null)})},ty=(O,F,J)=>{try{if(J===null)throw new Error("Cannot access filesystem");return r9({fileHandle:J,blob:O})}catch(fe){console.error("oops, something went wrong!",fe);const Pe=URL.createObjectURL(O),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(fe=>{fe(!0)})};async function Ub(O){let F=O.data,J=[],fe=[],Pe="title"in O.layout.xaxis&&O.layout.xaxis.title.text!=null?O.layout.xaxis.title.text:"x",D="title"in O.layout.yaxis&&O.layout.yaxis.title.text!=null?O.layout.yaxis.title.text:"y";return F.forEach(function(E){E.type=="candlestick"&&(J.length==0&&(J=["Date","Open","High","Low","Close"]),E.x.forEach(function(e,_){fe.push([e,E.open[_],E.high[_],E.low[_],E.close[_]])})),E.type=="scatter"&&(J.length==0&&J.push(Pe),J.push(E.name!=null?E.name:D),E.x.forEach(function(e,_){fe[_]==null&&(fe[_]=[e]),fe[_].push(E.y[_])}))}),await o9(J,fe)}async function o9(O,F){const J=O,fe=F.map(_=>_.map(T=>T==null?"":typeof T=="object"?JSON.stringify(T):T.toString().replace(/"/g,'""'))),D=[J,...fe].map(_=>_.join(",")).join(` -`),E=new Blob([D],{type:"text/csv;charset=utf-8;"}),e=`${window.title}.csv`;try{let _=await Vw({filename:e}),T="png";_!==null&&(T=_.name.split(".").pop()),await Bp(`Saving ${T.toUpperCase()}`),Np(async function(){ty(E,e,_).then(async function(){await Bp("",!0)})},2)()}catch(_){console.error(_)}}function Bp(O,F){const J=window.document.getElementById("loading"),fe=window.document.getElementById("loading_text");return new Promise(Pe=>{F?J.classList.remove("show"):(fe.innerHTML=O,J.classList.add("show"));let D=setInterval(function(){(F?!J.classList.contains("show"):J.classList.contains("show"))&&(clearInterval(D),Pe(!0))},.1)})}const Np=(O,F)=>{let J;return function(){const fe=this,Pe=arguments;clearTimeout(J),J=setTimeout(()=>O.apply(fe,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(O,F,J=!1){const fe=document.getElementById("plotlyChart");J&&(fe.layout.annotations.push(s9),fe.globals.cmd_idx!=null&&fe.globals.cmd_src!=null&&(fe.layout.annotations[fe.globals.cmd_idx].text=fe.globals.cmd_src),Gs.relayout(fe,{"title.text":fe.globals.title,margin:fe.globals.old_margin})),J||(fe.globals.cmd_idx!=null&&fe.globals.cmd_src!=null&&(fe.layout.annotations[fe.globals.cmd_idx].text=""),fe.layout.annotations.splice(F,1),Gs.relayout(fe,{"title.text":"",margin:O}))}async function Hw(O,F,J){const fe=document.getElementById(O);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(fe).then(function(Pe){ty(Pe,F,null)})},2)()}async function Hb(O,F,J){const fe=document.getElementById(O),Pe=`${window.title}.png`;try{J(!0);let D=await Vw({filename:Pe,is_image:!0}),E="png";if(D!==null&&(E=D.name.split(".").pop()),await Bp(`Saving ${E.toUpperCase()}`),["svg","pdf"].includes(E)){await Hw(O,Pe,E),F(!1),J(!1);return}Np(async function(){Uw.toBlob(fe).then(function(e){ty(e,Pe,D).then(async function(){await Bp("",!0),F(!1),J(!1)})})},2)()}catch(D){console.error(D),F(!1),J(!1)}}function rc(O=!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")&&!O?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:O,changeTheme:F,autoScaling:J,Loading:fe,changeColor:Pe}){return Ku("ctrl+shift+t",()=>{O({name:"titleDialog"})},{preventDefault:!0}),Ku("ctrl+t",()=>{O({name:"textDialog"})},{preventDefault:!0}),Ku("ctrl+o",()=>{O({name:"overlayChart"})},{preventDefault:!0}),Ku("ctrl+shift+h",()=>{rc()},{preventDefault:!0}),Ku("ctrl+e",()=>{Pe(!0)},{preventDefault:!0}),Ku("ctrl+shift+s",async()=>{O({name:"downloadCsv"}),await Ub(document.getElementById("plotlyChart"))},{preventDefault:!0}),Ku("ctrl+s",async()=>{rc(),Hb("MainChart",rc,fe)},{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)}},{name:"Download Chart as Image (Ctrl+S)",icon:Pu.downloadImage,click:async function(){rc(),await Hb("MainChart",rc,fe)}}],[{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(){O({name:"overlayChart"})}},{name:"Add Text (Ctrl+T)",icon:Pu.addText,click:function(){O({name:"textDialog",data:{text:""}})}},{name:"Change Titles (Ctrl+Shift+T)",icon:Pu.changeTitle,click:function(){O({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(O,F){try{if(O["xaxis.range[0]"]!=null){const J=O["xaxis.range[0]"],fe=O["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"))],T=s=>F.data.filter(w=>w.yaxis==s&&(w.y||w.type=="candlestick"));return _.forEach(s=>{if(typeof s!="string")return;let w="yaxis"+s.replace("y",""),m=[],f=[],l=F.layout[w].type=="log";T(s).forEach(r=>{let n=r.x;l=F.layout[w].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<=fe&&(r.y!=null&&(console.log(r.name,r.type,r.yaxis),d=o[b]),r.type=="candlestick"&&(m.push(a[b]),m.push(u[b]))),d});f=f.concat(p)}),f=f.filter(r=>r!=null&&r!=null),D=Math.min(...f),E=Math.max(...f),m.length>0&&(m=m.filter(r=>r!=null&&r!=null),D=Math.min(...m),E=Math.max(...m));let t=E,i=F.layout[w].fixedrange!=null&&F.layout[w].fixedrange==!0;if(D!=null&&E!=null){let r=E-D,n=.15;if(m.length>0&&(n=.3),D-=r*n,E+=r*n,i){if(F.layout[w].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;xc[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[w+".tickvals"]=d,Pe[w+".range"]=v,Pe[w+".tickformat"]=".2s";return}D=0,E=F.layout[w].range[1]}Pe[w+".range"]=[D,E]}}),Pe}}catch(J){console.log(`Error in AutoScaling: ${J}`)}return{}}async function c9({plotData:O,volumeBars:F,setMaximizePlot:J}){const fe=Object.keys(O.layout).filter(s=>s.startsWith("xaxis")).filter(s=>O.layout[s].showticklabels),Pe=O.data.filter(s=>{var w;return(w=s==null?void 0:s.name)==null?void 0:w.startsWith("Volume")});let D={},E=F||{old_nticks:{}};const e=window.innerWidth,_=window.innerHeight;let T=_>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"]=T,E.tickfont=O.layout[E.yaxis].tickfont||{},O.layout.margin.l-=40))}),fe.forEach(s=>{var w;((w=E.old_nticks)==null?void 0:w[s])==null&&(D[s+".nticks"]=6,E.old_nticks[s]=O.layout[s].nticks||10)}),J(!0),await rc()):window.MODEBAR.style.cssText.includes("display: none")&&(await rc(!1),J(!1),F.old_nticks!=null&&fe.forEach(s=>{E.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,O.layout.margin.l+=40,E.yaxis=void 0)})),{volume_update:E,layout_update:D,plotData:O}}function f9({open:O,onColorChange:F}){const[J,fe]=Un.useState(!1);function Pe(D){F(D)}return O&&!J&&fe(!0),!O&&J&&fe(!1),Un.useEffect(()=>{if(J){let D=function(e){let _=0,T=0,s=0,w=0;document.getElementById(e.id+"_header")?document.getElementById(e.id+"_header").onmousedown=m:e.onmousedown=m;function m(t){t=t||window.event,t.preventDefault(),s=t.clientX,w=t.clientY,document.onmouseup=l,document.onmousemove=f}function f(t){t=t||window.event,t.preventDefault(),_=s-t.clientX,T=w-t.clientY,s=t.clientX,w=t.clientY,e.style.top=e.offsetTop-T+"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]),Ar("div",{id:"changecolor",children:Ar("div",{id:"changecolor_header",children:Ar("input",{type:"color",id:"picked_color",value:"#00ACFF",onChange:D=>{let E=D.target.value;Pe(E)}})})})}function qw(O){var F,J,fe="";if(typeof O=="string"||typeof O=="number")fe+=O;else if(typeof O=="object")if(Array.isArray(O))for(F=0;F{E&&E.capture("chart",D)},[]),delete O.layout.width,delete O.layout.height,O.layout.title.text="";const[e,_]=Un.useState({}),[T,s]=Un.useState(!1),[w,m]=Un.useState(fe),[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(O),[y,k]=Un.useState([]),[h,M]=Un.useState(!1),[A,C]=Un.useState(!0),[L,P]=Un.useState(!1),[I,R]=Un.useState(!1),[U,B]=Un.useState(!1),[G,N]=Un.useState({}),[j,V]=Un.useState([]),H=()=>n({name:""});function ee(re){var se,ce,ye,he,de;console.log("onDeleteAnnotation",re);const oe=(ce=(se=x==null?void 0:x.layout)==null?void 0:se.annotations)==null?void 0:ce.findIndex(pe=>pe.text===re.text);console.log("index",oe),oe>-1&&((he=(ye=x==null?void 0:x.layout)==null?void 0:ye.annotations)==null||he.splice(oe,1),g({...x}),k((de=x==null?void 0:x.layout)==null?void 0:de.annotations))}function Q(re){U7({plotData:x,popupData:re,setPlotData:g,setModal:n,setOnAnnotationClick:N,setAnnotations:k,onAnnotationClick:G,ohlcAnnotation:j,setOhlcAnnotation:V,annotations:y,plotDiv:u})}Un.useEffect(()=>{f&&Object.keys(f).length>0&&(Object.keys(f).forEach(re=>{x.layout[re].title={...x.layout[re].title||{},text:f[re]},x.layout[re].showticklabels=!0}),l({}))},[f]);function X(re){let oe=u.layout.shapes;if(!oe||oe.length==0)return;let se=oe[oe.length-1];se.line.color=re,Gs.update(u,{},{shapes:oe})}function Y(re,oe=!1){let se=e[re]||document.querySelector(`[data-title="${re}"]`);oe?(se.style.border="transparent",se.style.boxShadow="none"):(se.style.border="1px solid rgba(0, 151, 222, 1.0)",se.style.borderRadius="5px",se.style.borderpadding="5px",se.style.boxShadow="0 0 5px rgba(0, 151, 222, 1.0)"),_({...e,[re]:se})}function K(){let re="Auto Scale (Ctrl+Shift+A)",oe=e[re]||document.querySelector(`[data-title="${re}"]`),se=!0;oe.style.border=="transparent"?(se=!1,u.on("plotly_relayout",Np(async function(ce){if(ce["xaxis.range[0]"]==null)return;let ye=await u9(ce,u);Gs.update(u,{},ye)},100))):u.removeAllListeners("plotly_relayout"),Y(re,se)}function te(){let re="Edit Color (Ctrl+E)",oe=e[re]||document.querySelector(`[data-title="${re}"]`),se=!0;oe.style.border=="transparent"&&(se=!1),B(!se),Y(re,se)}return Un.useEffect(()=>{L&&(console.log("activateAutoScale",!L),K(),P(!1))},[L]),Un.useEffect(()=>{I&&(te(),R(!1))},[I]),Un.useEffect(()=>{if(h)try{console.log("changeTheme",h);const re=x==null?void 0:x.data.filter(ye=>{var he;return(he=ye==null?void 0:ye.name)==null?void 0:he.startsWith("Volume")});let oe=!A;window.document.body.style.backgroundColor=oe?"#000":"#fff",x.layout.font={...x.layout.font||{},color:oe?"#fff":"#000"};const se=oe?Pu.sunIcon:Pu.moonIcon;document.querySelector('[data-title="Change Theme"]').getElementsByTagName("path")[0].setAttribute("d",se.path),document.querySelector('[data-title="Change Theme"]').getElementsByTagName("svg")[0].setAttribute("viewBox",se.viewBox);const ce={"#e4003a":"#c80000","#00ACFF":"#009600","#009600":"#00ACFF","#c80000":"#e4003a"};re.forEach(ye=>{ye.type=="bar"&&(ye.marker.color=ye.marker.color.map(he=>ce[he]||he))}),x.layout.template=oe?ek:tk,g({...x}),Gs.react(u,x.data,x.layout),C(oe),M(!1)}catch(re){console.log("error",re)}},[h]),Un.useEffect(()=>{if(t){C(!0),P(!1);const re=["Download CSV","Download Chart as Image","Overlay chart from CSV","Add Text","Change Titles","Auto Scale (Ctrl+Shift+A)","Reset Axes"],oe=document.querySelector('[data-title="Autoscale"]');oe&&(oe.getElementsByTagName("path")[0].setAttribute("d",Gs.Icons.home.path),oe.setAttribute("data-title","Reset Axes")),window.MODEBAR=document.getElementsByClassName("modebar-container")[0];const se=window.MODEBAR.getElementsByClassName("modebar-btn");if(window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`,se){let ce={};for(let ye=0;ye0&&(g(he),b(de),Gs.relayout(u,ye))})}},[t]),ri("div",{className:"relative h-full",children:[o&&Ar("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ri("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Ar("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ar("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})}),Ar(D7,{addOverlay:re=>{console.log(re),x.layout.showlegend=!0,g(re),i(!1)},plotlyData:x,setLoading:a,open:r.name==="overlayChart",close:H}),Ar(B7,{updateTitle:re=>m(re),updateAxesTitles:re=>l(re),defaultTitle:w,plotlyData:x,open:r.name==="titleDialog",close:H}),Ar(N7,{popupData:r.name==="textDialog"?r==null?void 0:r.data:null,open:r.name==="textDialog",close:H,addAnnotation:re=>Q(re),deleteAnnotation:re=>ee(re)}),Ar(f9,{open:U,onColorChange:X}),ri("div",{className:"relative h-full",id:"MainChart",children:[ri("div",{className:"_header relative gap-4 py-2 text-center text-xs flex items-center justify-between px-4 text-white",children:[Ar("div",{className:"w-1/3",children:Ar("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"40",fill:"none",viewBox:"0 0 64 40",children:Ar("path",{fill:"#fff",d:"M61.283 3.965H33.608v27.757h25.699V19.826H37.561v-3.965H63.26V3.965h-1.977zM39.538 23.792h15.815v3.965H37.561v-3.965h1.977zM59.306 9.913v1.983H37.561V7.931h21.745v1.982zM33.606 0h-3.954v3.965H33.606V0zM25.7 3.966H0V15.86h25.7v3.965H3.953v11.896h25.7V3.966h-3.955zm0 21.808v1.983H7.907v-3.965h17.791v1.982zm0-15.86v1.982H3.953V7.931h21.745v1.982zM37.039 35.693v2.952l-.246-.246-.245-.245-.245-.247-.245-.246-.246-.246-.245-.245-.245-.247-.247-.246-.245-.246-.245-.246-.245-.246-.246-.246h-.49v3.936h.49v-3.198l.246.246.245.246.245.246.245.246.246.246.246.246.245.247.246.245.245.246.245.247.245.246.246.245.245.246h.245v-3.936h-.49zM44.938 37.17h-.491v-1.477h-2.944v3.937h3.93v-2.46h-.495zm-2.944-.246v-.739h1.962v.984h-1.962v-.245zm2.944.984v1.23h-2.944V37.66h2.944v.247zM52.835 37.17h-.49v-1.477h-2.946v3.937h3.925v-2.46h-.489zm-2.944-.246v-.739h1.963v.984h-1.965l.002-.245zm2.944.984v1.23H49.89V37.66h2.946v.247zM29.174 35.693H25.739v3.936H29.663v-.491H26.229v-.984h2.943v-.493H26.229v-1.476h3.434v-.492h-.489zM13.37 35.693H9.934v3.937h3.925v-3.937h-.49zm0 .738v2.709h-2.945v-2.955h2.943l.001.246zM21.276 35.693h-3.435v3.937h.491v-1.476h3.434v-2.461h-.49zm0 .738v1.23h-2.944v-1.476h2.944v.246z"})})}),Ar("p",{className:"font-bold w-1/3 flex flex-col gap-0.5 items-center",children:w}),ri("p",{className:"w-1/3 text-right text-xs",children:[new Intl.DateTimeFormat("en-GB",{dateStyle:"full",timeStyle:"long"}).format(F).replace(/:\d\d /," "),Ar("br",{}),Ar("span",{className:"text-grey-400",children:J})]})]}),Ar("div",{className:h9("w-full sm:pb-12",{"h-[calc(100%-10px)]":d,"h-[calc(100%-50px)]":!d}),children:Ar(p9,{onInitialized:()=>{if(!u){const re=document.getElementById("plotlyChart");console.log("plot",re),re&&p(re),re.globals=Pe}t||i(!0)},className:"w-full h-full",divId:"plotlyChart",data:x.data,layout:x.layout,config:l9({setModal:n,changeTheme:M,autoScaling:P,Loading:a,changeColor:R})})})]})]})}function g9(){const[O,F]=Un.useState(null),[J,fe]=Un.useState({});Un.useEffect(()=>{{const E=setInterval(()=>{if(window.plotly_figure){const e=window.plotly_figure;console.log(e),F(e),clearInterval(E)}},100);return()=>clearInterval(E)}},[]);const D=(E=>{var m,f,l,t;if(!E)return null;let e={added_traces:[],csv_yaxis_id:null,cmd_src_idx:null,cmd_idx:null,cmd_src:"",old_margin:null,title:""},_=(f=(m=E.layout)==null?void 0:m.title)==null?void 0:f.text.replace(/|<\/b>/g,"").replace(/ /g,"_"),T=new Date().toISOString().slice(0,10).replace(/-/g,""),s=new Date().toISOString().slice(11,19).replace(/:/g,"");window.title=`openbb_${_}_${T}_${s}`,window.export_image!=null&&(_=window.export_image.split("/").pop(),_.split(".").pop().replace("jpg","jpeg")),E.layout.annotations!=null&&E.layout.annotations.forEach(function(i){if(i.text!=null&&i.text[0]=="/"){e.cmd_src=i.text,e.cmd_idx=E.layout.annotations.indexOf(i),i.text="";let r=E.layout.margin;e.old_margin={...r},r.t!=null&&r.t>40&&(r.t=40),r.l=70,E.cmd=="/stocks/candle"&&(r.r-=40)}});let w=(t=(l=E.layout)==null?void 0:l.title)==null?void 0:t.text;return e.title=w,{data:E,date:new Date,globals:e,cmd:E.command_location,posthog:E.posthog,python_version:E.python_version,pywry_version:E.pywry_version,terminal_version:E.terminal_version,title:w}})(O);if(D){D.posthog.collect_logs&&!J&&fe({api_host:"https://app.posthog.com",autocapture:{css_selector_allowlist:[".ph-capture"]},capture_pageview:!1,loaded:function(T){const s=(D==null?void 0:D.log_id)||"";s!=""&&s!="REPLACE_ME"&&T.identify(s),T.onFeatureFlags(function(){T.isFeatureEnabled("record-pywry",{send_event:!1})||T.stopSessionRecording(),T.isFeatureEnabled("collect-logs-pywry",{send_event:!1})?T.has_opted_out_capturing()&&T.opt_in_capturing():T.opt_out_capturing()})}});const E={INFO:{command:D.cmd,title:D.title,date:D.date,python_version:D.python_version,pywry_version:D.pywry_version,terminal_version:D.terminal_version}},e=Ar(d9,{json:D.data,date:D.date,cmd:D.cmd,title:D.title,globals:D.globals,info:E});return D.posthog.collect_logs&&J?Ar(qT,{apiKey:"phc_vhssDAMod5qIplznQ75Kdgz4aB1qPFmeVmfEOZ4hkRw",options:J,children:e}):e}else return Ar("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ri("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Ar("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ar("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})})}z8.render(Ar(s_.StrictMode,{children:Ar(g9,{})}),document.getElementById("root")); +`),E=new Blob([D],{type:"text/csv;charset=utf-8;"}),e=`${window.title}.csv`;try{let _=await Vw({filename:e});await Bp("Saving CSV"),await new Promise(T=>setTimeout(T,1500)),Np(async function(){ty(E,e,_).then(async function(){await Bp("",!0)})},2)()}catch(_){console.error(_)}}function Bp(O,F){const J=window.document.getElementById("loading"),fe=window.document.getElementById("loading_text");return new Promise(Pe=>{F?J.classList.remove("show"):(fe.innerHTML=O,J.classList.add("show"));let D=setInterval(function(){(F?!J.classList.contains("show"):J.classList.contains("show"))&&(clearInterval(D),Pe(!0))},.3)})}const Np=(O,F)=>{let J;return function(){const fe=this,Pe=arguments;clearTimeout(J),J=setTimeout(()=>O.apply(fe,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(O,F,J=!1){const fe=document.getElementById("plotlyChart");J&&(fe.layout.annotations.push(s9),fe.globals.cmd_idx!=null&&fe.globals.cmd_src!=null&&(fe.layout.annotations[fe.globals.cmd_idx].text=fe.globals.cmd_src),Gs.relayout(fe,{"title.text":fe.globals.title,margin:fe.globals.old_margin})),J||(fe.globals.cmd_idx!=null&&fe.globals.cmd_src!=null&&(fe.layout.annotations[fe.globals.cmd_idx].text=""),fe.layout.annotations.splice(F,1),Gs.relayout(fe,{"title.text":"",margin:O}))}async function Hw(O,F,J){const fe=document.getElementById(O);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(fe).then(function(Pe){ty(Pe,F,null)})},2)()}async function Hb(O,F,J){const fe=document.getElementById(O),Pe=`${window.title}.png`;try{J(!0);let D=await Vw({filename:Pe,is_image:!0}),E="png";if(D!==null&&(E=D.name.split(".").pop()),await Bp(`Saving ${E.toUpperCase()}`),["svg","pdf"].includes(E)){await Hw(O,Pe,E),F(!1),J(!1);return}Np(async function(){Uw.toBlob(fe).then(function(e){ty(e,Pe,D).then(async function(){await Bp("",!0),F(!1),J(!1)})})},2)()}catch(D){console.error(D),F(!1),J(!1)}}function rc(O=!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")&&!O?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:O,changeTheme:F,autoScaling:J,Loading:fe,changeColor:Pe}){return Ku("ctrl+shift+t",()=>{O({name:"titleDialog"})},{preventDefault:!0}),Ku("ctrl+t",()=>{O({name:"textDialog"})},{preventDefault:!0}),Ku("ctrl+o",()=>{O({name:"overlayChart"})},{preventDefault:!0}),Ku("ctrl+shift+h",()=>{rc()},{preventDefault:!0}),Ku("ctrl+e",()=>{Pe(!0)},{preventDefault:!0}),Ku("ctrl+shift+s",async()=>{O({name:"downloadCsv"}),await Ub(document.getElementById("plotlyChart"))},{preventDefault:!0}),Ku("ctrl+s",async()=>{rc(),Hb("MainChart",rc,fe)},{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)}},{name:"Download Chart as Image (Ctrl+S)",icon:Pu.downloadImage,click:async function(){rc(),await Hb("MainChart",rc,fe)}}],[{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(){O({name:"overlayChart"})}},{name:"Add Text (Ctrl+T)",icon:Pu.addText,click:function(){O({name:"textDialog",data:{text:""}})}},{name:"Change Titles (Ctrl+Shift+T)",icon:Pu.changeTitle,click:function(){O({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(O,F){try{if(O["xaxis.range[0]"]!=null){const J=O["xaxis.range[0]"],fe=O["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"))],T=s=>F.data.filter(w=>w.yaxis==s&&(w.y||w.type=="candlestick"));return _.forEach(s=>{if(typeof s!="string")return;let w="yaxis"+s.replace("y",""),m=[],f=[],l=F.layout[w].type=="log";T(s).forEach(r=>{let n=r.x;l=F.layout[w].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<=fe&&(r.y!=null&&(console.log(r.name,r.type,r.yaxis),d=o[b]),r.type=="candlestick"&&(m.push(a[b]),m.push(u[b]))),d});f=f.concat(p)}),f=f.filter(r=>r!=null&&r!=null),D=Math.min(...f),E=Math.max(...f),m.length>0&&(m=m.filter(r=>r!=null&&r!=null),D=Math.min(...m),E=Math.max(...m));let t=E,i=F.layout[w].fixedrange!=null&&F.layout[w].fixedrange==!0;if(D!=null&&E!=null){let r=E-D,n=.15;if(m.length>0&&(n=.3),D-=r*n,E+=r*n,i){if(F.layout[w].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;xc[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[w+".tickvals"]=d,Pe[w+".range"]=v,Pe[w+".tickformat"]=".2s";return}D=0,E=F.layout[w].range[1]}Pe[w+".range"]=[D,E]}}),Pe}}catch(J){console.log(`Error in AutoScaling: ${J}`)}return{}}async function c9({plotData:O,volumeBars:F,setMaximizePlot:J}){const fe=Object.keys(O.layout).filter(s=>s.startsWith("xaxis")).filter(s=>O.layout[s].showticklabels),Pe=O.data.filter(s=>{var w;return(w=s==null?void 0:s.name)==null?void 0:w.startsWith("Volume")});let D={},E=F||{old_nticks:{}};const e=window.innerWidth,_=window.innerHeight;let T=_>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"]=T,E.tickfont=O.layout[E.yaxis].tickfont||{},O.layout.margin.l-=40))}),fe.forEach(s=>{var w;((w=E.old_nticks)==null?void 0:w[s])==null&&(D[s+".nticks"]=6,E.old_nticks[s]=O.layout[s].nticks||10)}),J(!0),await rc()):window.MODEBAR.style.cssText.includes("display: none")&&(await rc(!1),J(!1),F.old_nticks!=null&&fe.forEach(s=>{E.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,O.layout.margin.l+=40,E.yaxis=void 0)})),{volume_update:E,layout_update:D,plotData:O}}function f9({open:O,onColorChange:F}){const[J,fe]=Un.useState(!1);function Pe(D){F(D)}return O&&!J&&fe(!0),!O&&J&&fe(!1),Un.useEffect(()=>{if(J){let D=function(e){let _=0,T=0,s=0,w=0;document.getElementById(e.id+"_header")?document.getElementById(e.id+"_header").onmousedown=m:e.onmousedown=m;function m(t){t=t||window.event,t.preventDefault(),s=t.clientX,w=t.clientY,document.onmouseup=l,document.onmousemove=f}function f(t){t=t||window.event,t.preventDefault(),_=s-t.clientX,T=w-t.clientY,s=t.clientX,w=t.clientY,e.style.top=e.offsetTop-T+"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]),Ar("div",{id:"changecolor",children:Ar("div",{id:"changecolor_header",children:Ar("input",{type:"color",id:"picked_color",value:"#00ACFF",onChange:D=>{let E=D.target.value;Pe(E)}})})})}function qw(O){var F,J,fe="";if(typeof O=="string"||typeof O=="number")fe+=O;else if(typeof O=="object")if(Array.isArray(O))for(F=0;F{E&&E.capture("chart",D)},[]),delete O.layout.width,delete O.layout.height,O.layout.title.text="";const[e,_]=Un.useState({}),[T,s]=Un.useState(!1),[w,m]=Un.useState(fe),[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(O),[y,k]=Un.useState([]),[h,M]=Un.useState(!1),[A,C]=Un.useState(!0),[L,P]=Un.useState(!1),[I,R]=Un.useState(!1),[U,B]=Un.useState(!1),[G,N]=Un.useState({}),[j,V]=Un.useState([]),H=()=>n({name:""});function ee(re){var se,ce,ye,he,de;console.log("onDeleteAnnotation",re);const oe=(ce=(se=x==null?void 0:x.layout)==null?void 0:se.annotations)==null?void 0:ce.findIndex(pe=>pe.text===re.text);console.log("index",oe),oe>-1&&((he=(ye=x==null?void 0:x.layout)==null?void 0:ye.annotations)==null||he.splice(oe,1),g({...x}),k((de=x==null?void 0:x.layout)==null?void 0:de.annotations))}function Q(re){U7({plotData:x,popupData:re,setPlotData:g,setModal:n,setOnAnnotationClick:N,setAnnotations:k,onAnnotationClick:G,ohlcAnnotation:j,setOhlcAnnotation:V,annotations:y,plotDiv:u})}Un.useEffect(()=>{f&&Object.keys(f).length>0&&(Object.keys(f).forEach(re=>{x.layout[re].title={...x.layout[re].title||{},text:f[re]},x.layout[re].showticklabels=!0}),l({}))},[f]);function X(re){let oe=u.layout.shapes;if(!oe||oe.length==0)return;let se=oe[oe.length-1];se.line.color=re,Gs.update(u,{},{shapes:oe})}function Y(re,oe=!1){let se=e[re]||document.querySelector(`[data-title="${re}"]`);oe?(se.style.border="transparent",se.style.boxShadow="none"):(se.style.border="1px solid rgba(0, 151, 222, 1.0)",se.style.borderRadius="5px",se.style.borderpadding="5px",se.style.boxShadow="0 0 5px rgba(0, 151, 222, 1.0)"),_({...e,[re]:se})}function K(){let re="Auto Scale (Ctrl+Shift+A)",oe=e[re]||document.querySelector(`[data-title="${re}"]`),se=!0;oe.style.border=="transparent"?(se=!1,u.on("plotly_relayout",Np(async function(ce){if(ce["xaxis.range[0]"]==null)return;let ye=await u9(ce,u);Gs.update(u,{},ye)},100))):u.removeAllListeners("plotly_relayout"),Y(re,se)}function te(){let re="Edit Color (Ctrl+E)",oe=e[re]||document.querySelector(`[data-title="${re}"]`),se=!0;oe.style.border=="transparent"&&(se=!1),B(!se),Y(re,se)}return Un.useEffect(()=>{L&&(console.log("activateAutoScale",!L),K(),P(!1))},[L]),Un.useEffect(()=>{I&&(te(),R(!1))},[I]),Un.useEffect(()=>{if(h)try{console.log("changeTheme",h);const re=x==null?void 0:x.data.filter(ye=>{var he;return(he=ye==null?void 0:ye.name)==null?void 0:he.startsWith("Volume")});let oe=!A;window.document.body.style.backgroundColor=oe?"#000":"#fff",x.layout.font={...x.layout.font||{},color:oe?"#fff":"#000"};const se=oe?Pu.sunIcon:Pu.moonIcon;document.querySelector('[data-title="Change Theme"]').getElementsByTagName("path")[0].setAttribute("d",se.path),document.querySelector('[data-title="Change Theme"]').getElementsByTagName("svg")[0].setAttribute("viewBox",se.viewBox);const ce={"#e4003a":"#c80000","#00ACFF":"#009600","#009600":"#00ACFF","#c80000":"#e4003a"};re.forEach(ye=>{ye.type=="bar"&&(ye.marker.color=ye.marker.color.map(he=>ce[he]||he))}),x.layout.template=oe?ek:tk,g({...x}),Gs.react(u,x.data,x.layout),C(oe),M(!1)}catch(re){console.log("error",re)}},[h]),Un.useEffect(()=>{if(t){C(!0),P(!1);const re=["Download CSV","Download Chart as Image","Overlay chart from CSV","Add Text","Change Titles","Auto Scale (Ctrl+Shift+A)","Reset Axes"],oe=document.querySelector('[data-title="Autoscale"]');oe&&(oe.getElementsByTagName("path")[0].setAttribute("d",Gs.Icons.home.path),oe.setAttribute("data-title","Reset Axes")),window.MODEBAR=document.getElementsByClassName("modebar-container")[0];const se=window.MODEBAR.getElementsByClassName("modebar-btn");if(window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`,se){let ce={};for(let ye=0;ye0&&(g(he),b(de),Gs.relayout(u,ye))})}},[t]),ri("div",{className:"relative h-full",children:[o&&Ar("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ri("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Ar("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ar("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})}),Ar(D7,{addOverlay:re=>{console.log(re),x.layout.showlegend=!0,g(re),i(!1)},plotlyData:x,setLoading:a,open:r.name==="overlayChart",close:H}),Ar(B7,{updateTitle:re=>m(re),updateAxesTitles:re=>l(re),defaultTitle:w,plotlyData:x,open:r.name==="titleDialog",close:H}),Ar(N7,{popupData:r.name==="textDialog"?r==null?void 0:r.data:null,open:r.name==="textDialog",close:H,addAnnotation:re=>Q(re),deleteAnnotation:re=>ee(re)}),Ar(f9,{open:U,onColorChange:X}),ri("div",{className:"relative h-full",id:"MainChart",children:[ri("div",{className:"_header relative gap-4 py-2 text-center text-xs flex items-center justify-between px-4 text-white",children:[Ar("div",{className:"w-1/3",children:Ar("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"40",fill:"none",viewBox:"0 0 64 40",children:Ar("path",{fill:"#fff",d:"M61.283 3.965H33.608v27.757h25.699V19.826H37.561v-3.965H63.26V3.965h-1.977zM39.538 23.792h15.815v3.965H37.561v-3.965h1.977zM59.306 9.913v1.983H37.561V7.931h21.745v1.982zM33.606 0h-3.954v3.965H33.606V0zM25.7 3.966H0V15.86h25.7v3.965H3.953v11.896h25.7V3.966h-3.955zm0 21.808v1.983H7.907v-3.965h17.791v1.982zm0-15.86v1.982H3.953V7.931h21.745v1.982zM37.039 35.693v2.952l-.246-.246-.245-.245-.245-.247-.245-.246-.246-.246-.245-.245-.245-.247-.247-.246-.245-.246-.245-.246-.245-.246-.246-.246h-.49v3.936h.49v-3.198l.246.246.245.246.245.246.245.246.246.246.246.246.245.247.246.245.245.246.245.247.245.246.246.245.245.246h.245v-3.936h-.49zM44.938 37.17h-.491v-1.477h-2.944v3.937h3.93v-2.46h-.495zm-2.944-.246v-.739h1.962v.984h-1.962v-.245zm2.944.984v1.23h-2.944V37.66h2.944v.247zM52.835 37.17h-.49v-1.477h-2.946v3.937h3.925v-2.46h-.489zm-2.944-.246v-.739h1.963v.984h-1.965l.002-.245zm2.944.984v1.23H49.89V37.66h2.946v.247zM29.174 35.693H25.739v3.936H29.663v-.491H26.229v-.984h2.943v-.493H26.229v-1.476h3.434v-.492h-.489zM13.37 35.693H9.934v3.937h3.925v-3.937h-.49zm0 .738v2.709h-2.945v-2.955h2.943l.001.246zM21.276 35.693h-3.435v3.937h.491v-1.476h3.434v-2.461h-.49zm0 .738v1.23h-2.944v-1.476h2.944v.246z"})})}),Ar("p",{className:"font-bold w-1/3 flex flex-col gap-0.5 items-center",children:w}),ri("p",{className:"w-1/3 text-right text-xs",children:[new Intl.DateTimeFormat("en-GB",{dateStyle:"full",timeStyle:"long"}).format(F).replace(/:\d\d /," "),Ar("br",{}),Ar("span",{className:"text-grey-400",children:J})]})]}),Ar("div",{className:h9("w-full sm:pb-12",{"h-[calc(100%-10px)]":d,"h-[calc(100%-50px)]":!d}),children:Ar(p9,{onInitialized:()=>{if(!u){const re=document.getElementById("plotlyChart");console.log("plot",re),re&&p(re),re.globals=Pe}t||i(!0)},className:"w-full h-full",divId:"plotlyChart",data:x.data,layout:x.layout,config:l9({setModal:n,changeTheme:M,autoScaling:P,Loading:a,changeColor:R})})})]})]})}function g9(){const[O,F]=Un.useState(null),[J,fe]=Un.useState({});Un.useEffect(()=>{{const E=setInterval(()=>{if(window.plotly_figure){const e=window.plotly_figure;console.log(e),F(e),clearInterval(E)}},100);return()=>clearInterval(E)}},[]);const D=(E=>{var m,f,l,t;if(!E)return null;let e={added_traces:[],csv_yaxis_id:null,cmd_src_idx:null,cmd_idx:null,cmd_src:"",old_margin:null,title:""},_=(f=(m=E.layout)==null?void 0:m.title)==null?void 0:f.text.replace(/|<\/b>/g,"").replace(/ /g,"_"),T=new Date().toISOString().slice(0,10).replace(/-/g,""),s=new Date().toISOString().slice(11,19).replace(/:/g,"");window.title=`openbb_${_}_${T}_${s}`,window.export_image!=null&&(_=window.export_image.split("/").pop(),_.split(".").pop().replace("jpg","jpeg")),E.layout.annotations!=null&&E.layout.annotations.forEach(function(i){if(i.text!=null&&i.text[0]=="/"){e.cmd_src=i.text,e.cmd_idx=E.layout.annotations.indexOf(i),i.text="";let r=E.layout.margin;e.old_margin={...r},r.t!=null&&r.t>40&&(r.t=40),r.l=70,E.cmd=="/stocks/candle"&&(r.r-=40)}});let w=(t=(l=E.layout)==null?void 0:l.title)==null?void 0:t.text;return e.title=w,{data:E,date:new Date,globals:e,cmd:E.command_location,posthog:E.posthog,python_version:E.python_version,pywry_version:E.pywry_version,terminal_version:E.terminal_version,title:w}})(O);if(D){D.posthog.collect_logs&&!J&&fe({api_host:"https://app.posthog.com",autocapture:{css_selector_allowlist:[".ph-capture"]},capture_pageview:!1,loaded:function(T){const s=(D==null?void 0:D.log_id)||"";s!=""&&s!="REPLACE_ME"&&T.identify(s),T.onFeatureFlags(function(){T.isFeatureEnabled("record-pywry",{send_event:!1})||T.stopSessionRecording(),T.isFeatureEnabled("collect-logs-pywry",{send_event:!1})?T.has_opted_out_capturing()&&T.opt_in_capturing():T.opt_out_capturing()})}});const E={INFO:{command:D.cmd,title:D.title,date:D.date,python_version:D.python_version,pywry_version:D.pywry_version,terminal_version:D.terminal_version}},e=Ar(d9,{json:D.data,date:D.date,cmd:D.cmd,title:D.title,globals:D.globals,info:E});return D.posthog.collect_logs&&J?Ar(qT,{apiKey:"phc_vhssDAMod5qIplznQ75Kdgz4aB1qPFmeVmfEOZ4hkRw",options:J,children:e}):e}else return Ar("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ri("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Ar("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ar("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})})}z8.render(Ar(s_.StrictMode,{children:Ar(g9,{})}),document.getElementById("root"));