@luxalgo/vela 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DataProvider-Bu9E5Zh5.d.ts → DataProvider-BALR0qPq.d.ts} +1 -1
- package/dist/{DataProvider-Ck2qyS_9.d.cts → DataProvider-D5uMiJYz.d.cts} +1 -1
- package/dist/{chunk-IFJJPXSV.js → chunk-BFA32GOU.js} +44 -16
- package/dist/{chunk-CZRNTHD6.js → chunk-BKHSQ4YM.js} +129 -125
- package/dist/{chunk-A4G64KVF.js → chunk-PTNO3YK2.js} +311 -111
- package/dist/{chunk-A347YL2P.js → chunk-QBWLINWL.js} +67 -9
- package/dist/{chunk-UHXG5J7C.js → chunk-ZADTVRUO.js} +1 -1
- package/dist/{contributions-BjQ7hyIx.d.ts → contributions-BbhbZd3c.d.ts} +31 -9
- package/dist/{contributions-Cv2Mutvn.d.cts → contributions-CcBFe-91.d.cts} +31 -9
- package/dist/index.cjs +391 -157
- package/dist/index.d.cts +52 -17
- package/dist/index.d.ts +52 -17
- package/dist/index.js +4 -4
- package/dist/{options-ex2_gtKp.d.ts → options-C7b_Qssu.d.cts} +42 -1
- package/dist/{options-ex2_gtKp.d.cts → options-C7b_Qssu.d.ts} +42 -1
- package/dist/{plugin-CiyhU7pi.d.ts → plugin-Cnix5ZBh.d.ts} +6 -4
- package/dist/{plugin-absNH7Yn.d.cts → plugin-D6MlX4--.d.cts} +6 -4
- package/dist/plugin.cjs +39 -15
- package/dist/plugin.d.cts +4 -4
- package/dist/plugin.d.ts +4 -4
- package/dist/plugin.js +2 -2
- package/dist/providers/binance.d.cts +2 -2
- package/dist/providers/binance.d.ts +2 -2
- package/dist/providers/coinbase.d.cts +2 -2
- package/dist/providers/coinbase.d.ts +2 -2
- package/dist/providers/hyperliquid.d.cts +2 -2
- package/dist/providers/hyperliquid.d.ts +2 -2
- package/dist/{statusline-model-BXoU4Kua.d.ts → statusline-model-D8NL7o4L.d.ts} +3 -3
- package/dist/{statusline-model-cRhPBLPO.d.cts → statusline-model-DUKt7_TQ.d.cts} +3 -3
- package/dist/ui.cjs +8 -4
- package/dist/ui.d.cts +10 -7
- package/dist/ui.d.ts +10 -7
- package/dist/ui.js +2 -2
- package/dist/vela.global.js +391 -157
- package/dist/vela.global.min.js +70 -70
- package/dist/widget.cjs +418 -128
- package/dist/widget.d.cts +6 -6
- package/dist/widget.d.ts +6 -6
- package/dist/widget.js +6 -6
- package/dist/workspace.cjs +418 -128
- package/dist/workspace.d.cts +39 -6
- package/dist/workspace.d.ts +39 -6
- package/dist/workspace.js +5 -5
- package/package.json +1 -1
- /package/dist/{chunk-FE6V2YAQ.js → chunk-JU4CWEBF.js} +0 -0
package/dist/vela.global.min.js
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
var Vela=(function(exports){'use strict';function Vt(r,e,t=1e3){return r===true?e:typeof r!="number"||!Number.isFinite(r)||r<=0?0:Math.min(r,t)}function wu(r){return Vt(r,90,1e3)}function xu(r){let e={style:false,duration:0};if(r===true)return {style:"settle",duration:650};if(r==="settle"||r==="grow")return {style:r,duration:650};if(r&&typeof r=="object"){let t=r,n=t.duration;return {style:t.style==="grow"?"grow":"settle",duration:typeof n=="number"&&Number.isFinite(n)&&n>0?Math.min(n,5e3):650}}return e}function Hp(r){if(r===false)return {animZoom:0,animPan:0,animScroll:0,animAutoscale:0,animLiveBar:0,animIntro:{style:false,duration:0}};let e=r===true||r==null?{}:r,t=Vt(e.pan??true,110);return {animZoom:Vt(e.zoom??true,70),animPan:t,animScroll:e.scroll===void 0?t>0?130:0:Vt(e.scroll,130),animAutoscale:Vt(e.autoscale??true,80),animLiveBar:wu(e.liveBar),animIntro:xu(e.intro??true)}}function Fe(r){return r.kind!=="candle"&&r.kind!=="bar"&&r.kind!=="markers"}var Qn=class{constructor(){this.handlers=new Map;}on(e,t){let n=this.handlers.get(e);n||(n=new Set,this.handlers.set(e,n));let i=n;return i.add(t),()=>{i.delete(t);}}off(e,t){this.handlers.get(e)?.delete(t);}hasListeners(e){return (this.handlers.get(e)?.size??0)>0}emit(e,t){let n=this.handlers.get(e);if(n)for(let i of n)try{i(t);}catch(o){console.error(`[vela] event handler error for "${String(e)}"`,o);}}clear(){this.handlers.clear();}};var Os=class{constructor(){this.records=new Map;this.counter=0;}nextId(e="ind"){return this.counter+=1,`${e}-${this.counter}`}add(e){this.records.set(e.id,e);}get(e){return this.records.get(e)}remove(e){let t=this.records.get(e);return this.records.delete(e),t}all(){return [...this.records.values()]}};var Wi=new Map;function Ln(r){Wi.set(r.type,r);}function zp(r){Wi.delete(r);}function Gi(r){return Wi.get(r)}function $p(){return [...Wi.keys()]}function Ns(){return [...Wi.values()]}var Fs=class{constructor(e,t,n){this.feed=e;this.market=t;this.onBar=n;this.unsubscribe=null;}start(){this.unsubscribe||(this.unsubscribe=this.feed.subscribe(this.market,this.onBar));}stop(){this.unsubscribe?.(),this.unsubscribe=null;}};var Hr=class{constructor(e,t,n,i,o){this.controller=n;this.schema=[];this.propsSchema=[];this.visibleState=true;this.bus=new Qn;this.id=e,this.title=t,i!==void 0&&(this.source=i),o!==void 0&&(this.nativeType=o);}get inputs(){return this.schema}get props(){return this.propsSchema}get visible(){return this.visibleState}inputValues(){return this.controller.inputValuesOf(this.id)}propValues(){return this.controller.propValuesOf(this.id)}setInput(e,t){this.controller.applyInputs(this.id,{[e]:t});}setInputs(e){this.controller.applyInputs(this.id,e);}setProp(e,t){this.controller.applyProps(this.id,{[e]:t});}setProps(e){this.controller.applyProps(this.id,e);}setVisible(e){this.controller.setVisible(this.id,e);}moveTo(e){this.controller.moveIndicator(this.id,e);}on(e,t){return this.bus.on(e,t)}context(e){return this.controller.getIndicatorContext(this.id,e)}remove(){this.controller.removeIndicator(this.id);}setSchema(e){this.schema=e;}setPropsSchema(e){this.propsSchema=e;}setVisibleState(e){this.visibleState=e;}emit(e,t){this.bus.emit(e,t);}};function T0(r){let e={};for(let i of r.series)e[i.kind]=(e[i.kind]??0)+1;let t=i=>i?.filter(o=>o.overlay===true).length??0,n=t(r.series)+t(r.fills)+t(r.backgrounds)+t(r.lines)+t(r.boxes)+t(r.labels)+t(r.polylines)+t(r.linefills)+t(r.tables);return {id:r.id,title:r.title,overlay:r.overlay,paneId:r.paneId,native:!!r.native,nativeType:r.native?.type,series:e,fills:r.fills.length,backgrounds:r.backgrounds.length,priceLines:r.priceLines.length,lines:r.lines?.length??0,boxes:r.boxes?.length??0,labels:r.labels?.length??0,polylines:r.polylines?.length??0,linefills:r.linefills?.length??0,tables:r.tables?.length??0,barColors:r.barColors?.length??0,trades:r.trades?.length??0,inputs:r.inputs.length,forcedOverlay:n}}function Wp(r){let e=r.map(T0),t=n=>e.reduce((i,o)=>i+n(o),0);return {indicators:e,totals:{panes:new Set(e.map(n=>n.paneId??"price")).size,series:t(n=>Object.values(n.series).reduce((i,o)=>i+o,0)),fills:t(n=>n.fills),backgrounds:t(n=>n.backgrounds),priceLines:t(n=>n.priceLines),lines:t(n=>n.lines),boxes:t(n=>n.boxes),labels:t(n=>n.labels),polylines:t(n=>n.polylines),linefills:t(n=>n.linefills),tables:t(n=>n.tables),barColors:t(n=>n.barColors),trades:t(n=>n.trades),forcedOverlay:t(n=>n.forcedOverlay)}}}var k0={"1D":864e5,"1W":6048e5,"1M":2592e6,"3M":7776e6,"6M":15552e6,"1Y":31536e6,"5Y":15768e7};function Gp(r,e){if(e.length===0)return null;let t=e[0].time,n=e[e.length-1].time;if(r==="ALL")return {from:t,to:n};let i;return r==="YTD"?i=Date.UTC(new Date(n).getUTCFullYear(),0,1):i=n-k0[r],{from:Math.max(t,i),to:n}}var Ke="#2962ff",zr="#38c0fd",z="#089981",W="#f23645",J="#787b86",Up="#e0b400",ue="#ff9800",Je="#5b9cf6",Yp="#ff5d00",_s="#0ecb81",Bs="#f6465d",f2="#f97316",g2="#0ea5e9",b2="#9ca3af",_="#3b82f6",Kp="#9aa0ad",Xp="#1e293b",jp="#475569",qp="#595959",Zp=Ke,Jp=W,Qp="#d500f9",Vs=[Ke,z,W,ue,"#7e57c2","#26a69a",Je,"#e573b5"];function v2(r){let e=0;for(let t=0;t<r.length;t++)e=e*31+r.charCodeAt(t)>>>0;return Vs[e%Vs.length]}var O=zr;function Su(){return {lineColor:O,lineWidth:2,lineStyle:"solid"}}function an(r=""){return {value:r,size:"normal",hAlign:"left",vAlign:"top"}}var Hs=class Hs{constructor(e){this.locked=false;this.visible=true;this.zIndex=0;this.id=e.id??`dw-${Hs.seq+=1}`,this.paneId=e.paneId,this.anchors=(e.anchors??[]).map(t=>({time:t.time,price:t.price})),this.style=e.style?{...e.style}:Su(),this.text=e.text?{...e.text}:void 0,this.locked=e.locked??false,this.visible=e.visible??true,this.zIndex=e.zIndex??0,this.createdAt=e.createdAt??Date.now(),e.props&&this.readProps(e.props);}isComplete(){return this.anchors.length>=this.anchorSchema().min}placementMode(){return "click"}onPlaced(e){}constrainHandleDrag(e){}translateBody(e,t,n){return n.map(i=>({time:i.time+e,price:i.price+t}))}timeExtent(){if(this.anchors.length===0)return null;let e=1/0,t=-1/0;for(let n of this.anchors)n.time<e&&(e=n.time),n.time>t&&(t=n.time);return {min:e,max:t}}editableLevels(){return null}applySettings(e){for(let[t,n]of Object.entries(e))t.startsWith("text.")&&!this.text&&(this.text=an()),em(this,t,n);}applyProps(e){this.readProps(e);}serialize(){return {id:this.id,type:this.type,paneId:this.paneId,anchors:this.anchors.map(e=>({time:e.time,price:e.price})),style:{...this.style},text:this.text?{...this.text}:void 0,locked:this.locked,visible:this.visible,zIndex:this.zIndex,createdAt:this.createdAt,props:this.writeProps()}}writeProps(){}readProps(e){}};Hs.seq=0;var G=Hs;function em(r,e,t){let n=e.split("."),i=r;for(let o=0;o<n.length-1;o+=1){let s=n[o],a=i[s];(a==null||typeof a!="object")&&(a={},i[s]=a),i=a;}i[n[n.length-1]]=t;}var Cu=new Map;function N(r,e){Cu.set(r,e);}function $r(r){return Cu.get(r)??null}function Z(r){return Cu.get(r)??""}function ye(r,e){return Z(r).replace("<svg ",`<svg width="${e}" height="${e}" `)}function tm(r,e=""){return `<svg viewBox="0 0 16 16" width="1em" height="1em" ${e?e+" ":""}fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`}function R(r,e=""){return `<svg viewBox="0 0 24 24" width="1em" height="1em" ${e?e+" ":""}fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`}function Tu(r){return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${r}</svg>`}var U=tm;N("style-candles",U('<path d="M4.5 2v2M4.5 12v2M11.5 2v1.5M11.5 11v3"/><rect x="2.8" y="4" width="3.4" height="8" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="3.5" width="3.4" height="7.5" rx="0.6" fill="currentColor"/>'));N("style-bars",U('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>'));N("style-line",U('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));N("style-area",U('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/><path d="M1.5 11.5 5.5 7l3 2.5 5-6V13.5h-12z" fill="currentColor" fill-opacity="0.25" stroke="none"/>'));N("style-baseline",U('<path d="M1.5 8h13" stroke-dasharray="2 2"/><path d="M2.5 8 5.25 4.5 8 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M2.5 8 5.25 4.5 8 8"/><path d="M8 8l2.75 3.5L13.5 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M8 8l2.75 3.5L13.5 8"/>'));N("style-heikinashi",U('<path d="M4.5 12v2M11.5 2v2"/><rect x="2.8" y="5" width="3.4" height="7" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="4" width="3.4" height="7" rx="0.6" fill="currentColor"/>'));N("indicators",U('<path d="M1.5 12.5 5 7l2.5 3.5L11 4l3.5 5"/><circle cx="11" cy="4" r="1.4" fill="currentColor" stroke="none"/>'));N("undo",U('<path d="M6.2 9.5 2.7 6l3.5-3.5"/><path d="M2.7 6h6.8a3.65 3.65 0 0 1 0 7.3H7.5"/>'));N("redo",U('<path d="M9.8 9.5 13.3 6 9.8 2.5"/><path d="M13.3 6H6.5a3.65 3.65 0 0 0 0 7.3h2"/>'));N("objects",U('<path d="M8 1.8 14 5 8 8.2 2 5z"/><path d="M2 8l6 3.2L14 8" opacity="0.7"/><path d="M2 11l6 3.2 6-3.2" opacity="0.4"/>'));N("clock",U('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));N("calendar",U('<rect x="2.2" y="3.2" width="11.6" height="10.6" rx="1.4"/><path d="M5.2 1.8v2.8M10.8 1.8v2.8M2.2 6.8h11.6"/>'));N("datawindow",U('<rect x="1.8" y="2.5" width="12.4" height="11" rx="1.5"/><path d="M4.5 5.5h4M4.5 8h7M4.5 10.5h5.5"/>'));N("camera",U('<path d="M5.5 4 6.5 2.5h3L10.5 4h3A1 1 0 0 1 14.5 5v7.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><circle cx="8" cy="8.5" r="2.6"/>'));N("gear",U('<path d="M6.55 1.4h2.9l.32 1.72c.48.14.92.38 1.3.7l1.66-.55 1.45 2.5-1.35 1.1c.08.34.12.7.12 1.07s-.04.73-.12 1.07l1.35 1.1-1.45 2.5-1.66-.55a4.3 4.3 0 0 1-1.3.7L9.45 14.6h-2.9l-.32-1.72a4.3 4.3 0 0 1-1.3-.7l-1.66.55-1.45-2.5 1.35-1.1A4.4 4.4 0 0 1 3.05 7.94c0-.37.04-.73.12-1.07l-1.35-1.1 1.45-2.5 1.66.55c.38-.32.82-.56 1.3-.7L6.55 1.4z"/><circle cx="8" cy="8" r="2.2"/>'));N("search",U('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));N("bell",U('<path d="M8 2a4 4 0 0 0-4 4v2.5L2.5 11v1h11v-1L12 8.5V6a4 4 0 0 0-4-4z"/><path d="M6.5 13.5a1.5 1.5 0 0 0 3 0"/>'));N("market-open",R('<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>'));N("market-pre",R('<path d="M12 2v8"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m8 6 4-4 4 4"/><path d="M16 18a4 4 0 0 0-8 0"/>'));N("market-post",R('<path d="M12 10V2"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m16 14-4 4-4-4"/><path d="M16 6a4 4 0 0 0-8 0"/>'));N("market-extended",R('<path d="M22 22H2"/><path d="M12 3a5 5 0 0 0 7.5 7.5A7.5 7.5 0 1 1 12 3Z"/>'));N("market-closed",R('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));N("market-holiday",R('<path d="m10 20-1.25-2.5L6 16"/><path d="M10 4 8.75 6.5 6 8"/><path d="m14 20 1.25-2.5L18 16"/><path d="m14 4 1.25 2.5L18 8"/><path d="m17 10-5 5-5-5"/><path d="M4 12h16"/>'));N("chevron-right",U('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));N("chevron-left",U('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));N("chevron-down",U('<path d="M3.5 6 8 10.5 12.5 6"/>'));N("chevron-up",U('<path d="M3.5 10 8 5.5 12.5 10"/>'));N("chevrons-right",U('<path d="m4 3.5 4.5 4.5L4 12.5"/><path d="m8.5 3.5 4.5 4.5-4.5 4.5"/>'));N("chevrons-left",U('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));N("check",U('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));N("close",U('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));N("pin",U('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/>'));N("pin-filled",U('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/><path d="M6.4 2.5h3.2v3.6l2 2.3v.9H4.4v-.9l2-2.3z" fill="currentColor" stroke="none"/>'));N("eye",U('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));N("eye-off",U('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));N("lock",U('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>'));N("unlock",U('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.7-.7"/>'));N("trash",U('<path d="M2.5 4.3h11M6.2 4.3V3.1a1 1 0 0 1 1-1h1.6a1 1 0 0 1 1 1v1.2M4.2 4.3l.5 9.1a1.15 1.15 0 0 0 1.15 1.1h4.3a1.15 1.15 0 0 0 1.15-1.1l.5-9.1M6.5 7v4.5M9.5 7v4.5"/>'));N("group",U('<path d="M1.8 4.5V2.4a.6.6 0 0 1 .6-.6h2.1M11.5 1.8h2.1a.6.6 0 0 1 .6.6v2.1M14.2 11.5v2.1a.6.6 0 0 1-.6.6h-2.1M4.5 14.2H2.4a.6.6 0 0 1-.6-.6v-2.1"/><rect x="4" y="4" width="4.2" height="4.2" rx="0.7"/><rect x="7.8" y="7.8" width="4.2" height="4.2" rx="0.7"/>'));N("ungroup",U('<rect x="1.6" y="1.6" width="6.2" height="6.2" rx="0.9"/><rect x="8.2" y="8.2" width="6.2" height="6.2" rx="0.9" stroke-dasharray="2 1.5"/>'));N("clone",U('<rect x="5.5" y="5.5" width="9" height="9" rx="1.2"/><path d="M11 5.5v-3a1 1 0 0 0-1-1H2.5a1 1 0 0 0-1 1V10a1 1 0 0 0 1 1h3"/>'));N("arrow-up",U('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));N("arrow-down",U('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));N("move-vertical",U('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));N("move",U('<path d="M8 1.8v12.4M1.8 8h12.4M5.6 4.2 8 1.8l2.4 2.4M5.6 11.8 8 14.2l2.4-2.4M4.2 5.6 1.8 8l2.4 2.4M11.8 5.6 14.2 8l-2.4 2.4"/>'));N("pen",U('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));N("wave",U('<path d="M1.5 10.4c1.6 0 1.9-4.8 3.4-4.8s1.8 4.8 3.4 4.8 1.8-4.8 3.4-4.8 1.6 4.8 2.8 4.8"/>'));N("folder-plus",U('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M8 7.6v3.6M6.2 9.4h3.6"/>'));N("folder-minus",U('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M6.2 9.4h3.6"/>'));N("collapse",U('<path d="M3 8h10"/>'));N("expand",U('<rect x="2.2" y="2.2" width="11.6" height="11.6" rx="1.4"/><path d="M8 5.4v5.2M5.4 8h5.2"/>'));N("plus",U('<path d="M8 2.8v10.4M2.8 8h10.4"/>'));N("minus",U('<path d="M2.8 8h10.4"/>'));N("maximize",U('<path d="M2.5 6V3a.5.5 0 0 1 .5-.5h3M10 2.5h3a.5.5 0 0 1 .5.5v3M13.5 10v3a.5.5 0 0 1-.5.5h-3M6 13.5H3a.5.5 0 0 1-.5-.5v-3"/>'));N("restore",U('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));N("star",U('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>'));N("star-filled",U('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>','fill="currentColor"'));N("grip",U('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5" r="1"/><circle cx="6" cy="8" r="1"/><circle cx="10" cy="8" r="1"/><circle cx="6" cy="12.5" r="1"/><circle cx="10" cy="12.5" r="1"/>','fill="currentColor" stroke="none"'));N("kebab",U('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>','fill="currentColor" stroke="none"'));N("burger",U('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));N("info",U('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));N("reset",U('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));N("pane-collapse",U('<path d="M2.6 9.4h4v4M13.4 6.6h-4v-4"/><path d="m9.4 6.6 4.2-4.2M2.4 13.6l4.2-4.2"/>'));N("pane-expand",U('<path d="M9.8 2.4h3.8v3.8M6.2 13.6H2.4V9.8"/><path d="m13.6 2.4-4.4 4.4M2.4 13.6l4.4-4.4"/>'));N("cursor",R('<path d="M5 3l6 16 2-6 6-2z"/>','fill="currentColor" stroke="none"'));N("ruler",R('<path d="M21.3 15.3 8.7 2.7a1 1 0 0 0-1.4 0L2.7 7.3a1 1 0 0 0 0 1.4l12.6 12.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4Z"/><path d="m7.5 10.5 2 2"/><path d="m10.5 7.5 2 2"/><path d="m13.5 4.5 2 2"/><path d="m4.5 13.5 2 2"/>'));N("magnet",R('<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>'));N("eraser",R('<path d="m7 21-4.3-4.3a1 1 0 0 1 0-1.4L13 5a2 2 0 0 1 2.8 0l4.2 4.2a2 2 0 0 1 0 2.8L12 20"/><path d="M22 21H7"/><path d="m5 11 9 9"/>'));N("pen-lock",R('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="13" y="14.5" width="8" height="6" rx="1.2"/><path d="M15 14.5v-1.6a2 2 0 0 1 4 0v1.6"/>'));N("pen-sync",R('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="12.5" y="13.5" width="6" height="4.8" rx="1"/><path d="M15.5 18.3v1a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-2.8a1 1 0 0 0-1-1h-1"/>'));N("brush",R('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'));N("bucket",R('<path d="m18.5 11.5-7-7L4 12a1.8 1.8 0 0 0 0 2.5l5 5a1.8 1.8 0 0 0 2.5 0Z"/><path d="m5 5 4 4"/><path d="M3.5 13.5h13"/><path d="M21 17.5c0 1.1-.9 2-2 2s-2-.9-2-2c0-1 1.2-1.7 2-3 .8 1.3 2 2 2 3Z"/>'));N("type",R('<path d="M5 6V4.5h14V6"/><path d="M12 4.5v15"/><path d="M9.5 19.5h5"/>'));N("bold",R('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7Z"/><path d="M7 12h7a3.5 3.5 0 0 1 0 7H7Z"/>','stroke-width="2.4"'));N("italic",R('<path d="M15 5h-5M14 19H9M14.5 5 10 19"/>','stroke-width="2.2"'));N("price-delta",R('<path d="M12 4v16"/><path d="M8 8l4-4 4 4"/><path d="M8 16l4 4 4-4"/>'));N("date-delta",R('<path d="M4 12h16"/><path d="M8 8l-4 4 4 4"/><path d="M16 8l4 4-4 4"/>'));N("bring-front",R('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/>'));N("send-back",R('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5" fill="currentColor" stroke="none" opacity="0.35"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/><rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/>'));N("r-squared",'<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none"><text x="2.5" y="17.5" font-size="14" font-family="serif">R\xB2</text></svg>');N("bands",R('<path d="M3 6h18"/><path d="M3 18h18"/><path d="M3 12h18" stroke-dasharray="3 3"/>'));N("dedekind",R('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0"/><path d="M8 20a4 4 0 0 1 8 0"/><path d="M12 4v16"/>'));N("sonic",R('<circle cx="15" cy="12" r="4"/><circle cx="12" cy="12" r="2.5"/><path d="M8 5v14"/>'));N("supersonic",R('<circle cx="16" cy="12" r="3.5"/><path d="M6 12 15 6M6 12 15 18"/>'));var Xe=[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}],B=[{path:"style.lineColor",label:"Line color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Line width",kind:"number",min:1,max:10,step:1,group:"line"},{path:"style.lineStyle",label:"Line style",kind:"lineStyle",options:Xe,group:"line"}],de=[{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"}],Ct=[{value:"small",label:"Small"},{value:"normal",label:"Normal"},{value:"large",label:"Large"},{value:"huge",label:"Huge"}],H=[{path:"text.value",label:"Text",kind:"text",group:"text"},{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ct,group:"text"},{path:"text.bold",label:"Bold",kind:"boolean",group:"text"},{path:"text.italic",label:"Italic",kind:"boolean",group:"text"}];function ne(r,e,t,n,i,o){let s=i-t,a=o-n,l=s*s+a*a;if(l<=1e-9)return Math.hypot(r-t,e-n);let c=((r-t)*s+(e-n)*a)/l;return c=c<0?0:c>1?1:c,Math.hypot(r-(t+c*s),e-(n+c*a))}function Wr(r,e,t){let n=1/0;for(let i=1;i<t.length;i+=1){let o=t[i-1],s=t[i],a=ne(r,e,o[0],o[1],s[0],s[1]);a<n&&(n=a);}return n}function Ve(r,e,t,n,i,o,s=0){let a=Math.min(t,i)-s,l=Math.max(t,i)+s,c=Math.min(n,o)-s,u=Math.max(n,o)+s;return r>=a&&r<=l&&e>=c&&e<=u}function _t(r,e,t){let n=false;for(let i=0,o=t.length-1;i<t.length;o=i,i+=1){let s=t[i],a=t[o];s[1]>e!=a[1]>e&&r<(a[0]-s[0])*(e-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}return n}function ku(r,e,t,n,i,o,s,a){let l=t-r,c=n-e,u=s-i,d=a-o,h=u*c-d*l;if(Math.abs(h)<1e-9)return null;let p=((o-e)*l-(i-r)*c)/h;return p<0||p>1?null:[i+p*u,o+p*d]}function Y(r,e,t,n=6){for(let i=0;i<t.length;i+=1){let o=t[i];if(Math.hypot(r-o[0],e-o[1])<=n)return i}return -1}function Se(r,e,t,n,i,o,s){if(i==="none")return [r,e,t,n];let a=t-r,l=i==="left"||i==="both",c=i==="right"||i==="both";if(Math.abs(a)<1e-6){if(l&&c)return [r,0,t,s];let m=n>=e;return c?m?[r,e,t,s]:[r,e,t,0]:m?[r,0,t,n]:[r,s,t,n]}let u=(n-e)/a,d=m=>e+u*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,d(h),p,d(p)]}var zs=class extends G{constructor(){super(...arguments);this.type="trendline";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);return s!=null&&ne(t,n,s[0],s[1],s[2],s[3])<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);if(!n)return null;let i=Math.min(n[0],n[2]),o=Math.min(n[1],n[3]);return {x:i,y:o,w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,{path:"style.arrowRight",label:"Arrow",kind:"boolean",group:"line"},...H]}}};var $s=class extends G{constructor(){super(...arguments);this.type="hline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"y"}]}}y(t){let n=this.anchors[0];return n?t.yOf(n.price,this.paneId):null}hitTest(t,n,i,o){let s=this.y(i);return s!=null&&Math.abs(n-s)<=o}handlePoints(t){let n=this.anchors[0],i=this.y(t);return !n||i==null?[]:[[t.xOf(n.time),i]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.y(t);return n==null?null:{x:0,y:n-1,w:t.width,h:2}}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){return null}schema(){return {fields:[...B,...H]}}};var Ws=class extends G{constructor(){super(...arguments);this.type="ray";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,u]=Se(s[0],s[1],s[2],s[3],"right",i.width,i.height);return ne(t,n,a,l,c,u)<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);return n?{x:Math.min(n[0],n[2]),y:Math.min(n[1],n[3]),w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...H]}}};var Pn=class extends G{anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:[e.xOf(t.time),i,e.xOf(n.time),o]}hitTest(e,t,n,i){let o=this.pixels(n);return o!=null&&ne(e,t,o[0],o[1],o[2],o[3])<=i}handlePoints(e){let t=this.pixels(e);return t?[[t[0],t[1]],[t[2],t[3]]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.pixels(e);return t?{x:Math.min(t[0],t[2]),y:Math.min(t[1],t[3]),w:Math.abs(t[2]-t[0]),h:Math.abs(t[3]-t[1])}:null}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[...B,...H]}}};var Gs=class extends Pn{constructor(){super(...arguments);this.type="extendedline";}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,u]=Se(s[0],s[1],s[2],s[3],"both",i.width,i.height);return ne(t,n,a,l,c,u)<=o}timeExtent(){return null}};var Us=class extends G{constructor(){super(...arguments);this.type="vline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"x"}]}}x(t){let n=this.anchors[0];return n?t.xOf(n.time):null}hitTest(t,n,i,o){let s=this.x(i);return s!=null&&Math.abs(t-s)<=o}handlePoints(t){let n=this.anchors[0],i=this.x(t);if(!n||i==null)return [];let o=t.yOf(n.price,this.paneId);return o==null?[]:[[i,o]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.x(t);return n==null?null:{x:n-1,y:0,w:2,h:t.height}}priceRange(){return null}schema(){return {fields:[...B,...H]}}};var Ys=class extends G{constructor(){super(...arguments);this.type="hray";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}pt(t){let n=this.anchors[0];if(!n)return null;let i=t.yOf(n.price,this.paneId);return i==null?null:[t.xOf(n.time),i]}hitTest(t,n,i,o){let s=this.pt(i);return s!=null&&ne(t,n,s[0],s[1],i.width,s[1])<=o}handlePoints(t){let n=this.pt(t);return n?[n]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pt(t);return n?{x:n[0],y:n[1]-1,w:Math.max(0,t.width-n[0]),h:2}:null}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){let t=this.anchors[0];return t?{min:t.time,max:Number.POSITIVE_INFINITY}:null}schema(){return {fields:[...B,...H]}}};var Ks=class extends G{constructor(){super(...arguments);this.type="crossline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}pt(t){let n=this.anchors[0];if(!n)return null;let i=t.yOf(n.price,this.paneId);return i==null?null:[t.xOf(n.time),i]}hitTest(t,n,i,o){let s=this.pt(i);return s!=null&&(Math.abs(n-s[1])<=o||Math.abs(t-s[0])<=o)}handlePoints(t){let n=this.pt(t);return n?[n]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pt(t);return n?{x:n[0]-1,y:n[1]-1,w:2,h:2}:null}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){return null}schema(){return {fields:[...B,...H]}}};var Xs=class extends Pn{constructor(){super(...arguments);this.type="infoline";}};var js=class extends Pn{constructor(){super(...arguments);this.type="trendangle";}};var qs=class extends G{constructor(){super(...arguments);this.type="box";}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}rect(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{x1:t.xOf(n.time),y1:o,x2:t.xOf(i.time),y2:s}}hitTest(t,n,i,o){let s=this.rect(i);return s?this.style.fillColor&&Ve(t,n,s.x1,s.y1,s.x2,s.y2)?true:[[s.x1,s.y1,s.x2,s.y1],[s.x2,s.y1,s.x2,s.y2],[s.x2,s.y2,s.x1,s.y2],[s.x1,s.y2,s.x1,s.y1]].some(l=>ne(t,n,l[0],l[1],l[2],l[3])<=o):false}handlePoints(t){let n=this.rect(t);return n?[[n.x1,n.y1],[n.x2,n.y2]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.rect(t);return n?{x:Math.min(n.x1,n.x2),y:Math.min(n.y1,n.y2),w:Math.abs(n.x2-n.x1),h:Math.abs(n.y2-n.y1)}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"},...H]}}};var E0={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},In=class extends G{defaultLabel(){return "Text"}labelText(){return this.text?.value??this.defaultLabel()}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}box(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=E0[this.text?.size??"normal"]??14,o=this.labelText().split(`
|
|
2
|
-
`),s=Math.max(1,...o.map(a=>a.length));return {x:e.xOf(t.time),y:n,w:Math.max(12,s*i*.6)+8,h:o.length*i*1.4+4}}hitTest(e,t,n,i){let o=this.box(n);return o!=null&&Ve(e,t,o.x,o.y,o.x+o.w,o.y+o.h)}handlePoints(e){let t=this.anchors[0],n=t?e.yOf(t.price,this.paneId):null;return t&&n!=null?[[e.xOf(t.time),n]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){return this.box(e)}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}};var
|
|
3
|
-
`),s=Math.max(1,...o.map(c=>c.length)),a=Math.max(20,s*i*.6)+16,l=o.length*i*1.4+12;return {x:e.xOf(t.time)-a/2,y:n-l/2,w:a,h:l}}points(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitTest(e,t,n,i){let o=this.box(n);if(o&&Ve(e,t,o.x,o.y,o.x+o.w,o.y+o.h,i))return true;let s=this.points(n);return s!=null&&ne(e,t,s[0][0],s[0][1],s[1][0],s[1][1])<=i}handlePoints(e){let t=this.points(e);return t?[t[0]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}translateBody(e,t,n){let i=n[0],o=n[1];return !i||!o?n.map(s=>({time:s.time+e,price:s.price+t})):[{time:i.time,price:i.price},{time:o.time+e,price:o.price+t}]}bounds(e){return this.box(e)}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[...B,...de,...H],textIsContent:true}}};var Bt=class extends dt{constructor(){super(...arguments);this.type="callout";}};var nr=class extends dt{constructor(){super(...arguments);this.type="pricenote";}defaultLabel(){return ""}labelText(){let t=this.anchors[0]?.price;return t==null?"0.00":t.toFixed(2)}schema(){return {fields:[...B,...de,...H.filter(t=>t.path!=="text.value")]}}};var rr=class extends dt{constructor(){super(...arguments);this.type="comment";}defaultLabel(){return "Comment"}};var ir=class extends dt{constructor(){super(...arguments);this.type="signpost";}defaultLabel(){return "Signpost"}};var pe=class extends G{hitTest(e,t,n,i){let o=this.geometry(n);return o?this.style.fillColor&&o.fill&&_t(e,t,o.fill)?true:o.segments.some(s=>ne(e,t,s[0],s[1],s[2],s[3])<=i):false}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}};var Zs=class extends pe{constructor(){super(...arguments);this.type="parallelchannel";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"y"}]}}offset(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];return !t||!n||!i?0:i.price-(t.price+n.price)/2}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.offset(),s=t.xOf(n.time),a=t.xOf(i.time),l=t.yOf(n.price,this.paneId),c=t.yOf(i.price,this.paneId),u=t.yOf(n.price+o,this.paneId),d=t.yOf(i.price+o,this.paneId);return l==null||c==null||u==null||d==null?null:{segments:[[s,l,a,c],[s,u,a,d]],fill:[[s,l],[a,c],[a,d],[s,u]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=this.offset(),o=[t.price,n.price,t.price+i,n.price+i],s=this.anchors[2];return s&&o.push(s.price),{min:Math.min(...o),max:Math.max(...o)}}schema(){return {fields:[...B,...de,...H]}}};var Js=class extends pe{constructor(){super(...arguments);this.type="disjointchannel";}anchorSchema(){return {min:4,max:4,slots:[{role:"top1",free:"both"},{role:"top2",free:"both"},{role:"bot1",free:"both"},{role:"bot2",free:"both"}]}}seg(t,n,i){let o=this.anchors[t],s=this.anchors[n];if(!o||!s)return null;let a=i.yOf(o.price,this.paneId),l=i.yOf(s.price,this.paneId);return a==null||l==null?null:[i.xOf(o.time),a,i.xOf(s.time),l]}geometry(t){let n=this.seg(0,1,t),i=this.seg(2,3,t),o=[n,i].filter(a=>a!=null);if(o.length===0)return null;let s=n&&i?[[n[0],n[1]],[n[2],n[3]],[i[2],i[3]],[i[0],i[1]]]:null;return {segments:o,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...de,...H]}}};var Qs=class extends pe{constructor(){super(...arguments);this.type="flattopbottom";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"flat",free:"y"}]}}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);if(a==null||l==null)return null;let c=this.anchors[2];if(!c)return {segments:[[o,a,s,l]],fill:null};let u=t.yOf(c.price,this.paneId);return u==null?null:{segments:[[o,a,s,l],[o,u,s,u]],fill:[[o,a],[s,l],[s,u],[o,u]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=[t.price,n.price],o=this.anchors[2];return o&&i.push(o.price),{min:Math.min(...i),max:Math.max(...i)}}schema(){return {fields:[...B,...de,...H]}}};var L0=2;function nm(){return {midColor:J,midStyle:"solid",upperColor:z,upperStyle:"solid",lowerColor:W,lowerStyle:"solid",upperFill:`${z}26`,lowerFill:`${W}26`,showR2:true}}function rm(r){let e=r.length;if(e<2)return null;let t=0,n=0,i=0,o=0,s=0;for(let m=0;m<e;m+=1){let f=r[m].close;t+=m,n+=f,i+=m*f,o+=m*m,s+=f*f;}let a=e*o-t*t,l=a===0?0:(e*i-t*n)/a,c=(n-l*t)/e,u=0;for(let m=0;m<e;m+=1){let f=r[m].close-(c+l*m);u+=f*f;}let d=Math.sqrt(u/e),h=Math.sqrt(a*(e*s-n*n)),p=h===0?0:(e*i-t*n)/h;return {t0:r[0].time,t1:r[e-1].time,mid0:c,mid1:c+l*(e-1),dev:L0*d,r2:Math.max(0,Math.min(1,p*p)),n:e}}var cn=class extends G{constructor(t){super(t);this.type="regressionchannel";this.cachedRange=null;this.reg||(this.reg=nm());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}fit(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null,l=a?rm(a):null;return l&&(this.cachedRange={min:Math.min(l.mid0,l.mid1)-l.dev,max:Math.max(l.mid0,l.mid1)+l.dev}),l}layout(t){let n=this.fit(t);if(!n)return null;let i=t.yOf(n.mid0,this.paneId),o=t.yOf(n.mid1,this.paneId),s=t.yOf(n.mid0+n.dev,this.paneId),a=t.yOf(n.mid1+n.dev,this.paneId),l=t.yOf(n.mid0-n.dev,this.paneId),c=t.yOf(n.mid1-n.dev,this.paneId);return i==null||o==null||s==null||a==null||l==null||c==null?null:{x0:t.xOf(n.t0),x1:t.xOf(n.t1),midY0:i,midY1:o,upperY0:s,upperY1:a,lowerY0:l,lowerY1:c,r2:n.r2,showR2:this.reg.showR2}}band(t){let n=this.layout(t);return n?[[n.x0,n.upperY0],[n.x1,n.upperY1],[n.x1,n.lowerY1],[n.x0,n.lowerY0]]:null}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=[[s.x0,s.upperY0],[s.x1,s.upperY1],[s.x1,s.lowerY1],[s.x0,s.lowerY0]];return _t(t,n,a)?true:[[s.x0,s.midY0,s.x1,s.midY1],[s.x0,s.upperY0,s.x1,s.upperY1],[s.x0,s.lowerY0,s.x1,s.lowerY1]].some(c=>ne(t,n,c[0],c[1],c[2],c[3])<=o)}handlePoints(t){let n=this.layout(t);if(n)return [[n.x0,n.midY0],[n.x1,n.midY1]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.band(t);if(!n)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"reg.midColor",label:"Midline color",kind:"color",group:"line"},{path:"reg.midStyle",label:"Midline style",kind:"lineStyle",group:"line"},{path:"reg.upperColor",label:"Upper line color",kind:"color",group:"line"},{path:"reg.upperStyle",label:"Upper line style",kind:"lineStyle",group:"line"},{path:"reg.lowerColor",label:"Lower line color",kind:"color",group:"line"},{path:"reg.lowerStyle",label:"Lower line style",kind:"lineStyle",group:"line"},{path:"reg.upperFill",label:"Upper fill",kind:"color",group:"fill"},{path:"reg.lowerFill",label:"Lower fill",kind:"color",group:"fill"},{path:"reg.showR2",label:"Show R\xB2",kind:"boolean",group:"behavior"}]}}writeProps(){return {...this.reg}}readProps(t){this.reg={...nm(),...t};}};var im=`${Je}00`;function om(){return {midColor:Je,midStyle:"solid",multiplier:1,upperColor:im,upperStyle:"solid",lowerColor:im,lowerStyle:"solid",bandFill:`${Je}33`}}function sm(r,e){let t=r.length;if(t<1)return null;let n=0;for(let c of r)n+=c.volume>0?c.volume:0;let i=n>0,o=0,s=0,a=0,l=[];for(let c=0;c<t;c+=1){let u=r[c],d=(u.high+u.low+u.close)/3,h=i?Math.max(0,u.volume):1;o+=h,s+=d*h,a+=d*d*h;let p=o>0?s/o:d,m=o>0?Math.max(0,a/o-p*p):0,f=Math.sqrt(m)*e;l.push({time:u.time,mid:p,upper:p+f,lower:p-f});}return l}var or=class extends G{constructor(t){super(t);this.type="anchoredvwap";this.cachedRange=null;this.cachedExtent=null;this.vwap||(this.vwap=om());}anchorSchema(){return {min:1,max:1,slots:[{role:"anchor",free:"x"}]}}series(t){let n=this.anchors[0];if(!n)return null;let i=t.barsInRange?.(n.time,Number.POSITIVE_INFINITY)??null;if(!i||i.length<1)return null;let o=sm(i.map(s=>({time:s.time,high:s.high,low:s.low,close:s.close,volume:s.volume??0})),this.vwap.multiplier);if(o&&o.length>0){let s=1/0,a=-1/0;for(let l of o)l.lower<s&&(s=l.lower),l.upper>a&&(a=l.upper);this.cachedRange={min:s,max:a},this.cachedExtent={min:o[0].time,max:o[o.length-1].time};}return o}layout(t){let n=this.series(t);if(!n)return null;let i=[],o=[],s=[];for(let a of n){let l=t.xOf(a.time),c=t.yOf(a.mid,this.paneId),u=t.yOf(a.upper,this.paneId),d=t.yOf(a.lower,this.paneId);c==null||u==null||d==null||(i.push([l,c]),o.push([l,u]),s.push([l,d]));}return i.length>0?{mid:i,upper:o,lower:s}:null}bandPolygon(t){return [...t.upper,...[...t.lower].reverse()]}hitTest(t,n,i,o){let s=this.layout(i);return s?_t(t,n,this.bandPolygon(s))?true:Eu(t,n,s.mid,o)||Eu(t,n,s.upper,o)||Eu(t,n,s.lower,o):false}handlePoints(t){let n=this.layout(t);if(n&&n.mid.length>0)return [n.mid[0]];let i=this.anchors[0];if(!i)return [];let o=t.yOf(i.price,this.paneId);return o==null?[]:[[t.xOf(i.time),o]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=[...n.upper,...n.lower],o=i.map(c=>c[0]),s=i.map(c=>c[1]),a=Math.min(...o),l=Math.min(...s);return {x:a,y:l,w:Math.max(...o)-a,h:Math.max(...s)-l}}priceRange(){return this.cachedRange}timeExtent(){return this.cachedExtent}schema(){return {fields:[{path:"vwap.midColor",label:"VWAP color",kind:"color",group:"line"},{path:"vwap.midStyle",label:"VWAP style",kind:"lineStyle",group:"line"},{path:"vwap.multiplier",label:"Band multiplier",kind:"number",min:.5,max:5,step:.5,group:"behavior"},{path:"vwap.upperColor",label:"Upper band color",kind:"color",group:"line"},{path:"vwap.lowerColor",label:"Lower band color",kind:"color",group:"line"},{path:"vwap.bandFill",label:"Band fill",kind:"color",group:"fill"}]}}writeProps(){return {...this.vwap}}readProps(t){this.vwap={...om(),...t};}};function Eu(r,e,t,n){for(let i=1;i<t.length;i+=1)if(ne(r,e,t[i-1][0],t[i-1][1],t[i][0],t[i][1])<=n)return true;return false}var P0=`${z}66`,I0=`${W}66`,A0=`${z}BF`,R0=`${W}BF`;function am(){return {rows:24,valueAreaPct:70,widthPct:35,anchor:"left",upColor:P0,downColor:I0,vaUpColor:A0,vaDownColor:R0,showVah:true,vahColor:J,vahStyle:"solid",showVal:true,valColor:J,valStyle:"solid",showPoc:true,pocColor:void 0,pocStyle:"solid",showDevelopingPoc:false,developingPocColor:Ke,developingPocStyle:"dotted",showDevelopingVa:false,developingVaColor:Ke,developingVaStyle:"dotted"}}function D0(r,e){return r<0?0:r>=e?e-1:r}function lm(r,e,t){let n=r.length,i=0,o=0;for(let u=0;u<n;u+=1){let d=r[u].up+r[u].down;i+=d,d>o&&(o=d);}let s=i*Math.min(1,Math.max(0,t)),a=e,l=e,c=o;for(;c<s&&(a>0||l<n-1);){let u=a>0?r[a-1].up+r[a-1].down:-1,d=l<n-1?r[l+1].up+r[l+1].down:-1;d>u?(l+=1,c+=d):(a-=1,c+=u);}return {vaFrom:a,vaTo:l}}function cm(r,e,t,n){let i=n.volume;if(!(i>0))return;let o=r.length,s=n.close>=n.open?"up":"down",a=new Set;for(let l of [n.open,n.high,n.low,n.close])a.add(D0(Math.floor((l-e)/t),o));for(let l of a)r[l][s]+=i;}function um(r){let e=0,t=0;for(let n=0;n<r.length;n+=1){let i=r[n].up+r[n].down;i>e&&(e=i,t=n);}return e>0?{poc:t,maxTotal:e}:null}function dm(r,e,t){let n=1/0,i=-1/0;for(let p of r)p.volume>0&&(p.low<n&&(n=p.low),p.high>i&&(i=p.high));if(!Number.isFinite(n))return null;let o=i>n?Math.max(1,Math.round(e)):1,s=i>n?(i-n)/o:1,a=Array.from({length:o},(p,m)=>({price:n+m*s,up:0,down:0}));for(let p of r)cm(a,n,s,p);let l=um(a);if(!l)return null;let{poc:c,maxTotal:u}=l,{vaFrom:d,vaTo:h}=lm(a,c,t);return {rows:a,rowH:s,min:n,maxTotal:u,poc:c,vaFrom:d,vaTo:h}}function hm(r,e,t,n){let i=dm(r,e,t);if(!i)return null;if(!n||r.length<1)return {profile:i,developingPoc:[],developingVaHigh:[],developingVaLow:[]};let{min:o,rowH:s}=i,a=i.rows.length,l=Array.from({length:a},(h,p)=>({price:o+p*s,up:0,down:0})),c=[],u=[],d=[];for(let h of r){cm(l,o,s,h);let p=um(l);if(!p)continue;let{poc:m}=p,{vaFrom:f,vaTo:g}=lm(l,m,t);c.push({time:h.time,price:l[m].price+s/2}),u.push({time:h.time,price:l[g].price+s}),d.push({time:h.time,price:l[f].price});}return {profile:i,developingPoc:c,developingVaHigh:u,developingVaLow:d}}var at=class extends G{constructor(t){super(t);this.type="fixedrangevp";this.cachedRange=null;this.frvp||(this.frvp=am());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}barsInSpan(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null;return !a||a.length<1?null:a.map(l=>({time:l.time,open:l.open,high:l.high,low:l.low,close:l.close,volume:l.volume??0}))}compute(t){let n=this.barsInSpan(t);if(!n)return null;let i=this.frvp,o=i.showDevelopingPoc||i.showDevelopingVa,s=hm(n,i.rows,i.valueAreaPct/100,o);if(s){let{profile:a}=s;this.cachedRange={min:a.min,max:a.min+a.rowH*a.rows.length};}return s}layout(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.compute(t);if(!o)return null;let{profile:s}=o,a=Math.min(n.time,i.time),l=Math.max(n.time,i.time),c=t.xOf(a),u=t.xOf(l),d=Math.abs(u-c),h=Math.max(1,Math.min(100,Math.max(0,this.frvp.widthPct))/100*d),p=this.frvp.anchor==="left",m=p?Math.min(c,u):Math.max(c,u),f=p?1:-1,g=[];for(let T=0;T<=s.rows.length;T+=1){let k=t.yOf(s.min+T*s.rowH,this.paneId);if(k==null)return null;g.push(k);}let b=T=>t.yOf(T,this.paneId),y=s.rows[s.vaTo].price+s.rowH,v=s.rows[s.vaFrom].price,S=s.rows[s.poc].price+s.rowH/2,E=T=>{let k=[];for(let x of T){let M=b(x.price);M!=null&&k.push([t.xOf(x.time),M]);}return k};return {x0:Math.min(c,u),x1:Math.max(c,u),anchorX:m,maxW:h,grow:f,profile:s,yEdges:g,vahY:b(y),valY:b(v),pocY:b(S),developingPoc:E(o.developingPoc),developingVaHigh:E(o.developingVaHigh),developingVaLow:E(o.developingVaLow)}}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=s.grow===1?s.anchorX:s.anchorX-s.maxW,l=s.grow===1?s.anchorX+s.maxW:s.anchorX,c=Math.min(s.yEdges[0],s.yEdges[s.yEdges.length-1]),u=Math.max(s.yEdges[0],s.yEdges[s.yEdges.length-1]);if(_t(t,n,[[a,c],[l,c],[l,u],[a,u]]))return true;let d=[[s.x0,s.vahY],[s.x0,s.valY],[s.x0,s.pocY]];for(let[,h]of d)if(h!=null&&ne(t,n,s.x0,h,s.x1,h)<=o)return true;for(let h of [s.developingPoc,s.developingVaHigh,s.developingVaLow])for(let p=1;p<h.length;p+=1)if(ne(t,n,h[p-1][0],h[p-1][1],h[p][0],h[p][1])<=o)return true;return false}handlePoints(t){let n=this.layout(t);if(n&&n.pocY!=null)return [[n.x0,n.pocY],[n.x1,n.pocY]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=Math.min(n.x0,n.grow===1?n.anchorX:n.anchorX-n.maxW),o=Math.max(n.x1,n.grow===1?n.anchorX+n.maxW:n.anchorX),s=Math.min(n.yEdges[0],n.yEdges[n.yEdges.length-1]),a=Math.max(n.yEdges[0],n.yEdges[n.yEdges.length-1]);return {x:i,y:s,w:o-i,h:a-s}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"frvp.rows",label:"Rows",kind:"number",min:1,max:500,step:1,group:"behavior"},{path:"frvp.valueAreaPct",label:"Value Area",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.widthPct",label:"Width %",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.anchor",label:"Anchor",kind:"select",options:[{value:"right",label:"Right"},{value:"left",label:"Left"}],group:"behavior"},{path:"frvp.upColor",label:"Up Volume",kind:"color",group:"fill"},{path:"frvp.downColor",label:"Down Volume",kind:"color",group:"fill"},{path:"frvp.vaUpColor",label:"Value Area Up",kind:"color",group:"fill"},{path:"frvp.vaDownColor",label:"Value Area Down",kind:"color",group:"fill"},{path:"frvp.showVah",label:"VAH",kind:"boolean",group:"line"},{path:"frvp.vahColor",label:"VAH color",kind:"color",group:"line"},{path:"frvp.vahStyle",label:"VAH style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showVal",label:"VAL",kind:"boolean",group:"line"},{path:"frvp.valColor",label:"VAL color",kind:"color",group:"line"},{path:"frvp.valStyle",label:"VAL style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showPoc",label:"POC",kind:"boolean",group:"line"},{path:"frvp.pocColor",label:"POC color",kind:"color",group:"line"},{path:"frvp.pocStyle",label:"POC style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showDevelopingPoc",label:"Developing POC",kind:"boolean",group:"line"},{path:"frvp.developingPocColor",label:"Developing POC color",kind:"color",group:"line"},{path:"frvp.developingPocStyle",label:"Developing POC style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showDevelopingVa",label:"Developing VA",kind:"boolean",group:"line"},{path:"frvp.developingVaColor",label:"Developing VA color",kind:"color",group:"line"},{path:"frvp.developingVaStyle",label:"Developing VA style",kind:"lineStyle",options:Xe,group:"line"}]}}writeProps(){return {...this.frvp}}readProps(t){this.frvp={...am(),...t};}};var ea=class extends pe{constructor(){super(...arguments);this.type="pitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=g=>{let b=t.yOf(g.price,this.paneId);return b==null?null:[t.xOf(g.time),b]},a=s(n),l=s(i),c=s(o);if(!a||!l||!c)return null;let u=(l[0]+c[0])/2,d=(l[1]+c[1])/2,h=u-a[0],p=d-a[1],m=t.width,f=t.height;return {segments:[Se(a[0],a[1],u,d,"right",m,f),Se(l[0],l[1],l[0]+h,l[1]+p,"right",m,f),Se(c[0],c[1],c[0]+h,c[1]+p,"right",m,f),[l[0],l[1],c[0],c[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...H]}}};var Gr=class extends pe{anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(e){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n||!i)return null;let o=f=>{let g=e.yOf(f.price,this.paneId);return g==null?null:[e.xOf(f.time),g]},s=o(this.medianStart(t,n,i)),a=o(n),l=o(i);if(!s||!a||!l)return null;let c=(a[0]+l[0])/2,u=(a[1]+l[1])/2,d=c-s[0],h=u-s[1],p=e.width,m=e.height;return {segments:[Se(s[0],s[1],c,u,"right",p,m),Se(a[0],a[1],a[0]+d,a[1]+h,"right",p,m),Se(l[0],l[1],l[0]+d,l[1]+h,"right",p,m),[a[0],a[1],l[0],l[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...B,...H]}}};var ta=class extends Gr{constructor(){super(...arguments);this.type="schiffpitchfork";}medianStart(t,n){return {time:t.time,price:(t.price+n.price)/2}}};var na=class extends Gr{constructor(){super(...arguments);this.type="modifiedschiffpitchfork";}medianStart(t,n){return {time:(t.time+n.time)/2,price:(t.price+n.price)/2}}};var ra=class extends pe{constructor(){super(...arguments);this.type="insidepitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=b=>{let y=t.yOf(b.price,this.paneId);return y==null?null:[t.xOf(b.time),y]},a=s({time:(n.time+i.time)/2,price:(n.price+i.price)/2}),l=s(n),c=s(i),u=s(o);if(!a||!l||!c||!u)return null;let d=(c[0]+u[0])/2,h=(c[1]+u[1])/2,p=u[0]-a[0],m=u[1]-a[1],f=t.width,g=t.height;return {segments:[Se(d,h,d+p,h+m,"right",f,g),Se(c[0],c[1],c[0]+p,c[1]+m,"right",f,g),Se(u[0],u[1],u[0]+p,u[1]+m,"right",f,g),[c[0],c[1],u[0],u[1]],[a[0],a[1],u[0],u[1]],[l[0],l[1],c[0],c[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...H]}}};var ia=class extends G{constructor(){super(...arguments);this.type="arrow";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);return s!=null&&ne(t,n,s[0],s[1],s[2],s[3])<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);return n?{x:Math.min(n[0],n[2]),y:Math.min(n[1],n[3]),w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,{path:"style.arrowRight",label:"Head (end)",kind:"boolean",group:"line"},{path:"style.arrowLeft",label:"Head (start)",kind:"boolean",group:"line"},...H]}}};var pm=48,oa=class extends G{constructor(){super(...arguments);this.type="ellipse";}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}oval(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:(a+l)/2,cy:(o+s)/2,rx:Math.abs(l-a)/2,ry:Math.abs(s-o)/2}}perimeter(t){let n=[];for(let i=0;i<=pm;i+=1){let o=i/pm*Math.PI*2;n.push([t.cx+t.rx*Math.cos(o),t.cy+t.ry*Math.sin(o)]);}return n}hitTest(t,n,i,o){let s=this.oval(i);if(!s||s.rx<1||s.ry<1)return false;let a=((t-s.cx)/s.rx)**2+((n-s.cy)/s.ry)**2;return this.style.fillColor&&a<=1?true:Wr(t,n,this.perimeter(s))<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.oval(t);return n?{x:n.cx-n.rx,y:n.cy-n.ry,w:n.rx*2,h:n.ry*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...de,...H]}}};var sa=class extends pe{constructor(){super(...arguments);this.type="triangle";}anchorSchema(){return {min:3,max:3,slots:[{role:"v1",free:"both"},{role:"v2",free:"both"},{role:"v3",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=u=>{let d=t.yOf(u.price,this.paneId);return d==null?null:[t.xOf(u.time),d]},a=s(n),l=s(i),c=s(o);return !a||!l||!c?null:{segments:[[a[0],a[1],l[0],l[1]],[l[0],l[1],c[0],c[1]],[c[0],c[1],a[0],a[1]]],fill:[a,l,c]}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...de,...H]}}};var O0=512,An=class extends pe{anchorSchema(){return {min:2,max:O0,slots:[]}}geometry(e){let t=[];for(let i of this.anchors){let o=e.yOf(i.price,this.paneId);if(o==null)return null;t.push([e.xOf(i.time),o]);}if(t.length<2)return null;let n=[];for(let i=1;i<t.length;i+=1)n.push([t[i-1][0],t[i-1][1],t[i][0],t[i][1]]);return {segments:n,fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...B,...H]}}};var aa=class extends An{constructor(){super(...arguments);this.type="polyline";}};var Ui=class extends An{placementMode(){return "freehand"}handlePoints(e){return []}bounds(e){let t=[],n=[];for(let s of this.anchors){let a=e.yOf(s.price,this.paneId);a!=null&&(t.push(e.xOf(s.time)),n.push(a));}if(t.length===0)return null;let i=Math.min(...t),o=Math.min(...n);return {x:i,y:o,w:Math.max(...t)-i,h:Math.max(...n)-o}}},la=class extends Ui{constructor(){super(...arguments);this.type="freehand";}};var N0=[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Width",kind:"number",min:4,max:60,step:1,group:"line"}],ca=class extends Ui{constructor(){super(...arguments);this.type="highlighter";}schema(){return {fields:N0}}};var ua=class extends G{constructor(){super(...arguments);this.type="circle";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}geom(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,r:Math.hypot(l-a,s-o)}}hitTest(t,n,i,o){let s=this.geom(i);if(!s||s.r<1)return false;let a=Math.hypot(t-s.cx,n-s.cy);return this.style.fillColor&&a<=s.r?true:Math.abs(a-s.r)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.geom(t);return n?{x:n.cx-n.r,y:n.cy-n.r,w:n.r*2,h:n.r*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...de,...H]}}};var da=class extends pe{constructor(){super(...arguments);this.type="rotatedrect";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"w",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=i[0]-n[0],a=i[1]-n[1],l=Math.hypot(s,a);if(l<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let c=-a/l,u=s/l,d=(o[0]-n[0])*c+(o[1]-n[1])*u,h=c*d,p=u*d,m=n,f=i,g=[i[0]+h,i[1]+p],b=[n[0]+h,n[1]+p];return {segments:[[m[0],m[1],f[0],f[1]],[f[0],f[1],g[0],g[1]],[g[0],g[1],b[0],b[1]],[b[0],b[1],m[0],m[1]]],fill:[m,f,g,b]}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B.map(t=>({...t,label:t.label.replace("Line","Border")})),...de,...H]}}};var ha=class extends An{constructor(){super(...arguments);this.type="path";}};var mm=40,pa=class extends pe{constructor(){super(...arguments);this.type="arc";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"apex",free:"both"}]}}pinApex(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];t&&n&&i&&(i.time=(t.time+n.time)/2);}onPlaced(){this.pinApex();}constrainHandleDrag(){this.pinApex();}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.anchors[2];if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=t.yOf(o.price,this.paneId);if(s==null)return null;let a=(n[0]+i[0])/2,l=(n[1]+i[1])/2,c=(i[0]-n[0])/2,u=(i[1]-n[1])/2,d=Math.hypot(c,u);if(d<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let h=-u/d,p=c/d,m=(s-l)*p;m<0&&(h=-h,p=-p);let f=Math.abs(m),g=[];for(let y=0;y<=mm;y+=1){let v=y/mm*Math.PI,S=Math.cos(v),E=Math.sin(v);g.push([a+S*c+E*f*h,l+S*u+E*f*p]);}let b=[];for(let y=1;y<g.length;y+=1)b.push([g[y-1][0],g[y-1][1],g[y][0],g[y][1]]);return b.push([g[g.length-1][0],g[g.length-1][1],g[0][0],g[0][1]]),{segments:b,fill:g}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B.map(t=>({...t,label:t.label.replace("Line","Border")})),...de,...H]}}};var fm=40,ma=class extends pe{constructor(){super(...arguments);this.type="curve";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"control",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=[];for(let l=0;l<=fm;l+=1){let c=l/fm,u=1-c;s.push([u*u*n[0]+2*u*c*o[0]+c*c*i[0],u*u*n[1]+2*u*c*o[1]+c*c*i[1]]);}let a=[];for(let l=1;l<s.length;l+=1)a.push([s[l-1][0],s[l-1][1],s[l][0],s[l][1]]);return {segments:a,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...de,...H]}}};var F0={head:11,headW:9,stemW:3.5,len:22},sr=class extends G{anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}glyphPoints(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=e.xOf(t.time),{head:o,headW:s,stemW:a,len:l}=F0,c=[[0,0],[-s,o],[-a,o],[-a,l],[a,l],[a,o],[s,o]],u=this.dir(),d=([h,p])=>{switch(u){case "up":return [h,p];case "down":return [h,-p];case "left":return [p,h];default:return [-p,h]}};return c.map(h=>{let[p,m]=d(h);return [i+p,n+m]})}hitTest(e,t,n,i){let o=this.glyphPoints(n);return o!=null&&_t(e,t,o)}handlePoints(e){let t=this.anchors[0];if(!t)return [];let n=e.yOf(t.price,this.paneId);return n==null?[]:[[e.xOf(t.time),n]]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.glyphPoints(e);if(!t)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...H]}}},Yi=class extends sr{constructor(){super(...arguments);this.type="arrowmarkup";}dir(){return "up"}},Ki=class extends sr{constructor(){super(...arguments);this.type="arrowmarkdown";}dir(){return "down"}};var qi=["\u2605","\u2606","\u25CF","\u25C6","\u25B2","\u25BC","\u27A4","\u2691","\u271A","\u2715","\u2764","\u2666"],fa=["small","normal","large","huge"],gm={small:16,normal:22,large:32,huge:44},ar=class extends G{constructor(e){super(e),this.glyph||(this.glyph=this.defaultGlyph()),this.size||(this.size="normal");}sizePx(){return gm[this.size]??gm.normal}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}center(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);return n==null?null:[e.xOf(t.time),n]}hitTest(e,t,n,i){let o=this.center(n);if(!o)return false;let s=this.sizePx()/2+i;return Math.abs(e-o[0])<=s&&Math.abs(t-o[1])<=s}handlePoints(e){let t=this.center(e);return t?[t]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.center(e);if(!t)return null;let n=this.sizePx();return {x:t[0]-n/2,y:t[1]-n/2,w:n,h:n}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"glyph",label:"Icon",kind:"select",options:qi.map(e=>({value:e,label:e})),group:"line"},{path:"size",label:"Size",kind:"select",options:fa.map(e=>({value:e,label:e})),group:"line"},{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...H]}}writeProps(){return {glyph:this.glyph,size:this.size}}readProps(e){typeof e.glyph=="string"&&(this.glyph=e.glyph),typeof e.size=="string"&&(this.size=e.size);}},Xi=class extends ar{constructor(){super(...arguments);this.type="flagmark";}defaultGlyph(){return "\u2691"}},ji=class extends ar{constructor(){super(...arguments);this.type="iconstamp";}defaultGlyph(){return "\u2605"}};var bm=r=>r==="small"||r==="normal"||r==="large"||r==="huge";function V0(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var fe=class extends G{constructor(e){super(e),this.levels||(this.levels=this.defaultLevels().map(t=>({...t}))),this.numbersSize||(this.numbersSize="small"),this.labelsSize||(this.labelsSize="normal");}fillBands(e){return []}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}hitTest(e,t,n,i){let o=this.entryLines(n);return o!=null&&o.some(s=>ne(e,t,s.x1,s.y1,s.x2,s.y2)<=i)}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}schema(){return {fields:B.filter(e=>e.path!=="style.lineColor")}}writeProps(){return {levels:this.levels.map(e=>({...e})),numbersSize:this.numbersSize,labelsSize:this.labelsSize}}readProps(e){if(Array.isArray(e.levels)){let t=e.levels.map(V0).filter(n=>n!=null);t.length&&(this.levels=t);}bm(e.numbersSize)&&(this.numbersSize=e.numbersSize),bm(e.labelsSize)&&(this.labelsSize=e.labelsSize);}};var Ur=class extends fe{levelLines(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.xOf(t.time),o=e.xOf(n.time),s=Math.min(i,o),a=Math.max(i,o),l=n.price-t.price,c=[];for(let u of this.levels){if(!u.enabled)continue;let d=t.price+u.ratio*l,h=e.yOf(d,this.paneId);h!=null&&c.push({ratio:u.ratio,color:u.color,label:u.label,price:d,x1:s,x2:a,y:h});}return c}entryLines(e){let t=this.levelLines(e);return t?t.map(n=>({color:n.color,label:n.label,x1:n.x1,y1:n.y,x2:n.x2,y2:n.y,numberText:`${n.ratio} (${n.price.toFixed(2)})`,numberX:n.x1+4,numberY:n.y-7,numberAlign:"left",labelX:(n.x1+n.x2)/2,labelY:n.y-7})):null}fillBands(e){let t=this.levelLines(e);if(!t)return [];let n=[];for(let i=1;i<t.length;i+=1){let o=t[i-1],s=t[i];n.push({color:s.color,x:o.x1,y:Math.min(o.y,s.y),w:o.x2-o.x1,h:Math.abs(s.y-o.y)});}return n}priceRange(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return null;let n=t.price-e.price,i=this.levels.filter(o=>o.enabled).map(o=>e.price+o.ratio*n);return i.length===0?null:{min:Math.min(...i),max:Math.max(...i)}}};var lr=J,Ht=W,zt=ue,cr="#4caf50",Rn=z,un=Je,ur="#9c27b0",_0="#e91e63",Mu="#26a69a",B0="#ab47bc",H0="#ef5350",vm="#ffb74d",z0="#38c0fd",ga="#b2b5be",Yr=[z0,un,Rn,cr,zt,Ht,_0,ur,lr,Mu,B0,H0];function ym(r){return Yr[(r%Yr.length+Yr.length)%Yr.length]}var $0=[[0,lr],[.125,Ht],[.236,Ht],[.25,Ht],[.382,zt],[.5,cr],[.618,Rn],[.75,un],[.786,un],[1,lr],[1.272,un],[1.382,zt],[1.618,Ht],[2,lr],[2.382,zt],[2.618,zt],[3,lr],[4.236,cr],[6.854,Rn],[11.09,un]];function W0(r,e=0){return $0.find(([t])=>t===r)?.[1]??ym(e)}function me(r){return r.map((e,t)=>{let n=typeof e=="number"?{ratio:e}:e;return {ratio:n.ratio,color:n.color??W0(n.ratio,t),enabled:n.enabled!==false,...n.label?{label:n.label}:{}}})}function wm(r,e=r){return Array.from({length:r},(t,n)=>({ratio:n+1,color:ym(n),enabled:n<e,label:String(n+1)}))}var G0=me([0,.236,.382,.5,.618,.786,1]),ba=class extends Ur{constructor(){super(...arguments);this.type="fibretracement";}defaultLevels(){return G0}};var U0=me([0,.382,.618,1,1.272,1.618,{ratio:2.618,color:ur}]),va=class extends Ur{constructor(){super(...arguments);this.type="fibextension";}defaultLevels(){return U0}};var Y0=me([0,.382,.5,.618,1,1.618,{ratio:2.618,color:ur}]),ya=class extends fe{constructor(){super(...arguments);this.type="fibextensiontrend";}anchorSchema(){return {min:3,max:3,slots:[{role:"a",free:"both"},{role:"b",free:"both"},{role:"c",free:"both"}]}}defaultLevels(){return Y0}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.price-n.price,a=[t.xOf(n.time),t.xOf(i.time),t.xOf(o.time)],l=Math.min(...a),c=Math.max(...a),u=[];for(let d of this.levels){if(!d.enabled)continue;let h=o.price+d.ratio*s,p=t.yOf(h,this.paneId);p!=null&&u.push({color:d.color,label:d.label,x1:l,y1:p,x2:c,y2:p,numberText:`${d.ratio} (${h.toFixed(2)})`,numberX:l+4,numberY:p-7,numberAlign:"left",labelX:(l+c)/2,labelY:p-7});}return u}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n||!i)return null;let o=n.price-t.price,s=this.levels.filter(a=>a.enabled).map(a=>i.price+a.ratio*o);return s.push(t.price,n.price,i.price),{min:Math.min(...s),max:Math.max(...s)}}};var K0=me([.236,.382,.5,.618,.786,1]),wa=class extends fe{constructor(){super(...arguments);this.type="fibfan";}defaultLevels(){return K0}fanLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let u of this.levels){if(!u.enabled)continue;let d=t.yOf(n.price+u.ratio*l,this.paneId);if(d==null)continue;let[h,p,m,f]=Se(o,s,a,d,"right",t.width,t.height);c.push({ratio:u.ratio,color:u.color,label:u.label,x1:h,y1:p,x2:m,y2:f,labelX:a+5,labelY:d});}return c}entryLines(t){let n=this.fanLines(t);return n?n.map(i=>({color:i.color,label:i.label,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,numberText:String(i.ratio),numberX:i.labelX,numberY:i.labelY,numberAlign:"left",labelX:i.labelX,labelY:i.labelY+13})):null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var X0=[0,1,2,3,5,8,13,21,34].map(r=>({ratio:r,color:O,enabled:true})),xa=class extends fe{constructor(){super(...arguments);this.type="fibtimezones";}defaultLevels(){return X0}zoneLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=i.time-n.time;if(Math.abs(o)<1e-9)return null;let s=[];for(let a of this.levels)a.enabled&&s.push({n:a.ratio,color:a.color,label:a.label,x:t.xOf(n.time+a.ratio*o)});return s}entryLines(t){let n=this.zoneLines(t);if(!n)return null;let i=t.height;return n.map(o=>({color:o.color,label:o.label,x1:o.x,y1:0,x2:o.x,y2:i,numberText:String(o.n),numberX:o.x,numberY:9,numberAlign:"center",labelX:o.x,labelY:24}))}priceRange(){return null}timeExtent(){return null}};var j0=me([0,.236,.382,.5,.618,.786,1,1.618,2.618]),Sa=class extends fe{constructor(){super(...arguments);this.type="fibchannel";}defaultLevels(){return j0}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=0,u=0,d=this.anchors[2];if(d){let p=t.yOf(d.price,this.paneId);if(p==null)return null;c=t.xOf(d.time)-a,u=p-o;}let h=[];for(let p of this.levels){if(!p.enabled)continue;let m=p.ratio*c,f=p.ratio*u,g=l+m,b=s+f;h.push({color:p.color,label:p.label,x1:a+m,y1:o+f,x2:g,y2:b,numberText:String(p.ratio),numberX:g+5,numberY:b,numberAlign:"left",labelX:g+5,labelY:b+13});}return h}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n)return null;let o=i?i.price-t.price:0,s=1/0,a=-1/0;for(let l of this.levels)if(l.enabled)for(let c of [t.price,n.price]){let u=c+l.ratio*o;u<s&&(s=u),u>a&&(a=u);}return s<=a?{min:s,max:a}:null}};var q0=me([0,.236,.382,.5,.618,.786,1]),Ca=class extends fe{constructor(){super(...arguments);this.type="fibspeedfan";}defaultLevels(){return q0}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),c=t.xOf(i.time)-a,u=s-o,d=c>=0?"right":"left",h=t.width,p=t.height,m=[];for(let f of this.levels){if(!f.enabled)continue;let g=a+c,b=o+u*f.ratio,y=Se(a,o,g,b,d,h,p);if(m.push({color:f.color,label:f.label,x1:y[0],y1:y[1],x2:y[2],y2:y[3],numberText:String(f.ratio),numberX:d==="right"?g+5:g-5,numberY:b,numberAlign:d==="right"?"left":"right",labelX:g,labelY:b}),f.ratio===1)continue;let v=a+c*f.ratio,S=o+u,E=Se(a,o,v,S,d,h,p);m.push({color:f.color,label:f.label,x1:E[0],y1:E[1],x2:E[2],y2:E[3],numberText:String(f.ratio),numberX:v,numberY:S+(u>=0?12:-12),numberAlign:"center",labelX:v,labelY:S+12});}return m}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Z0=me([0,.382,{ratio:.5,enabled:false},.618,1,1.382,1.618,2,2.382,2.618,3]),Ta=class extends fe{constructor(){super(...arguments);this.type="trendfibtime";}defaultLevels(){return Z0}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"p3",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.time-n.time;if(Math.abs(s)<1e-9)return null;let a=t.height,l=[];for(let c of this.levels){if(!c.enabled)continue;let u=t.xOf(o.time+c.ratio*s);l.push({color:c.color,label:c.label,x1:u,y1:0,x2:u,y2:a,numberText:String(c.ratio),numberX:u,numberY:9,numberAlign:"center",labelX:u,labelY:24});}return l}priceRange(){return null}timeExtent(){return null}};function J0(r,e,t){if(t-e>=Math.PI*2-.001)return true;let n=r-e,i=Math.PI*2;for(;n<0;)n+=i;for(;n>=i;)n-=i;return n<=t-e+1e-6}var Tt=class extends fe{boundingLines(e){return []}entryLines(e){return []}hitTest(e,t,n,i){let o=this.radial(n);if(o){let s=Math.hypot(e-o.cx,t-o.cy),a=Math.atan2(t-o.cy,e-o.cx);if(J0(a,o.a0,o.a1)){for(let l of this.levels)if(l.enabled&&Math.abs(s-o.R0*l.ratio)<=i)return true}}return this.boundingLines(n).some(s=>ne(e,t,s[0],s[1],s[2],s[3])<=i)}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}};var Q0=me([.236,.382,.5,.618,.786,1,1.618,2.618]),ka=class extends Tt{constructor(){super(...arguments);this.type="fibcircles";}defaultLevels(){return Q0}radial(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,R0:Math.hypot(l-a,s-o),a0:0,a1:Math.PI*2}}};var eS=me([.236,.382,.5,.618,.786,1,1.618,2.618]),Ea=class extends Tt{constructor(){super(...arguments);this.type="fibarcs";}defaultLevels(){return eS}pts(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{cx:t.xOf(n.time),cy:o,ex:t.xOf(i.time),ey:s}}radial(t){let n=this.pts(t);if(!n)return null;let i=Math.hypot(n.ex-n.cx,n.ey-n.cy),o=Math.atan2(n.ey-n.cy,n.ex-n.cx);return {cx:n.cx,cy:n.cy,R0:i,a0:o-Math.PI/2,a1:o+Math.PI/2}}boundingLines(t){let n=this.pts(t);return n?[[n.cx,n.cy,n.ex,n.ey]]:[]}};var tS=me([.236,.382,.5,.618,.786,1]),Ma=class extends Tt{constructor(){super(...arguments);this.type="fibwedge";}defaultLevels(){return tS}anchorSchema(){return {min:3,max:3,slots:[{role:"apex",free:"both"},{role:"radius",free:"both"},{role:"angle",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}radial(t){let n=this.px(t,0),i=this.px(t,1),o=this.px(t,2);if(!n||!i||!o)return null;let s=Math.hypot(i[0]-n[0],i[1]-n[1]);if(s<1)return null;let a=Math.atan2(i[1]-n[1],i[0]-n[0]),l=Math.atan2(o[1]-n[1],o[0]-n[0]),c=Math.min(a,l),u=Math.max(a,l);return u-c>Math.PI&&([c,u]=[u,c+Math.PI*2]),{cx:n[0],cy:n[1],R0:s,a0:c,a1:u}}boundingLines(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return [];let o=[[n[0],n[1],i[0],i[1]]],s=this.px(t,2);if(s){let a=Math.hypot(i[0]-n[0],i[1]-n[1]),l=Math.hypot(s[0]-n[0],s[1]-n[1]);l>1e-6&&o.push([n[0],n[1],n[0]+(s[0]-n[0])/l*a,n[1]+(s[1]-n[1])/l*a]);}return o}};var nS=1.6180339887,xm=Math.log(nS)/(Math.PI/2),rS=Math.PI/64,iS=Math.PI,oS=.5,dr=class extends G{constructor(){super(...arguments);this.type="fibspiral";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}spiralPoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=Math.hypot(l-a,s-o);if(c<1)return null;let u=Math.atan2(s-o,l-a),d=Math.max(Math.log(oS/c)/xm,-8*Math.PI*2),h=[];for(let p=d;p<=iS;p+=rS){let m=c*Math.exp(xm*p),f=u+p;h.push([a+m*Math.cos(f),o+m*Math.sin(f)]);}return h}hitTest(t,n,i,o){let s=this.spiralPoints(i);return s!=null&&s.length>=2&&Wr(t,n,s)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.handlePoints(t);if(n.length<2)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...H]}}};var sS=me([{ratio:.125,color:Ht,label:"1/8"},{ratio:.25,color:zt,label:"1/4"},{ratio:.333,color:vm,label:"1/3"},{ratio:.5,color:cr,label:"1/2"},{ratio:1,color:ga,label:"1/1"},{ratio:2,color:Rn,label:"2/1"},{ratio:3,color:un,label:"3/1"},{ratio:4,color:Mu,label:"4/1"},{ratio:8,color:ur,label:"8/1"}]),La=class extends fe{constructor(){super(...arguments);this.type="gannfan";}defaultLevels(){return sS}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let u of this.levels){if(!u.enabled)continue;let d=t.yOf(n.price+l*u.ratio,this.paneId);if(d==null)continue;let[h,p,m,f]=Se(o,s,a,d,"right",t.width,t.height);c.push({color:u.color,x1:h,y1:p,x2:m,y2:f,numberText:u.label??String(u.ratio),numberX:a+5,numberY:d,numberAlign:"left",labelX:a+5,labelY:d});}return c}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var aS=me([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),Pa=class extends fe{constructor(){super(...arguments);this.type="gannbox";}defaultLevels(){return aS}corners(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);return a==null||l==null?null:{c1:n,c2:i,left:Math.min(o,s),right:Math.max(o,s),top:Math.min(a,l),bot:Math.max(a,l)}}entryLines(t){let n=this.corners(t);if(!n)return null;let{c1:i,c2:o,left:s,right:a,top:l,bot:c}=n,u=[];for(let h of this.levels){if(!h.enabled)continue;let p=t.yOf(i.price+h.ratio*(o.price-i.price),this.paneId);p!=null&&u.push({color:h.color,x1:s,y1:p,x2:a,y2:p,numberText:h.label??String(h.ratio),numberX:s-5,numberY:p,numberAlign:"right",labelX:s,labelY:p});let m=t.xOf(i.time+h.ratio*(o.time-i.time));u.push({color:h.color,x1:m,y1:l,x2:m,y2:c,numberText:"",numberX:m,numberY:l,numberAlign:"center",labelX:m,labelY:l});}let d=this.levels.find(h=>h.ratio===1)?.color??lr;return u.push({color:d,x1:s,y1:l,x2:a,y2:c,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),u.push({color:d,x1:s,y1:c,x2:a,y2:l,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),u}hitTest(t,n,i,o){let s=this.corners(i);return s!=null&&Ve(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var lS=me([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),cS=[{label:"3x1",x:3,y:1,color:Ht},{label:"2x1",x:2,y:1,color:zt},{label:"1x1",x:1,y:1,color:ga},{label:"1x2",x:1,y:2,color:Rn},{label:"1x3",x:1,y:3,color:un}],Lu=[{k:.25,color:Ht},{k:.5,color:zt},{k:.75,color:cr},{k:1,color:Rn}],hr=class extends fe{constructor(){super(...arguments);this.type="gannsquare";}defaultLevels(){return lS}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {ox:a,oy:o,bx:l-a,py:s-o,left:Math.min(a,l),top:Math.min(o,s),right:Math.max(a,l),bot:Math.max(o,s)}}arcGeom(t){let n=this.box(t);return n?{ox:n.ox,oy:n.oy,bx:n.bx,py:n.py}:null}entryLines(t){let n=this.box(t);if(!n)return null;let i=this.anchors[0],o=this.anchors[1],s=[];for(let a of this.levels){if(!a.enabled)continue;let l=t.yOf(i.price+a.ratio*(o.price-i.price),this.paneId);l!=null&&s.push({color:a.color,x1:n.left,y1:l,x2:n.right,y2:l,numberText:a.label??String(a.ratio),numberX:n.left-5,numberY:l,numberAlign:"right",labelX:n.left,labelY:l});let c=t.xOf(i.time+a.ratio*(o.time-i.time));s.push({color:a.color,x1:c,y1:n.top,x2:c,y2:n.bot,numberText:"",numberX:c,numberY:n.top,numberAlign:"center",labelX:c,labelY:n.top});}for(let a of cS){let l,c;a.x>a.y?(l=n.ox+n.bx,c=n.oy+a.y/a.x*n.py):(c=n.oy+n.py,l=n.ox+a.x/a.y*n.bx),s.push({color:a.color,x1:n.ox,y1:n.oy,x2:l,y2:c,numberText:a.label,numberX:l+4,numberY:c,numberAlign:"left",labelX:l+4,labelY:c});}return s}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&Ve(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Pu=[4,8,12,16,24,32,48,64],uS=24,dS=.75;function Sm(r,e){if(!Number.isInteger(r)||!Number.isInteger(e)||e<=0)return false;let t=r*r-1;return e%2===1?t%e===0:e%8===0?t%e!==0?false:t/e%2!==0:false}function Cm(r){let e=[];for(let t=0;t<r;t+=1)Sm(t,r)&&e.push(t);return e}var pr=class extends G{constructor(t){super(t);this.type="dedekind";this.maxCurvature===void 0&&(this.maxCurvature=uS);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=Math.min(t.xOf(n.time),t.xOf(i.time)),l=Math.max(t.xOf(n.time),t.xOf(i.time)),c=Math.min(o,s),u=Math.max(o,s),d=l-a,h=u-c;if(d<1||h<1)return null;let p=h,m=d/p;return {left:a,right:l,top:c,bot:u,unitPx:p,x0:0,realSpan:m}}geodesics(t){let n=this.box(t);if(!n)return null;let{left:i,top:o,bot:s,unitPx:a,x0:l,realSpan:c}=n,u=Math.max(1,Math.min(64,Math.round(this.maxCurvature))),d=l-1/u,h=l+c+1/u,p=i+c*a,m=[],f=Math.floor(d*2),g=Math.ceil(h*2);for(let b=f;b<=g;b+=1){if(b%2===0)continue;let y=i+(b/2-l)*a;y<i-.5||y>p+.5||m.push({kind:"vline",x:y,y0:s,y1:o});}for(let b=1;b<=u;b+=1){let y=1/b,v=y*a;if(v<dS)continue;let S=Cm(b);if(S.length===0)continue;let E=Math.floor(d)-1,T=Math.ceil(h)+1;for(let k=E;k<=T;k+=1)for(let x of S){let M=x/b+k;if(M+y<d||M-y>h)continue;let w=i+(M-l)*a;w+v<i-1||w-v>p+1||m.push({kind:"arc",cx:w,cy:s,r:v});}}return m}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&Ve(t,n,s.left,s.top,s.right,s.bot,o)}handlePoints(t){let n=this.box(t);return n?[[n.left,n.top],[n.right,n.bot]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);return n?{x:n.left,y:n.top,w:n.right-n.left,h:n.bot-n.top}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,{path:"maxCurvature",label:"Max curvature",kind:"number",min:4,max:64,step:4,group:"behavior"},...H]}}writeProps(){return {maxCurvature:this.maxCurvature}}readProps(t){typeof t.maxCurvature=="number"&&Number.isFinite(t.maxCurvature)&&(this.maxCurvature=Math.max(1,Math.min(64,Math.round(t.maxCurvature))));}};var Iu=[3,4,5,6,8,10,12],Au=[1.5,2,2.5,3,4,5],Ia=6,hS=2;function Ru(r=Ia){return [...wm(Yr.length,r)]}function pS(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var Kr={path:"showRatios",label:"Show ratios",kind:"boolean",group:"behavior"},Qe=class extends G{constructor(e){super(e),this.waveCount===void 0&&(this.waveCount=Ia),this.showRatios===void 0&&(this.showRatios=true);let t=Array.isArray(e.props?.levels);this.levels||(this.levels=this.defaultLevels().map(n=>({...n}))),!t&&this.shouldSyncWaveCount()&&this.syncLevelsToWaveCount();}shouldSyncWaveCount(){return true}syncLevelsToWaveCount(){let e=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=e;for(let t=0;t<this.levels.length;t+=1)this.levels[t].enabled=t<e;}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"d1",free:"both"},{role:"d2",free:"both"}]}}geom(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);if(i==null||o==null)return null;let s=e.xOf(t.time),a=e.xOf(n.time),l=(s+a)/2,c=(i+o)/2,u=Math.hypot(a-s,o-i)/2;if(u<1)return null;let d=a-s,h=o-i,p=Math.hypot(d,h);p<1e-9?(d=1,h=0):(d/=p,h/=p);let m=this.levels.filter(T=>T.enabled&&T.ratio>0).slice().sort((T,k)=>T.ratio-k.ratio);if(m.length===0)return null;let f=Math.max(1,this.machNumber()),g=[];for(let T of m){let k=T.ratio*u;g.push({cx:l+f*(k-u)*d,cy:c+f*(k-u)*h,r:k,color:T.color,ratio:T.ratio});}let b=l-f*u*d,y=c-f*u*h,v=g[g.length-1].r,S=f*v+2*u,E=[];if(f<=1+1e-9){let T=-h,k=d;E.push([b-T*S,y-k*S,b+T*S,y+k*S]);}else {let T=Math.asin(1/f),k=Math.cos(T),x=Math.sin(T),M=(A,$,ie)=>[A*k-$*ie*x,A*ie*x+$*k],[w,L]=M(d,h,1),[P,C]=M(d,h,-1);E.push([b,y,b+w*S,y+L*S]),E.push([b,y,b+P*S,y+C*S]);}return {c0x:l,c0y:c,R:u,fx:d,fy:h,noseX:b,noseY:y,circles:g,rays:E}}hitTest(e,t,n,i){let o=this.geom(n);if(!o)return false;for(let s of o.circles)if(Math.abs(Math.hypot(e-s.cx,t-s.cy)-s.r)<=i)return true;return o.rays.some(s=>ne(e,t,s[0],s[1],s[2],s[3])<=i)}handlePoints(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return [];let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?[]:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.geom(e);if(!t)return null;let n=t.noseX,i=t.noseX,o=t.noseY,s=t.noseY;for(let a of t.circles)n=Math.min(n,a.cx-a.r),i=Math.max(i,a.cx+a.r),o=Math.min(o,a.cy-a.r),s=Math.max(s,a.cy+a.r);for(let a of t.rays)n=Math.min(n,a[0],a[2]),i=Math.max(i,a[0],a[2]),o=Math.min(o,a[1],a[3]),s=Math.max(s,a[1],a[3]);return {x:n,y:o,w:i-n,h:s-o}}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}applySettings(e){if(super.applySettings(e),Object.prototype.hasOwnProperty.call(e,"waveCount")&&typeof this.waveCount=="number"){let t=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=t;for(let n=0;n<this.levels.length;n+=1)this.levels[n].enabled=n<t;}}schema(){return {fields:[...B,{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},Kr,...H]}}writeProps(){return {waveCount:this.waveCount,showRatios:this.showRatios,levels:this.levels.map(e=>({...e}))}}readProps(e){if(typeof e.waveCount=="number"&&Number.isFinite(e.waveCount)&&(this.waveCount=Math.max(2,Math.min(12,Math.round(e.waveCount)))),typeof e.showRatios=="boolean"&&(this.showRatios=e.showRatios),Array.isArray(e.levels)){let t=e.levels.map(pS).filter(n=>n!=null);t.length&&(this.levels=t);}}},Zi=class extends Qe{constructor(){super(...arguments);this.type="sonic";}defaultLevels(){return Ru(Ia)}machNumber(){return 1}},Ji=class extends Qe{constructor(t){super(t);this.type="supersonic";this.mach===void 0&&(this.mach=hS);}defaultLevels(){return Ru(Ia)}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...B,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},Kr,...H]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var Tm=me([.236,.382,.5,.618,.786,1,1.618,2.618,4.236,6.854,11.09]),mS=2,Aa=class extends Qe{constructor(){super(...arguments);this.type="goldensonic";}shouldSyncWaveCount(){return false}defaultLevels(){return Tm}machNumber(){return 1}schema(){return {fields:[...B,Kr,...H]}}},Ra=class extends Qe{constructor(t){super(t);this.type="goldensupersonic";this.mach===void 0&&(this.mach=mS);}shouldSyncWaveCount(){return false}defaultLevels(){return Tm}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...B,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},Kr,...H]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var Ne=class extends G{legRatios(){return false}fillTriangles(){return []}necklineIndices(){return null}anchorSchema(){let e=this.vertexLabels().length,t=[];for(let n=0;n<e;n+=1)t.push({role:`p${n}`,free:"both"});return {min:e,max:e,slots:t}}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitTest(e,t,n,i){let o=this.handlePoints(n);return o.length>=2&&Wr(e,t,o)<=i}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}patternName(){return null}ratioOk(e){return null}valid(){return null}ratioAt(e){let t=this.anchors[e-2],n=this.anchors[e-1],i=this.anchors[e];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}schema(){return {fields:[...B,...this.fillTriangles().length?de:[]]}}};var Da=class extends Ne{constructor(){super(...arguments);this.type="xabcd";}vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}};var Oa=class extends Ne{constructor(){super(...arguments);this.type="abcd";}vertexLabels(){return ["A","B","C","D"]}legRatios(){return true}};var Na=class extends Ne{constructor(){super(...arguments);this.type="elliottimpulse";}vertexLabels(){return ["1","2","3","4","5"]}};var Fa=class extends Ne{constructor(){super(...arguments);this.type="elliottcorrection";}vertexLabels(){return ["A","B","C"]}};var Va=class extends Ne{constructor(){super(...arguments);this.type="headshoulders";}vertexLabels(){return ["","LS","","H","","RS",""]}necklineIndices(){return [2,4]}};var et=class extends Ne{vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}legValue(e){let[t,n,i,o,s]=this.anchors;if(!t||!n||!i||!o||!s)return null;let a=(d,h)=>Math.abs(h.price-d.price),l=a(t,n),c=a(n,i),u=a(i,o);switch(e){case "ab":return l<1e-9?null:c/l;case "bc":return c<1e-9?null:u/c;case "cd":return u<1e-9?null:a(o,s)/u;default:return l<1e-9?null:a(n,s)/l}}inBand(e,t){return e!=null&&e>=t.min&&e<=t.max}ratioOk(e){let t=this.ranges();return e===2?this.inBand(this.legValue("ab"),t.ab):e===3?this.inBand(this.legValue("bc"),t.bc):e===4?this.inBand(this.legValue("cd"),t.cd):null}valid(){if(this.anchors.length<5)return null;let e=this.ranges();return this.inBand(this.legValue("ab"),e.ab)&&this.inBand(this.legValue("bc"),e.bc)&&this.inBand(this.legValue("cd"),e.cd)&&this.inBand(this.legValue("ad"),e.ad)}};var _a=class extends et{constructor(){super(...arguments);this.type="gartley";}patternName(){return "Gartley"}ranges(){return {ab:{min:.55,max:.68},bc:{min:.382,max:.886},cd:{min:1.13,max:1.618},ad:{min:.74,max:.83}}}};var Ba=class extends et{constructor(){super(...arguments);this.type="bat";}patternName(){return "Bat"}ranges(){return {ab:{min:.382,max:.5},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:.84,max:.92}}}};var Ha=class extends et{constructor(){super(...arguments);this.type="butterfly";}patternName(){return "Butterfly"}ranges(){return {ab:{min:.74,max:.83},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:1.272,max:1.618}}}};var za=class extends et{constructor(){super(...arguments);this.type="crab";}patternName(){return "Crab"}ranges(){return {ab:{min:.382,max:.618},bc:{min:.382,max:.886},cd:{min:2.618,max:3.618},ad:{min:1.55,max:1.69}}}};var $a=class extends et{constructor(){super(...arguments);this.type="shark";}patternName(){return "Shark"}ranges(){return {ab:{min:.382,max:.618},bc:{min:1.13,max:1.618},cd:{min:1.618,max:2.24},ad:{min:.886,max:1.13}}}};var fS={min:1.272,max:1.414},gS={min:.74,max:.83},Wa=class extends et{constructor(){super(...arguments);this.type="cypher";}patternName(){return "Cypher"}ranges(){return {ab:{min:.382,max:.618},bc:{min:0,max:1/0},cd:{min:0,max:1/0},ad:{min:0,max:1/0}}}xcOverXa(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[3];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-t.price)/o}cdOverXc(){let t=this.anchors[0],n=this.anchors[3],i=this.anchors[4];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}ratioOk(t){return t===2?this.inBand(this.legValue("ab"),this.ranges().ab):null}valid(){return this.anchors.length<5?null:this.inBand(this.legValue("ab"),this.ranges().ab)&&this.inBand(this.xcOverXa(),fS)&&this.inBand(this.cdOverXc(),gS)}};function km(r){return `${r>=0?"+":""}${r.toFixed(2)}`}function Qi(r){let e=Math.abs(r),t=864e5,n=36e5,i=6e4;if(e>=t){let o=Math.floor(e/t),s=Math.round(e%t/n);return s?`${o}d ${s}h`:`${o}d`}if(e>=n){let o=Math.floor(e/n),s=Math.round(e%n/i);return s?`${o}h ${s}m`:`${o}h`}return e>=i?`${Math.round(e/i)}m`:`${Math.round(e/1e3)}s`}var mr=class extends G{constructor(e){super(e),this.showPrice===void 0&&(this.showPrice=true),this.showDate===void 0&&(this.showDate=true);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}measureLabel(e){let t=[];return this.showPrice&&t.push(this.priceLabel()),this.showDate&&t.push(this.timeLabel(e)),t}isUp(){let e=this.anchors[0],t=this.anchors[1];return e!=null&&t!=null&&t.price>=e.price}priceLabel(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return "";let n=t.price-e.price,i=e.price!==0?n/e.price*100:0;return `${km(n)} (${km(i)}%)`}timeLabel(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return "";let i=Qi(n.time-t.time),o=e.barsBetween?Math.round(e.barsBetween(t.time,n.time)):null;return o!=null?`${o} bars, ${i}`:i}rect(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:{x1:e.xOf(t.time),y1:i,x2:e.xOf(n.time),y2:o}}hitTest(e,t,n,i){let o=this.rect(n);return o!=null&&Ve(e,t,o.x1,o.y1,o.x2,o.y2,i)}handlePoints(e){let t=this.rect(e);return t?[[t.x1,t.y1],[t.x2,t.y2]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.rect(e);return t?{x:Math.min(t.x1,t.x2),y:Math.min(t.y1,t.y2),w:Math.abs(t.x2-t.x1),h:Math.abs(t.y2-t.y1)}:null}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[{path:"showPrice",label:"Show price",kind:"boolean",group:"behavior"},{path:"showDate",label:"Show date",kind:"boolean",group:"behavior"},...B.filter(e=>e.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ct,group:"text"}]}}writeProps(){return {showPrice:this.showPrice,showDate:this.showDate}}readProps(e){typeof e.showPrice=="boolean"&&(this.showPrice=e.showPrice),typeof e.showDate=="boolean"&&(this.showDate=e.showDate);}};var Ga=class extends mr{constructor(){super(...arguments);this.type="datepricerange";}};var Ua=[{value:"long",label:"Long"},{value:"short",label:"Short"}],Ee=class Ee extends G{constructor(t){super(t);this.type="position";this.riskPercent===void 0&&(this.riskPercent=Ee.DEFAULT_RISK_PERCENT),this.accountBalance===void 0&&(this.accountBalance=Ee.DEFAULT_ACCOUNT_BALANCE),this.showText===void 0&&(this.showText=true),this.showHeader===void 0&&(this.showHeader=true),this.showPrices===void 0&&(this.showPrices=false),this.showLossSize===void 0&&(this.showLossSize=true),this.showTargetLabel===void 0&&(this.showTargetLabel=true),this.showStopLabel===void 0&&(this.showStopLabel=true),this.profitColor===void 0&&(this.profitColor=Ee.DEFAULT_PROFIT_COLOR),this.lossColor===void 0&&(this.lossColor=Ee.DEFAULT_LOSS_COLOR);}directionLabel(){let t=this.prices();return t&&t.target>=t.entry?"LONG":"SHORT"}get direction(){return this.directionLabel()==="LONG"?"long":"short"}set direction(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];!n||!i||!o||(t==="long"||t==="short")&&t!==this.direction&&(i.price=2*n.price-i.price,o.price=2*n.price-o.price);}get quantity(){return this.positionSize()}set quantity(t){let n=this.prices();if(!n||!Number.isFinite(t)||t<0)return;let i=Math.abs(n.entry-n.stop);i<1e-9||this.accountBalance<=0||(this.riskPercent=t*i/this.accountBalance*100);}get entryPrice(){return this.anchors[0]?.price??0}set entryPrice(t){let n=this.anchors[0];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(0));}get stopPrice(){return this.anchors[1]?.price??0}set stopPrice(t){let n=this.anchors[1];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(1));}get targetPrice(){return this.anchors[2]?.price??0}set targetPrice(t){let n=this.anchors[2];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(2));}anchorSchema(){return {min:2,max:2,slots:[{role:"entry",free:"both"},{role:"stop",free:"both"},{role:"target",free:"both"}]}}onPlaced(t){let n=this.anchors[0];if(!n)return;let i=t.xOf(n.time),o=t.yOf(n.price,this.paneId);if(o==null)return;let s=this.anchors[1],a=s?t.yOf(s.price,this.paneId):null,l,c;s&&a!=null&&Math.abs(a-o)>=Ee.MIN_DRAG_PX?(l=a,c=i+Math.max(Math.abs(t.xOf(s.time)-i),Ee.MIN_WIDTH_PX)):(l=o-Ee.DEFAULT_RISK_PX*Ee.DEFAULT_RR,c=i+Ee.DEFAULT_WIDTH_PX);let u=o-(l-o)/Ee.DEFAULT_RR,d=t.pxToPoint(c,o,this.paneId).time;this.anchors=[{time:n.time,price:n.price},{time:d,price:t.pxToPoint(i,u,this.paneId).price},{time:d,price:t.pxToPoint(i,l,this.paneId).price}];}constrainHandleDrag(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return;let s=Math.sign(i.price-n.price),a=Math.sign(o.price-n.price);s===0||a===0||s!==a||(t===2?i.price=2*n.price-i.price:o.price=2*n.price-o.price);}resolved(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;if(this.anchors[2])return [t,n,this.anchors[2]];let i={time:n.time,price:t.price-(n.price-t.price)/Ee.DEFAULT_RR};return [t,i,n]}prices(){let t=this.resolved();return t?{entry:t[0].price,stop:t[1].price,target:t[2].price}:null}rr(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:Math.abs(t.target-t.entry)/n}rewardPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.target-t.entry)/t.entry*100:0}riskPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.entry-t.stop)/t.entry*100:0}dollarLoss(){return Math.max(0,this.accountBalance)*(Math.max(0,this.riskPercent)/100)}positionSize(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:this.dollarLoss()/n}headerLabel(){return `${this.directionLabel()} \xB7 R:R ${this.rr().toFixed(2)}`}lossSizeLabel(){return `Loss $${bS(this.dollarLoss())} \xB7 Size ${vS(this.positionSize())}`}targetLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Em(t.target)}`:"";return `Target +${this.rewardPct().toFixed(2)}%${n}`}stopLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Em(t.stop)}`:"";return `Stop \u2212${this.riskPct().toFixed(2)}%${n}`}levelDisplayValue(t,n){let i=this.prices();if(!i)return 0;let o=t==="stop"?i.stop:i.target;return Mm(n==="price"?o:Math.abs(o-i.entry))}levelPriceFromDisplay(t,n,i){let o=this.prices();if(!o||n==="price")return i;let s=t==="stop"?o.stop:o.target,a=Math.sign(s-o.entry);return a===0&&(a=(t==="target"?1:-1)*(this.direction==="long"?1:-1)),o.entry+a*Math.abs(i)}box(t){let n=this.handlePoints(t);if(n.length<3)return null;let i=n.map(o=>o[0]);return {x1:Math.min(...i),x2:Math.max(...i),ey:n[0][1],sy:n[1][1],ty:n[2][1]}}layout(t){return this.box(t)}hitTest(t,n,i,o){let s=this.box(i);if(!s)return false;let a=Math.min(s.ey,s.sy,s.ty),l=Math.max(s.ey,s.sy,s.ty);return Ve(t,n,s.x1,a,s.x2,l,o)}handlePoints(t){let n=this.resolved();if(!n)return [];let i=[];for(let o of n){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);if(!n)return null;let i=Math.min(n.ey,n.sy,n.ty);return {x:n.x1,y:i,w:n.x2-n.x1,h:Math.max(n.ey,n.sy,n.ty)-i}}priceRange(){let t=this.resolved();if(!t)return null;let n=t.map(i=>i.price);return {min:Math.min(...n),max:Math.max(...n)}}schema(){return {fields:[{path:"riskPercent",label:"Risk %",kind:"number",min:0,max:100,step:.1,group:"behavior"},{path:"accountBalance",label:"Account balance",kind:"number",min:0,max:1e12,step:1,group:"behavior"},{path:"quantity",label:"Position size",kind:"number",group:"behavior"},{path:"direction",label:"Direction",kind:"select",options:Ua,group:"behavior"},{path:"entryPrice",label:"Entry price",kind:"number",group:"behavior"},{path:"stopPrice",label:"Stop price",kind:"number",group:"behavior"},{path:"targetPrice",label:"Target price",kind:"number",group:"behavior"},{path:"showText",label:"Show text",kind:"boolean",group:"behavior"},{path:"showHeader",label:"Show direction & ratio",kind:"boolean",group:"behavior"},{path:"showLossSize",label:"Show loss & size",kind:"boolean",group:"behavior"},{path:"showTargetLabel",label:"Show target label",kind:"boolean",group:"behavior"},{path:"showStopLabel",label:"Show stop label",kind:"boolean",group:"behavior"},{path:"showPrices",label:"Show level prices",kind:"boolean",group:"behavior"},{path:"profitColor",label:"Profit zone",kind:"color",group:"fill"},{path:"lossColor",label:"Loss zone",kind:"color",group:"fill"},...B.filter(t=>t.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ct,group:"text"}]}}writeProps(){return {riskPercent:this.riskPercent,accountBalance:this.accountBalance,showText:this.showText,showHeader:this.showHeader,showPrices:this.showPrices,showLossSize:this.showLossSize,showTargetLabel:this.showTargetLabel,showStopLabel:this.showStopLabel,profitColor:this.profitColor,lossColor:this.lossColor}}readProps(t){typeof t.riskPercent=="number"&&Number.isFinite(t.riskPercent)&&(this.riskPercent=t.riskPercent),typeof t.accountBalance=="number"&&Number.isFinite(t.accountBalance)&&(this.accountBalance=t.accountBalance),typeof t.showText=="boolean"&&(this.showText=t.showText),typeof t.showHeader=="boolean"&&(this.showHeader=t.showHeader),typeof t.showPrices=="boolean"&&(this.showPrices=t.showPrices),typeof t.showLossSize=="boolean"&&(this.showLossSize=t.showLossSize),typeof t.showTargetLabel=="boolean"&&(this.showTargetLabel=t.showTargetLabel),typeof t.showStopLabel=="boolean"&&(this.showStopLabel=t.showStopLabel),typeof t.profitColor=="string"&&(this.profitColor=t.profitColor),typeof t.lossColor=="string"&&(this.lossColor=t.lossColor);}};Ee.DEFAULT_RR=2,Ee.MIN_DRAG_PX=6,Ee.DEFAULT_RISK_PX=64,Ee.DEFAULT_WIDTH_PX=150,Ee.MIN_WIDTH_PX=48,Ee.DEFAULT_RISK_PERCENT=1,Ee.DEFAULT_ACCOUNT_BALANCE=1e4,Ee.DEFAULT_PROFIT_COLOR=_s,Ee.DEFAULT_LOSS_COLOR=Bs;var ht=Ee;function bS(r){if(!Number.isFinite(r))return "0";let e=Math.round(r*100)/100;return Number.isInteger(e)?String(e):e.toFixed(2)}function vS(r){return !Number.isFinite(r)||r===0?"0":r>=100?r.toFixed(2):r>=1?r.toFixed(4).replace(/\.?0+$/,""):r.toPrecision(4).replace(/\.?0+$/,"")}function Em(r){return Number.isFinite(r)?Math.abs(r)>=1?r.toFixed(2):r.toPrecision(4).replace(/\.?0+$/,""):"0"}function Mm(r){return Math.round(r*1e8)/1e8}var fr=[{value:"auto",label:"Auto",ms:0},{value:"1",label:"1m",ms:6e4},{value:"5",label:"5m",ms:3e5},{value:"15",label:"15m",ms:9e5},{value:"30",label:"30m",ms:18e5},{value:"60",label:"1h",ms:36e5},{value:"240",label:"4h",ms:144e5},{value:"D",label:"1D",ms:864e5}];function eo(r){let e=fr.find(n=>n.value===r);if(e)return e.label;let t=Number(r);return Number.isFinite(t)&&t>0?t%1440===0?`${t/1440}D`:t%60===0?`${t/60}h`:`${t}m`:r}function Lm(){return {timeframe:"auto",upColor:"",downColor:""}}var tt=class extends G{constructor(t){super(t);this.type="magnifier";this.chipRect=null;this.magnifier||(this.magnifier=Lm());}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}placementMode(){return "drag"}rect(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{x1:t.xOf(n.time),y1:o,x2:t.xOf(i.time),y2:s}}hitTest(t,n,i,o){let s=this.rect(i);return s?Ve(t,n,s.x1,s.y1,s.x2,s.y2)?true:[[s.x1,s.y1,s.x2,s.y1],[s.x2,s.y1,s.x2,s.y2],[s.x2,s.y2,s.x1,s.y2],[s.x1,s.y2,s.x1,s.y1]].some(l=>ne(t,n,l[0],l[1],l[2],l[3])<=o):false}handlePoints(t){let n=this.rect(t);return n?[[n.x1,n.y1],[n.x2,n.y2]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.rect(t);return n?{x:Math.min(n.x1,n.x2),y:Math.min(n.y1,n.y2),w:Math.abs(n.x2-n.x1),h:Math.abs(n.y2-n.y1)}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"magnifier.timeframe",label:"Timeframe",kind:"select",options:fr,group:"behavior"},...B.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"magnifier.upColor",label:"Up candles",kind:"color",group:"fill"},{path:"magnifier.downColor",label:"Down candles",kind:"color",group:"fill"}]}}writeProps(){return {...this.magnifier}}readProps(t){this.magnifier={...Lm(),...t};}};var to=new Map;function V(r){to.set(r.type,r);}function kt(r){return to.get(r)}function Ya(){return [...to.values()]}function Dn(r,e){let t=to.get(r);if(!t)return null;let n={...t.defaultStyle,...e.style??{}};return t.create({...e,style:n})}function Ka(r){let e=Dn(r.type,{paneId:r.paneId});if(!e)return;r.style={...e.style};let t=r.text?.value;e.text?(r.text={...e.text},t!==void 0&&(r.text.value=t)):r.text=void 0;let n=e.serialize().props;n!==void 0&&r.applyProps(n);}function pt(r){let e=to.get(r.type);return e?e.create(r):null}var yS=R('<line x1="4" y1="19" x2="20" y2="5"/>'),wS=R('<line x1="3" y1="12" x2="21" y2="12"/>');V({type:"trendline",group:"lines",label:"Trend Line",icon:yS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new zs(r)});V({type:"hline",group:"lines",label:"Horizontal Line",icon:wS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"dashed"},create:r=>new $s(r)});var xS=R('<line x1="3" y1="20" x2="21" y2="6"/><circle cx="3" cy="20" r="1.6" fill="currentColor"/>'),SS=R('<rect x="4" y="6" width="16" height="12" rx="1"/>'),CS=R('<path d="M5 6h14M12 6v13"/>');V({type:"ray",group:"lines",label:"Ray",icon:xS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Ws(r)});var TS=R('<path d="M5 19 19 5"/><path d="M5 19 8.5 19M5 19 5 15.5"/><path d="M19 5 15.5 5M19 5 19 8.5"/>'),kS=R('<line x1="12" y1="3" x2="12" y2="21"/>'),ES=R('<line x1="5" y1="12" x2="21" y2="12"/><circle cx="5" cy="12" r="1.6" fill="currentColor"/>'),MS=R('<line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/>'),LS=R('<path d="M4 20 20 4"/><rect x="9" y="9" width="9" height="6" rx="1"/>'),PS=R('<path d="M4 20 20 6"/><path d="M4 20 15 20"/><path d="M11 20a7 7 0 0 0-2-4.9"/>');V({type:"extendedline",group:"lines",label:"Extended Line",icon:TS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Gs(r)});V({type:"vline",group:"lines",label:"Vertical Line",icon:kS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Us(r)});V({type:"hray",group:"lines",label:"Horizontal Ray",icon:ES,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Ys(r)});V({type:"crossline",group:"lines",label:"Cross Line",icon:MS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ks(r)});V({type:"infoline",group:"lines",label:"Info Line",icon:LS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Xs(r)});V({type:"trendangle",group:"lines",label:"Trend Angle",icon:PS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new js(r)});V({type:"box",group:"shapes",label:"Rectangle",icon:SS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}26`},create:r=>new qs(r)});V({type:"text",group:"annotations",label:"Text",icon:CS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ln(r)});var IS=R('<path d="M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-6l-5 5v-5H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z"/>');V({type:"callout",group:"annotations",label:"Callout",icon:IS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new Bt(r)});var AS=R('<path d="M5 4h14a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-7l-4 4v-4H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z"/><path d="M8 8.5h8M8 12h5"/>'),RS=R('<rect x="10" y="4.5" width="11" height="8" rx="1.5"/><path d="M10 8.5 4 16"/><circle cx="3.5" cy="16.5" r="1.6" fill="currentColor" stroke="none"/>'),DS=R('<path d="M5 4.5h14a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-7l-4 4v-4H5a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2Z"/>'),OS=R('<path d="M3 12 7 8h12a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H7Z"/><path d="M10.5 12.5h6" stroke-width="1.4"/>'),NS=R('<path d="M12 11.5V21"/><rect x="5" y="4" width="14" height="7" rx="1"/><path d="M9 7.5h6"/>');V({type:"note",group:"annotations",label:"Note",icon:AS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new er(r)});V({type:"pricenote",group:"annotations",label:"Price Note",icon:RS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new nr(r)});V({type:"comment",group:"annotations",label:"Comment",icon:DS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new rr(r)});V({type:"pricelabel",group:"annotations",label:"Price Label",icon:OS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new tr(r)});V({type:"signpost",group:"annotations",label:"Signpost",icon:NS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new ir(r)});var FS=R('<line x1="3" y1="16" x2="21" y2="8"/><line x1="3" y1="21" x2="21" y2="13"/>'),VS=R('<line x1="3" y1="7" x2="21" y2="10"/><line x1="3" y1="18" x2="21" y2="14"/>'),_S=R('<circle cx="4" cy="12" r="1.6" fill="currentColor"/><line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>');V({type:"parallelchannel",group:"channels",label:"Parallel Channel",icon:FS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new Zs(r)});V({type:"disjointchannel",group:"channels",label:"Disjoint Channel",icon:VS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new Js(r)});var BS=R('<line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="18" x2="21" y2="11"/>');V({type:"flattopbottom",group:"channels",label:"Flat Top/Bottom",icon:BS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new Qs(r)});var HS=R('<line x1="3" y1="8" x2="21" y2="4"/><line x1="3" y1="16" x2="21" y2="12"/><line x1="3" y1="12" x2="21" y2="8" stroke-dasharray="3 3"/>');V({type:"regressionchannel",group:"channels",label:"Linear Regression",icon:HS,defaultStyle:{lineColor:J,lineWidth:1,lineStyle:"solid"},create:r=>new cn(r)});V({type:"pitchfork",group:"pitchforks",label:"Pitchfork",icon:_S,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ea(r)});var zS=R('<circle cx="4" cy="8" r="1.6" fill="currentColor"/><line x1="4" y1="8" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),$S=R('<circle cx="6" cy="9" r="1.6" fill="currentColor"/><line x1="6" y1="9" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),WS=R('<line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="8" x2="10" y2="16"/><line x1="10" y1="8" x2="21" y2="8"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="16" x2="21" y2="16"/>');V({type:"schiffpitchfork",group:"pitchforks",label:"Schiff Pitchfork",icon:zS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ta(r)});V({type:"modifiedschiffpitchfork",group:"pitchforks",label:"Modified Schiff Pitchfork",icon:$S,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new na(r)});V({type:"insidepitchfork",group:"pitchforks",label:"Inside Pitchfork",icon:WS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ra(r)});var GS=R('<path d="M7 7h10v10"/><path d="M7 17 17 7"/>'),US=R('<ellipse cx="12" cy="12" rx="9" ry="6"/>'),YS=R('<path d="M12 4 20 19 4 19Z"/>');V({type:"arrow",group:"shapes",label:"Arrow",icon:GS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",arrowRight:true},create:r=>new ia(r)});V({type:"ellipse",group:"shapes",label:"Ellipse",icon:US,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new oa(r)});V({type:"triangle",group:"shapes",label:"Triangle",icon:YS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new sa(r)});var KS=R('<polyline points="3 17 9 10 13 14 21 5"/>'),XS=R('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'),jS=R('<path d="M9 11 15 5l4 4-6 6H9Z"/><path d="M9 15l-2 2"/><path d="M4 21h6"/>');V({type:"polyline",group:"shapes",label:"Polyline",icon:KS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new aa(r)});V({type:"freehand",group:"shapes",label:"Brush",icon:XS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new la(r)});V({type:"highlighter",group:"shapes",label:"Highlighter",icon:jS,defaultStyle:{lineColor:`${Yp}59`,lineWidth:14,lineStyle:"solid"},create:r=>new ca(r)});var qS=R('<circle cx="12" cy="12" r="8"/>'),ZS=R('<path d="M5 14 9.5 5 19 10 14.5 19 Z"/>'),JS=R('<path d="M4 19 9 11 13 14 17 8 20 4"/><path d="M17.2 5.5 20 4 19.4 7.1"/>'),QS=R('<path d="M4 17a8 8 0 0 1 16 0"/><path d="M4 17 20 17"/>'),eC=R('<path d="M4 18Q12 1 20 14"/>'),tC=R('<path d="M12 5 12 19"/><path d="M6 11 12 5 18 11"/>'),nC=R('<path d="M12 5 12 19"/><path d="M6 13 12 19 18 13"/>');V({type:"circle",group:"shapes",label:"Circle",icon:qS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new ua(r)});V({type:"rotatedrect",group:"shapes",label:"Rotated Rectangle",icon:ZS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}26`},create:r=>new da(r)});V({type:"path",group:"shapes",label:"Path",icon:JS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ha(r)});V({type:"arc",group:"shapes",label:"Arc",icon:QS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}26`},create:r=>new pa(r)});V({type:"curve",group:"shapes",label:"Curve",icon:eC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ma(r)});V({type:"arrowmarkup",group:"shapes",label:"Arrow Mark Up",icon:tC,defaultStyle:{lineColor:z,lineWidth:1,lineStyle:"solid"},create:r=>new Yi(r)});V({type:"arrowmarkdown",group:"shapes",label:"Arrow Mark Down",icon:nC,defaultStyle:{lineColor:W,lineWidth:1,lineStyle:"solid"},create:r=>new Ki(r)});var rC=R('<path d="M6 21V4"/><path d="M6 5h11l-2.5 3.5L17 12H6" fill="currentColor" stroke="none"/>'),iC=R('<path d="m12 3 2.6 5.8 6.4.6-4.8 4.2 1.4 6.2L12 16.9 6.4 19.8 7.8 13.6 3 9.4l6.4-.6Z"/>');V({type:"flagmark",group:"stamps",label:"Flag",icon:rC,defaultStyle:{lineColor:Ke,lineWidth:1,lineStyle:"solid"},create:r=>new Xi(r)});V({type:"iconstamp",group:"stamps",label:"Icon",icon:iC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ji(r)});var oC=R('<line x1="3" y1="5" x2="21" y2="5"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="3" y1="14" x2="21" y2="14"/><line x1="3" y1="19" x2="21" y2="19"/>'),sC=R('<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="15" x2="14" y2="15"/><line x1="3" y1="20" x2="14" y2="20"/>');V({type:"fibretracement",group:"fibonacci",label:"Fib Retracement",icon:oC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ba(r)});V({type:"fibextension",group:"fibonacci",label:"Fib Extension",icon:sC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new va(r)});var aC=R('<path d="M3 20 10 9l4 5"/><path d="M14 14h7M14 9h7M14 4h7"/>');V({type:"fibextensiontrend",group:"fibonacci",label:"Trend-Based Fib Extension",icon:aC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ya(r)});var lC=R('<path d="M4 20 20 5M4 20 21 11M4 20 21 17M4 20 20 20"/>'),cC=R('<path d="M3 5v14M6 5v14M11 5v14M19 5v14"/>');V({type:"fibfan",group:"fibonacci",label:"Fib Fan",icon:lC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new wa(r)});V({type:"fibtimezones",group:"fibonacci",label:"Fib Time Zones",icon:cC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"dashed"},create:r=>new xa(r)});var uC=R('<path d="M3 18 18 9M5 21 20 12M6 13 21 4"/>'),dC=R('<path d="M4 4 20 20M4 4 20 12M4 4 12 20M4 4 20 4M4 4 4 20"/>'),hC=R('<path d="M3 19 9 8M9 8 12 5v14M14 5v14M18 5v14M21 5v14"/>');V({type:"fibchannel",group:"fibonacci",label:"Fib Channel",icon:uC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Sa(r)});V({type:"fibspeedfan",group:"fibonacci",label:"Fib Speed Resistance Fan",icon:dC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ca(r)});V({type:"trendfibtime",group:"fibonacci",label:"Trend-Based Fib Time",icon:hC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"dashed"},create:r=>new Ta(r)});var pC=R('<circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/><circle cx="12" cy="12" r="10"/>'),mC=R('<path d="M8 20a4 4 0 0 1 8 0"/><path d="M4.5 20a7.5 7.5 0 0 1 15 0"/><circle cx="12" cy="20" r="1.4" fill="currentColor" stroke="none"/>'),fC=R('<path d="M4 20 20 16M4 20 14 4"/><path d="M11.8 18.1A8 8 0 0 0 8.2 13.2"/><path d="M16.6 16.9A13 13 0 0 0 10.9 9"/>'),gC=R('<path d="M13 12a2 2 0 1 1-2-2 4 4 0 0 1 4 4 6 6 0 0 1-9 5.2 9 9 0 0 1 .5-15"/>');V({type:"fibcircles",group:"fibonacci",label:"Fib Circles",icon:pC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ka(r)});V({type:"fibarcs",group:"fibonacci",label:"Fib Speed Resistance Arcs",icon:mC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ea(r)});V({type:"fibwedge",group:"fibonacci",label:"Fib Wedge",icon:fC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ma(r)});V({type:"fibspiral",group:"fibonacci",label:"Fib Spiral",icon:gC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new dr(r)});var bC=R('<path d="M4 20 20 20M4 20 20 13M4 20 20 6M4 20 15 4M4 20 9 4M4 20 4 4"/>'),vC=R('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 12h16M12 4v16M4 4 20 20" opacity="0.6"/>');V({type:"gannfan",group:"fibonacci",label:"Gann Fan",icon:bC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new La(r)});V({type:"gannbox",group:"fibonacci",label:"Gann Box",icon:vC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Pa(r)});var yC=R('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 20 20 4M4 20 20 12M4 20 12 4" opacity="0.7"/><path d="M4 20a16 16 0 0 1 16-16" opacity="0.5"/>');V({type:"gannsquare",group:"fibonacci",label:"Gann Square",icon:yC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new hr(r)});var wC=R('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0" opacity="0.9"/><path d="M6 20a4 4 0 0 1 8 0" opacity="0.75"/><path d="M10 20a2 2 0 0 1 4 0" opacity="0.6"/><path d="M8 20v-6M12 20v-9M16 20v-6" opacity="0.45"/>');V({type:"dedekind",group:"geometry",label:"Dedekind Tessellation",icon:wC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new pr(r)});var xC=R('<circle cx="16" cy="12" r="5" opacity="0.55"/><circle cx="13" cy="12" r="3.5" opacity="0.75"/><circle cx="10.5" cy="12" r="2"/><path d="M8 4v16"/>'),SC=R('<circle cx="17" cy="12" r="4.5" opacity="0.45"/><circle cx="13" cy="12" r="3" opacity="0.7"/><circle cx="10" cy="12" r="1.6"/><path d="M6 12 16 5M6 12 16 19"/>');V({type:"sonic",group:"geometry",label:"Sonic",icon:xC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Zi(r)});V({type:"supersonic",group:"geometry",label:"Supersonic",icon:SC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ji(r)});var CC=R('<circle cx="16" cy="12" r="5" opacity="0.4"/><circle cx="13" cy="12" r="3.2" opacity="0.65"/><circle cx="10.8" cy="12" r="1.8"/><path d="M8 4v16"/><path d="M15 8.5h2M12.5 10h2" opacity="0.5"/>'),TC=R('<circle cx="17" cy="12" r="4.5" opacity="0.4"/><circle cx="12.5" cy="12" r="2.8" opacity="0.65"/><circle cx="9.8" cy="12" r="1.4"/><path d="M6 12 16 5M6 12 16 19"/>');V({type:"goldensonic",group:"geometry",label:"Golden Sonic",icon:CC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Aa(r)});V({type:"goldensupersonic",group:"geometry",label:"Golden Supersonic",icon:TC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ra(r)});var kC=R('<path d="M3 18 7 8 11 14 15 6 20 16"/>'),EC=R('<path d="M4 17 9 7 14 15 20 5"/>'),MC=R('<path d="M3 19 8 9 12 13 17 5 21 9"/>'),LC=R('<path d="M4 7 11 16 20 9"/>'),PC=R('<path d="M3 18 6 12 9 16 12 5 15 16 18 12 21 18"/>');V({type:"xabcd",group:"patterns",label:"XABCD Pattern",icon:kC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Da(r)});V({type:"abcd",group:"patterns",label:"ABCD Pattern",icon:EC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Oa(r)});V({type:"elliottimpulse",group:"patterns",label:"Elliott Impulse Wave (1-5)",icon:MC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Na(r)});V({type:"elliottcorrection",group:"patterns",label:"Elliott Correction Wave (ABC)",icon:LC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Fa(r)});V({type:"headshoulders",group:"patterns",label:"Head & Shoulders",icon:PC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Va(r)});var IC=R('<path d="M3 17 7 6 12 14 17 5 21 16"/><path d="M3 17 21 16" opacity="0.45"/>'),Xr={group:"patterns",icon:IC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"}};V({type:"gartley",label:"Gartley",...Xr,create:r=>new _a(r)});V({type:"bat",label:"Bat",...Xr,create:r=>new Ba(r)});V({type:"butterfly",label:"Butterfly",...Xr,create:r=>new Ha(r)});V({type:"crab",label:"Crab",...Xr,create:r=>new za(r)});V({type:"shark",label:"Shark",...Xr,create:r=>new $a(r)});V({type:"cypher",label:"Cypher",...Xr,create:r=>new Wa(r)});var AC=R('<rect x="4" y="6" width="16" height="12" rx="1"/><path d="M4 18 20 6" opacity="0.5"/>');V({type:"datepricerange",group:"measure",label:"Date & Price Range",icon:AC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ga(r)});var RC=R('<rect x="4.5" y="4.5" width="15" height="7.5" rx="1" fill="currentColor" fill-opacity="0.25"/><rect x="4.5" y="12" width="15" height="7.5" rx="1"/>');V({type:"position",group:"measure",label:"Long/Short Position",icon:RC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ht(r)});var DC=R('<circle cx="10.5" cy="10.5" r="6.5"/><path d="m15.3 15.3 5.2 5.2"/><path d="M8 12.5v-3M10.5 13.5v-5.5M13 12v-2"/>');V({type:"magnifier",group:"measure",label:"Magnifier",icon:DC,defaultStyle:{lineColor:"",lineWidth:1,lineStyle:"solid"},coversSeries:true,placementHint:"Drag an area on the chart to view it at a lower timeframe",create:r=>new tt(r)});var OC=R('<line x1="5" y1="3" x2="5" y2="21"/><path d="M5 16c4 0 5-9 8-9s3 5 8 3"/>');V({type:"anchoredvwap",group:"measure",label:"Anchored VWAP",icon:OC,defaultStyle:{lineColor:Je,lineWidth:2,lineStyle:"solid"},create:r=>new or(r)});var NC=R('<path d="M4 4v16"/><path d="M4 8h10"/><path d="M4 12h14"/><path d="M4 16h8"/><path d="M4 20h12"/>');V({type:"fixedrangevp",group:"measure",label:"Fixed Range Volume Profile",icon:NC,defaultStyle:{lineColor:z,lineWidth:1,lineStyle:"solid"},create:r=>new at(r)});var FC=["fibretracement","fibextension","fibextensiontrend","fibfan","fibtimezones","fibchannel","fibspeedfan","trendfibtime","fibcircles","fibarcs","fibwedge","fibspiral"],VC=["gannfan","gannbox","gannsquare"],_C=["dedekind","sonic","supersonic","goldensonic","goldensupersonic"],BC=["xabcd","abcd","headshoulders"],HC=["elliottimpulse","elliottcorrection"],zC=["gartley","bat","butterfly","crab","shark","cypher"],$C=["position","datepricerange","magnifier"],WC=["anchoredvwap","fixedrangevp"],GC=["freehand","highlighter"],UC=["arrow","arrowmarkup","arrowmarkdown"],YC=["box","ellipse","triangle","polyline","circle","rotatedrect","path","arc","curve"],KC=["text","callout","note","pricenote","comment","pricelabel","signpost"],XC=["flagmark","iconstamp"],jC=[{id:"lines-channels-pitchforks",label:"Lines",sections:[{label:"Lines",registryGroup:"lines"},{label:"Channels",registryGroup:"channels"},{label:"Pitchforks",registryGroup:"pitchforks"}]},{id:"fibonacci-gann",label:"Fibonacci",sections:[{label:"Fibonacci",types:FC},{label:"Gann",types:VC},{label:"Geometry",types:_C}]},{id:"patterns-waves-harmonics",label:"Patterns",sections:[{label:"Patterns",types:BC},{label:"Elliott Waves",types:HC},{label:"Harmonics",types:zC}]},{id:"measurements",label:"Measurements",sections:[{label:"Measurements",types:$C},{label:"Volume",types:WC}]},{id:"brushes-arrows-shapes",label:"Shapes",sections:[{label:"Brushes",types:GC},{label:"Arrows",types:UC},{label:"Shapes",types:YC}]},{id:"text",label:"Text",sections:[{label:"Text",types:KC}]},{id:"icons",label:"Icons",sections:[{label:"Icons",types:XC}]}];function qC(r){let e=kt(r);return e?{type:e.type,label:e.label,icon:e.icon}:null}function ZC(r){let e=new Map;for(let t of Ya()){if(r&&!r.has(t.type))continue;let n={type:t.type,label:t.label,icon:t.icon};e.has(t.group)||e.set(t.group,[]),e.get(t.group).push(n);}return e}function JC(r,e,t){return "registryGroup"in r?e.get(r.registryGroup)??[]:r.types.map(n=>t.get(n)).filter(n=>n!=null)}function Pm(r){let e=ZC(r),t=new Map;for(let i of e.values())for(let o of i)t.set(o.type,o);let n=[];for(let i of jC){let o=[],s=[];for(let a of i.sections){let l=JC(a,e,t);l.length!==0&&(o.push({label:a.label,tools:l}),s.push(...l));}s.length!==0&&n.push({id:i.id,label:i.label,tools:s,sections:o.length>0?o:void 0});}return {groups:n}}function QC(r){let e=new Set;for(let t of r)kt(t)&&e.add(t);return Pm(e)}function e1(r){let e=[];for(let t of r){let n=t.tools.map(qC).filter(i=>i!=null);n.length>0&&e.push({id:t.id,label:t.label,tools:n});}return {groups:e}}function no(){return Pm()}function ro(r){if(r===false)return {definition:no(),visible:false};if(r===void 0||r===true)return {definition:no(),visible:true};let e=r.toolbar??true;return r.groups?{definition:e1(r.groups),visible:e}:r.tools?{definition:QC(r.tools),visible:e}:{definition:no(),visible:e}}function $t(r){let e=globalThis.structuredClone;return e?e(r):JSON.parse(JSON.stringify(r))}function Im(r){if(!r||typeof r!="object")return false;let e=r;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.paneId=="string"&&Array.isArray(e.anchors)&&e.anchors.every(t=>t&&typeof t.time=="number"&&typeof t.price=="number")&&!!e.style&&typeof e.style=="object"}function Du(r){let e=r;return !e||typeof e!="object"||e.version!==1||!Array.isArray(e.drawings)?{version:1,drawings:[]}:{version:1,drawings:e.drawings.filter(Im)}}var jr=class{constructor(){this.byId=new Map;this.seq=0;this.zCounter=1;this.listeners=new Set;}nextId(){return this.seq+=1,`dw-${this.seq}`}add(e){return e.zIndex||(e.zIndex=this.zCounter),this.zCounter=Math.max(this.zCounter,Math.ceil(e.zIndex))+1,this.byId.set(e.id,e),this.emit(),e}remove(e){let t=this.byId.delete(e);return t&&this.emit(),t}get(e){return this.byId.get(e)}has(e){return this.byId.has(e)}update(e,t){let n=this.byId.get(e);return n?(t.anchors&&(n.anchors=t.anchors.map(i=>({time:i.time,price:i.price}))),t.style&&(n.style={...t.style}),t.text!==void 0&&(n.text=t.text?{...t.text}:void 0),t.paneId!==void 0&&(n.paneId=t.paneId),t.locked!==void 0&&(n.locked=t.locked),t.visible!==void 0&&(n.visible=t.visible),t.zIndex!==void 0&&(n.zIndex=t.zIndex),t.props!==void 0&&n.applyProps(t.props),this.emit(),n):null}all(){return [...this.byId.values()].sort((e,t)=>e.zIndex-t.zIndex)}byPane(e){return this.all().filter(t=>t.paneId===e)}bringToFront(e,t=0){let n=this.byId.get(e);n&&(n.zIndex=Math.max(this.zCounter,Math.floor(t)+1),this.zCounter=n.zIndex+1,this.emit());}sendToBack(e,t=1){let n=this.byId.get(e);if(!n)return;let i=Math.min(...[...this.byId.values()].map(o=>o.zIndex),Math.ceil(t));n.zIndex=i-1,this.emit();}setLocked(e,t){let n=this.byId.get(e);n&&(n.locked=t,this.emit());}setVisible(e,t){let n=this.byId.get(e);n&&(n.visible=t,this.emit());}clear(){this.byId.size!==0&&(this.byId.clear(),this.emit());}serialize(){return {version:1,drawings:this.all().map(e=>e.serialize())}}load(e){let t=Du(e);this.byId.clear(),this.seq=0,this.zCounter=1;for(let n of t.drawings){let i=pt(n);i&&(this.byId.set(i.id,i),this.zCounter=Math.max(this.zCounter,i.zIndex)+1,this.bumpSeqPast(i.id));}this.emit();}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}bumpSeqPast(e){let t=/^dw-(\d+)$/.exec(e);t&&(this.seq=Math.max(this.seq,Number(t[1])));}emit(){for(let e of this.listeners)e();}};var Xa=class{constructor(e=100){this.cap=e;this.undoStack=[];this.redoStack=[];this.pending=null;this.dirtied=false;this.depth=0;}begin(e){this.depth+=1,this.depth===1&&(this.pending=$t(e),this.dirtied=false);}markDirty(){this.depth===0||this.dirtied||!this.pending||(this.push(this.pending),this.dirtied=true);}commit(){this.depth!==0&&(this.depth-=1,this.depth===0&&(this.pending=null,this.dirtied=false));}abort(){this.commit();}record(e){if(this.depth>0){this.markDirty();return}this.push($t(e));}undo(e){let t=this.undoStack.pop();return t?(this.redoStack.push($t(e)),t):null}redo(e){let t=this.redoStack.pop();return t?(this.undoStack.push($t(e)),t):null}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[],this.pending=null,this.dirtied=false,this.depth=0;}push(e){this.undoStack.push(e),this.undoStack.length>this.cap&&this.undoStack.shift(),this.redoStack=[];}};var ja=class{constructor(e,t,n,i){this.events=t;this.store=new jr;this.history=new Xa;this.activeTool=null;this.snapMode="off";this.stayInDrawingMode=false;this.mode=null;this.favs=new Set;this.selectedIds=[];this.clipboard=[];this.lastStyle=new Map;this.subs=[];if(this.enabled=!!e.capabilities.userDrawings&&!!e.userDrawingsPort,this.port=this.enabled?e.userDrawingsPort:null,this.port){let{definition:o,visible:s}=ro(n);this.port.setToolbar(o),this.port.showToolbar(s),i&&this.port.setSeriesGateway?.(i),this.subs.push(this.port.onDrawingIntent(a=>this.onIntent(a))),this.subs.push(this.store.onChange(()=>this.sync()));}}get supported(){return this.enabled}setTool(e){if(!this.port)return;let t=e!==this.activeTool;this.activeTool=e,this.port.setActiveTool(e,e?this.lastStyle.get(e):void 0),t&&this.events.emit("drawing:tool",{type:e});}getTool(){return this.activeTool}getSnapMode(){return this.snapMode}setSnapMode(e){!this.port||e===this.snapMode||(this.snapMode=e,this.port.setSnapMode?.(e),this.events.emit("drawing:snap",{mode:e}));}getStayMode(){return this.stayInDrawingMode}setStayMode(e){!this.port||e===this.stayInDrawingMode||(this.stayInDrawingMode=e,this.port.setStayMode?.(e),this.events.emit("drawing:stay",{on:e}));}getMode(){return this.mode}setMode(e){!this.port||e===this.mode||(this.mode=e,this.port.setMode?.(e),this.events.emit("drawing:mode",{mode:e}));}showToolbar(e){this.port?.showToolbar(e);}favorites(){return [...this.favs]}isFavorite(e){return this.favs.has(e)}setFavorite(e,t){kt(e)&&t!==this.favs.has(e)&&(t?this.favs.add(e):this.favs.delete(e),this.pushFavorites());}setFavorites(e){let t=e.filter(n=>kt(n)!=null);t.length===this.favs.size&&t.every(n=>this.favs.has(n))||(this.favs=new Set(t),this.pushFavorites());}pushFavorites(){let e=[...this.favs];this.port?.setFavorites?.(e),this.events.emit("drawing:favorites",{favorites:e});}setToolbar(e){this.port?.setToolbar(ro(e).definition);}setExternalGhost(e){this.port?.setExternalGhost?.(e);}setToolShortcuts(e){this.port?.setToolShortcuts?.(e);}add(e,t={}){if(!this.enabled)return null;let i={...this.lastStyle.get(e)??{},...t.style??{}},o=Dn(e,{id:this.store.nextId(),paneId:t.paneId??"price",anchors:t.anchors,style:i,text:t.text,props:t.props,zIndex:t.zIndex??this.startZ(e,t.paneId??"price")});return o?(this.history.record(this.store.serialize()),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id}),o):null}remove(e){this.deleteMany([e]);}update(e,t){let n=this.store.serialize(),i=t.style?this.store.get(e):void 0,o=t.style&&i?{...t,style:{...i.style,...t.style}}:t;this.store.update(e,o)&&(this.history.record(n),this.captureStyle(e),this.events.emit("drawing:edited",{id:e}));}updateMany(e){this.history.begin(this.store.serialize());for(let{id:t,patch:n}of e)this.store.update(t,n)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t}));this.history.commit();}removeMany(e){this.deleteMany(e);}setLocked(e,t){let n=this.store.serialize();this.history.record(n),this.store.setLocked(e,t),this.events.emit("drawing:edited",{id:e});}setVisible(e,t){let n=this.store.serialize();this.history.record(n),this.store.setVisible(e,t),this.events.emit("drawing:edited",{id:e});}bringToFront(e){let t=this.store.serialize();this.history.record(t),this.store.bringToFront(e,this.seriesTopZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}sendToBack(e){let t=this.store.serialize();this.history.record(t),this.store.sendToBack(e,this.seriesBottomZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}seriesTopZ(e){return e!==void 0?this.port?.stackRange?.(e)?.front??0:0}seriesBottomZ(e){return e!==void 0?this.port?.stackRange?.(e)?.back??1:1}startZ(e,t){let n=this.port?.stackRange?.(t);if(n)return kt(e)?.coversSeries?n.front+.5:(n.price??n.front)-.5}select(e,t=false){this.setSelection(e,t);}openSettings(e){this.port?.openSettings(e);}undo(){let e=this.history.undo(this.store.serialize());e&&this.restoreSnapshot(e);}redo(){let e=this.history.redo(this.store.serialize());e&&this.restoreSnapshot(e);}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}duplicate(e){if(!this.enabled)return [];let t=this.resolve(e);return t.length===0?[]:this.insertClones(t.map(n=>n.serialize()))}clone(e){return this.duplicate([e])[0]??null}copy(e){let t=this.resolve(e).map(n=>$t(n.serialize()));t.length&&(this.clipboard=t);}paste(){return !this.enabled||this.clipboard.length===0?[]:this.insertClones(this.clipboard)}all(){return this.store.serialize().drawings}toJSON(){return this.store.serialize()}fromJSON(e){this.history.clear(),this.selectedIds=[],this.store.load(e);}destroy(){for(let e of this.subs)e();this.subs.length=0;}setSelection(e,t=false){let n;if(t){n=[...this.selectedIds];for(let i of e){let o=n.indexOf(i);o>=0?n.splice(o,1):n.push(i);}}else n=[...e];this.selectedIds=n.filter(i=>this.store.has(i)),this.announceSelection();}announceSelection(){this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null,ids:[...this.selectedIds]});}restoreSnapshot(e){this.store.load(e),this.selectedIds=this.selectedIds.filter(t=>this.store.has(t)),this.announceSelection();}deleteMany(e){this.history.begin(this.store.serialize());let t=[];for(let i of e)this.store.remove(i)&&t.push(i),this.history.markDirty();if(this.history.commit(),t.length===0)return;let n=this.selectedIds.filter(i=>this.store.has(i));n.length!==this.selectedIds.length&&this.setSelection(n);for(let i of t)this.events.emit("drawing:removed",{id:i});}insertClones(e){this.history.begin(this.store.serialize());let t=[];for(let n of e){let i=pt({...n,id:this.store.nextId()});i&&(this.store.add(i),this.history.markDirty(),t.push(i));}if(this.history.commit(),t.length){this.setSelection(t.map(n=>n.id));for(let n of t)this.events.emit("drawing:created",{id:n.id});}return t}resolve(e){return e.map(t=>this.store.get(t)).filter(t=>t!=null)}captureStyle(e){let t=this.store.get(e);t&&this.lastStyle.set(t.type,{...t.style});}sync(){this.port?.syncDrawings(this.store.serialize().drawings);}onIntent(e){switch(e.kind){case "arm":this.setTool(e.type);break;case "draft":this.events.emit("drawing:draft",{doc:e.doc});break;case "create":{let t=this.store.serialize(),n=this.lastStyle.get(e.doc.type),i=n?{...e.doc.style,...n}:e.doc.style,o=pt({...e.doc,id:this.store.nextId(),style:i});if(!o)return;o.zIndex||(o.zIndex=this.startZ(o.type,o.paneId)??0),this.history.record(t),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id});break}case "edit":{let t=this.store.serialize();this.store.update(e.doc.id,e.doc)&&(this.history.record(t),this.captureStyle(e.doc.id),this.events.emit("drawing:edited",{id:e.doc.id}));break}case "edit-many":{this.history.begin(this.store.serialize());for(let t of e.docs)this.store.update(t.id,t)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t.id}));this.history.commit();break}case "select":this.setSelection(e.ids,e.additive);break;case "delete":this.deleteMany(e.ids);break;case "reorder":e.to==="front"?this.bringToFront(e.id):this.sendToBack(e.id);break;case "settings":this.events.emit("drawing:settings",{id:e.id});break;case "favorite":this.setFavorite(e.type,e.on);break;case "snap-mode":e.mode!==this.snapMode&&(this.snapMode=e.mode,this.events.emit("drawing:snap",{mode:e.mode}));break;case "stay-mode":e.on!==this.stayInDrawingMode&&(this.stayInDrawingMode=e.on,this.events.emit("drawing:stay",{on:e.on}));break;case "mode":e.mode!==this.mode&&(this.mode=e.mode,this.events.emit("drawing:mode",{mode:e.mode}));break;case "tool-finished":!this.stayInDrawingMode&&e.type!=="freehand"&&e.type!=="highlighter"&&this.setTool(null);break;case "undo":this.undo();break;case "redo":this.redo();break;case "duplicate":this.duplicate(e.ids);break;case "clone":this.enabled&&e.docs.length&&this.insertClones(e.docs);break;case "copy":this.copy(e.ids);break;case "paste":this.paste();break}}};var qa=class{constructor(e,t){this.renderer=e;this.marks=new Map;this.groups=new Map;this.subs=[];this.enabled=!!e.capabilities.timelineMarks&&typeof e.setTimelineMarks=="function",this.enabled&&e.onMarkClick&&this.subs.push(e.onMarkClick(n=>t.emit("mark:click",n)));}get supported(){return this.enabled}add(e){this.marks.set(e.id,Rm(e)),this.sync();}set(e){this.marks.clear();for(let t of e)this.marks.set(t.id,Rm(t));this.sync();}remove(e){let t=this.marks.delete(e);return t&&this.sync(),t}clear(){this.marks.size!==0&&(this.marks.clear(),this.sync());}all(){return [...this.marks.values()].map(e=>({...e,glyph:{...e.glyph}}))}defineGroup(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("[vela] marks.defineGroup: `id` must be a non-empty string");if(typeof e.label!="string")throw new Error(`[vela] marks.defineGroup: group "${e.id}" needs a string \`label\``);this.groups.set(e.id,{...e}),this.sync();}groupDefinitions(){return [...this.groups.values()].map(e=>({...e}))}setGroupVisible(e,t){if(!this.renderer.features.includes("marks")){console.warn(`[vela] renderer "${this.renderer.name}" does not paint timeline marks \u2014 setGroupVisible ignored.`);return}this.renderer.applyFeature("marks",{groups:{[e]:t}});}isGroupVisible(e){let n=this.renderer.readFeature("marks")?.groups?.[e];return typeof n=="boolean"?n:this.groups.get(e)?.visible!==false}destroy(){for(let e of this.subs)e();this.subs.length=0;}sync(){this.enabled&&this.renderer.setTimelineMarks([...this.marks.values()],[...this.groups.values()]);}};function Rm(r){if(!r||typeof r!="object")throw new Error("[vela] marks: a mark must be an object");if(typeof r.id!="string"||r.id.length===0)throw new Error("[vela] marks: `id` must be a non-empty string");if(typeof r.time!="number"||!Number.isFinite(r.time))throw new Error(`[vela] marks: mark "${r.id}" needs a finite epoch-ms \`time\``);if(!r.glyph||typeof r.glyph!="object"||typeof r.glyph.color!="string")throw new Error(`[vela] marks: mark "${r.id}" needs a glyph with a \`color\``);return {...r,glyph:{...r.glyph}}}var Dm={D:864e5,W:6048e5,M:2592e6};function Et(r){let e=r.trim();if(Dm[e])return Dm[e];let t=/^(\d+)\s*(m|h|d|w)?$/i.exec(e);if(t){let n=parseInt(t[1],10),i=(t[2]??"m").toLowerCase();return n*(i==="m"?6e4:i==="h"?36e5:i==="d"?864e5:6048e5)}return 36e5}var t1=5e3,n1=.25,r1=16,i1=15e3,Ou=["240","60","30","15","5","1"],Za=class{constructor(e){this.deps=e;this.cache=new Map;this.listeners=new Set;}seriesInRange(e,t,n){if(!this.deps.canFetch())return {state:"unavailable",reason:"no-source"};let i=this.resolveTimeframe(e);if(typeof i!="string")return {state:"unavailable",reason:i.reason};let o=Et(i),s=Math.min(t,n),a=Math.max(t,n);if(!(a>s)||!(o>0))return {state:"unavailable",reason:"not-lower"};if((a-s)/o>t1)return {state:"unavailable",reason:"too-wide"};let l=`${this.deps.marketKey()}|${i}`,c=this.cache.get(l)??[],u=c.find(d=>d.from<=s&&d.to>=a);if(u){if(u.pending)return this.loading(c,i,o,s,a);if(u.failedAt>0){if(Date.now()-u.failedAt<i1)return this.loading(c,i,o,s,a);c.splice(c.indexOf(u),1);}else return this.maybeRefresh(l,u,i,o,a),{state:"ready",bars:this.slice(u.bars,s,a),timeframe:i,barMs:o}}return this.fetchWindow(l,c,i,s,a),this.loading(c,i,o,s,a)}onUpdate(e){return this.listeners.add(e),()=>this.listeners.delete(e)}resolveTimeframe(e){let t=Et(this.deps.chartTimeframe()),n=Ou[Ou.length-1];if(Et(n)>=t)return {reason:"none-lower"};let i=e.trim()||"auto";if(i==="auto"){for(let o of Ou)if(Et(o)<=t/4)return o;return n}return Et(i)<t?i:{reason:"not-lower"}}loading(e,t,n,i,o){let s=new Map;for(let l of e)if(!(l.pending||l.failedAt>0)&&!(l.to<i||l.from>o))for(let c of this.slice(l.bars,i,o))s.set(c.time,c);if(s.size===0)return {state:"loading",timeframe:t,barMs:n};let a=[...s.values()].sort((l,c)=>l.time-c.time);return {state:"loading",timeframe:t,barMs:n,bars:a}}fetchWindow(e,t,n,i,o){if(t.some(l=>l.pending&&l.to>=i&&l.from<=o))return;let s=(o-i)*n1,a={from:i-s,to:o+s,bars:[],fetchedAt:0,pending:true,failedAt:0};t.push(a),this.cache.set(e,t),this.evict(),this.deps.fetchBars(n,{from:a.from,to:a.to}).then(l=>{a.bars=l,a.fetchedAt=Date.now(),a.pending=false,this.absorbOverlaps(e,a),this.fire();}).catch(()=>{a.pending=false,a.failedAt=Date.now(),this.fire();});}maybeRefresh(e,t,n,i,o){if(t.pending)return;let s=t.bars.length>0?t.bars[t.bars.length-1].time:t.from;o<s||Date.now()-t.fetchedAt<i||(t.pending=true,this.deps.fetchBars(n,{from:t.from,to:t.to}).then(a=>{t.bars=a,t.fetchedAt=Date.now(),t.pending=false,this.fire();}).catch(()=>{t.pending=false,t.fetchedAt=Date.now();}));}absorbOverlaps(e,t){let n=this.cache.get(e);if(n)for(let i=n.length-1;i>=0;i-=1){let o=n[i];if(o===t||o.pending||o.failedAt>0||o.to<t.from||o.from>t.to)continue;let s=new Map;for(let a of o.bars)s.set(a.time,a);for(let a of t.bars)s.set(a.time,a);t.bars=[...s.values()].sort((a,l)=>a.time-l.time),t.from=Math.min(t.from,o.from),t.to=Math.max(t.to,o.to),t.fetchedAt=Math.min(t.fetchedAt,o.fetchedAt||t.fetchedAt),n.splice(i,1);}}evict(){let e=0;for(let t of this.cache.values())e+=t.length;for(;e>r1;){let t=null,n=-1,i=1/0;for(let[s,a]of this.cache)for(let l=0;l<a.length;l+=1){let c=a[l];if(c.pending)continue;let u=c.fetchedAt||c.failedAt;u<i&&(t=s,n=l,i=u);}if(t==null)return;let o=this.cache.get(t);o.splice(n,1),o.length===0&&this.cache.delete(t),e-=1;}}slice(e,t,n){let i=[];for(let o of e)if(!(o.time<t)){if(o.time>n)break;i.push(o);}return i}fire(){for(let e of [...this.listeners])e();}};function io(r){return r.group!=null&&r.ticker===r.group}function Om(r){return `${(r.prefix??r.provider??"").toLowerCase()}:${(r.group??"").toUpperCase()}`}function o1(r,e){let t=Om(e);return r.filter(n=>n.group!=null&&!io(n)&&Om(n)===t)}function Nm(r,e){let t=o1(r,e),n=t.filter(i=>i.default);return (n.length===1?n[0]:t[0])??null}var Wt=r=>r.trim().toLowerCase(),dn=r=>r.trim().toUpperCase();function Gt(r){let e=r.trim(),t=/^(?:([A-Za-z0-9_.]+):)?(.+)$/.exec(e);if(!t)return {provider:null,ticker:e};let n=t[1]?Wt(t[1]):null,i=t[2],o=i.lastIndexOf("."),s=o>0?i.slice(o+1):void 0;return {provider:n,ticker:i,ext:s}}var Ja=class{constructor(){this.entries=new Map;this.changeListeners=new Set;this.waits=new Set;this.unresolvedCbs=new Set;}register(e,t){let n=Wt(e),i={name:n,provider:t,index:null,prefixIndex:null,byTicker:null,descriptors:[],settled:false,settle:Promise.resolve()};return this.entries.set(n,i),i.settle=this.buildIndex(i),queueMicrotask(()=>this.notify(false)),i.settle}async buildIndex(e){await Promise.resolve();try{if(e.provider.listSymbols){let t=await e.provider.listSymbols();e.descriptors=t,e.index=new Set(t.map(n=>dn(n.ticker))),e.byTicker=new Map(t.map(n=>[dn(n.ticker),n])),e.prefixIndex=new Map;for(let n of t)n.prefix&&e.prefixIndex.set(`${Wt(n.prefix)}:${dn(n.ticker)}`,n);}}catch{e.index=null;}finally{e.settled=true,this.notify(true);}}notify(e){for(let t of [...this.changeListeners])t(e);}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}unregister(e){this.entries.delete(Wt(e)),this.notify(false);}has(e){return this.entries.has(Wt(e))}get(e){return this.entries.get(Wt(e))?.provider}names(){return [...this.entries.keys()]}parse(e){return Gt(e)}resolve(e,t={}){let{provider:n,ticker:i}=this.parse(e);if(n){if(this.entries.has(n)){let a=this.entries.get(n).byTicker?.get(dn(i));return {provider:n,ticker:a!=null&&io(a)?this.loadableTicker(n,a):i}}let s=`${n}:${dn(i)}`;for(let a of this.candidateOrder(t.default)){let l=this.entries.get(a).prefixIndex?.get(s);if(l)return {provider:a,ticker:this.loadableTicker(a,l)}}return null}let o=dn(i);for(let s of this.candidateOrder(t.default)){let a=this.entries.get(s);if(a.index?.has(o)){let l=a.byTicker?.get(o);return {provider:s,ticker:l!=null&&io(l)?this.loadableTicker(s,l):i}}}if(t.lenient&&this.entries.size===1){let s=this.names()[0],a=this.entries.get(s);if(a.settled&&a.index==null)return {provider:s,ticker:i}}return null}loadableTicker(e,t){return io(t)?Nm(this.entries.get(e)?.descriptors??[],t)?.ticker??t.ticker:t.ticker}whenResolvable(e,t={}){let n=this.resolve(e,{...t,lenient:true});return n?Promise.resolve(n):new Promise(i=>{let o=this.onChange(a=>{let l=this.resolve(e,{...t,lenient:true});l?(s(),i(l)):a&&this.allSettled()&&this.reportUnresolved(e);}),s=()=>{o(),this.waits.delete(s);};this.waits.add(s);})}allSettled(){for(let e of this.entries.values())if(!e.settled)return false;return true}cancelWaits(){for(let e of [...this.waits])e();}onUnresolved(e){return this.unresolvedCbs.add(e),()=>this.unresolvedCbs.delete(e)}reportUnresolved(e){let t=this.names();console.warn(`[vela] symbol "${e}" not yet resolvable \u2014 registered providers: [${t.join(", ")||"none"}]. Register a provider that serves it.`);for(let n of this.unresolvedCbs)n({symbol:e,providers:t});}candidateOrder(e){let t=this.names();if(e){let n=Wt(e);if(this.entries.has(n))return [n,...t.filter(i=>i!==n)]}return t}displayPrefixOf(e){return this.entries.get(e.provider)?.byTicker?.get(dn(e.ticker))?.prefix??e.provider}canonicalSymbol(e){let t=this.entries.get(e.provider)?.byTicker?.get(dn(e.ticker));return `${t?.prefix??e.provider}:${t?.ticker??e.ticker}`}symbolIconOf(e){let t=e.provider?Wt(e.provider):[...this.entries.keys()][0],n=t!==void 0?this.entries.get(t):void 0;try{return n?.provider.resolveSymbolIcon?.(e)??void 0}catch{return}}symbolIcon(e){if(!e)return;let t=this.entries.get(e.provider)?.byTicker?.get(dn(e.ticker));return this.symbolIconOf({...t??{ticker:e.ticker},provider:t?.provider??e.provider})}symbolsOf(e){return e!=null?this.entries.get(Wt(e))?.descriptors??[]:[...this.entries.entries()].flatMap(([t,n])=>n.descriptors.map(i=>({...i,provider:t})))}infoOf(e){let t=Wt(e),n=this.entries.get(t);if(!n)return {name:t,capabilities:{enumerate:false,stream:false,symbolInfo:false}};let i=n.provider;return i.info?.()??{name:n.name,capabilities:{enumerate:!!i.listSymbols,stream:!!i.subscribe,symbolInfo:!!i.getSymbolInfo}}}indexReady(){return Promise.all([...this.entries.values()].map(e=>e.settle)).then(()=>{})}};function qr(r){switch(r.kind){case "row":return {label:r.label,toggle:r.toggle,controls:r.controls,when:r.when};case "toggle":{let e=[];r.number&&e.push({kind:"number",...r.number});for(let t of r.colors??[])e.push({kind:"color",...t});return r.width&&e.push({kind:"width",...r.width}),{label:r.label,toggle:{key:r.key,defval:r.defval},controls:e,when:r.when}}case "number":return {label:r.label,controls:[{kind:"number",key:r.key,label:r.label,defval:r.defval,min:r.min,max:r.max,step:r.step}],when:r.when};case "color":return {label:r.label,controls:[{kind:"color",key:r.key,label:r.label,defval:r.defval}],when:r.when};case "select":return {label:r.label,controls:[{kind:"select",key:r.key,label:r.label,options:r.options,defval:r.defval}],when:r.when};case "range":return {label:r.label,controls:[{kind:"number",key:r.minKey,label:`${r.label} \u2014 min`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder},{kind:"hint",text:"\u2013"},{kind:"number",key:r.maxKey,label:`${r.label} \u2014 max`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder}],when:r.when}}}function oo(r){if(r.kind==="heading"||r.kind==="header")return [];let e=qr(r),t=[];e.toggle&&t.push({key:e.toggle.key,type:"boolean",defval:e.toggle.defval});for(let n of e.controls)n.kind!=="hint"&&(n.kind==="color"||n.kind==="select"?t.push({key:n.key,type:"string",defval:n.defval}):t.push({key:n.key,type:"number",defval:n.defval}));return t}function gr(r,e){return r?(Array.isArray(r)?r:[r]).every(n=>n.anyOf?n.anyOf.some(i=>i===e[n.key]):e[n.key]===n.equals):true}var so=new Map;function Nu(r){so.set(r.id,r);}function s1(r){so.delete(r);}function hn(r){return typeof r=="string"?so.get(r):void 0}function Mt(){return [...so.values()]}function Fu(){return [...so.values()].filter(r=>r.tickerModifier??r.barTransform!=null).map(r=>r.id)}function Zr(r){return hn(r)?.barTransform??null}function Fm(r){let e=r.lastIndexOf(";");if(e<=0||e===r.length-1)return {symbol:r,modifier:null,transform:null};let t=r.slice(e+1).toLowerCase();return t!=="standard"&&!Fu().includes(t)?{symbol:r,modifier:null,transform:null}:{symbol:r.slice(0,e),modifier:t,transform:Zr(t)}}var Ut={background:"#151619",textColor:"#b2b5be",gridColor:"#20222c",borderColor:"#2a2b30",upColor:z,downColor:W,fontFamily:"sans-serif"},ao={background:"#ffffff",textColor:"#1e293b",gridColor:"#cccccc",borderColor:"#d4dae3",upColor:z,downColor:W,fontFamily:"sans-serif"};function Jr(r){return !r||r==="dark"?Ut:r==="light"?ao:r}var a1=150,l1=1e3,c1=300,u1=5e3,Vm=1e4,d1=20,h1=1.5,_m=5e3,Qa=class r{constructor(e,t,n,i,o,s){this.renderer=t;this.feed=n;this.config=o;this.dataControl=s;this.events=new Qn;this.registry=new Os;this.paneOrder=["price"];this.collapsedPanes=new Set;this.maximizedPaneId=null;this.paneActionUnsub=null;this.handles=new Map;this.engines=new Map;this.live=null;this.bars=[];this.rawBars=[];this.barTransform=null;this.typeEngines=new Map;this.typeSettings=new Map;this.activeEngineStyle=null;this.priceStyle="candles";this.unresolvedUnsub=null;this.visibleRange=null;this.viewportUnsub=null;this.viewportTimer=null;this.healing=false;this.healBuffer=[];this.lastHealAt=0;this.onVisible=null;this.barCause="tick";this.historyState="complete";this.generation=0;this.progressiveAbort=null;this.supersedeWaiters=[];this.historyCompleted=false;this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});this.switchingMarket=false;this.loadingUp=false;this.volumeOptedOut=false;this.contextEmitAt=new Map;this.runEmitAt=new Map;for(let c of i)this.registerEngine(c.language,c);this.defaultLanguage=o.defaultLanguage,this.renderer.mount(e,o.theme),this.renderer.onInputChange(c=>c.kind==="prop"?this.applyProps(c.indicatorId,{[c.key]:c.value}):this.applyInputs(c.indicatorId,{[c.key]:c.value})),this.renderer.onRemoveIndicator(c=>this.removeIndicator(c)),this.renderer.onToggleIndicatorVisible?.((c,u)=>this.setVisible(c,u)),this.paneActionUnsub=this.renderer.onPaneAction?.(c=>this.handlePaneAction(c))??null,this.renderer.onChartTypeSettingsChange?.((c,u)=>{this.typeSettings.set(c,u),this.typeEngines.get(c)?.onSettings?.(u);}),this.renderer.onMoveIndicator?.((c,u)=>this.moveIndicator(c,u)),this.renderer.onThemeSelect?.(c=>this.setTheme(Jr(c))),this.viewportUnsub=this.renderer.onViewportChange(c=>this.onViewportChange(c)),this.renderer.onPriceStyleChange?.(c=>this.syncPriceStyle(c));let a=this.renderer.readFeature("priceStyle");typeof a=="string"&&(this.priceStyle=a),this.barTransform=Zr(a);let l=new Za({fetchBars:(c,u)=>this.fetchSeries(this.config.market.symbol??"",c,u),canFetch:()=>!!this.feed.loadRange&&!this.config.market.data?.length&&!!this.config.market.symbol,chartTimeframe:()=>this.config.market.timeframe??"60",marketKey:()=>`${this.config.market.symbol??""}|${this.config.market.session??""}`});this.drawings=new ja(this.renderer,this.events,o.drawings,l),this.marks=new qa(this.renderer,this.events),this.unresolvedUnsub=this.feed.onUnresolved?.(c=>{this.endLoad(),this.events.emit("data:unresolved",c);})??null,this.readyPromise=this.init(),hn(a)?.dataEngine&&this.syncChartTypeEngine(a);}currentVisibleRange(){if(this.visibleRange)return this.visibleRange;let e=this.renderer.getVisibleRange();return e?{left:e.from,right:e.to}:void 0}engineFor(e){let t=e??this.defaultLanguage,n=this.engines.get(t);if(!n)throw new Error(`[vela] no scripting engine registered for language "${t}". Vela ships none \u2014 install one (Pine Script: @luxalgo/vela-pinets) and register it before addIndicator, e.g. chart.registerEngine('pine', new PineEngine()).`);return n}market(){return {symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",symbolInfo:this.feed.symbolInfo?.(this.config.market),chartStyle:this.priceStyle}}async fetchSeries(e,t,n){let i=Fm(e),o={symbol:i.symbol,timeframe:t},s=await(this.feed.loadRange?this.feed.loadRange(o,n):this.feed.load({...o,bars:n.limit}));return i.transform?i.transform.full(s):s}onViewportChange(e){this.visibleRange={left:e.from,right:e.to},this.events.emit("viewport:changed",{from:e.from,to:e.to}),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportTimer=setTimeout(()=>{if(this.viewportTimer=null,this.switchingMarket)return;let t=this.visibleRange;if(t){for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session&&n.prepared?.reactsToViewport?(n.pendingCause="viewport",n.session.setVisibleRange(t)):n.native?.descriptor.reactsToViewport&&n.native.instance.onViewport({from:t.left,to:t.right}));this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.onViewport?.({from:t.left,to:t.right});}},a1);}async init(){let e=this.bumpGeneration();this.beginLoad(true),await this.loadMarket(e,{firstLoad:true}),this.generation===e&&(this.startLive(),this.events.emit("ready",void 0));}bumpGeneration(){let e=++this.generation;this.progressiveAbort?.abort(),this.progressiveAbort=null;for(let t of this.supersedeWaiters.splice(0))t();return e}beginLoad(e){if(this.loadingUp)return;this.loadingUp=true,this.renderer.setLoading?.(true);let t=this.config.market;this.events.emit("load:start",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",firstLoad:e});}endLoad(){if(!this.loadingUp)return;this.loadingUp=false,this.renderer.setLoading?.(false);let e=this.config.market;this.events.emit("load:end",{symbol:e.symbol??"TEST",timeframe:e.timeframe??"60",bars:this.bars.length});}async loadMarket(e,t){try{await this.loadMarketInner(e,t);}finally{this.generation===e&&this.endLoad();}}async loadMarketInner(e,t){let n=this.config.market,i=n.bars??500,o=n.visibleRange,s=!n.data?.length&&o==null&&i>u1,a=false;if(!n.data?.length&&o==null&&this.feed.loadProgressive){let l=false,c=(d,h)=>{this.generation!==e||!h&&d.length===0||!l&&!h&&d.length<Math.min(i,d1)||(this.setBarSeries(d,l?{preserveView:true}:void 0),!l&&d.length>0&&(l=true,t.firstLoad&&this.activateBarLayers(),h||(this.historyState="backfill")));},u=new AbortController;this.progressiveAbort=u,a=await new Promise(d=>{let h=false,p=m=>{h||(h=true,d(m));};u.signal.addEventListener("abort",()=>p(true),{once:true}),this.feed.loadProgressive(n,m=>{c(m,false),l&&p(true);},{signal:u.signal}).then(m=>{if(this.progressiveAbort===u&&(this.progressiveAbort=null),m==null)return p(false);if(this.generation!==e)return p(true);c(m,true),this.completeHistory(m.length>=i?"depth":"genesis"),p(true);}).catch(()=>{this.progressiveAbort===u&&(this.progressiveAbort=null),this.generation===e&&this.completeHistory("aborted"),p(true);});});}if(!a)if(s&&this.feed.loadRange){let l=await this.feed.load({...n,bars:Math.min(i,Vm)});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),l.length>0&&i>l.length?(this.historyState="backfill",this.backfillHistory(e,i)):this.completeHistory("depth");}else if(s){let l=await this.feed.load({...n,bars:c1});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers();let c=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(c,{preserveView:true}),this.completeHistory("depth");}else {let l=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),this.completeHistory("depth");}o!=null&&(typeof o=="string"?this.setVisibleRangePreset(o):this.renderer.setVisibleRange(o)),this.refreshPriceFormat(),this.ensurePriceFormat();}startLive(){this.config.live&&(this.live=new Fs(this.feed,this.config.market,e=>this.onBar(e)),this.live.start(),typeof document<"u"&&(this.onVisible=()=>{if(document.visibilityState!=="visible")return;let e=this.bars[this.bars.length-1];!e||this.healing||!this.canHeal()||Date.now()-this.lastHealAt<=_m||this.healGap(e.time);},document.addEventListener("visibilitychange",this.onVisible)));}stopLive(){this.live?.stop(),this.live=null,this.onVisible&&typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisible),this.onVisible=null,this.healing=false,this.healBuffer=[],this.lastHealAt=0;}resetHistoryTracking(){this.resolveHistoryComplete(),this.historyCompleted=false,this.historyState="complete",this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});}marketSnapshot(){let e=this.config.market;return {symbol:e.symbol,provider:Gt(e.symbol??"").provider??void 0,timeframe:e.timeframe,bars:e.bars,session:e.session,offline:e.data!==void 0}}async setMarket(e){let t=this.config.market,n=e.symbol!==void 0&&e.symbol!==t.symbol||e.timeframe!==void 0&&e.timeframe!==t.timeframe||e.session!==void 0&&e.session!==t.session||e.data!==void 0,i=e.bars!==void 0&&e.bars!==t.bars,o=i&&!n&&this.rawBars.length>0&&!t.data?.length&&((e.bars??0)<=this.rawBars.length||typeof this.feed.loadRange=="function");if(!n&&!i){typeof e.visibleRange=="string"?this.setVisibleRangePreset(e.visibleRange):e.visibleRange&&this.renderer.setVisibleRange(e.visibleRange);return}let s={symbol:t.symbol??"TEST",timeframe:t.timeframe??"60"},l=n&&e.session!==void 0&&e.data===void 0&&(e.symbol===void 0||e.symbol===t.symbol)&&(e.timeframe===void 0||e.timeframe===t.timeframe)&&e.visibleRange===void 0?this.currentVisibleRange():void 0,c=l?this.rawBars.filter(d=>d.time>=l.left&&d.time<=l.right).length:0,u=this.bumpGeneration();this.switchingMarket=true;try{if(this.stopLive(),this.viewportTimer!=null&&(clearTimeout(this.viewportTimer),this.viewportTimer=null),this.visibleRange=null,this.resetHistoryTracking(),e.symbol!==void 0&&(t.symbol=e.symbol),e.timeframe!==void 0&&(t.timeframe=e.timeframe),e.bars!==void 0&&(t.bars=e.bars),e.session!==void 0&&(t.session=e.session),l){let d=Math.min(Math.ceil((Date.now()-l.left)/this.barIntervalMs())+50,5e3);d>(t.bars??500)&&(t.bars=d);}if(e.data!==void 0?t.data=e.data:e.symbol!==void 0&&delete t.data,t.visibleRange=e.visibleRange??(l?{from:l.left,to:l.right}:void 0),n&&(this.beginLoad(!1),this.setBarSeries([],{clearing:!0}),this.activeEngineStyle&&(this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.renderer.setNativeData?.(this.activeEngineStyle,void 0),this.renderer.setNativeData?.(`${this.activeEngineStyle}-pending`,[]))),o?this.extendDepth(u,t.bars??500):await Promise.race([this.loadMarket(u,{firstLoad:!1}),new Promise(d=>this.supersedeWaiters.push(d))]),this.generation!==u)return}finally{this.generation===u&&(this.switchingMarket=false);}if(l&&c>=2&&this.rawBars.length>0){let d=this.rawBars,h=d.length-1;for(;h>0&&d[h].time>l.right;)h-=1;let p=d[Math.max(0,h-(c-1))].time;this.renderer.setVisibleRange({from:p,to:Math.max(l.right,d[h].time+1)});}o||(this.restartNativeIndicators(),this.restartChartTypeEngine(),this.reexecuteIndicators()),this.startLive(),n&&this.events.emit("market:changed",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",prev:s});}restartNativeIndicators(){for(let e of this.registry.all())if(e.native)if(e.native.instance.stop(),e.native.instance=e.native.descriptor.create(),e.native.started=false,e.pendingStructural=true,e.hidden)e.native.stale=true;else {let t=this.handles.get(e.id);t&&this.startNativeIndicator(e.id,t);}}restartChartTypeEngine(){for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle&&this.startChartTypeEngine(this.activeEngineStyle);}activateBarLayers(){this.maybeAutoAddVolume();}extendDepth(e,t){if(this.rawBars.length>t){this.setBarSeries(this.rawBars.slice(this.rawBars.length-t),{preserveView:true}),this.completeHistory("depth");return}if(this.rawBars.length===t){this.completeHistory("depth");return}this.historyState="backfill",this.backfillHistory(e,t);}async backfillHistory(e,t){try{for(;this.generation===e&&this.rawBars.length<t&&this.rawBars.length>0;){let n=t-this.rawBars.length,i=Vm,o=await this.feed.loadRange(this.config.market,{to:this.rawBars[0].time,limit:Math.min(i,n)+1});if(this.generation!==e)return;let s=this.rawBars[0].time,a=o.filter(l=>l.time<s);if(a.length===0){this.completeHistory("genesis");return}for(let l=1;l<a.length;l+=1)if(a[l].time<=a[l-1].time){console.warn("[vela] non-monotonic history chunk \u2014 stopping the backfill"),this.completeHistory("aborted");return}this.setBarSeries([...a,...this.rawBars],{preserveView:!0}),this.notifySessionsBars("backfill"),this.events.emit("history:progress",{loaded:this.rawBars.length,target:t});}this.generation===e&&this.completeHistory("depth");}catch(n){console.warn(`[vela] history backfill failed \u2014 keeping ${this.rawBars.length} bars (${n instanceof Error?n.message:String(n)})`),this.generation===e&&this.completeHistory("aborted");}}completeHistory(e){this.historyCompleted||(this.historyCompleted=true,this.historyState="complete",this.notifySessionsBars("complete"),this.events.emit("history:complete",{reason:e,oldestTime:this.rawBars[0]?.time??0,barsLoaded:this.rawBars.length}),this.resolveHistoryComplete());}historyComplete(){return this.historyCompletePromise}qualifiedSymbol(){let e=this.config.market;return e.symbol?e.symbol:null}refreshPriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.feed.symbolInfo?.(this.config.market)?.mintick;this.renderer.setPricePrecision(typeof e=="number"&&e>0?e:void 0);}async ensurePriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.qualifiedSymbol();if(e)try{await this.dataControl.symbolInfo(e),this.refreshPriceFormat();}catch{}}maybeAutoAddVolume(){!this.config.volume||this.volumeOptedOut||!this.renderer.setNativeData||Gi("volume")&&this.addNativeIndicator("volume");}syncPriceStyle(e){typeof e=="string"&&(this.priceStyle=e),this.syncBarTransform(e),this.syncChartTypeEngine(e);}syncChartTypeEngine(e){let t=typeof e=="string"?e:null,i=hn(t)?.dataEngine?t:null;i!==this.activeEngineStyle&&(this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.activeEngineStyle=i,i&&this.startChartTypeEngine(i));}async startChartTypeEngine(e){if(!this.renderer.setNativeData||(await this.readyPromise,this.activeEngineStyle!==e))return;let t=this.typeEngines.get(e);if(t){t.resume();return}let n=hn(e);if(!n?.dataEngine)return;let i=n.dataEngine();this.typeEngines.set(e,i);let o=this.typeSettings.get(e);o&&i.onSettings?.(o),i.start({symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live??false,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,pushData:s=>this.renderer.setNativeData?.(e,s),pushPending:s=>this.renderer.setNativeData?.(`${e}-pending`,s)});}syncBarTransform(e){let t=Zr(e);t!==this.barTransform&&(this.barTransform=t,this.rawBars.length!==0&&(this.bars=t?t.full(this.rawBars):this.rawBars,this.renderer.setBars(this.bars,{preserveView:true}),this.reexecuteIndicators()));}reexecuteIndicators(){for(let e of this.registry.all()){if(e.hidden||!e.session)continue;e.session.stop(),e.session=void 0,e.pendingStructural=true,e.pendingCause="market",this.setLoading(e,true);let t=this.handles.get(e.id);t&&this.executeIndicator(e.id,t);}}onBar(e){if(this.healing){this.healBuffer.push(e);return}let t=this.rawBars[this.rawBars.length-1];if(t&&this.canHeal()&&e.time>t.time+this.barIntervalMs()*h1&&Date.now()-this.lastHealAt>_m){this.healBuffer.push(e),this.healGap(t.time);return}this.applyBar(e);}setBarSeries(e,t){this.rawBars=e,this.bars=this.barTransform?this.barTransform.full(e):e,this.renderer.setBars(this.bars,{preserveView:t?.preserveView}),!t?.clearing&&this.bars.length>0&&this.endLoad();}applyBar(e,t=true){let n=this.rawBars[this.rawBars.length-1],i=e;if(n&&e.time===n.time)this.rawBars[this.rawBars.length-1]=e,this.barCause="tick",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-2]),this.bars[this.bars.length-1]=i);else if(!n||e.time>n.time)this.rawBars.push(e),this.barCause="bar",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-1]),this.bars.push(i));else return;this.renderer.updateBar(i),this.events.emit("bar",e),t&&this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}notifySessionsBars(e){if(this.switchingMarket)return;let t=e?"history":this.barCause;for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session?(n.pendingCause=t,n.session.notifyBars(e)):n.native&&n.native.instance.onBars());}canHeal(){return !!this.feed.loadRange&&!this.config.market.data?.length}barIntervalMs(){return Et(this.config.market.timeframe??"60")}async healGap(e){let t=this.generation;this.healing=true,this.lastHealAt=Date.now();try{let n=await this.feed.loadRange(this.config.market,{from:e});if(this.generation!==t)return;for(let i of n)this.applyBar(i,!1);}catch{}finally{if(this.generation===t){this.healing=false;let n=this.healBuffer;this.healBuffer=[];for(let i of n)this.applyBar(i,false);this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}}}registerEngine(e,t){let n=this.engines.get(e);n&&n!==t&&console.warn(`[vela] re-registering scripting engine for language "${e}"; replacing ${n.constructor.name} with ${t.constructor.name}.`),this.engines.set(e,t);}addIndicator(e,t={}){let n=this.registry.nextId(),i=t.title??"Indicator",o=new Hr(n,i,this,e);return this.handles.set(n,o),this.registry.add({id:n,title:i,source:e,options:t,inputValues:{...t.inputs??{}},propValues:{...t.props??{}}}),this.startIndicator(n,e,t,o),o}addNativeIndicator(e,t={}){let n=Gi(e);if(!n?.multiInstance){let l=this.registry.all().find(c=>c.native?.type===e);if(l)return this.handles.get(l.id)??new Hr(l.id,l.title,this,void 0,e)}let i=this.registry.nextId("native"),o=n?.title??e,s=new Hr(i,o,this,void 0,e);if(this.handles.set(i,s),!n)return console.warn(`[vela] addNativeIndicator("${e}") \u2014 no native indicator registered for this type.`),s;let a={...n.defaultInputs(),...t.inputs??{}};return this.registry.add({id:i,title:o,source:e,inputValues:a,propValues:{},native:{type:e,instance:n.create(),descriptor:n}}),s.setSchema(n.inputsSchema()),this.startNativeIndicator(i,s),s}presentNativeIndicators(){return this.registry.all().map(e=>e.native?.type).filter(e=>!!e)}async availableNativeIndicators(){let e=this.qualifiedSymbol(),t=new Set(this.presentNativeIndicators());return Promise.all(Ns().map(async n=>({type:n.type,title:n.title,supported:await this.isNativeSupported(n,e),present:t.has(n.type),beta:n.beta,...n.multiInstance?{multiInstance:true}:{}})))}async isNativeSupported(e,t){if(!e.isSupported)return true;if(!t)return false;try{return await e.isSupported(t,this.dataControl)}catch{return false}}applyInputs(e,t){let n=this.registry.get(e);!n||!n.session&&!n.native||(n.inputValues={...n.inputValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues),n.pendingStructural=true,!n.hidden&&!n.native&&this.setLoading(n,true),n.pendingCause="inputs",n.session?n.session.update(n.inputValues):n.native&&!n.hidden&&n.native.instance.setInputs(n.inputValues),this.events.emit("indicator:inputs",{id:e}));}inputValuesOf(e){return {...this.registry.get(e)?.inputValues}}propValuesOf(e){return {...this.registry.get(e)?.propValues}}applyProps(e,t){let n=this.registry.get(e);n?.session&&(n.propValues={...n.propValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=true,n.hidden||this.setLoading(n,true),n.pendingCause="inputs",n.session.update(n.inputValues,n.propValues),this.events.emit("indicator:inputs",{id:e}));}listIndicators(){return [...this.handles.values()]}getIndicatorContext(e,t){return this.registry.get(e)?.session?.getContext?.(t)??Promise.resolve(null)}removeIndicator(e){let t=this.registry.remove(e);t?.native?.type==="volume"&&(this.volumeOptedOut=true),t?.session?.stop(),t?.native?.instance.stop(),this.handles.delete(e),t?.renderHandle&&this.renderer.removeIndicator(t.renderHandle);let n=t?.model?.paneId;n&&n!=="price"&&!this.paneStillUsed(n)&&(this.renderer.removePane(n),this.forgetPane(n),this.events.emit("pane:changed",void 0)),this.events.emit("indicator:removed",{id:e});}setVisible(e,t){let n=this.registry.get(e);if(!(!n||n.hidden===!t)){if(n.hidden=!t,this.handles.get(e)?.setVisibleState(t),!t)n.session?.stop(),n.session=void 0,n.native?.instance.suspend(),n.renderHandle?this.renderer.setIndicatorVisible?.(n.renderHandle,false):n.native&&this.mountHiddenNativeRow(e,n);else if(n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,true),n.pendingStructural=true,n.native)if(n.native.stale||!n.native.started){n.native.stale=false;let i=this.handles.get(e);i&&this.startNativeIndicator(e,i);}else n.native.instance.resume();else {this.setLoading(n,true);let i=this.handles.get(e);i&&this.executeIndicator(e,i);}this.events.emit("indicator:visibility",{id:e,visible:t});}}ready(){return this.readyPromise}inspect(){let e=[...this.registry.all()].filter(t=>!t.loading).sort((t,n)=>(n.native?1:0)-(t.native?1:0));return Wp(e.map(t=>t.model).filter(t=>t!=null))}resize(){this.renderer.resize();}setTheme(e){let t=this.config.theme;Object.keys(e).every(n=>e[n]===t[n])||(this.config.theme=e,this.renderer.setTheme(e),this.events.emit("theme:changed",e));}getVisibleRange(){return this.renderer.getVisibleRange()}setVisibleRange(e){this.renderer.setVisibleRange(e);}panBy(e){if(this.renderer.panBy){this.renderer.panBy(e);return}let t=this.renderer.getVisibleRange();if(!t)return;let n=(t.to-t.from)*e;this.renderer.setVisibleRange({from:t.from+n,to:t.to+n});}setVisibleRangePreset(e){let t=Gp(e,this.bars);t&&this.renderer.setVisibleRange(t);}destroy(){this.bumpGeneration(),this.resolveHistoryComplete(),this.stopLive(),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportUnsub?.(),this.paneActionUnsub?.();for(let e of this.registry.all())e.session?.stop(),e.native?.instance.stop();for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle=null,this.unresolvedUnsub?.(),this.unresolvedUnsub=null,this.feed.destroy?.(),this.drawings.destroy(),this.marks.destroy(),this.renderer.destroy(),this.events.clear();}async startIndicator(e,t,n,i){try{if(await this.readyPromise,!this.registry.get(e))return;await p1();let o=this.registry.get(e);if(!o)return;let s=this.engineFor(n.language);o.engine=s;let a=await s.prepare(t,e);o.prepared=a;let l={};for(let u of a.inputs)l[u.key]=u.defval;o.inputValues={...l,...o.inputValues},i.setSchema(a.inputs);let c={};for(let u of a.props??[])c[u.key]=u.defval;o.propValues={...c,...o.propValues},i.setPropsSchema(a.props??[]),this.mountLoadingPlaceholder(e,o),this.executeIndicator(e,i);}catch(o){this.fail(e,i,o);}}executeIndicator(e,t){let n=this.registry.get(e);if(!n||!n.engine||!n.prepared||n.hidden)return;let i=this.config.live&&!n.prepared.reactsToViewport&&n.engine.capabilities.streaming?"live":"static";n.session=n.engine.execute({prepared:n.prepared,market:this.market(),bars:this.bars,getBars:()=>this.bars,fetchSeries:(o,s,a)=>this.fetchSeries(o,s,a),inputs:n.inputValues,props:n.propValues,visibleRange:this.currentVisibleRange(),mode:i,historyState:this.historyState},{onModel:o=>{let s=!n.announced,a=n.pendingCause??"history";this.applyModel(e,o)&&(n.pendingCause=void 0,this.emitContextChanged(e),this.emitScriptRun(e,a,s));},onAlert:o=>{let s=n.options?.title??n.prepared?.meta.title??n.title;this.events.emit("alert",{...o,indicator:s}),t.emit("alert",{id:o.id,message:o.message,title:o.title,time:o.time});},onWarning:o=>this.events.emit("warning",o),onError:o=>this.fail(e,t,o)}),this.emitContextChanged(e);}async startNativeIndicator(e,t){try{await this.readyPromise;let n=this.registry.get(e);if(!n?.native||n.hidden)return;let i={symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,emit:o=>this.applyModel(e,this.buildNativeModel(n,o)),pushData:o=>this.renderer.setNativeData?.(n.native.type,o),setStatus:o=>{n.renderHandle&&!n.hidden&&this.renderer.setIndicatorStatus?.(n.renderHandle,o);}};n.native.instance.start(i,n.inputValues),n.native.started=!0;}catch(n){this.fail(e,t,n);}}buildNativeModel(e,t){let n=e.native.descriptor;return {id:e.id,title:e.title,...n.shortTitle?{shorttitle:n.shortTitle}:{},overlay:n.overlay,paneHint:n.paneHint,native:{type:e.native.type},...n.legend===false?{legend:false}:{},...t.paneAxis!=null?{paneAxis:t.paneAxis}:{},series:t.series??[],fills:t.fills??[],backgrounds:t.backgrounds??[],priceLines:t.priceLines??[],...t.lines?{lines:t.lines}:{},...t.boxes?{boxes:t.boxes}:{},...t.labels?{labels:t.labels}:{},...t.polylines?{polylines:t.polylines}:{},...t.linefills?{linefills:t.linefills}:{},...t.tables?{tables:t.tables}:{},inputs:n.inputsSchema(),inputValues:e.inputValues}}mountLoadingPlaceholder(e,t){if(t.renderHandle||!t.prepared)return;let n=t.prepared.meta,i={id:e,title:t.options?.title??n.title,overlay:n.overlay,paneHint:n.overlay?"price":"new",series:[],fills:[],backgrounds:[],priceLines:[],inputs:t.prepared.inputs,inputValues:t.inputValues,...t.prepared.props?{props:t.prepared.props,propValues:t.propValues}:{}},o=this.routePane(e,i,t.options??{});if(this.placeModel(i,e,o),t.model=i,this.ensurePaneFor(o),t.renderHandle=this.renderer.mountIndicator(i),t.pendingStructural=true,t.hidden){this.renderer.setIndicatorVisible?.(t.renderHandle,false),this.announce(t,this.handles.get(e));return}this.setLoading(t,true);}mountHiddenNativeRow(e,t){if(t.renderHandle||!t.native)return;let n=this.buildNativeModel(t,{}),i=this.routePane(e,n,t.options??{});this.placeModel(n,e,i),t.model=n,this.ensurePaneFor(i),t.renderHandle=this.renderer.mountIndicator(n),t.pendingStructural=true,this.renderer.setIndicatorVisible?.(t.renderHandle,false),this.announce(t,this.handles.get(e));}setLoading(e,t){e.loading=t,e.renderHandle&&!e.hidden&&this.renderer.setIndicatorStatus?.(e.renderHandle,t?"loading":"idle");}ensurePaneFor(e){this.paneOrder.includes(e)||this.paneOrder.push(e),this.renderer.ensurePane({id:e,kind:e==="price"?"price":"study",order:this.paneOrder.indexOf(e)});}paneStillUsed(e){for(let t of this.registry.all())if(t.model?.paneId===e)return true;return false}forgetPane(e){let t=this.paneOrder.indexOf(e);t>0&&this.paneOrder.splice(t,1),this.collapsedPanes.delete(e),this.maximizedPaneId===e&&(this.maximizedPaneId=null);}paneManagementSupported(){return this.renderer.capabilities.paneManagement===true&&typeof this.renderer.setIndicatorPane=="function"}listPanes(){let e=new Map;for(let n of this.registry.all()){let i=n.model;if(!i||i.legend===false)continue;let o=i.paneId??"price";e.has(o)||e.set(o,[]),e.get(o).push({id:n.id,title:i.title||n.title,...i.shorttitle?{shorttitle:i.shorttitle}:{},ownScale:i.ownScale===true});}let t=[];for(let n of this.paneOrder)n!=="price"&&!e.has(n)||t.push({id:n,kind:n==="price"?"price":"study",order:t.length,collapsed:this.collapsedPanes.has(n),maximized:this.maximizedPaneId===n,indicators:e.get(n)??[]});return t}movePane(e,t){if(e==="price")return;let n=this.existingPaneIds(),i=n.indexOf(e);if(i<0)return;let o=t==="up"?i-1:i+1;o<=0||o>=n.length||([n[i],n[o]]=[n[o],n[i]],this.reorderPanes(n),this.events.emit("pane:moved",{paneId:e,dir:t}));}removePaneAndIndicators(e){if(e!=="price")for(let t of [...this.registry.all()])t.model?.paneId===e&&this.removeIndicator(t.id);}collapsePane(e,t){t?this.collapsedPanes.add(e):this.collapsedPanes.delete(e),this.renderer.setPaneCollapsed?.(e,t),this.events.emit("pane:changed",void 0);}maximizePane(e){this.maximizedPaneId=e,this.renderer.setPaneMaximized?.(e),this.events.emit("pane:changed",void 0);}moveIndicator(e,t){if(!this.paneManagementSupported()||!this.renderer.setIndicatorPane){console.warn("[vela] the active renderer does not support moving indicators between panes.");return}let n=this.registry.get(e);if(!n?.renderHandle||!n.model)return;let i=n.model,o=i.paneId??"price",s=this.resolveMoveTarget(e,i,t);if(!s)return;let{paneId:a,ownScale:l,insert:c}=s;a===o&&i.ownScale===true===l||(c?this.insertPaneOrder(a,c):this.paneOrder.includes(a)||this.paneOrder.push(a),i.ownScale=l,n.paneLocked=true,this.placeModel(i,e,a),this.ensurePaneFor(a),this.renderer.setIndicatorPane(n.renderHandle,a,{ownScale:l}),o!=="price"&&o!==a&&!this.paneStillUsed(o)&&(this.renderer.removePane(o),this.forgetPane(o)),this.reorderPanes(this.existingPaneIds()),this.events.emit("indicator:moved",{id:e,paneId:a}),this.events.emit("pane:changed",void 0));}resolveMoveTarget(e,t,n){if(n==="price"||typeof n=="object"&&"pane"in n&&n.pane==="price")return {paneId:"price",ownScale:!t.overlay};if("pane"in n)return this.existingPaneIds().includes(n.pane)?{paneId:n.pane,ownScale:true}:null;let i=n.newPane===true?{}:n.newPane;return {paneId:this.freshPaneId(e,t.paneId??"price"),ownScale:false,insert:i}}freshPaneId(e,t){let n=new Set(this.existingPaneIds()),i=`pane-${e}`;for(let o=2;i===t||n.has(i);o+=1)i=`pane-${e}-${o}`;return i}insertPaneOrder(e,t){let n=this.paneOrder.indexOf(e);n>0&&this.paneOrder.splice(n,1);let i=this.paneOrder.length;t.before&&this.paneOrder.includes(t.before)?i=this.paneOrder.indexOf(t.before):t.after&&this.paneOrder.includes(t.after)&&(i=this.paneOrder.indexOf(t.after)+1),i<1&&(i=1),this.paneOrder.splice(i,0,e);}existingPaneIds(){return this.paneOrder.filter(e=>e==="price"||this.paneStillUsed(e))}reorderPanes(e){this.paneOrder.length=0,this.paneOrder.push(...e),this.renderer.orderPanes?.(e),this.events.emit("pane:changed",void 0);}handlePaneAction(e){switch(e.type){case "remove":this.removePaneAndIndicators(e.paneId);break;case "move":{let t=this.existingPaneIds(),n=t.indexOf(e.paneId),i=e.dir==="up"?n-1:n+1;n>0&&i>0&&i<t.length&&([t[n],t[i]]=[t[i],t[n]],this.paneOrder.length=0,this.paneOrder.push(...t),this.events.emit("pane:changed",void 0),this.events.emit("pane:moved",{paneId:e.paneId,dir:e.dir}));break}case "collapse":e.collapsed?this.collapsedPanes.add(e.paneId):this.collapsedPanes.delete(e.paneId),this.events.emit("pane:changed",void 0);break;case "maximize":this.maximizedPaneId=e.maximized?e.paneId:null,this.events.emit("pane:changed",void 0);break}}announce(e,t){e.announced||(e.announced=true,this.events.emit("indicator:added",{id:e.id}),this.emitContextChanged(e.id),t?.emit("ready",void 0));}applyModel(e,t){let n=this.registry.get(e);if(!n||n.hidden)return true;if(n.loading&&this.bars.length===0&&!r.modelHasOutput(t))return false;let i=this.handles.get(e);if(!n.renderHandle){let a=this.routePane(e,t,n.options??{});return this.placeModel(t,e,a),n.model=t,this.ensurePaneFor(a),n.renderHandle=this.renderer.mountIndicator(t),n.pendingStructural=false,this.announce(n,i),true}let o=n.model?.paneId??"price",s=n.model?.ownScale===true;if(n.loading&&!n.paneLocked){let a=this.routePane(e,t,n.options??{});a!==o&&(o!=="price"&&(this.renderer.removePane(o),this.forgetPane(o)),this.ensurePaneFor(a),n.pendingStructural=true,o=a);}return this.placeModel(t,e,o),n.paneLocked&&(t.ownScale=s),n.model=t,n.pendingStructural?(n.renderHandle=this.renderer.mountIndicator(t),this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=false):this.renderer.updateIndicator(n.renderHandle,m1(t)),n.loading&&this.setLoading(n,false),this.announce(n,i),true}static modelHasOutput(e){return e.series.length>0||e.fills.length>0||e.backgrounds.length>0||e.priceLines.length>0||(e.lines?.length??0)>0||(e.boxes?.length??0)>0||(e.labels?.length??0)>0||(e.polylines?.length??0)>0||(e.linefills?.length??0)>0||(e.tables?.length??0)>0||(e.barColors?.length??0)>0||(e.trades?.length??0)>0}routePane(e,t,n){return n.pane==="new"?`pane-${e}`:n.pane==="price"||(n.overlay??t.overlay)?"price":`pane-${e}`}static plotsAtLastBar(e){let t={};for(let n of e.series)Fe(n)&&(t[n.title]=n.points[n.points.length-1]?.value??null);return t}placeModel(e,t,n){e.id=t,e.paneId=n;let i=o=>o.overlay===true?"price":n;for(let o of e.series)o.paneId=i(o);for(let o of e.fills)o.paneId=i(o);for(let o of e.backgrounds)o.paneId=i(o);for(let o of e.priceLines)o.paneId=n;if(e.lines)for(let o of e.lines)o.paneId=i(o);if(e.boxes)for(let o of e.boxes)o.paneId=i(o);if(e.labels)for(let o of e.labels)o.paneId=i(o);if(e.polylines)for(let o of e.polylines)o.paneId=i(o);if(e.linefills)for(let o of e.linefills)o.paneId=i(o);if(e.tables)for(let o of e.tables)o.paneId=i(o);}emitContextChanged(e){if(!this.registry.get(e)?.session?.getContext)return;let t=Date.now();t-(this.contextEmitAt.get(e)??0)<1e3||(this.contextEmitAt.set(e,t),this.events.emit("context:changed",{id:e}));}emitScriptRun(e,t,n){let i=this.registry.get(e);if(!i||i.native||!this.events.hasListeners("script:run"))return;let o=Date.now();t==="tick"&&o-(this.runEmitAt.get(e)??0)<l1||(this.runEmitAt.set(e,o),Promise.resolve().then(()=>this.buildScriptRun(i,t,n)).then(s=>{s&&this.registry.get(e)&&this.events.emit("script:run",s);}));}async buildScriptRun(e,t,n){let i=e.model;if(!i)return null;let o=await this.pullContext(e,["variables","strategy","warnings"]),s=this.bars[this.bars.length-1];return {id:e.id,title:i.title,kind:o?.strategy||(i.trades?.length??0)>0?"strategy":"indicator",cause:t,first:n,bar:Math.max(0,this.bars.length-1),time:s?.time??0,forming:this.config.live&&this.bars.length>0,complete:this.historyState!=="backfill",plots:r.plotsAtLastBar(i),vars:o?.variables??{},...o?.strategy?{strategy:o.strategy}:{},warnings:o?.warnings??[],trades:async()=>(await this.pullContext(e,["trades"]))?.trades??[],series:async a=>((await this.pullContext(e,["plots"]))?.plots?.[a]??[]).map(c=>({time:c.time,value:typeof c.value=="number"?c.value:null}))}}async pullContext(e,t){try{return await e.session?.getContext?.(t)??null}catch{return null}}fail(e,t,n){let i=this.registry.get(e);i?.loading&&this.setLoading(i,false);let o=n instanceof Error?n:new Error(String(n));console.error(`[vela] indicator "${e}" failed:`,o.message),this.events.emit("indicator:error",{id:e,error:o}),t?.emit("error",{error:o});}};function p1(){return typeof requestAnimationFrame=="function"?new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(()=>r()))):new Promise(r=>setTimeout(r,0))}function m1(r){let e=[],t=Number.POSITIVE_INFINITY,n=0;for(let i of r.series)if(i.kind==="candle"||i.kind==="bar"){e.push({seriesId:i.id,kind:"bars",bars:i.bars});for(let o of i.bars)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}else if(Fe(i)){e.push({seriesId:i.id,kind:"points",points:i.points});for(let o of i.points)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}return {kind:"value",indicatorId:r.id,dirty:{from:Number.isFinite(t)?t:0,to:n},anchorTime:r.anchorTime??null,series:e,lines:r.lines??[],boxes:r.boxes??[],labels:r.labels??[],polylines:r.polylines??[],linefills:r.linefills??[],tables:r.tables??[],trades:r.trades??[]}}var lo=class{constructor(e){this.renderer=e;}get name(){return this.renderer.name}get capabilities(){return this.renderer.capabilities}supports(e){return this.renderer.features.includes(e)}get(e){return this.renderer.readFeature(e)}set(e,t){let n=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[i,o]of n)this.renderer.features.includes(i)?this.renderer.applyFeature(i,o):console.warn(`[vela] renderer "${this.renderer.name}" has no feature "${i}" \u2014 set ignored.`);return this}setLegendActions(e){this.renderer.setLegendActions?.(e);}setLegendCallouts(e){this.renderer.setLegendCallouts?.(e);}setLegendOverviewAction(e){return this.renderer.setLegendOverviewAction?.(e),this}get supportsIndicatorSettings(){return typeof this.renderer.openIndicatorSettings=="function"}openIndicatorSettings(e){return this.renderer.openIndicatorSettings?.(e),this}screenshot(){return typeof this.renderer.screenshot=="function"?this.renderer.screenshot():(console.warn(`[vela] renderer "${this.renderer.name}" does not support screenshot().`),null)}screenshotCanvas(){return typeof this.renderer.screenshotCanvas=="function"?this.renderer.screenshotCanvas():null}getConfig(){return typeof this.renderer.getConfig=="function"?this.renderer.getConfig():(console.warn(`[vela] renderer "${this.renderer.name}" does not support getConfig().`),null)}applyConfig(e){return typeof this.renderer.applyConfig=="function"?this.renderer.applyConfig(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support applyConfig().`),this}onConfigChanged(e){return this.renderer.onConfigChanged?.(e)??(()=>{})}onCrosshairMove(e){return this.renderer.onCrosshairMove(e)}onAxisLongPress(e){return this.renderer.onAxisLongPress?.(e)??(()=>{})}dataWindowReadout(){return this.renderer.getDataWindowReadout?.()??null}setSymbolPicker(e){return typeof this.renderer.setSymbolPicker=="function"?this.renderer.setSymbolPicker(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support setSymbolPicker().`),this}focus(){return this.renderer.focus?.(),this}get supportsExternalCrosshair(){return typeof this.renderer.setExternalCrosshair=="function"}setExternalCrosshair(e,t=null){return this.renderer.setExternalCrosshair?.(e,t),this}closeDialogs(){return this.renderer.closeDialogs?.(),this}openSettings(e){return this.renderer.openSettingsDialog?.(e),this}setSettingsSections(e){return this.renderer.setSettingsSections?.(e),this}setSettingsVisibility(e){return this.renderer.setSettingsVisibility?.(e),this}listSettingsIds(){return this.renderer.listSettingsIds?.()??[]}setLayoutMode(e){return this.renderer.setLayoutMode?.(e),this}setWallClock(e){return this.renderer.setWallClock?.(e),this}};var Qr=new Map;function f1(r){let e=Object.entries(r);for(let[t,n]of e)Qr.set(t,n);return ()=>{for(let[t,n]of e)Qr.get(t)===n&&Qr.delete(t);}}function g1(...r){if(r.length===0)Qr.clear();else for(let e of r)Qr.delete(e);}function Vu(){return Object.fromEntries(Qr)}var el=class{constructor(e){this.controller=e;}get supported(){return this.controller.paneManagementSupported()}list(){return this.controller.listPanes()}move(e,t){return this.guard()&&this.controller.movePane(e,t),this}remove(e){return this.guard()&&this.controller.removePaneAndIndicators(e),this}collapse(e,t=true){return this.guard()&&this.controller.collapsePane(e,t),this}maximize(e){return this.guard()&&this.controller.maximizePane(e),this}moveIndicator(e,t){return this.guard()&&this.controller.moveIndicator(e,t),this}guard(){return this.controller.paneManagementSupported()?true:(console.warn("[vela] the active renderer does not support pane management \u2014 chart.panes mutation ignored."),false)}};function Bm(r,e,t,n){return `${r}|${e}|${t}${n&&n!=="regular"?`|${n}`:""}`}function b1(r){return r.split("|")[1]??""}var tl=class{constructor(){this.series=new Map;this.coveredFrom=new Map;this.retained=new Set;this.retainedByOwner=new Map;}get(e){return this.series.get(e)}markCovered(e,t){this.coveredFrom.set(e,Math.min(this.coveredFrom.get(e)??1/0,t));}coveredFromOf(e){return this.coveredFrom.get(e)}merge(e,t){if(t.length===0)return this.series.get(e)??[];let n=new Map;for(let o of this.series.get(e)??[])n.set(o.time,o);for(let o of t)n.set(o.time,o);let i=[...n.values()].sort((o,s)=>o.time-s.time);return this.series.set(e,i),i}retainSymbol(e){this.currentSymbol!==e&&(this.currentSymbol=e,this.purgeOutside(e));}retain(e,t="default"){e.size===0?this.retainedByOwner.delete(t):this.retainedByOwner.set(t,new Set(e));let n=new Set;for(let i of this.retainedByOwner.values())for(let o of i)n.add(o);this.retained=n,this.purgeOutside(this.currentSymbol);}purgeOutside(e){for(let t of [...this.series.keys()]){let n=b1(t);n!==e&&!this.retained.has(n)&&(this.series.delete(t),this.coveredFrom.delete(t));}}clear(){this.series.clear(),this.coveredFrom.clear();}},co=new tl;function _u(r,e,t){let{provider:n,ticker:i}=Gt(r);return Bm(n??"",i,e,t)}var ho=1e4,v1=ho+1,po=class{constructor(e,t=co){this.inner=e;this.store=t;}async load(e){if(e.data&&e.data.length>0)return this.inner.load(e);let t=e.symbol??"TEST",n=_u(t,e.timeframe??"60",e.session);this.store.retainSymbol(t);let i=this.store.get(n),o=e.bars??500,s=i?.[i.length-1];if(i&&s&&i.length>=o-1&&this.inner.loadRange){let{bars:l}=await this.fetchRange(e,{from:s.time}),c=this.store.merge(n,uo(l));return Hm(c,l[l.length-1]).slice(-o)}let a=await this.inner.load(e);return this.store.merge(n,uo(a)),a}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.inner.load(e);if(!this.inner.loadProgressive)return null;let i=e.symbol??"TEST",o=_u(i,e.timeframe??"60",e.session),s=this.store.get(o),a=e.bars??500,l=s?.[s.length-1];if(s&&l&&s.length>=a-1&&this.inner.loadRange)return this.load(e);this.store.retainSymbol(i);let c=await this.inner.loadProgressive(e,t,n);return c==null?null:(this.store.merge(o,uo(c)),c)}async loadRange(e,t){if(!this.inner.loadRange)return this.inner.load(e);let n=_u(e.symbol??"TEST",e.timeframe??"60",e.session),i=this.store.get(n),o=i?.[i.length-1];if(t.to!=null&&o&&t.to<o.time){let u=i.filter(f=>f.time<=t.to),d=this.store.coveredFromOf(n)??1/0;if(t.limit!=null?u.length>=t.limit&&(t.from==null||d<=t.from):t.from!=null&&d<=t.from){let f=t.from!=null?u.filter(g=>g.time>=t.from):u;return t.limit!=null&&f.length>t.limit&&(f=f.slice(-t.limit)),f}let p=await this.fetchRange(e,t),m=p.bars.filter(f=>f.time<=t.to);return m.length>0&&(this.store.merge(n,m),this.store.markCovered(n,p.coveredDownTo??m[0].time)),m}if(o&&t.from!=null){let u=this.store.coveredFromOf(n);if(u!=null&&u>t.from){let{bars:d,coveredDownTo:h}=await this.fetchRange(e,{from:t.from,to:u});this.store.merge(n,d.filter(p=>p.time<=u)),this.store.markCovered(n,h??t.from),i=this.store.get(n),o=i?.[i.length-1];}}let s=this.store.coveredFromOf(n);if(!!i&&i.length>0&&!!o&&(t.from!=null?s!=null&&s<=t.from:t.limit==null||i.length>=t.limit)&&o){let{bars:u}=await this.fetchRange(e,{from:o.time,to:t.to,limit:t.limit}),d=this.store.merge(n,uo(u)),h=Hm(d,u[u.length-1]),p=t.from!=null?h.filter(m=>m.time>=t.from):h;return t.to!=null&&(p=p.filter(m=>m.time<=t.to)),p}let{bars:l,coveredDownTo:c}=await this.fetchRange(e,t);return this.store.merge(n,uo(l)),this.store.markCovered(n,c??t.from??l[0]?.time??0),l}async fetchRange(e,t){let n=Et(e.timeframe??"60"),i=y1(t,n);if(i<=v1){let c=await this.inner.loadRange(e,{...t,limit:t.limit??i});return {bars:c,coveredDownTo:t.from??c[0]?.time}}let o=new Map,s=t.to??Date.now();for(;!(t.from!=null&&s<t.from);){let c=t.limit!=null?t.limit-o.size:ho;if(c<=0)break;let u=await this.inner.loadRange(e,{to:s,limit:Math.min(ho,c)}),d=1/0;for(let h of u)h.time<d&&(d=h.time),h.time<=s&&(t.from==null||h.time>=t.from)&&o.set(h.time,h);if(u.length===0){if(t.from==null)break;s-=ho*n;continue}if(d-1>=s)break;s=d-1;}let a=[...o.values()].sort((c,u)=>c.time-u.time),l=t.from!=null&&s<t.from;return {bars:a,coveredDownTo:l?t.from:a[0]?.time}}subscribe(e,t){return this.inner.subscribe(e,t)}symbolInfo(e){return this.inner.symbolInfo?.(e)}};function y1(r,e){if(r.limit!=null)return r.limit;if(r.from==null)return ho;let t=Math.max(0,(r.to??Date.now())-r.from);return Math.ceil(t/e*1.1)+2}function uo(r){return r.length>0?r.slice(0,-1):r}function Hm(r,e){if(!e)return r;let t=r[r.length-1];return !t||e.time>t.time?[...r,e]:r}function w1(r){return {"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,"1M":2592e6,1:6e4,5:3e5,15:9e5,30:18e5,60:36e5,240:144e5,D:864e5,W:6048e5,M:2592e6}[r]??36e5}var br=class{constructor(e=co){this.registry=new Ja;this.primaryProvider=null;this.liveBars=[];this.symInfoCache=new Map;this.cache=new po(new Hu(this.registry),e);}registerProvider(e,t){return this.registry.register(e,t)}unregisterProvider(e){this.registry.unregister(e);}providers(){return this.registry.names().map(e=>this.registry.infoOf(e))}resolveSymbol(e){return this.registry.resolve(e,{default:this.primaryProvider})}displayPrefix(e){let t=this.resolveSymbol(e);return t?this.registry.displayPrefixOf(t):null}canonicalSymbol(e){let t=this.resolveSymbol(e);return t?this.registry.canonicalSymbol(t):null}providerInstance(e){return this.registry.get(e)}symbolIconOf(e){return this.registry.symbolIconOf(e)}symbolIcon(e){return this.registry.symbolIcon(this.resolveSymbol(e))}symbols(e){return this.registry.symbolsOf(e)}onUnresolved(e){return this.registry.onUnresolved(e)}destroy(){this.registry.cancelWaits();}ready(){return this.registry.indexReady()}async symbolInfoFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return;let n=await this.registry.get(t.provider)?.getSymbolInfo?.(t.ticker);return n&&this.symInfoCache.set(Bu(t),n),n}capabilitiesFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return null;let n=this.registry.get(t.provider);return n?n.capabilitiesFor?.(t.ticker)??this.registry.infoOf(t.provider).capabilities:null}async load(e){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(n=>({...n})),e.data;let t=await this.registry.whenResolvable(mo(e),{default:this.primaryProvider});return this.primaryProvider=t.provider,this.prefetchSymbolInfo(t),this.cache.load(nl(e,t))}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(o=>({...o})),e.data;let i=await this.registry.whenResolvable(mo(e),{default:this.primaryProvider});return this.primaryProvider=i.provider,this.prefetchSymbolInfo(i),this.cache.loadProgressive(nl(e,i),t,n)}symbolInfo(e){if(e.data&&e.data.length>0)return;let t=this.registry.resolve(mo(e),{default:this.primaryProvider});return t?this.symInfoCache.get(Bu(t)):void 0}prefetchSymbolInfo(e){let t=Bu(e);if(this.symInfoCache.has(t))return;let n=this.registry.get(e.provider);n?.getSymbolInfo&&n.getSymbolInfo(e.ticker).then(i=>{i&&this.symInfoCache.set(t,i);}).catch(()=>{});}async loadRange(e,t){if(e.data&&e.data.length>0)return this.cache.loadRange(e,t);let n=this.registry.resolve(mo(e),{default:this.primaryProvider});return n?this.cache.loadRange(nl(e,n),t):[]}subscribe(e,t){if(e.data&&e.data.length>0)return this.synthesizeTicks(e,t);let n=this.registry.resolve(mo(e),{default:this.primaryProvider});return n?this.cache.subscribe(nl(e,n),t):()=>{}}synthesizeTicks(e,t){if(this.liveBars.length===0)return ()=>{};let n=w1(e.timeframe??"60"),i=setInterval(()=>{let o=this.liveBars,s=o[o.length-1];if(!s)return;let a=s.close*.0015*(Math.random()-.5)*2,l=Math.max(0,s.close+a),c={...s,close:l,high:Math.max(s.high,l),low:Math.min(s.low,l)};if(o[o.length-1]=c,t(c),Math.random()<.12){let u={time:c.time+n,open:c.close,high:c.close,low:c.close,close:c.close,volume:0};o.push(u),t(u);}},1e3);return ()=>clearInterval(i)}};function mo(r){return r.symbol??""}function nl(r,e){return {...r,symbol:`${e.provider}:${e.ticker}`}}function Bu(r){return `${r.provider}|${r.ticker}`}async function zm(r,e,t,n){try{return await r.getBars(e,t,n)}catch(i){return console.warn(`[vela] data fetch failed for ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}var Hu=class{constructor(e){this.registry=e;}load(e){let{provider:t,ticker:n}=Gt(e.symbol??""),i=this.registry.get(t??"");return i?zm(i,n,e.timeframe??"60",{limit:e.bars??500,session:e.session}):Promise.resolve([])}async loadProgressive(e,t,n){let{provider:i,ticker:o}=Gt(e.symbol??""),s=this.registry.get(i??"");if(!s)return [];if(!s.getBarsProgressive)return null;try{return await s.getBarsProgressive(o,e.timeframe??"60",{limit:e.bars??500,session:e.session},t,n)}catch(a){return console.warn(`[vela] progressive fetch failed for ${o} ${e.timeframe??"60"} \u2014 ${a instanceof Error?a.message:String(a)}`),[]}}loadRange(e,t){let{provider:n,ticker:i}=Gt(e.symbol??""),o=this.registry.get(n??"");return o?zm(o,i,e.timeframe??"60",{...t,session:e.session}):Promise.resolve([])}subscribe(e,t){let{provider:n,ticker:i}=Gt(e.symbol??""),o=this.registry.get(n??"");if(!o)return ()=>{};let s=e.timeframe??"60";if(o.subscribe)return o.subscribe(i,s,t,e.session?{session:e.session}:void 0);let a=false,l=null,c=async()=>{if(!a){try{let u=await o.getBars(i,s,{limit:2,session:e.session});if(a)return;for(let d of u)t(d);}catch{}a||(l=setTimeout(()=>{c();},3e3));}};return l=setTimeout(()=>{c();},3e3),()=>{a=true,l&&clearTimeout(l);}}};var fo=class{constructor(e){this.registry=e instanceof br?e:null;}registerProvider(e,t){return this.registry?(this.registry.registerProvider(e,t),this):(console.warn(`[vela] chart.data.registerProvider("${e}") ignored \u2014 the active data feed is a custom feed (deps.dataFeed), not the default provider registry.`),this)}unregisterProvider(e){return this.registry?.unregisterProvider(e),this}providers(){return this.registry?.providers()??[]}resolve(e){return this.registry?.resolveSymbol(e)??null}displayPrefix(e){return this.registry?.displayPrefix(e)??null}canonicalSymbol(e){return this.registry?.canonicalSymbol(e)??null}providerInstance(e){return this.registry?.providerInstance(e)}symbols(e){return this.registry?.symbols(e)??[]}symbolIcon(e){return this.registry?.symbolIcon(e)}symbolInfo(e){return this.registry?.symbolInfoFor(e)??Promise.resolve(void 0)}capabilities(e){return this.registry?.capabilitiesFor(e)??null}ready(){return this.registry?.ready()??Promise.resolve()}};var go=class{constructor(e){this.ctrl=e;}get supported(){return this.ctrl.supported}setTool(e){return this.ok("setTool")&&this.ctrl.setTool(e),this}getTool(){return this.ctrl.getTool()}setSnapMode(e){return this.ok("setSnapMode")&&this.ctrl.setSnapMode(e),this}getSnapMode(){return this.ctrl.getSnapMode()}setStayMode(e){return this.ok("setStayMode")&&this.ctrl.setStayMode(e),this}getStayMode(){return this.ctrl.getStayMode()}setMode(e){return this.ok("setMode")&&this.ctrl.setMode(e),this}getMode(){return this.ctrl.getMode()}showToolbar(e=true){return this.ok("showToolbar")&&this.ctrl.showToolbar(e),this}setToolbar(e){return this.ok("setToolbar")&&this.ctrl.setToolbar(e),this}setToolShortcuts(e){return this.ok("setToolShortcuts")&&this.ctrl.setToolShortcuts(e),this}setExternalGhost(e){return this.ctrl.setExternalGhost(e),this}add(e,t={}){return this.ok("add")?this.ctrl.add(e,t):null}remove(e){return this.ctrl.remove(e),this}update(e,t){return this.ctrl.update(e,t),this}updateMany(e){return this.ctrl.updateMany(e),this}removeMany(e){return this.ctrl.removeMany(e),this}lock(e,t=true){return this.ctrl.setLocked(e,t),this}show(e,t=true){return this.ctrl.setVisible(e,t),this}select(e){return this.ok("select")&&this.ctrl.select(e==null?[]:typeof e=="string"?[e]:e),this}openSettings(e){return this.ok("openSettings")&&this.ctrl.openSettings(e),this}bringToFront(e){return this.ctrl.bringToFront(e),this}sendToBack(e){return this.ctrl.sendToBack(e),this}undo(){return this.ctrl.undo(),this}redo(){return this.ctrl.redo(),this}canUndo(){return this.ctrl.canUndo()}canRedo(){return this.ctrl.canRedo()}clone(e){return this.ok("clone")&&this.ctrl.clone(e),this}duplicate(e){return this.ok("duplicate")&&this.ctrl.duplicate(e),this}copyToClipboard(e){return this.ok("copy")&&this.ctrl.copy(e),this}paste(){return this.ok("paste")&&this.ctrl.paste(),this}all(){return this.ctrl.all()}toJSON(){return this.ctrl.toJSON()}fromJSON(e){return this.ctrl.fromJSON(e),this}favorites(){return this.ctrl.favorites()}isFavorite(e){return this.ctrl.isFavorite(e)}setFavorite(e,t){return this.ok("setFavorite")&&this.ctrl.setFavorite(e,t),this}setFavorites(e){return this.ok("setFavorites")&&this.ctrl.setFavorites([...e]),this}getConfig(){return this.ctrl.toJSON()}applyConfig(e){return this.ctrl.fromJSON(e),this}ok(e){return this.ctrl.supported?true:(console.warn(`[vela] chart.drawings.${e}() ignored \u2014 the active renderer has no userDrawings capability.`),false)}};var bo=class{constructor(e){this.ctrl=e;}get supported(){return this.ctrl.supported}add(e){return this.ctrl.add(e),this}set(e){return this.ctrl.set(e),this}remove(e){return this.ctrl.remove(e),this}clear(){return this.ctrl.clear(),this}all(){return this.ctrl.all()}defineGroup(e){return this.ctrl.defineGroup(e),this}groups(){return this.ctrl.groupDefinitions()}setGroupVisible(e,t=true){return this.ctrl.setGroupVisible(e,t),this}isGroupVisible(e){return this.ctrl.isGroupVisible(e)}};var vo=class r{constructor(e=()=>Date.now()){this.now=e;this.subs=new Set;this.timer=null;}onTick(e){return this.subs.add(e),this.timer==null&&this.arm(),()=>{this.subs.delete(e),this.subs.size===0&&this.timer!=null&&(clearTimeout(this.timer),this.timer=null);}}static delayToNextSecond(e){return 1e3-(e%1e3+1e3)%1e3+5}arm(){this.timer=setTimeout(()=>{this.timer=null;let e=this.now();for(let t of this.subs)t(e);this.subs.size>0&&this.arm();},r.delayToNextSecond(this.now()));}};function rl(r){let e=r.trim(),t=/^#([0-9a-f]{3})$/i.exec(e);if(t){let i=t[1];return {r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16)}}if(t=/^#([0-9a-f]{6})[0-9a-f]{0,2}$/i.exec(e),t){let i=t[1];return {r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16)}}let n=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i.exec(e);return n?{r:parseFloat(n[1]),g:parseFloat(n[2]),b:parseFloat(n[3])}:null}function q(r,e){let t=rl(r);return t?`rgba(${t.r},${t.g},${t.b},${e})`:r}function $m(r,e,t){let n=rl(r),i=rl(e);if(!n||!i)return r;let o=(s,a)=>Math.round(s+(a-s)*t);return `rgb(${o(n.r,i.r)},${o(n.g,i.g)},${o(n.b,i.b)})`}function lt(r){let e=rl(r);return e?.2126*e.r+.7152*e.g+.0722*e.b<128:true}var il={"--vela-space-1":"4px","--vela-space-2":"8px","--vela-space-3":"12px","--vela-space-4":"16px","--vela-radius-sm":"4px","--vela-radius-md":"6px","--vela-radius-lg":"10px","--vela-z-tooltip":"60","--vela-z-menu":"50","--vela-z-dialog":"40","--vela-z-popover":"6000","--vela-ease":"cubic-bezier(0.22, 1, 0.36, 1)","--vela-dur-fast":"90ms","--vela-dur-med":"160ms","--vela-font-size-sm":"11px","--vela-font-size-md":"12px","--vela-font-size-lg":"14px"};function ol(r){let e=lt(r.background),t=i=>e?`rgba(255,255,255,${i})`:q(r.textColor,i+.02),n=$m(r.background,e?"#ffffff":r.textColor,e?.03:.05);return {"--vela-font":r.fontFamily,"--vela-bg":r.background,"--vela-fg":e?"#d1d4dc":r.textColor,"--vela-fg-muted":e?"#868a96":q(r.textColor,.62),"--vela-fg-faint":q(r.textColor,.35),"--vela-fg-bright":e?"#f0f3fa":"#000000","--vela-surface":r.background,"--vela-surface-elev":n,"--vela-surface-overlay":n,"--vela-surface-sunken":r.background,"--vela-border":r.borderColor,"--vela-border-strong":e?"#34353b":q(r.textColor,.28),"--vela-border-soft":r.borderColor,"--vela-border-faint":q(r.textColor,.08),"--vela-hover":t(.06),"--vela-active":t(.1),"--vela-hover-strong":t(.16),"--vela-focus":q(r.textColor,.5),"--vela-focus-soft":q(r.textColor,.12),"--vela-separator-hover-band":q(r.textColor,.1),"--vela-separator-hover-line":q(r.textColor,.55),"--vela-scroll":q(r.textColor,.3),"--vela-accent":Ke,"--vela-accent-bright":zr,"--vela-highlight":Up,"--vela-selected-bg":e?"#f0f3fa":r.textColor,"--vela-selected-fg":e?r.background:"#ffffff","--vela-fg-on-fill":"#ffffff","--vela-up":r.upColor,"--vela-down":r.downColor,"--vela-danger":r.downColor,"--vela-shadow":"0 8px 30px rgba(0,0,0,0.5)","--vela-shadow-dialog":"0 20px 60px rgba(0,0,0,0.5)","--vela-backdrop":"rgba(0,0,0,0.45)"}}function Re(r,e){let t=n=>{for(let i in n)r.style.setProperty(i,n[i]);};t(il),t(ol(e));}function Yt(r,e){let t=null,n=null,i=()=>{t!==null&&(clearTimeout(t),t=null),n?.remove(),n=null;},o=()=>{let a=e.text();if(!a)return;n=r.ownerDocument.createElement("div"),n.textContent=a,n.style.cssText="position:absolute;z-index:var(--vela-z-tooltip);pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);"+(e.wrap?"max-width:260px;":"white-space:nowrap;"),Re(n,e.theme()),e.host.appendChild(n);let c=r.getBoundingClientRect(),u=e.host.getBoundingClientRect();if(e.placement==="right")n.style.left=`${c.right-u.left+8}px`,n.style.top=`${c.top-u.top+(c.height-n.offsetHeight)/2}px`;else {let d=Math.min(c.left-u.left,Math.max(0,u.width-n.offsetWidth-4));n.style.left=`${Math.max(0,d)}px`,n.style.top=e.placement==="above"?`${Math.max(0,c.top-u.top-n.offsetHeight-6)}px`:`${c.bottom-u.top+6}px`;}},s=a=>{a.pointerType==="mouse"&&(i(),t=window.setTimeout(o,e.delayMs??700));};return r.addEventListener("pointerenter",s),r.addEventListener("pointerleave",i),r.addEventListener("pointerdown",i),()=>{r.removeEventListener("pointerenter",s),r.removeEventListener("pointerleave",i),r.removeEventListener("pointerdown",i),i();}}function sl(r,e){let t=e.size??16,n=document.createElement("span");n.className="vela-hint",n.setAttribute("role","img"),n.setAttribute("aria-label",r),n.innerHTML=ye("info",t),n.style.cssText=`flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:${t}px;height:${t}px;border-radius:50%;cursor:help;user-select:none;background:var(--vela-hover);color:var(--vela-fg-muted);transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease;`;let i=s=>{n.style.background=s?"var(--vela-active)":"var(--vela-hover)",n.style.color=s?"var(--vela-fg-bright)":"var(--vela-fg-muted)";};n.addEventListener("pointerenter",()=>i(true)),n.addEventListener("pointerleave",()=>i(false));let o=Yt(n,{host:e.host,theme:e.theme,text:()=>r,wrap:true,delayMs:250});return {el:n,dispose:o}}var x1=Object.defineProperty,S1=(r,e,t)=>e in r?x1(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,le=(r,e,t)=>S1(r,typeof e!="symbol"?e+"":e,t);function Wm(r){return r==null?[]:Array.isArray(r)?r:[r]}var Gm=r=>r[0],Um=r=>r[r.length-1];function Ym(r,e,t={}){let{step:n=1,loop:i=true}=t,o=e+n,s=r.length,a=s-1;return e===-1?n>0?0:a:o<0?i?a:0:o>=s?i?0:e>s?s:e:o}function Km(r,e,t={}){return r[Ym(r,e,t)]}function C1(r,e,t={}){let{step:n=1,loop:i=true}=t;return Ym(r,e,{step:-n,loop:i})}function Xm(r,e,t={}){return r[C1(r,e,t)]}var jm=r=>r?.constructor.name==="Array",T1=(r,e)=>{if(r.length!==e.length)return false;for(let t=0;t<r.length;t++)if(!ei(r[t],e[t]))return false;return true},ei=(r,e)=>{if(Object.is(r,e))return true;if(r==null&&e!=null||r!=null&&e==null)return false;if(typeof r?.isEqual=="function"&&typeof e?.isEqual=="function")return r.isEqual(e);if(typeof r=="function"&&typeof e=="function")return r.toString()===e.toString();if(jm(r)&&jm(e))return T1(Array.from(r),Array.from(e));if(typeof r!="object"||typeof e!="object")return false;let t=Object.keys(e??Object.create(null)),n=t.length;for(let i=0;i<n;i++)if(!Reflect.has(r,t[i]))return false;for(let i=0;i<n;i++){let o=t[i];if(!ei(r[o],e[o]))return false}return true};var k1=r=>r!=null&&typeof r=="object";var ti=r=>typeof r=="string",nt=r=>typeof r=="function",qm=r=>r==null,yo=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),E1=r=>Object.prototype.toString.call(r),Zm=Function.prototype.toString,M1=Zm.call(Object),vr=r=>{if(!k1(r)||E1(r)!="[object Object]"||I1(r))return false;let e=Object.getPrototypeOf(r);if(e===null)return true;let t=yo(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Zm.call(t)==M1},L1=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,P1=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,I1=r=>L1(r)||P1(r);var wo=(r,...e)=>(typeof r=="function"?r(...e):r)??void 0,zu=r=>r,Jm=r=>r(),$u=()=>{},On=(...r)=>(...e)=>{r.forEach(function(t){t?.(...e);});};function Nn(r){if(!vr(r)||r===void 0)return r;let e=Reflect.ownKeys(r).filter(n=>typeof n=="string"),t={};for(let n of e){let i=r[n];i!==void 0&&(t[n]=Nn(i));}return t}function ni(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Wu(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function xo(r,e){if(r==null)throw new Error(e())}var A1=(...r)=>r.map(e=>e?.trim?.()).filter(Boolean).join(" "),R1=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,Qm=r=>{let e={},t;for(;t=R1.exec(r);)e[t[1]]=t[2];return e},D1=(r,e)=>{if(ti(r)){if(ti(e))return `${r};${e}`;r=Qm(r);}else ti(e)&&(e=Qm(e));return Object.assign({},r??{},e??{})};function ef(...r){let e={};for(let t of r){if(!t)continue;for(let i in e){if(i.startsWith("on")&&typeof e[i]=="function"&&typeof t[i]=="function"){e[i]=On(t[i],e[i]);continue}if(i==="className"||i==="class"){e[i]=A1(e[i],t[i]);continue}if(i==="style"){e[i]=D1(e[i],t[i]);continue}e[i]=t[i]!==void 0?t[i]:e[i];}for(let i in t)e[i]===void 0&&(e[i]=t[i]);let n=Object.getOwnPropertySymbols(t);for(let i of n)e[i]=t[i];}return e}var Fn=".",rf="#",tf=new WeakMap,of=new WeakMap;function Gu(r){return r.join(Fn)}function O1(r){return r.includes(Fn)}function sf(r){return r.startsWith(rf)}function N1(r){return r.startsWith(Fn)}function F1(r){return sf(r)?r.slice(rf.length):r}function Uu(r,e){return r?`${r}${Fn}${e}`:e}function V1(r){let e=new Map,t=new Map,n=(i,o)=>{e.set(i,o);let s=o.id;s&&(t.has(s)&&Wu(`[zag-js] Duplicate state id: "${s}"`),t.set(s,i));let a=o.states;if(a){xo(o.initial,()=>`[zag-js] Compound state "${i}" has child states but no "initial" property`),o.initial in a||Wu(`[zag-js] Compound state "${i}" has initial "${String(o.initial)}" which is not a child state`);for(let[l,c]of Object.entries(a)){if(!c)continue;let u=Uu(i,l);n(u,c);}}};for(let[i,o]of Object.entries(r.states))o&&n(i,o);return {index:e,idIndex:t}}function ri(r){let e=tf.get(r);if(e)return e;let{index:t,idIndex:n}=V1(r);return tf.set(r,t),of.set(r,n),t}function _1(r,e){return ri(r),of.get(r)?.get(e)}function Yu(r){return r?String(r).split(Fn).filter(Boolean):[]}function al(r,e){if(!e)return [];let t=ri(r),n=Yu(e),i=[],o=[];for(let s of n){o.push(s);let a=Gu(o),l=t.get(a);if(!l)break;i.push({path:a,state:l});}return i}function So(r,e){let t=ri(r),n=Yu(e);if(!n.length)return e;let i=[];for(let a of n){i.push(a);let l=Gu(i);if(!t.has(l))return e}let o=Gu(i),s=t.get(o);for(;s?.initial;){let a=`${o}${Fn}${s.initial}`,l=t.get(a);if(!l)break;o=a,s=l;}return o}function nf(r,e){return ri(r).has(e)}function Ku(r,e,t){let n=String(e);if(sf(n)){let i=F1(n),o=_1(r,i);return xo(o,()=>`[zag-js] Unknown state id: "${i}"`),So(r,o)}if(N1(n)&&t){let i=Uu(t,n.slice(1));return So(r,i)}if(!O1(n)&&t){let i=Yu(t);for(let o=i.length-1;o>=1;o--){let s=i.slice(0,o).join(Fn),a=Uu(s,n);if(nf(r,a))return So(r,a)}if(nf(r,n))return So(r,n)}return So(r,n)}function af(r,e,t){let n=al(r,e);for(let o=n.length-1;o>=0;o--){let a=n[o]?.state.on?.[t];if(a)return {transitions:a,source:n[o]?.path}}return {transitions:r.on?.[t],source:void 0}}function lf(r,e,t,n){let i=e?al(r,e):[],o=al(r,t),s=0;for(;s<i.length&&s<o.length&&i[s]?.path===o[s]?.path;)s+=1;let a=i.slice(s).reverse(),l=o.slice(s),c=i.at(-1)?.path===o.at(-1)?.path;return n&&c&&(a=i.slice().reverse(),l=o),{exiting:a,entering:l}}function cf(r,e){return r?r===e||r.startsWith(`${e}${Fn}`):false}function uf(r,e,t){return al(r,e).some(n=>n.state.tags?.includes(t))}function df(){return {and:(...r)=>function(t){return r.every(n=>t.guard(n))},or:(...r)=>function(t){return r.some(n=>t.guard(n))},not:r=>function(t){return !t.guard(r)}}}function ll(r){return ri(r),r}var ii=(r=>(r.NotStarted="Not Started",r.Started="Started",r.Stopped="Stopped",r))(ii||{}),Co="__init__";var B1=Object.defineProperty,H1=(r,e,t)=>e in r?B1(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,cl=(r,e,t)=>H1(r,typeof e!="symbol"?e+"":e,t);var hf=(r,e)=>r.map((t,n)=>r[(Math.max(e,0)+n)%r.length]);var To=()=>{},ko=r=>typeof r=="object"&&r!==null;var mt=r=>r?"":void 0,Xu=r=>r?"true":void 0;var z1=1,$1=9,W1=11;var ce=r=>ko(r)&&r.nodeType===z1&&typeof r.nodeName=="string",Eo=r=>ko(r)&&r.nodeType===$1,G1=r=>ko(r)&&r===r.window;var pf=r=>ce(r)?r.localName||"":"#document";function mf(r){return ["html","body","#document"].includes(pf(r))}var ff=r=>ko(r)&&r.nodeType!==void 0,yr=r=>ff(r)&&r.nodeType===W1&&"host"in r,ju=r=>ce(r)&&r.localName==="input",gf=r=>!!r?.matches("a[href]"),bf=r=>ce(r)?r.offsetWidth>0||r.offsetHeight>0||r.getClientRects().length>0:false;function Mo(r){if(!r)return false;let e=r.getRootNode();return Kt(e)===r}var U1=/(textarea|select)/;function oi(r){if(r==null||!ce(r))return false;try{return ju(r)&&r.selectionStart!=null||U1.test(r.localName)||r.isContentEditable||r.getAttribute("contenteditable")==="true"||r.getAttribute("contenteditable")===""}catch{return false}}function rt(r,e){if(!r||!e||!ce(r)||!ff(e))return false;if(ce(e)&&r===e||r.contains(e))return true;let t=e.getRootNode?.();if(t&&yr(t)){let n=e;for(;n;){if(r===n)return true;n=n.parentNode||n.host;}}return false}function Me(r){return Eo(r)?r:G1(r)?r.document:r?.ownerDocument??document}function Y1(r){return Me(r).documentElement}function Ce(r){return yr(r)?Ce(r.host):Eo(r)?r.defaultView??window:ce(r)?r.ownerDocument?.defaultView??window:window}function Kt(r){let e=r.activeElement;for(;e?.shadowRoot;){let t=e.shadowRoot.activeElement;if(!t||t===e)break;e=t;}return e}function vf(r){if(pf(r)==="html")return r;let e=r.assignedSlot||r.parentNode||yr(r)&&r.host||Y1(r);return yr(e)?e.host:e}function ul(r){let e;try{if(e=r.getRootNode({composed:!0}),Eo(e)||yr(e))return e}catch{}return r.ownerDocument??document}var qu=new WeakMap;function si(r){return qu.has(r)||qu.set(r,Ce(r).getComputedStyle(r)),qu.get(r)}var Zu=new Set(["menu","listbox","dialog","grid","tree","region","application"]),K1=r=>Zu.has(r),yf=r=>r.getAttribute("aria-controls")?.split(" ")||[];function dl(r,e){let t=new Set,n=ul(r),i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=yf(a);for(let c of l){if(!c||t.has(c))continue;t.add(c);let u=n.getElementById(c);if(u){let d=u.getAttribute("role"),h=u.getAttribute("aria-modal")==="true";if(d&&K1(d)&&!h&&(u===e||u.contains(e)||i(u)))return true}}}return false};return i(r)}function Ju(r,e){let t=ul(r),n=new Set,i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=yf(a);for(let c of l){if(!c||n.has(c))continue;n.add(c);let u=t.getElementById(c);if(u){let d=u.getAttribute("role"),h=u.getAttribute("aria-modal")==="true";d&&Zu.has(d)&&!h&&(e(u),i(u));}}}};i(r);}function wf(r){let e=new Set;return Ju(r,t=>{r.contains(t)||e.add(t);}),Array.from(e)}function X1(r){let e=r.getAttribute("role");return !!(e&&Zu.has(e))}function j1(r){return r.hasAttribute("aria-controls")&&r.getAttribute("aria-expanded")==="true"}function xf(r){return j1(r)?true:!!r.querySelector?.('[aria-controls][aria-expanded="true"]')}function Sf(r){if(!r.id)return false;let e=ul(r),t=CSS.escape(r.id),n=`[aria-controls~="${t}"][aria-expanded="true"], [aria-controls="${t}"][aria-expanded="true"]`;return !!(e.querySelector(n)&&X1(r))}var Qu=()=>typeof document<"u";function q1(){return navigator.userAgentData?.platform??navigator.platform}function Z1(){let r=navigator.userAgentData;return r&&Array.isArray(r.brands)?r.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" "):navigator.userAgent}var ed=r=>Qu()&&r.test(q1()),Cf=r=>Qu()&&r.test(Z1());var td=()=>Qu()&&!!navigator.maxTouchPoints,J1=()=>ed(/^iPhone/i),Q1=()=>ed(/^iPad/i)||ai()&&navigator.maxTouchPoints>1,Tf=()=>J1()||Q1();var ai=()=>ed(/^Mac/i);var kf=()=>Cf(/Firefox/i);var Ef=()=>Cf(/Android/i);function eT(r){return r.composedPath?.()??r.nativeEvent?.composedPath?.()}function De(r){return eT(r)?.[0]??r.target}function nd(r){let e=r.currentTarget;if(!e||!e.matches("a[href], button[type='submit'], input[type='submit']"))return false;let n=r.button===1,i=tT(r);return n||i}function rd(r){let e=r.currentTarget;if(!e)return false;let t=e.localName;return r.altKey?t==="a"||t==="button"&&e.type==="submit"||t==="input"&&e.type==="submit":false}function tT(r){return ai()?r.metaKey:r.ctrlKey}function Lf(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function Pf(r){return r.pointerType===""&&r.isTrusted?true:Ef()&&r.pointerType?r.type==="click"&&r.buttons===1:r.detail===0&&!r.pointerType}var hl=r=>r.button===2||ai()&&r.ctrlKey&&r.button===0,If=r=>r.ctrlKey||r.altKey||r.metaKey,nT=r=>"touches"in r&&r.touches.length>0,rT={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},Mf={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function id(r,e={}){let{dir:t="ltr",orientation:n="horizontal"}=e,i=r.key;return i=rT[i]??i,t==="rtl"&&n==="horizontal"&&i in Mf&&(i=Mf[i]),i}function li(r,e="client"){let t=nT(r)?r.touches[0]||r.changedTouches[0]:r;return {x:t[`${e}X`],y:t[`${e}Y`]}}var je=(r,e,t,n)=>{let i=typeof r=="function"?r():r;return i?.addEventListener(e,t,n),()=>{i?.removeEventListener(e,t,n);}};var Af=r=>ce(r)&&r.tagName==="IFRAME",iT=/^(audio|video|details)$/;function Rf(r){let e=r.getAttribute("tabindex");return e?parseInt(e,10):NaN}var oT=r=>!Number.isNaN(Rf(r)),sT=r=>Rf(r)<0;function aT(r){return ju(r)&&r.type==="radio"}function lT(r){if(!aT(r)||!r.name||r.checked)return true;let e=`input[type="radio"][name="${CSS.escape(r.name)}"]`,t=r.form??r.ownerDocument,n=Array.from(t.querySelectorAll(e)).filter(o=>o.form===r.form&&ft(o)),i=n.find(o=>o.checked);return i?i===r:n[0]===r}function cT(r,e){if(!e)return null;if(e===true)return r.shadowRoot||null;let t=e(r);return (t===true?r.shadowRoot:t)||null}function Df(r,e,t){let n=[...r],i=[...r],o=new Set,s=new Map;r.forEach((l,c)=>s.set(l,c));let a=0;for(;a<i.length;){let l=i[a++];if(!l||o.has(l))continue;o.add(l);let c=cT(l,e);if(c){let u=Array.from(c.querySelectorAll(pl)).filter(t),d=s.get(l);if(d!==void 0){let h=d+1;n.splice(h,0,...u),u.forEach((p,m)=>{s.set(p,h+m);});for(let p=h+u.length;p<n.length;p++)s.set(n[p],p);}else {let h=n.length;n.push(...u),u.forEach((p,m)=>{s.set(p,h+m);});}i.push(...u);}}return n}var pl="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type",od=(r,e={})=>{if(!r)return [];let{includeContainer:t=false,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(pl));(t==true||t=="if-empty"&&i.length===0)&&ce(r)&&ft(r)&&i.unshift(r);let s=[];for(let a of i)if(ft(a)){if(Af(a)&&a.contentDocument){let l=a.contentDocument.body;s.push(...od(l,{getShadowRoot:n}));continue}s.push(a);}return n?Df(s,n,ft):s};function ft(r){return !ce(r)||r.closest("[inert]")?false:r.matches(pl)&&bf(r)}function ci(r,e={}){if(!r)return [];let{includeContainer:t,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(pl));t&&Vn(r)&&i.unshift(r);let o=[];for(let s of i)if(Vn(s)){if(Af(s)&&s.contentDocument){let a=s.contentDocument.body;o.push(...ci(a,{getShadowRoot:n}));continue}o.push(s);}if(n){let s=Df(o,n,Vn);return !s.length&&t?i:s}return !o.length&&t?i:o}function Vn(r){return ce(r)&&r.tabIndex>0?true:!ft(r)||sT(r)?false:lT(r)}function Of(r,e={}){let t=ci(r,e),n=t[0]||null,i=t[t.length-1]||null;return [n,i]}function ui(r){return r.tabIndex<0&&(iT.test(r.localName)||oi(r))&&!oT(r)?0:r.tabIndex}function ml(r){let{root:e,getInitialEl:t,filter:n,enabled:i=true}=r;if(!i)return;let o=null;if(o||(o=typeof t=="function"?t():t),o||(o=e?.querySelector("[data-autofocus],[autofocus]")),!o){let s=ci(e);o=n?s.filter(n)[0]:s[0];}return o||e||void 0}function Nf(r){let e=r.currentTarget;if(!e)return false;let[t,n]=Of(e);return !(Mo(t)&&r.shiftKey||Mo(n)&&!r.shiftKey||!t&&!n)}var uT=class Ff{constructor(){cl(this,"id",null),cl(this,"fn_cleanup"),cl(this,"cleanup",()=>{this.cancel();});}static create(){return new Ff}request(e){this.cancel(),this.id=globalThis.requestAnimationFrame(()=>{this.id=null,this.fn_cleanup=e?.();});}cancel(){this.id!==null&&(globalThis.cancelAnimationFrame(this.id),this.id=null),this.fn_cleanup?.(),this.fn_cleanup=void 0;}isActive(){return this.id!==null}};function Ie(r){let e=uT.create();return e.request(r),e.cleanup}function Vf(r){let e=new Set;function t(n){let i=globalThis.requestAnimationFrame(n);e.add(()=>globalThis.cancelAnimationFrame(i));}return t(()=>t(r)),function(){e.forEach(i=>i());}}function _f(r,e,t){let n=Ie(()=>{r.removeEventListener(e,i,true),t();}),i=()=>{n(),t();};return r.addEventListener(e,i,{once:true,capture:true}),n}function dT(r,e){if(!r)return;let{attributes:t,callback:n}=e,i=r.ownerDocument.defaultView||window,o=new i.MutationObserver(s=>{for(let a of s)a.type==="attributes"&&a.attributeName&&t.includes(a.attributeName)&&n(a);});return o.observe(r,{attributes:true,attributeFilter:t}),()=>o.disconnect()}function Bf(r,e){let n=Ie,i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(dT(o,e));})),()=>{i.forEach(o=>o?.());}}function Hf(r){let e=()=>{let t=Ce(r);r.dispatchEvent(new t.MouseEvent("click"));};kf()?_f(r,"keyup",e):queueMicrotask(e);}function fl(r){let e=vf(r);return mf(e)?Me(e).body:ce(e)&&sd(e)?e:fl(e)}var hT=/auto|scroll|overlay|hidden|clip/,pT=new Set(["inline","contents"]);function sd(r){let e=Ce(r),{overflow:t,overflowX:n,overflowY:i,display:o}=e.getComputedStyle(r);return hT.test(t+i+n)&&!pT.has(o)}function di(r,e){return Array.from(r?.querySelectorAll(e)??[])}var gl=r=>r.id;function mT(r,e,t=gl){return r.find(n=>t(n)===e)}function zf(r,e,t=gl){let n=mT(r,e,t);return n?r.indexOf(n):-1}function fT(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth}function $f(r,e){let{rootEl:t,...n}=e||{};!r||!t||!sd(t)||!fT(t)||r.scrollIntoView(n);}var gT=r=>r.split("").map(e=>{let t=e.charCodeAt(0);return t>0&&t<128?e:t>=128&&t<=255?`/x${t.toString(16)}`.replace("/","\\"):""}).join("").trim(),bT=r=>gT(r.dataset?.valuetext??r.textContent??""),vT=(r,e)=>r.trim().toLowerCase().startsWith(e.toLowerCase());function Wf(r,e,t,n=gl){let i=t?zf(r,t,n):-1,o=t?hf(r,i):r;return e.length===1&&(o=o.filter(a=>n(a)!==t)),o.find(a=>vT(bT(a),e))}function Lo(r,e){if(!r)return To;let t=Object.keys(e).reduce((n,i)=>(n[i]=r.style.getPropertyValue(i),n),{});return yT(t,e)?To:(Object.assign(r.style,e),()=>{Object.assign(r.style,t),r.style.length===0&&r.removeAttribute("style");})}function Gf(r,e,t){if(!r)return To;let n=r.style.getPropertyValue(e);return n===t?To:(r.style.setProperty(e,t),()=>{r.style.setProperty(e,n),r.style.length===0&&r.removeAttribute("style");})}function yT(r,e){return Object.keys(r).every(t=>r[t]===e[t])}function wT(r,e){let{state:t,activeId:n,key:i,timeout:o=350,itemToId:s}=e,a=t.keysSoFar+i,c=a.length>1&&Array.from(a).every(m=>m===a[0])?a[0]:a,u=r.slice(),d=Wf(u,c,n,s);function h(){clearTimeout(t.timer),t.timer=-1;}function p(m){t.keysSoFar=m,h(),m!==""&&(t.timer=+setTimeout(()=>{p(""),h();},o));}return p(a),d}var bl=Object.assign(wT,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:xT});function xT(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function ST(r,e,t){let{signal:n}=e;return [new Promise((s,a)=>{let l=setTimeout(()=>{a(new Error(`Timeout of ${t}ms exceeded`));},t);n.addEventListener("abort",()=>{clearTimeout(l),a(new DOMException("Promise aborted","AbortError"));}),r.then(c=>{n.aborted||(clearTimeout(l),s(c));}).catch(c=>{n.aborted||(clearTimeout(l),a(c));});}),()=>e.abort()]}function Uf(r,e){let{timeout:t,rootNode:n}=e,i=Ce(n),o=Me(n),s=new i.AbortController;return ST(new Promise(a=>{let l=r();if(l){a(l);return}let c=new i.MutationObserver(()=>{let u=r();u&&u.isConnected&&(c.disconnect(),a(u));});c.observe(o.body,{childList:true,subtree:true});}),s,t)}function Yf(r){let e=()=>r.getRootNode?.()??document,t=()=>Me(e());return {...r,getRootNode:e,getDoc:t,getWin:()=>t().defaultView??window,getActiveElement:()=>Kt(e()),isActiveElement:Mo,getById:s=>e().getElementById(s)}}function Kf(r){return new Proxy({},{get(e,t){return t==="style"?n=>r({style:n}).style:r}})}var Xf={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},CT=new Set(["viewBox","preserveAspectRatio"]),TT=r=>{let e="";for(let t in r){let n=r[t];n!=null&&(t.startsWith("--")||(t=t.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)),e+=`${t}:${n};`);}return e},hi=Kf(r=>Object.entries(r).reduce((e,[t,n])=>{if(n===void 0)return e;if(t in Xf&&(t=Xf[t]),t==="style"&&typeof n=="object")return e.style=TT(n),e;let i=CT.has(t)?t:t.toLowerCase();return e[i]=n,e},{}));var vl=new WeakMap,jf=new Set(["value","checked","selected"]),kT=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),ET=r=>r.tagName==="svg"||r.namespaceURI==="http://www.w3.org/2000/svg",yl=(r,e)=>ET(r)&&kT.has(e)?e:e.toLowerCase();function it(r,e,t){let n=t||"default",i=vl.get(r);i||(i=new Map,vl.set(r,i));let o=i.get(n)||{},s=Object.keys(e),a=(f,g)=>{r.addEventListener(f.toLowerCase(),g);},l=(f,g)=>{r.removeEventListener(f.toLowerCase(),g);},c=f=>f.startsWith("on"),u=f=>!f.startsWith("on"),d=f=>a(f.substring(2),e[f]),h=f=>l(f.substring(2),e[f]),p=f=>{let g=e[f],b=o[f];if(g!==b){if(f==="class"){r.className=g??"";return}if(jf.has(f)){r[f]=g??"";return}if(typeof g=="boolean"&&!f.includes("aria-")){r.toggleAttribute(yl(r,f),g);return}if(f==="children"){r.innerHTML=g;return}if(g!=null){r.setAttribute(yl(r,f),g);return}r.removeAttribute(yl(r,f));}};for(let f in o)e[f]==null&&(f==="class"?r.className="":jf.has(f)?r[f]="":r.removeAttribute(yl(r,f)));return Object.keys(o).filter(c).forEach(f=>{l(f.substring(2),o[f]);}),s.filter(c).forEach(d),s.filter(u).forEach(p),i.set(n,e),function(){s.filter(c).forEach(h);let g=vl.get(r);g&&(g.delete(n),g.size===0&&vl.delete(r));}}function MT(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function ad(r,e){let t=MT();return t?(t[r]||(t[r]=e()),t[r]):e()}var pi=ad("__zag__refSet",()=>new WeakSet);var LT=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,PT=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,IT=r=>typeof r=="object"&&r!==null&&"nodeType"in r&&typeof r.nodeName=="string",AT=r=>LT(r)||PT(r)||IT(r),wl=r=>r!==null&&typeof r=="object",ld=r=>wl(r)&&!pi.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!AT(r)&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise)&&!(r instanceof File)&&!(r instanceof Blob)&&!(r instanceof AbortController);var RT=Symbol();var qf=Object.getPrototypeOf,cd=new WeakMap,DT=r=>r&&(cd.has(r)?cd.get(r):qf(r)===Object.prototype||qf(r)===Array.prototype);var Zf=r=>DT(r)&&r[RT]||null,ud=(r,e=true)=>{cd.set(r,e);};var wr=ad("__zag__proxyStateMap",()=>new WeakMap),OT=(r=Object.is,e=(a,l)=>new Proxy(a,l),t=new WeakMap,n=(a,l)=>{let c=t.get(a);if(c?.[0]===l)return c[1];let u=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return ud(u,true),t.set(a,[l,u]),Reflect.ownKeys(a).forEach(d=>{let h=Reflect.get(a,d);pi.has(h)?(ud(h,false),u[d]=h):wr.has(h)?u[d]=Jf(h):u[d]=h;}),Object.freeze(u)},i=new WeakMap,o=[1,1],s=a=>{if(!wl(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=o[0],u=new Set,d=(k,x=++o[0])=>{c!==x&&(c=x,u.forEach(M=>M(k,x)));},h=o[1],p=(k=++o[1])=>(h!==k&&!u.size&&(h=k,f.forEach(([x])=>{let M=x[1](k);M>c&&(c=M);})),c),m=k=>(x,M)=>{let w=[...x];w[1]=[k,...w[1]],d(w,M);},f=new Map,g=(k,x)=>{if(u.size){let M=x[3](m(k));f.set(k,[x,M]);}else f.set(k,[x]);},b=k=>{let x=f.get(k);x&&(f.delete(k),x[1]?.());},y=k=>(u.add(k),u.size===1&&f.forEach(([M,w],L)=>{let P=M[3](m(L));f.set(L,[M,P]);}),()=>{u.delete(k),u.size===0&&f.forEach(([M,w],L)=>{w&&(w(),f.set(L,[M]));});}),v=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),E=e(v,{deleteProperty(k,x){let M=Reflect.get(k,x);b(x);let w=Reflect.deleteProperty(k,x);return w&&d(["delete",[x],M]),w},set(k,x,M,w){let L=Reflect.has(k,x),P=Reflect.get(k,x,w);if(L&&(r(P,M)||i.has(M)&&r(P,i.get(M))))return true;b(x),wl(M)&&(M=Zf(M)||M);let C=M;if(!Object.getOwnPropertyDescriptor(k,x)?.set){!wr.has(M)&&ld(M)&&(C=xl(M));let A=!pi.has(C)&&wr.get(C);A&&g(x,A);}return Reflect.set(k,x,C,w),d(["set",[x],M,P]),true}});i.set(a,E);let T=[v,p,n,y];return wr.set(E,T),Reflect.ownKeys(a).forEach(k=>{let x=Object.getOwnPropertyDescriptor(a,k);x.get||x.set?Object.defineProperty(v,k,x):E[k]=a[k];}),E})=>[s,wr,pi,r,e,ld,t,n,i,o],[NT]=OT();function xl(r={}){return NT(r)}function Sl(r,e,t){let n=wr.get(r);let i,o=[],s=n[3],a=false,c=s(u=>{if(o.push(u),t);i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(o.splice(0));}));});return a=true,()=>{a=false,c();}}function Jf(r){let e=wr.get(r);let[t,n,i]=e;return i(t,n())}function Io(r){let e=r().value??r().defaultValue;r().debug&&console.log(`[bindable > ${r().debug}] initial`,e);let t=r().isEqual??Object.is,n=xl({value:e}),i=()=>r().value!==void 0;return {initial:e,ref:n,get(){return i()?r().value:n.value},set(o){let s=i()?r().value:n.value,a=nt(o)?o(s):o;r().debug&&console.log(`[bindable > ${r().debug}] setValue`,{next:a,prev:s}),i()||(n.value=a),t(a,s)||r().onChange?.(a,s);},invoke(o,s){r().onChange?.(o,s);},hash(o){return r().hash?.(o)??String(o)}}}Io.cleanup=r=>{};Io.ref=r=>{let e=r;return {get:()=>e,set:t=>{e=t;}}};function Qf(r){let e={current:r};return {get(t){return e.current[t]},set(t,n){e.current[t]=n;}}}function dd(r,e){if(!vr(r)||!vr(e))return e===void 0?r:e;let t={...r};for(let n of Object.keys(e)){let i=e[n],o=r[n];i!==void 0&&(vr(o)&&vr(i)?t[n]=dd(o,i):t[n]=i);}return t}var hd=class{constructor(r,e={}){le(this,"machine",r),le(this,"scope"),le(this,"context"),le(this,"prop"),le(this,"state"),le(this,"refs"),le(this,"computed"),le(this,"event",{type:""}),le(this,"previousEvent",{type:""}),le(this,"effects",new Map),le(this,"transition",null),le(this,"cleanups",[]),le(this,"subscriptions",[]),le(this,"userPropsRef"),le(this,"getEvent",()=>({...this.event,current:()=>this.event,previous:()=>this.previousEvent})),le(this,"getState",()=>({...this.state,matches:(...d)=>d.some(h=>cf(this.state.get(),h)),hasTag:d=>uf(this.machine,this.state.get(),d)})),le(this,"debug",(...d)=>{this.machine.debug&&console.log(...d);}),le(this,"notify",()=>{this.publish();}),le(this,"send",d=>{this.status===ii.Started&&queueMicrotask(()=>{if(!d)return;this.previousEvent=this.event,this.event=d,this.debug("send",d);let h=this.state.get(),p=d.type,{transitions:m,source:f}=af(this.machine,h,p),g=this.choose(m);if(!g)return;this.transition=g;let b=Ku(this.machine,g.target??h,f);this.debug("transition",g),b!==h?this.state.set(b):g.reenter?this.state.invoke(h,h):this.action(g.actions);});}),le(this,"action",d=>{let h=nt(d)?d(this.getParams()):d;if(!h)return;let p=h.map(m=>{let f=this.machine.implementations?.actions?.[m];return f||ni(`[zag-js] No implementation found for action "${JSON.stringify(m)}"`),f});for(let m of p)m?.(this.getParams());}),le(this,"guard",d=>{if(nt(d))return d(this.getParams());let h=this.machine.implementations?.guards?.[d];return h||ni(`[zag-js] No implementation found for guard "${JSON.stringify(d)}"`),h?.(this.getParams())}),le(this,"effect",d=>{let h=nt(d)?d(this.getParams()):d;if(!h)return;let p=h.map(f=>{let g=this.machine.implementations?.effects?.[f];return g||ni(`[zag-js] No implementation found for effect "${JSON.stringify(f)}"`),g}),m=[];for(let f of p){let g=f?.(this.getParams());g&&m.push(g);}return ()=>m.forEach(f=>f?.())}),le(this,"choose",d=>Wm(d).find(h=>{let p=!h.guard;return ti(h.guard)?p=!!this.guard(h.guard):nt(h.guard)&&(p=h.guard(this.getParams())),p})),le(this,"subscribe",d=>(this.subscriptions.push(d),()=>{let h=this.subscriptions.indexOf(d);h>-1&&this.subscriptions.splice(h,1);})),le(this,"status",ii.NotStarted),le(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(d=>d(this.service));}),le(this,"trackers",[]),le(this,"setupTrackers",()=>{this.machine.watch?.(this.getParams());}),le(this,"callTrackers",()=>{this.trackers.forEach(({deps:d,fn:h})=>{let p=d.map(m=>m());ei(h.prev,p)||(h(),h.prev=p);});}),le(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(d,h)=>{h.prev=d.map(p=>p()),this.trackers.push({deps:d,fn:h});},refs:this.refs,computed:this.computed,flush:Jm,scope:this.scope,choose:this.choose})),this.userPropsRef={current:e};let{id:t,ids:n,getRootNode:i}=wo(e);this.scope=Yf({id:t,ids:n,getRootNode:i});let o=d=>{let h=wo(this.userPropsRef.current);return (r.props?.({props:Nn(h),scope:this.scope})??h)[d]};this.prop=o;let s=r.context?.({prop:o,bindable:Io,scope:this.scope,flush(d){queueMicrotask(d);},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});s&&Object.values(s).forEach(d=>{let h=Sl(d.ref,()=>this.notify());this.cleanups.push(h);});let a={get(d){return s?.[d].get()},set(d,h){s?.[d].set(h);},initial(d){return s?.[d].initial},hash(d){let h=s?.[d].get();return s?.[d].hash(h)}};this.context=a;let l=d=>(xo(r.computed,()=>"[zag-js] No computed object found on machine"),r.computed[d]({context:a,event:this.getEvent(),prop:o,refs:this.refs,scope:this.scope,computed:l}));this.computed=l;let c=Qf(r.refs?.({prop:o,context:a})??{});this.refs=c;let u=Io(()=>({defaultValue:Ku(r,r.initialState({prop:o})),onChange:(d,h)=>{let{exiting:p,entering:m}=lf(this.machine,h,d,this.transition?.reenter);if(p.forEach(f=>{this.effects.get(f.path)?.(),this.effects.delete(f.path);}),p.forEach(f=>{this.action(f.state?.exit);}),this.action(this.transition?.actions),m.forEach(f=>{let g=this.effect(f.state?.effects);if(g){let b=this.effects.get(f.path);this.effects.set(f.path,b?On(b,g):g);}}),h===Co){this.action(r.entry);let f=this.effect(r.effects);if(f){let g=this.effects.get(Co);this.effects.set(Co,g?On(g,f):f);}}m.forEach(f=>{this.action(f.state?.entry);});}}));this.state=u,this.cleanups.push(Sl(this.state.ref,()=>this.notify()));}updateProps(r){let e=this.userPropsRef.current;this.userPropsRef.current=()=>{let t=wo(e),n=wo(r);return dd(t,n)},this.notify();}start(){this.status=ii.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,Co),this.setupTrackers();}stop(){this.effects.forEach(r=>r?.()),this.effects.clear(),this.transition=null,this.action(this.machine.exit),this.cleanups.forEach(r=>r()),this.cleanups=[],this.subscriptions=[],this.status=ii.Stopped,this.debug("unmounting...");}get service(){return {state:this.getState(),send:this.send,context:this.context,prop:this.prop,scope:this.scope,refs:this.refs,computed:this.computed,event:this.getEvent(),getStatus:()=>this.status}}};function Cl(r,e,t){let n=new hd(r,e),i=n.subscribe(t);return n.start(),t(n.service),{service:n.service,flush:()=>t(n.service),stop:()=>{i(),n.stop();}}}var FT=0;function Tl(r){return `${r}-${++FT}`}function xr(r,e=8){return `${r}::-webkit-scrollbar{width:${e}px;height:${e}px;}${r}::-webkit-scrollbar-thumb{background:var(--vela-scroll);border-radius:4px;border:2px solid transparent;background-clip:padding-box;}${r}::-webkit-scrollbar-track{background:transparent;}${r}::-webkit-scrollbar-button{display:none;width:0;height:0;}`}var eg="outline:none;transition:border-color .12s ease,box-shadow .12s ease;",tg="border-color:var(--vela-focus);box-shadow:0 0 0 3px var(--vela-focus-soft);";function he(r,e,t=document){if(typeof document>"u")return;let n=t instanceof Document?t.head:t;if(t.getElementById?.(r)??n.querySelector(`#${CSS.escape(r)}`))return;let i=document.createElement("style");i.id=r,i.textContent=e,n.appendChild(i);}function qe(r,e=document){let t=e.createElement("span");t.className="vela-icon",t.setAttribute("aria-hidden","true");let n=$r(r);return n&&(t.innerHTML=n),t}var pn=(r,e=[])=>({parts:(...t)=>{if(VT(e))return pn(r,t);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...t)=>pn(r,[...e,...t]),omit:(...t)=>pn(r,e.filter(n=>!t.includes(n))),rename:t=>pn(t,e),keys:()=>e,build:()=>[...new Set(e)].reduce((t,n)=>Object.assign(t,{[n]:{selector:[`&[data-scope="${mi(r)}"][data-part="${mi(n)}"]`,`& [data-scope="${mi(r)}"][data-part="${mi(n)}"]`].join(", "),attrs:{"data-scope":mi(r),"data-part":mi(n)}}}),{})}),mi=r=>r.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),VT=r=>r.length===0;var _T=pn("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),We=_T.build();var ig=["top","right","bottom","left"];var Xt=Math.min,Lt=Math.max,Ro=Math.round,Do=Math.floor,jt=r=>({x:r,y:r}),BT={left:"right",right:"left",bottom:"top",top:"bottom"};function pd(r,e,t){return Lt(r,Xt(e,t))}function qt(r,e){return typeof r=="function"?r(e):r}function mn(r){return r.split("-")[0]}function Sr(r){return r.split("-")[1]}function El(r){return r==="x"?"y":"x"}function Ml(r){return r==="y"?"height":"width"}function Pt(r){let e=r[0];return e==="t"||e==="b"?"y":"x"}function Ll(r){return El(Pt(r))}function og(r,e,t){t===void 0&&(t=false);let n=Sr(r),i=Ll(r),o=Ml(i),s=i==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Ao(s)),[s,Ao(s)]}function sg(r){let e=Ao(r);return [kl(r),e,kl(e)]}function kl(r){return r.includes("start")?r.replace("start","end"):r.replace("end","start")}var ng=["left","right"],rg=["right","left"],HT=["top","bottom"],zT=["bottom","top"];function $T(r,e,t){switch(r){case "top":case "bottom":return t?e?rg:ng:e?ng:rg;case "left":case "right":return e?HT:zT;default:return []}}function ag(r,e,t,n){let i=Sr(r),o=$T(mn(r),t==="start",n);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(kl)))),o}function Ao(r){let e=mn(r);return BT[e]+r.slice(e.length)}function WT(r){var e,t,n,i;return {top:(e=r.top)!=null?e:0,right:(t=r.right)!=null?t:0,bottom:(n=r.bottom)!=null?n:0,left:(i=r.left)!=null?i:0}}function md(r){return typeof r!="number"?WT(r):{top:r,right:r,bottom:r,left:r}}function Cr(r){let{x:e,y:t,width:n,height:i}=r;return {width:n,height:i,top:t,left:e,right:e+n,bottom:t+i,x:e,y:t}}function lg(r,e,t){let{reference:n,floating:i}=r,o=Pt(e),s=Ll(e),a=Ml(s),l=mn(e),c=o==="y",u=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,h=n[a]/2-i[a]/2,p;switch(l){case "top":p={x:u,y:n.y-i.height};break;case "bottom":p={x:u,y:n.y+n.height};break;case "right":p={x:n.x+n.width,y:d};break;case "left":p={x:n.x-i.width,y:d};break;default:p={x:n.x,y:n.y};}let m=Sr(e);return m&&(p[s]+=h*(m==="end"?1:-1)*(t&&c?-1:1)),p}async function dg(r,e){var t;e===void 0&&(e={});let{x:n,y:i,platform:o,rects:s,elements:a,strategy:l}=r,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=false,padding:p=0}=qt(e,r),m=md(p),g=a[h?d==="floating"?"reference":"floating":d],b=Cr(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(g)))==null||t?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),y=d==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),S=await(o.isElement==null?void 0:o.isElement(v))&&await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1},E=Cr(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:v,strategy:l}):y);return {top:(b.top-E.top+m.top)/S.y,bottom:(E.bottom-b.bottom+m.bottom)/S.y,left:(b.left-E.left+m.left)/S.x,right:(E.right-b.right+m.right)/S.x}}var GT=50,hg=async(r,e,t)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:dg},l=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:r,floating:e,strategy:i}),{x:u,y:d}=lg(c,n,l),h=n,p=0,m={};for(let f=0;f<o.length;f++){let g=o[f];if(!g)continue;let{name:b,fn:y}=g,{x:v,y:S,data:E,reset:T}=await y({x:u,y:d,initialPlacement:n,placement:h,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:r,floating:e}});u=v??u,d=S??d,m[b]={...m[b],...E},T&&p<GT&&(p++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(c=T.rects===true?await s.getElementRects({reference:r,floating:e,strategy:i}):T.rects),{x:u,y:d}=lg(c,h,l)),f=-1);}return {x:u,y:d,placement:h,strategy:i,middlewareData:m}},pg=r=>({name:"arrow",options:r,async fn(e){let{x:t,y:n,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=qt(r,e)||{};if(c==null)return {};let d=md(u),h={x:t,y:n},p=Ll(i),m=Ml(p),f=await s.getDimensions(c),g=p==="y",b=g?"top":"left",y=g?"bottom":"right",v=g?"clientHeight":"clientWidth",S=o.reference[m]+o.reference[p]-h[p]-o.floating[m],E=h[p]-o.reference[p],T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),k=T?T[v]:0;(!k||!await(s.isElement==null?void 0:s.isElement(T)))&&(k=a.floating[v]||o.floating[m]);let x=S/2-E/2,M=k/2-f[m]/2-1,w=Xt(d[b],M),L=Xt(d[y],M),P=k-f[m]-L,C=k/2-f[m]/2+x,A=pd(w,C,P),$=!l.arrow&&Sr(i)!=null&&C!==A&&o.reference[m]/2-(C<w?w:L)-f[m]/2<0,ie=$?C<w?C-w:C-P:0;return {[p]:h[p]+ie,data:{[p]:A,centerOffset:C-A-ie,...$&&{alignmentOffset:ie}},reset:$}}});var mg=function(r){return r===void 0&&(r={}),{name:"flip",options:r,async fn(e){var t,n;let{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=true,crossAxis:d=true,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:f=true,...g}=qt(r,e);if((t=o.arrow)!=null&&t.alignmentOffset)return {};let b=mn(i),y=Pt(a),v=mn(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=h||(v||!f?[Ao(a)]:sg(a)),T=m!=="none";!h&&T&&E.push(...ag(a,f,m,S));let k=[a,...E],x=await l.detectOverflow(e,g),M=[],w=((n=o.flip)==null?void 0:n.overflows)||[];if(u&&M.push(x[b]),d){let A=og(i,s,S);M.push(x[A[0]],x[A[1]]);}if(w=[...w,{placement:i,overflows:M}],!M.every(A=>A<=0)){var L,P;let A=(((L=o.flip)==null?void 0:L.index)||0)+1,$=k[A];if($&&(!(d==="alignment"?y!==Pt($):false)||w.every(j=>Pt(j.placement)===y?j.overflows[0]>0:true)))return {data:{index:A,overflows:w},reset:{placement:$}};let ie=(P=w.filter(oe=>oe.overflows[0]<=0).sort((oe,j)=>oe.overflows[1]-j.overflows[1])[0])==null?void 0:P.placement;if(!ie)switch(p){case "bestFit":{var C;let oe=(C=w.filter(j=>{if(T){let ut=Pt(j.placement);return ut===y||ut==="y"}return true}).map(j=>[j.placement,j.overflows.filter(ut=>ut>0).reduce((ut,C0)=>ut+C0,0)]).sort((j,ut)=>j[1]-ut[1])[0])==null?void 0:C[0];oe&&(ie=oe);break}case "initialPlacement":ie=a;break}if(i!==ie)return {reset:{placement:ie}}}return {}}}};function cg(r,e){return {top:r.top-e.height,right:r.right-e.width,bottom:r.bottom-e.height,left:r.left-e.width}}function ug(r){return ig.some(e=>r[e]>=0)}var fg=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(e){let{rects:t,platform:n}=e,{strategy:i="referenceHidden",...o}=qt(r,e);switch(i){case "referenceHidden":{let s=await n.detectOverflow(e,{...o,elementContext:"reference"}),a=cg(s,t.reference);return {data:{referenceHiddenOffsets:a,referenceHidden:ug(a)}}}case "escaped":{let s=await n.detectOverflow(e,{...o,altBoundary:true}),a=cg(s,t.floating);return {data:{escapedOffsets:a,escaped:ug(a)}}}default:return {}}}}};var gg=new Set(["left","top"]);async function UT(r,e){let{placement:t,platform:n,elements:i}=r,o=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=mn(t),a=Sr(t),l=Pt(t)==="y",c=gg.has(s)?-1:1,u=o&&l?-1:1,d=qt(e,r),{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}var bg=function(r){return r===void 0&&(r=0),{name:"offset",options:r,async fn(e){var t,n;let{x:i,y:o,placement:s,middlewareData:a}=e,l=await UT(e,r);return s===((t=a.offset)==null?void 0:t.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},vg=function(r){return r===void 0&&(r={}),{name:"shift",options:r,async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:s=true,crossAxis:a=false,limiter:l={fn:y=>{let{x:v,y:S}=y;return {x:v,y:S}}},...c}=qt(r,e),u={x:t,y:n},d=await o.detectOverflow(e,c),h=Pt(i),p=El(h),m=u[p],f=u[h],g=(y,v)=>pd(v+d[y==="y"?"top":"left"],v,v-d[y==="y"?"bottom":"right"]);s&&(m=g(p,m)),a&&(f=g(h,f));let b=l.fn({...e,[p]:m,[h]:f});return {...b,data:{x:b.x-t,y:b.y-n,enabled:{[p]:s,[h]:a}}}}}},yg=function(r){return r===void 0&&(r={}),{options:r,fn(e){var t,n;let{x:i,y:o,placement:s,rects:a,middlewareData:l}=e,{offset:c=0,mainAxis:u=true,crossAxis:d=true}=qt(r,e),h={x:i,y:o},p=Pt(s),m=El(p),f=h[m],g=h[p],b=qt(c,e),y=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(n=b.crossAxis)!=null?n:0};if(u){let E=m==="y"?"height":"width",T=a.reference[m]-a.floating[E]+y.mainAxis,k=a.reference[m]+a.reference[E]-y.mainAxis;f<T?f=T:f>k&&(f=k);}if(d){var v,S;let E=m==="y"?"width":"height",T=gg.has(mn(s)),k=a.reference[p]-a.floating[E]+(T&&((v=l.offset)==null?void 0:v[p])||0)+(T?0:y.crossAxis),x=a.reference[p]+a.reference[E]+(T?0:((S=l.offset)==null?void 0:S[p])||0)-(T?y.crossAxis:0);g<k?g=k:g>x&&(g=x);}return {[m]:f,[p]:g}}}},wg=function(r){return r===void 0&&(r={}),{name:"size",options:r,async fn(e){let{placement:t,rects:n,platform:i,elements:o}=e,{apply:s=()=>{},...a}=qt(r,e),l=await i.detectOverflow(e,a),c=mn(t),u=Sr(t),d=Pt(t)==="y",{width:h,height:p}=n.floating,m,f;c==="top"||c==="bottom"?(m=c,f=u===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(f=c,m=u==="end"?"top":"bottom");let g=p-l.top-l.bottom,b=h-l.left-l.right,y=Xt(p-l[m],g),v=Xt(h-l[f],b),S=e.middlewareData.shift,E=!S,T=y,k=v;S!=null&&S.enabled.x&&(k=b),S!=null&&S.enabled.y&&(T=g),E&&!u&&(d?k=h-2*Lt(l.left,l.right):T=p-2*Lt(l.top,l.bottom)),await s({...e,availableWidth:k,availableHeight:T});let x=await i.getDimensions(o.floating);return h!==x.width||p!==x.height?{reset:{rects:true}}:{}}}};function Pl(){return typeof window<"u"}function kr(r){return Sg(r)?(r.nodeName||"").toLowerCase():"#document"}function Ze(r){var e;return (r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function Zt(r){var e;return (e=(Sg(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function Sg(r){return Pl()?r instanceof Node||r instanceof Ze(r).Node:false}function It(r){return Pl()?r instanceof Element||r instanceof Ze(r).Element:false}function fn(r){return Pl()?r instanceof HTMLElement||r instanceof Ze(r).HTMLElement:false}function xg(r){return !Pl()||typeof ShadowRoot>"u"?false:r instanceof ShadowRoot||r instanceof Ze(r).ShadowRoot}function Oo(r){let{overflow:e,overflowX:t,overflowY:n,display:i}=At(r);return /auto|scroll|overlay|hidden|clip/.test(e+n+t)&&i!=="inline"&&i!=="contents"}function Cg(r){return /^(table|td|th)$/.test(kr(r))}function No(r){try{if(r.matches(":popover-open"))return !0}catch{}try{return r.matches(":modal")}catch{return false}}var YT=/transform|translate|scale|rotate|perspective|filter/,KT=/paint|layout|strict|content/,Tr=r=>!!r&&r!=="none",fd;function Il(r){let e=It(r)?At(r):r;return Tr(e.transform)||Tr(e.translate)||Tr(e.scale)||Tr(e.rotate)||Tr(e.perspective)||!Al()&&(Tr(e.backdropFilter)||Tr(e.filter))||YT.test(e.willChange||"")||KT.test(e.contain||"")}function Tg(r){let e=_n(r);for(;fn(e)&&!gi(e);){if(Il(e))return e;if(No(e))return null;e=_n(e);}return null}function Al(){return fd==null&&(fd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),fd}function gi(r){return /^(html|body|#document)$/.test(kr(r))}function At(r){return Ze(r).getComputedStyle(r)}function Fo(r){return It(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function _n(r){if(kr(r)==="html")return r;let e=r.assignedSlot||r.parentNode||xg(r)&&r.host||Zt(r);return xg(e)?e.host:e}function kg(r){let e=_n(r);return gi(e)?(r.ownerDocument||r).body:fn(e)&&Oo(e)?e:kg(e)}function fi(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=true);let i=kg(r),o=i===((n=r.ownerDocument)==null?void 0:n.body),s=Ze(i);if(o){let a=Rl(s);return e.concat(s,s.visualViewport||[],Oo(i)?i:[],a&&t?fi(a):[])}else return e.concat(i,fi(i,[],t))}function Rl(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}function Lg(r){let e=At(r),t=parseFloat(e.width)||0,n=parseFloat(e.height)||0,i=fn(r),o=i?r.offsetWidth:t,s=i?r.offsetHeight:n,a=Ro(t)!==o||Ro(n)!==s;return a&&(t=o,n=s),{width:t,height:n,$:a}}function bd(r){return It(r)?r:r.contextElement}function bi(r){let e=bd(r);if(!fn(e))return jt(1);let t=e.getBoundingClientRect(),{width:n,height:i,$:o}=Lg(e),s=(o?Ro(t.width):t.width)/n,a=(o?Ro(t.height):t.height)/i;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var XT=jt(0);function Pg(r){let e=Ze(r);return !Al()||!e.visualViewport?XT:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function jT(r,e,t){return e===void 0&&(e=false),!!t&&e&&t===Ze(r)}function Er(r,e,t,n){e===void 0&&(e=false),t===void 0&&(t=false);let i=r.getBoundingClientRect(),o=bd(r),s=jt(1);e&&(n?It(n)&&(s=bi(n)):s=bi(r));let a=jT(o,t,n)?Pg(o):jt(0),l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,u=i.width/s.x,d=i.height/s.y;if(o&&n){let h=Ze(o),p=It(n)?Ze(n):n,m=h,f=Rl(m);for(;f&&p!==m;){let g=bi(f),b=f.getBoundingClientRect(),y=At(f),v=b.left+(f.clientLeft+parseFloat(y.paddingLeft))*g.x,S=b.top+(f.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,c*=g.y,u*=g.x,d*=g.y,l+=v,c+=S,m=Ze(f),f=Rl(m);}}return Cr({width:u,height:d,x:l,y:c})}function Dl(r,e){let t=Fo(r).scrollLeft;return e?e.left+t:Er(Zt(r)).left+t}function Ig(r,e){let t=r.getBoundingClientRect(),n=t.left+e.scrollLeft-Dl(r,t),i=t.top+e.scrollTop;return {x:n,y:i}}function qT(r){let{elements:e,rect:t,offsetParent:n,strategy:i}=r,o=i==="fixed",s=Zt(n),a=e?No(e.floating):false;if(n===s||a&&o)return t;let l={scrollLeft:0,scrollTop:0},c=jt(1),u=jt(0),d=fn(n);if((d||!o)&&((kr(n)!=="body"||Oo(s))&&(l=Fo(n)),d)){let p=Er(n);c=bi(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop;}let h=s&&!d&&!o?Ig(s,l):jt(0);return {width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:t.y*c.y-l.scrollTop*c.y+u.y+h.y}}function ZT(r){return r.getClientRects?Array.from(r.getClientRects()):[]}function JT(r){let e=Fo(r),t=r.ownerDocument.body,n=Lt(r.scrollWidth,r.clientWidth,t.scrollWidth,t.clientWidth),i=Lt(r.scrollHeight,r.clientHeight,t.scrollHeight,t.clientHeight),o=-e.scrollLeft+Dl(r),s=-e.scrollTop;return At(t).direction==="rtl"&&(o+=Lt(r.clientWidth,t.clientWidth)-n),{width:n,height:i,x:o,y:s}}var QT=25;function ek(r,e,t){t===void 0&&(t="viewport");let n=t==="layoutViewport",i=Ze(r),o=Zt(r),s=i.visualViewport,a=o.clientWidth,l=o.clientHeight,c=0,u=0;if(s){let h=!Al()||e==="fixed";n?h||(c=-s.offsetLeft,u=-s.offsetTop):(a=s.width,l=s.height,h&&(c=s.offsetLeft,u=s.offsetTop));}if(Dl(o)<=0){let h=o.ownerDocument,p=h.body,m=getComputedStyle(p),f=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(o.clientWidth-p.clientWidth-f),b=getComputedStyle(o).scrollbarGutter==="stable both-edges"?g/2:g;b<=QT&&(a-=b);}return {width:a,height:l,x:c,y:u}}function tk(r,e){let t=Er(r,true,e==="fixed"),n=t.top+r.clientTop,i=t.left+r.clientLeft,o=bi(r),s=r.clientWidth*o.x,a=r.clientHeight*o.y,l=i*o.x,c=n*o.y;return {width:s,height:a,x:l,y:c}}function Eg(r,e,t){let n;if(e==="viewport"||e==="layoutViewport")n=ek(r,t,e);else if(e==="document")n=JT(Zt(r));else if(It(e))n=tk(e,t);else {let i=Pg(r);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height};}return Cr(n)}function nk(r,e){let t=e.get(r);if(t)return t;let n=fi(r,[],false).filter(a=>It(a)&&kr(a)!=="body"),i=null,o=At(r).position==="fixed",s=o?_n(r):r;for(;It(s)&&!gi(s);){let a=At(s),l=Il(s),c=i?i.position:o?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?n=n.filter(d=>d!==s):i=a,s=_n(s);}return e.set(r,n),n}function rk(r){let{element:e,boundary:t,rootBoundary:n,strategy:i}=r,s=[...t==="clippingAncestors"?No(e)?[]:nk(e,this._c):[].concat(t),n],a=Eg(e,s[0],i),l=a.top,c=a.right,u=a.bottom,d=a.left;for(let h=1;h<s.length;h++){let p=Eg(e,s[h],i);l=Lt(p.top,l),c=Xt(p.right,c),u=Xt(p.bottom,u),d=Lt(p.left,d);}return {width:c-d,height:u-l,x:d,y:l}}function ik(r){let{width:e,height:t}=Lg(r);return {width:e,height:t}}function ok(r,e,t){let n=fn(e),i=Zt(e),o=t==="fixed",s=Er(r,true,o,e),a={scrollLeft:0,scrollTop:0},l=jt(0);if((n||!o)&&((kr(e)!=="body"||Oo(i))&&(a=Fo(e)),n)){let h=Er(e,true,o,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop;}!n&&i&&(l.x=Dl(i));let c=i&&!n&&!o?Ig(i,a):jt(0),u=s.left+a.scrollLeft-l.x-c.x,d=s.top+a.scrollTop-l.y-c.y;return {x:u,y:d,width:s.width,height:s.height}}function gd(r){return At(r).position==="static"}function Mg(r,e){if(!fn(r)||At(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return Zt(r)===t&&(t=t.ownerDocument.body),t}function Ag(r,e){let t=Ze(r);if(No(r))return t;if(!fn(r)){let i=_n(r);for(;i&&!gi(i);){if(It(i)&&!gd(i))return i;i=_n(i);}return t}let n=Mg(r,e);for(;n&&Cg(n)&&gd(n);)n=Mg(n,e);return n&&gi(n)&&gd(n)&&!Il(n)?t:n||Tg(r)||t}var sk=async function(r){let e=this.getOffsetParent||Ag,t=this.getDimensions,n=await t(r.floating);return {reference:ok(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function ak(r){return At(r).direction==="rtl"}var lk={convertOffsetParentRelativeRectToViewportRelativeRect:qT,getDocumentElement:Zt,getClippingRect:rk,getOffsetParent:Ag,getElementRects:sk,getClientRects:ZT,getDimensions:ik,getScale:bi,isElement:It,isRTL:ak};function Rg(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function ck(r,e,t){let n=null,i,o=Zt(r);function s(){var u;clearTimeout(i),(u=n)==null||u.disconnect(),n=null;}function a(u,d){u===void 0&&(u=false),d===void 0&&(d=1),s();let h=r.getBoundingClientRect(),{left:p,top:m,width:f,height:g}=h;if(u||e(),!f||!g)return;let b=Do(m),y=Do(o.clientWidth-(p+f)),v=Do(o.clientHeight-(m+g)),S=Do(p),T={rootMargin:-b+"px "+-y+"px "+-v+"px "+-S+"px",threshold:Lt(0,Xt(1,d))||1},k=true;function x(M){let w=M[0].intersectionRatio;if(!Rg(h,r.getBoundingClientRect()))return a();if(w!==d){if(!k)return a();w?a(false,w):i=setTimeout(()=>{a(false,1e-7);},1e3);}k=false;}try{n=new IntersectionObserver(x,{...T,root:o.ownerDocument});}catch{n=new IntersectionObserver(x,T);}n.observe(r);}let l=Ze(r),c=()=>a(t);return l.addEventListener("resize",c),a(true),()=>{l.removeEventListener("resize",c),s();}}function Dg(r,e,t,n){n===void 0&&(n={});let{ancestorScroll:i=true,ancestorResize:o=true,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=false}=n,c=bd(r),u=i||o?[...c?fi(c):[],...e?fi(e):[]]:[];u.forEach(b=>{i&&b.addEventListener("scroll",t),o&&b.addEventListener("resize",t);});let d=c&&a?ck(c,t,o):null,h=-1,p=null;s&&(p=new ResizeObserver(b=>{let[y]=b;y&&y.target===c&&p&&e&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var v;(v=p)==null||v.observe(e);})),t();}),c&&!l&&p.observe(c),e&&p.observe(e));let m,f=l?Er(r):null;l&&g();function g(){let b=Er(r);f&&!Rg(f,b)&&t(),f=b,m=requestAnimationFrame(g);}return t(),()=>{var b;u.forEach(y=>{i&&y.removeEventListener("scroll",t),o&&y.removeEventListener("resize",t);}),d?.(),(b=p)==null||b.disconnect(),p=null,l&&cancelAnimationFrame(m);}}var Og=bg;var Ng=vg,Fg=mg,Vg=wg,_g=fg,Bg=pg;var Hg=yg,zg=(r,e,t)=>{let n=new Map,i=t??{},o={...lk,...i.platform,_c:n};return hg(r,e,{...i,platform:o})};function $g(r=0,e=0,t=0,n=0){if(typeof DOMRect=="function")return new DOMRect(r,e,t,n);let i={x:r,y:e,width:t,height:n,top:e,right:r+t,bottom:e+n,left:r};return {...i,toJSON:()=>i}}function uk(r){if(!r)return $g();let{x:e,y:t,width:n,height:i}=r;return $g(e,t,n,i)}function Wg(r,e){return {contextElement:ce(r)?r:r?.contextElement,getBoundingClientRect:()=>{let t=r,n=e?.(t);return n||!t?uk(n):t.getBoundingClientRect()}}}var Vo=r=>({variable:r,reference:`var(${r})`}),Jt={arrowSize:Vo("--arrow-size"),arrowSizeHalf:Vo("--arrow-size-half"),arrowBg:Vo("--arrow-background"),transformOrigin:Vo("--transform-origin"),arrowOffset:Vo("--arrow-offset")},dk=r=>r==="top"||r==="bottom"?"y":"x";function Gg(r,e){return {name:"transformOrigin",fn(t){let{elements:n,middlewareData:i,placement:o,rects:s,y:a}=t,l=o.split("-")[0],c=dk(l),u=i.arrow?.x||0,d=i.arrow?.y||0,h=e?.clientWidth||0,p=e?.clientHeight||0,m=u+h/2,f=d+p/2,g=Math.abs(i.shift?.y||0),b=s.reference.height/2,y=p/2,v=r.offset?.mainAxis??r.gutter,S=typeof v=="number"?v+y:v??y,E=g>S,T={top:`${m}px calc(100% + ${S}px)`,bottom:`${m}px ${-S}px`,left:`calc(100% + ${S}px) ${f}px`,right:`${-S}px ${f}px`}[l],k=`${m}px ${s.reference.y+b-a}px`,x=!!r.overlap&&c==="y"&&E;return n.floating.style.setProperty(Jt.transformOrigin.variable,x?k:T),{data:{transformOrigin:x?k:T}}}}}var Ug={name:"rects",fn({rects:r}){return {data:r}}},Yg=r=>{if(r)return {name:"shiftArrow",fn({placement:e,middlewareData:t}){if(!t.arrow)return {};let{x:n,y:i}=t.arrow,o=e.split("-")[0];return Object.assign(r.style,{left:n!=null?`${n}px`:"",top:i!=null?`${i}px`:"",[o]:`calc(100% + ${Jt.arrowOffset.reference})`}),{}}}};function Kg(r){let[e,t]=r.split("-");return {side:e,align:t,hasAlign:t!=null}}function _o(r){return r.split("-")[0]}var hk={strategy:"absolute",placement:"bottom",listeners:true,restoreStyles:false,gutter:8,flip:true,slide:true,overlap:false,sameWidth:false,fitViewport:false,overflowPadding:8,arrowPadding:4};function Xg(r,e){let t=r.devicePixelRatio||1;return Math.round(e*t)/t}function vi(r,e){return r!=null&&Math.abs(r-e)<.5}function Ol(r){return typeof r=="function"?r():r==="clipping-ancestors"?"clippingAncestors":r}function pk(r,e,t){let n=r||e.createElement("div");return Bg({element:n,padding:t.arrowPadding})}function mk(r,e){if(!qm(e.offset??e.gutter))return Og(({placement:t})=>{let n=(r?.clientHeight||0)/2,i=e.offset?.mainAxis??e.gutter,o=typeof i=="number"?i+n:i??n,{hasAlign:s}=Kg(t),a=s?void 0:e.shift,l=e.offset?.crossAxis??a;return Nn({crossAxis:l,mainAxis:o,alignmentAxis:e.shift})})}function fk(r){if(r.flip)return Fg(()=>{let e=Ol(r.boundary);return {...e?{boundary:e}:void 0,padding:r.overflowPadding,fallbackPlacements:r.flip===true?void 0:r.flip}})}function gk(r){if(!(!r.slide&&!r.overlap))return Ng(()=>{let e=Ol(r.boundary);return {...e?{boundary:e}:void 0,mainAxis:r.slide,crossAxis:r.overlap,padding:r.overflowPadding,limiter:Hg()}})}function bk(r){if(r.sizeMiddleware===false&&!r.sameWidth&&!r.fitViewport)return;let e,t,n,i;return Vg(()=>{let o=Ol(r.boundary);return {padding:r.overflowPadding,...o?{boundary:o}:void 0,apply({elements:s,rects:a,availableHeight:l,availableWidth:c}){let u=s.floating,d=Math.round(a.reference.width),h=Math.round(a.reference.height);c=Math.floor(c),l=Math.floor(l),vi(e,d)||(u.style.setProperty("--reference-width",`${d}px`),e=d),vi(t,h)||(u.style.setProperty("--reference-height",`${h}px`),t=h),vi(n,c)||(u.style.setProperty("--available-width",`${c}px`),n=c),vi(i,l)||(u.style.setProperty("--available-height",`${l}px`),i=l);}}})}function vk(r){if(r.hideWhenDetached)return _g(()=>({strategy:"referenceHidden",boundary:Ol(r.boundary)??"clippingAncestors"}))}function yk(r){return r?r===true?{ancestorResize:true,ancestorScroll:true,elementResize:true,layoutShift:true}:r:{}}var wk=["transform","visibility","pointer-events","--x","--y","--z-index","--reference-width","--reference-height","--available-width","--available-height","--transform-origin"],xk=["top","right","bottom","left"];function jg(r,e){if(!r)return $u;let t=new Map(e.map(n=>[n,r.style.getPropertyValue(n)]));return ()=>{t.forEach((n,i)=>{n?r.style.setProperty(i,n):r.style.removeProperty(i);}),r.style.length===0&&r.removeAttribute("style");}}function qg(r){return r==null?null:ce(r)?r:typeof r=="object"&&r&&"contextElement"in r&&r.contextElement?r.contextElement:r}function Sk(r,e,t={}){let n=()=>(typeof e=="function"?e():e)??null,i=()=>{let w=typeof r=="function"?r():r;return t.getAnchorElement?.()??w},o=()=>{let w=i();return !w&&!t.getAnchorRect?null:Wg(w,t.getAnchorRect)},s=Object.assign({},hk,t),a=[],l=null,c,u;function d(w){c?.(),u?.(),l=w,c=s.restoreStyles?jg(w,wk):void 0;let L=w.querySelector("[data-part=arrow]");u=s.restoreStyles?jg(L,xk):void 0,a=[mk(L,s),fk(s),gk(s),pk(L,w.ownerDocument,s),Yg(L),Gg({gutter:s.gutter,offset:s.offset,overlap:s.overlap},L),bk(s),vk(s),Ug];}let{placement:h,strategy:p,onComplete:m,onPositioned:f}=s,g,b,y=false,v,S,E=$u,T=yk(s.listeners);function k(){if(!s.listeners)return;let w=i(),L=o(),P=n();if(!L||!P)return;(qg(w)!==qg(v)||P!==S)&&(E(),v=w,S=P,E=Dg(L,P,M,T));}async function x(){k();let w=n();if(!w)return;w!==l&&(d(w),y=false);let L=o();if(!L)return;let P=await zg(L,w,{placement:h,middleware:a,strategy:p});m?.(P);let C=Ce(w),A=Xg(C,P.x),$=Xg(C,P.y);if(vi(g,A)||(w.style.setProperty("--x",`${A}px`),g=A),vi(b,$)||(w.style.setProperty("--y",`${$}px`),b=$),s.hideWhenDetached&&(P.middlewareData.hide?.referenceHidden?(w.style.setProperty("visibility","hidden"),w.style.setProperty("pointer-events","none")):(w.style.removeProperty("visibility"),w.style.removeProperty("pointer-events"))),!y){let ie=w.firstElementChild;ie&&(w.style.setProperty("--z-index",si(ie).zIndex),y=true);}}async function M(){t.updatePosition?(await t.updatePosition({updatePosition:x,floatingElement:n()}),f?.({placed:true})):await x();}return M(),()=>{E(),u?.(),c?.(),f?.({placed:false});}}function Nl(r,e,t={}){let{defer:n,...i}=t,o=n?Ie:a=>a(),s=[];return s.push(o(()=>{s.push(Sk(r,e,i));})),()=>{s.forEach(a=>a?.());}}var Ck={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"};function vd(r={}){let{placement:e,sameWidth:t,fitViewport:n,strategy:i="absolute"}=r;return {arrow:{position:"absolute",width:Jt.arrowSize.reference,height:Jt.arrowSize.reference,[Jt.arrowSizeHalf.variable]:`calc(${Jt.arrowSize.reference} / 2)`,[Jt.arrowOffset.variable]:`calc(${Jt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:e?Ck[e.split("-")[0]]:void 0,background:Jt.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:i,isolation:"isolate",minWidth:t?void 0:"max-content",width:t?"var(--reference-width)":void 0,maxWidth:n?"var(--available-width)":void 0,maxHeight:n?"var(--available-height)":void 0,pointerEvents:e?void 0:"none",top:"0px",left:"0px",transform:e?"translate3d(var(--x), var(--y), 0)":"translate3d(0, -100vh, 0)",zIndex:"var(--z-index)"}}}var Qt=(r,e)=>{let t=r.ids?.trigger;return t!=null?nt(t)?t(e):t:e?`menu:${r.id}:trigger:${e}`:`menu:${r.id}:trigger`},Fl=(r,e)=>{let t=r.ids?.contextTrigger;return t!=null?nt(t)?t(e):t:e?`menu:${r.id}:ctx-trigger:${e}`:`menu:${r.id}:ctx-trigger`},Bn=r=>r.ids?.content??`menu:${r.id}:content`,Zg=r=>r.ids?.arrow??`menu:${r.id}:arrow`,yd=r=>r.ids?.positioner??`menu:${r.id}:popper`,Jg=(r,e)=>r.ids?.group?.(e)??`menu:${r.id}:group:${e}`,Mr=(r,e)=>`${r.id}/${e}`,Hn=r=>r?.dataset.value??null,wd=(r,e)=>r.ids?.groupLabel?.(e)??`menu:${r.id}:group-label:${e}`,Rt=r=>r.getById(Bn(r)),xd=r=>r.getById(yd(r)),Sd=r=>r.getById(Qt(r)),Qg=(r,e)=>e?r.getById(Mr(r,e)):null;var eb=r=>r.getById(Fl(r)),Cd=r=>di(r.getRootNode(),`[data-scope="menu"][data-part="trigger"][data-ownedby="${r.id}"]`),Td=r=>di(r.getRootNode(),`[data-scope="menu"][data-part="context-trigger"][data-ownedby="${r.id}"]`),Bo=(r,e)=>e==null?Sd(r)??Cd(r)[0]:r.getById(Qt(r,e)),Ho=r=>{let t=`[role^="menuitem"][data-ownedby=${CSS.escape(Bn(r))}]:not([data-disabled])`;return di(Rt(r),t)},tb=r=>Gm(Ho(r)),nb=r=>Um(Ho(r)),kd=(r,e)=>e?r.id===e||r.dataset.value===e:false,rb=(r,e)=>{let t=Ho(r),n=t.findIndex(i=>kd(i,e.value));return Km(t,n,{loop:e.loop??e.loopFocus})},ib=(r,e)=>{let t=Ho(r),n=t.findIndex(i=>kd(i,e.value));return Xm(t,n,{loop:e.loop??e.loopFocus})},ob=(r,e)=>{let t=Ho(r),n=t.find(i=>kd(i,e.value));return bl(t,{state:e.typeaheadState,key:e.key,activeId:n?.id??null})},zo=r=>ce(r)&&(r.dataset.disabled===""||r.hasAttribute("disabled")),Ed=r=>!!r?.getAttribute("role")?.startsWith("menuitem")&&!!r?.hasAttribute("data-controls");var Vl="menu:select";function sb(r,e){if(!r)return;let t=Ce(r),n=new t.CustomEvent(Vl,{detail:{value:e}});r.dispatchEvent(n);}function Tk(r){let e=Bn(r);return Rt(r)??r.getDoc().getElementById(e)}function Md(r,e){if(!ce(r))return false;for(let t in e){let n=e[t],i=Tk(n.scope);if(i&&rt(i,r))return true;let o=n.refs.get("children");if(Object.keys(o).length>0&&Md(r,o))return true}return false}var $o=(r,e)=>({x:r,y:e});function ab(r){let{x:e,y:t,width:n,height:i}=r,o=e+n/2,s=t+i/2;return {x:e,y:t,width:n,height:i,minX:e,minY:t,maxX:e+n,maxY:t+i,midX:o,midY:s,center:$o(o,s)}}function lb(r){let e=$o(r.minX,r.minY),t=$o(r.maxX,r.minY),n=$o(r.maxX,r.maxY),i=$o(r.minX,r.maxY);return {top:e,right:t,bottom:n,left:i}}function cb(r,e){let t=ab(r),{top:n,right:i,left:o,bottom:s}=lb(t),[a]=e.split("-");return {top:[o,n,i,s],right:[n,i,s,o],bottom:[n,o,s,i],left:[i,n,o,s]}[a]}function _l(r,e){let{x:t,y:n}=e,i=false;for(let o=0,s=r.length-1;o<r.length;s=o++){let a=r[o].x,l=r[o].y,c=r[s].x,u=r[s].y;l>n!=u>n&&t<(c-a)*(n-l)/(u-l)+a&&(i=!i);}return i}function Pd(r){let e=r.parent;for(;e&&e.context.get("isSubmenu");)e=e.refs.get("parent");e?.send({type:"CLOSE"});}function ub(r,e){return r?_l(r,e):false}function db(r,e,t){let n=Object.keys(r).length>0;if(!e)return null;if(!n)return Mr(t,e);for(let i in r){let o=r[i],s=Qt(o.scope);if(s===e)return s}return Mr(t,e)}function zn(r,e){r&&(r.refs.set("pointerRoutingLocked",e),r.context.set("pointerRoutingMode",e?"locked":"interactive"));}function hb(r){let e=r.context.get("highlightedValue");if(!e)return false;let t=r.refs.get("children");for(let n in t){let i=t[n];if(i.state.hasTag("open")&&Qt(i.scope)===e)return true}return false}function pb(r,e){r&&(r.refs.get("pointerRoutingLocked")||e&&hb(r)||zn(r,false));}function mb(r){r&&(hb(r)||zn(r,false));}function Id(r,e){let{context:t,send:n,state:i,computed:o,prop:s,scope:a}=r,l=i.hasTag("open"),c=t.get("isSubmenu"),u=o("isTypingAhead"),d=s("composite"),h=t.get("currentPlacement"),p=h?_o(h):void 0,m=t.get("anchorPoint"),f=t.get("highlightedValue"),g=t.get("triggerValue"),b=vd({...s("positioning"),placement:h});function y(T){return {id:Mr(a,T.value),disabled:!!T.disabled,highlighted:f===T.value}}function v(T){let k=T.valueText??T.value;return {...T,id:T.value,valueText:k}}function S(T){return {...y(v(T)),checked:!!T.checked}}function E(T){let{closeOnSelect:k,valueText:x,value:M}=T,w=y(T),L=Mr(a,M);return e.element({...We.item.attrs,id:L,role:"menuitem","aria-disabled":Xu(w.disabled),"data-disabled":mt(w.disabled),"data-ownedby":Bn(a),"data-highlighted":mt(w.highlighted),"data-value":M,"data-valuetext":x,onDragStart(P){P.currentTarget.matches("a[href]")&&P.preventDefault();},onPointerMove(P){if(w.disabled||P.pointerType!=="mouse")return;let C=P.currentTarget;if(w.highlighted)return;let A=li(P);n({type:"ITEM_POINTERMOVE",id:L,target:C,closeOnSelect:k,point:A});},onPointerLeave(P){if(w.disabled||P.pointerType!=="mouse"||!r.event.previous()?.type.includes("POINTER"))return;let A=P.currentTarget;n({type:"ITEM_POINTERLEAVE",id:L,target:A,closeOnSelect:k});},onPointerDown(P){if(w.disabled)return;let C=P.currentTarget;n({type:"ITEM_POINTERDOWN",target:C,id:L,closeOnSelect:k});},onClick(P){if(rd(P)||nd(P)||w.disabled)return;let C=P.currentTarget;n({type:"ITEM_CLICK",target:C,id:L,closeOnSelect:k});}})}return {highlightedValue:f,open:l,setOpen(T){i.hasTag("open")!==T&&n({type:T?"OPEN":"CLOSE"});},triggerValue:g,setTriggerValue(T){n({type:"TRIGGER_VALUE.SET",value:T});},setHighlightedValue(T){n({type:"HIGHLIGHTED.SET",value:T});},setParent(T){n({type:"PARENT.SET",value:T,id:T.prop("id")});},setChild(T){n({type:"CHILD.SET",value:T,id:T.prop("id")});},reposition(T={}){n({type:"POSITIONING.SET",options:T});},addItemListener(T){let k=a.getById(T.id);if(!k)return;let x=()=>T.onSelect?.();return k.addEventListener(Vl,x),()=>k.removeEventListener(Vl,x)},getContextTriggerProps(T={}){let{value:k}=T,x=k==null?false:g===k,M=Fl(a,k);return e.element({...We.contextTrigger.attrs,dir:s("dir"),id:M,"data-ownedby":a.id,"data-value":k,"data-current":mt(x),"data-state":l?"open":"closed",onPointerDown(w){if(w.pointerType==="mouse")return;let L=li(w);n({type:"CONTEXT_MENU_START",point:L,value:k});},onPointerCancel(w){w.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerMove(w){w.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerUp(w){w.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onContextMenu(w){let L=li(w),P=l&&k!=null&&!x;n({type:P?"TRIGGER_VALUE.SET":"CONTEXT_MENU",point:L,value:k}),w.preventDefault();},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}})},getTriggerItemProps(T){let k=T.getTriggerProps();return ef(E({value:k.id}),k)},getTriggerProps(T={}){let{value:k}=T,x=k==null?false:g===k,M=Qt(a,k);return e.button({...c?We.triggerItem.attrs:We.trigger.attrs,"data-placement":h,"data-side":p,type:"button",dir:s("dir"),id:M,...k!=null&&{"data-ownedby":a.id,"data-value":k,"data-current":mt(x)},"data-uid":s("id"),"aria-haspopup":d?"menu":"dialog","aria-controls":Bn(a),"data-controls":Bn(a),"aria-expanded":k==null?l:l&&x,"data-state":l?"open":"closed",onPointerMove(w){if(w.pointerType!=="mouse"||zo(w.currentTarget)||!c)return;let P=li(w);n({type:"TRIGGER_POINTERMOVE",target:w.currentTarget,point:P});},onPointerLeave(w){if(zo(w.currentTarget)||w.pointerType!=="mouse"||!c)return;zn(r.refs.get("parent"),true);let L=li(w);n({type:"TRIGGER_POINTERLEAVE",target:w.currentTarget,point:L});},onPointerDown(w){zo(w.currentTarget)||hl(w)||w.preventDefault();},onClick(w){if(w.defaultPrevented||zo(w.currentTarget))return;let L=l&&k!=null&&!x;n({type:L?"TRIGGER_VALUE.SET":"TRIGGER_CLICK",target:w.currentTarget,value:k});},onBlur(){n({type:"TRIGGER_BLUR"});},onFocus(){n({type:"TRIGGER_FOCUS"});},onKeyDown(w){if(w.defaultPrevented)return;let L={ArrowDown(){n({type:"ARROW_DOWN",value:k});},ArrowUp(){n({type:"ARROW_UP",value:k});},Enter(){n({type:"ARROW_DOWN",src:"enter",value:k});},Space(){n({type:"ARROW_DOWN",src:"space",value:k});}},P=id(w,{orientation:"vertical",dir:s("dir")}),C=L[P];C&&(w.preventDefault(),C(w));}})},getIndicatorProps(){return e.element({...We.indicator.attrs,dir:s("dir"),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...We.positioner.attrs,dir:s("dir"),id:yd(a),style:b.floating})},getArrowProps(){return e.element({id:Zg(a),...We.arrow.attrs,dir:s("dir"),style:b.arrow})},getArrowTipProps(){return e.element({...We.arrowTip.attrs,dir:s("dir"),style:b.arrowTip})},getContentProps(){return e.element({...We.content.attrs,id:Bn(a),"aria-label":s("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:d?"menu":"dialog",tabIndex:0,dir:s("dir"),"aria-activedescendant":o("highlightedId")||void 0,"aria-labelledby":m?Fl(a,g??void 0):Qt(a,g??void 0),"data-placement":h,"data-side":p,onPointerEnter(T){T.pointerType==="mouse"&&n({type:"MENU_POINTERENTER"});},onKeyDown(T){if(T.defaultPrevented||!rt(T.currentTarget,De(T)))return;let k=De(T);if(!(k?.closest("[role=menu]")===T.currentTarget||k===T.currentTarget))return;if(T.key==="Tab"&&!Nf(T)){T.preventDefault();return}let M={ArrowDown(){n({type:"ARROW_DOWN"});},ArrowUp(){n({type:"ARROW_UP"});},ArrowLeft(){n({type:"ARROW_LEFT"});},ArrowRight(){n({type:"ARROW_RIGHT"});},Enter(){n({type:"ENTER"});},Space(P){u?n({type:"TYPEAHEAD",key:P.key}):M.Enter?.(P);},Home(){n({type:"HOME"});},End(){n({type:"END"});}},w=id(T,{dir:s("dir")}),L=M[w];if(L){L(T),T.stopPropagation(),T.preventDefault();return}s("typeahead")&&Lf(T)&&(If(T)||oi(k)||(n({type:"TYPEAHEAD",key:T.key}),T.preventDefault()));}})},getSeparatorProps(){return e.element({...We.separator.attrs,role:"separator",dir:s("dir"),"aria-orientation":"horizontal"})},getItemState:y,getItemProps:E,getOptionItemState:S,getOptionItemProps(T){let{type:k,disabled:x,closeOnSelect:M}=T,w=v(T),L=S(T);return {...E(w),...e.element({"data-type":k,...We.item.attrs,dir:s("dir"),"data-value":w.value,role:`menuitem${k}`,"aria-checked":!!L.checked,"data-state":L.checked?"checked":"unchecked",onClick(P){if(x||rd(P)||nd(P))return;let C=P.currentTarget;n({type:"ITEM_CLICK",target:C,option:w,closeOnSelect:M});}})}},getItemIndicatorProps(T){let k=S(zu(T)),x=k.checked?"checked":"unchecked";return e.element({...We.itemIndicator.attrs,dir:s("dir"),"data-disabled":mt(k.disabled),"data-highlighted":mt(k.highlighted),"data-state":yo(T,"checked")?x:void 0,hidden:yo(T,"checked")?!k.checked:void 0})},getItemTextProps(T){let k=S(zu(T)),x=k.checked?"checked":"unchecked";return e.element({...We.itemText.attrs,dir:s("dir"),"data-disabled":mt(k.disabled),"data-highlighted":mt(k.highlighted),"data-state":yo(T,"checked")?x:void 0})},getItemGroupLabelProps(T){return e.element({...We.itemGroupLabel.attrs,id:wd(a,T.htmlFor),dir:s("dir")})},getItemGroupProps(T){return e.element({id:Jg(a,T.id),...We.itemGroup.attrs,dir:s("dir"),"aria-labelledby":wd(a,T.id),role:"group"})}}}function fb(r){let e={each(t){for(let n=0;n<r.frames?.length;n+=1){let i=r.frames[n];i&&t(i);}},addEventListener(t,n,i){return e.each(o=>{try{o.document.addEventListener(t,n,i);}catch{}}),()=>{try{e.removeEventListener(t,n,i);}catch{}}},removeEventListener(t,n,i){e.each(o=>{try{o.document.removeEventListener(t,n,i);}catch{}});}};return e}function gb(r){let e=r.frameElement!=null?r.parent:null;return {addEventListener:(t,n,i)=>{try{e?.addEventListener(t,n,i);}catch{}return ()=>{try{e?.removeEventListener(t,n,i);}catch{}}},removeEventListener:(t,n,i)=>{try{e?.removeEventListener(t,n,i);}catch{}}}}var bb="pointerdown.outside",vb="focus.outside";function kk(r){for(let e of r)if(ce(e)&&ft(e))return true;return false}var xb=r=>"clientY"in r;function Ek(r,e){if(!xb(e)||!r)return false;let t=r.getBoundingClientRect();return t.width===0||t.height===0?false:t.top<=e.clientY&&e.clientY<=t.top+t.height&&t.left<=e.clientX&&e.clientX<=t.left+t.width}function Mk(r,e){return r.y<=e.y&&e.y<=r.y+r.height&&r.x<=e.x&&e.x<=r.x+r.width}function yb(r,e){if(!e||!xb(r))return false;let t=e.scrollHeight>e.clientHeight,n=t&&r.clientX>e.offsetLeft+e.clientWidth,i=e.scrollWidth>e.clientWidth,o=i&&r.clientY>e.offsetTop+e.clientHeight,s={x:e.offsetLeft,y:e.offsetTop,width:e.clientWidth+(t?16:0),height:e.clientHeight+(i?16:0)},a={x:r.clientX,y:r.clientY};return Mk(s,a)?n||o:false}function Lk(r,e){let{exclude:t,onFocusOutside:n,onPointerDownOutside:i,onInteractOutside:o,defer:s,followControlledElements:a=true}=e;if(!r)return;let l=Me(r),c=Ce(r),u=fb(c),d=gb(c);function h(S,E){if(!ce(E)||!E.isConnected||rt(r,E)||Ek(r,S)||a&&dl(r,E))return false;let T=l.querySelector(`[aria-controls="${r.id}"]`);if(T){let x=fl(T);if(yb(S,x))return false}let k=fl(r);return yb(S,k)?false:!t?.(E)}let p=new Set,m=yr(r?.getRootNode()),f=false;function g(S){f=true;let E=()=>{f=false;};l.addEventListener("pointerup",E,{once:true}),c.addEventListener("pointerup",E,{once:true});function T(k){let x=s&&!td()?Ie:L=>L(),M=k??S,w=M?.composedPath?.()??[M?.target];x(()=>{let L=m?w[0]:De(S);if(!(!r||!h(S,L))){if(i||o){let P=On(i,o);r.addEventListener(bb,P,{once:true});}wb(r,bb,{bubbles:false,cancelable:true,detail:{originalEvent:M,contextmenu:hl(M),focusable:kk(w),target:L}});}});}S.pointerType==="touch"?(p.forEach(k=>k()),p.add(je(l,"click",T,{once:true})),p.add(d.addEventListener("click",T,{once:true})),p.add(u.addEventListener("click",T,{once:true}))):T();}let b=new Set,y=setTimeout(()=>{b.add(je(l,"pointerdown",g,true)),b.add(d.addEventListener("pointerdown",g,true)),b.add(u.addEventListener("pointerdown",g,true));},0);function v(S){if(f)return;(s?Ie:T=>T())(()=>{let T=S?.composedPath?.()??[S?.target],k=m?T[0]:De(S);if(!(!r||!h(S,k))){if(n||o){let x=On(n,o);r.addEventListener(vb,x,{once:true});}wb(r,vb,{bubbles:false,cancelable:true,detail:{originalEvent:S,contextmenu:false,focusable:ft(k),target:k}});}});}return td()||(b.add(je(l,"focusin",v,true)),b.add(d.addEventListener("focusin",v,true)),b.add(u.addEventListener("focusin",v,true))),()=>{clearTimeout(y),p.forEach(S=>S()),b.forEach(S=>S());}}function Sb(r,e){let{defer:t}=e,n=t?Ie:o=>o(),i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(Lk(o,e));})),()=>{i.forEach(o=>o?.());}}function wb(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,t);return r.dispatchEvent(i)}function Cb(r,e){let t=n=>{n.key==="Escape"&&(n.isComposing||e?.(n));};return je(Me(r),"keydown",t,{capture:true})}var Tb="layer:request-dismiss",Ge={layers:[],branches:[],recentlyRemoved:new Set,count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(r=>r.pointerBlocking)},topMostPointerBlockingLayer(){return [...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(r){let e=this.indexOf(r),t=this.topMostPointerBlockingLayer()?this.indexOf(this.topMostPointerBlockingLayer()?.node):-1;return e<t},isTopMost(r){return this.layers[this.count()-1]?.node===r},getNestedLayers(r){return Array.from(this.layers).slice(this.indexOf(r)+1)},getLayersByType(r){return this.layers.filter(e=>e.type===r)},getNestedLayersByType(r,e){let t=this.indexOf(r);return t===-1?[]:this.layers.slice(t+1).filter(n=>n.type===e)},getParentLayerOfType(r,e){let t=this.indexOf(r);if(!(t<=0))return this.layers.slice(0,t).reverse().find(n=>n.type===e)},countNestedLayersOfType(r,e){return this.getNestedLayersByType(r,e).length},isInNestedLayer(r,e){return !!(this.getNestedLayers(r).some(n=>rt(n.node,e))||this.recentlyRemoved.size>0)},isInBranch(r){return Array.from(this.branches).some(e=>rt(e,r))},add(r){let e=this.indexOf(r.node);e!==-1&&this.layers.splice(e,1),this.layers.push(r),this.syncLayers();},addBranch(r){this.branches.push(r);},remove(r){let e=this.indexOf(r);if(e<0)return;this.layers[e].styleTargets?.forEach(n=>{let i=n();i&&Pk(i);}),this.recentlyRemoved.add(r),Vf(()=>this.recentlyRemoved.delete(r)),e<this.count()-1&&this.getNestedLayers(r).forEach(i=>Ge.dismiss(i.node,r)),this.layers.splice(e,1),this.syncLayers();},removeBranch(r){let e=this.branches.indexOf(r);e>=0&&this.branches.splice(e,1);},syncLayers(){this.layers.forEach((r,e)=>{kb(r,e,r.node),r.styleTargets?.forEach(t=>{let n=t();if(!n||n===r.node)return;kb(r,e,n);let{zIndex:i}=si(r.node);n.style.setProperty("--z-index",i);});});},indexOf(r){return this.layers.findIndex(e=>e.node===r)},dismiss(r,e){let t=this.indexOf(r);if(t===-1)return;let n=this.layers[t];Ak(r,Tb,i=>{n.requestDismiss?.(i),i.defaultPrevented||n?.dismiss();}),Ik(r,Tb,{originalLayer:r,targetLayer:e,originalIndex:t,targetIndex:e?this.indexOf(e):-1}),this.syncLayers();},clear(){this.remove(this.layers[0].node);}};function kb(r,e,t){t.style.setProperty("--layer-index",`${e}`),t.removeAttribute("data-nested"),t.removeAttribute("data-has-nested"),Ge.getParentLayerOfType(r.node,r.type)&&t.setAttribute("data-nested",r.type);let i=Ge.countNestedLayersOfType(r.node,r.type);i>0&&t.setAttribute("data-has-nested",r.type),t.style.setProperty("--nested-layer-count",`${i}`);}function Pk(r){r.style.removeProperty("--layer-index"),r.style.removeProperty("--nested-layer-count"),r.style.removeProperty("--z-index"),r.removeAttribute("data-nested"),r.removeAttribute("data-has-nested");}function Ik(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,{cancelable:true,bubbles:true,detail:t});return r.dispatchEvent(i)}function Ak(r,e,t){r.addEventListener(e,t,{once:true});}var Ad=new WeakMap,Wo=new WeakMap;function Rk(r){return Ge.isBelowPointerBlockingLayer(r)?"none":"auto"}function Eb(r){let e=Rk(r);r.style.pointerEvents!==e&&(r.style.pointerEvents=e);}function Dk(r){if(Wo.has(r))return;let e=Ce(r);if(typeof e.MutationObserver>"u")return;let t=new e.MutationObserver(()=>{Wo.has(r)&&Eb(r);});t.observe(r,{attributes:true,attributeFilter:["style"]}),Wo.set(r,t);}function Rd(){Ge.layers.forEach(({node:r})=>{Eb(r),Dk(r);});}function Mb(r){let e=Wo.get(r);e&&(e.disconnect(),Wo.delete(r)),r.style.pointerEvents="";}function Lb(r,e){let t=Me(r),n=[];return Ge.hasPointerBlockingLayer()&&!t.body.hasAttribute("data-inert")&&(Ad.set(t.body,t.body.style.pointerEvents),queueMicrotask(()=>{let i=t.body;i&&(i.style.pointerEvents="none",i.setAttribute("data-inert",""));})),e?.forEach(i=>{let[o,s]=Uf(()=>{let a=i();return ce(a)?a:null},{timeout:1e3});o.then(a=>n.push(Lo(a,{pointerEvents:"auto"}))),n.push(s);}),()=>{Ge.hasPointerBlockingLayer()||(queueMicrotask(()=>{let i=t.body;if(!i)return;let o=Ad.get(i);o!==void 0&&(i.style.pointerEvents=o,Ad.delete(i)),i.removeAttribute("data-inert"),i.style.length===0&&i.removeAttribute("style");}),n.forEach(i=>i()));}}function Ok(r,e){let{warnOnMissingNode:t=true}=e;if(t&&!r){ni("[@zag-js/dismissable] node is `null` or `undefined`");return}if(!r)return;let{onDismiss:n,onRequestDismiss:i,pointerBlocking:o,exclude:s,debug:a,type:l="dialog",layerStyleTargets:c}=e,u={dismiss:n,node:r,type:l,pointerBlocking:o,requestDismiss:i,styleTargets:c};Ge.add(u),Rd();function d(g){let b=De(g.detail.originalEvent);Ge.isBelowPointerBlockingLayer(r)||Ge.isInBranch(b)||(e.onPointerDownOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onPointerDownOutside:",g.detail.originalEvent),n?.()));}function h(g){let b=De(g.detail.originalEvent);Ge.isInBranch(b)||(e.onFocusOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onFocusOutside:",g.detail.originalEvent),n?.()));}function p(g){Ge.isTopMost(r)&&(e.onEscapeKeyDown?.(g),!g.defaultPrevented&&n&&(g.preventDefault(),n()));}function m(g){if(!r)return false;let b=typeof s=="function"?s():s,y=Array.isArray(b)?b:[b],v=e.persistentElements?.map(S=>S()).filter(ce);return v&&y.push(...v),y.some(S=>rt(S,g))||Ge.isInNestedLayer(r,g)}let f=[o?Lb(r,e.persistentElements):void 0,Cb(r,p),Sb(r,{exclude:m,onFocusOutside:h,onPointerDownOutside:d,defer:e.defer})];return ()=>{Ge.remove(r),Rd(),Mb(r),f.forEach(g=>g?.());}}function Bl(r,e){let{defer:t}=e,n=t?Ie:o=>o(),i=[];return i.push(n(()=>{let o=nt(r)?r():r;i.push(Ok(o,e));})),()=>{i.forEach(o=>o?.());}}function Nk(r){return !(r.metaKey||!ai()&&r.altKey||r.ctrlKey||r.key==="Control"||r.key==="Shift"||r.key==="Meta")}var Fk=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function Vk(r,e,t){let n=t?De(t):null,i=Me(n),o=Ce(n),s=Kt(i);return r=r||s instanceof o.HTMLInputElement&&!Fk.has(s?.type)||s instanceof o.HTMLTextAreaElement||s instanceof o.HTMLElement&&s.isContentEditable,!(r&&e==="keyboard"&&t instanceof o.KeyboardEvent&&!Reflect.has(_k,t.key))}var gn=null,Dd=new Set,Hl=new Map,Lr=false,Od=false,Ib=false,_k={Tab:true,Escape:true};function $l(r,e){for(let t of Dd)t(r,e);}function zl(r){Lr=true,Nk(r)&&(gn="keyboard",$l("keyboard",r));}function gt(r){gn="pointer",(r.type==="mousedown"||r.type==="pointerdown")&&(Lr=true,$l("pointer",r));}function Ab(r){Pf(r)&&(Lr=true,gn="virtual");}function Rb(r){let e=De(r);e===Ce(e)||e===Me(e)||Ib||!r.isTrusted||(!Lr&&!Od&&(gn="virtual",$l("virtual",r)),Lr=false,Od=false);}function Db(){(Lr=false,Od=true);}function Bk(r){if(typeof window>"u"||Hl.get(Ce(r)))return;let e=Ce(r),t=Me(r),n=e.HTMLElement.prototype.focus;function i(){Lr=true,n.apply(this,arguments);}try{Object.defineProperty(e.HTMLElement.prototype,"focus",{configurable:!0,value:i});}catch{}t.addEventListener("keydown",zl,true),t.addEventListener("keyup",zl,true),t.addEventListener("click",Ab,true),e.addEventListener("focus",Rb,true),e.addEventListener("blur",Db,false),typeof e.PointerEvent<"u"?(t.addEventListener("pointerdown",gt,true),t.addEventListener("pointermove",gt,true),t.addEventListener("pointerup",gt,true)):(t.addEventListener("mousedown",gt,true),t.addEventListener("mousemove",gt,true),t.addEventListener("mouseup",gt,true)),e.addEventListener("beforeunload",()=>{Hk(r);},{once:true}),Hl.set(e,{focus:n});}var Hk=(r,e)=>{let t=Ce(r),n=Me(r);let i=Hl.get(t);if(i){try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus});}catch{}n.removeEventListener("keydown",zl,true),n.removeEventListener("keyup",zl,true),n.removeEventListener("click",Ab,true),t.removeEventListener("focus",Rb,true),t.removeEventListener("blur",Db,false),typeof t.PointerEvent<"u"?(n.removeEventListener("pointerdown",gt,true),n.removeEventListener("pointermove",gt,true),n.removeEventListener("pointerup",gt,true)):(n.removeEventListener("mousedown",gt,true),n.removeEventListener("mousemove",gt,true),n.removeEventListener("mouseup",gt,true)),Hl.delete(t);}};function Ob(){return gn}function Nb(r){gn=r,$l(r,null);}function Pb(){return gn==="keyboard"||gn==="virtual"}function Fb(r={}){let{isTextInput:e,autoFocus:t,onChange:n,root:i}=r;Bk(i),n?.({isFocusVisible:t||Pb(),modality:gn});let o=(s,a)=>{Vk(!!e,s,a)&&n?.({isFocusVisible:Pb(),modality:s});};return Dd.add(o),()=>{Dd.delete(o);}}var{not:bt,and:yi,or:zk}=df(),Nd=ll({props({props:r}){return {closeOnSelect:true,typeahead:true,composite:true,loopFocus:false,navigate(e){Hf(e.node);},...r,positioning:{placement:"bottom-start",gutter:8,...r.positioning}}},initialState({prop:r}){return r("open")||r("defaultOpen")?"open":"idle"},context({bindable:r,prop:e,scope:t}){return {highlightedValue:r(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(n){e("onHighlightChange")?.({highlightedValue:n});}})),lastHighlightedValue:r(()=>({defaultValue:null})),currentPlacement:r(()=>({defaultValue:void 0})),intentPolygon:r(()=>({defaultValue:null})),anchorPoint:r(()=>({defaultValue:null,hash(n){return `x: ${n?.x}, y: ${n?.y}`}})),isSubmenu:r(()=>({defaultValue:false})),triggerValue:r(()=>({defaultValue:e("defaultTriggerValue")??null,value:e("triggerValue"),onChange(n){let i=e("onTriggerValueChange");if(!i)return;let o=Bo(t,n);i({value:n,triggerElement:o});}})),pointerRoutingMode:r(()=>({defaultValue:"interactive"}))}},refs(){return {parent:null,children:{},pointerRoutingLocked:false,typeaheadState:{...bl.defaultOptions},positioningOverride:{}}},computed:{isRtl:({prop:r})=>r("dir")==="rtl",isTypingAhead:({refs:r})=>r.get("typeaheadState").keysSoFar!=="",highlightedId:({context:r,scope:e,refs:t})=>db(t.get("children"),r.get("highlightedValue"),e)},watch({track:r,action:e,context:t,prop:n}){r([()=>t.get("isSubmenu")],()=>{e(["setSubmenuPlacement"]);}),r([()=>t.hash("anchorPoint")],()=>{t.get("anchorPoint")&&e(["reposition"]);}),r([()=>n("open")],()=>{e(["toggleVisibility"]);});},on:{"TRIGGER_VALUE.SET":{actions:["setTriggerValue","setAnchorPoint","reposition","focusMenu"]},"PARENT.SET":{actions:["setParentMenu"]},"CHILD.SET":{actions:["setChildMenu"]},OPEN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen"]}],OPEN_AUTOFOCUS:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"HIGHLIGHTED.RESTORE":{actions:["restoreHighlightedItem"]},"HIGHLIGHTED.SET":{actions:["setHighlightedItem"]},"HIGHLIGHTED.SUGGEST":{actions:["suggestHighlightedItem"]}},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_FOCUS:{guard:bt("isSubmenu"),target:"closed"},TRIGGER_POINTERMOVE:{guard:"isSubmenu",target:"opening"}}},"opening:contextmenu":{tags:["closed"],effects:["waitForLongPress"],on:{"CONTROLLED.OPEN":{target:"open",actions:["reposition"]},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},CONTEXT_MENU_CANCEL:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"LONG_PRESS.OPEN":[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen","reposition"]}]}},opening:{tags:["closed"],effects:["waitForOpenDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},BLUR:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],TRIGGER_POINTERLEAVE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"DELAY.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},closing:{tags:["open"],effects:["trackPointerMove","trackInteractOutside","waitForCloseDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]},MENU_POINTERENTER:{target:"open",actions:["clearIntentPolygon"]},POINTER_MOVED_AWAY_FROM_SUBMENU:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]}],"DELAY.CLOSE":[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem","invokeOnClose","releaseParentRoutingLock"]}]}},closed:{tags:["closed"],entry:["clearHighlightedItem","unlockParentOnClose","clearAnchorPoint"],on:{"CONTROLLED.OPEN":[{guard:zk("isOpenAutoFocusEvent","isArrowDownEvent"),target:"open",actions:["highlightFirstItem"]},{guard:"isArrowUpEvent",target:"open",actions:["highlightLastItem"]},{target:"open"}],CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",target:"opening"},TRIGGER_BLUR:{target:"idle"},ARROW_DOWN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],ARROW_UP:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightLastItem","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackInteractOutside","trackFocusVisible","trackPositioning","scrollToHighlightedItem"],entry:["focusMenu","unlockParentOnOpen"],on:{"CONTROLLED.CLOSE":[{target:"closed",guard:"isArrowLeftEvent",actions:["focusParentMenu"]},{target:"closed",actions:["focusTrigger"]}],TRIGGER_CLICK:[{guard:yi(bt("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:bt("isTriggerItem"),target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],CONTEXT_MENU:{actions:["setAnchorPoint","setTriggerValue","focusMenu"]},ARROW_UP:{actions:["highlightPrevItem","focusMenu"]},ARROW_DOWN:{actions:["highlightNextItem","focusMenu"]},ARROW_LEFT:[{guard:yi("isSubmenu","isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:"isSubmenu",target:"closed",actions:["focusParentMenu","invokeOnClose","releaseParentRoutingLock"]}],HOME:{actions:["highlightFirstItem","focusMenu"]},END:{actions:["highlightLastItem","focusMenu"]},ARROW_RIGHT:{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},ENTER:[{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},{actions:["clickHighlightedItem"]}],ITEM_POINTERMOVE:[{guard:bt("isPointerRoutingLocked"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:yi(bt("isPointerRoutingLocked"),bt("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:yi(bt("isTriggerItemHighlighted"),bt("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock"]},{guard:yi(bt("isTriggerItemHighlighted"),bt("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock","focusTrigger"]},{guard:yi(bt("isTriggerItemHighlighted"),bt("isHighlightedItemEditable")),actions:["invokeOnSelect","setOptionState"]},{actions:["setHighlightedItem"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",actions:["setIntentPolygon"]},TRIGGER_POINTERLEAVE:{target:"closing",actions:["setIntentPolygon"]},ITEM_POINTERDOWN:{actions:["setHighlightedItem"]},TYPEAHEAD:{actions:["highlightMatchedItem"]},FOCUS_MENU:{actions:["focusMenu"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{closeOnSelect:({prop:r,event:e})=>!!(e?.closeOnSelect??r("closeOnSelect")),isTriggerItem:({event:r})=>Ed(r.target),isTriggerItemHighlighted:({event:r,scope:e,computed:t})=>!!(r.target??e.getById(t("highlightedId")))?.hasAttribute("data-controls"),isSubmenu:({context:r})=>r.get("isSubmenu"),isPointerRoutingLocked:({refs:r})=>r.get("pointerRoutingLocked"),isHighlightedItemEditable:({scope:r,computed:e})=>oi(r.getById(e("highlightedId"))),isOpenControlled:({prop:r})=>r("open")!==void 0,isArrowLeftEvent:({event:r})=>r.previousEvent?.type==="ARROW_LEFT",isArrowUpEvent:({event:r})=>r.previousEvent?.type==="ARROW_UP",isArrowDownEvent:({event:r})=>r.previousEvent?.type==="ARROW_DOWN",isOpenAutoFocusEvent:({event:r})=>r.previousEvent?.type==="OPEN_AUTOFOCUS"},effects:{waitForOpenDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.OPEN"});},200);return ()=>clearTimeout(e)},waitForCloseDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.CLOSE"});},100);return ()=>clearTimeout(e)},waitForLongPress({send:r}){let e=setTimeout(()=>{r({type:"LONG_PRESS.OPEN"});},700);return ()=>clearTimeout(e)},trackFocusVisible({scope:r}){return Fb({root:r.getRootNode?.()})},trackPositioning({context:r,prop:e,scope:t,refs:n}){if(eb(t)||Td(t).length>0)return;let o={...e("positioning"),...n.get("positioningOverride")};return r.set("currentPlacement",o.placement),Nl(()=>Bo(t,r.get("triggerValue")),()=>xd(t),{...o,defer:true,onComplete(l){r.set("currentPlacement",l.placement);}})},trackInteractOutside({refs:r,scope:e,prop:t,context:n,send:i}){let o=()=>Rt(e),s=true,a=l=>Td(e).some(c=>rt(c,l));return Bl(o,{type:"menu",defer:true,exclude:[Sd(e),...Cd(e)].filter(Boolean),onInteractOutside:t("onInteractOutside"),onRequestDismiss:t("onRequestDismiss"),onFocusOutside(l){t("onFocusOutside")?.(l);let c=De(l.detail.originalEvent);if(a(c)){l.preventDefault();return}if(Md(c,r.get("children"))){l.preventDefault();return}},onEscapeKeyDown(l){t("onEscapeKeyDown")?.(l),n.get("isSubmenu")&&l.preventDefault(),Pd({parent:r.get("parent")});},onPointerDownOutside(l){t("onPointerDownOutside")?.(l);let c=De(l.detail.originalEvent);if(a(c)&&l.detail.contextmenu){l.preventDefault();return}s=!l.detail.focusable;},onDismiss(){i({type:"CLOSE",src:"interact-outside",restoreFocus:s});}})},trackPointerMove({context:r,scope:e,send:t,refs:n}){let i=n.get("parent");if(!i)return;zn(i,true);let o=e.getDoc();return je(o,"pointermove",s=>{ub(r.get("intentPolygon"),{x:s.clientX,y:s.clientY})||(t({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),zn(i,false));})},scrollToHighlightedItem({scope:r,computed:e}){let t=()=>{if(Ob()==="pointer")return;let o=r.getById(e("highlightedId")),s=Rt(r);$f(o,{rootEl:s,block:"nearest"});};return Ie(()=>{Nb("virtual"),t();}),Bf(()=>Rt(r),{attributes:["aria-activedescendant"],callback:t})}},actions:{setAnchorPoint({context:r,event:e}){r.set("anchorPoint",t=>ei(t,e.point)?t:e.point);},setSubmenuPlacement({context:r,computed:e,refs:t}){if(!r.get("isSubmenu"))return;let n=e("isRtl")?"left-start":"right-start";t.set("positioningOverride",{placement:n,gutter:0});},reposition({context:r,scope:e,prop:t,event:n,refs:i}){let o=()=>xd(e),s=n.point??r.get("anchorPoint"),a=s?()=>({width:0,height:0,...s}):void 0,l={...t("positioning"),...i.get("positioningOverride")},c=n.value??r.get("triggerValue");Nl(()=>Bo(e,c),o,{...l,defer:true,getAnchorRect:a,...n.options??{},listeners:false,onComplete(d){r.set("currentPlacement",d.placement);}});},setOptionState({event:r}){if(!r.option)return;let{checked:e,onCheckedChange:t,type:n}=r.option;n==="radio"?t?.(true):n==="checkbox"&&t?.(!e);},clickHighlightedItem({scope:r,computed:e,prop:t,context:n}){let i=r.getById(e("highlightedId"));if(!i||i.dataset.disabled)return;let o=n.get("highlightedValue");gf(i)?t("navigate")?.({value:o,node:i,href:i.href}):queueMicrotask(()=>i.click());},setIntentPolygon({context:r,scope:e,event:t}){let n=Rt(e),i=r.get("currentPlacement");if(!n||!i)return;let o=n.getBoundingClientRect(),s=cb(o,i);if(!s)return;let l=_o(i)==="right"?-5:5;r.set("intentPolygon",[{...t.point,x:t.point.x+l},...s]);},clearIntentPolygon({context:r}){r.set("intentPolygon",null);},clearAnchorPoint({context:r}){r.set("anchorPoint",null);},unlockParentOnOpen({refs:r,context:e,scope:t}){let n=r.get("parent");if(e.get("isSubmenu")){let i=Qt(t);n?.send({type:"HIGHLIGHTED.SUGGEST",value:i});}zn(n,false);},unlockParentOnClose({refs:r,context:e}){pb(r.get("parent"),e.get("isSubmenu"));},setHighlightedItem({context:r,event:e}){let t=e.value||Hn(e.target);r.set("highlightedValue",t);},clearHighlightedItem({context:r}){r.set("highlightedValue",null);},focusMenu({scope:r}){Ie(()=>{let e=Rt(r);ml({root:e,enabled:!rt(e,r.getActiveElement()),filter(n){return !n.role?.startsWith("menuitem")}})?.focus({preventScroll:true});});},highlightFirstItem({context:r,scope:e}){(Rt(e)?queueMicrotask:Ie)(()=>{let n=tb(e);n&&r.set("highlightedValue",Hn(n));});},highlightLastItem({context:r,scope:e}){(Rt(e)?queueMicrotask:Ie)(()=>{let n=nb(e);n&&r.set("highlightedValue",Hn(n));});},highlightNextItem({context:r,scope:e,event:t,prop:n}){let i=rb(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",Hn(i));},highlightPrevItem({context:r,scope:e,event:t,prop:n}){let i=ib(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",Hn(i));},invokeOnSelect({context:r,prop:e,scope:t}){let n=r.get("highlightedValue");if(n==null)return;let i=Qg(t,n);sb(i,n),e("onSelect")?.({value:n});},focusTrigger({scope:r,context:e,event:t}){e.get("isSubmenu")||e.get("anchorPoint")||t.restoreFocus===false||queueMicrotask(()=>{Bo(r,e.get("triggerValue"))?.focus({preventScroll:true});});},highlightMatchedItem({scope:r,context:e,event:t,refs:n}){let i=ob(r,{key:t.key,value:e.get("highlightedValue"),typeaheadState:n.get("typeaheadState")});i&&e.set("highlightedValue",Hn(i));},setParentMenu({refs:r,event:e,context:t}){r.set("parent",e.value),t.set("isSubmenu",true);},setChildMenu({refs:r,event:e}){let t=r.get("children");t[e.id]=e.value,r.set("children",t);},closeSiblingMenus({refs:r,event:e,scope:t}){let n=e.target;if(!Ed(n))return;let i=n?.getAttribute("data-uid"),o=r.get("children");for(let s in o){if(s===i)continue;let a=o[s],l=a.context.get("intentPolygon");l&&e.point&&_l(l,e.point)||(Rt(t)?.focus({preventScroll:true}),a.send({type:"CLOSE"}));}},closeRootMenu({refs:r}){Pd({parent:r.get("parent")});},openSubmenu({refs:r,scope:e,computed:t}){let i=e.getById(t("highlightedId"))?.getAttribute("data-uid"),o=r.get("children");(i?o[i]:null)?.send({type:"OPEN_AUTOFOCUS"});},focusParentMenu({refs:r}){r.get("parent")?.send({type:"FOCUS_MENU"});},setLastHighlightedItem({context:r,event:e}){r.set("lastHighlightedValue",Hn(e.target));},suggestHighlightedItem({context:r,event:e}){let t=e.value;if(t){if(r.get("highlightedValue")!=null){r.set("lastHighlightedValue",t);return}r.set("highlightedValue",t);}},restoreHighlightedItem({context:r}){let e=r.get("lastHighlightedValue");r.set("lastHighlightedValue",null),e&&r.set("highlightedValue",e);},restoreParentHighlightedItem({refs:r}){r.get("parent")?.send({type:"HIGHLIGHTED.RESTORE"});},invokeOnOpen({prop:r}){r("onOpenChange")?.({open:true});},invokeOnClose({prop:r}){r("onOpenChange")?.({open:false});},releaseParentRoutingLock({refs:r,context:e}){e.get("isSubmenu")&&mb(r.get("parent"));},toggleVisibility({prop:r,event:e,send:t}){t({type:r("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e});},setTriggerValue({context:r,event:e}){e.value!==void 0&&r.set("triggerValue",e.value);}}}});function Vb(r){return {machine:Nd,props:{id:r.id??Tl("vela-menu"),ids:r.triggerId?{trigger:r.triggerId}:void 0,positioning:{placement:r.placement??"bottom-start",...r.getAnchorRect?{getAnchorRect:()=>r.getAnchorRect()}:{}},onSelect:e=>r.onSelect?.(e.value),onOpenChange:e=>r.onOpenChange?.(e.open)},connect:e=>Id(e,hi)}}var _b="vela-ui-menu",Bb=`
|
|
1
|
+
var Vela=(function(exports){'use strict';function _t(r,e,t=1e3){return r===true?e:typeof r!="number"||!Number.isFinite(r)||r<=0?0:Math.min(r,t)}function Cu(r){return _t(r,90,1e3)}function Tu(r){let e={style:false,duration:0};if(r===true)return {style:"settle",duration:650};if(r==="settle"||r==="grow")return {style:r,duration:650};if(r&&typeof r=="object"){let t=r,n=t.duration;return {style:t.style==="grow"?"grow":"settle",duration:typeof n=="number"&&Number.isFinite(n)&&n>0?Math.min(n,5e3):650}}return e}function Wp(r){if(r===false)return {animZoom:0,animPan:0,animScroll:0,animAutoscale:0,animLiveBar:0,animIntro:{style:false,duration:0}};let e=r===true||r==null?{}:r,t=_t(e.pan??true,110);return {animZoom:_t(e.zoom??true,70),animPan:t,animScroll:e.scroll===void 0?t>0?130:0:_t(e.scroll,130),animAutoscale:_t(e.autoscale??true,80),animLiveBar:Cu(e.liveBar),animIntro:Tu(e.intro??true)}}function Fe(r){return r.kind!=="candle"&&r.kind!=="bar"&&r.kind!=="markers"}function Ct(r,e){return r.display?r.display[e]!==false:r.visible!==false}function Ns(r){return Ct(r,"pane")||Ct(r,"priceScale")}var er=class{constructor(){this.handlers=new Map;}on(e,t){let n=this.handlers.get(e);n||(n=new Set,this.handlers.set(e,n));let i=n;return i.add(t),()=>{i.delete(t);}}off(e,t){this.handlers.get(e)?.delete(t);}hasListeners(e){return (this.handlers.get(e)?.size??0)>0}emit(e,t){let n=this.handlers.get(e);if(n)for(let i of n)try{i(t);}catch(o){console.error(`[vela] event handler error for "${String(e)}"`,o);}}clear(){this.handlers.clear();}};var Fs=class{constructor(){this.records=new Map;this.counter=0;}nextId(e="ind"){return this.counter+=1,`${e}-${this.counter}`}add(e){this.records.set(e.id,e);}get(e){return this.records.get(e)}remove(e){let t=this.records.get(e);return this.records.delete(e),t}all(){return [...this.records.values()]}};function Gp(r,e){return `${r}#${e}`}var Gi=new Map;function Pn(r){Gi.set(r.type,r);}function Up(r){Gi.delete(r);}function Ui(r){return Gi.get(r)}function Yp(){return [...Gi.keys()]}function Vs(){return [...Gi.values()]}var _s=class{constructor(e,t,n){this.feed=e;this.market=t;this.onBar=n;this.unsubscribe=null;}start(){this.unsubscribe||(this.unsubscribe=this.feed.subscribe(this.market,this.onBar));}stop(){this.unsubscribe?.(),this.unsubscribe=null;}};var zr=class{constructor(e,t,n,i,o){this.controller=n;this.schema=[];this.propsSchema=[];this.visibleState=true;this.bus=new er;this.id=e,this.title=t,i!==void 0&&(this.source=i),o!==void 0&&(this.nativeType=o);}get inputs(){return this.schema}get props(){return this.propsSchema}get visible(){return this.visibleState}inputValues(){return this.controller.inputValuesOf(this.id)}propValues(){return this.controller.propValuesOf(this.id)}setInput(e,t){this.controller.applyInputs(this.id,{[e]:t});}setInputs(e){this.controller.applyInputs(this.id,e);}setProp(e,t){this.controller.applyProps(this.id,{[e]:t});}setProps(e){this.controller.applyProps(this.id,e);}updateCode(e){this.controller.updateCode(this.id,e);}setVisible(e){this.controller.setVisible(this.id,e);}moveTo(e){this.controller.moveIndicator(this.id,e);}on(e,t){return this.bus.on(e,t)}context(e){return this.controller.getIndicatorContext(this.id,e)}remove(){this.controller.removeIndicator(this.id);}setSchema(e){this.schema=e;}setPropsSchema(e){this.propsSchema=e;}setSource(e){this.source=e;}setVisibleState(e){this.visibleState=e;}emit(e,t){this.bus.emit(e,t);}};function P0(r){let e={};for(let i of r.series)e[i.kind]=(e[i.kind]??0)+1;let t=i=>i?.filter(o=>o.overlay===true).length??0,n=t(r.series)+t(r.fills)+t(r.backgrounds)+t(r.lines)+t(r.boxes)+t(r.labels)+t(r.polylines)+t(r.linefills)+t(r.tables);return {id:r.id,title:r.title,overlay:r.overlay,paneId:r.paneId,native:!!r.native,nativeType:r.native?.type,series:e,fills:r.fills.length,backgrounds:r.backgrounds.length,priceLines:r.priceLines.length,lines:r.lines?.length??0,boxes:r.boxes?.length??0,labels:r.labels?.length??0,polylines:r.polylines?.length??0,linefills:r.linefills?.length??0,tables:r.tables?.length??0,barColors:r.barColors?.length??0,trades:r.trades?.length??0,inputs:r.inputs.length,forcedOverlay:n}}function Kp(r){let e=r.map(P0),t=n=>e.reduce((i,o)=>i+n(o),0);return {indicators:e,totals:{panes:new Set(e.map(n=>n.paneId??"price")).size,series:t(n=>Object.values(n.series).reduce((i,o)=>i+o,0)),fills:t(n=>n.fills),backgrounds:t(n=>n.backgrounds),priceLines:t(n=>n.priceLines),lines:t(n=>n.lines),boxes:t(n=>n.boxes),labels:t(n=>n.labels),polylines:t(n=>n.polylines),linefills:t(n=>n.linefills),tables:t(n=>n.tables),barColors:t(n=>n.barColors),trades:t(n=>n.trades),forcedOverlay:t(n=>n.forcedOverlay)}}}var I0={"1D":864e5,"1W":6048e5,"1M":2592e6,"3M":7776e6,"6M":15552e6,"1Y":31536e6,"5Y":15768e7};function Xp(r,e){if(e.length===0)return null;let t=e[0].time,n=e[e.length-1].time;if(r==="ALL")return {from:t,to:n};let i;return r==="YTD"?i=Date.UTC(new Date(n).getUTCFullYear(),0,1):i=n-I0[r],{from:Math.max(t,i),to:n}}var Ke="#2962ff",$r="#38c0fd",z="#089981",W="#f23645",J="#787b86",jp="#e0b400",ue="#ff9800",Je="#5b9cf6",qp="#ff5d00",Hs="#0ecb81",zs="#f6465d",x2="#f97316",S2="#0ea5e9",C2="#9ca3af",_="#3b82f6",Zp="#9aa0ad",Jp="#1e293b",Qp="#475569",em="#595959",tm=Ke,nm=W,rm="#d500f9",Bs=[Ke,z,W,ue,"#7e57c2","#26a69a",Je,"#e573b5"];function T2(r){let e=0;for(let t=0;t<r.length;t++)e=e*31+r.charCodeAt(t)>>>0;return Bs[e%Bs.length]}var O=$r;function ku(){return {lineColor:O,lineWidth:2,lineStyle:"solid"}}function ln(r=""){return {value:r,size:"normal",hAlign:"left",vAlign:"top"}}var $s=class $s{constructor(e){this.locked=false;this.visible=true;this.zIndex=0;this.id=e.id??`dw-${$s.seq+=1}`,this.paneId=e.paneId,this.anchors=(e.anchors??[]).map(t=>({time:t.time,price:t.price})),this.style=e.style?{...e.style}:ku(),this.text=e.text?{...e.text}:void 0,this.locked=e.locked??false,this.visible=e.visible??true,this.zIndex=e.zIndex??0,this.createdAt=e.createdAt??Date.now(),e.props&&this.readProps(e.props);}isComplete(){return this.anchors.length>=this.anchorSchema().min}placementMode(){return "click"}onPlaced(e){}constrainHandleDrag(e){}translateBody(e,t,n){return n.map(i=>({time:i.time+e,price:i.price+t}))}timeExtent(){if(this.anchors.length===0)return null;let e=1/0,t=-1/0;for(let n of this.anchors)n.time<e&&(e=n.time),n.time>t&&(t=n.time);return {min:e,max:t}}editableLevels(){return null}applySettings(e){for(let[t,n]of Object.entries(e))t.startsWith("text.")&&!this.text&&(this.text=ln()),im(this,t,n);}applyProps(e){this.readProps(e);}serialize(){return {id:this.id,type:this.type,paneId:this.paneId,anchors:this.anchors.map(e=>({time:e.time,price:e.price})),style:{...this.style},text:this.text?{...this.text}:void 0,locked:this.locked,visible:this.visible,zIndex:this.zIndex,createdAt:this.createdAt,props:this.writeProps()}}writeProps(){}readProps(e){}};$s.seq=0;var G=$s;function im(r,e,t){let n=e.split("."),i=r;for(let o=0;o<n.length-1;o+=1){let s=n[o],a=i[s];(a==null||typeof a!="object")&&(a={},i[s]=a),i=a;}i[n[n.length-1]]=t;}var Eu=new Map;function N(r,e){Eu.set(r,e);}function Wr(r){return Eu.get(r)??null}function Z(r){return Eu.get(r)??""}function ye(r,e){return Z(r).replace("<svg ",`<svg width="${e}" height="${e}" `)}function om(r,e=""){return `<svg viewBox="0 0 16 16" width="1em" height="1em" ${e?e+" ":""}fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`}function R(r,e=""){return `<svg viewBox="0 0 24 24" width="1em" height="1em" ${e?e+" ":""}fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`}function Lu(r){return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${r}</svg>`}var U=om;N("style-candles",U('<path d="M4.5 2v2M4.5 12v2M11.5 2v1.5M11.5 11v3"/><rect x="2.8" y="4" width="3.4" height="8" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="3.5" width="3.4" height="7.5" rx="0.6" fill="currentColor"/>'));N("style-bars",U('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>'));N("style-line",U('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));N("style-area",U('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/><path d="M1.5 11.5 5.5 7l3 2.5 5-6V13.5h-12z" fill="currentColor" fill-opacity="0.25" stroke="none"/>'));N("style-baseline",U('<path d="M1.5 8h13" stroke-dasharray="2 2"/><path d="M2.5 8 5.25 4.5 8 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M2.5 8 5.25 4.5 8 8"/><path d="M8 8l2.75 3.5L13.5 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M8 8l2.75 3.5L13.5 8"/>'));N("style-heikinashi",U('<path d="M4.5 12v2M11.5 2v2"/><rect x="2.8" y="5" width="3.4" height="7" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="4" width="3.4" height="7" rx="0.6" fill="currentColor"/>'));N("indicators",U('<path d="M1.5 12.5 5 7l2.5 3.5L11 4l3.5 5"/><circle cx="11" cy="4" r="1.4" fill="currentColor" stroke="none"/>'));N("undo",U('<path d="M6.2 9.5 2.7 6l3.5-3.5"/><path d="M2.7 6h6.8a3.65 3.65 0 0 1 0 7.3H7.5"/>'));N("redo",U('<path d="M9.8 9.5 13.3 6 9.8 2.5"/><path d="M13.3 6H6.5a3.65 3.65 0 0 0 0 7.3h2"/>'));N("objects",U('<path d="M8 1.8 14 5 8 8.2 2 5z"/><path d="M2 8l6 3.2L14 8" opacity="0.7"/><path d="M2 11l6 3.2 6-3.2" opacity="0.4"/>'));N("clock",U('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));N("calendar",U('<rect x="2.2" y="3.2" width="11.6" height="10.6" rx="1.4"/><path d="M5.2 1.8v2.8M10.8 1.8v2.8M2.2 6.8h11.6"/>'));N("datawindow",U('<rect x="1.8" y="2.5" width="12.4" height="11" rx="1.5"/><path d="M4.5 5.5h4M4.5 8h7M4.5 10.5h5.5"/>'));N("camera",U('<path d="M5.5 4 6.5 2.5h3L10.5 4h3A1 1 0 0 1 14.5 5v7.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><circle cx="8" cy="8.5" r="2.6"/>'));N("gear",U('<path d="M6.55 1.4h2.9l.32 1.72c.48.14.92.38 1.3.7l1.66-.55 1.45 2.5-1.35 1.1c.08.34.12.7.12 1.07s-.04.73-.12 1.07l1.35 1.1-1.45 2.5-1.66-.55a4.3 4.3 0 0 1-1.3.7L9.45 14.6h-2.9l-.32-1.72a4.3 4.3 0 0 1-1.3-.7l-1.66.55-1.45-2.5 1.35-1.1A4.4 4.4 0 0 1 3.05 7.94c0-.37.04-.73.12-1.07l-1.35-1.1 1.45-2.5 1.66.55c.38-.32.82-.56 1.3-.7L6.55 1.4z"/><circle cx="8" cy="8" r="2.2"/>'));N("search",U('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));N("bell",U('<path d="M8 2a4 4 0 0 0-4 4v2.5L2.5 11v1h11v-1L12 8.5V6a4 4 0 0 0-4-4z"/><path d="M6.5 13.5a1.5 1.5 0 0 0 3 0"/>'));N("market-open",R('<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>'));N("market-pre",R('<path d="M12 2v8"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m8 6 4-4 4 4"/><path d="M16 18a4 4 0 0 0-8 0"/>'));N("market-post",R('<path d="M12 10V2"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m16 14-4 4-4-4"/><path d="M16 6a4 4 0 0 0-8 0"/>'));N("market-extended",R('<path d="M22 22H2"/><path d="M12 3a5 5 0 0 0 7.5 7.5A7.5 7.5 0 1 1 12 3Z"/>'));N("market-closed",R('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));N("market-holiday",R('<path d="m10 20-1.25-2.5L6 16"/><path d="M10 4 8.75 6.5 6 8"/><path d="m14 20 1.25-2.5L18 16"/><path d="m14 4 1.25 2.5L18 8"/><path d="m17 10-5 5-5-5"/><path d="M4 12h16"/>'));N("chevron-right",U('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));N("chevron-left",U('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));N("chevron-down",U('<path d="M3.5 6 8 10.5 12.5 6"/>'));N("chevron-up",U('<path d="M3.5 10 8 5.5 12.5 10"/>'));N("chevrons-right",U('<path d="m4 3.5 4.5 4.5L4 12.5"/><path d="m8.5 3.5 4.5 4.5-4.5 4.5"/>'));N("chevrons-left",U('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));N("check",U('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));N("close",U('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));N("pin",U('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/>'));N("pin-filled",U('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/><path d="M6.4 2.5h3.2v3.6l2 2.3v.9H4.4v-.9l2-2.3z" fill="currentColor" stroke="none"/>'));N("eye",U('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));N("eye-off",U('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));N("lock",U('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>'));N("unlock",U('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.7-.7"/>'));N("trash",U('<path d="M2.5 4.3h11M6.2 4.3V3.1a1 1 0 0 1 1-1h1.6a1 1 0 0 1 1 1v1.2M4.2 4.3l.5 9.1a1.15 1.15 0 0 0 1.15 1.1h4.3a1.15 1.15 0 0 0 1.15-1.1l.5-9.1M6.5 7v4.5M9.5 7v4.5"/>'));N("group",U('<path d="M1.8 4.5V2.4a.6.6 0 0 1 .6-.6h2.1M11.5 1.8h2.1a.6.6 0 0 1 .6.6v2.1M14.2 11.5v2.1a.6.6 0 0 1-.6.6h-2.1M4.5 14.2H2.4a.6.6 0 0 1-.6-.6v-2.1"/><rect x="4" y="4" width="4.2" height="4.2" rx="0.7"/><rect x="7.8" y="7.8" width="4.2" height="4.2" rx="0.7"/>'));N("ungroup",U('<rect x="1.6" y="1.6" width="6.2" height="6.2" rx="0.9"/><rect x="8.2" y="8.2" width="6.2" height="6.2" rx="0.9" stroke-dasharray="2 1.5"/>'));N("clone",U('<rect x="5.5" y="5.5" width="9" height="9" rx="1.2"/><path d="M11 5.5v-3a1 1 0 0 0-1-1H2.5a1 1 0 0 0-1 1V10a1 1 0 0 0 1 1h3"/>'));N("arrow-up",U('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));N("arrow-down",U('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));N("move-vertical",U('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));N("move",U('<path d="M8 1.8v12.4M1.8 8h12.4M5.6 4.2 8 1.8l2.4 2.4M5.6 11.8 8 14.2l2.4-2.4M4.2 5.6 1.8 8l2.4 2.4M11.8 5.6 14.2 8l-2.4 2.4"/>'));N("pen",U('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));N("wave",U('<path d="M1.5 10.4c1.6 0 1.9-4.8 3.4-4.8s1.8 4.8 3.4 4.8 1.8-4.8 3.4-4.8 1.6 4.8 2.8 4.8"/>'));N("folder-plus",U('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M8 7.6v3.6M6.2 9.4h3.6"/>'));N("folder-minus",U('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M6.2 9.4h3.6"/>'));N("collapse",U('<path d="M3 8h10"/>'));N("expand",U('<rect x="2.2" y="2.2" width="11.6" height="11.6" rx="1.4"/><path d="M8 5.4v5.2M5.4 8h5.2"/>'));N("plus",U('<path d="M8 2.8v10.4M2.8 8h10.4"/>'));N("minus",U('<path d="M2.8 8h10.4"/>'));N("maximize",U('<path d="M2.5 6V3a.5.5 0 0 1 .5-.5h3M10 2.5h3a.5.5 0 0 1 .5.5v3M13.5 10v3a.5.5 0 0 1-.5.5h-3M6 13.5H3a.5.5 0 0 1-.5-.5v-3"/>'));N("restore",U('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));N("star",U('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>'));N("star-filled",U('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>','fill="currentColor"'));N("grip",U('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5" r="1"/><circle cx="6" cy="8" r="1"/><circle cx="10" cy="8" r="1"/><circle cx="6" cy="12.5" r="1"/><circle cx="10" cy="12.5" r="1"/>','fill="currentColor" stroke="none"'));N("kebab",U('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>','fill="currentColor" stroke="none"'));N("burger",U('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));N("info",U('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));N("reset",U('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));N("pane-collapse",U('<path d="M2.6 9.4h4v4M13.4 6.6h-4v-4"/><path d="m9.4 6.6 4.2-4.2M2.4 13.6l4.2-4.2"/>'));N("pane-expand",U('<path d="M9.8 2.4h3.8v3.8M6.2 13.6H2.4V9.8"/><path d="m13.6 2.4-4.4 4.4M2.4 13.6l4.4-4.4"/>'));N("cursor",R('<path d="M5 3l6 16 2-6 6-2z"/>','fill="currentColor" stroke="none"'));N("ruler",R('<path d="M21.3 15.3 8.7 2.7a1 1 0 0 0-1.4 0L2.7 7.3a1 1 0 0 0 0 1.4l12.6 12.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4Z"/><path d="m7.5 10.5 2 2"/><path d="m10.5 7.5 2 2"/><path d="m13.5 4.5 2 2"/><path d="m4.5 13.5 2 2"/>'));N("magnet",R('<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>'));N("eraser",R('<path d="m7 21-4.3-4.3a1 1 0 0 1 0-1.4L13 5a2 2 0 0 1 2.8 0l4.2 4.2a2 2 0 0 1 0 2.8L12 20"/><path d="M22 21H7"/><path d="m5 11 9 9"/>'));N("pen-lock",R('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="13" y="14.5" width="8" height="6" rx="1.2"/><path d="M15 14.5v-1.6a2 2 0 0 1 4 0v1.6"/>'));N("pen-sync",R('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="12.5" y="13.5" width="6" height="4.8" rx="1"/><path d="M15.5 18.3v1a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-2.8a1 1 0 0 0-1-1h-1"/>'));N("brush",R('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'));N("bucket",R('<path d="m18.5 11.5-7-7L4 12a1.8 1.8 0 0 0 0 2.5l5 5a1.8 1.8 0 0 0 2.5 0Z"/><path d="m5 5 4 4"/><path d="M3.5 13.5h13"/><path d="M21 17.5c0 1.1-.9 2-2 2s-2-.9-2-2c0-1 1.2-1.7 2-3 .8 1.3 2 2 2 3Z"/>'));N("type",R('<path d="M5 6V4.5h14V6"/><path d="M12 4.5v15"/><path d="M9.5 19.5h5"/>'));N("bold",R('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7Z"/><path d="M7 12h7a3.5 3.5 0 0 1 0 7H7Z"/>','stroke-width="2.4"'));N("italic",R('<path d="M15 5h-5M14 19H9M14.5 5 10 19"/>','stroke-width="2.2"'));N("price-delta",R('<path d="M12 4v16"/><path d="M8 8l4-4 4 4"/><path d="M8 16l4 4 4-4"/>'));N("date-delta",R('<path d="M4 12h16"/><path d="M8 8l-4 4 4 4"/><path d="M16 8l4 4-4 4"/>'));N("bring-front",R('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/>'));N("send-back",R('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5" fill="currentColor" stroke="none" opacity="0.35"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/><rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/>'));N("r-squared",'<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none"><text x="2.5" y="17.5" font-size="14" font-family="serif">R\xB2</text></svg>');N("bands",R('<path d="M3 6h18"/><path d="M3 18h18"/><path d="M3 12h18" stroke-dasharray="3 3"/>'));N("dedekind",R('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0"/><path d="M8 20a4 4 0 0 1 8 0"/><path d="M12 4v16"/>'));N("sonic",R('<circle cx="15" cy="12" r="4"/><circle cx="12" cy="12" r="2.5"/><path d="M8 5v14"/>'));N("supersonic",R('<circle cx="16" cy="12" r="3.5"/><path d="M6 12 15 6M6 12 15 18"/>'));var Xe=[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}],B=[{path:"style.lineColor",label:"Line color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Line width",kind:"number",min:1,max:10,step:1,group:"line"},{path:"style.lineStyle",label:"Line style",kind:"lineStyle",options:Xe,group:"line"}],de=[{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"}],Tt=[{value:"small",label:"Small"},{value:"normal",label:"Normal"},{value:"large",label:"Large"},{value:"huge",label:"Huge"}],H=[{path:"text.value",label:"Text",kind:"text",group:"text"},{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Tt,group:"text"},{path:"text.bold",label:"Bold",kind:"boolean",group:"text"},{path:"text.italic",label:"Italic",kind:"boolean",group:"text"}];function ne(r,e,t,n,i,o){let s=i-t,a=o-n,l=s*s+a*a;if(l<=1e-9)return Math.hypot(r-t,e-n);let c=((r-t)*s+(e-n)*a)/l;return c=c<0?0:c>1?1:c,Math.hypot(r-(t+c*s),e-(n+c*a))}function Gr(r,e,t){let n=1/0;for(let i=1;i<t.length;i+=1){let o=t[i-1],s=t[i],a=ne(r,e,o[0],o[1],s[0],s[1]);a<n&&(n=a);}return n}function Ve(r,e,t,n,i,o,s=0){let a=Math.min(t,i)-s,l=Math.max(t,i)+s,c=Math.min(n,o)-s,u=Math.max(n,o)+s;return r>=a&&r<=l&&e>=c&&e<=u}function Bt(r,e,t){let n=false;for(let i=0,o=t.length-1;i<t.length;o=i,i+=1){let s=t[i],a=t[o];s[1]>e!=a[1]>e&&r<(a[0]-s[0])*(e-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}return n}function Mu(r,e,t,n,i,o,s,a){let l=t-r,c=n-e,u=s-i,d=a-o,h=u*c-d*l;if(Math.abs(h)<1e-9)return null;let p=((o-e)*l-(i-r)*c)/h;return p<0||p>1?null:[i+p*u,o+p*d]}function Y(r,e,t,n=6){for(let i=0;i<t.length;i+=1){let o=t[i];if(Math.hypot(r-o[0],e-o[1])<=n)return i}return -1}function Se(r,e,t,n,i,o,s){if(i==="none")return [r,e,t,n];let a=t-r,l=i==="left"||i==="both",c=i==="right"||i==="both";if(Math.abs(a)<1e-6){if(l&&c)return [r,0,t,s];let m=n>=e;return c?m?[r,e,t,s]:[r,e,t,0]:m?[r,0,t,n]:[r,s,t,n]}let u=(n-e)/a,d=m=>e+u*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,d(h),p,d(p)]}var Ws=class extends G{constructor(){super(...arguments);this.type="trendline";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);return s!=null&&ne(t,n,s[0],s[1],s[2],s[3])<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);if(!n)return null;let i=Math.min(n[0],n[2]),o=Math.min(n[1],n[3]);return {x:i,y:o,w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,{path:"style.arrowRight",label:"Arrow",kind:"boolean",group:"line"},...H]}}};var Gs=class extends G{constructor(){super(...arguments);this.type="hline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"y"}]}}y(t){let n=this.anchors[0];return n?t.yOf(n.price,this.paneId):null}hitTest(t,n,i,o){let s=this.y(i);return s!=null&&Math.abs(n-s)<=o}handlePoints(t){let n=this.anchors[0],i=this.y(t);return !n||i==null?[]:[[t.xOf(n.time),i]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.y(t);return n==null?null:{x:0,y:n-1,w:t.width,h:2}}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){return null}schema(){return {fields:[...B,...H]}}};var Us=class extends G{constructor(){super(...arguments);this.type="ray";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,u]=Se(s[0],s[1],s[2],s[3],"right",i.width,i.height);return ne(t,n,a,l,c,u)<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);return n?{x:Math.min(n[0],n[2]),y:Math.min(n[1],n[3]),w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...H]}}};var In=class extends G{anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:[e.xOf(t.time),i,e.xOf(n.time),o]}hitTest(e,t,n,i){let o=this.pixels(n);return o!=null&&ne(e,t,o[0],o[1],o[2],o[3])<=i}handlePoints(e){let t=this.pixels(e);return t?[[t[0],t[1]],[t[2],t[3]]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.pixels(e);return t?{x:Math.min(t[0],t[2]),y:Math.min(t[1],t[3]),w:Math.abs(t[2]-t[0]),h:Math.abs(t[3]-t[1])}:null}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[...B,...H]}}};var Ys=class extends In{constructor(){super(...arguments);this.type="extendedline";}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,u]=Se(s[0],s[1],s[2],s[3],"both",i.width,i.height);return ne(t,n,a,l,c,u)<=o}timeExtent(){return null}};var Ks=class extends G{constructor(){super(...arguments);this.type="vline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"x"}]}}x(t){let n=this.anchors[0];return n?t.xOf(n.time):null}hitTest(t,n,i,o){let s=this.x(i);return s!=null&&Math.abs(t-s)<=o}handlePoints(t){let n=this.anchors[0],i=this.x(t);if(!n||i==null)return [];let o=t.yOf(n.price,this.paneId);return o==null?[]:[[i,o]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.x(t);return n==null?null:{x:n-1,y:0,w:2,h:t.height}}priceRange(){return null}schema(){return {fields:[...B,...H]}}};var Xs=class extends G{constructor(){super(...arguments);this.type="hray";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}pt(t){let n=this.anchors[0];if(!n)return null;let i=t.yOf(n.price,this.paneId);return i==null?null:[t.xOf(n.time),i]}hitTest(t,n,i,o){let s=this.pt(i);return s!=null&&ne(t,n,s[0],s[1],i.width,s[1])<=o}handlePoints(t){let n=this.pt(t);return n?[n]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pt(t);return n?{x:n[0],y:n[1]-1,w:Math.max(0,t.width-n[0]),h:2}:null}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){let t=this.anchors[0];return t?{min:t.time,max:Number.POSITIVE_INFINITY}:null}schema(){return {fields:[...B,...H]}}};var js=class extends G{constructor(){super(...arguments);this.type="crossline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}pt(t){let n=this.anchors[0];if(!n)return null;let i=t.yOf(n.price,this.paneId);return i==null?null:[t.xOf(n.time),i]}hitTest(t,n,i,o){let s=this.pt(i);return s!=null&&(Math.abs(n-s[1])<=o||Math.abs(t-s[0])<=o)}handlePoints(t){let n=this.pt(t);return n?[n]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pt(t);return n?{x:n[0]-1,y:n[1]-1,w:2,h:2}:null}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){return null}schema(){return {fields:[...B,...H]}}};var qs=class extends In{constructor(){super(...arguments);this.type="infoline";}};var Zs=class extends In{constructor(){super(...arguments);this.type="trendangle";}};var Js=class extends G{constructor(){super(...arguments);this.type="box";}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}rect(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{x1:t.xOf(n.time),y1:o,x2:t.xOf(i.time),y2:s}}hitTest(t,n,i,o){let s=this.rect(i);return s?this.style.fillColor&&Ve(t,n,s.x1,s.y1,s.x2,s.y2)?true:[[s.x1,s.y1,s.x2,s.y1],[s.x2,s.y1,s.x2,s.y2],[s.x2,s.y2,s.x1,s.y2],[s.x1,s.y2,s.x1,s.y1]].some(l=>ne(t,n,l[0],l[1],l[2],l[3])<=o):false}handlePoints(t){let n=this.rect(t);return n?[[n.x1,n.y1],[n.x2,n.y2]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.rect(t);return n?{x:Math.min(n.x1,n.x2),y:Math.min(n.y1,n.y2),w:Math.abs(n.x2-n.x1),h:Math.abs(n.y2-n.y1)}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"},...H]}}};var A0={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},An=class extends G{defaultLabel(){return "Text"}labelText(){return this.text?.value??this.defaultLabel()}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}box(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=A0[this.text?.size??"normal"]??14,o=this.labelText().split(`
|
|
2
|
+
`),s=Math.max(1,...o.map(a=>a.length));return {x:e.xOf(t.time),y:n,w:Math.max(12,s*i*.6)+8,h:o.length*i*1.4+4}}hitTest(e,t,n,i){let o=this.box(n);return o!=null&&Ve(e,t,o.x,o.y,o.x+o.w,o.y+o.h)}handlePoints(e){let t=this.anchors[0],n=t?e.yOf(t.price,this.paneId):null;return t&&n!=null?[[e.xOf(t.time),n]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){return this.box(e)}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}};var cn=class extends An{constructor(t){super(t);this.type="text";this.text||(this.text={...ln(),size:"large"});}schema(){return {fields:[...H],textIsContent:true}}};var tr=class extends An{constructor(t){super(t);this.type="note";this.text||(this.text=ln("Note"));}defaultLabel(){return "Note"}schema(){return {fields:[...B,...de,...H],textIsContent:true}}};var nr=class extends An{constructor(){super(...arguments);this.type="pricelabel";}labelText(){let t=this.anchors[0]?.price;return t==null?"0.00":t.toFixed(2)}schema(){return {fields:[...B,...de,...H.filter(t=>t.path!=="text.value")]}}};var R0={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},dt=class extends G{constructor(e){super(e),this.text||(this.text=ln(this.defaultLabel()));}defaultLabel(){return "Callout"}labelText(){return this.text?.value??this.defaultLabel()}anchorSchema(){return {min:2,max:2,slots:[{role:"target",free:"both"},{role:"box",free:"both"}]}}box(e){let t=this.anchors[1];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=R0[this.text?.size??"normal"]??14,o=this.labelText().split(`
|
|
3
|
+
`),s=Math.max(1,...o.map(c=>c.length)),a=Math.max(20,s*i*.6)+16,l=o.length*i*1.4+12;return {x:e.xOf(t.time)-a/2,y:n-l/2,w:a,h:l}}points(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitTest(e,t,n,i){let o=this.box(n);if(o&&Ve(e,t,o.x,o.y,o.x+o.w,o.y+o.h,i))return true;let s=this.points(n);return s!=null&&ne(e,t,s[0][0],s[0][1],s[1][0],s[1][1])<=i}handlePoints(e){let t=this.points(e);return t?[t[0]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}translateBody(e,t,n){let i=n[0],o=n[1];return !i||!o?n.map(s=>({time:s.time+e,price:s.price+t})):[{time:i.time,price:i.price},{time:o.time+e,price:o.price+t}]}bounds(e){return this.box(e)}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[...B,...de,...H],textIsContent:true}}};var Ht=class extends dt{constructor(){super(...arguments);this.type="callout";}};var rr=class extends dt{constructor(){super(...arguments);this.type="pricenote";}defaultLabel(){return ""}labelText(){let t=this.anchors[0]?.price;return t==null?"0.00":t.toFixed(2)}schema(){return {fields:[...B,...de,...H.filter(t=>t.path!=="text.value")]}}};var ir=class extends dt{constructor(){super(...arguments);this.type="comment";}defaultLabel(){return "Comment"}};var or=class extends dt{constructor(){super(...arguments);this.type="signpost";}defaultLabel(){return "Signpost"}};var pe=class extends G{hitTest(e,t,n,i){let o=this.geometry(n);return o?this.style.fillColor&&o.fill&&Bt(e,t,o.fill)?true:o.segments.some(s=>ne(e,t,s[0],s[1],s[2],s[3])<=i):false}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}};var Qs=class extends pe{constructor(){super(...arguments);this.type="parallelchannel";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"y"}]}}offset(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];return !t||!n||!i?0:i.price-(t.price+n.price)/2}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.offset(),s=t.xOf(n.time),a=t.xOf(i.time),l=t.yOf(n.price,this.paneId),c=t.yOf(i.price,this.paneId),u=t.yOf(n.price+o,this.paneId),d=t.yOf(i.price+o,this.paneId);return l==null||c==null||u==null||d==null?null:{segments:[[s,l,a,c],[s,u,a,d]],fill:[[s,l],[a,c],[a,d],[s,u]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=this.offset(),o=[t.price,n.price,t.price+i,n.price+i],s=this.anchors[2];return s&&o.push(s.price),{min:Math.min(...o),max:Math.max(...o)}}schema(){return {fields:[...B,...de,...H]}}};var ea=class extends pe{constructor(){super(...arguments);this.type="disjointchannel";}anchorSchema(){return {min:4,max:4,slots:[{role:"top1",free:"both"},{role:"top2",free:"both"},{role:"bot1",free:"both"},{role:"bot2",free:"both"}]}}seg(t,n,i){let o=this.anchors[t],s=this.anchors[n];if(!o||!s)return null;let a=i.yOf(o.price,this.paneId),l=i.yOf(s.price,this.paneId);return a==null||l==null?null:[i.xOf(o.time),a,i.xOf(s.time),l]}geometry(t){let n=this.seg(0,1,t),i=this.seg(2,3,t),o=[n,i].filter(a=>a!=null);if(o.length===0)return null;let s=n&&i?[[n[0],n[1]],[n[2],n[3]],[i[2],i[3]],[i[0],i[1]]]:null;return {segments:o,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...de,...H]}}};var ta=class extends pe{constructor(){super(...arguments);this.type="flattopbottom";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"flat",free:"y"}]}}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);if(a==null||l==null)return null;let c=this.anchors[2];if(!c)return {segments:[[o,a,s,l]],fill:null};let u=t.yOf(c.price,this.paneId);return u==null?null:{segments:[[o,a,s,l],[o,u,s,u]],fill:[[o,a],[s,l],[s,u],[o,u]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=[t.price,n.price],o=this.anchors[2];return o&&i.push(o.price),{min:Math.min(...i),max:Math.max(...i)}}schema(){return {fields:[...B,...de,...H]}}};var D0=2;function sm(){return {midColor:J,midStyle:"solid",upperColor:z,upperStyle:"solid",lowerColor:W,lowerStyle:"solid",upperFill:`${z}26`,lowerFill:`${W}26`,showR2:true}}function am(r){let e=r.length;if(e<2)return null;let t=0,n=0,i=0,o=0,s=0;for(let m=0;m<e;m+=1){let f=r[m].close;t+=m,n+=f,i+=m*f,o+=m*m,s+=f*f;}let a=e*o-t*t,l=a===0?0:(e*i-t*n)/a,c=(n-l*t)/e,u=0;for(let m=0;m<e;m+=1){let f=r[m].close-(c+l*m);u+=f*f;}let d=Math.sqrt(u/e),h=Math.sqrt(a*(e*s-n*n)),p=h===0?0:(e*i-t*n)/h;return {t0:r[0].time,t1:r[e-1].time,mid0:c,mid1:c+l*(e-1),dev:D0*d,r2:Math.max(0,Math.min(1,p*p)),n:e}}var un=class extends G{constructor(t){super(t);this.type="regressionchannel";this.cachedRange=null;this.reg||(this.reg=sm());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}fit(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null,l=a?am(a):null;return l&&(this.cachedRange={min:Math.min(l.mid0,l.mid1)-l.dev,max:Math.max(l.mid0,l.mid1)+l.dev}),l}layout(t){let n=this.fit(t);if(!n)return null;let i=t.yOf(n.mid0,this.paneId),o=t.yOf(n.mid1,this.paneId),s=t.yOf(n.mid0+n.dev,this.paneId),a=t.yOf(n.mid1+n.dev,this.paneId),l=t.yOf(n.mid0-n.dev,this.paneId),c=t.yOf(n.mid1-n.dev,this.paneId);return i==null||o==null||s==null||a==null||l==null||c==null?null:{x0:t.xOf(n.t0),x1:t.xOf(n.t1),midY0:i,midY1:o,upperY0:s,upperY1:a,lowerY0:l,lowerY1:c,r2:n.r2,showR2:this.reg.showR2}}band(t){let n=this.layout(t);return n?[[n.x0,n.upperY0],[n.x1,n.upperY1],[n.x1,n.lowerY1],[n.x0,n.lowerY0]]:null}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=[[s.x0,s.upperY0],[s.x1,s.upperY1],[s.x1,s.lowerY1],[s.x0,s.lowerY0]];return Bt(t,n,a)?true:[[s.x0,s.midY0,s.x1,s.midY1],[s.x0,s.upperY0,s.x1,s.upperY1],[s.x0,s.lowerY0,s.x1,s.lowerY1]].some(c=>ne(t,n,c[0],c[1],c[2],c[3])<=o)}handlePoints(t){let n=this.layout(t);if(n)return [[n.x0,n.midY0],[n.x1,n.midY1]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.band(t);if(!n)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"reg.midColor",label:"Midline color",kind:"color",group:"line"},{path:"reg.midStyle",label:"Midline style",kind:"lineStyle",group:"line"},{path:"reg.upperColor",label:"Upper line color",kind:"color",group:"line"},{path:"reg.upperStyle",label:"Upper line style",kind:"lineStyle",group:"line"},{path:"reg.lowerColor",label:"Lower line color",kind:"color",group:"line"},{path:"reg.lowerStyle",label:"Lower line style",kind:"lineStyle",group:"line"},{path:"reg.upperFill",label:"Upper fill",kind:"color",group:"fill"},{path:"reg.lowerFill",label:"Lower fill",kind:"color",group:"fill"},{path:"reg.showR2",label:"Show R\xB2",kind:"boolean",group:"behavior"}]}}writeProps(){return {...this.reg}}readProps(t){this.reg={...sm(),...t};}};var lm=`${Je}00`;function cm(){return {midColor:Je,midStyle:"solid",multiplier:1,upperColor:lm,upperStyle:"solid",lowerColor:lm,lowerStyle:"solid",bandFill:`${Je}33`}}function um(r,e){let t=r.length;if(t<1)return null;let n=0;for(let c of r)n+=c.volume>0?c.volume:0;let i=n>0,o=0,s=0,a=0,l=[];for(let c=0;c<t;c+=1){let u=r[c],d=(u.high+u.low+u.close)/3,h=i?Math.max(0,u.volume):1;o+=h,s+=d*h,a+=d*d*h;let p=o>0?s/o:d,m=o>0?Math.max(0,a/o-p*p):0,f=Math.sqrt(m)*e;l.push({time:u.time,mid:p,upper:p+f,lower:p-f});}return l}var sr=class extends G{constructor(t){super(t);this.type="anchoredvwap";this.cachedRange=null;this.cachedExtent=null;this.vwap||(this.vwap=cm());}anchorSchema(){return {min:1,max:1,slots:[{role:"anchor",free:"x"}]}}series(t){let n=this.anchors[0];if(!n)return null;let i=t.barsInRange?.(n.time,Number.POSITIVE_INFINITY)??null;if(!i||i.length<1)return null;let o=um(i.map(s=>({time:s.time,high:s.high,low:s.low,close:s.close,volume:s.volume??0})),this.vwap.multiplier);if(o&&o.length>0){let s=1/0,a=-1/0;for(let l of o)l.lower<s&&(s=l.lower),l.upper>a&&(a=l.upper);this.cachedRange={min:s,max:a},this.cachedExtent={min:o[0].time,max:o[o.length-1].time};}return o}layout(t){let n=this.series(t);if(!n)return null;let i=[],o=[],s=[];for(let a of n){let l=t.xOf(a.time),c=t.yOf(a.mid,this.paneId),u=t.yOf(a.upper,this.paneId),d=t.yOf(a.lower,this.paneId);c==null||u==null||d==null||(i.push([l,c]),o.push([l,u]),s.push([l,d]));}return i.length>0?{mid:i,upper:o,lower:s}:null}bandPolygon(t){return [...t.upper,...[...t.lower].reverse()]}hitTest(t,n,i,o){let s=this.layout(i);return s?Bt(t,n,this.bandPolygon(s))?true:Pu(t,n,s.mid,o)||Pu(t,n,s.upper,o)||Pu(t,n,s.lower,o):false}handlePoints(t){let n=this.layout(t);if(n&&n.mid.length>0)return [n.mid[0]];let i=this.anchors[0];if(!i)return [];let o=t.yOf(i.price,this.paneId);return o==null?[]:[[t.xOf(i.time),o]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=[...n.upper,...n.lower],o=i.map(c=>c[0]),s=i.map(c=>c[1]),a=Math.min(...o),l=Math.min(...s);return {x:a,y:l,w:Math.max(...o)-a,h:Math.max(...s)-l}}priceRange(){return this.cachedRange}timeExtent(){return this.cachedExtent}schema(){return {fields:[{path:"vwap.midColor",label:"VWAP color",kind:"color",group:"line"},{path:"vwap.midStyle",label:"VWAP style",kind:"lineStyle",group:"line"},{path:"vwap.multiplier",label:"Band multiplier",kind:"number",min:.5,max:5,step:.5,group:"behavior"},{path:"vwap.upperColor",label:"Upper band color",kind:"color",group:"line"},{path:"vwap.lowerColor",label:"Lower band color",kind:"color",group:"line"},{path:"vwap.bandFill",label:"Band fill",kind:"color",group:"fill"}]}}writeProps(){return {...this.vwap}}readProps(t){this.vwap={...cm(),...t};}};function Pu(r,e,t,n){for(let i=1;i<t.length;i+=1)if(ne(r,e,t[i-1][0],t[i-1][1],t[i][0],t[i][1])<=n)return true;return false}var O0=`${z}66`,N0=`${W}66`,F0=`${z}BF`,V0=`${W}BF`;function dm(){return {rows:24,valueAreaPct:70,widthPct:35,anchor:"left",upColor:O0,downColor:N0,vaUpColor:F0,vaDownColor:V0,showVah:true,vahColor:J,vahStyle:"solid",showVal:true,valColor:J,valStyle:"solid",showPoc:true,pocColor:void 0,pocStyle:"solid",showDevelopingPoc:false,developingPocColor:Ke,developingPocStyle:"dotted",showDevelopingVa:false,developingVaColor:Ke,developingVaStyle:"dotted"}}function _0(r,e){return r<0?0:r>=e?e-1:r}function hm(r,e,t){let n=r.length,i=0,o=0;for(let u=0;u<n;u+=1){let d=r[u].up+r[u].down;i+=d,d>o&&(o=d);}let s=i*Math.min(1,Math.max(0,t)),a=e,l=e,c=o;for(;c<s&&(a>0||l<n-1);){let u=a>0?r[a-1].up+r[a-1].down:-1,d=l<n-1?r[l+1].up+r[l+1].down:-1;d>u?(l+=1,c+=d):(a-=1,c+=u);}return {vaFrom:a,vaTo:l}}function pm(r,e,t,n){let i=n.volume;if(!(i>0))return;let o=r.length,s=n.close>=n.open?"up":"down",a=new Set;for(let l of [n.open,n.high,n.low,n.close])a.add(_0(Math.floor((l-e)/t),o));for(let l of a)r[l][s]+=i;}function mm(r){let e=0,t=0;for(let n=0;n<r.length;n+=1){let i=r[n].up+r[n].down;i>e&&(e=i,t=n);}return e>0?{poc:t,maxTotal:e}:null}function fm(r,e,t){let n=1/0,i=-1/0;for(let p of r)p.volume>0&&(p.low<n&&(n=p.low),p.high>i&&(i=p.high));if(!Number.isFinite(n))return null;let o=i>n?Math.max(1,Math.round(e)):1,s=i>n?(i-n)/o:1,a=Array.from({length:o},(p,m)=>({price:n+m*s,up:0,down:0}));for(let p of r)pm(a,n,s,p);let l=mm(a);if(!l)return null;let{poc:c,maxTotal:u}=l,{vaFrom:d,vaTo:h}=hm(a,c,t);return {rows:a,rowH:s,min:n,maxTotal:u,poc:c,vaFrom:d,vaTo:h}}function gm(r,e,t,n){let i=fm(r,e,t);if(!i)return null;if(!n||r.length<1)return {profile:i,developingPoc:[],developingVaHigh:[],developingVaLow:[]};let{min:o,rowH:s}=i,a=i.rows.length,l=Array.from({length:a},(h,p)=>({price:o+p*s,up:0,down:0})),c=[],u=[],d=[];for(let h of r){pm(l,o,s,h);let p=mm(l);if(!p)continue;let{poc:m}=p,{vaFrom:f,vaTo:g}=hm(l,m,t);c.push({time:h.time,price:l[m].price+s/2}),u.push({time:h.time,price:l[g].price+s}),d.push({time:h.time,price:l[f].price});}return {profile:i,developingPoc:c,developingVaHigh:u,developingVaLow:d}}var at=class extends G{constructor(t){super(t);this.type="fixedrangevp";this.cachedRange=null;this.frvp||(this.frvp=dm());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}barsInSpan(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null;return !a||a.length<1?null:a.map(l=>({time:l.time,open:l.open,high:l.high,low:l.low,close:l.close,volume:l.volume??0}))}compute(t){let n=this.barsInSpan(t);if(!n)return null;let i=this.frvp,o=i.showDevelopingPoc||i.showDevelopingVa,s=gm(n,i.rows,i.valueAreaPct/100,o);if(s){let{profile:a}=s;this.cachedRange={min:a.min,max:a.min+a.rowH*a.rows.length};}return s}layout(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.compute(t);if(!o)return null;let{profile:s}=o,a=Math.min(n.time,i.time),l=Math.max(n.time,i.time),c=t.xOf(a),u=t.xOf(l),d=Math.abs(u-c),h=Math.max(1,Math.min(100,Math.max(0,this.frvp.widthPct))/100*d),p=this.frvp.anchor==="left",m=p?Math.min(c,u):Math.max(c,u),f=p?1:-1,g=[];for(let T=0;T<=s.rows.length;T+=1){let k=t.yOf(s.min+T*s.rowH,this.paneId);if(k==null)return null;g.push(k);}let b=T=>t.yOf(T,this.paneId),y=s.rows[s.vaTo].price+s.rowH,v=s.rows[s.vaFrom].price,S=s.rows[s.poc].price+s.rowH/2,E=T=>{let k=[];for(let x of T){let L=b(x.price);L!=null&&k.push([t.xOf(x.time),L]);}return k};return {x0:Math.min(c,u),x1:Math.max(c,u),anchorX:m,maxW:h,grow:f,profile:s,yEdges:g,vahY:b(y),valY:b(v),pocY:b(S),developingPoc:E(o.developingPoc),developingVaHigh:E(o.developingVaHigh),developingVaLow:E(o.developingVaLow)}}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=s.grow===1?s.anchorX:s.anchorX-s.maxW,l=s.grow===1?s.anchorX+s.maxW:s.anchorX,c=Math.min(s.yEdges[0],s.yEdges[s.yEdges.length-1]),u=Math.max(s.yEdges[0],s.yEdges[s.yEdges.length-1]);if(Bt(t,n,[[a,c],[l,c],[l,u],[a,u]]))return true;let d=[[s.x0,s.vahY],[s.x0,s.valY],[s.x0,s.pocY]];for(let[,h]of d)if(h!=null&&ne(t,n,s.x0,h,s.x1,h)<=o)return true;for(let h of [s.developingPoc,s.developingVaHigh,s.developingVaLow])for(let p=1;p<h.length;p+=1)if(ne(t,n,h[p-1][0],h[p-1][1],h[p][0],h[p][1])<=o)return true;return false}handlePoints(t){let n=this.layout(t);if(n&&n.pocY!=null)return [[n.x0,n.pocY],[n.x1,n.pocY]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=Math.min(n.x0,n.grow===1?n.anchorX:n.anchorX-n.maxW),o=Math.max(n.x1,n.grow===1?n.anchorX+n.maxW:n.anchorX),s=Math.min(n.yEdges[0],n.yEdges[n.yEdges.length-1]),a=Math.max(n.yEdges[0],n.yEdges[n.yEdges.length-1]);return {x:i,y:s,w:o-i,h:a-s}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"frvp.rows",label:"Rows",kind:"number",min:1,max:500,step:1,group:"behavior"},{path:"frvp.valueAreaPct",label:"Value Area",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.widthPct",label:"Width %",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.anchor",label:"Anchor",kind:"select",options:[{value:"right",label:"Right"},{value:"left",label:"Left"}],group:"behavior"},{path:"frvp.upColor",label:"Up Volume",kind:"color",group:"fill"},{path:"frvp.downColor",label:"Down Volume",kind:"color",group:"fill"},{path:"frvp.vaUpColor",label:"Value Area Up",kind:"color",group:"fill"},{path:"frvp.vaDownColor",label:"Value Area Down",kind:"color",group:"fill"},{path:"frvp.showVah",label:"VAH",kind:"boolean",group:"line"},{path:"frvp.vahColor",label:"VAH color",kind:"color",group:"line"},{path:"frvp.vahStyle",label:"VAH style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showVal",label:"VAL",kind:"boolean",group:"line"},{path:"frvp.valColor",label:"VAL color",kind:"color",group:"line"},{path:"frvp.valStyle",label:"VAL style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showPoc",label:"POC",kind:"boolean",group:"line"},{path:"frvp.pocColor",label:"POC color",kind:"color",group:"line"},{path:"frvp.pocStyle",label:"POC style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showDevelopingPoc",label:"Developing POC",kind:"boolean",group:"line"},{path:"frvp.developingPocColor",label:"Developing POC color",kind:"color",group:"line"},{path:"frvp.developingPocStyle",label:"Developing POC style",kind:"lineStyle",options:Xe,group:"line"},{path:"frvp.showDevelopingVa",label:"Developing VA",kind:"boolean",group:"line"},{path:"frvp.developingVaColor",label:"Developing VA color",kind:"color",group:"line"},{path:"frvp.developingVaStyle",label:"Developing VA style",kind:"lineStyle",options:Xe,group:"line"}]}}writeProps(){return {...this.frvp}}readProps(t){this.frvp={...dm(),...t};}};var na=class extends pe{constructor(){super(...arguments);this.type="pitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=g=>{let b=t.yOf(g.price,this.paneId);return b==null?null:[t.xOf(g.time),b]},s=o(n),a=o(i);if(!s||!a)return null;let l=this.anchors[2];if(!l)return {segments:[[s[0],s[1],a[0],a[1]]],fill:null};let c=o(l);if(!c)return null;let u=(a[0]+c[0])/2,d=(a[1]+c[1])/2,h=u-s[0],p=d-s[1],m=t.width,f=t.height;return {segments:[Se(s[0],s[1],u,d,"right",m,f),Se(a[0],a[1],a[0]+h,a[1]+p,"right",m,f),Se(c[0],c[1],c[0]+h,c[1]+p,"right",m,f),[a[0],a[1],c[0],c[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...H]}}};var Ur=class extends pe{anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=g=>{let b=e.yOf(g.price,this.paneId);return b==null?null:[e.xOf(g.time),b]},o=i(t),s=i(n);if(!o||!s)return null;let a=this.anchors[2];if(!a)return {segments:[[o[0],o[1],s[0],s[1]]],fill:null};let l=i(this.medianStart(t,n,a)),c=i(a);if(!l||!c)return null;let u=(s[0]+c[0])/2,d=(s[1]+c[1])/2,h=u-l[0],p=d-l[1],m=e.width,f=e.height;return {segments:[Se(l[0],l[1],u,d,"right",m,f),Se(s[0],s[1],s[0]+h,s[1]+p,"right",m,f),Se(c[0],c[1],c[0]+h,c[1]+p,"right",m,f),[s[0],s[1],c[0],c[1]],[o[0],o[1],s[0],s[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...B,...H]}}};var ra=class extends Ur{constructor(){super(...arguments);this.type="schiffpitchfork";}medianStart(t,n){return {time:t.time,price:(t.price+n.price)/2}}};var ia=class extends Ur{constructor(){super(...arguments);this.type="modifiedschiffpitchfork";}medianStart(t,n){return {time:(t.time+n.time)/2,price:(t.price+n.price)/2}}};var oa=class extends pe{constructor(){super(...arguments);this.type="insidepitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=b=>{let y=t.yOf(b.price,this.paneId);return y==null?null:[t.xOf(b.time),y]},s=o(n),a=o(i);if(!s||!a)return null;let l=this.anchors[2];if(!l)return {segments:[[s[0],s[1],a[0],a[1]]],fill:null};let c=o({time:(n.time+i.time)/2,price:(n.price+i.price)/2}),u=o(l);if(!c||!u)return null;let d=(a[0]+u[0])/2,h=(a[1]+u[1])/2,p=u[0]-c[0],m=u[1]-c[1],f=t.width,g=t.height;return {segments:[Se(d,h,d+p,h+m,"right",f,g),Se(a[0],a[1],a[0]+p,a[1]+m,"right",f,g),Se(u[0],u[1],u[0]+p,u[1]+m,"right",f,g),[a[0],a[1],u[0],u[1]],[c[0],c[1],u[0],u[1]],[s[0],s[1],a[0],a[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...H]}}};var sa=class extends G{constructor(){super(...arguments);this.type="arrow";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);return s!=null&&ne(t,n,s[0],s[1],s[2],s[3])<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);return n?{x:Math.min(n[0],n[2]),y:Math.min(n[1],n[3]),w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,{path:"style.arrowRight",label:"Head (end)",kind:"boolean",group:"line"},{path:"style.arrowLeft",label:"Head (start)",kind:"boolean",group:"line"},...H]}}};var bm=48,aa=class extends G{constructor(){super(...arguments);this.type="ellipse";}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}oval(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:(a+l)/2,cy:(o+s)/2,rx:Math.abs(l-a)/2,ry:Math.abs(s-o)/2}}perimeter(t){let n=[];for(let i=0;i<=bm;i+=1){let o=i/bm*Math.PI*2;n.push([t.cx+t.rx*Math.cos(o),t.cy+t.ry*Math.sin(o)]);}return n}hitTest(t,n,i,o){let s=this.oval(i);if(!s||s.rx<1||s.ry<1)return false;let a=((t-s.cx)/s.rx)**2+((n-s.cy)/s.ry)**2;return this.style.fillColor&&a<=1?true:Gr(t,n,this.perimeter(s))<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.oval(t);return n?{x:n.cx-n.rx,y:n.cy-n.ry,w:n.rx*2,h:n.ry*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...de,...H]}}};var la=class extends pe{constructor(){super(...arguments);this.type="triangle";}anchorSchema(){return {min:3,max:3,slots:[{role:"v1",free:"both"},{role:"v2",free:"both"},{role:"v3",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=u=>{let d=t.yOf(u.price,this.paneId);return d==null?null:[t.xOf(u.time),d]},s=o(n),a=o(i);if(!s||!a)return null;let l=this.anchors[2];if(!l)return {segments:[[s[0],s[1],a[0],a[1]]],fill:null};let c=o(l);return c?{segments:[[s[0],s[1],a[0],a[1]],[a[0],a[1],c[0],c[1]],[c[0],c[1],s[0],s[1]]],fill:[s,a,c]}:null}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...de,...H]}}};var B0=512,Rn=class extends pe{anchorSchema(){return {min:2,max:B0,slots:[]}}geometry(e){let t=[];for(let i of this.anchors){let o=e.yOf(i.price,this.paneId);if(o==null)return null;t.push([e.xOf(i.time),o]);}if(t.length<2)return null;let n=[];for(let i=1;i<t.length;i+=1)n.push([t[i-1][0],t[i-1][1],t[i][0],t[i][1]]);return {segments:n,fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...B,...H]}}};var ca=class extends Rn{constructor(){super(...arguments);this.type="polyline";}};var Yi=class extends Rn{placementMode(){return "freehand"}handlePoints(e){return []}bounds(e){let t=[],n=[];for(let s of this.anchors){let a=e.yOf(s.price,this.paneId);a!=null&&(t.push(e.xOf(s.time)),n.push(a));}if(t.length===0)return null;let i=Math.min(...t),o=Math.min(...n);return {x:i,y:o,w:Math.max(...t)-i,h:Math.max(...n)-o}}},ua=class extends Yi{constructor(){super(...arguments);this.type="freehand";}};var H0=[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Width",kind:"number",min:4,max:60,step:1,group:"line"}],da=class extends Yi{constructor(){super(...arguments);this.type="highlighter";}schema(){return {fields:H0}}};var ha=class extends G{constructor(){super(...arguments);this.type="circle";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}geom(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,r:Math.hypot(l-a,s-o)}}hitTest(t,n,i,o){let s=this.geom(i);if(!s||s.r<1)return false;let a=Math.hypot(t-s.cx,n-s.cy);return this.style.fillColor&&a<=s.r?true:Math.abs(a-s.r)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.geom(t);return n?{x:n.cx-n.r,y:n.cy-n.r,w:n.r*2,h:n.r*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...de,...H]}}};var pa=class extends pe{constructor(){super(...arguments);this.type="rotatedrect";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"w",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=i[0]-n[0],a=i[1]-n[1],l=Math.hypot(s,a);if(l<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let c=-a/l,u=s/l,d=(o[0]-n[0])*c+(o[1]-n[1])*u,h=c*d,p=u*d,m=n,f=i,g=[i[0]+h,i[1]+p],b=[n[0]+h,n[1]+p];return {segments:[[m[0],m[1],f[0],f[1]],[f[0],f[1],g[0],g[1]],[g[0],g[1],b[0],b[1]],[b[0],b[1],m[0],m[1]]],fill:[m,f,g,b]}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B.map(t=>({...t,label:t.label.replace("Line","Border")})),...de,...H]}}};var ma=class extends Rn{constructor(){super(...arguments);this.type="path";}};var vm=40,fa=class extends pe{constructor(){super(...arguments);this.type="arc";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"apex",free:"both"}]}}pinApex(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];t&&n&&i&&(i.time=(t.time+n.time)/2);}onPlaced(){this.pinApex();}constrainHandleDrag(){this.pinApex();}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.anchors[2];if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=t.yOf(o.price,this.paneId);if(s==null)return null;let a=(n[0]+i[0])/2,l=(n[1]+i[1])/2,c=(i[0]-n[0])/2,u=(i[1]-n[1])/2,d=Math.hypot(c,u);if(d<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let h=-u/d,p=c/d,m=(s-l)*p;m<0&&(h=-h,p=-p);let f=Math.abs(m),g=[];for(let y=0;y<=vm;y+=1){let v=y/vm*Math.PI,S=Math.cos(v),E=Math.sin(v);g.push([a+S*c+E*f*h,l+S*u+E*f*p]);}let b=[];for(let y=1;y<g.length;y+=1)b.push([g[y-1][0],g[y-1][1],g[y][0],g[y][1]]);return b.push([g[g.length-1][0],g[g.length-1][1],g[0][0],g[0][1]]),{segments:b,fill:g}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B.map(t=>({...t,label:t.label.replace("Line","Border")})),...de,...H]}}};var ym=40,ga=class extends pe{constructor(){super(...arguments);this.type="curve";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"control",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=[];for(let l=0;l<=ym;l+=1){let c=l/ym,u=1-c;s.push([u*u*n[0]+2*u*c*o[0]+c*c*i[0],u*u*n[1]+2*u*c*o[1]+c*c*i[1]]);}let a=[];for(let l=1;l<s.length;l+=1)a.push([s[l-1][0],s[l-1][1],s[l][0],s[l][1]]);return {segments:a,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...B,...de,...H]}}};var z0={head:11,headW:9,stemW:3.5,len:22},ar=class extends G{anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}glyphPoints(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=e.xOf(t.time),{head:o,headW:s,stemW:a,len:l}=z0,c=[[0,0],[-s,o],[-a,o],[-a,l],[a,l],[a,o],[s,o]],u=this.dir(),d=([h,p])=>{switch(u){case "up":return [h,p];case "down":return [h,-p];case "left":return [p,h];default:return [-p,h]}};return c.map(h=>{let[p,m]=d(h);return [i+p,n+m]})}hitTest(e,t,n,i){let o=this.glyphPoints(n);return o!=null&&Bt(e,t,o)}handlePoints(e){let t=this.anchors[0];if(!t)return [];let n=e.yOf(t.price,this.paneId);return n==null?[]:[[e.xOf(t.time),n]]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.glyphPoints(e);if(!t)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...H]}}},Ki=class extends ar{constructor(){super(...arguments);this.type="arrowmarkup";}dir(){return "up"}},Xi=class extends ar{constructor(){super(...arguments);this.type="arrowmarkdown";}dir(){return "down"}};var Zi=["\u2605","\u2606","\u25CF","\u25C6","\u25B2","\u25BC","\u27A4","\u2691","\u271A","\u2715","\u2764","\u2666"],ba=["small","normal","large","huge"],wm={small:16,normal:22,large:32,huge:44},lr=class extends G{constructor(e){super(e),this.glyph||(this.glyph=this.defaultGlyph()),this.size||(this.size="normal");}sizePx(){return wm[this.size]??wm.normal}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}center(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);return n==null?null:[e.xOf(t.time),n]}hitTest(e,t,n,i){let o=this.center(n);if(!o)return false;let s=this.sizePx()/2+i;return Math.abs(e-o[0])<=s&&Math.abs(t-o[1])<=s}handlePoints(e){let t=this.center(e);return t?[t]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.center(e);if(!t)return null;let n=this.sizePx();return {x:t[0]-n/2,y:t[1]-n/2,w:n,h:n}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"glyph",label:"Icon",kind:"select",options:Zi.map(e=>({value:e,label:e})),group:"line"},{path:"size",label:"Size",kind:"select",options:ba.map(e=>({value:e,label:e})),group:"line"},{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...H]}}writeProps(){return {glyph:this.glyph,size:this.size}}readProps(e){typeof e.glyph=="string"&&(this.glyph=e.glyph),typeof e.size=="string"&&(this.size=e.size);}},ji=class extends lr{constructor(){super(...arguments);this.type="flagmark";}defaultGlyph(){return "\u2691"}},qi=class extends lr{constructor(){super(...arguments);this.type="iconstamp";}defaultGlyph(){return "\u2605"}};var xm=r=>r==="small"||r==="normal"||r==="large"||r==="huge";function $0(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var fe=class extends G{constructor(e){super(e),this.levels||(this.levels=this.defaultLevels().map(t=>({...t}))),this.numbersSize||(this.numbersSize="small"),this.labelsSize||(this.labelsSize="normal");}fillBands(e){return []}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}hitTest(e,t,n,i){let o=this.entryLines(n);return o!=null&&o.some(s=>ne(e,t,s.x1,s.y1,s.x2,s.y2)<=i)}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}schema(){return {fields:B.filter(e=>e.path!=="style.lineColor")}}writeProps(){return {levels:this.levels.map(e=>({...e})),numbersSize:this.numbersSize,labelsSize:this.labelsSize}}readProps(e){if(Array.isArray(e.levels)){let t=e.levels.map($0).filter(n=>n!=null);t.length&&(this.levels=t);}xm(e.numbersSize)&&(this.numbersSize=e.numbersSize),xm(e.labelsSize)&&(this.labelsSize=e.labelsSize);}};var Yr=class extends fe{levelLines(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.xOf(t.time),o=e.xOf(n.time),s=Math.min(i,o),a=Math.max(i,o),l=n.price-t.price,c=[];for(let u of this.levels){if(!u.enabled)continue;let d=t.price+u.ratio*l,h=e.yOf(d,this.paneId);h!=null&&c.push({ratio:u.ratio,color:u.color,label:u.label,price:d,x1:s,x2:a,y:h});}return c}entryLines(e){let t=this.levelLines(e);return t?t.map(n=>({color:n.color,label:n.label,x1:n.x1,y1:n.y,x2:n.x2,y2:n.y,numberText:`${n.ratio} (${n.price.toFixed(2)})`,numberX:n.x1+4,numberY:n.y-7,numberAlign:"left",labelX:(n.x1+n.x2)/2,labelY:n.y-7})):null}fillBands(e){let t=this.levelLines(e);if(!t)return [];let n=[];for(let i=1;i<t.length;i+=1){let o=t[i-1],s=t[i];n.push({color:s.color,x:o.x1,y:Math.min(o.y,s.y),w:o.x2-o.x1,h:Math.abs(s.y-o.y)});}return n}priceRange(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return null;let n=t.price-e.price,i=this.levels.filter(o=>o.enabled).map(o=>e.price+o.ratio*n);return i.length===0?null:{min:Math.min(...i),max:Math.max(...i)}}};var cr=J,zt=W,$t=ue,ur="#4caf50",Dn=z,dn=Je,dr="#9c27b0",W0="#e91e63",Iu="#26a69a",G0="#ab47bc",U0="#ef5350",Sm="#ffb74d",Y0="#38c0fd",va="#b2b5be",Kr=[Y0,dn,Dn,ur,$t,zt,W0,dr,cr,Iu,G0,U0];function Cm(r){return Kr[(r%Kr.length+Kr.length)%Kr.length]}var K0=[[0,cr],[.125,zt],[.236,zt],[.25,zt],[.382,$t],[.5,ur],[.618,Dn],[.75,dn],[.786,dn],[1,cr],[1.272,dn],[1.382,$t],[1.618,zt],[2,cr],[2.382,$t],[2.618,$t],[3,cr],[4.236,ur],[6.854,Dn],[11.09,dn]];function X0(r,e=0){return K0.find(([t])=>t===r)?.[1]??Cm(e)}function me(r){return r.map((e,t)=>{let n=typeof e=="number"?{ratio:e}:e;return {ratio:n.ratio,color:n.color??X0(n.ratio,t),enabled:n.enabled!==false,...n.label?{label:n.label}:{}}})}function Tm(r,e=r){return Array.from({length:r},(t,n)=>({ratio:n+1,color:Cm(n),enabled:n<e,label:String(n+1)}))}var j0=me([0,.236,.382,.5,.618,.786,1]),ya=class extends Yr{constructor(){super(...arguments);this.type="fibretracement";}defaultLevels(){return j0}};var q0=me([0,.382,.618,1,1.272,1.618,{ratio:2.618,color:dr}]),wa=class extends Yr{constructor(){super(...arguments);this.type="fibextension";}defaultLevels(){return q0}};var Z0=me([0,.382,.5,.618,1,1.618,{ratio:2.618,color:dr}]),xa=class extends fe{constructor(){super(...arguments);this.type="fibextensiontrend";}anchorSchema(){return {min:3,max:3,slots:[{role:"a",free:"both"},{role:"b",free:"both"},{role:"c",free:"both"}]}}defaultLevels(){return Z0}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.price-n.price,a=[t.xOf(n.time),t.xOf(i.time),t.xOf(o.time)],l=Math.min(...a),c=Math.max(...a),u=[];for(let d of this.levels){if(!d.enabled)continue;let h=o.price+d.ratio*s,p=t.yOf(h,this.paneId);p!=null&&u.push({color:d.color,label:d.label,x1:l,y1:p,x2:c,y2:p,numberText:`${d.ratio} (${h.toFixed(2)})`,numberX:l+4,numberY:p-7,numberAlign:"left",labelX:(l+c)/2,labelY:p-7});}return u}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n||!i)return null;let o=n.price-t.price,s=this.levels.filter(a=>a.enabled).map(a=>i.price+a.ratio*o);return s.push(t.price,n.price,i.price),{min:Math.min(...s),max:Math.max(...s)}}};var J0=me([.236,.382,.5,.618,.786,1]),Sa=class extends fe{constructor(){super(...arguments);this.type="fibfan";}defaultLevels(){return J0}fanLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let u of this.levels){if(!u.enabled)continue;let d=t.yOf(n.price+u.ratio*l,this.paneId);if(d==null)continue;let[h,p,m,f]=Se(o,s,a,d,"right",t.width,t.height);c.push({ratio:u.ratio,color:u.color,label:u.label,x1:h,y1:p,x2:m,y2:f,labelX:a+5,labelY:d});}return c}entryLines(t){let n=this.fanLines(t);return n?n.map(i=>({color:i.color,label:i.label,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,numberText:String(i.ratio),numberX:i.labelX,numberY:i.labelY,numberAlign:"left",labelX:i.labelX,labelY:i.labelY+13})):null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Q0=[0,1,2,3,5,8,13,21,34].map(r=>({ratio:r,color:O,enabled:true})),Ca=class extends fe{constructor(){super(...arguments);this.type="fibtimezones";}defaultLevels(){return Q0}zoneLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=i.time-n.time;if(Math.abs(o)<1e-9)return null;let s=[];for(let a of this.levels)a.enabled&&s.push({n:a.ratio,color:a.color,label:a.label,x:t.xOf(n.time+a.ratio*o)});return s}entryLines(t){let n=this.zoneLines(t);if(!n)return null;let i=t.height;return n.map(o=>({color:o.color,label:o.label,x1:o.x,y1:0,x2:o.x,y2:i,numberText:String(o.n),numberX:o.x,numberY:9,numberAlign:"center",labelX:o.x,labelY:24}))}priceRange(){return null}timeExtent(){return null}};var eS=me([0,.236,.382,.5,.618,.786,1,1.618,2.618]),Ta=class extends fe{constructor(){super(...arguments);this.type="fibchannel";}defaultLevels(){return eS}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=0,u=0,d=this.anchors[2];if(d){let p=t.yOf(d.price,this.paneId);if(p==null)return null;c=t.xOf(d.time)-a,u=p-o;}let h=[];for(let p of this.levels){if(!p.enabled)continue;let m=p.ratio*c,f=p.ratio*u,g=l+m,b=s+f;h.push({color:p.color,label:p.label,x1:a+m,y1:o+f,x2:g,y2:b,numberText:String(p.ratio),numberX:g+5,numberY:b,numberAlign:"left",labelX:g+5,labelY:b+13});}return h}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n)return null;let o=i?i.price-t.price:0,s=1/0,a=-1/0;for(let l of this.levels)if(l.enabled)for(let c of [t.price,n.price]){let u=c+l.ratio*o;u<s&&(s=u),u>a&&(a=u);}return s<=a?{min:s,max:a}:null}};var tS=me([0,.236,.382,.5,.618,.786,1]),ka=class extends fe{constructor(){super(...arguments);this.type="fibspeedfan";}defaultLevels(){return tS}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),c=t.xOf(i.time)-a,u=s-o,d=c>=0?"right":"left",h=t.width,p=t.height,m=[];for(let f of this.levels){if(!f.enabled)continue;let g=a+c,b=o+u*f.ratio,y=Se(a,o,g,b,d,h,p);if(m.push({color:f.color,label:f.label,x1:y[0],y1:y[1],x2:y[2],y2:y[3],numberText:String(f.ratio),numberX:d==="right"?g+5:g-5,numberY:b,numberAlign:d==="right"?"left":"right",labelX:g,labelY:b}),f.ratio===1)continue;let v=a+c*f.ratio,S=o+u,E=Se(a,o,v,S,d,h,p);m.push({color:f.color,label:f.label,x1:E[0],y1:E[1],x2:E[2],y2:E[3],numberText:String(f.ratio),numberX:v,numberY:S+(u>=0?12:-12),numberAlign:"center",labelX:v,labelY:S+12});}return m}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var nS=me([0,.382,{ratio:.5,enabled:false},.618,1,1.382,1.618,2,2.382,2.618,3]),Ea=class extends fe{constructor(){super(...arguments);this.type="trendfibtime";}defaultLevels(){return nS}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"p3",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.time-n.time;if(Math.abs(s)<1e-9)return null;let a=t.height,l=[];for(let c of this.levels){if(!c.enabled)continue;let u=t.xOf(o.time+c.ratio*s);l.push({color:c.color,label:c.label,x1:u,y1:0,x2:u,y2:a,numberText:String(c.ratio),numberX:u,numberY:9,numberAlign:"center",labelX:u,labelY:24});}return l}priceRange(){return null}timeExtent(){return null}};function rS(r,e,t){if(t-e>=Math.PI*2-.001)return true;let n=r-e,i=Math.PI*2;for(;n<0;)n+=i;for(;n>=i;)n-=i;return n<=t-e+1e-6}var kt=class extends fe{boundingLines(e){return []}entryLines(e){return []}hitTest(e,t,n,i){let o=this.radial(n);if(o){let s=Math.hypot(e-o.cx,t-o.cy),a=Math.atan2(t-o.cy,e-o.cx);if(rS(a,o.a0,o.a1)){for(let l of this.levels)if(l.enabled&&Math.abs(s-o.R0*l.ratio)<=i)return true}}return this.boundingLines(n).some(s=>ne(e,t,s[0],s[1],s[2],s[3])<=i)}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}};var iS=me([.236,.382,.5,.618,.786,1,1.618,2.618]),La=class extends kt{constructor(){super(...arguments);this.type="fibcircles";}defaultLevels(){return iS}radial(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,R0:Math.hypot(l-a,s-o),a0:0,a1:Math.PI*2}}};var oS=me([.236,.382,.5,.618,.786,1,1.618,2.618]),Ma=class extends kt{constructor(){super(...arguments);this.type="fibarcs";}defaultLevels(){return oS}pts(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{cx:t.xOf(n.time),cy:o,ex:t.xOf(i.time),ey:s}}radial(t){let n=this.pts(t);if(!n)return null;let i=Math.hypot(n.ex-n.cx,n.ey-n.cy),o=Math.atan2(n.ey-n.cy,n.ex-n.cx);return {cx:n.cx,cy:n.cy,R0:i,a0:o-Math.PI/2,a1:o+Math.PI/2}}boundingLines(t){let n=this.pts(t);return n?[[n.cx,n.cy,n.ex,n.ey]]:[]}};var sS=me([.236,.382,.5,.618,.786,1]),Pa=class extends kt{constructor(){super(...arguments);this.type="fibwedge";}defaultLevels(){return sS}anchorSchema(){return {min:3,max:3,slots:[{role:"apex",free:"both"},{role:"radius",free:"both"},{role:"angle",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}radial(t){let n=this.px(t,0),i=this.px(t,1),o=this.px(t,2);if(!n||!i||!o)return null;let s=Math.hypot(i[0]-n[0],i[1]-n[1]);if(s<1)return null;let a=Math.atan2(i[1]-n[1],i[0]-n[0]),l=Math.atan2(o[1]-n[1],o[0]-n[0]),c=Math.min(a,l),u=Math.max(a,l);return u-c>Math.PI&&([c,u]=[u,c+Math.PI*2]),{cx:n[0],cy:n[1],R0:s,a0:c,a1:u}}boundingLines(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return [];let o=[[n[0],n[1],i[0],i[1]]],s=this.px(t,2);if(s){let a=Math.hypot(i[0]-n[0],i[1]-n[1]),l=Math.hypot(s[0]-n[0],s[1]-n[1]);l>1e-6&&o.push([n[0],n[1],n[0]+(s[0]-n[0])/l*a,n[1]+(s[1]-n[1])/l*a]);}return o}};var aS=1.6180339887,km=Math.log(aS)/(Math.PI/2),lS=Math.PI/64,cS=Math.PI,uS=.5,hr=class extends G{constructor(){super(...arguments);this.type="fibspiral";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}spiralPoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=Math.hypot(l-a,s-o);if(c<1)return null;let u=Math.atan2(s-o,l-a),d=Math.max(Math.log(uS/c)/km,-8*Math.PI*2),h=[];for(let p=d;p<=cS;p+=lS){let m=c*Math.exp(km*p),f=u+p;h.push([a+m*Math.cos(f),o+m*Math.sin(f)]);}return h}hitTest(t,n,i,o){let s=this.spiralPoints(i);return s!=null&&s.length>=2&&Gr(t,n,s)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.handlePoints(t);if(n.length<2)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,...H]}}};var dS=me([{ratio:.125,color:zt,label:"1/8"},{ratio:.25,color:$t,label:"1/4"},{ratio:.333,color:Sm,label:"1/3"},{ratio:.5,color:ur,label:"1/2"},{ratio:1,color:va,label:"1/1"},{ratio:2,color:Dn,label:"2/1"},{ratio:3,color:dn,label:"3/1"},{ratio:4,color:Iu,label:"4/1"},{ratio:8,color:dr,label:"8/1"}]),Ia=class extends fe{constructor(){super(...arguments);this.type="gannfan";}defaultLevels(){return dS}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let u of this.levels){if(!u.enabled)continue;let d=t.yOf(n.price+l*u.ratio,this.paneId);if(d==null)continue;let[h,p,m,f]=Se(o,s,a,d,"right",t.width,t.height);c.push({color:u.color,x1:h,y1:p,x2:m,y2:f,numberText:u.label??String(u.ratio),numberX:a+5,numberY:d,numberAlign:"left",labelX:a+5,labelY:d});}return c}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var hS=me([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),Aa=class extends fe{constructor(){super(...arguments);this.type="gannbox";}defaultLevels(){return hS}corners(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);return a==null||l==null?null:{c1:n,c2:i,left:Math.min(o,s),right:Math.max(o,s),top:Math.min(a,l),bot:Math.max(a,l)}}entryLines(t){let n=this.corners(t);if(!n)return null;let{c1:i,c2:o,left:s,right:a,top:l,bot:c}=n,u=[];for(let h of this.levels){if(!h.enabled)continue;let p=t.yOf(i.price+h.ratio*(o.price-i.price),this.paneId);p!=null&&u.push({color:h.color,x1:s,y1:p,x2:a,y2:p,numberText:h.label??String(h.ratio),numberX:s-5,numberY:p,numberAlign:"right",labelX:s,labelY:p});let m=t.xOf(i.time+h.ratio*(o.time-i.time));u.push({color:h.color,x1:m,y1:l,x2:m,y2:c,numberText:"",numberX:m,numberY:l,numberAlign:"center",labelX:m,labelY:l});}let d=this.levels.find(h=>h.ratio===1)?.color??cr;return u.push({color:d,x1:s,y1:l,x2:a,y2:c,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),u.push({color:d,x1:s,y1:c,x2:a,y2:l,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),u}hitTest(t,n,i,o){let s=this.corners(i);return s!=null&&Ve(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var pS=me([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),mS=[{label:"3x1",x:3,y:1,color:zt},{label:"2x1",x:2,y:1,color:$t},{label:"1x1",x:1,y:1,color:va},{label:"1x2",x:1,y:2,color:Dn},{label:"1x3",x:1,y:3,color:dn}],Au=[{k:.25,color:zt},{k:.5,color:$t},{k:.75,color:ur},{k:1,color:Dn}],pr=class extends fe{constructor(){super(...arguments);this.type="gannsquare";}defaultLevels(){return pS}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {ox:a,oy:o,bx:l-a,py:s-o,left:Math.min(a,l),top:Math.min(o,s),right:Math.max(a,l),bot:Math.max(o,s)}}arcGeom(t){let n=this.box(t);return n?{ox:n.ox,oy:n.oy,bx:n.bx,py:n.py}:null}entryLines(t){let n=this.box(t);if(!n)return null;let i=this.anchors[0],o=this.anchors[1],s=[];for(let a of this.levels){if(!a.enabled)continue;let l=t.yOf(i.price+a.ratio*(o.price-i.price),this.paneId);l!=null&&s.push({color:a.color,x1:n.left,y1:l,x2:n.right,y2:l,numberText:a.label??String(a.ratio),numberX:n.left-5,numberY:l,numberAlign:"right",labelX:n.left,labelY:l});let c=t.xOf(i.time+a.ratio*(o.time-i.time));s.push({color:a.color,x1:c,y1:n.top,x2:c,y2:n.bot,numberText:"",numberX:c,numberY:n.top,numberAlign:"center",labelX:c,labelY:n.top});}for(let a of mS){let l,c;a.x>a.y?(l=n.ox+n.bx,c=n.oy+a.y/a.x*n.py):(c=n.oy+n.py,l=n.ox+a.x/a.y*n.bx),s.push({color:a.color,x1:n.ox,y1:n.oy,x2:l,y2:c,numberText:a.label,numberX:l+4,numberY:c,numberAlign:"left",labelX:l+4,labelY:c});}return s}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&Ve(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Ru=[4,8,12,16,24,32,48,64],fS=24,gS=.75;function Em(r,e){if(!Number.isInteger(r)||!Number.isInteger(e)||e<=0)return false;let t=r*r-1;return e%2===1?t%e===0:e%8===0?t%e!==0?false:t/e%2!==0:false}function Lm(r){let e=[];for(let t=0;t<r;t+=1)Em(t,r)&&e.push(t);return e}var mr=class extends G{constructor(t){super(t);this.type="dedekind";this.maxCurvature===void 0&&(this.maxCurvature=fS);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=Math.min(t.xOf(n.time),t.xOf(i.time)),l=Math.max(t.xOf(n.time),t.xOf(i.time)),c=Math.min(o,s),u=Math.max(o,s),d=l-a,h=u-c;if(d<1||h<1)return null;let p=h,m=d/p;return {left:a,right:l,top:c,bot:u,unitPx:p,x0:0,realSpan:m}}geodesics(t){let n=this.box(t);if(!n)return null;let{left:i,top:o,bot:s,unitPx:a,x0:l,realSpan:c}=n,u=Math.max(1,Math.min(64,Math.round(this.maxCurvature))),d=l-1/u,h=l+c+1/u,p=i+c*a,m=[],f=Math.floor(d*2),g=Math.ceil(h*2);for(let b=f;b<=g;b+=1){if(b%2===0)continue;let y=i+(b/2-l)*a;y<i-.5||y>p+.5||m.push({kind:"vline",x:y,y0:s,y1:o});}for(let b=1;b<=u;b+=1){let y=1/b,v=y*a;if(v<gS)continue;let S=Lm(b);if(S.length===0)continue;let E=Math.floor(d)-1,T=Math.ceil(h)+1;for(let k=E;k<=T;k+=1)for(let x of S){let L=x/b+k;if(L+y<d||L-y>h)continue;let w=i+(L-l)*a;w+v<i-1||w-v>p+1||m.push({kind:"arc",cx:w,cy:s,r:v});}}return m}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&Ve(t,n,s.left,s.top,s.right,s.bot,o)}handlePoints(t){let n=this.box(t);return n?[[n.left,n.top],[n.right,n.bot]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);return n?{x:n.left,y:n.top,w:n.right-n.left,h:n.bot-n.top}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...B,{path:"maxCurvature",label:"Max curvature",kind:"number",min:4,max:64,step:4,group:"behavior"},...H]}}writeProps(){return {maxCurvature:this.maxCurvature}}readProps(t){typeof t.maxCurvature=="number"&&Number.isFinite(t.maxCurvature)&&(this.maxCurvature=Math.max(1,Math.min(64,Math.round(t.maxCurvature))));}};var Du=[3,4,5,6,8,10,12],Ou=[1.5,2,2.5,3,4,5],Ra=6,bS=2;function Nu(r=Ra){return [...Tm(Kr.length,r)]}function vS(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var Xr={path:"showRatios",label:"Show ratios",kind:"boolean",group:"behavior"},Qe=class extends G{constructor(e){super(e),this.waveCount===void 0&&(this.waveCount=Ra),this.showRatios===void 0&&(this.showRatios=true);let t=Array.isArray(e.props?.levels);this.levels||(this.levels=this.defaultLevels().map(n=>({...n}))),!t&&this.shouldSyncWaveCount()&&this.syncLevelsToWaveCount();}shouldSyncWaveCount(){return true}syncLevelsToWaveCount(){let e=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=e;for(let t=0;t<this.levels.length;t+=1)this.levels[t].enabled=t<e;}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"d1",free:"both"},{role:"d2",free:"both"}]}}geom(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);if(i==null||o==null)return null;let s=e.xOf(t.time),a=e.xOf(n.time),l=(s+a)/2,c=(i+o)/2,u=Math.hypot(a-s,o-i)/2;if(u<1)return null;let d=a-s,h=o-i,p=Math.hypot(d,h);p<1e-9?(d=1,h=0):(d/=p,h/=p);let m=this.levels.filter(T=>T.enabled&&T.ratio>0).slice().sort((T,k)=>T.ratio-k.ratio);if(m.length===0)return null;let f=Math.max(1,this.machNumber()),g=[];for(let T of m){let k=T.ratio*u;g.push({cx:l+f*(k-u)*d,cy:c+f*(k-u)*h,r:k,color:T.color,ratio:T.ratio});}let b=l-f*u*d,y=c-f*u*h,v=g[g.length-1].r,S=f*v+2*u,E=[];if(f<=1+1e-9){let T=-h,k=d;E.push([b-T*S,y-k*S,b+T*S,y+k*S]);}else {let T=Math.asin(1/f),k=Math.cos(T),x=Math.sin(T),L=(A,$,ie)=>[A*k-$*ie*x,A*ie*x+$*k],[w,M]=L(d,h,1),[P,C]=L(d,h,-1);E.push([b,y,b+w*S,y+M*S]),E.push([b,y,b+P*S,y+C*S]);}return {c0x:l,c0y:c,R:u,fx:d,fy:h,noseX:b,noseY:y,circles:g,rays:E}}hitTest(e,t,n,i){let o=this.geom(n);if(!o)return false;for(let s of o.circles)if(Math.abs(Math.hypot(e-s.cx,t-s.cy)-s.r)<=i)return true;return o.rays.some(s=>ne(e,t,s[0],s[1],s[2],s[3])<=i)}handlePoints(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return [];let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?[]:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.geom(e);if(!t)return null;let n=t.noseX,i=t.noseX,o=t.noseY,s=t.noseY;for(let a of t.circles)n=Math.min(n,a.cx-a.r),i=Math.max(i,a.cx+a.r),o=Math.min(o,a.cy-a.r),s=Math.max(s,a.cy+a.r);for(let a of t.rays)n=Math.min(n,a[0],a[2]),i=Math.max(i,a[0],a[2]),o=Math.min(o,a[1],a[3]),s=Math.max(s,a[1],a[3]);return {x:n,y:o,w:i-n,h:s-o}}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}applySettings(e){if(super.applySettings(e),Object.prototype.hasOwnProperty.call(e,"waveCount")&&typeof this.waveCount=="number"){let t=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=t;for(let n=0;n<this.levels.length;n+=1)this.levels[n].enabled=n<t;}}schema(){return {fields:[...B,{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},Xr,...H]}}writeProps(){return {waveCount:this.waveCount,showRatios:this.showRatios,levels:this.levels.map(e=>({...e}))}}readProps(e){if(typeof e.waveCount=="number"&&Number.isFinite(e.waveCount)&&(this.waveCount=Math.max(2,Math.min(12,Math.round(e.waveCount)))),typeof e.showRatios=="boolean"&&(this.showRatios=e.showRatios),Array.isArray(e.levels)){let t=e.levels.map(vS).filter(n=>n!=null);t.length&&(this.levels=t);}}},Ji=class extends Qe{constructor(){super(...arguments);this.type="sonic";}defaultLevels(){return Nu(Ra)}machNumber(){return 1}},Qi=class extends Qe{constructor(t){super(t);this.type="supersonic";this.mach===void 0&&(this.mach=bS);}defaultLevels(){return Nu(Ra)}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...B,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},Xr,...H]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var Mm=me([.236,.382,.5,.618,.786,1,1.618,2.618,4.236,6.854,11.09]),yS=2,Da=class extends Qe{constructor(){super(...arguments);this.type="goldensonic";}shouldSyncWaveCount(){return false}defaultLevels(){return Mm}machNumber(){return 1}schema(){return {fields:[...B,Xr,...H]}}},Oa=class extends Qe{constructor(t){super(t);this.type="goldensupersonic";this.mach===void 0&&(this.mach=yS);}shouldSyncWaveCount(){return false}defaultLevels(){return Mm}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...B,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},Xr,...H]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var Ne=class extends G{legRatios(){return false}fillTriangles(){return []}necklineIndices(){return null}anchorSchema(){let e=this.vertexLabels().length,t=[];for(let n=0;n<e;n+=1)t.push({role:`p${n}`,free:"both"});return {min:e,max:e,slots:t}}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitTest(e,t,n,i){let o=this.handlePoints(n);return o.length>=2&&Gr(e,t,o)<=i}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}patternName(){return null}ratioOk(e){return null}valid(){return null}ratioAt(e){let t=this.anchors[e-2],n=this.anchors[e-1],i=this.anchors[e];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}schema(){return {fields:[...B,...this.fillTriangles().length?de:[]]}}};var Na=class extends Ne{constructor(){super(...arguments);this.type="xabcd";}vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}};var Fa=class extends Ne{constructor(){super(...arguments);this.type="abcd";}vertexLabels(){return ["A","B","C","D"]}legRatios(){return true}};var Va=class extends Ne{constructor(){super(...arguments);this.type="elliottimpulse";}vertexLabels(){return ["1","2","3","4","5"]}};var _a=class extends Ne{constructor(){super(...arguments);this.type="elliottcorrection";}vertexLabels(){return ["A","B","C"]}};var Ba=class extends Ne{constructor(){super(...arguments);this.type="headshoulders";}vertexLabels(){return ["","LS","","H","","RS",""]}necklineIndices(){return [2,4]}};var et=class extends Ne{vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}legValue(e){let[t,n,i,o,s]=this.anchors;if(!t||!n||!i||!o||!s)return null;let a=(d,h)=>Math.abs(h.price-d.price),l=a(t,n),c=a(n,i),u=a(i,o);switch(e){case "ab":return l<1e-9?null:c/l;case "bc":return c<1e-9?null:u/c;case "cd":return u<1e-9?null:a(o,s)/u;default:return l<1e-9?null:a(n,s)/l}}inBand(e,t){return e!=null&&e>=t.min&&e<=t.max}ratioOk(e){let t=this.ranges();return e===2?this.inBand(this.legValue("ab"),t.ab):e===3?this.inBand(this.legValue("bc"),t.bc):e===4?this.inBand(this.legValue("cd"),t.cd):null}valid(){if(this.anchors.length<5)return null;let e=this.ranges();return this.inBand(this.legValue("ab"),e.ab)&&this.inBand(this.legValue("bc"),e.bc)&&this.inBand(this.legValue("cd"),e.cd)&&this.inBand(this.legValue("ad"),e.ad)}};var Ha=class extends et{constructor(){super(...arguments);this.type="gartley";}patternName(){return "Gartley"}ranges(){return {ab:{min:.55,max:.68},bc:{min:.382,max:.886},cd:{min:1.13,max:1.618},ad:{min:.74,max:.83}}}};var za=class extends et{constructor(){super(...arguments);this.type="bat";}patternName(){return "Bat"}ranges(){return {ab:{min:.382,max:.5},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:.84,max:.92}}}};var $a=class extends et{constructor(){super(...arguments);this.type="butterfly";}patternName(){return "Butterfly"}ranges(){return {ab:{min:.74,max:.83},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:1.272,max:1.618}}}};var Wa=class extends et{constructor(){super(...arguments);this.type="crab";}patternName(){return "Crab"}ranges(){return {ab:{min:.382,max:.618},bc:{min:.382,max:.886},cd:{min:2.618,max:3.618},ad:{min:1.55,max:1.69}}}};var Ga=class extends et{constructor(){super(...arguments);this.type="shark";}patternName(){return "Shark"}ranges(){return {ab:{min:.382,max:.618},bc:{min:1.13,max:1.618},cd:{min:1.618,max:2.24},ad:{min:.886,max:1.13}}}};var wS={min:1.272,max:1.414},xS={min:.74,max:.83},Ua=class extends et{constructor(){super(...arguments);this.type="cypher";}patternName(){return "Cypher"}ranges(){return {ab:{min:.382,max:.618},bc:{min:0,max:1/0},cd:{min:0,max:1/0},ad:{min:0,max:1/0}}}xcOverXa(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[3];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-t.price)/o}cdOverXc(){let t=this.anchors[0],n=this.anchors[3],i=this.anchors[4];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}ratioOk(t){return t===2?this.inBand(this.legValue("ab"),this.ranges().ab):null}valid(){return this.anchors.length<5?null:this.inBand(this.legValue("ab"),this.ranges().ab)&&this.inBand(this.xcOverXa(),wS)&&this.inBand(this.cdOverXc(),xS)}};function Pm(r){return `${r>=0?"+":""}${r.toFixed(2)}`}function eo(r){let e=Math.abs(r),t=864e5,n=36e5,i=6e4;if(e>=t){let o=Math.floor(e/t),s=Math.round(e%t/n);return s?`${o}d ${s}h`:`${o}d`}if(e>=n){let o=Math.floor(e/n),s=Math.round(e%n/i);return s?`${o}h ${s}m`:`${o}h`}return e>=i?`${Math.round(e/i)}m`:`${Math.round(e/1e3)}s`}var fr=class extends G{constructor(e){super(e),this.showPrice===void 0&&(this.showPrice=true),this.showDate===void 0&&(this.showDate=true);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}measureLabel(e){let t=[];return this.showPrice&&t.push(this.priceLabel()),this.showDate&&t.push(this.timeLabel(e)),t}isUp(){let e=this.anchors[0],t=this.anchors[1];return e!=null&&t!=null&&t.price>=e.price}priceLabel(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return "";let n=t.price-e.price,i=e.price!==0?n/e.price*100:0;return `${Pm(n)} (${Pm(i)}%)`}timeLabel(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return "";let i=eo(n.time-t.time),o=e.barsBetween?Math.round(e.barsBetween(t.time,n.time)):null;return o!=null?`${o} bars, ${i}`:i}rect(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:{x1:e.xOf(t.time),y1:i,x2:e.xOf(n.time),y2:o}}hitTest(e,t,n,i){let o=this.rect(n);return o!=null&&Ve(e,t,o.x1,o.y1,o.x2,o.y2,i)}handlePoints(e){let t=this.rect(e);return t?[[t.x1,t.y1],[t.x2,t.y2]]:[]}hitHandle(e,t,n,i){return Y(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.rect(e);return t?{x:Math.min(t.x1,t.x2),y:Math.min(t.y1,t.y2),w:Math.abs(t.x2-t.x1),h:Math.abs(t.y2-t.y1)}:null}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[{path:"showPrice",label:"Show price",kind:"boolean",group:"behavior"},{path:"showDate",label:"Show date",kind:"boolean",group:"behavior"},...B.filter(e=>e.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Tt,group:"text"}]}}writeProps(){return {showPrice:this.showPrice,showDate:this.showDate}}readProps(e){typeof e.showPrice=="boolean"&&(this.showPrice=e.showPrice),typeof e.showDate=="boolean"&&(this.showDate=e.showDate);}};var Ya=class extends fr{constructor(){super(...arguments);this.type="datepricerange";}};var Ka=[{value:"long",label:"Long"},{value:"short",label:"Short"}],Ee=class Ee extends G{constructor(t){super(t);this.type="position";this.riskPercent===void 0&&(this.riskPercent=Ee.DEFAULT_RISK_PERCENT),this.accountBalance===void 0&&(this.accountBalance=Ee.DEFAULT_ACCOUNT_BALANCE),this.showText===void 0&&(this.showText=true),this.showHeader===void 0&&(this.showHeader=true),this.showPrices===void 0&&(this.showPrices=false),this.showLossSize===void 0&&(this.showLossSize=true),this.showTargetLabel===void 0&&(this.showTargetLabel=true),this.showStopLabel===void 0&&(this.showStopLabel=true),this.profitColor===void 0&&(this.profitColor=Ee.DEFAULT_PROFIT_COLOR),this.lossColor===void 0&&(this.lossColor=Ee.DEFAULT_LOSS_COLOR);}directionLabel(){let t=this.prices();return t&&t.target>=t.entry?"LONG":"SHORT"}get direction(){return this.directionLabel()==="LONG"?"long":"short"}set direction(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];!n||!i||!o||(t==="long"||t==="short")&&t!==this.direction&&(i.price=2*n.price-i.price,o.price=2*n.price-o.price);}get quantity(){return this.positionSize()}set quantity(t){let n=this.prices();if(!n||!Number.isFinite(t)||t<0)return;let i=Math.abs(n.entry-n.stop);i<1e-9||this.accountBalance<=0||(this.riskPercent=t*i/this.accountBalance*100);}get entryPrice(){return this.anchors[0]?.price??0}set entryPrice(t){let n=this.anchors[0];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(0));}get stopPrice(){return this.anchors[1]?.price??0}set stopPrice(t){let n=this.anchors[1];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(1));}get targetPrice(){return this.anchors[2]?.price??0}set targetPrice(t){let n=this.anchors[2];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(2));}anchorSchema(){return {min:2,max:2,slots:[{role:"entry",free:"both"},{role:"stop",free:"both"},{role:"target",free:"both"}]}}onPlaced(t){let n=this.anchors[0];if(!n)return;let i=t.xOf(n.time),o=t.yOf(n.price,this.paneId);if(o==null)return;let s=this.anchors[1],a=s?t.yOf(s.price,this.paneId):null,l,c;s&&a!=null&&Math.abs(a-o)>=Ee.MIN_DRAG_PX?(l=a,c=i+Math.max(Math.abs(t.xOf(s.time)-i),Ee.MIN_WIDTH_PX)):(l=o-Ee.DEFAULT_RISK_PX*Ee.DEFAULT_RR,c=i+Ee.DEFAULT_WIDTH_PX);let u=o-(l-o)/Ee.DEFAULT_RR,d=t.pxToPoint(c,o,this.paneId).time;this.anchors=[{time:n.time,price:n.price},{time:d,price:t.pxToPoint(i,u,this.paneId).price},{time:d,price:t.pxToPoint(i,l,this.paneId).price}];}constrainHandleDrag(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return;let s=Math.sign(i.price-n.price),a=Math.sign(o.price-n.price);s===0||a===0||s!==a||(t===2?i.price=2*n.price-i.price:o.price=2*n.price-o.price);}resolved(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;if(this.anchors[2])return [t,n,this.anchors[2]];let i={time:n.time,price:t.price-(n.price-t.price)/Ee.DEFAULT_RR};return [t,i,n]}prices(){let t=this.resolved();return t?{entry:t[0].price,stop:t[1].price,target:t[2].price}:null}rr(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:Math.abs(t.target-t.entry)/n}rewardPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.target-t.entry)/t.entry*100:0}riskPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.entry-t.stop)/t.entry*100:0}dollarLoss(){return Math.max(0,this.accountBalance)*(Math.max(0,this.riskPercent)/100)}positionSize(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:this.dollarLoss()/n}headerLabel(){return `${this.directionLabel()} \xB7 R:R ${this.rr().toFixed(2)}`}lossSizeLabel(){return `Loss $${SS(this.dollarLoss())} \xB7 Size ${CS(this.positionSize())}`}targetLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Im(t.target)}`:"";return `Target +${this.rewardPct().toFixed(2)}%${n}`}stopLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Im(t.stop)}`:"";return `Stop \u2212${this.riskPct().toFixed(2)}%${n}`}levelDisplayValue(t,n){let i=this.prices();if(!i)return 0;let o=t==="stop"?i.stop:i.target;return Am(n==="price"?o:Math.abs(o-i.entry))}levelPriceFromDisplay(t,n,i){let o=this.prices();if(!o||n==="price")return i;let s=t==="stop"?o.stop:o.target,a=Math.sign(s-o.entry);return a===0&&(a=(t==="target"?1:-1)*(this.direction==="long"?1:-1)),o.entry+a*Math.abs(i)}box(t){let n=this.handlePoints(t);if(n.length<3)return null;let i=n.map(o=>o[0]);return {x1:Math.min(...i),x2:Math.max(...i),ey:n[0][1],sy:n[1][1],ty:n[2][1]}}layout(t){return this.box(t)}hitTest(t,n,i,o){let s=this.box(i);if(!s)return false;let a=Math.min(s.ey,s.sy,s.ty),l=Math.max(s.ey,s.sy,s.ty);return Ve(t,n,s.x1,a,s.x2,l,o)}handlePoints(t){let n=this.resolved();if(!n)return [];let i=[];for(let o of n){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);if(!n)return null;let i=Math.min(n.ey,n.sy,n.ty);return {x:n.x1,y:i,w:n.x2-n.x1,h:Math.max(n.ey,n.sy,n.ty)-i}}priceRange(){let t=this.resolved();if(!t)return null;let n=t.map(i=>i.price);return {min:Math.min(...n),max:Math.max(...n)}}schema(){return {fields:[{path:"riskPercent",label:"Risk %",kind:"number",min:0,max:100,step:.1,group:"behavior"},{path:"accountBalance",label:"Account balance",kind:"number",min:0,max:1e12,step:1,group:"behavior"},{path:"quantity",label:"Position size",kind:"number",group:"behavior"},{path:"direction",label:"Direction",kind:"select",options:Ka,group:"behavior"},{path:"entryPrice",label:"Entry price",kind:"number",group:"behavior"},{path:"stopPrice",label:"Stop price",kind:"number",group:"behavior"},{path:"targetPrice",label:"Target price",kind:"number",group:"behavior"},{path:"showText",label:"Show text",kind:"boolean",group:"behavior"},{path:"showHeader",label:"Show direction & ratio",kind:"boolean",group:"behavior"},{path:"showLossSize",label:"Show loss & size",kind:"boolean",group:"behavior"},{path:"showTargetLabel",label:"Show target label",kind:"boolean",group:"behavior"},{path:"showStopLabel",label:"Show stop label",kind:"boolean",group:"behavior"},{path:"showPrices",label:"Show level prices",kind:"boolean",group:"behavior"},{path:"profitColor",label:"Profit zone",kind:"color",group:"fill"},{path:"lossColor",label:"Loss zone",kind:"color",group:"fill"},...B.filter(t=>t.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Tt,group:"text"}]}}writeProps(){return {riskPercent:this.riskPercent,accountBalance:this.accountBalance,showText:this.showText,showHeader:this.showHeader,showPrices:this.showPrices,showLossSize:this.showLossSize,showTargetLabel:this.showTargetLabel,showStopLabel:this.showStopLabel,profitColor:this.profitColor,lossColor:this.lossColor}}readProps(t){typeof t.riskPercent=="number"&&Number.isFinite(t.riskPercent)&&(this.riskPercent=t.riskPercent),typeof t.accountBalance=="number"&&Number.isFinite(t.accountBalance)&&(this.accountBalance=t.accountBalance),typeof t.showText=="boolean"&&(this.showText=t.showText),typeof t.showHeader=="boolean"&&(this.showHeader=t.showHeader),typeof t.showPrices=="boolean"&&(this.showPrices=t.showPrices),typeof t.showLossSize=="boolean"&&(this.showLossSize=t.showLossSize),typeof t.showTargetLabel=="boolean"&&(this.showTargetLabel=t.showTargetLabel),typeof t.showStopLabel=="boolean"&&(this.showStopLabel=t.showStopLabel),typeof t.profitColor=="string"&&(this.profitColor=t.profitColor),typeof t.lossColor=="string"&&(this.lossColor=t.lossColor);}};Ee.DEFAULT_RR=2,Ee.MIN_DRAG_PX=6,Ee.DEFAULT_RISK_PX=64,Ee.DEFAULT_WIDTH_PX=150,Ee.MIN_WIDTH_PX=48,Ee.DEFAULT_RISK_PERCENT=1,Ee.DEFAULT_ACCOUNT_BALANCE=1e4,Ee.DEFAULT_PROFIT_COLOR=Hs,Ee.DEFAULT_LOSS_COLOR=zs;var ht=Ee;function SS(r){if(!Number.isFinite(r))return "0";let e=Math.round(r*100)/100;return Number.isInteger(e)?String(e):e.toFixed(2)}function CS(r){return !Number.isFinite(r)||r===0?"0":r>=100?r.toFixed(2):r>=1?r.toFixed(4).replace(/\.?0+$/,""):r.toPrecision(4).replace(/\.?0+$/,"")}function Im(r){return Number.isFinite(r)?Math.abs(r)>=1?r.toFixed(2):r.toPrecision(4).replace(/\.?0+$/,""):"0"}function Am(r){return Math.round(r*1e8)/1e8}var gr=[{value:"auto",label:"Auto",ms:0},{value:"1",label:"1m",ms:6e4},{value:"5",label:"5m",ms:3e5},{value:"15",label:"15m",ms:9e5},{value:"30",label:"30m",ms:18e5},{value:"60",label:"1h",ms:36e5},{value:"240",label:"4h",ms:144e5},{value:"D",label:"1D",ms:864e5}];function to(r){let e=gr.find(n=>n.value===r);if(e)return e.label;let t=Number(r);return Number.isFinite(t)&&t>0?t%1440===0?`${t/1440}D`:t%60===0?`${t/60}h`:`${t}m`:r}function Rm(){return {timeframe:"auto",upColor:"",downColor:""}}var tt=class extends G{constructor(t){super(t);this.type="magnifier";this.chipRect=null;this.magnifier||(this.magnifier=Rm());}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}placementMode(){return "drag"}rect(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{x1:t.xOf(n.time),y1:o,x2:t.xOf(i.time),y2:s}}hitTest(t,n,i,o){let s=this.rect(i);return s?Ve(t,n,s.x1,s.y1,s.x2,s.y2)?true:[[s.x1,s.y1,s.x2,s.y1],[s.x2,s.y1,s.x2,s.y2],[s.x2,s.y2,s.x1,s.y2],[s.x1,s.y2,s.x1,s.y1]].some(l=>ne(t,n,l[0],l[1],l[2],l[3])<=o):false}handlePoints(t){let n=this.rect(t);return n?[[n.x1,n.y1],[n.x2,n.y2]]:[]}hitHandle(t,n,i,o){return Y(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.rect(t);return n?{x:Math.min(n.x1,n.x2),y:Math.min(n.y1,n.y2),w:Math.abs(n.x2-n.x1),h:Math.abs(n.y2-n.y1)}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"magnifier.timeframe",label:"Timeframe",kind:"select",options:gr,group:"behavior"},...B.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"magnifier.upColor",label:"Up candles",kind:"color",group:"fill"},{path:"magnifier.downColor",label:"Down candles",kind:"color",group:"fill"}]}}writeProps(){return {...this.magnifier}}readProps(t){this.magnifier={...Rm(),...t};}};var no=new Map;function V(r){no.set(r.type,r);}function Et(r){return no.get(r)}function Xa(){return [...no.values()]}function On(r,e){let t=no.get(r);if(!t)return null;let n={...t.defaultStyle,...e.style??{}};return t.create({...e,style:n})}function ja(r){let e=On(r.type,{paneId:r.paneId});if(!e)return;r.style={...e.style};let t=r.text?.value;e.text?(r.text={...e.text},t!==void 0&&(r.text.value=t)):r.text=void 0;let n=e.serialize().props;n!==void 0&&r.applyProps(n);}function pt(r){let e=no.get(r.type);return e?e.create(r):null}var TS=R('<line x1="4" y1="19" x2="20" y2="5"/>'),kS=R('<line x1="3" y1="12" x2="21" y2="12"/>');V({type:"trendline",group:"lines",label:"Trend Line",icon:TS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Ws(r)});V({type:"hline",group:"lines",label:"Horizontal Line",icon:kS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"dashed"},create:r=>new Gs(r)});var ES=R('<line x1="3" y1="20" x2="21" y2="6"/><circle cx="3" cy="20" r="1.6" fill="currentColor"/>'),LS=R('<rect x="4" y="6" width="16" height="12" rx="1"/>'),MS=R('<path d="M5 6h14M12 6v13"/>');V({type:"ray",group:"lines",label:"Ray",icon:ES,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Us(r)});var PS=R('<path d="M5 19 19 5"/><path d="M5 19 8.5 19M5 19 5 15.5"/><path d="M19 5 15.5 5M19 5 19 8.5"/>'),IS=R('<line x1="12" y1="3" x2="12" y2="21"/>'),AS=R('<line x1="5" y1="12" x2="21" y2="12"/><circle cx="5" cy="12" r="1.6" fill="currentColor"/>'),RS=R('<line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/>'),DS=R('<path d="M4 20 20 4"/><rect x="9" y="9" width="9" height="6" rx="1"/>'),OS=R('<path d="M4 20 20 6"/><path d="M4 20 15 20"/><path d="M11 20a7 7 0 0 0-2-4.9"/>');V({type:"extendedline",group:"lines",label:"Extended Line",icon:PS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Ys(r)});V({type:"vline",group:"lines",label:"Vertical Line",icon:IS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Ks(r)});V({type:"hray",group:"lines",label:"Horizontal Ray",icon:AS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Xs(r)});V({type:"crossline",group:"lines",label:"Cross Line",icon:RS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new js(r)});V({type:"infoline",group:"lines",label:"Info Line",icon:DS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new qs(r)});V({type:"trendangle",group:"lines",label:"Trend Angle",icon:OS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new Zs(r)});V({type:"box",group:"shapes",label:"Rectangle",icon:LS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}26`},create:r=>new Js(r)});V({type:"text",group:"annotations",label:"Text",icon:MS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new cn(r)});var NS=R('<path d="M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-6l-5 5v-5H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z"/>');V({type:"callout",group:"annotations",label:"Callout",icon:NS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new Ht(r)});var FS=R('<path d="M5 4h14a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-7l-4 4v-4H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z"/><path d="M8 8.5h8M8 12h5"/>'),VS=R('<rect x="10" y="4.5" width="11" height="8" rx="1.5"/><path d="M10 8.5 4 16"/><circle cx="3.5" cy="16.5" r="1.6" fill="currentColor" stroke="none"/>'),_S=R('<path d="M5 4.5h14a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-7l-4 4v-4H5a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2Z"/>'),BS=R('<path d="M3 12 7 8h12a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H7Z"/><path d="M10.5 12.5h6" stroke-width="1.4"/>'),HS=R('<path d="M12 11.5V21"/><rect x="5" y="4" width="14" height="7" rx="1"/><path d="M9 7.5h6"/>');V({type:"note",group:"annotations",label:"Note",icon:FS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new tr(r)});V({type:"pricenote",group:"annotations",label:"Price Note",icon:VS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new rr(r)});V({type:"comment",group:"annotations",label:"Comment",icon:_S,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new ir(r)});V({type:"pricelabel",group:"annotations",label:"Price Label",icon:BS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new nr(r)});V({type:"signpost",group:"annotations",label:"Signpost",icon:HS,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid",fillColor:`${O}d9`},create:r=>new or(r)});var zS=R('<line x1="3" y1="16" x2="21" y2="8"/><line x1="3" y1="21" x2="21" y2="13"/>'),$S=R('<line x1="3" y1="7" x2="21" y2="10"/><line x1="3" y1="18" x2="21" y2="14"/>'),WS=R('<circle cx="4" cy="12" r="1.6" fill="currentColor"/><line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>');V({type:"parallelchannel",group:"channels",label:"Parallel Channel",icon:zS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new Qs(r)});V({type:"disjointchannel",group:"channels",label:"Disjoint Channel",icon:$S,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new ea(r)});var GS=R('<line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="18" x2="21" y2="11"/>');V({type:"flattopbottom",group:"channels",label:"Flat Top/Bottom",icon:GS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new ta(r)});var US=R('<line x1="3" y1="8" x2="21" y2="4"/><line x1="3" y1="16" x2="21" y2="12"/><line x1="3" y1="12" x2="21" y2="8" stroke-dasharray="3 3"/>');V({type:"regressionchannel",group:"channels",label:"Linear Regression",icon:US,defaultStyle:{lineColor:J,lineWidth:1,lineStyle:"solid"},create:r=>new un(r)});V({type:"pitchfork",group:"pitchforks",label:"Pitchfork",icon:WS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new na(r)});var YS=R('<circle cx="4" cy="8" r="1.6" fill="currentColor"/><line x1="4" y1="8" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),KS=R('<circle cx="6" cy="9" r="1.6" fill="currentColor"/><line x1="6" y1="9" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),XS=R('<line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="8" x2="10" y2="16"/><line x1="10" y1="8" x2="21" y2="8"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="16" x2="21" y2="16"/>');V({type:"schiffpitchfork",group:"pitchforks",label:"Schiff Pitchfork",icon:YS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ra(r)});V({type:"modifiedschiffpitchfork",group:"pitchforks",label:"Modified Schiff Pitchfork",icon:KS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ia(r)});V({type:"insidepitchfork",group:"pitchforks",label:"Inside Pitchfork",icon:XS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new oa(r)});var jS=R('<path d="M7 7h10v10"/><path d="M7 17 17 7"/>'),qS=R('<ellipse cx="12" cy="12" rx="9" ry="6"/>'),ZS=R('<path d="M12 4 20 19 4 19Z"/>');V({type:"arrow",group:"shapes",label:"Arrow",icon:jS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",arrowRight:true},create:r=>new sa(r)});V({type:"ellipse",group:"shapes",label:"Ellipse",icon:qS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new aa(r)});V({type:"triangle",group:"shapes",label:"Triangle",icon:ZS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new la(r)});var JS=R('<polyline points="3 17 9 10 13 14 21 5"/>'),QS=R('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'),eC=R('<path d="M9 11 15 5l4 4-6 6H9Z"/><path d="M9 15l-2 2"/><path d="M4 21h6"/>');V({type:"polyline",group:"shapes",label:"Polyline",icon:JS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ca(r)});V({type:"freehand",group:"shapes",label:"Brush",icon:QS,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ua(r)});V({type:"highlighter",group:"shapes",label:"Highlighter",icon:eC,defaultStyle:{lineColor:`${qp}59`,lineWidth:14,lineStyle:"solid"},create:r=>new da(r)});var tC=R('<circle cx="12" cy="12" r="8"/>'),nC=R('<path d="M5 14 9.5 5 19 10 14.5 19 Z"/>'),rC=R('<path d="M4 19 9 11 13 14 17 8 20 4"/><path d="M17.2 5.5 20 4 19.4 7.1"/>'),iC=R('<path d="M4 17a8 8 0 0 1 16 0"/><path d="M4 17 20 17"/>'),oC=R('<path d="M4 18Q12 1 20 14"/>'),sC=R('<path d="M12 5 12 19"/><path d="M6 11 12 5 18 11"/>'),aC=R('<path d="M12 5 12 19"/><path d="M6 13 12 19 18 13"/>');V({type:"circle",group:"shapes",label:"Circle",icon:tC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}1a`},create:r=>new ha(r)});V({type:"rotatedrect",group:"shapes",label:"Rotated Rectangle",icon:nC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}26`},create:r=>new pa(r)});V({type:"path",group:"shapes",label:"Path",icon:rC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ma(r)});V({type:"arc",group:"shapes",label:"Arc",icon:iC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid",fillColor:`${O}26`},create:r=>new fa(r)});V({type:"curve",group:"shapes",label:"Curve",icon:oC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new ga(r)});V({type:"arrowmarkup",group:"shapes",label:"Arrow Mark Up",icon:sC,defaultStyle:{lineColor:z,lineWidth:1,lineStyle:"solid"},create:r=>new Ki(r)});V({type:"arrowmarkdown",group:"shapes",label:"Arrow Mark Down",icon:aC,defaultStyle:{lineColor:W,lineWidth:1,lineStyle:"solid"},create:r=>new Xi(r)});var lC=R('<path d="M6 21V4"/><path d="M6 5h11l-2.5 3.5L17 12H6" fill="currentColor" stroke="none"/>'),cC=R('<path d="m12 3 2.6 5.8 6.4.6-4.8 4.2 1.4 6.2L12 16.9 6.4 19.8 7.8 13.6 3 9.4l6.4-.6Z"/>');V({type:"flagmark",group:"stamps",label:"Flag",icon:lC,defaultStyle:{lineColor:Ke,lineWidth:1,lineStyle:"solid"},create:r=>new ji(r)});V({type:"iconstamp",group:"stamps",label:"Icon",icon:cC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new qi(r)});var uC=R('<line x1="3" y1="5" x2="21" y2="5"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="3" y1="14" x2="21" y2="14"/><line x1="3" y1="19" x2="21" y2="19"/>'),dC=R('<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="15" x2="14" y2="15"/><line x1="3" y1="20" x2="14" y2="20"/>');V({type:"fibretracement",group:"fibonacci",label:"Fib Retracement",icon:uC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ya(r)});V({type:"fibextension",group:"fibonacci",label:"Fib Extension",icon:dC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new wa(r)});var hC=R('<path d="M3 20 10 9l4 5"/><path d="M14 14h7M14 9h7M14 4h7"/>');V({type:"fibextensiontrend",group:"fibonacci",label:"Trend-Based Fib Extension",icon:hC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new xa(r)});var pC=R('<path d="M4 20 20 5M4 20 21 11M4 20 21 17M4 20 20 20"/>'),mC=R('<path d="M3 5v14M6 5v14M11 5v14M19 5v14"/>');V({type:"fibfan",group:"fibonacci",label:"Fib Fan",icon:pC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Sa(r)});V({type:"fibtimezones",group:"fibonacci",label:"Fib Time Zones",icon:mC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"dashed"},create:r=>new Ca(r)});var fC=R('<path d="M3 18 18 9M5 21 20 12M6 13 21 4"/>'),gC=R('<path d="M4 4 20 20M4 4 20 12M4 4 12 20M4 4 20 4M4 4 4 20"/>'),bC=R('<path d="M3 19 9 8M9 8 12 5v14M14 5v14M18 5v14M21 5v14"/>');V({type:"fibchannel",group:"fibonacci",label:"Fib Channel",icon:fC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ta(r)});V({type:"fibspeedfan",group:"fibonacci",label:"Fib Speed Resistance Fan",icon:gC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ka(r)});V({type:"trendfibtime",group:"fibonacci",label:"Trend-Based Fib Time",icon:bC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"dashed"},create:r=>new Ea(r)});var vC=R('<circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/><circle cx="12" cy="12" r="10"/>'),yC=R('<path d="M8 20a4 4 0 0 1 8 0"/><path d="M4.5 20a7.5 7.5 0 0 1 15 0"/><circle cx="12" cy="20" r="1.4" fill="currentColor" stroke="none"/>'),wC=R('<path d="M4 20 20 16M4 20 14 4"/><path d="M11.8 18.1A8 8 0 0 0 8.2 13.2"/><path d="M16.6 16.9A13 13 0 0 0 10.9 9"/>'),xC=R('<path d="M13 12a2 2 0 1 1-2-2 4 4 0 0 1 4 4 6 6 0 0 1-9 5.2 9 9 0 0 1 .5-15"/>');V({type:"fibcircles",group:"fibonacci",label:"Fib Circles",icon:vC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new La(r)});V({type:"fibarcs",group:"fibonacci",label:"Fib Speed Resistance Arcs",icon:yC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ma(r)});V({type:"fibwedge",group:"fibonacci",label:"Fib Wedge",icon:wC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Pa(r)});V({type:"fibspiral",group:"fibonacci",label:"Fib Spiral",icon:xC,defaultStyle:{lineColor:O,lineWidth:2,lineStyle:"solid"},create:r=>new hr(r)});var SC=R('<path d="M4 20 20 20M4 20 20 13M4 20 20 6M4 20 15 4M4 20 9 4M4 20 4 4"/>'),CC=R('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 12h16M12 4v16M4 4 20 20" opacity="0.6"/>');V({type:"gannfan",group:"fibonacci",label:"Gann Fan",icon:SC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ia(r)});V({type:"gannbox",group:"fibonacci",label:"Gann Box",icon:CC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Aa(r)});var TC=R('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 20 20 4M4 20 20 12M4 20 12 4" opacity="0.7"/><path d="M4 20a16 16 0 0 1 16-16" opacity="0.5"/>');V({type:"gannsquare",group:"fibonacci",label:"Gann Square",icon:TC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new pr(r)});var kC=R('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0" opacity="0.9"/><path d="M6 20a4 4 0 0 1 8 0" opacity="0.75"/><path d="M10 20a2 2 0 0 1 4 0" opacity="0.6"/><path d="M8 20v-6M12 20v-9M16 20v-6" opacity="0.45"/>');V({type:"dedekind",group:"geometry",label:"Dedekind Tessellation",icon:kC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new mr(r)});var EC=R('<circle cx="16" cy="12" r="5" opacity="0.55"/><circle cx="13" cy="12" r="3.5" opacity="0.75"/><circle cx="10.5" cy="12" r="2"/><path d="M8 4v16"/>'),LC=R('<circle cx="17" cy="12" r="4.5" opacity="0.45"/><circle cx="13" cy="12" r="3" opacity="0.7"/><circle cx="10" cy="12" r="1.6"/><path d="M6 12 16 5M6 12 16 19"/>');V({type:"sonic",group:"geometry",label:"Sonic",icon:EC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ji(r)});V({type:"supersonic",group:"geometry",label:"Supersonic",icon:LC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Qi(r)});var MC=R('<circle cx="16" cy="12" r="5" opacity="0.4"/><circle cx="13" cy="12" r="3.2" opacity="0.65"/><circle cx="10.8" cy="12" r="1.8"/><path d="M8 4v16"/><path d="M15 8.5h2M12.5 10h2" opacity="0.5"/>'),PC=R('<circle cx="17" cy="12" r="4.5" opacity="0.4"/><circle cx="12.5" cy="12" r="2.8" opacity="0.65"/><circle cx="9.8" cy="12" r="1.4"/><path d="M6 12 16 5M6 12 16 19"/>');V({type:"goldensonic",group:"geometry",label:"Golden Sonic",icon:MC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Da(r)});V({type:"goldensupersonic",group:"geometry",label:"Golden Supersonic",icon:PC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Oa(r)});var IC=R('<path d="M3 18 7 8 11 14 15 6 20 16"/>'),AC=R('<path d="M4 17 9 7 14 15 20 5"/>'),RC=R('<path d="M3 19 8 9 12 13 17 5 21 9"/>'),DC=R('<path d="M4 7 11 16 20 9"/>'),OC=R('<path d="M3 18 6 12 9 16 12 5 15 16 18 12 21 18"/>');V({type:"xabcd",group:"patterns",label:"XABCD Pattern",icon:IC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Na(r)});V({type:"abcd",group:"patterns",label:"ABCD Pattern",icon:AC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Fa(r)});V({type:"elliottimpulse",group:"patterns",label:"Elliott Impulse Wave (1-5)",icon:RC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Va(r)});V({type:"elliottcorrection",group:"patterns",label:"Elliott Correction Wave (ABC)",icon:DC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new _a(r)});V({type:"headshoulders",group:"patterns",label:"Head & Shoulders",icon:OC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ba(r)});var NC=R('<path d="M3 17 7 6 12 14 17 5 21 16"/><path d="M3 17 21 16" opacity="0.45"/>'),jr={group:"patterns",icon:NC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"}};V({type:"gartley",label:"Gartley",...jr,create:r=>new Ha(r)});V({type:"bat",label:"Bat",...jr,create:r=>new za(r)});V({type:"butterfly",label:"Butterfly",...jr,create:r=>new $a(r)});V({type:"crab",label:"Crab",...jr,create:r=>new Wa(r)});V({type:"shark",label:"Shark",...jr,create:r=>new Ga(r)});V({type:"cypher",label:"Cypher",...jr,create:r=>new Ua(r)});var FC=R('<rect x="4" y="6" width="16" height="12" rx="1"/><path d="M4 18 20 6" opacity="0.5"/>');V({type:"datepricerange",group:"measure",label:"Date & Price Range",icon:FC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new Ya(r)});var VC=R('<rect x="4.5" y="4.5" width="15" height="7.5" rx="1" fill="currentColor" fill-opacity="0.25"/><rect x="4.5" y="12" width="15" height="7.5" rx="1"/>');V({type:"position",group:"measure",label:"Long/Short Position",icon:VC,defaultStyle:{lineColor:O,lineWidth:1,lineStyle:"solid"},create:r=>new ht(r)});var _C=R('<circle cx="10.5" cy="10.5" r="6.5"/><path d="m15.3 15.3 5.2 5.2"/><path d="M8 12.5v-3M10.5 13.5v-5.5M13 12v-2"/>');V({type:"magnifier",group:"measure",label:"Magnifier",icon:_C,defaultStyle:{lineColor:"",lineWidth:1,lineStyle:"solid"},coversSeries:true,placementHint:"Drag an area on the chart to view it at a lower timeframe",create:r=>new tt(r)});var BC=R('<line x1="5" y1="3" x2="5" y2="21"/><path d="M5 16c4 0 5-9 8-9s3 5 8 3"/>');V({type:"anchoredvwap",group:"measure",label:"Anchored VWAP",icon:BC,defaultStyle:{lineColor:Je,lineWidth:2,lineStyle:"solid"},create:r=>new sr(r)});var HC=R('<path d="M4 4v16"/><path d="M4 8h10"/><path d="M4 12h14"/><path d="M4 16h8"/><path d="M4 20h12"/>');V({type:"fixedrangevp",group:"measure",label:"Fixed Range Volume Profile",icon:HC,defaultStyle:{lineColor:z,lineWidth:1,lineStyle:"solid"},create:r=>new at(r)});var zC=["fibretracement","fibextension","fibextensiontrend","fibfan","fibtimezones","fibchannel","fibspeedfan","trendfibtime","fibcircles","fibarcs","fibwedge","fibspiral"],$C=["gannfan","gannbox","gannsquare"],WC=["dedekind","sonic","supersonic","goldensonic","goldensupersonic"],GC=["xabcd","abcd","headshoulders"],UC=["elliottimpulse","elliottcorrection"],YC=["gartley","bat","butterfly","crab","shark","cypher"],KC=["position","datepricerange","magnifier"],XC=["anchoredvwap","fixedrangevp"],jC=["freehand","highlighter"],qC=["arrow","arrowmarkup","arrowmarkdown"],ZC=["box","ellipse","triangle","polyline","circle","rotatedrect","path","arc","curve"],JC=["text","callout","note","pricenote","comment","pricelabel","signpost"],QC=["flagmark","iconstamp"],e1=[{id:"lines-channels-pitchforks",label:"Lines",sections:[{label:"Lines",registryGroup:"lines"},{label:"Channels",registryGroup:"channels"},{label:"Pitchforks",registryGroup:"pitchforks"}]},{id:"fibonacci-gann",label:"Fibonacci",sections:[{label:"Fibonacci",types:zC},{label:"Gann",types:$C},{label:"Geometry",types:WC}]},{id:"patterns-waves-harmonics",label:"Patterns",sections:[{label:"Patterns",types:GC},{label:"Elliott Waves",types:UC},{label:"Harmonics",types:YC}]},{id:"measurements",label:"Measurements",sections:[{label:"Measurements",types:KC},{label:"Volume",types:XC}]},{id:"brushes-arrows-shapes",label:"Shapes",sections:[{label:"Brushes",types:jC},{label:"Arrows",types:qC},{label:"Shapes",types:ZC}]},{id:"text",label:"Text",sections:[{label:"Text",types:JC}]},{id:"icons",label:"Icons",sections:[{label:"Icons",types:QC}]}];function t1(r){let e=Et(r);return e?{type:e.type,label:e.label,icon:e.icon}:null}function n1(r){let e=new Map;for(let t of Xa()){if(r&&!r.has(t.type))continue;let n={type:t.type,label:t.label,icon:t.icon};e.has(t.group)||e.set(t.group,[]),e.get(t.group).push(n);}return e}function r1(r,e,t){return "registryGroup"in r?e.get(r.registryGroup)??[]:r.types.map(n=>t.get(n)).filter(n=>n!=null)}function Dm(r){let e=n1(r),t=new Map;for(let i of e.values())for(let o of i)t.set(o.type,o);let n=[];for(let i of e1){let o=[],s=[];for(let a of i.sections){let l=r1(a,e,t);l.length!==0&&(o.push({label:a.label,tools:l}),s.push(...l));}s.length!==0&&n.push({id:i.id,label:i.label,tools:s,sections:o.length>0?o:void 0});}return {groups:n}}function i1(r){let e=new Set;for(let t of r)Et(t)&&e.add(t);return Dm(e)}function o1(r){let e=[];for(let t of r){let n=t.tools.map(t1).filter(i=>i!=null);n.length>0&&e.push({id:t.id,label:t.label,tools:n});}return {groups:e}}function ro(){return Dm()}function io(r){if(r===false)return {definition:ro(),visible:false};if(r===void 0||r===true)return {definition:ro(),visible:true};let e=r.toolbar??true;return r.groups?{definition:o1(r.groups),visible:e}:r.tools?{definition:i1(r.tools),visible:e}:{definition:ro(),visible:e}}function Wt(r){let e=globalThis.structuredClone;return e?e(r):JSON.parse(JSON.stringify(r))}function Om(r){if(!r||typeof r!="object")return false;let e=r;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.paneId=="string"&&Array.isArray(e.anchors)&&e.anchors.every(t=>t&&typeof t.time=="number"&&typeof t.price=="number")&&!!e.style&&typeof e.style=="object"}function Fu(r){let e=r;return !e||typeof e!="object"||e.version!==1||!Array.isArray(e.drawings)?{version:1,drawings:[]}:{version:1,drawings:e.drawings.filter(Om)}}var qr=class{constructor(){this.byId=new Map;this.seq=0;this.zCounter=1;this.listeners=new Set;}nextId(){return this.seq+=1,`dw-${this.seq}`}add(e){return e.zIndex||(e.zIndex=this.zCounter),this.zCounter=Math.max(this.zCounter,Math.ceil(e.zIndex))+1,this.byId.set(e.id,e),this.emit(),e}remove(e){let t=this.byId.delete(e);return t&&this.emit(),t}get(e){return this.byId.get(e)}has(e){return this.byId.has(e)}update(e,t){let n=this.byId.get(e);return n?(t.anchors&&(n.anchors=t.anchors.map(i=>({time:i.time,price:i.price}))),t.style&&(n.style={...t.style}),t.text!==void 0&&(n.text=t.text?{...t.text}:void 0),t.paneId!==void 0&&(n.paneId=t.paneId),t.locked!==void 0&&(n.locked=t.locked),t.visible!==void 0&&(n.visible=t.visible),t.zIndex!==void 0&&(n.zIndex=t.zIndex),t.props!==void 0&&n.applyProps(t.props),this.emit(),n):null}all(){return [...this.byId.values()].sort((e,t)=>e.zIndex-t.zIndex)}byPane(e){return this.all().filter(t=>t.paneId===e)}bringToFront(e,t=0){let n=this.byId.get(e);n&&(n.zIndex=Math.max(this.zCounter,Math.floor(t)+1),this.zCounter=n.zIndex+1,this.emit());}sendToBack(e,t=1){let n=this.byId.get(e);if(!n)return;let i=Math.min(...[...this.byId.values()].map(o=>o.zIndex),Math.ceil(t));n.zIndex=i-1,this.emit();}setLocked(e,t){let n=this.byId.get(e);n&&(n.locked=t,this.emit());}setVisible(e,t){let n=this.byId.get(e);n&&(n.visible=t,this.emit());}clear(){this.byId.size!==0&&(this.byId.clear(),this.emit());}serialize(){return {version:1,drawings:this.all().map(e=>e.serialize())}}load(e){let t=Fu(e);this.byId.clear(),this.seq=0,this.zCounter=1;for(let n of t.drawings){let i=pt(n);i&&(this.byId.set(i.id,i),this.zCounter=Math.max(this.zCounter,i.zIndex)+1,this.bumpSeqPast(i.id));}this.emit();}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}bumpSeqPast(e){let t=/^dw-(\d+)$/.exec(e);t&&(this.seq=Math.max(this.seq,Number(t[1])));}emit(){for(let e of this.listeners)e();}};var qa=class{constructor(e=100){this.cap=e;this.undoStack=[];this.redoStack=[];this.pending=null;this.dirtied=false;this.depth=0;}begin(e){this.depth+=1,this.depth===1&&(this.pending=Wt(e),this.dirtied=false);}markDirty(){this.depth===0||this.dirtied||!this.pending||(this.push(this.pending),this.dirtied=true);}commit(){this.depth!==0&&(this.depth-=1,this.depth===0&&(this.pending=null,this.dirtied=false));}abort(){this.commit();}record(e){if(this.depth>0){this.markDirty();return}this.push(Wt(e));}undo(e){let t=this.undoStack.pop();return t?(this.redoStack.push(Wt(e)),t):null}redo(e){let t=this.redoStack.pop();return t?(this.undoStack.push(Wt(e)),t):null}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[],this.pending=null,this.dirtied=false,this.depth=0;}push(e){this.undoStack.push(e),this.undoStack.length>this.cap&&this.undoStack.shift(),this.redoStack=[];}};var Za=class{constructor(e,t,n,i){this.events=t;this.store=new qr;this.history=new qa;this.activeTool=null;this.snapMode="off";this.stayInDrawingMode=false;this.mode=null;this.favs=new Set;this.selectedIds=[];this.clipboard=[];this.lastStyle=new Map;this.subs=[];if(this.enabled=!!e.capabilities.userDrawings&&!!e.userDrawingsPort,this.port=this.enabled?e.userDrawingsPort:null,this.port){let{definition:o,visible:s}=io(n);this.port.setToolbar(o),this.port.showToolbar(s),i&&this.port.setSeriesGateway?.(i),this.subs.push(this.port.onDrawingIntent(a=>this.onIntent(a))),this.subs.push(this.store.onChange(()=>this.sync()));}}get supported(){return this.enabled}setTool(e){if(!this.port)return;let t=e!==this.activeTool;this.activeTool=e,this.port.setActiveTool(e,e?this.lastStyle.get(e):void 0),t&&this.events.emit("drawing:tool",{type:e});}getTool(){return this.activeTool}getSnapMode(){return this.snapMode}setSnapMode(e){!this.port||e===this.snapMode||(this.snapMode=e,this.port.setSnapMode?.(e),this.events.emit("drawing:snap",{mode:e}));}getStayMode(){return this.stayInDrawingMode}setStayMode(e){!this.port||e===this.stayInDrawingMode||(this.stayInDrawingMode=e,this.port.setStayMode?.(e),this.events.emit("drawing:stay",{on:e}));}getMode(){return this.mode}setMode(e){!this.port||e===this.mode||(this.mode=e,this.port.setMode?.(e),this.events.emit("drawing:mode",{mode:e}));}showToolbar(e){this.port?.showToolbar(e);}favorites(){return [...this.favs]}isFavorite(e){return this.favs.has(e)}setFavorite(e,t){Et(e)&&t!==this.favs.has(e)&&(t?this.favs.add(e):this.favs.delete(e),this.pushFavorites());}setFavorites(e){let t=e.filter(n=>Et(n)!=null);t.length===this.favs.size&&t.every(n=>this.favs.has(n))||(this.favs=new Set(t),this.pushFavorites());}pushFavorites(){let e=[...this.favs];this.port?.setFavorites?.(e),this.events.emit("drawing:favorites",{favorites:e});}setToolbar(e){this.port?.setToolbar(io(e).definition);}setExternalGhost(e){this.port?.setExternalGhost?.(e);}setToolShortcuts(e){this.port?.setToolShortcuts?.(e);}add(e,t={}){if(!this.enabled)return null;let i={...this.lastStyle.get(e)??{},...t.style??{}},o=On(e,{id:this.store.nextId(),paneId:t.paneId??"price",anchors:t.anchors,style:i,text:t.text,props:t.props,zIndex:t.zIndex??this.startZ(e,t.paneId??"price")});return o?(this.history.record(this.store.serialize()),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id}),o):null}remove(e){this.deleteMany([e]);}update(e,t){let n=this.store.serialize(),i=t.style?this.store.get(e):void 0,o=t.style&&i?{...t,style:{...i.style,...t.style}}:t;this.store.update(e,o)&&(this.history.record(n),this.captureStyle(e),this.events.emit("drawing:edited",{id:e}));}updateMany(e){this.history.begin(this.store.serialize());for(let{id:t,patch:n}of e)this.store.update(t,n)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t}));this.history.commit();}removeMany(e){this.deleteMany(e);}setLocked(e,t){let n=this.store.serialize();this.history.record(n),this.store.setLocked(e,t),this.events.emit("drawing:edited",{id:e});}setVisible(e,t){let n=this.store.serialize();this.history.record(n),this.store.setVisible(e,t),this.events.emit("drawing:edited",{id:e});}bringToFront(e){let t=this.store.serialize();this.history.record(t),this.store.bringToFront(e,this.seriesTopZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}sendToBack(e){let t=this.store.serialize();this.history.record(t),this.store.sendToBack(e,this.seriesBottomZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}seriesTopZ(e){return e!==void 0?this.port?.stackRange?.(e)?.front??0:0}seriesBottomZ(e){return e!==void 0?this.port?.stackRange?.(e)?.back??1:1}startZ(e,t){let n=this.port?.stackRange?.(t);if(n)return Et(e)?.coversSeries?n.front+.5:(n.price??n.front)-.5}select(e,t=false){this.setSelection(e,t);}openSettings(e){this.port?.openSettings(e);}undo(){let e=this.history.undo(this.store.serialize());e&&this.restoreSnapshot(e);}redo(){let e=this.history.redo(this.store.serialize());e&&this.restoreSnapshot(e);}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}duplicate(e){if(!this.enabled)return [];let t=this.resolve(e);return t.length===0?[]:this.insertClones(t.map(n=>n.serialize()))}clone(e){return this.duplicate([e])[0]??null}copy(e){let t=this.resolve(e).map(n=>Wt(n.serialize()));t.length&&(this.clipboard=t);}paste(){return !this.enabled||this.clipboard.length===0?[]:this.insertClones(this.clipboard)}all(){return this.store.serialize().drawings}toJSON(){return this.store.serialize()}fromJSON(e){this.history.clear(),this.selectedIds=[],this.store.load(e);}destroy(){for(let e of this.subs)e();this.subs.length=0;}setSelection(e,t=false){let n;if(t){n=[...this.selectedIds];for(let i of e){let o=n.indexOf(i);o>=0?n.splice(o,1):n.push(i);}}else n=[...e];this.selectedIds=n.filter(i=>this.store.has(i)),this.announceSelection();}announceSelection(){this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null,ids:[...this.selectedIds]});}restoreSnapshot(e){this.store.load(e),this.selectedIds=this.selectedIds.filter(t=>this.store.has(t)),this.announceSelection();}deleteMany(e){this.history.begin(this.store.serialize());let t=[];for(let i of e)this.store.remove(i)&&t.push(i),this.history.markDirty();if(this.history.commit(),t.length===0)return;let n=this.selectedIds.filter(i=>this.store.has(i));n.length!==this.selectedIds.length&&this.setSelection(n);for(let i of t)this.events.emit("drawing:removed",{id:i});}insertClones(e){this.history.begin(this.store.serialize());let t=[];for(let n of e){let i=pt({...n,id:this.store.nextId()});i&&(this.store.add(i),this.history.markDirty(),t.push(i));}if(this.history.commit(),t.length){this.setSelection(t.map(n=>n.id));for(let n of t)this.events.emit("drawing:created",{id:n.id});}return t}resolve(e){return e.map(t=>this.store.get(t)).filter(t=>t!=null)}captureStyle(e){let t=this.store.get(e);t&&this.lastStyle.set(t.type,{...t.style});}sync(){this.port?.syncDrawings(this.store.serialize().drawings);}onIntent(e){switch(e.kind){case "arm":this.setTool(e.type);break;case "draft":this.events.emit("drawing:draft",{doc:e.doc});break;case "create":{let t=this.store.serialize(),n=this.lastStyle.get(e.doc.type),i=n?{...e.doc.style,...n}:e.doc.style,o=pt({...e.doc,id:this.store.nextId(),style:i});if(!o)return;o.zIndex||(o.zIndex=this.startZ(o.type,o.paneId)??0),this.history.record(t),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id});break}case "edit":{let t=this.store.serialize();this.store.update(e.doc.id,e.doc)&&(this.history.record(t),this.captureStyle(e.doc.id),this.events.emit("drawing:edited",{id:e.doc.id}));break}case "edit-many":{this.history.begin(this.store.serialize());for(let t of e.docs)this.store.update(t.id,t)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t.id}));this.history.commit();break}case "select":this.setSelection(e.ids,e.additive);break;case "delete":this.deleteMany(e.ids);break;case "reorder":e.to==="front"?this.bringToFront(e.id):this.sendToBack(e.id);break;case "settings":this.events.emit("drawing:settings",{id:e.id});break;case "favorite":this.setFavorite(e.type,e.on);break;case "snap-mode":e.mode!==this.snapMode&&(this.snapMode=e.mode,this.events.emit("drawing:snap",{mode:e.mode}));break;case "stay-mode":e.on!==this.stayInDrawingMode&&(this.stayInDrawingMode=e.on,this.events.emit("drawing:stay",{on:e.on}));break;case "mode":e.mode!==this.mode&&(this.mode=e.mode,this.events.emit("drawing:mode",{mode:e.mode}));break;case "tool-finished":!this.stayInDrawingMode&&e.type!=="freehand"&&e.type!=="highlighter"&&this.setTool(null);break;case "undo":this.undo();break;case "redo":this.redo();break;case "duplicate":this.duplicate(e.ids);break;case "clone":this.enabled&&e.docs.length&&this.insertClones(e.docs);break;case "copy":this.copy(e.ids);break;case "paste":this.paste();break}}};var Ja=class{constructor(e,t){this.renderer=e;this.marks=new Map;this.groups=new Map;this.subs=[];this.enabled=!!e.capabilities.timelineMarks&&typeof e.setTimelineMarks=="function",this.enabled&&e.onMarkClick&&this.subs.push(e.onMarkClick(n=>t.emit("mark:click",n)));}get supported(){return this.enabled}add(e){this.marks.set(e.id,Fm(e)),this.sync();}set(e){this.marks.clear();for(let t of e)this.marks.set(t.id,Fm(t));this.sync();}remove(e){let t=this.marks.delete(e);return t&&this.sync(),t}clear(){this.marks.size!==0&&(this.marks.clear(),this.sync());}all(){return [...this.marks.values()].map(e=>({...e,glyph:{...e.glyph}}))}defineGroup(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("[vela] marks.defineGroup: `id` must be a non-empty string");if(typeof e.label!="string")throw new Error(`[vela] marks.defineGroup: group "${e.id}" needs a string \`label\``);this.groups.set(e.id,{...e}),this.sync();}groupDefinitions(){return [...this.groups.values()].map(e=>({...e}))}setGroupVisible(e,t){if(!this.renderer.features.includes("marks")){console.warn(`[vela] renderer "${this.renderer.name}" does not paint timeline marks \u2014 setGroupVisible ignored.`);return}this.renderer.applyFeature("marks",{groups:{[e]:t}});}isGroupVisible(e){let n=this.renderer.readFeature("marks")?.groups?.[e];return typeof n=="boolean"?n:this.groups.get(e)?.visible!==false}destroy(){for(let e of this.subs)e();this.subs.length=0;}sync(){this.enabled&&this.renderer.setTimelineMarks([...this.marks.values()],[...this.groups.values()]);}};function Fm(r){if(!r||typeof r!="object")throw new Error("[vela] marks: a mark must be an object");if(typeof r.id!="string"||r.id.length===0)throw new Error("[vela] marks: `id` must be a non-empty string");if(typeof r.time!="number"||!Number.isFinite(r.time))throw new Error(`[vela] marks: mark "${r.id}" needs a finite epoch-ms \`time\``);if(!r.glyph||typeof r.glyph!="object"||typeof r.glyph.color!="string")throw new Error(`[vela] marks: mark "${r.id}" needs a glyph with a \`color\``);return {...r,glyph:{...r.glyph}}}var Vm={D:864e5,W:6048e5,M:2592e6};function Lt(r){let e=r.trim();if(Vm[e])return Vm[e];let t=/^(\d+)\s*(m|h|d|w)?$/i.exec(e);if(t){let n=parseInt(t[1],10),i=(t[2]??"m").toLowerCase();return n*(i==="m"?6e4:i==="h"?36e5:i==="d"?864e5:6048e5)}return 36e5}var s1=5e3,a1=.25,l1=16,c1=15e3,Vu=["240","60","30","15","5","1"],Qa=class{constructor(e){this.deps=e;this.cache=new Map;this.listeners=new Set;}seriesInRange(e,t,n){if(!this.deps.canFetch())return {state:"unavailable",reason:"no-source"};let i=this.resolveTimeframe(e);if(typeof i!="string")return {state:"unavailable",reason:i.reason};let o=Lt(i),s=Math.min(t,n),a=Math.max(t,n);if(!(a>s)||!(o>0))return {state:"unavailable",reason:"not-lower"};if((a-s)/o>s1)return {state:"unavailable",reason:"too-wide"};let l=`${this.deps.marketKey()}|${i}`,c=this.cache.get(l)??[],u=c.find(d=>d.from<=s&&d.to>=a);if(u){if(u.pending)return this.loading(c,i,o,s,a);if(u.failedAt>0){if(Date.now()-u.failedAt<c1)return this.loading(c,i,o,s,a);c.splice(c.indexOf(u),1);}else return this.maybeRefresh(l,u,i,o,a),{state:"ready",bars:this.slice(u.bars,s,a),timeframe:i,barMs:o}}return this.fetchWindow(l,c,i,s,a),this.loading(c,i,o,s,a)}onUpdate(e){return this.listeners.add(e),()=>this.listeners.delete(e)}resolveTimeframe(e){let t=Lt(this.deps.chartTimeframe()),n=Vu[Vu.length-1];if(Lt(n)>=t)return {reason:"none-lower"};let i=e.trim()||"auto";if(i==="auto"){for(let o of Vu)if(Lt(o)<=t/4)return o;return n}return Lt(i)<t?i:{reason:"not-lower"}}loading(e,t,n,i,o){let s=new Map;for(let l of e)if(!(l.pending||l.failedAt>0)&&!(l.to<i||l.from>o))for(let c of this.slice(l.bars,i,o))s.set(c.time,c);if(s.size===0)return {state:"loading",timeframe:t,barMs:n};let a=[...s.values()].sort((l,c)=>l.time-c.time);return {state:"loading",timeframe:t,barMs:n,bars:a}}fetchWindow(e,t,n,i,o){if(t.some(l=>l.pending&&l.to>=i&&l.from<=o))return;let s=(o-i)*a1,a={from:i-s,to:o+s,bars:[],fetchedAt:0,pending:true,failedAt:0};t.push(a),this.cache.set(e,t),this.evict(),this.deps.fetchBars(n,{from:a.from,to:a.to}).then(l=>{a.bars=l,a.fetchedAt=Date.now(),a.pending=false,this.absorbOverlaps(e,a),this.fire();}).catch(()=>{a.pending=false,a.failedAt=Date.now(),this.fire();});}maybeRefresh(e,t,n,i,o){if(t.pending)return;let s=t.bars.length>0?t.bars[t.bars.length-1].time:t.from;o<s||Date.now()-t.fetchedAt<i||(t.pending=true,this.deps.fetchBars(n,{from:t.from,to:t.to}).then(a=>{t.bars=a,t.fetchedAt=Date.now(),t.pending=false,this.fire();}).catch(()=>{t.pending=false,t.fetchedAt=Date.now();}));}absorbOverlaps(e,t){let n=this.cache.get(e);if(n)for(let i=n.length-1;i>=0;i-=1){let o=n[i];if(o===t||o.pending||o.failedAt>0||o.to<t.from||o.from>t.to)continue;let s=new Map;for(let a of o.bars)s.set(a.time,a);for(let a of t.bars)s.set(a.time,a);t.bars=[...s.values()].sort((a,l)=>a.time-l.time),t.from=Math.min(t.from,o.from),t.to=Math.max(t.to,o.to),t.fetchedAt=Math.min(t.fetchedAt,o.fetchedAt||t.fetchedAt),n.splice(i,1);}}evict(){let e=0;for(let t of this.cache.values())e+=t.length;for(;e>l1;){let t=null,n=-1,i=1/0;for(let[s,a]of this.cache)for(let l=0;l<a.length;l+=1){let c=a[l];if(c.pending)continue;let u=c.fetchedAt||c.failedAt;u<i&&(t=s,n=l,i=u);}if(t==null)return;let o=this.cache.get(t);o.splice(n,1),o.length===0&&this.cache.delete(t),e-=1;}}slice(e,t,n){let i=[];for(let o of e)if(!(o.time<t)){if(o.time>n)break;i.push(o);}return i}fire(){for(let e of [...this.listeners])e();}};function oo(r){return r.group!=null&&r.ticker===r.group}function _m(r){return `${(r.prefix??r.provider??"").toLowerCase()}:${(r.group??"").toUpperCase()}`}function u1(r,e){let t=_m(e);return r.filter(n=>n.group!=null&&!oo(n)&&_m(n)===t)}function Bm(r,e){let t=u1(r,e),n=t.filter(i=>i.default);return (n.length===1?n[0]:t[0])??null}var Gt=r=>r.trim().toLowerCase(),hn=r=>r.trim().toUpperCase();function Ut(r){let e=r.trim(),t=/^(?:([A-Za-z0-9_.]+):)?(.+)$/.exec(e);if(!t)return {provider:null,ticker:e};let n=t[1]?Gt(t[1]):null,i=t[2],o=i.lastIndexOf("."),s=o>0?i.slice(o+1):void 0;return {provider:n,ticker:i,ext:s}}var el=class{constructor(){this.entries=new Map;this.changeListeners=new Set;this.waits=new Set;this.unresolvedCbs=new Set;}register(e,t){let n=Gt(e),i={name:n,provider:t,index:null,prefixIndex:null,byTicker:null,descriptors:[],settled:false,settle:Promise.resolve()};return this.entries.set(n,i),i.settle=this.buildIndex(i),queueMicrotask(()=>this.notify(false)),i.settle}async buildIndex(e){await Promise.resolve();try{if(e.provider.listSymbols){let t=await e.provider.listSymbols();e.descriptors=t,e.index=new Set(t.map(n=>hn(n.ticker))),e.byTicker=new Map(t.map(n=>[hn(n.ticker),n])),e.prefixIndex=new Map;for(let n of t)n.prefix&&e.prefixIndex.set(`${Gt(n.prefix)}:${hn(n.ticker)}`,n);}}catch{e.index=null;}finally{e.settled=true,this.notify(true);}}notify(e){for(let t of [...this.changeListeners])t(e);}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}unregister(e){this.entries.delete(Gt(e)),this.notify(false);}has(e){return this.entries.has(Gt(e))}get(e){return this.entries.get(Gt(e))?.provider}names(){return [...this.entries.keys()]}parse(e){return Ut(e)}resolve(e,t={}){let{provider:n,ticker:i}=this.parse(e);if(n){if(this.entries.has(n)){let a=this.entries.get(n).byTicker?.get(hn(i));return {provider:n,ticker:a!=null&&oo(a)?this.loadableTicker(n,a):i}}let s=`${n}:${hn(i)}`;for(let a of this.candidateOrder(t.default)){let l=this.entries.get(a).prefixIndex?.get(s);if(l)return {provider:a,ticker:this.loadableTicker(a,l)}}return null}let o=hn(i);for(let s of this.candidateOrder(t.default)){let a=this.entries.get(s);if(a.index?.has(o)){let l=a.byTicker?.get(o);return {provider:s,ticker:l!=null&&oo(l)?this.loadableTicker(s,l):i}}}if(t.lenient&&this.entries.size===1){let s=this.names()[0],a=this.entries.get(s);if(a.settled&&a.index==null)return {provider:s,ticker:i}}return null}loadableTicker(e,t){return oo(t)?Bm(this.entries.get(e)?.descriptors??[],t)?.ticker??t.ticker:t.ticker}whenResolvable(e,t={}){let n=this.resolve(e,{...t,lenient:true});return n?Promise.resolve(n):new Promise(i=>{let o=this.onChange(a=>{let l=this.resolve(e,{...t,lenient:true});l?(s(),i(l)):a&&this.allSettled()&&this.reportUnresolved(e);}),s=()=>{o(),this.waits.delete(s);};this.waits.add(s);})}allSettled(){for(let e of this.entries.values())if(!e.settled)return false;return true}cancelWaits(){for(let e of [...this.waits])e();}onUnresolved(e){return this.unresolvedCbs.add(e),()=>this.unresolvedCbs.delete(e)}reportUnresolved(e){let t=this.names();console.warn(`[vela] symbol "${e}" not yet resolvable \u2014 registered providers: [${t.join(", ")||"none"}]. Register a provider that serves it.`);for(let n of this.unresolvedCbs)n({symbol:e,providers:t});}candidateOrder(e){let t=this.names();if(e){let n=Gt(e);if(this.entries.has(n))return [n,...t.filter(i=>i!==n)]}return t}displayPrefixOf(e){return this.entries.get(e.provider)?.byTicker?.get(hn(e.ticker))?.prefix??e.provider}canonicalSymbol(e){let t=this.entries.get(e.provider)?.byTicker?.get(hn(e.ticker));return `${t?.prefix??e.provider}:${t?.ticker??e.ticker}`}symbolIconOf(e){let t=e.provider?Gt(e.provider):[...this.entries.keys()][0],n=t!==void 0?this.entries.get(t):void 0;try{return n?.provider.resolveSymbolIcon?.(e)??void 0}catch{return}}symbolIcon(e){if(!e)return;let t=this.entries.get(e.provider)?.byTicker?.get(hn(e.ticker));return this.symbolIconOf({...t??{ticker:e.ticker},provider:t?.provider??e.provider})}symbolsOf(e){return e!=null?this.entries.get(Gt(e))?.descriptors??[]:[...this.entries.entries()].flatMap(([t,n])=>n.descriptors.map(i=>({...i,provider:t})))}infoOf(e){let t=Gt(e),n=this.entries.get(t);if(!n)return {name:t,capabilities:{enumerate:false,stream:false,symbolInfo:false}};let i=n.provider;return i.info?.()??{name:n.name,capabilities:{enumerate:!!i.listSymbols,stream:!!i.subscribe,symbolInfo:!!i.getSymbolInfo}}}indexReady(){return Promise.all([...this.entries.values()].map(e=>e.settle)).then(()=>{})}};function Zr(r){switch(r.kind){case "row":return {label:r.label,toggle:r.toggle,controls:r.controls,when:r.when};case "toggle":{let e=[];r.number&&e.push({kind:"number",...r.number});for(let t of r.colors??[])e.push({kind:"color",...t});return r.width&&e.push({kind:"width",...r.width}),{label:r.label,toggle:{key:r.key,defval:r.defval},controls:e,when:r.when}}case "number":return {label:r.label,controls:[{kind:"number",key:r.key,label:r.label,defval:r.defval,min:r.min,max:r.max,step:r.step}],when:r.when};case "color":return {label:r.label,controls:[{kind:"color",key:r.key,label:r.label,defval:r.defval}],when:r.when};case "select":return {label:r.label,controls:[{kind:"select",key:r.key,label:r.label,options:r.options,defval:r.defval}],when:r.when};case "range":return {label:r.label,controls:[{kind:"number",key:r.minKey,label:`${r.label} \u2014 min`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder},{kind:"hint",text:"\u2013"},{kind:"number",key:r.maxKey,label:`${r.label} \u2014 max`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder}],when:r.when}}}function so(r){if(r.kind==="heading"||r.kind==="header")return [];let e=Zr(r),t=[];e.toggle&&t.push({key:e.toggle.key,type:"boolean",defval:e.toggle.defval});for(let n of e.controls)n.kind!=="hint"&&(n.kind==="color"||n.kind==="select"?t.push({key:n.key,type:"string",defval:n.defval}):t.push({key:n.key,type:"number",defval:n.defval}));return t}function br(r,e){return r?(Array.isArray(r)?r:[r]).every(n=>n.anyOf?n.anyOf.some(i=>i===e[n.key]):e[n.key]===n.equals):true}var ao=new Map;function _u(r){ao.set(r.id,r);}function d1(r){ao.delete(r);}function pn(r){return typeof r=="string"?ao.get(r):void 0}function Mt(){return [...ao.values()]}function Bu(){return [...ao.values()].filter(r=>r.tickerModifier??r.barTransform!=null).map(r=>r.id)}function Jr(r){return pn(r)?.barTransform??null}function Hm(r){let e=r.lastIndexOf(";");if(e<=0||e===r.length-1)return {symbol:r,modifier:null,transform:null};let t=r.slice(e+1).toLowerCase();return t!=="standard"&&!Bu().includes(t)?{symbol:r,modifier:null,transform:null}:{symbol:r.slice(0,e),modifier:t,transform:Jr(t)}}var Yt={background:"#151619",textColor:"#b2b5be",gridColor:"#20222c",borderColor:"#2a2b30",upColor:z,downColor:W,fontFamily:"sans-serif"},lo={background:"#ffffff",textColor:"#1e293b",gridColor:"#cccccc",borderColor:"#d4dae3",upColor:z,downColor:W,fontFamily:"sans-serif"};function Qr(r){return !r||r==="dark"?Yt:r==="light"?lo:r}var h1=150,p1=1e3,m1=300,f1=5e3,zm=1e4,g1=20,b1=1.5,$m=5e3,tl=class r{constructor(e,t,n,i,o,s){this.renderer=t;this.feed=n;this.config=o;this.dataControl=s;this.events=new er;this.registry=new Fs;this.paneOrder=["price"];this.collapsedPanes=new Set;this.maximizedPaneId=null;this.paneActionUnsub=null;this.handles=new Map;this.engines=new Map;this.live=null;this.bars=[];this.rawBars=[];this.barTransform=null;this.typeEngines=new Map;this.typeSettings=new Map;this.activeEngineStyle=null;this.priceStyle="candles";this.unresolvedUnsub=null;this.visibleRange=null;this.viewportUnsub=null;this.viewportTimer=null;this.healing=false;this.healBuffer=[];this.lastHealAt=0;this.onVisible=null;this.barCause="tick";this.historyState="complete";this.generation=0;this.progressiveAbort=null;this.supersedeWaiters=[];this.historyCompleted=false;this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});this.switchingMarket=false;this.loadingUp=false;this.volumeOptedOut=false;this.contextEmitAt=new Map;this.runEmitAt=new Map;for(let c of i)this.registerEngine(c.language,c);this.defaultLanguage=o.defaultLanguage,this.renderer.mount(e,o.theme),this.renderer.onInputChange(c=>c.kind==="prop"?this.applyProps(c.indicatorId,{[c.key]:c.value}):this.applyInputs(c.indicatorId,{[c.key]:c.value})),this.renderer.onRemoveIndicator(c=>this.removeIndicator(c)),this.renderer.onToggleIndicatorVisible?.((c,u)=>this.setVisible(c,u)),this.paneActionUnsub=this.renderer.onPaneAction?.(c=>this.handlePaneAction(c))??null,this.renderer.onChartTypeSettingsChange?.((c,u)=>{this.typeSettings.set(c,u),this.typeEngines.get(c)?.onSettings?.(u);}),this.renderer.onMoveIndicator?.((c,u)=>this.moveIndicator(c,u)),this.renderer.onThemeSelect?.(c=>this.setTheme(Qr(c))),this.viewportUnsub=this.renderer.onViewportChange(c=>this.onViewportChange(c)),this.renderer.onPriceStyleChange?.(c=>this.syncPriceStyle(c));let a=this.renderer.readFeature("priceStyle");typeof a=="string"&&(this.priceStyle=a),this.barTransform=Jr(a);let l=new Qa({fetchBars:(c,u)=>this.fetchSeries(this.config.market.symbol??"",c,u),canFetch:()=>!!this.feed.loadRange&&!this.config.market.data?.length&&!!this.config.market.symbol,chartTimeframe:()=>this.config.market.timeframe??"60",marketKey:()=>`${this.config.market.symbol??""}|${this.config.market.session??""}`});this.drawings=new Za(this.renderer,this.events,o.drawings,l),this.marks=new Ja(this.renderer,this.events),this.unresolvedUnsub=this.feed.onUnresolved?.(c=>{this.endLoad(),this.events.emit("data:unresolved",c);})??null,this.readyPromise=this.init(),pn(a)?.dataEngine&&this.syncChartTypeEngine(a);}currentVisibleRange(){if(this.visibleRange)return this.visibleRange;let e=this.renderer.getVisibleRange();return e?{left:e.from,right:e.to}:void 0}engineFor(e){let t=e??this.defaultLanguage,n=this.engines.get(t);if(!n)throw new Error(`[vela] no scripting engine registered for language "${t}". Vela ships none \u2014 install one (Pine Script: @luxalgo/vela-pinets) and register it before addIndicator, e.g. chart.registerEngine('pine', new PineEngine()).`);return n}market(){return {symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",symbolInfo:this.feed.symbolInfo?.(this.config.market),chartStyle:this.priceStyle}}async fetchSeries(e,t,n){let i=Hm(e),o={symbol:i.symbol,timeframe:t},s=await(this.feed.loadRange?this.feed.loadRange(o,n):this.feed.load({...o,bars:n.limit}));return i.transform?i.transform.full(s):s}onViewportChange(e){this.visibleRange={left:e.from,right:e.to},this.events.emit("viewport:changed",{from:e.from,to:e.to}),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportTimer=setTimeout(()=>{if(this.viewportTimer=null,this.switchingMarket)return;let t=this.visibleRange;if(t){for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session&&n.prepared?.reactsToViewport?(n.pendingCause="viewport",n.session.setVisibleRange(t)):n.native?.descriptor.reactsToViewport&&n.native.instance.onViewport({from:t.left,to:t.right}));this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.onViewport?.({from:t.left,to:t.right});}},h1);}async init(){let e=this.bumpGeneration();this.beginLoad(true),await this.loadMarket(e,{firstLoad:true}),this.generation===e&&(this.startLive(),this.events.emit("ready",void 0));}bumpGeneration(){let e=++this.generation;this.progressiveAbort?.abort(),this.progressiveAbort=null;for(let t of this.supersedeWaiters.splice(0))t();return e}beginLoad(e){if(this.loadingUp)return;this.loadingUp=true,this.renderer.setLoading?.(true);let t=this.config.market;this.events.emit("load:start",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",firstLoad:e});}endLoad(){if(!this.loadingUp)return;this.loadingUp=false,this.renderer.setLoading?.(false);let e=this.config.market;this.events.emit("load:end",{symbol:e.symbol??"TEST",timeframe:e.timeframe??"60",bars:this.bars.length});}async loadMarket(e,t){try{await this.loadMarketInner(e,t);}finally{this.generation===e&&this.endLoad();}}async loadMarketInner(e,t){let n=this.config.market,i=n.bars??500,o=n.visibleRange,s=!n.data?.length&&o==null&&i>f1,a=false;if(!n.data?.length&&o==null&&this.feed.loadProgressive){let l=false,c=(d,h)=>{this.generation!==e||!h&&d.length===0||!l&&!h&&d.length<Math.min(i,g1)||(this.setBarSeries(d,l?{preserveView:true}:void 0),!l&&d.length>0&&(l=true,t.firstLoad&&this.activateBarLayers(),h||(this.historyState="backfill")));},u=new AbortController;this.progressiveAbort=u,a=await new Promise(d=>{let h=false,p=m=>{h||(h=true,d(m));};u.signal.addEventListener("abort",()=>p(true),{once:true}),this.feed.loadProgressive(n,m=>{c(m,false),l&&p(true);},{signal:u.signal}).then(m=>{if(this.progressiveAbort===u&&(this.progressiveAbort=null),m==null)return p(false);if(this.generation!==e)return p(true);c(m,true),this.completeHistory(m.length>=i?"depth":"genesis"),p(true);}).catch(()=>{this.progressiveAbort===u&&(this.progressiveAbort=null),this.generation===e&&this.completeHistory("aborted"),p(true);});});}if(!a)if(s&&this.feed.loadRange){let l=await this.feed.load({...n,bars:Math.min(i,zm)});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),l.length>0&&i>l.length?(this.historyState="backfill",this.backfillHistory(e,i)):this.completeHistory("depth");}else if(s){let l=await this.feed.load({...n,bars:m1});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers();let c=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(c,{preserveView:true}),this.completeHistory("depth");}else {let l=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),this.completeHistory("depth");}o!=null&&(typeof o=="string"?this.setVisibleRangePreset(o):this.renderer.setVisibleRange(o)),this.refreshPriceFormat(),this.ensurePriceFormat();}startLive(){this.config.live&&(this.live=new _s(this.feed,this.config.market,e=>this.onBar(e)),this.live.start(),typeof document<"u"&&(this.onVisible=()=>{if(document.visibilityState!=="visible")return;let e=this.bars[this.bars.length-1];!e||this.healing||!this.canHeal()||Date.now()-this.lastHealAt<=$m||this.healGap(e.time);},document.addEventListener("visibilitychange",this.onVisible)));}stopLive(){this.live?.stop(),this.live=null,this.onVisible&&typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisible),this.onVisible=null,this.healing=false,this.healBuffer=[],this.lastHealAt=0;}resetHistoryTracking(){this.resolveHistoryComplete(),this.historyCompleted=false,this.historyState="complete",this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});}marketSnapshot(){let e=this.config.market;return {symbol:e.symbol,provider:Ut(e.symbol??"").provider??void 0,timeframe:e.timeframe,bars:e.bars,session:e.session,offline:e.data!==void 0}}async setMarket(e){let t=this.config.market,n=e.symbol!==void 0&&e.symbol!==t.symbol||e.timeframe!==void 0&&e.timeframe!==t.timeframe||e.session!==void 0&&e.session!==t.session||e.data!==void 0,i=e.bars!==void 0&&e.bars!==t.bars,o=i&&!n&&this.rawBars.length>0&&!t.data?.length&&((e.bars??0)<=this.rawBars.length||typeof this.feed.loadRange=="function");if(!n&&!i){typeof e.visibleRange=="string"?this.setVisibleRangePreset(e.visibleRange):e.visibleRange&&this.renderer.setVisibleRange(e.visibleRange);return}let s={symbol:t.symbol??"TEST",timeframe:t.timeframe??"60"},l=n&&e.session!==void 0&&e.data===void 0&&(e.symbol===void 0||e.symbol===t.symbol)&&(e.timeframe===void 0||e.timeframe===t.timeframe)&&e.visibleRange===void 0?this.currentVisibleRange():void 0,c=l?this.rawBars.filter(d=>d.time>=l.left&&d.time<=l.right).length:0,u=this.bumpGeneration();this.switchingMarket=true;try{if(this.stopLive(),this.viewportTimer!=null&&(clearTimeout(this.viewportTimer),this.viewportTimer=null),this.visibleRange=null,this.resetHistoryTracking(),e.symbol!==void 0&&(t.symbol=e.symbol),e.timeframe!==void 0&&(t.timeframe=e.timeframe),e.bars!==void 0&&(t.bars=e.bars),e.session!==void 0&&(t.session=e.session),l){let d=Math.min(Math.ceil((Date.now()-l.left)/this.barIntervalMs())+50,5e3);d>(t.bars??500)&&(t.bars=d);}if(e.data!==void 0?t.data=e.data:e.symbol!==void 0&&delete t.data,t.visibleRange=e.visibleRange??(l?{from:l.left,to:l.right}:void 0),n&&(this.beginLoad(!1),this.setBarSeries([],{clearing:!0}),this.blankIndicatorVisuals(),this.activeEngineStyle&&(this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.renderer.setNativeData?.(this.activeEngineStyle,void 0),this.renderer.setNativeData?.(`${this.activeEngineStyle}-pending`,[]))),o?this.extendDepth(u,t.bars??500):await Promise.race([this.loadMarket(u,{firstLoad:!1}),new Promise(d=>this.supersedeWaiters.push(d))]),this.generation!==u)return}finally{this.generation===u&&(this.switchingMarket=false);}if(l&&c>=2&&this.rawBars.length>0){let d=this.rawBars,h=d.length-1;for(;h>0&&d[h].time>l.right;)h-=1;let p=d[Math.max(0,h-(c-1))].time;this.renderer.setVisibleRange({from:p,to:Math.max(l.right,d[h].time+1)});}o||(this.restartNativeIndicators(),this.restartChartTypeEngine(),this.reexecuteIndicators()),this.startLive(),n&&this.events.emit("market:changed",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",prev:s});}restartNativeIndicators(){for(let e of this.registry.all())if(e.native)if(e.native.started&&e.native.instance.stop(),e.native.instance=e.native.descriptor.create(),e.native.started=false,e.pendingStructural=true,e.hidden)e.native.stale=true;else {let t=this.handles.get(e.id);t&&this.startNativeIndicator(e.id,t);}}restartChartTypeEngine(){for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle&&this.startChartTypeEngine(this.activeEngineStyle);}activateBarLayers(){this.maybeAutoAddVolume();}extendDepth(e,t){if(this.rawBars.length>t){this.setBarSeries(this.rawBars.slice(this.rawBars.length-t),{preserveView:true}),this.completeHistory("depth");return}if(this.rawBars.length===t){this.completeHistory("depth");return}this.historyState="backfill",this.backfillHistory(e,t);}async backfillHistory(e,t){try{for(;this.generation===e&&this.rawBars.length<t&&this.rawBars.length>0;){let n=t-this.rawBars.length,i=zm,o=await this.feed.loadRange(this.config.market,{to:this.rawBars[0].time,limit:Math.min(i,n)+1});if(this.generation!==e)return;let s=this.rawBars[0].time,a=o.filter(l=>l.time<s);if(a.length===0){this.completeHistory("genesis");return}for(let l=1;l<a.length;l+=1)if(a[l].time<=a[l-1].time){console.warn("[vela] non-monotonic history chunk \u2014 stopping the backfill"),this.completeHistory("aborted");return}this.setBarSeries([...a,...this.rawBars],{preserveView:!0}),this.notifySessionsBars("backfill"),this.events.emit("history:progress",{loaded:this.rawBars.length,target:t});}this.generation===e&&this.completeHistory("depth");}catch(n){console.warn(`[vela] history backfill failed \u2014 keeping ${this.rawBars.length} bars (${n instanceof Error?n.message:String(n)})`),this.generation===e&&this.completeHistory("aborted");}}completeHistory(e){this.historyCompleted||(this.historyCompleted=true,this.historyState="complete",this.notifySessionsBars("complete"),this.events.emit("history:complete",{reason:e,oldestTime:this.rawBars[0]?.time??0,barsLoaded:this.rawBars.length}),this.resolveHistoryComplete());}historyComplete(){return this.historyCompletePromise}qualifiedSymbol(){let e=this.config.market;return e.symbol?e.symbol:null}refreshPriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.feed.symbolInfo?.(this.config.market)?.mintick;this.renderer.setPricePrecision(typeof e=="number"&&e>0?e:void 0);}async ensurePriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.qualifiedSymbol();if(e)try{await this.dataControl.symbolInfo(e),this.refreshPriceFormat();}catch{}}maybeAutoAddVolume(){!this.config.volume||this.volumeOptedOut||!this.renderer.setNativeData||Ui("volume")&&this.addNativeIndicator("volume");}syncPriceStyle(e){typeof e=="string"&&(this.priceStyle=e),this.syncBarTransform(e),this.syncChartTypeEngine(e);}syncChartTypeEngine(e){let t=typeof e=="string"?e:null,i=pn(t)?.dataEngine?t:null;i!==this.activeEngineStyle&&(this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.activeEngineStyle=i,i&&this.startChartTypeEngine(i));}async startChartTypeEngine(e){if(!this.renderer.setNativeData||(await this.readyPromise,this.activeEngineStyle!==e))return;let t=this.typeEngines.get(e);if(t){t.resume();return}let n=pn(e);if(!n?.dataEngine)return;let i=n.dataEngine();this.typeEngines.set(e,i);let o=this.typeSettings.get(e);o&&i.onSettings?.(o),i.start({symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live??false,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,pushData:s=>this.renderer.setNativeData?.(e,s),pushPending:s=>this.renderer.setNativeData?.(`${e}-pending`,s)});}syncBarTransform(e){let t=Jr(e);t!==this.barTransform&&(this.barTransform=t,this.rawBars.length!==0&&(this.bars=t?t.full(this.rawBars):this.rawBars,this.renderer.setBars(this.bars,{preserveView:true}),this.reexecuteIndicators()));}blankIndicatorVisuals(){for(let e of this.registry.all())e.hidden||!e.renderHandle||!e.model||(e.model=y1(e.model),e.renderHandle=this.renderer.mountIndicator(e.model),e.pendingStructural=true,this.setLoading(e,true));}reexecuteIndicators(){for(let e of this.registry.all()){if(e.hidden||!e.session)continue;e.session.stop(),e.session=void 0,e.pendingStructural=true,e.pendingCause="market",this.setLoading(e,true);let t=this.handles.get(e.id);t&&this.executeIndicator(e.id,t);}}onBar(e){if(this.healing){this.healBuffer.push(e);return}let t=this.rawBars[this.rawBars.length-1];if(t&&this.canHeal()&&e.time>t.time+this.barIntervalMs()*b1&&Date.now()-this.lastHealAt>$m){this.healBuffer.push(e),this.healGap(t.time);return}this.applyBar(e);}setBarSeries(e,t){this.rawBars=e,this.bars=this.barTransform?this.barTransform.full(e):e,this.renderer.setBars(this.bars,{preserveView:t?.preserveView}),!t?.clearing&&this.bars.length>0&&this.endLoad();}applyBar(e,t=true){let n=this.rawBars[this.rawBars.length-1],i=e;if(n&&e.time===n.time)this.rawBars[this.rawBars.length-1]=e,this.barCause="tick",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-2]),this.bars[this.bars.length-1]=i);else if(!n||e.time>n.time)this.rawBars.push(e),this.barCause="bar",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-1]),this.bars.push(i));else return;this.renderer.updateBar(i),this.events.emit("bar",e),t&&this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}notifySessionsBars(e){if(this.switchingMarket)return;let t=e?"history":this.barCause;for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session?(n.pendingCause=t,n.session.notifyBars(e)):n.native&&n.native.instance.onBars());}canHeal(){return !!this.feed.loadRange&&!this.config.market.data?.length}barIntervalMs(){return Lt(this.config.market.timeframe??"60")}async healGap(e){let t=this.generation;this.healing=true,this.lastHealAt=Date.now();try{let n=await this.feed.loadRange(this.config.market,{from:e});if(this.generation!==t)return;for(let i of n)this.applyBar(i,!1);}catch{}finally{if(this.generation===t){this.healing=false;let n=this.healBuffer;this.healBuffer=[];for(let i of n)this.applyBar(i,false);this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}}}registerEngine(e,t){let n=this.engines.get(e);n&&n!==t&&console.warn(`[vela] re-registering scripting engine for language "${e}"; replacing ${n.constructor.name} with ${t.constructor.name}.`),this.engines.set(e,t);}addIndicator(e,t={}){let n=this.registry.nextId(),i=t.title??"Indicator",o=new zr(n,i,this,e);return this.handles.set(n,o),this.registry.add({id:n,title:i,source:e,options:t,inputValues:{...t.inputs??{}},propValues:{...t.props??{}}}),this.startIndicator(n,e,t,o),o}addNativeIndicator(e,t={}){let n=Ui(e);if(!n?.multiInstance){let l=this.registry.all().find(c=>c.native?.type===e);if(l)return this.handles.get(l.id)??new zr(l.id,l.title,this,void 0,e)}let i=this.registry.nextId("native"),o=n?.title??e,s=new zr(i,o,this,void 0,e);if(this.handles.set(i,s),!n)return console.warn(`[vela] addNativeIndicator("${e}") \u2014 no native indicator registered for this type.`),s;let a={...n.defaultInputs(),...t.inputs??{}};return this.registry.add({id:i,title:o,source:e,inputValues:a,propValues:{},native:{type:e,instance:n.create(),descriptor:n}}),s.setSchema(n.inputsSchema()),this.startNativeIndicator(i,s),s}presentNativeIndicators(){return this.registry.all().map(e=>e.native?.type).filter(e=>!!e)}async availableNativeIndicators(){let e=this.qualifiedSymbol(),t=new Set(this.presentNativeIndicators());return Promise.all(Vs().map(async n=>({type:n.type,title:n.title,supported:await this.isNativeSupported(n,e),present:t.has(n.type),beta:n.beta,...n.multiInstance?{multiInstance:true}:{}})))}async isNativeSupported(e,t){if(!e.isSupported)return true;if(!t)return false;try{return await e.isSupported(t,this.dataControl)}catch{return false}}applyInputs(e,t){let n=this.registry.get(e);!n||!n.session&&!n.native||(n.inputValues={...n.inputValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues),n.pendingStructural=true,!n.hidden&&!n.native&&this.setLoading(n,true),n.pendingCause="inputs",n.session?n.session.update(n.inputValues):n.native&&!n.hidden&&n.native.instance.setInputs(n.inputValues),this.events.emit("indicator:inputs",{id:e}));}inputValuesOf(e){return {...this.registry.get(e)?.inputValues}}propValuesOf(e){return {...this.registry.get(e)?.propValues}}applyProps(e,t){let n=this.registry.get(e);n?.session&&(n.propValues={...n.propValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=true,n.hidden||this.setLoading(n,true),n.pendingCause="inputs",n.session.update(n.inputValues,n.propValues),this.events.emit("indicator:inputs",{id:e}));}updateCode(e,t){let n=this.registry.get(e),i=this.handles.get(e);if(!(!n||!i)){if(n.native){console.warn(`[vela] updateCode("${e}") \u2014 a native indicator has no script to update.`);return}t===n.source&&n.pendingSource===void 0||(n.pendingSource=t,this.swapSource(e,t,i));}}async swapSource(e,t,n){let i=this.registry.get(e)?.engine??this.engineFor(this.registry.get(e)?.options?.language),o;try{o=await i.prepare(t,e);}catch(a){let l=this.registry.get(e);l?.pendingSource===t&&(l.pendingSource=void 0,this.fail(e,n,a));return}let s=this.registry.get(e);!s||s.pendingSource!==t||(s.pendingSource=void 0,s.source=t,s.engine=i,s.prepared=o,n.setSource(t),s.inputValues=Wm(o.inputs,s.inputValues),s.propValues=Wm(o.props??[],s.propValues),n.setSchema(o.inputs),n.setPropsSchema(o.props??[]),s.session?.stop(),s.session=void 0,s.pendingStructural=true,s.pendingCause="code",!s.hidden&&(s.renderHandle?(this.renderer.setIndicatorInputs(s.renderHandle,s.inputValues,s.propValues),this.setLoading(s,true)):this.mountLoadingPlaceholder(e,s),this.executeIndicator(e,n)));}listIndicators(){return [...this.handles.values()]}getIndicatorContext(e,t){return this.registry.get(e)?.session?.getContext?.(t)??Promise.resolve(null)}removeIndicator(e){let t=this.registry.remove(e);t?.native?.type==="volume"&&(this.volumeOptedOut=true),t?.session?.stop(),t?.native?.started&&t.native.instance.stop(),this.handles.delete(e),t?.renderHandle&&this.renderer.removeIndicator(t.renderHandle);let n=t?.model?.paneId;n&&n!=="price"&&!this.paneStillUsed(n)&&(this.renderer.removePane(n),this.forgetPane(n),this.events.emit("pane:changed",void 0)),this.events.emit("indicator:removed",{id:e});}setVisible(e,t){let n=this.registry.get(e);if(!(!n||n.hidden===!t)){if(n.hidden=!t,this.handles.get(e)?.setVisibleState(t),!t)n.session?.stop(),n.session=void 0,n.native?.started&&n.native.instance.suspend(),n.renderHandle?this.renderer.setIndicatorVisible?.(n.renderHandle,false):n.native&&this.mountHiddenNativeRow(e,n);else if(n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,true),n.pendingStructural=true,n.native)if(n.native.stale||!n.native.started){n.native.stale=false;let i=this.handles.get(e);i&&this.startNativeIndicator(e,i);}else n.native.instance.resume();else {this.setLoading(n,true);let i=this.handles.get(e);i&&this.executeIndicator(e,i);}this.events.emit("indicator:visibility",{id:e,visible:t});}}ready(){return this.readyPromise}inspect(){let e=[...this.registry.all()].filter(t=>!t.loading).sort((t,n)=>(n.native?1:0)-(t.native?1:0));return Kp(e.map(t=>t.model).filter(t=>t!=null))}resize(){this.renderer.resize();}setTheme(e){let t=this.config.theme;Object.keys(e).every(n=>e[n]===t[n])||(this.config.theme=e,this.renderer.setTheme(e),this.events.emit("theme:changed",e));}getVisibleRange(){return this.renderer.getVisibleRange()}setVisibleRange(e){this.renderer.setVisibleRange(e);}panBy(e){if(this.renderer.panBy){this.renderer.panBy(e);return}let t=this.renderer.getVisibleRange();if(!t)return;let n=(t.to-t.from)*e;this.renderer.setVisibleRange({from:t.from+n,to:t.to+n});}setVisibleRangePreset(e){let t=Xp(e,this.bars);t&&this.renderer.setVisibleRange(t);}destroy(){this.bumpGeneration(),this.resolveHistoryComplete(),this.stopLive(),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportUnsub?.(),this.paneActionUnsub?.();for(let e of this.registry.all())e.session?.stop(),e.native?.started&&e.native.instance.stop();for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle=null,this.unresolvedUnsub?.(),this.unresolvedUnsub=null,this.feed.destroy?.(),this.drawings.destroy(),this.marks.destroy(),this.renderer.destroy(),this.events.clear();}async startIndicator(e,t,n,i){try{if(await this.readyPromise,!this.registry.get(e))return;await v1();let o=this.registry.get(e);if(!o)return;let s=this.engineFor(n.language);o.engine=s;let a=await s.prepare(t,e);if(o.source!==t)return;o.prepared=a;let l={};for(let u of a.inputs)l[u.key]=u.defval;o.inputValues={...l,...o.inputValues},i.setSchema(a.inputs);let c={};for(let u of a.props??[])c[u.key]=u.defval;o.propValues={...c,...o.propValues},i.setPropsSchema(a.props??[]),this.mountLoadingPlaceholder(e,o),this.executeIndicator(e,i);}catch(o){this.fail(e,i,o);}}executeIndicator(e,t){let n=this.registry.get(e);if(!n||!n.engine||!n.prepared||n.hidden)return;let i=this.config.live&&!n.prepared.reactsToViewport&&n.engine.capabilities.streaming?"live":"static";n.session=n.engine.execute({prepared:n.prepared,market:this.market(),bars:this.bars,getBars:()=>this.bars,fetchSeries:(o,s,a)=>this.fetchSeries(o,s,a),inputs:n.inputValues,props:n.propValues,visibleRange:this.currentVisibleRange(),mode:i,historyState:this.historyState},{onModel:o=>{let s=!n.announced,a=n.pendingCause??"history";this.applyModel(e,o)&&(n.pendingCause=void 0,this.emitContextChanged(e),this.emitScriptRun(e,a,s));},onAlert:o=>{let s=n.options?.title??n.prepared?.meta.title??n.title;this.events.emit("alert",{...o,indicator:s}),t.emit("alert",{id:o.id,message:o.message,title:o.title,time:o.time});},onWarning:o=>this.events.emit("warning",o),onError:o=>this.fail(e,t,o)}),this.emitContextChanged(e);}async startNativeIndicator(e,t){try{await this.readyPromise;let n=this.registry.get(e);if(!n?.native||n.hidden)return;let i=this.nativeChannel(n),o={id:e,symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,emit:s=>this.applyModel(e,this.buildNativeModel(n,s)),pushData:s=>this.renderer.setNativeData?.(i,s),setStatus:s=>{n.renderHandle&&!n.hidden&&this.renderer.setIndicatorStatus?.(n.renderHandle,s);}};n.native.instance.start(o,n.inputValues),n.native.started=!0;}catch(n){this.fail(e,t,n);}}nativeChannel(e){let{type:t,descriptor:n}=e.native;return n.multiInstance?Gp(t,e.id):t}buildNativeModel(e,t){let n=e.native.descriptor,i=e.native.type,o=this.nativeChannel(e);return {id:e.id,title:e.title,...n.shortTitle?{shorttitle:n.shortTitle}:{},overlay:n.overlay,paneHint:n.paneHint,native:{type:i,...o!==i?{channel:o}:{}},...n.legend===false?{legend:false}:{},...t.paneAxis!=null?{paneAxis:t.paneAxis}:{},series:t.series??[],fills:t.fills??[],backgrounds:t.backgrounds??[],priceLines:t.priceLines??[],...t.lines?{lines:t.lines}:{},...t.boxes?{boxes:t.boxes}:{},...t.labels?{labels:t.labels}:{},...t.polylines?{polylines:t.polylines}:{},...t.linefills?{linefills:t.linefills}:{},...t.tables?{tables:t.tables}:{},inputs:n.inputsSchema(),inputValues:e.inputValues}}mountLoadingPlaceholder(e,t){if(t.renderHandle||!t.prepared)return;let n=t.prepared.meta,i={id:e,title:t.options?.title??n.title,overlay:n.overlay,paneHint:n.overlay?"price":"new",series:[],fills:[],backgrounds:[],priceLines:[],inputs:t.prepared.inputs,inputValues:t.inputValues,...t.prepared.props?{props:t.prepared.props,propValues:t.propValues}:{}},o=this.routePane(e,i,t.options??{});if(this.placeModel(i,e,o),t.model=i,this.ensurePaneFor(o),t.renderHandle=this.renderer.mountIndicator(i),t.pendingStructural=true,t.hidden){this.renderer.setIndicatorVisible?.(t.renderHandle,false),this.announce(t,this.handles.get(e));return}this.setLoading(t,true);}mountHiddenNativeRow(e,t){if(t.renderHandle||!t.native)return;let n=this.buildNativeModel(t,{}),i=this.routePane(e,n,t.options??{});this.placeModel(n,e,i),t.model=n,this.ensurePaneFor(i),t.renderHandle=this.renderer.mountIndicator(n),t.pendingStructural=true,this.renderer.setIndicatorVisible?.(t.renderHandle,false),this.announce(t,this.handles.get(e));}setLoading(e,t){e.loading=t,e.renderHandle&&!e.hidden&&this.renderer.setIndicatorStatus?.(e.renderHandle,t?"loading":"idle");}ensurePaneFor(e){this.paneOrder.includes(e)||this.paneOrder.push(e),this.renderer.ensurePane({id:e,kind:e==="price"?"price":"study",order:this.paneOrder.indexOf(e)});}paneStillUsed(e){for(let t of this.registry.all())if(t.model?.paneId===e)return true;return false}forgetPane(e){let t=this.paneOrder.indexOf(e);t>0&&this.paneOrder.splice(t,1),this.collapsedPanes.delete(e),this.maximizedPaneId===e&&(this.maximizedPaneId=null);}paneManagementSupported(){return this.renderer.capabilities.paneManagement===true&&typeof this.renderer.setIndicatorPane=="function"}listPanes(){let e=new Map;for(let n of this.registry.all()){let i=n.model;if(!i||i.legend===false)continue;let o=i.paneId??"price";e.has(o)||e.set(o,[]),e.get(o).push({id:n.id,title:i.title||n.title,...i.shorttitle?{shorttitle:i.shorttitle}:{},ownScale:i.ownScale===true});}let t=[];for(let n of this.paneOrder)n!=="price"&&!e.has(n)||t.push({id:n,kind:n==="price"?"price":"study",order:t.length,collapsed:this.collapsedPanes.has(n),maximized:this.maximizedPaneId===n,indicators:e.get(n)??[]});return t}movePane(e,t){if(e==="price")return;let n=this.existingPaneIds(),i=n.indexOf(e);if(i<0)return;let o=t==="up"?i-1:i+1;o<=0||o>=n.length||([n[i],n[o]]=[n[o],n[i]],this.reorderPanes(n),this.events.emit("pane:moved",{paneId:e,dir:t}));}removePaneAndIndicators(e){if(e!=="price")for(let t of [...this.registry.all()])t.model?.paneId===e&&this.removeIndicator(t.id);}collapsePane(e,t){t?this.collapsedPanes.add(e):this.collapsedPanes.delete(e),this.renderer.setPaneCollapsed?.(e,t),this.events.emit("pane:changed",void 0);}maximizePane(e){this.maximizedPaneId=e,this.renderer.setPaneMaximized?.(e),this.events.emit("pane:changed",void 0);}moveIndicator(e,t){if(!this.paneManagementSupported()||!this.renderer.setIndicatorPane){console.warn("[vela] the active renderer does not support moving indicators between panes.");return}let n=this.registry.get(e);if(!n?.renderHandle||!n.model)return;let i=n.model,o=i.paneId??"price",s=this.resolveMoveTarget(e,i,t);if(!s)return;let{paneId:a,ownScale:l,insert:c}=s;a===o&&i.ownScale===true===l||(c?this.insertPaneOrder(a,c):this.paneOrder.includes(a)||this.paneOrder.push(a),i.ownScale=l,n.paneLocked=true,this.placeModel(i,e,a),this.ensurePaneFor(a),this.renderer.setIndicatorPane(n.renderHandle,a,{ownScale:l}),o!=="price"&&o!==a&&!this.paneStillUsed(o)&&(this.renderer.removePane(o),this.forgetPane(o)),this.reorderPanes(this.existingPaneIds()),this.events.emit("indicator:moved",{id:e,paneId:a}),this.events.emit("pane:changed",void 0));}resolveMoveTarget(e,t,n){if(n==="price"||typeof n=="object"&&"pane"in n&&n.pane==="price")return {paneId:"price",ownScale:!t.overlay};if("pane"in n)return this.existingPaneIds().includes(n.pane)?{paneId:n.pane,ownScale:true}:null;let i=n.newPane===true?{}:n.newPane;return {paneId:this.freshPaneId(e,t.paneId??"price"),ownScale:false,insert:i}}freshPaneId(e,t){let n=new Set(this.existingPaneIds()),i=`pane-${e}`;for(let o=2;i===t||n.has(i);o+=1)i=`pane-${e}-${o}`;return i}insertPaneOrder(e,t){let n=this.paneOrder.indexOf(e);n>0&&this.paneOrder.splice(n,1);let i=this.paneOrder.length;t.before&&this.paneOrder.includes(t.before)?i=this.paneOrder.indexOf(t.before):t.after&&this.paneOrder.includes(t.after)&&(i=this.paneOrder.indexOf(t.after)+1),i<1&&(i=1),this.paneOrder.splice(i,0,e);}existingPaneIds(){return this.paneOrder.filter(e=>e==="price"||this.paneStillUsed(e))}reorderPanes(e){this.paneOrder.length=0,this.paneOrder.push(...e),this.renderer.orderPanes?.(e),this.events.emit("pane:changed",void 0);}handlePaneAction(e){switch(e.type){case "remove":this.removePaneAndIndicators(e.paneId);break;case "move":{let t=this.existingPaneIds(),n=t.indexOf(e.paneId),i=e.dir==="up"?n-1:n+1;n>0&&i>0&&i<t.length&&([t[n],t[i]]=[t[i],t[n]],this.paneOrder.length=0,this.paneOrder.push(...t),this.events.emit("pane:changed",void 0),this.events.emit("pane:moved",{paneId:e.paneId,dir:e.dir}));break}case "collapse":e.collapsed?this.collapsedPanes.add(e.paneId):this.collapsedPanes.delete(e.paneId),this.events.emit("pane:changed",void 0);break;case "maximize":this.maximizedPaneId=e.maximized?e.paneId:null,this.events.emit("pane:changed",void 0);break}}announce(e,t){e.announced||(e.announced=true,this.events.emit("indicator:added",{id:e.id}),this.emitContextChanged(e.id),t?.emit("ready",void 0));}applyModel(e,t){let n=this.registry.get(e);if(!n||n.hidden)return true;if(this.switchingMarket||n.loading&&this.bars.length===0&&!r.modelHasOutput(t))return false;let i=this.handles.get(e);if(!n.renderHandle){let a=this.routePane(e,t,n.options??{});return this.placeModel(t,e,a),n.model=t,this.ensurePaneFor(a),n.renderHandle=this.renderer.mountIndicator(t),n.pendingStructural=false,this.announce(n,i),true}let o=n.model?.paneId??"price",s=n.model?.ownScale===true;if(n.loading&&!n.paneLocked){let a=this.routePane(e,t,n.options??{});a!==o&&(o!=="price"&&!this.registry.all().some(l=>l.id!==e&&l.model?.paneId===o)&&(this.renderer.removePane(o),this.forgetPane(o)),this.ensurePaneFor(a),n.pendingStructural=true,o=a);}return this.placeModel(t,e,o),n.paneLocked&&(t.ownScale=s),n.model=t,n.pendingStructural?(n.renderHandle=this.renderer.mountIndicator(t),this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=false):this.renderer.updateIndicator(n.renderHandle,w1(t)),n.loading&&this.setLoading(n,false),this.announce(n,i),true}static modelHasOutput(e){return e.series.length>0||e.fills.length>0||e.backgrounds.length>0||e.priceLines.length>0||(e.lines?.length??0)>0||(e.boxes?.length??0)>0||(e.labels?.length??0)>0||(e.polylines?.length??0)>0||(e.linefills?.length??0)>0||(e.tables?.length??0)>0||(e.barColors?.length??0)>0||(e.trades?.length??0)>0}routePane(e,t,n){return n.pane==="new"?`pane-${e}`:n.pane==="price"||(n.overlay??t.overlay)?"price":`pane-${e}`}static plotsAtLastBar(e){let t={};for(let n of e.series)Fe(n)&&(t[n.title]=n.points[n.points.length-1]?.value??null);return t}placeModel(e,t,n){e.id=t,e.paneId=n;let i=o=>o.overlay===true?"price":n;for(let o of e.series)o.paneId=i(o);for(let o of e.fills)o.paneId=i(o);for(let o of e.backgrounds)o.paneId=i(o);for(let o of e.priceLines)o.paneId=n;if(e.lines)for(let o of e.lines)o.paneId=i(o);if(e.boxes)for(let o of e.boxes)o.paneId=i(o);if(e.labels)for(let o of e.labels)o.paneId=i(o);if(e.polylines)for(let o of e.polylines)o.paneId=i(o);if(e.linefills)for(let o of e.linefills)o.paneId=i(o);if(e.tables)for(let o of e.tables)o.paneId=i(o);}emitContextChanged(e){if(!this.registry.get(e)?.session?.getContext)return;let t=Date.now();t-(this.contextEmitAt.get(e)??0)<1e3||(this.contextEmitAt.set(e,t),this.events.emit("context:changed",{id:e}));}emitScriptRun(e,t,n){let i=this.registry.get(e);if(!i||i.native||!this.events.hasListeners("script:run"))return;let o=Date.now();t==="tick"&&o-(this.runEmitAt.get(e)??0)<p1||(this.runEmitAt.set(e,o),Promise.resolve().then(()=>this.buildScriptRun(i,t,n)).then(s=>{s&&this.registry.get(e)&&this.events.emit("script:run",s);}));}async buildScriptRun(e,t,n){let i=e.model;if(!i)return null;let o=await this.pullContext(e,["variables","strategy","warnings"]),s=this.bars[this.bars.length-1];return {id:e.id,title:i.title,kind:o?.strategy||(i.trades?.length??0)>0?"strategy":"indicator",cause:t,first:n,bar:Math.max(0,this.bars.length-1),time:s?.time??0,forming:this.config.live&&this.bars.length>0,complete:this.historyState!=="backfill",plots:r.plotsAtLastBar(i),vars:o?.variables??{},...o?.strategy?{strategy:o.strategy}:{},warnings:o?.warnings??[],trades:async()=>(await this.pullContext(e,["trades"]))?.trades??[],series:async a=>((await this.pullContext(e,["plots"]))?.plots?.[a]??[]).map(c=>({time:c.time,value:typeof c.value=="number"?c.value:null}))}}async pullContext(e,t){try{return await e.session?.getContext?.(t)??null}catch{return null}}fail(e,t,n){let i=this.registry.get(e);i?.loading&&this.setLoading(i,false);let o=n instanceof Error?n:new Error(String(n));console.error(`[vela] indicator "${e}" failed:`,o.message),this.events.emit("indicator:error",{id:e,error:o}),t?.emit("error",{error:o});}};function v1(){return typeof requestAnimationFrame=="function"?new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(()=>r()))):new Promise(r=>setTimeout(r,0))}function Wm(r,e){let t={},n=new Set;for(let i of r)t[i.key]=i.defval,n.add(i.key),n.add(i.title);for(let[i,o]of Object.entries(e))n.has(i)&&(t[i]=o);return t}function y1(r){return {...r,series:r.series.map(e=>e.kind==="candle"||e.kind==="bar"?{...e,bars:[]}:e.kind==="markers"?{...e,markers:[]}:{...e,points:[]}),fills:[],backgrounds:[],priceLines:[],lines:[],boxes:[],labels:[],polylines:[],linefills:[],tables:[],barColors:[],trades:[]}}function w1(r){let e=[],t=Number.POSITIVE_INFINITY,n=0;for(let i of r.series)if(i.kind==="candle"||i.kind==="bar"){e.push({seriesId:i.id,kind:"bars",bars:i.bars});for(let o of i.bars)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}else if(Fe(i)){e.push({seriesId:i.id,kind:"points",points:i.points});for(let o of i.points)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}return {kind:"value",indicatorId:r.id,dirty:{from:Number.isFinite(t)?t:0,to:n},anchorTime:r.anchorTime??null,series:e,lines:r.lines??[],boxes:r.boxes??[],labels:r.labels??[],polylines:r.polylines??[],linefills:r.linefills??[],tables:r.tables??[],trades:r.trades??[]}}var co=class{constructor(e){this.renderer=e;}get name(){return this.renderer.name}get capabilities(){return this.renderer.capabilities}supports(e){return this.renderer.features.includes(e)}get(e){return this.renderer.readFeature(e)}set(e,t){let n=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[i,o]of n)this.renderer.features.includes(i)?this.renderer.applyFeature(i,o):console.warn(`[vela] renderer "${this.renderer.name}" has no feature "${i}" \u2014 set ignored.`);return this}setLegendActions(e){this.renderer.setLegendActions?.(e);}setLegendCallouts(e){this.renderer.setLegendCallouts?.(e);}setLegendOverviewAction(e){return this.renderer.setLegendOverviewAction?.(e),this}get supportsIndicatorSettings(){return typeof this.renderer.openIndicatorSettings=="function"}openIndicatorSettings(e){return this.renderer.openIndicatorSettings?.(e),this}screenshot(){return typeof this.renderer.screenshot=="function"?this.renderer.screenshot():(console.warn(`[vela] renderer "${this.renderer.name}" does not support screenshot().`),null)}screenshotCanvas(){return typeof this.renderer.screenshotCanvas=="function"?this.renderer.screenshotCanvas():null}getConfig(){return typeof this.renderer.getConfig=="function"?this.renderer.getConfig():(console.warn(`[vela] renderer "${this.renderer.name}" does not support getConfig().`),null)}applyConfig(e){return typeof this.renderer.applyConfig=="function"?this.renderer.applyConfig(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support applyConfig().`),this}onConfigChanged(e){return this.renderer.onConfigChanged?.(e)??(()=>{})}onCrosshairMove(e){return this.renderer.onCrosshairMove(e)}onAxisLongPress(e){return this.renderer.onAxisLongPress?.(e)??(()=>{})}dataWindowReadout(){return this.renderer.getDataWindowReadout?.()??null}setSymbolPicker(e){return typeof this.renderer.setSymbolPicker=="function"?this.renderer.setSymbolPicker(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support setSymbolPicker().`),this}focus(){return this.renderer.focus?.(),this}get supportsExternalCrosshair(){return typeof this.renderer.setExternalCrosshair=="function"}setExternalCrosshair(e,t=null){return this.renderer.setExternalCrosshair?.(e,t),this}closeDialogs(){return this.renderer.closeDialogs?.(),this}openSettings(e){return this.renderer.openSettingsDialog?.(e),this}setSettingsSections(e){return this.renderer.setSettingsSections?.(e),this}setSettingsVisibility(e){return this.renderer.setSettingsVisibility?.(e),this}listSettingsIds(){return this.renderer.listSettingsIds?.()??[]}setLayoutMode(e){return this.renderer.setLayoutMode?.(e),this}setWallClock(e){return this.renderer.setWallClock?.(e),this}};var ei=new Map;function x1(r){let e=Object.entries(r);for(let[t,n]of e)ei.set(t,n);return ()=>{for(let[t,n]of e)ei.get(t)===n&&ei.delete(t);}}function S1(...r){if(r.length===0)ei.clear();else for(let e of r)ei.delete(e);}function Hu(){return Object.fromEntries(ei)}var nl=class{constructor(e){this.controller=e;}get supported(){return this.controller.paneManagementSupported()}list(){return this.controller.listPanes()}move(e,t){return this.guard()&&this.controller.movePane(e,t),this}remove(e){return this.guard()&&this.controller.removePaneAndIndicators(e),this}collapse(e,t=true){return this.guard()&&this.controller.collapsePane(e,t),this}maximize(e){return this.guard()&&this.controller.maximizePane(e),this}moveIndicator(e,t){return this.guard()&&this.controller.moveIndicator(e,t),this}guard(){return this.controller.paneManagementSupported()?true:(console.warn("[vela] the active renderer does not support pane management \u2014 chart.panes mutation ignored."),false)}};function Gm(r,e,t,n){return `${r}|${e}|${t}${n&&n!=="regular"?`|${n}`:""}`}function C1(r){return r.split("|")[1]??""}var rl=class{constructor(){this.series=new Map;this.coveredFrom=new Map;this.retained=new Set;this.retainedByOwner=new Map;}get(e){return this.series.get(e)}markCovered(e,t){this.coveredFrom.set(e,Math.min(this.coveredFrom.get(e)??1/0,t));}coveredFromOf(e){return this.coveredFrom.get(e)}merge(e,t){if(t.length===0)return this.series.get(e)??[];let n=new Map;for(let o of this.series.get(e)??[])n.set(o.time,o);for(let o of t)n.set(o.time,o);let i=[...n.values()].sort((o,s)=>o.time-s.time);return this.series.set(e,i),i}retainSymbol(e){this.currentSymbol!==e&&(this.currentSymbol=e,this.purgeOutside(e));}retain(e,t="default"){e.size===0?this.retainedByOwner.delete(t):this.retainedByOwner.set(t,new Set(e));let n=new Set;for(let i of this.retainedByOwner.values())for(let o of i)n.add(o);this.retained=n,this.purgeOutside(this.currentSymbol);}purgeOutside(e){for(let t of [...this.series.keys()]){let n=C1(t);n!==e&&!this.retained.has(n)&&(this.series.delete(t),this.coveredFrom.delete(t));}}clear(){this.series.clear(),this.coveredFrom.clear();}},uo=new rl;function zu(r,e,t){let{provider:n,ticker:i}=Ut(r);return Gm(n??"",i,e,t)}var po=1e4,T1=po+1,mo=class{constructor(e,t=uo){this.inner=e;this.store=t;}async load(e){if(e.data&&e.data.length>0)return this.inner.load(e);let t=e.symbol??"TEST",n=zu(t,e.timeframe??"60",e.session);this.store.retainSymbol(t);let i=this.store.get(n),o=e.bars??500,s=i?.[i.length-1];if(i&&s&&i.length>=o-1&&this.inner.loadRange){let{bars:l}=await this.fetchRange(e,{from:s.time}),c=this.store.merge(n,ho(l));return Um(c,l[l.length-1]).slice(-o)}let a=await this.inner.load(e);return this.store.merge(n,ho(a)),a}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.inner.load(e);if(!this.inner.loadProgressive)return null;let i=e.symbol??"TEST",o=zu(i,e.timeframe??"60",e.session),s=this.store.get(o),a=e.bars??500,l=s?.[s.length-1];if(s&&l&&s.length>=a-1&&this.inner.loadRange)return this.load(e);this.store.retainSymbol(i);let c=await this.inner.loadProgressive(e,t,n);return c==null?null:(this.store.merge(o,ho(c)),c)}async loadRange(e,t){if(!this.inner.loadRange)return this.inner.load(e);let n=zu(e.symbol??"TEST",e.timeframe??"60",e.session),i=this.store.get(n),o=i?.[i.length-1];if(t.to!=null&&o&&t.to<o.time){let u=i.filter(f=>f.time<=t.to),d=this.store.coveredFromOf(n)??1/0;if(t.limit!=null?u.length>=t.limit&&(t.from==null||d<=t.from):t.from!=null&&d<=t.from){let f=t.from!=null?u.filter(g=>g.time>=t.from):u;return t.limit!=null&&f.length>t.limit&&(f=f.slice(-t.limit)),f}let p=await this.fetchRange(e,t),m=p.bars.filter(f=>f.time<=t.to);return m.length>0&&(this.store.merge(n,m),this.store.markCovered(n,p.coveredDownTo??m[0].time)),m}if(o&&t.from!=null){let u=this.store.coveredFromOf(n);if(u!=null&&u>t.from){let{bars:d,coveredDownTo:h}=await this.fetchRange(e,{from:t.from,to:u});this.store.merge(n,d.filter(p=>p.time<=u)),this.store.markCovered(n,h??t.from),i=this.store.get(n),o=i?.[i.length-1];}}let s=this.store.coveredFromOf(n);if(!!i&&i.length>0&&!!o&&(t.from!=null?s!=null&&s<=t.from:t.limit==null||i.length>=t.limit)&&o){let{bars:u}=await this.fetchRange(e,{from:o.time,to:t.to,limit:t.limit}),d=this.store.merge(n,ho(u)),h=Um(d,u[u.length-1]),p=t.from!=null?h.filter(m=>m.time>=t.from):h;return t.to!=null&&(p=p.filter(m=>m.time<=t.to)),p}let{bars:l,coveredDownTo:c}=await this.fetchRange(e,t);return this.store.merge(n,ho(l)),this.store.markCovered(n,c??t.from??l[0]?.time??0),l}async fetchRange(e,t){let n=Lt(e.timeframe??"60"),i=k1(t,n);if(i<=T1){let c=await this.inner.loadRange(e,{...t,limit:t.limit??i});return {bars:c,coveredDownTo:t.from??c[0]?.time}}let o=new Map,s=t.to??Date.now();for(;!(t.from!=null&&s<t.from);){let c=t.limit!=null?t.limit-o.size:po;if(c<=0)break;let u=await this.inner.loadRange(e,{to:s,limit:Math.min(po,c)}),d=1/0;for(let h of u)h.time<d&&(d=h.time),h.time<=s&&(t.from==null||h.time>=t.from)&&o.set(h.time,h);if(u.length===0){if(t.from==null)break;s-=po*n;continue}if(d-1>=s)break;s=d-1;}let a=[...o.values()].sort((c,u)=>c.time-u.time),l=t.from!=null&&s<t.from;return {bars:a,coveredDownTo:l?t.from:a[0]?.time}}subscribe(e,t){return this.inner.subscribe(e,t)}symbolInfo(e){return this.inner.symbolInfo?.(e)}};function k1(r,e){if(r.limit!=null)return r.limit;if(r.from==null)return po;let t=Math.max(0,(r.to??Date.now())-r.from);return Math.ceil(t/e*1.1)+2}function ho(r){return r.length>0?r.slice(0,-1):r}function Um(r,e){if(!e)return r;let t=r[r.length-1];return !t||e.time>t.time?[...r,e]:r}function E1(r){return {"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,"1M":2592e6,1:6e4,5:3e5,15:9e5,30:18e5,60:36e5,240:144e5,D:864e5,W:6048e5,M:2592e6}[r]??36e5}var vr=class{constructor(e=uo){this.registry=new el;this.primaryProvider=null;this.liveBars=[];this.symInfoCache=new Map;this.cache=new mo(new Wu(this.registry),e);}registerProvider(e,t){return this.registry.register(e,t)}unregisterProvider(e){this.registry.unregister(e);}providers(){return this.registry.names().map(e=>this.registry.infoOf(e))}resolveSymbol(e){return this.registry.resolve(e,{default:this.primaryProvider})}displayPrefix(e){let t=this.resolveSymbol(e);return t?this.registry.displayPrefixOf(t):null}canonicalSymbol(e){let t=this.resolveSymbol(e);return t?this.registry.canonicalSymbol(t):null}providerInstance(e){return this.registry.get(e)}symbolIconOf(e){return this.registry.symbolIconOf(e)}symbolIcon(e){return this.registry.symbolIcon(this.resolveSymbol(e))}symbols(e){return this.registry.symbolsOf(e)}onUnresolved(e){return this.registry.onUnresolved(e)}destroy(){this.registry.cancelWaits();}ready(){return this.registry.indexReady()}async symbolInfoFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return;let n=await this.registry.get(t.provider)?.getSymbolInfo?.(t.ticker);return n&&this.symInfoCache.set($u(t),n),n}capabilitiesFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return null;let n=this.registry.get(t.provider);return n?n.capabilitiesFor?.(t.ticker)??this.registry.infoOf(t.provider).capabilities:null}async load(e){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(n=>({...n})),e.data;let t=await this.registry.whenResolvable(fo(e),{default:this.primaryProvider});return this.primaryProvider=t.provider,this.prefetchSymbolInfo(t),this.cache.load(il(e,t))}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(o=>({...o})),e.data;let i=await this.registry.whenResolvable(fo(e),{default:this.primaryProvider});return this.primaryProvider=i.provider,this.prefetchSymbolInfo(i),this.cache.loadProgressive(il(e,i),t,n)}symbolInfo(e){if(e.data&&e.data.length>0)return;let t=this.registry.resolve(fo(e),{default:this.primaryProvider});return t?this.symInfoCache.get($u(t)):void 0}prefetchSymbolInfo(e){let t=$u(e);if(this.symInfoCache.has(t))return;let n=this.registry.get(e.provider);n?.getSymbolInfo&&n.getSymbolInfo(e.ticker).then(i=>{i&&this.symInfoCache.set(t,i);}).catch(()=>{});}async loadRange(e,t){if(e.data&&e.data.length>0)return this.cache.loadRange(e,t);let n=this.registry.resolve(fo(e),{default:this.primaryProvider});return n?this.cache.loadRange(il(e,n),t):[]}subscribe(e,t){if(e.data&&e.data.length>0)return this.synthesizeTicks(e,t);let n=this.registry.resolve(fo(e),{default:this.primaryProvider});return n?this.cache.subscribe(il(e,n),t):()=>{}}synthesizeTicks(e,t){if(this.liveBars.length===0)return ()=>{};let n=E1(e.timeframe??"60"),i=setInterval(()=>{let o=this.liveBars,s=o[o.length-1];if(!s)return;let a=s.close*.0015*(Math.random()-.5)*2,l=Math.max(0,s.close+a),c={...s,close:l,high:Math.max(s.high,l),low:Math.min(s.low,l)};if(o[o.length-1]=c,t(c),Math.random()<.12){let u={time:c.time+n,open:c.close,high:c.close,low:c.close,close:c.close,volume:0};o.push(u),t(u);}},1e3);return ()=>clearInterval(i)}};function fo(r){return r.symbol??""}function il(r,e){return {...r,symbol:`${e.provider}:${e.ticker}`}}function $u(r){return `${r.provider}|${r.ticker}`}async function Ym(r,e,t,n){try{return await r.getBars(e,t,n)}catch(i){return console.warn(`[vela] data fetch failed for ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}var Wu=class{constructor(e){this.registry=e;}load(e){let{provider:t,ticker:n}=Ut(e.symbol??""),i=this.registry.get(t??"");return i?Ym(i,n,e.timeframe??"60",{limit:e.bars??500,session:e.session}):Promise.resolve([])}async loadProgressive(e,t,n){let{provider:i,ticker:o}=Ut(e.symbol??""),s=this.registry.get(i??"");if(!s)return [];if(!s.getBarsProgressive)return null;try{return await s.getBarsProgressive(o,e.timeframe??"60",{limit:e.bars??500,session:e.session},t,n)}catch(a){return console.warn(`[vela] progressive fetch failed for ${o} ${e.timeframe??"60"} \u2014 ${a instanceof Error?a.message:String(a)}`),[]}}loadRange(e,t){let{provider:n,ticker:i}=Ut(e.symbol??""),o=this.registry.get(n??"");return o?Ym(o,i,e.timeframe??"60",{...t,session:e.session}):Promise.resolve([])}subscribe(e,t){let{provider:n,ticker:i}=Ut(e.symbol??""),o=this.registry.get(n??"");if(!o)return ()=>{};let s=e.timeframe??"60";if(o.subscribe)return o.subscribe(i,s,t,e.session?{session:e.session}:void 0);let a=false,l=null,c=async()=>{if(!a){try{let u=await o.getBars(i,s,{limit:2,session:e.session});if(a)return;for(let d of u)t(d);}catch{}a||(l=setTimeout(()=>{c();},3e3));}};return l=setTimeout(()=>{c();},3e3),()=>{a=true,l&&clearTimeout(l);}}};var go=class{constructor(e){this.registry=e instanceof vr?e:null;}registerProvider(e,t){return this.registry?(this.registry.registerProvider(e,t),this):(console.warn(`[vela] chart.data.registerProvider("${e}") ignored \u2014 the active data feed is a custom feed (deps.dataFeed), not the default provider registry.`),this)}unregisterProvider(e){return this.registry?.unregisterProvider(e),this}providers(){return this.registry?.providers()??[]}resolve(e){return this.registry?.resolveSymbol(e)??null}displayPrefix(e){return this.registry?.displayPrefix(e)??null}canonicalSymbol(e){return this.registry?.canonicalSymbol(e)??null}providerInstance(e){return this.registry?.providerInstance(e)}symbols(e){return this.registry?.symbols(e)??[]}symbolIcon(e){return this.registry?.symbolIcon(e)}symbolInfo(e){return this.registry?.symbolInfoFor(e)??Promise.resolve(void 0)}capabilities(e){return this.registry?.capabilitiesFor(e)??null}ready(){return this.registry?.ready()??Promise.resolve()}};var bo=class{constructor(e){this.ctrl=e;}get supported(){return this.ctrl.supported}setTool(e){return this.ok("setTool")&&this.ctrl.setTool(e),this}getTool(){return this.ctrl.getTool()}setSnapMode(e){return this.ok("setSnapMode")&&this.ctrl.setSnapMode(e),this}getSnapMode(){return this.ctrl.getSnapMode()}setStayMode(e){return this.ok("setStayMode")&&this.ctrl.setStayMode(e),this}getStayMode(){return this.ctrl.getStayMode()}setMode(e){return this.ok("setMode")&&this.ctrl.setMode(e),this}getMode(){return this.ctrl.getMode()}showToolbar(e=true){return this.ok("showToolbar")&&this.ctrl.showToolbar(e),this}setToolbar(e){return this.ok("setToolbar")&&this.ctrl.setToolbar(e),this}setToolShortcuts(e){return this.ok("setToolShortcuts")&&this.ctrl.setToolShortcuts(e),this}setExternalGhost(e){return this.ctrl.setExternalGhost(e),this}add(e,t={}){return this.ok("add")?this.ctrl.add(e,t):null}remove(e){return this.ctrl.remove(e),this}update(e,t){return this.ctrl.update(e,t),this}updateMany(e){return this.ctrl.updateMany(e),this}removeMany(e){return this.ctrl.removeMany(e),this}lock(e,t=true){return this.ctrl.setLocked(e,t),this}show(e,t=true){return this.ctrl.setVisible(e,t),this}select(e){return this.ok("select")&&this.ctrl.select(e==null?[]:typeof e=="string"?[e]:e),this}openSettings(e){return this.ok("openSettings")&&this.ctrl.openSettings(e),this}bringToFront(e){return this.ctrl.bringToFront(e),this}sendToBack(e){return this.ctrl.sendToBack(e),this}undo(){return this.ctrl.undo(),this}redo(){return this.ctrl.redo(),this}canUndo(){return this.ctrl.canUndo()}canRedo(){return this.ctrl.canRedo()}clone(e){return this.ok("clone")&&this.ctrl.clone(e),this}duplicate(e){return this.ok("duplicate")&&this.ctrl.duplicate(e),this}copyToClipboard(e){return this.ok("copy")&&this.ctrl.copy(e),this}paste(){return this.ok("paste")&&this.ctrl.paste(),this}all(){return this.ctrl.all()}toJSON(){return this.ctrl.toJSON()}fromJSON(e){return this.ctrl.fromJSON(e),this}favorites(){return this.ctrl.favorites()}isFavorite(e){return this.ctrl.isFavorite(e)}setFavorite(e,t){return this.ok("setFavorite")&&this.ctrl.setFavorite(e,t),this}setFavorites(e){return this.ok("setFavorites")&&this.ctrl.setFavorites([...e]),this}getConfig(){return this.ctrl.toJSON()}applyConfig(e){return this.ctrl.fromJSON(e),this}ok(e){return this.ctrl.supported?true:(console.warn(`[vela] chart.drawings.${e}() ignored \u2014 the active renderer has no userDrawings capability.`),false)}};var vo=class{constructor(e){this.ctrl=e;}get supported(){return this.ctrl.supported}add(e){return this.ctrl.add(e),this}set(e){return this.ctrl.set(e),this}remove(e){return this.ctrl.remove(e),this}clear(){return this.ctrl.clear(),this}all(){return this.ctrl.all()}defineGroup(e){return this.ctrl.defineGroup(e),this}groups(){return this.ctrl.groupDefinitions()}setGroupVisible(e,t=true){return this.ctrl.setGroupVisible(e,t),this}isGroupVisible(e){return this.ctrl.isGroupVisible(e)}};var yo=class r{constructor(e=()=>Date.now()){this.now=e;this.subs=new Set;this.timer=null;}onTick(e){return this.subs.add(e),this.timer==null&&this.arm(),()=>{this.subs.delete(e),this.subs.size===0&&this.timer!=null&&(clearTimeout(this.timer),this.timer=null);}}static delayToNextSecond(e){return 1e3-(e%1e3+1e3)%1e3+5}arm(){this.timer=setTimeout(()=>{this.timer=null;let e=this.now();for(let t of this.subs)t(e);this.subs.size>0&&this.arm();},r.delayToNextSecond(this.now()));}};function ol(r){let e=r.trim(),t=/^#([0-9a-f]{3})$/i.exec(e);if(t){let i=t[1];return {r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16)}}if(t=/^#([0-9a-f]{6})[0-9a-f]{0,2}$/i.exec(e),t){let i=t[1];return {r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16)}}let n=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i.exec(e);return n?{r:parseFloat(n[1]),g:parseFloat(n[2]),b:parseFloat(n[3])}:null}function q(r,e){let t=ol(r);return t?`rgba(${t.r},${t.g},${t.b},${e})`:r}function Km(r,e,t){let n=ol(r),i=ol(e);if(!n||!i)return r;let o=(s,a)=>Math.round(s+(a-s)*t);return `rgb(${o(n.r,i.r)},${o(n.g,i.g)},${o(n.b,i.b)})`}function lt(r){let e=ol(r);return e?.2126*e.r+.7152*e.g+.0722*e.b<128:true}var sl={"--vela-space-1":"4px","--vela-space-2":"8px","--vela-space-3":"12px","--vela-space-4":"16px","--vela-radius-sm":"4px","--vela-radius-md":"6px","--vela-radius-lg":"10px","--vela-z-tooltip":"60","--vela-z-menu":"50","--vela-z-dialog":"40","--vela-z-popover":"6000","--vela-ease":"cubic-bezier(0.22, 1, 0.36, 1)","--vela-dur-fast":"90ms","--vela-dur-med":"160ms","--vela-font-size-sm":"11px","--vela-font-size-md":"12px","--vela-font-size-lg":"14px"};function al(r){let e=lt(r.background),t=i=>e?`rgba(255,255,255,${i})`:q(r.textColor,i+.02),n=Km(r.background,e?"#ffffff":r.textColor,e?.03:.05);return {"--vela-font":r.fontFamily,"--vela-bg":r.background,"--vela-fg":e?"#d1d4dc":r.textColor,"--vela-fg-muted":e?"#868a96":q(r.textColor,.62),"--vela-fg-faint":q(r.textColor,.35),"--vela-fg-bright":e?"#f0f3fa":"#000000","--vela-surface":r.background,"--vela-surface-elev":n,"--vela-surface-overlay":n,"--vela-surface-sunken":r.background,"--vela-border":r.borderColor,"--vela-border-strong":e?"#34353b":q(r.textColor,.28),"--vela-border-soft":r.borderColor,"--vela-border-faint":q(r.textColor,.08),"--vela-hover":t(.06),"--vela-active":t(.1),"--vela-hover-strong":t(.16),"--vela-focus":q(r.textColor,.5),"--vela-focus-soft":q(r.textColor,.12),"--vela-separator-hover-band":q(r.textColor,.1),"--vela-separator-hover-line":q(r.textColor,.55),"--vela-scroll":q(r.textColor,.3),"--vela-accent":Ke,"--vela-accent-bright":$r,"--vela-highlight":jp,"--vela-selected-bg":e?"#f0f3fa":r.textColor,"--vela-selected-fg":e?r.background:"#ffffff","--vela-fg-on-fill":"#ffffff","--vela-up":r.upColor,"--vela-down":r.downColor,"--vela-danger":r.downColor,"--vela-shadow":"0 8px 30px rgba(0,0,0,0.5)","--vela-shadow-dialog":"0 20px 60px rgba(0,0,0,0.5)","--vela-backdrop":"rgba(0,0,0,0.45)"}}function Re(r,e){let t=n=>{for(let i in n)r.style.setProperty(i,n[i]);};t(sl),t(al(e));}function Kt(r,e){let t=null,n=null,i=()=>{t!==null&&(clearTimeout(t),t=null),n?.remove(),n=null;},o=()=>{let a=e.text();if(!a)return;n=r.ownerDocument.createElement("div"),n.textContent=a,n.style.cssText="position:absolute;z-index:var(--vela-z-tooltip);pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);"+(e.wrap?"max-width:260px;":"white-space:nowrap;"),Re(n,e.theme()),e.host.appendChild(n);let c=r.getBoundingClientRect(),u=e.host.getBoundingClientRect();if(e.placement==="right")n.style.left=`${c.right-u.left+8}px`,n.style.top=`${c.top-u.top+(c.height-n.offsetHeight)/2}px`;else {let d=Math.min(c.left-u.left,Math.max(0,u.width-n.offsetWidth-4));n.style.left=`${Math.max(0,d)}px`,n.style.top=e.placement==="above"?`${Math.max(0,c.top-u.top-n.offsetHeight-6)}px`:`${c.bottom-u.top+6}px`;}},s=a=>{a.pointerType==="mouse"&&(i(),t=window.setTimeout(o,e.delayMs??700));};return r.addEventListener("pointerenter",s),r.addEventListener("pointerleave",i),r.addEventListener("pointerdown",i),()=>{r.removeEventListener("pointerenter",s),r.removeEventListener("pointerleave",i),r.removeEventListener("pointerdown",i),i();}}function ll(r,e){let t=e.size??16,n=document.createElement("span");n.className="vela-hint",n.setAttribute("role","img"),n.setAttribute("aria-label",r),n.innerHTML=ye("info",t),n.style.cssText=`flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:${t}px;height:${t}px;border-radius:50%;cursor:help;user-select:none;background:var(--vela-hover);color:var(--vela-fg-muted);transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease;`;let i=s=>{n.style.background=s?"var(--vela-active)":"var(--vela-hover)",n.style.color=s?"var(--vela-fg-bright)":"var(--vela-fg-muted)";};n.addEventListener("pointerenter",()=>i(true)),n.addEventListener("pointerleave",()=>i(false));let o=Kt(n,{host:e.host,theme:e.theme,text:()=>r,wrap:true,delayMs:250});return {el:n,dispose:o}}var L1=Object.defineProperty,M1=(r,e,t)=>e in r?L1(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,le=(r,e,t)=>M1(r,typeof e!="symbol"?e+"":e,t);function Xm(r){return r==null?[]:Array.isArray(r)?r:[r]}var jm=r=>r[0],qm=r=>r[r.length-1];function Zm(r,e,t={}){let{step:n=1,loop:i=true}=t,o=e+n,s=r.length,a=s-1;return e===-1?n>0?0:a:o<0?i?a:0:o>=s?i?0:e>s?s:e:o}function Jm(r,e,t={}){return r[Zm(r,e,t)]}function P1(r,e,t={}){let{step:n=1,loop:i=true}=t;return Zm(r,e,{step:-n,loop:i})}function Qm(r,e,t={}){return r[P1(r,e,t)]}var ef=r=>r?.constructor.name==="Array",I1=(r,e)=>{if(r.length!==e.length)return false;for(let t=0;t<r.length;t++)if(!ti(r[t],e[t]))return false;return true},ti=(r,e)=>{if(Object.is(r,e))return true;if(r==null&&e!=null||r!=null&&e==null)return false;if(typeof r?.isEqual=="function"&&typeof e?.isEqual=="function")return r.isEqual(e);if(typeof r=="function"&&typeof e=="function")return r.toString()===e.toString();if(ef(r)&&ef(e))return I1(Array.from(r),Array.from(e));if(typeof r!="object"||typeof e!="object")return false;let t=Object.keys(e??Object.create(null)),n=t.length;for(let i=0;i<n;i++)if(!Reflect.has(r,t[i]))return false;for(let i=0;i<n;i++){let o=t[i];if(!ti(r[o],e[o]))return false}return true};var A1=r=>r!=null&&typeof r=="object";var ni=r=>typeof r=="string",nt=r=>typeof r=="function",tf=r=>r==null,wo=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),R1=r=>Object.prototype.toString.call(r),nf=Function.prototype.toString,D1=nf.call(Object),yr=r=>{if(!A1(r)||R1(r)!="[object Object]"||F1(r))return false;let e=Object.getPrototypeOf(r);if(e===null)return true;let t=wo(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&nf.call(t)==D1},O1=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,N1=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,F1=r=>O1(r)||N1(r);var xo=(r,...e)=>(typeof r=="function"?r(...e):r)??void 0,Gu=r=>r,rf=r=>r(),Uu=()=>{},Nn=(...r)=>(...e)=>{r.forEach(function(t){t?.(...e);});};function Fn(r){if(!yr(r)||r===void 0)return r;let e=Reflect.ownKeys(r).filter(n=>typeof n=="string"),t={};for(let n of e){let i=r[n];i!==void 0&&(t[n]=Fn(i));}return t}function ri(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Yu(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function So(r,e){if(r==null)throw new Error(e())}var V1=(...r)=>r.map(e=>e?.trim?.()).filter(Boolean).join(" "),_1=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,of=r=>{let e={},t;for(;t=_1.exec(r);)e[t[1]]=t[2];return e},B1=(r,e)=>{if(ni(r)){if(ni(e))return `${r};${e}`;r=of(r);}else ni(e)&&(e=of(e));return Object.assign({},r??{},e??{})};function sf(...r){let e={};for(let t of r){if(!t)continue;for(let i in e){if(i.startsWith("on")&&typeof e[i]=="function"&&typeof t[i]=="function"){e[i]=Nn(t[i],e[i]);continue}if(i==="className"||i==="class"){e[i]=V1(e[i],t[i]);continue}if(i==="style"){e[i]=B1(e[i],t[i]);continue}e[i]=t[i]!==void 0?t[i]:e[i];}for(let i in t)e[i]===void 0&&(e[i]=t[i]);let n=Object.getOwnPropertySymbols(t);for(let i of n)e[i]=t[i];}return e}var Vn=".",cf="#",af=new WeakMap,uf=new WeakMap;function Ku(r){return r.join(Vn)}function H1(r){return r.includes(Vn)}function df(r){return r.startsWith(cf)}function z1(r){return r.startsWith(Vn)}function $1(r){return df(r)?r.slice(cf.length):r}function Xu(r,e){return r?`${r}${Vn}${e}`:e}function W1(r){let e=new Map,t=new Map,n=(i,o)=>{e.set(i,o);let s=o.id;s&&(t.has(s)&&Yu(`[zag-js] Duplicate state id: "${s}"`),t.set(s,i));let a=o.states;if(a){So(o.initial,()=>`[zag-js] Compound state "${i}" has child states but no "initial" property`),o.initial in a||Yu(`[zag-js] Compound state "${i}" has initial "${String(o.initial)}" which is not a child state`);for(let[l,c]of Object.entries(a)){if(!c)continue;let u=Xu(i,l);n(u,c);}}};for(let[i,o]of Object.entries(r.states))o&&n(i,o);return {index:e,idIndex:t}}function ii(r){let e=af.get(r);if(e)return e;let{index:t,idIndex:n}=W1(r);return af.set(r,t),uf.set(r,n),t}function G1(r,e){return ii(r),uf.get(r)?.get(e)}function ju(r){return r?String(r).split(Vn).filter(Boolean):[]}function cl(r,e){if(!e)return [];let t=ii(r),n=ju(e),i=[],o=[];for(let s of n){o.push(s);let a=Ku(o),l=t.get(a);if(!l)break;i.push({path:a,state:l});}return i}function Co(r,e){let t=ii(r),n=ju(e);if(!n.length)return e;let i=[];for(let a of n){i.push(a);let l=Ku(i);if(!t.has(l))return e}let o=Ku(i),s=t.get(o);for(;s?.initial;){let a=`${o}${Vn}${s.initial}`,l=t.get(a);if(!l)break;o=a,s=l;}return o}function lf(r,e){return ii(r).has(e)}function qu(r,e,t){let n=String(e);if(df(n)){let i=$1(n),o=G1(r,i);return So(o,()=>`[zag-js] Unknown state id: "${i}"`),Co(r,o)}if(z1(n)&&t){let i=Xu(t,n.slice(1));return Co(r,i)}if(!H1(n)&&t){let i=ju(t);for(let o=i.length-1;o>=1;o--){let s=i.slice(0,o).join(Vn),a=Xu(s,n);if(lf(r,a))return Co(r,a)}if(lf(r,n))return Co(r,n)}return Co(r,n)}function hf(r,e,t){let n=cl(r,e);for(let o=n.length-1;o>=0;o--){let a=n[o]?.state.on?.[t];if(a)return {transitions:a,source:n[o]?.path}}return {transitions:r.on?.[t],source:void 0}}function pf(r,e,t,n){let i=e?cl(r,e):[],o=cl(r,t),s=0;for(;s<i.length&&s<o.length&&i[s]?.path===o[s]?.path;)s+=1;let a=i.slice(s).reverse(),l=o.slice(s),c=i.at(-1)?.path===o.at(-1)?.path;return n&&c&&(a=i.slice().reverse(),l=o),{exiting:a,entering:l}}function mf(r,e){return r?r===e||r.startsWith(`${e}${Vn}`):false}function ff(r,e,t){return cl(r,e).some(n=>n.state.tags?.includes(t))}function gf(){return {and:(...r)=>function(t){return r.every(n=>t.guard(n))},or:(...r)=>function(t){return r.some(n=>t.guard(n))},not:r=>function(t){return !t.guard(r)}}}function ul(r){return ii(r),r}var oi=(r=>(r.NotStarted="Not Started",r.Started="Started",r.Stopped="Stopped",r))(oi||{}),To="__init__";var U1=Object.defineProperty,Y1=(r,e,t)=>e in r?U1(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,dl=(r,e,t)=>Y1(r,typeof e!="symbol"?e+"":e,t);var bf=(r,e)=>r.map((t,n)=>r[(Math.max(e,0)+n)%r.length]);var ko=()=>{},Eo=r=>typeof r=="object"&&r!==null;var mt=r=>r?"":void 0,Zu=r=>r?"true":void 0;var K1=1,X1=9,j1=11;var ce=r=>Eo(r)&&r.nodeType===K1&&typeof r.nodeName=="string",Lo=r=>Eo(r)&&r.nodeType===X1,q1=r=>Eo(r)&&r===r.window;var vf=r=>ce(r)?r.localName||"":"#document";function yf(r){return ["html","body","#document"].includes(vf(r))}var wf=r=>Eo(r)&&r.nodeType!==void 0,wr=r=>wf(r)&&r.nodeType===j1&&"host"in r,Ju=r=>ce(r)&&r.localName==="input",xf=r=>!!r?.matches("a[href]"),Sf=r=>ce(r)?r.offsetWidth>0||r.offsetHeight>0||r.getClientRects().length>0:false;function Mo(r){if(!r)return false;let e=r.getRootNode();return Xt(e)===r}var Z1=/(textarea|select)/;function si(r){if(r==null||!ce(r))return false;try{return Ju(r)&&r.selectionStart!=null||Z1.test(r.localName)||r.isContentEditable||r.getAttribute("contenteditable")==="true"||r.getAttribute("contenteditable")===""}catch{return false}}function rt(r,e){if(!r||!e||!ce(r)||!wf(e))return false;if(ce(e)&&r===e||r.contains(e))return true;let t=e.getRootNode?.();if(t&&wr(t)){let n=e;for(;n;){if(r===n)return true;n=n.parentNode||n.host;}}return false}function Le(r){return Lo(r)?r:q1(r)?r.document:r?.ownerDocument??document}function J1(r){return Le(r).documentElement}function Ce(r){return wr(r)?Ce(r.host):Lo(r)?r.defaultView??window:ce(r)?r.ownerDocument?.defaultView??window:window}function Xt(r){let e=r.activeElement;for(;e?.shadowRoot;){let t=e.shadowRoot.activeElement;if(!t||t===e)break;e=t;}return e}function Cf(r){if(vf(r)==="html")return r;let e=r.assignedSlot||r.parentNode||wr(r)&&r.host||J1(r);return wr(e)?e.host:e}function hl(r){let e;try{if(e=r.getRootNode({composed:!0}),Lo(e)||wr(e))return e}catch{}return r.ownerDocument??document}var Qu=new WeakMap;function ai(r){return Qu.has(r)||Qu.set(r,Ce(r).getComputedStyle(r)),Qu.get(r)}var ed=new Set(["menu","listbox","dialog","grid","tree","region","application"]),Q1=r=>ed.has(r),Tf=r=>r.getAttribute("aria-controls")?.split(" ")||[];function pl(r,e){let t=new Set,n=hl(r),i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=Tf(a);for(let c of l){if(!c||t.has(c))continue;t.add(c);let u=n.getElementById(c);if(u){let d=u.getAttribute("role"),h=u.getAttribute("aria-modal")==="true";if(d&&Q1(d)&&!h&&(u===e||u.contains(e)||i(u)))return true}}}return false};return i(r)}function td(r,e){let t=hl(r),n=new Set,i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=Tf(a);for(let c of l){if(!c||n.has(c))continue;n.add(c);let u=t.getElementById(c);if(u){let d=u.getAttribute("role"),h=u.getAttribute("aria-modal")==="true";d&&ed.has(d)&&!h&&(e(u),i(u));}}}};i(r);}function kf(r){let e=new Set;return td(r,t=>{r.contains(t)||e.add(t);}),Array.from(e)}function eT(r){let e=r.getAttribute("role");return !!(e&&ed.has(e))}function tT(r){return r.hasAttribute("aria-controls")&&r.getAttribute("aria-expanded")==="true"}function Ef(r){return tT(r)?true:!!r.querySelector?.('[aria-controls][aria-expanded="true"]')}function Lf(r){if(!r.id)return false;let e=hl(r),t=CSS.escape(r.id),n=`[aria-controls~="${t}"][aria-expanded="true"], [aria-controls="${t}"][aria-expanded="true"]`;return !!(e.querySelector(n)&&eT(r))}var nd=()=>typeof document<"u";function nT(){return navigator.userAgentData?.platform??navigator.platform}function rT(){let r=navigator.userAgentData;return r&&Array.isArray(r.brands)?r.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" "):navigator.userAgent}var rd=r=>nd()&&r.test(nT()),Mf=r=>nd()&&r.test(rT());var id=()=>nd()&&!!navigator.maxTouchPoints,iT=()=>rd(/^iPhone/i),oT=()=>rd(/^iPad/i)||li()&&navigator.maxTouchPoints>1,Pf=()=>iT()||oT();var li=()=>rd(/^Mac/i);var If=()=>Mf(/Firefox/i);var Af=()=>Mf(/Android/i);function sT(r){return r.composedPath?.()??r.nativeEvent?.composedPath?.()}function De(r){return sT(r)?.[0]??r.target}function od(r){let e=r.currentTarget;if(!e||!e.matches("a[href], button[type='submit'], input[type='submit']"))return false;let n=r.button===1,i=aT(r);return n||i}function sd(r){let e=r.currentTarget;if(!e)return false;let t=e.localName;return r.altKey?t==="a"||t==="button"&&e.type==="submit"||t==="input"&&e.type==="submit":false}function aT(r){return li()?r.metaKey:r.ctrlKey}function Df(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function Of(r){return r.pointerType===""&&r.isTrusted?true:Af()&&r.pointerType?r.type==="click"&&r.buttons===1:r.detail===0&&!r.pointerType}var ml=r=>r.button===2||li()&&r.ctrlKey&&r.button===0,Nf=r=>r.ctrlKey||r.altKey||r.metaKey,lT=r=>"touches"in r&&r.touches.length>0,cT={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},Rf={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function ad(r,e={}){let{dir:t="ltr",orientation:n="horizontal"}=e,i=r.key;return i=cT[i]??i,t==="rtl"&&n==="horizontal"&&i in Rf&&(i=Rf[i]),i}function ci(r,e="client"){let t=lT(r)?r.touches[0]||r.changedTouches[0]:r;return {x:t[`${e}X`],y:t[`${e}Y`]}}var je=(r,e,t,n)=>{let i=typeof r=="function"?r():r;return i?.addEventListener(e,t,n),()=>{i?.removeEventListener(e,t,n);}};var Ff=r=>ce(r)&&r.tagName==="IFRAME",uT=/^(audio|video|details)$/;function Vf(r){let e=r.getAttribute("tabindex");return e?parseInt(e,10):NaN}var dT=r=>!Number.isNaN(Vf(r)),hT=r=>Vf(r)<0;function pT(r){return Ju(r)&&r.type==="radio"}function mT(r){if(!pT(r)||!r.name||r.checked)return true;let e=`input[type="radio"][name="${CSS.escape(r.name)}"]`,t=r.form??r.ownerDocument,n=Array.from(t.querySelectorAll(e)).filter(o=>o.form===r.form&&ft(o)),i=n.find(o=>o.checked);return i?i===r:n[0]===r}function fT(r,e){if(!e)return null;if(e===true)return r.shadowRoot||null;let t=e(r);return (t===true?r.shadowRoot:t)||null}function _f(r,e,t){let n=[...r],i=[...r],o=new Set,s=new Map;r.forEach((l,c)=>s.set(l,c));let a=0;for(;a<i.length;){let l=i[a++];if(!l||o.has(l))continue;o.add(l);let c=fT(l,e);if(c){let u=Array.from(c.querySelectorAll(fl)).filter(t),d=s.get(l);if(d!==void 0){let h=d+1;n.splice(h,0,...u),u.forEach((p,m)=>{s.set(p,h+m);});for(let p=h+u.length;p<n.length;p++)s.set(n[p],p);}else {let h=n.length;n.push(...u),u.forEach((p,m)=>{s.set(p,h+m);});}i.push(...u);}}return n}var fl="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type",ld=(r,e={})=>{if(!r)return [];let{includeContainer:t=false,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(fl));(t==true||t=="if-empty"&&i.length===0)&&ce(r)&&ft(r)&&i.unshift(r);let s=[];for(let a of i)if(ft(a)){if(Ff(a)&&a.contentDocument){let l=a.contentDocument.body;s.push(...ld(l,{getShadowRoot:n}));continue}s.push(a);}return n?_f(s,n,ft):s};function ft(r){return !ce(r)||r.closest("[inert]")?false:r.matches(fl)&&Sf(r)}function ui(r,e={}){if(!r)return [];let{includeContainer:t,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(fl));t&&_n(r)&&i.unshift(r);let o=[];for(let s of i)if(_n(s)){if(Ff(s)&&s.contentDocument){let a=s.contentDocument.body;o.push(...ui(a,{getShadowRoot:n}));continue}o.push(s);}if(n){let s=_f(o,n,_n);return !s.length&&t?i:s}return !o.length&&t?i:o}function _n(r){return ce(r)&&r.tabIndex>0?true:!ft(r)||hT(r)?false:mT(r)}function Bf(r,e={}){let t=ui(r,e),n=t[0]||null,i=t[t.length-1]||null;return [n,i]}function di(r){return r.tabIndex<0&&(uT.test(r.localName)||si(r))&&!dT(r)?0:r.tabIndex}function gl(r){let{root:e,getInitialEl:t,filter:n,enabled:i=true}=r;if(!i)return;let o=null;if(o||(o=typeof t=="function"?t():t),o||(o=e?.querySelector("[data-autofocus],[autofocus]")),!o){let s=ui(e);o=n?s.filter(n)[0]:s[0];}return o||e||void 0}function Hf(r){let e=r.currentTarget;if(!e)return false;let[t,n]=Bf(e);return !(Mo(t)&&r.shiftKey||Mo(n)&&!r.shiftKey||!t&&!n)}var gT=class zf{constructor(){dl(this,"id",null),dl(this,"fn_cleanup"),dl(this,"cleanup",()=>{this.cancel();});}static create(){return new zf}request(e){this.cancel(),this.id=globalThis.requestAnimationFrame(()=>{this.id=null,this.fn_cleanup=e?.();});}cancel(){this.id!==null&&(globalThis.cancelAnimationFrame(this.id),this.id=null),this.fn_cleanup?.(),this.fn_cleanup=void 0;}isActive(){return this.id!==null}};function Ie(r){let e=gT.create();return e.request(r),e.cleanup}function $f(r){let e=new Set;function t(n){let i=globalThis.requestAnimationFrame(n);e.add(()=>globalThis.cancelAnimationFrame(i));}return t(()=>t(r)),function(){e.forEach(i=>i());}}function Wf(r,e,t){let n=Ie(()=>{r.removeEventListener(e,i,true),t();}),i=()=>{n(),t();};return r.addEventListener(e,i,{once:true,capture:true}),n}function bT(r,e){if(!r)return;let{attributes:t,callback:n}=e,i=r.ownerDocument.defaultView||window,o=new i.MutationObserver(s=>{for(let a of s)a.type==="attributes"&&a.attributeName&&t.includes(a.attributeName)&&n(a);});return o.observe(r,{attributes:true,attributeFilter:t}),()=>o.disconnect()}function Gf(r,e){let n=Ie,i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(bT(o,e));})),()=>{i.forEach(o=>o?.());}}function Uf(r){let e=()=>{let t=Ce(r);r.dispatchEvent(new t.MouseEvent("click"));};If()?Wf(r,"keyup",e):queueMicrotask(e);}function bl(r){let e=Cf(r);return yf(e)?Le(e).body:ce(e)&&cd(e)?e:bl(e)}var vT=/auto|scroll|overlay|hidden|clip/,yT=new Set(["inline","contents"]);function cd(r){let e=Ce(r),{overflow:t,overflowX:n,overflowY:i,display:o}=e.getComputedStyle(r);return vT.test(t+i+n)&&!yT.has(o)}function hi(r,e){return Array.from(r?.querySelectorAll(e)??[])}var vl=r=>r.id;function wT(r,e,t=vl){return r.find(n=>t(n)===e)}function Yf(r,e,t=vl){let n=wT(r,e,t);return n?r.indexOf(n):-1}function xT(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth}function Kf(r,e){let{rootEl:t,...n}=e||{};!r||!t||!cd(t)||!xT(t)||r.scrollIntoView(n);}var ST=r=>r.split("").map(e=>{let t=e.charCodeAt(0);return t>0&&t<128?e:t>=128&&t<=255?`/x${t.toString(16)}`.replace("/","\\"):""}).join("").trim(),CT=r=>ST(r.dataset?.valuetext??r.textContent??""),TT=(r,e)=>r.trim().toLowerCase().startsWith(e.toLowerCase());function Xf(r,e,t,n=vl){let i=t?Yf(r,t,n):-1,o=t?bf(r,i):r;return e.length===1&&(o=o.filter(a=>n(a)!==t)),o.find(a=>TT(CT(a),e))}function Po(r,e){if(!r)return ko;let t=Object.keys(e).reduce((n,i)=>(n[i]=r.style.getPropertyValue(i),n),{});return kT(t,e)?ko:(Object.assign(r.style,e),()=>{Object.assign(r.style,t),r.style.length===0&&r.removeAttribute("style");})}function jf(r,e,t){if(!r)return ko;let n=r.style.getPropertyValue(e);return n===t?ko:(r.style.setProperty(e,t),()=>{r.style.setProperty(e,n),r.style.length===0&&r.removeAttribute("style");})}function kT(r,e){return Object.keys(r).every(t=>r[t]===e[t])}function ET(r,e){let{state:t,activeId:n,key:i,timeout:o=350,itemToId:s}=e,a=t.keysSoFar+i,c=a.length>1&&Array.from(a).every(m=>m===a[0])?a[0]:a,u=r.slice(),d=Xf(u,c,n,s);function h(){clearTimeout(t.timer),t.timer=-1;}function p(m){t.keysSoFar=m,h(),m!==""&&(t.timer=+setTimeout(()=>{p(""),h();},o));}return p(a),d}var yl=Object.assign(ET,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:LT});function LT(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function MT(r,e,t){let{signal:n}=e;return [new Promise((s,a)=>{let l=setTimeout(()=>{a(new Error(`Timeout of ${t}ms exceeded`));},t);n.addEventListener("abort",()=>{clearTimeout(l),a(new DOMException("Promise aborted","AbortError"));}),r.then(c=>{n.aborted||(clearTimeout(l),s(c));}).catch(c=>{n.aborted||(clearTimeout(l),a(c));});}),()=>e.abort()]}function qf(r,e){let{timeout:t,rootNode:n}=e,i=Ce(n),o=Le(n),s=new i.AbortController;return MT(new Promise(a=>{let l=r();if(l){a(l);return}let c=new i.MutationObserver(()=>{let u=r();u&&u.isConnected&&(c.disconnect(),a(u));});c.observe(o.body,{childList:true,subtree:true});}),s,t)}function Zf(r){let e=()=>r.getRootNode?.()??document,t=()=>Le(e());return {...r,getRootNode:e,getDoc:t,getWin:()=>t().defaultView??window,getActiveElement:()=>Xt(e()),isActiveElement:Mo,getById:s=>e().getElementById(s)}}function Jf(r){return new Proxy({},{get(e,t){return t==="style"?n=>r({style:n}).style:r}})}var Qf={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},PT=new Set(["viewBox","preserveAspectRatio"]),IT=r=>{let e="";for(let t in r){let n=r[t];n!=null&&(t.startsWith("--")||(t=t.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)),e+=`${t}:${n};`);}return e},pi=Jf(r=>Object.entries(r).reduce((e,[t,n])=>{if(n===void 0)return e;if(t in Qf&&(t=Qf[t]),t==="style"&&typeof n=="object")return e.style=IT(n),e;let i=PT.has(t)?t:t.toLowerCase();return e[i]=n,e},{}));var wl=new WeakMap,eg=new Set(["value","checked","selected"]),AT=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),RT=r=>r.tagName==="svg"||r.namespaceURI==="http://www.w3.org/2000/svg",xl=(r,e)=>RT(r)&&AT.has(e)?e:e.toLowerCase();function it(r,e,t){let n=t||"default",i=wl.get(r);i||(i=new Map,wl.set(r,i));let o=i.get(n)||{},s=Object.keys(e),a=(f,g)=>{r.addEventListener(f.toLowerCase(),g);},l=(f,g)=>{r.removeEventListener(f.toLowerCase(),g);},c=f=>f.startsWith("on"),u=f=>!f.startsWith("on"),d=f=>a(f.substring(2),e[f]),h=f=>l(f.substring(2),e[f]),p=f=>{let g=e[f],b=o[f];if(g!==b){if(f==="class"){r.className=g??"";return}if(eg.has(f)){r[f]=g??"";return}if(typeof g=="boolean"&&!f.includes("aria-")){r.toggleAttribute(xl(r,f),g);return}if(f==="children"){r.innerHTML=g;return}if(g!=null){r.setAttribute(xl(r,f),g);return}r.removeAttribute(xl(r,f));}};for(let f in o)e[f]==null&&(f==="class"?r.className="":eg.has(f)?r[f]="":r.removeAttribute(xl(r,f)));return Object.keys(o).filter(c).forEach(f=>{l(f.substring(2),o[f]);}),s.filter(c).forEach(d),s.filter(u).forEach(p),i.set(n,e),function(){s.filter(c).forEach(h);let g=wl.get(r);g&&(g.delete(n),g.size===0&&wl.delete(r));}}function DT(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function ud(r,e){let t=DT();return t?(t[r]||(t[r]=e()),t[r]):e()}var mi=ud("__zag__refSet",()=>new WeakSet);var OT=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,NT=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,FT=r=>typeof r=="object"&&r!==null&&"nodeType"in r&&typeof r.nodeName=="string",VT=r=>OT(r)||NT(r)||FT(r),Sl=r=>r!==null&&typeof r=="object",dd=r=>Sl(r)&&!mi.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!VT(r)&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise)&&!(r instanceof File)&&!(r instanceof Blob)&&!(r instanceof AbortController);var _T=Symbol();var tg=Object.getPrototypeOf,hd=new WeakMap,BT=r=>r&&(hd.has(r)?hd.get(r):tg(r)===Object.prototype||tg(r)===Array.prototype);var ng=r=>BT(r)&&r[_T]||null,pd=(r,e=true)=>{hd.set(r,e);};var xr=ud("__zag__proxyStateMap",()=>new WeakMap),HT=(r=Object.is,e=(a,l)=>new Proxy(a,l),t=new WeakMap,n=(a,l)=>{let c=t.get(a);if(c?.[0]===l)return c[1];let u=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return pd(u,true),t.set(a,[l,u]),Reflect.ownKeys(a).forEach(d=>{let h=Reflect.get(a,d);mi.has(h)?(pd(h,false),u[d]=h):xr.has(h)?u[d]=rg(h):u[d]=h;}),Object.freeze(u)},i=new WeakMap,o=[1,1],s=a=>{if(!Sl(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=o[0],u=new Set,d=(k,x=++o[0])=>{c!==x&&(c=x,u.forEach(L=>L(k,x)));},h=o[1],p=(k=++o[1])=>(h!==k&&!u.size&&(h=k,f.forEach(([x])=>{let L=x[1](k);L>c&&(c=L);})),c),m=k=>(x,L)=>{let w=[...x];w[1]=[k,...w[1]],d(w,L);},f=new Map,g=(k,x)=>{if(u.size){let L=x[3](m(k));f.set(k,[x,L]);}else f.set(k,[x]);},b=k=>{let x=f.get(k);x&&(f.delete(k),x[1]?.());},y=k=>(u.add(k),u.size===1&&f.forEach(([L,w],M)=>{let P=L[3](m(M));f.set(M,[L,P]);}),()=>{u.delete(k),u.size===0&&f.forEach(([L,w],M)=>{w&&(w(),f.set(M,[L]));});}),v=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),E=e(v,{deleteProperty(k,x){let L=Reflect.get(k,x);b(x);let w=Reflect.deleteProperty(k,x);return w&&d(["delete",[x],L]),w},set(k,x,L,w){let M=Reflect.has(k,x),P=Reflect.get(k,x,w);if(M&&(r(P,L)||i.has(L)&&r(P,i.get(L))))return true;b(x),Sl(L)&&(L=ng(L)||L);let C=L;if(!Object.getOwnPropertyDescriptor(k,x)?.set){!xr.has(L)&&dd(L)&&(C=Cl(L));let A=!mi.has(C)&&xr.get(C);A&&g(x,A);}return Reflect.set(k,x,C,w),d(["set",[x],L,P]),true}});i.set(a,E);let T=[v,p,n,y];return xr.set(E,T),Reflect.ownKeys(a).forEach(k=>{let x=Object.getOwnPropertyDescriptor(a,k);x.get||x.set?Object.defineProperty(v,k,x):E[k]=a[k];}),E})=>[s,xr,mi,r,e,dd,t,n,i,o],[zT]=HT();function Cl(r={}){return zT(r)}function Tl(r,e,t){let n=xr.get(r);let i,o=[],s=n[3],a=false,c=s(u=>{if(o.push(u),t);i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(o.splice(0));}));});return a=true,()=>{a=false,c();}}function rg(r){let e=xr.get(r);let[t,n,i]=e;return i(t,n())}function Ao(r){let e=r().value??r().defaultValue;r().debug&&console.log(`[bindable > ${r().debug}] initial`,e);let t=r().isEqual??Object.is,n=Cl({value:e}),i=()=>r().value!==void 0;return {initial:e,ref:n,get(){return i()?r().value:n.value},set(o){let s=i()?r().value:n.value,a=nt(o)?o(s):o;r().debug&&console.log(`[bindable > ${r().debug}] setValue`,{next:a,prev:s}),i()||(n.value=a),t(a,s)||r().onChange?.(a,s);},invoke(o,s){r().onChange?.(o,s);},hash(o){return r().hash?.(o)??String(o)}}}Ao.cleanup=r=>{};Ao.ref=r=>{let e=r;return {get:()=>e,set:t=>{e=t;}}};function ig(r){let e={current:r};return {get(t){return e.current[t]},set(t,n){e.current[t]=n;}}}function md(r,e){if(!yr(r)||!yr(e))return e===void 0?r:e;let t={...r};for(let n of Object.keys(e)){let i=e[n],o=r[n];i!==void 0&&(yr(o)&&yr(i)?t[n]=md(o,i):t[n]=i);}return t}var fd=class{constructor(r,e={}){le(this,"machine",r),le(this,"scope"),le(this,"context"),le(this,"prop"),le(this,"state"),le(this,"refs"),le(this,"computed"),le(this,"event",{type:""}),le(this,"previousEvent",{type:""}),le(this,"effects",new Map),le(this,"transition",null),le(this,"cleanups",[]),le(this,"subscriptions",[]),le(this,"userPropsRef"),le(this,"getEvent",()=>({...this.event,current:()=>this.event,previous:()=>this.previousEvent})),le(this,"getState",()=>({...this.state,matches:(...d)=>d.some(h=>mf(this.state.get(),h)),hasTag:d=>ff(this.machine,this.state.get(),d)})),le(this,"debug",(...d)=>{this.machine.debug&&console.log(...d);}),le(this,"notify",()=>{this.publish();}),le(this,"send",d=>{this.status===oi.Started&&queueMicrotask(()=>{if(!d)return;this.previousEvent=this.event,this.event=d,this.debug("send",d);let h=this.state.get(),p=d.type,{transitions:m,source:f}=hf(this.machine,h,p),g=this.choose(m);if(!g)return;this.transition=g;let b=qu(this.machine,g.target??h,f);this.debug("transition",g),b!==h?this.state.set(b):g.reenter?this.state.invoke(h,h):this.action(g.actions);});}),le(this,"action",d=>{let h=nt(d)?d(this.getParams()):d;if(!h)return;let p=h.map(m=>{let f=this.machine.implementations?.actions?.[m];return f||ri(`[zag-js] No implementation found for action "${JSON.stringify(m)}"`),f});for(let m of p)m?.(this.getParams());}),le(this,"guard",d=>{if(nt(d))return d(this.getParams());let h=this.machine.implementations?.guards?.[d];return h||ri(`[zag-js] No implementation found for guard "${JSON.stringify(d)}"`),h?.(this.getParams())}),le(this,"effect",d=>{let h=nt(d)?d(this.getParams()):d;if(!h)return;let p=h.map(f=>{let g=this.machine.implementations?.effects?.[f];return g||ri(`[zag-js] No implementation found for effect "${JSON.stringify(f)}"`),g}),m=[];for(let f of p){let g=f?.(this.getParams());g&&m.push(g);}return ()=>m.forEach(f=>f?.())}),le(this,"choose",d=>Xm(d).find(h=>{let p=!h.guard;return ni(h.guard)?p=!!this.guard(h.guard):nt(h.guard)&&(p=h.guard(this.getParams())),p})),le(this,"subscribe",d=>(this.subscriptions.push(d),()=>{let h=this.subscriptions.indexOf(d);h>-1&&this.subscriptions.splice(h,1);})),le(this,"status",oi.NotStarted),le(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(d=>d(this.service));}),le(this,"trackers",[]),le(this,"setupTrackers",()=>{this.machine.watch?.(this.getParams());}),le(this,"callTrackers",()=>{this.trackers.forEach(({deps:d,fn:h})=>{let p=d.map(m=>m());ti(h.prev,p)||(h(),h.prev=p);});}),le(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(d,h)=>{h.prev=d.map(p=>p()),this.trackers.push({deps:d,fn:h});},refs:this.refs,computed:this.computed,flush:rf,scope:this.scope,choose:this.choose})),this.userPropsRef={current:e};let{id:t,ids:n,getRootNode:i}=xo(e);this.scope=Zf({id:t,ids:n,getRootNode:i});let o=d=>{let h=xo(this.userPropsRef.current);return (r.props?.({props:Fn(h),scope:this.scope})??h)[d]};this.prop=o;let s=r.context?.({prop:o,bindable:Ao,scope:this.scope,flush(d){queueMicrotask(d);},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});s&&Object.values(s).forEach(d=>{let h=Tl(d.ref,()=>this.notify());this.cleanups.push(h);});let a={get(d){return s?.[d].get()},set(d,h){s?.[d].set(h);},initial(d){return s?.[d].initial},hash(d){let h=s?.[d].get();return s?.[d].hash(h)}};this.context=a;let l=d=>(So(r.computed,()=>"[zag-js] No computed object found on machine"),r.computed[d]({context:a,event:this.getEvent(),prop:o,refs:this.refs,scope:this.scope,computed:l}));this.computed=l;let c=ig(r.refs?.({prop:o,context:a})??{});this.refs=c;let u=Ao(()=>({defaultValue:qu(r,r.initialState({prop:o})),onChange:(d,h)=>{let{exiting:p,entering:m}=pf(this.machine,h,d,this.transition?.reenter);if(p.forEach(f=>{this.effects.get(f.path)?.(),this.effects.delete(f.path);}),p.forEach(f=>{this.action(f.state?.exit);}),this.action(this.transition?.actions),m.forEach(f=>{let g=this.effect(f.state?.effects);if(g){let b=this.effects.get(f.path);this.effects.set(f.path,b?Nn(b,g):g);}}),h===To){this.action(r.entry);let f=this.effect(r.effects);if(f){let g=this.effects.get(To);this.effects.set(To,g?Nn(g,f):f);}}m.forEach(f=>{this.action(f.state?.entry);});}}));this.state=u,this.cleanups.push(Tl(this.state.ref,()=>this.notify()));}updateProps(r){let e=this.userPropsRef.current;this.userPropsRef.current=()=>{let t=xo(e),n=xo(r);return md(t,n)},this.notify();}start(){this.status=oi.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,To),this.setupTrackers();}stop(){this.effects.forEach(r=>r?.()),this.effects.clear(),this.transition=null,this.action(this.machine.exit),this.cleanups.forEach(r=>r()),this.cleanups=[],this.subscriptions=[],this.status=oi.Stopped,this.debug("unmounting...");}get service(){return {state:this.getState(),send:this.send,context:this.context,prop:this.prop,scope:this.scope,refs:this.refs,computed:this.computed,event:this.getEvent(),getStatus:()=>this.status}}};function kl(r,e,t){let n=new fd(r,e),i=n.subscribe(t);return n.start(),t(n.service),{service:n.service,flush:()=>t(n.service),stop:()=>{i(),n.stop();}}}var $T=0;function El(r){return `${r}-${++$T}`}function Sr(r,e=8){return `${r}::-webkit-scrollbar{width:${e}px;height:${e}px;}${r}::-webkit-scrollbar-thumb{background:var(--vela-scroll);border-radius:4px;border:2px solid transparent;background-clip:padding-box;}${r}::-webkit-scrollbar-track{background:transparent;}${r}::-webkit-scrollbar-button{display:none;width:0;height:0;}`}var og="outline:none;transition:border-color .12s ease,box-shadow .12s ease;",sg="border-color:var(--vela-focus);box-shadow:0 0 0 3px var(--vela-focus-soft);";function he(r,e,t=document){if(typeof document>"u")return;let n=t instanceof Document?t.head:t;if(t.getElementById?.(r)??n.querySelector(`#${CSS.escape(r)}`))return;let i=document.createElement("style");i.id=r,i.textContent=e,n.appendChild(i);}var WT="vela-ui-tokens",GT=Object.entries(sl).map(([r,e])=>` ${r}: ${e};`).join(`
|
|
4
|
+
`),UT=`
|
|
5
|
+
.vela-ui, .vela-ui-layer {
|
|
6
|
+
${GT}
|
|
7
|
+
font-family: var(--vela-font, -apple-system, system-ui, sans-serif);
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
/* Chrome text (titles, buttons, menus, readouts) is UI, not copy \u2014 never selectable. */
|
|
10
|
+
user-select: none;
|
|
11
|
+
-webkit-user-select: none;
|
|
12
|
+
}
|
|
13
|
+
.vela-ui *, .vela-ui-layer * { box-sizing: border-box; }
|
|
14
|
+
/* Text ENTRY is the one exception: selection is part of editing. */
|
|
15
|
+
.vela-ui :is(input, textarea), .vela-ui-layer :is(input, textarea) { user-select: text; -webkit-user-select: text; }
|
|
16
|
+
/* iOS Safari zooms the page when a focused field is under 16px, and often
|
|
17
|
+
keeps that zoom after the field blurs or a dialog closes. The shell's
|
|
18
|
+
mobile size class is the honest gate \u2014 not a media query \u2014 so an embedded
|
|
19
|
+
chart on a wide desktop still gets the rule when it is in the phone layout.
|
|
20
|
+
Scoped to the kit root so a host page's own [data-layout] is never touched. */
|
|
21
|
+
.vela-ui[data-layout='mobile'] :is(input, textarea, select) { font-size: 16px; }
|
|
22
|
+
.vela-icon { display: inline-flex; align-items: center; flex: none; }
|
|
23
|
+
.vela-icon svg { display: block; }
|
|
24
|
+
`;function YT(r,e){let t=al(e);for(let n in t)r.style.setProperty(n,t[n]);}function Ll(r,e){return r.closest(".vela-ui")??e??r}function ag(r,e){he(WT,UT,r.getRootNode()),r.classList.add("vela-ui"),e&&YT(r,e);}function qe(r,e=document){let t=e.createElement("span");t.className="vela-icon",t.setAttribute("aria-hidden","true");let n=Wr(r);return n&&(t.innerHTML=n),t}var mn=(r,e=[])=>({parts:(...t)=>{if(KT(e))return mn(r,t);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...t)=>mn(r,[...e,...t]),omit:(...t)=>mn(r,e.filter(n=>!t.includes(n))),rename:t=>mn(t,e),keys:()=>e,build:()=>[...new Set(e)].reduce((t,n)=>Object.assign(t,{[n]:{selector:[`&[data-scope="${fi(r)}"][data-part="${fi(n)}"]`,`& [data-scope="${fi(r)}"][data-part="${fi(n)}"]`].join(", "),attrs:{"data-scope":fi(r),"data-part":fi(n)}}}),{})}),fi=r=>r.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),KT=r=>r.length===0;var XT=mn("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),We=XT.build();var ug=["top","right","bottom","left"];var jt=Math.min,Pt=Math.max,Do=Math.round,Oo=Math.floor,qt=r=>({x:r,y:r}),jT={left:"right",right:"left",bottom:"top",top:"bottom"};function gd(r,e,t){return Pt(r,jt(e,t))}function Zt(r,e){return typeof r=="function"?r(e):r}function fn(r){return r.split("-")[0]}function Cr(r){return r.split("-")[1]}function Pl(r){return r==="x"?"y":"x"}function Il(r){return r==="y"?"height":"width"}function It(r){let e=r[0];return e==="t"||e==="b"?"y":"x"}function Al(r){return Pl(It(r))}function dg(r,e,t){t===void 0&&(t=false);let n=Cr(r),i=Al(r),o=Il(i),s=i==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Ro(s)),[s,Ro(s)]}function hg(r){let e=Ro(r);return [Ml(r),e,Ml(e)]}function Ml(r){return r.includes("start")?r.replace("start","end"):r.replace("end","start")}var lg=["left","right"],cg=["right","left"],qT=["top","bottom"],ZT=["bottom","top"];function JT(r,e,t){switch(r){case "top":case "bottom":return t?e?cg:lg:e?lg:cg;case "left":case "right":return e?qT:ZT;default:return []}}function pg(r,e,t,n){let i=Cr(r),o=JT(fn(r),t==="start",n);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(Ml)))),o}function Ro(r){let e=fn(r);return jT[e]+r.slice(e.length)}function QT(r){var e,t,n,i;return {top:(e=r.top)!=null?e:0,right:(t=r.right)!=null?t:0,bottom:(n=r.bottom)!=null?n:0,left:(i=r.left)!=null?i:0}}function bd(r){return typeof r!="number"?QT(r):{top:r,right:r,bottom:r,left:r}}function Tr(r){let{x:e,y:t,width:n,height:i}=r;return {width:n,height:i,top:t,left:e,right:e+n,bottom:t+i,x:e,y:t}}function mg(r,e,t){let{reference:n,floating:i}=r,o=It(e),s=Al(e),a=Il(s),l=fn(e),c=o==="y",u=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,h=n[a]/2-i[a]/2,p;switch(l){case "top":p={x:u,y:n.y-i.height};break;case "bottom":p={x:u,y:n.y+n.height};break;case "right":p={x:n.x+n.width,y:d};break;case "left":p={x:n.x-i.width,y:d};break;default:p={x:n.x,y:n.y};}let m=Cr(e);return m&&(p[s]+=h*(m==="end"?1:-1)*(t&&c?-1:1)),p}async function bg(r,e){var t;e===void 0&&(e={});let{x:n,y:i,platform:o,rects:s,elements:a,strategy:l}=r,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=false,padding:p=0}=Zt(e,r),m=bd(p),g=a[h?d==="floating"?"reference":"floating":d],b=Tr(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(g)))==null||t?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),y=d==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),S=await(o.isElement==null?void 0:o.isElement(v))&&await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1},E=Tr(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:v,strategy:l}):y);return {top:(b.top-E.top+m.top)/S.y,bottom:(E.bottom-b.bottom+m.bottom)/S.y,left:(b.left-E.left+m.left)/S.x,right:(E.right-b.right+m.right)/S.x}}var ek=50,vg=async(r,e,t)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:bg},l=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:r,floating:e,strategy:i}),{x:u,y:d}=mg(c,n,l),h=n,p=0,m={};for(let f=0;f<o.length;f++){let g=o[f];if(!g)continue;let{name:b,fn:y}=g,{x:v,y:S,data:E,reset:T}=await y({x:u,y:d,initialPlacement:n,placement:h,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:r,floating:e}});u=v??u,d=S??d,m[b]={...m[b],...E},T&&p<ek&&(p++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(c=T.rects===true?await s.getElementRects({reference:r,floating:e,strategy:i}):T.rects),{x:u,y:d}=mg(c,h,l)),f=-1);}return {x:u,y:d,placement:h,strategy:i,middlewareData:m}},yg=r=>({name:"arrow",options:r,async fn(e){let{x:t,y:n,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=Zt(r,e)||{};if(c==null)return {};let d=bd(u),h={x:t,y:n},p=Al(i),m=Il(p),f=await s.getDimensions(c),g=p==="y",b=g?"top":"left",y=g?"bottom":"right",v=g?"clientHeight":"clientWidth",S=o.reference[m]+o.reference[p]-h[p]-o.floating[m],E=h[p]-o.reference[p],T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),k=T?T[v]:0;(!k||!await(s.isElement==null?void 0:s.isElement(T)))&&(k=a.floating[v]||o.floating[m]);let x=S/2-E/2,L=k/2-f[m]/2-1,w=jt(d[b],L),M=jt(d[y],L),P=k-f[m]-M,C=k/2-f[m]/2+x,A=gd(w,C,P),$=!l.arrow&&Cr(i)!=null&&C!==A&&o.reference[m]/2-(C<w?w:M)-f[m]/2<0,ie=$?C<w?C-w:C-P:0;return {[p]:h[p]+ie,data:{[p]:A,centerOffset:C-A-ie,...$&&{alignmentOffset:ie}},reset:$}}});var wg=function(r){return r===void 0&&(r={}),{name:"flip",options:r,async fn(e){var t,n;let{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=true,crossAxis:d=true,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:f=true,...g}=Zt(r,e);if((t=o.arrow)!=null&&t.alignmentOffset)return {};let b=fn(i),y=It(a),v=fn(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=h||(v||!f?[Ro(a)]:hg(a)),T=m!=="none";!h&&T&&E.push(...pg(a,f,m,S));let k=[a,...E],x=await l.detectOverflow(e,g),L=[],w=((n=o.flip)==null?void 0:n.overflows)||[];if(u&&L.push(x[b]),d){let A=dg(i,s,S);L.push(x[A[0]],x[A[1]]);}if(w=[...w,{placement:i,overflows:L}],!L.every(A=>A<=0)){var M,P;let A=(((M=o.flip)==null?void 0:M.index)||0)+1,$=k[A];if($&&(!(d==="alignment"?y!==It($):false)||w.every(j=>It(j.placement)===y?j.overflows[0]>0:true)))return {data:{index:A,overflows:w},reset:{placement:$}};let ie=(P=w.filter(oe=>oe.overflows[0]<=0).sort((oe,j)=>oe.overflows[1]-j.overflows[1])[0])==null?void 0:P.placement;if(!ie)switch(p){case "bestFit":{var C;let oe=(C=w.filter(j=>{if(T){let ut=It(j.placement);return ut===y||ut==="y"}return true}).map(j=>[j.placement,j.overflows.filter(ut=>ut>0).reduce((ut,M0)=>ut+M0,0)]).sort((j,ut)=>j[1]-ut[1])[0])==null?void 0:C[0];oe&&(ie=oe);break}case "initialPlacement":ie=a;break}if(i!==ie)return {reset:{placement:ie}}}return {}}}};function fg(r,e){return {top:r.top-e.height,right:r.right-e.width,bottom:r.bottom-e.height,left:r.left-e.width}}function gg(r){return ug.some(e=>r[e]>=0)}var xg=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(e){let{rects:t,platform:n}=e,{strategy:i="referenceHidden",...o}=Zt(r,e);switch(i){case "referenceHidden":{let s=await n.detectOverflow(e,{...o,elementContext:"reference"}),a=fg(s,t.reference);return {data:{referenceHiddenOffsets:a,referenceHidden:gg(a)}}}case "escaped":{let s=await n.detectOverflow(e,{...o,altBoundary:true}),a=fg(s,t.floating);return {data:{escapedOffsets:a,escaped:gg(a)}}}default:return {}}}}};var Sg=new Set(["left","top"]);async function tk(r,e){let{placement:t,platform:n,elements:i}=r,o=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=fn(t),a=Cr(t),l=It(t)==="y",c=Sg.has(s)?-1:1,u=o&&l?-1:1,d=Zt(e,r),{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}var Cg=function(r){return r===void 0&&(r=0),{name:"offset",options:r,async fn(e){var t,n;let{x:i,y:o,placement:s,middlewareData:a}=e,l=await tk(e,r);return s===((t=a.offset)==null?void 0:t.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Tg=function(r){return r===void 0&&(r={}),{name:"shift",options:r,async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:s=true,crossAxis:a=false,limiter:l={fn:y=>{let{x:v,y:S}=y;return {x:v,y:S}}},...c}=Zt(r,e),u={x:t,y:n},d=await o.detectOverflow(e,c),h=It(i),p=Pl(h),m=u[p],f=u[h],g=(y,v)=>gd(v+d[y==="y"?"top":"left"],v,v-d[y==="y"?"bottom":"right"]);s&&(m=g(p,m)),a&&(f=g(h,f));let b=l.fn({...e,[p]:m,[h]:f});return {...b,data:{x:b.x-t,y:b.y-n,enabled:{[p]:s,[h]:a}}}}}},kg=function(r){return r===void 0&&(r={}),{options:r,fn(e){var t,n;let{x:i,y:o,placement:s,rects:a,middlewareData:l}=e,{offset:c=0,mainAxis:u=true,crossAxis:d=true}=Zt(r,e),h={x:i,y:o},p=It(s),m=Pl(p),f=h[m],g=h[p],b=Zt(c,e),y=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(n=b.crossAxis)!=null?n:0};if(u){let E=m==="y"?"height":"width",T=a.reference[m]-a.floating[E]+y.mainAxis,k=a.reference[m]+a.reference[E]-y.mainAxis;f<T?f=T:f>k&&(f=k);}if(d){var v,S;let E=m==="y"?"width":"height",T=Sg.has(fn(s)),k=a.reference[p]-a.floating[E]+(T&&((v=l.offset)==null?void 0:v[p])||0)+(T?0:y.crossAxis),x=a.reference[p]+a.reference[E]+(T?0:((S=l.offset)==null?void 0:S[p])||0)-(T?y.crossAxis:0);g<k?g=k:g>x&&(g=x);}return {[m]:f,[p]:g}}}},Eg=function(r){return r===void 0&&(r={}),{name:"size",options:r,async fn(e){let{placement:t,rects:n,platform:i,elements:o}=e,{apply:s=()=>{},...a}=Zt(r,e),l=await i.detectOverflow(e,a),c=fn(t),u=Cr(t),d=It(t)==="y",{width:h,height:p}=n.floating,m,f;c==="top"||c==="bottom"?(m=c,f=u===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(f=c,m=u==="end"?"top":"bottom");let g=p-l.top-l.bottom,b=h-l.left-l.right,y=jt(p-l[m],g),v=jt(h-l[f],b),S=e.middlewareData.shift,E=!S,T=y,k=v;S!=null&&S.enabled.x&&(k=b),S!=null&&S.enabled.y&&(T=g),E&&!u&&(d?k=h-2*Pt(l.left,l.right):T=p-2*Pt(l.top,l.bottom)),await s({...e,availableWidth:k,availableHeight:T});let x=await i.getDimensions(o.floating);return h!==x.width||p!==x.height?{reset:{rects:true}}:{}}}};function Rl(){return typeof window<"u"}function Er(r){return Mg(r)?(r.nodeName||"").toLowerCase():"#document"}function Ze(r){var e;return (r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function Jt(r){var e;return (e=(Mg(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function Mg(r){return Rl()?r instanceof Node||r instanceof Ze(r).Node:false}function At(r){return Rl()?r instanceof Element||r instanceof Ze(r).Element:false}function gn(r){return Rl()?r instanceof HTMLElement||r instanceof Ze(r).HTMLElement:false}function Lg(r){return !Rl()||typeof ShadowRoot>"u"?false:r instanceof ShadowRoot||r instanceof Ze(r).ShadowRoot}function No(r){let{overflow:e,overflowX:t,overflowY:n,display:i}=Rt(r);return /auto|scroll|overlay|hidden|clip/.test(e+n+t)&&i!=="inline"&&i!=="contents"}function Pg(r){return /^(table|td|th)$/.test(Er(r))}function Fo(r){try{if(r.matches(":popover-open"))return !0}catch{}try{return r.matches(":modal")}catch{return false}}var nk=/transform|translate|scale|rotate|perspective|filter/,rk=/paint|layout|strict|content/,kr=r=>!!r&&r!=="none",vd;function Dl(r){let e=At(r)?Rt(r):r;return kr(e.transform)||kr(e.translate)||kr(e.scale)||kr(e.rotate)||kr(e.perspective)||!Ol()&&(kr(e.backdropFilter)||kr(e.filter))||nk.test(e.willChange||"")||rk.test(e.contain||"")}function Ig(r){let e=Bn(r);for(;gn(e)&&!bi(e);){if(Dl(e))return e;if(Fo(e))return null;e=Bn(e);}return null}function Ol(){return vd==null&&(vd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),vd}function bi(r){return /^(html|body|#document)$/.test(Er(r))}function Rt(r){return Ze(r).getComputedStyle(r)}function Vo(r){return At(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function Bn(r){if(Er(r)==="html")return r;let e=r.assignedSlot||r.parentNode||Lg(r)&&r.host||Jt(r);return Lg(e)?e.host:e}function Ag(r){let e=Bn(r);return bi(e)?(r.ownerDocument||r).body:gn(e)&&No(e)?e:Ag(e)}function gi(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=true);let i=Ag(r),o=i===((n=r.ownerDocument)==null?void 0:n.body),s=Ze(i);if(o){let a=Nl(s);return e.concat(s,s.visualViewport||[],No(i)?i:[],a&&t?gi(a):[])}else return e.concat(i,gi(i,[],t))}function Nl(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}function Og(r){let e=Rt(r),t=parseFloat(e.width)||0,n=parseFloat(e.height)||0,i=gn(r),o=i?r.offsetWidth:t,s=i?r.offsetHeight:n,a=Do(t)!==o||Do(n)!==s;return a&&(t=o,n=s),{width:t,height:n,$:a}}function wd(r){return At(r)?r:r.contextElement}function vi(r){let e=wd(r);if(!gn(e))return qt(1);let t=e.getBoundingClientRect(),{width:n,height:i,$:o}=Og(e),s=(o?Do(t.width):t.width)/n,a=(o?Do(t.height):t.height)/i;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var ik=qt(0);function Ng(r){let e=Ze(r);return !Ol()||!e.visualViewport?ik:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ok(r,e,t){return e===void 0&&(e=false),!!t&&e&&t===Ze(r)}function Lr(r,e,t,n){e===void 0&&(e=false),t===void 0&&(t=false);let i=r.getBoundingClientRect(),o=wd(r),s=qt(1);e&&(n?At(n)&&(s=vi(n)):s=vi(r));let a=ok(o,t,n)?Ng(o):qt(0),l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,u=i.width/s.x,d=i.height/s.y;if(o&&n){let h=Ze(o),p=At(n)?Ze(n):n,m=h,f=Nl(m);for(;f&&p!==m;){let g=vi(f),b=f.getBoundingClientRect(),y=Rt(f),v=b.left+(f.clientLeft+parseFloat(y.paddingLeft))*g.x,S=b.top+(f.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,c*=g.y,u*=g.x,d*=g.y,l+=v,c+=S,m=Ze(f),f=Nl(m);}}return Tr({width:u,height:d,x:l,y:c})}function Fl(r,e){let t=Vo(r).scrollLeft;return e?e.left+t:Lr(Jt(r)).left+t}function Fg(r,e){let t=r.getBoundingClientRect(),n=t.left+e.scrollLeft-Fl(r,t),i=t.top+e.scrollTop;return {x:n,y:i}}function sk(r){let{elements:e,rect:t,offsetParent:n,strategy:i}=r,o=i==="fixed",s=Jt(n),a=e?Fo(e.floating):false;if(n===s||a&&o)return t;let l={scrollLeft:0,scrollTop:0},c=qt(1),u=qt(0),d=gn(n);if((d||!o)&&((Er(n)!=="body"||No(s))&&(l=Vo(n)),d)){let p=Lr(n);c=vi(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop;}let h=s&&!d&&!o?Fg(s,l):qt(0);return {width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:t.y*c.y-l.scrollTop*c.y+u.y+h.y}}function ak(r){return r.getClientRects?Array.from(r.getClientRects()):[]}function lk(r){let e=Vo(r),t=r.ownerDocument.body,n=Pt(r.scrollWidth,r.clientWidth,t.scrollWidth,t.clientWidth),i=Pt(r.scrollHeight,r.clientHeight,t.scrollHeight,t.clientHeight),o=-e.scrollLeft+Fl(r),s=-e.scrollTop;return Rt(t).direction==="rtl"&&(o+=Pt(r.clientWidth,t.clientWidth)-n),{width:n,height:i,x:o,y:s}}var ck=25;function uk(r,e,t){t===void 0&&(t="viewport");let n=t==="layoutViewport",i=Ze(r),o=Jt(r),s=i.visualViewport,a=o.clientWidth,l=o.clientHeight,c=0,u=0;if(s){let h=!Ol()||e==="fixed";n?h||(c=-s.offsetLeft,u=-s.offsetTop):(a=s.width,l=s.height,h&&(c=s.offsetLeft,u=s.offsetTop));}if(Fl(o)<=0){let h=o.ownerDocument,p=h.body,m=getComputedStyle(p),f=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(o.clientWidth-p.clientWidth-f),b=getComputedStyle(o).scrollbarGutter==="stable both-edges"?g/2:g;b<=ck&&(a-=b);}return {width:a,height:l,x:c,y:u}}function dk(r,e){let t=Lr(r,true,e==="fixed"),n=t.top+r.clientTop,i=t.left+r.clientLeft,o=vi(r),s=r.clientWidth*o.x,a=r.clientHeight*o.y,l=i*o.x,c=n*o.y;return {width:s,height:a,x:l,y:c}}function Rg(r,e,t){let n;if(e==="viewport"||e==="layoutViewport")n=uk(r,t,e);else if(e==="document")n=lk(Jt(r));else if(At(e))n=dk(e,t);else {let i=Ng(r);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height};}return Tr(n)}function hk(r,e){let t=e.get(r);if(t)return t;let n=gi(r,[],false).filter(a=>At(a)&&Er(a)!=="body"),i=null,o=Rt(r).position==="fixed",s=o?Bn(r):r;for(;At(s)&&!bi(s);){let a=Rt(s),l=Dl(s),c=i?i.position:o?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?n=n.filter(d=>d!==s):i=a,s=Bn(s);}return e.set(r,n),n}function pk(r){let{element:e,boundary:t,rootBoundary:n,strategy:i}=r,s=[...t==="clippingAncestors"?Fo(e)?[]:hk(e,this._c):[].concat(t),n],a=Rg(e,s[0],i),l=a.top,c=a.right,u=a.bottom,d=a.left;for(let h=1;h<s.length;h++){let p=Rg(e,s[h],i);l=Pt(p.top,l),c=jt(p.right,c),u=jt(p.bottom,u),d=Pt(p.left,d);}return {width:c-d,height:u-l,x:d,y:l}}function mk(r){let{width:e,height:t}=Og(r);return {width:e,height:t}}function fk(r,e,t){let n=gn(e),i=Jt(e),o=t==="fixed",s=Lr(r,true,o,e),a={scrollLeft:0,scrollTop:0},l=qt(0);if((n||!o)&&((Er(e)!=="body"||No(i))&&(a=Vo(e)),n)){let h=Lr(e,true,o,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop;}!n&&i&&(l.x=Fl(i));let c=i&&!n&&!o?Fg(i,a):qt(0),u=s.left+a.scrollLeft-l.x-c.x,d=s.top+a.scrollTop-l.y-c.y;return {x:u,y:d,width:s.width,height:s.height}}function yd(r){return Rt(r).position==="static"}function Dg(r,e){if(!gn(r)||Rt(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return Jt(r)===t&&(t=t.ownerDocument.body),t}function Vg(r,e){let t=Ze(r);if(Fo(r))return t;if(!gn(r)){let i=Bn(r);for(;i&&!bi(i);){if(At(i)&&!yd(i))return i;i=Bn(i);}return t}let n=Dg(r,e);for(;n&&Pg(n)&&yd(n);)n=Dg(n,e);return n&&bi(n)&&yd(n)&&!Dl(n)?t:n||Ig(r)||t}var gk=async function(r){let e=this.getOffsetParent||Vg,t=this.getDimensions,n=await t(r.floating);return {reference:fk(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function bk(r){return Rt(r).direction==="rtl"}var vk={convertOffsetParentRelativeRectToViewportRelativeRect:sk,getDocumentElement:Jt,getClippingRect:pk,getOffsetParent:Vg,getElementRects:gk,getClientRects:ak,getDimensions:mk,getScale:vi,isElement:At,isRTL:bk};function _g(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function yk(r,e,t){let n=null,i,o=Jt(r);function s(){var u;clearTimeout(i),(u=n)==null||u.disconnect(),n=null;}function a(u,d){u===void 0&&(u=false),d===void 0&&(d=1),s();let h=r.getBoundingClientRect(),{left:p,top:m,width:f,height:g}=h;if(u||e(),!f||!g)return;let b=Oo(m),y=Oo(o.clientWidth-(p+f)),v=Oo(o.clientHeight-(m+g)),S=Oo(p),T={rootMargin:-b+"px "+-y+"px "+-v+"px "+-S+"px",threshold:Pt(0,jt(1,d))||1},k=true;function x(L){let w=L[0].intersectionRatio;if(!_g(h,r.getBoundingClientRect()))return a();if(w!==d){if(!k)return a();w?a(false,w):i=setTimeout(()=>{a(false,1e-7);},1e3);}k=false;}try{n=new IntersectionObserver(x,{...T,root:o.ownerDocument});}catch{n=new IntersectionObserver(x,T);}n.observe(r);}let l=Ze(r),c=()=>a(t);return l.addEventListener("resize",c),a(true),()=>{l.removeEventListener("resize",c),s();}}function Bg(r,e,t,n){n===void 0&&(n={});let{ancestorScroll:i=true,ancestorResize:o=true,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=false}=n,c=wd(r),u=i||o?[...c?gi(c):[],...e?gi(e):[]]:[];u.forEach(b=>{i&&b.addEventListener("scroll",t),o&&b.addEventListener("resize",t);});let d=c&&a?yk(c,t,o):null,h=-1,p=null;s&&(p=new ResizeObserver(b=>{let[y]=b;y&&y.target===c&&p&&e&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var v;(v=p)==null||v.observe(e);})),t();}),c&&!l&&p.observe(c),e&&p.observe(e));let m,f=l?Lr(r):null;l&&g();function g(){let b=Lr(r);f&&!_g(f,b)&&t(),f=b,m=requestAnimationFrame(g);}return t(),()=>{var b;u.forEach(y=>{i&&y.removeEventListener("scroll",t),o&&y.removeEventListener("resize",t);}),d?.(),(b=p)==null||b.disconnect(),p=null,l&&cancelAnimationFrame(m);}}var Hg=Cg;var zg=Tg,$g=wg,Wg=Eg,Gg=xg,Ug=yg;var Yg=kg,Kg=(r,e,t)=>{let n=new Map,i=t??{},o={...vk,...i.platform,_c:n};return vg(r,e,{...i,platform:o})};function Xg(r=0,e=0,t=0,n=0){if(typeof DOMRect=="function")return new DOMRect(r,e,t,n);let i={x:r,y:e,width:t,height:n,top:e,right:r+t,bottom:e+n,left:r};return {...i,toJSON:()=>i}}function wk(r){if(!r)return Xg();let{x:e,y:t,width:n,height:i}=r;return Xg(e,t,n,i)}function jg(r,e){return {contextElement:ce(r)?r:r?.contextElement,getBoundingClientRect:()=>{let t=r,n=e?.(t);return n||!t?wk(n):t.getBoundingClientRect()}}}var _o=r=>({variable:r,reference:`var(${r})`}),Qt={arrowSize:_o("--arrow-size"),arrowSizeHalf:_o("--arrow-size-half"),arrowBg:_o("--arrow-background"),transformOrigin:_o("--transform-origin"),arrowOffset:_o("--arrow-offset")},xk=r=>r==="top"||r==="bottom"?"y":"x";function qg(r,e){return {name:"transformOrigin",fn(t){let{elements:n,middlewareData:i,placement:o,rects:s,y:a}=t,l=o.split("-")[0],c=xk(l),u=i.arrow?.x||0,d=i.arrow?.y||0,h=e?.clientWidth||0,p=e?.clientHeight||0,m=u+h/2,f=d+p/2,g=Math.abs(i.shift?.y||0),b=s.reference.height/2,y=p/2,v=r.offset?.mainAxis??r.gutter,S=typeof v=="number"?v+y:v??y,E=g>S,T={top:`${m}px calc(100% + ${S}px)`,bottom:`${m}px ${-S}px`,left:`calc(100% + ${S}px) ${f}px`,right:`${-S}px ${f}px`}[l],k=`${m}px ${s.reference.y+b-a}px`,x=!!r.overlap&&c==="y"&&E;return n.floating.style.setProperty(Qt.transformOrigin.variable,x?k:T),{data:{transformOrigin:x?k:T}}}}}var Zg={name:"rects",fn({rects:r}){return {data:r}}},Jg=r=>{if(r)return {name:"shiftArrow",fn({placement:e,middlewareData:t}){if(!t.arrow)return {};let{x:n,y:i}=t.arrow,o=e.split("-")[0];return Object.assign(r.style,{left:n!=null?`${n}px`:"",top:i!=null?`${i}px`:"",[o]:`calc(100% + ${Qt.arrowOffset.reference})`}),{}}}};function Qg(r){let[e,t]=r.split("-");return {side:e,align:t,hasAlign:t!=null}}function Bo(r){return r.split("-")[0]}var Sk={strategy:"absolute",placement:"bottom",listeners:true,restoreStyles:false,gutter:8,flip:true,slide:true,overlap:false,sameWidth:false,fitViewport:false,overflowPadding:8,arrowPadding:4};function eb(r,e){let t=r.devicePixelRatio||1;return Math.round(e*t)/t}function yi(r,e){return r!=null&&Math.abs(r-e)<.5}function Vl(r){return typeof r=="function"?r():r==="clipping-ancestors"?"clippingAncestors":r}function Ck(r,e,t){let n=r||e.createElement("div");return Ug({element:n,padding:t.arrowPadding})}function Tk(r,e){if(!tf(e.offset??e.gutter))return Hg(({placement:t})=>{let n=(r?.clientHeight||0)/2,i=e.offset?.mainAxis??e.gutter,o=typeof i=="number"?i+n:i??n,{hasAlign:s}=Qg(t),a=s?void 0:e.shift,l=e.offset?.crossAxis??a;return Fn({crossAxis:l,mainAxis:o,alignmentAxis:e.shift})})}function kk(r){if(r.flip)return $g(()=>{let e=Vl(r.boundary);return {...e?{boundary:e}:void 0,padding:r.overflowPadding,fallbackPlacements:r.flip===true?void 0:r.flip}})}function Ek(r){if(!(!r.slide&&!r.overlap))return zg(()=>{let e=Vl(r.boundary);return {...e?{boundary:e}:void 0,mainAxis:r.slide,crossAxis:r.overlap,padding:r.overflowPadding,limiter:Yg()}})}function Lk(r){if(r.sizeMiddleware===false&&!r.sameWidth&&!r.fitViewport)return;let e,t,n,i;return Wg(()=>{let o=Vl(r.boundary);return {padding:r.overflowPadding,...o?{boundary:o}:void 0,apply({elements:s,rects:a,availableHeight:l,availableWidth:c}){let u=s.floating,d=Math.round(a.reference.width),h=Math.round(a.reference.height);c=Math.floor(c),l=Math.floor(l),yi(e,d)||(u.style.setProperty("--reference-width",`${d}px`),e=d),yi(t,h)||(u.style.setProperty("--reference-height",`${h}px`),t=h),yi(n,c)||(u.style.setProperty("--available-width",`${c}px`),n=c),yi(i,l)||(u.style.setProperty("--available-height",`${l}px`),i=l);}}})}function Mk(r){if(r.hideWhenDetached)return Gg(()=>({strategy:"referenceHidden",boundary:Vl(r.boundary)??"clippingAncestors"}))}function Pk(r){return r?r===true?{ancestorResize:true,ancestorScroll:true,elementResize:true,layoutShift:true}:r:{}}var Ik=["transform","visibility","pointer-events","--x","--y","--z-index","--reference-width","--reference-height","--available-width","--available-height","--transform-origin"],Ak=["top","right","bottom","left"];function tb(r,e){if(!r)return Uu;let t=new Map(e.map(n=>[n,r.style.getPropertyValue(n)]));return ()=>{t.forEach((n,i)=>{n?r.style.setProperty(i,n):r.style.removeProperty(i);}),r.style.length===0&&r.removeAttribute("style");}}function nb(r){return r==null?null:ce(r)?r:typeof r=="object"&&r&&"contextElement"in r&&r.contextElement?r.contextElement:r}function Rk(r,e,t={}){let n=()=>(typeof e=="function"?e():e)??null,i=()=>{let w=typeof r=="function"?r():r;return t.getAnchorElement?.()??w},o=()=>{let w=i();return !w&&!t.getAnchorRect?null:jg(w,t.getAnchorRect)},s=Object.assign({},Sk,t),a=[],l=null,c,u;function d(w){c?.(),u?.(),l=w,c=s.restoreStyles?tb(w,Ik):void 0;let M=w.querySelector("[data-part=arrow]");u=s.restoreStyles?tb(M,Ak):void 0,a=[Tk(M,s),kk(s),Ek(s),Ck(M,w.ownerDocument,s),Jg(M),qg({gutter:s.gutter,offset:s.offset,overlap:s.overlap},M),Lk(s),Mk(s),Zg];}let{placement:h,strategy:p,onComplete:m,onPositioned:f}=s,g,b,y=false,v,S,E=Uu,T=Pk(s.listeners);function k(){if(!s.listeners)return;let w=i(),M=o(),P=n();if(!M||!P)return;(nb(w)!==nb(v)||P!==S)&&(E(),v=w,S=P,E=Bg(M,P,L,T));}async function x(){k();let w=n();if(!w)return;w!==l&&(d(w),y=false);let M=o();if(!M)return;let P=await Kg(M,w,{placement:h,middleware:a,strategy:p});m?.(P);let C=Ce(w),A=eb(C,P.x),$=eb(C,P.y);if(yi(g,A)||(w.style.setProperty("--x",`${A}px`),g=A),yi(b,$)||(w.style.setProperty("--y",`${$}px`),b=$),s.hideWhenDetached&&(P.middlewareData.hide?.referenceHidden?(w.style.setProperty("visibility","hidden"),w.style.setProperty("pointer-events","none")):(w.style.removeProperty("visibility"),w.style.removeProperty("pointer-events"))),!y){let ie=w.firstElementChild;ie&&(w.style.setProperty("--z-index",ai(ie).zIndex),y=true);}}async function L(){t.updatePosition?(await t.updatePosition({updatePosition:x,floatingElement:n()}),f?.({placed:true})):await x();}return L(),()=>{E(),u?.(),c?.(),f?.({placed:false});}}function _l(r,e,t={}){let{defer:n,...i}=t,o=n?Ie:a=>a(),s=[];return s.push(o(()=>{s.push(Rk(r,e,i));})),()=>{s.forEach(a=>a?.());}}var Dk={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"};function xd(r={}){let{placement:e,sameWidth:t,fitViewport:n,strategy:i="absolute"}=r;return {arrow:{position:"absolute",width:Qt.arrowSize.reference,height:Qt.arrowSize.reference,[Qt.arrowSizeHalf.variable]:`calc(${Qt.arrowSize.reference} / 2)`,[Qt.arrowOffset.variable]:`calc(${Qt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:e?Dk[e.split("-")[0]]:void 0,background:Qt.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:i,isolation:"isolate",minWidth:t?void 0:"max-content",width:t?"var(--reference-width)":void 0,maxWidth:n?"var(--available-width)":void 0,maxHeight:n?"var(--available-height)":void 0,pointerEvents:e?void 0:"none",top:"0px",left:"0px",transform:e?"translate3d(var(--x), var(--y), 0)":"translate3d(0, -100vh, 0)",zIndex:"var(--z-index)"}}}var en=(r,e)=>{let t=r.ids?.trigger;return t!=null?nt(t)?t(e):t:e?`menu:${r.id}:trigger:${e}`:`menu:${r.id}:trigger`},Bl=(r,e)=>{let t=r.ids?.contextTrigger;return t!=null?nt(t)?t(e):t:e?`menu:${r.id}:ctx-trigger:${e}`:`menu:${r.id}:ctx-trigger`},Hn=r=>r.ids?.content??`menu:${r.id}:content`,rb=r=>r.ids?.arrow??`menu:${r.id}:arrow`,Sd=r=>r.ids?.positioner??`menu:${r.id}:popper`,ib=(r,e)=>r.ids?.group?.(e)??`menu:${r.id}:group:${e}`,Mr=(r,e)=>`${r.id}/${e}`,zn=r=>r?.dataset.value??null,Cd=(r,e)=>r.ids?.groupLabel?.(e)??`menu:${r.id}:group-label:${e}`,Dt=r=>r.getById(Hn(r)),Td=r=>r.getById(Sd(r)),kd=r=>r.getById(en(r)),ob=(r,e)=>e?r.getById(Mr(r,e)):null;var sb=r=>r.getById(Bl(r)),Ed=r=>hi(r.getRootNode(),`[data-scope="menu"][data-part="trigger"][data-ownedby="${r.id}"]`),Ld=r=>hi(r.getRootNode(),`[data-scope="menu"][data-part="context-trigger"][data-ownedby="${r.id}"]`),Ho=(r,e)=>e==null?kd(r)??Ed(r)[0]:r.getById(en(r,e)),zo=r=>{let t=`[role^="menuitem"][data-ownedby=${CSS.escape(Hn(r))}]:not([data-disabled])`;return hi(Dt(r),t)},ab=r=>jm(zo(r)),lb=r=>qm(zo(r)),Md=(r,e)=>e?r.id===e||r.dataset.value===e:false,cb=(r,e)=>{let t=zo(r),n=t.findIndex(i=>Md(i,e.value));return Jm(t,n,{loop:e.loop??e.loopFocus})},ub=(r,e)=>{let t=zo(r),n=t.findIndex(i=>Md(i,e.value));return Qm(t,n,{loop:e.loop??e.loopFocus})},db=(r,e)=>{let t=zo(r),n=t.find(i=>Md(i,e.value));return yl(t,{state:e.typeaheadState,key:e.key,activeId:n?.id??null})},$o=r=>ce(r)&&(r.dataset.disabled===""||r.hasAttribute("disabled")),Pd=r=>!!r?.getAttribute("role")?.startsWith("menuitem")&&!!r?.hasAttribute("data-controls");var Hl="menu:select";function hb(r,e){if(!r)return;let t=Ce(r),n=new t.CustomEvent(Hl,{detail:{value:e}});r.dispatchEvent(n);}function Ok(r){let e=Hn(r);return Dt(r)??r.getDoc().getElementById(e)}function Id(r,e){if(!ce(r))return false;for(let t in e){let n=e[t],i=Ok(n.scope);if(i&&rt(i,r))return true;let o=n.refs.get("children");if(Object.keys(o).length>0&&Id(r,o))return true}return false}var Wo=(r,e)=>({x:r,y:e});function pb(r){let{x:e,y:t,width:n,height:i}=r,o=e+n/2,s=t+i/2;return {x:e,y:t,width:n,height:i,minX:e,minY:t,maxX:e+n,maxY:t+i,midX:o,midY:s,center:Wo(o,s)}}function mb(r){let e=Wo(r.minX,r.minY),t=Wo(r.maxX,r.minY),n=Wo(r.maxX,r.maxY),i=Wo(r.minX,r.maxY);return {top:e,right:t,bottom:n,left:i}}function fb(r,e){let t=pb(r),{top:n,right:i,left:o,bottom:s}=mb(t),[a]=e.split("-");return {top:[o,n,i,s],right:[n,i,s,o],bottom:[n,o,s,i],left:[i,n,o,s]}[a]}function zl(r,e){let{x:t,y:n}=e,i=false;for(let o=0,s=r.length-1;o<r.length;s=o++){let a=r[o].x,l=r[o].y,c=r[s].x,u=r[s].y;l>n!=u>n&&t<(c-a)*(n-l)/(u-l)+a&&(i=!i);}return i}function Rd(r){let e=r.parent;for(;e&&e.context.get("isSubmenu");)e=e.refs.get("parent");e?.send({type:"CLOSE"});}function gb(r,e){return r?zl(r,e):false}function bb(r,e,t){let n=Object.keys(r).length>0;if(!e)return null;if(!n)return Mr(t,e);for(let i in r){let o=r[i],s=en(o.scope);if(s===e)return s}return Mr(t,e)}function $n(r,e){r&&(r.refs.set("pointerRoutingLocked",e),r.context.set("pointerRoutingMode",e?"locked":"interactive"));}function vb(r){let e=r.context.get("highlightedValue");if(!e)return false;let t=r.refs.get("children");for(let n in t){let i=t[n];if(i.state.hasTag("open")&&en(i.scope)===e)return true}return false}function yb(r,e){r&&(r.refs.get("pointerRoutingLocked")||e&&vb(r)||$n(r,false));}function wb(r){r&&(vb(r)||$n(r,false));}function Dd(r,e){let{context:t,send:n,state:i,computed:o,prop:s,scope:a}=r,l=i.hasTag("open"),c=t.get("isSubmenu"),u=o("isTypingAhead"),d=s("composite"),h=t.get("currentPlacement"),p=h?Bo(h):void 0,m=t.get("anchorPoint"),f=t.get("highlightedValue"),g=t.get("triggerValue"),b=xd({...s("positioning"),placement:h});function y(T){return {id:Mr(a,T.value),disabled:!!T.disabled,highlighted:f===T.value}}function v(T){let k=T.valueText??T.value;return {...T,id:T.value,valueText:k}}function S(T){return {...y(v(T)),checked:!!T.checked}}function E(T){let{closeOnSelect:k,valueText:x,value:L}=T,w=y(T),M=Mr(a,L);return e.element({...We.item.attrs,id:M,role:"menuitem","aria-disabled":Zu(w.disabled),"data-disabled":mt(w.disabled),"data-ownedby":Hn(a),"data-highlighted":mt(w.highlighted),"data-value":L,"data-valuetext":x,onDragStart(P){P.currentTarget.matches("a[href]")&&P.preventDefault();},onPointerMove(P){if(w.disabled||P.pointerType!=="mouse")return;let C=P.currentTarget;if(w.highlighted)return;let A=ci(P);n({type:"ITEM_POINTERMOVE",id:M,target:C,closeOnSelect:k,point:A});},onPointerLeave(P){if(w.disabled||P.pointerType!=="mouse"||!r.event.previous()?.type.includes("POINTER"))return;let A=P.currentTarget;n({type:"ITEM_POINTERLEAVE",id:M,target:A,closeOnSelect:k});},onPointerDown(P){if(w.disabled)return;let C=P.currentTarget;n({type:"ITEM_POINTERDOWN",target:C,id:M,closeOnSelect:k});},onClick(P){if(sd(P)||od(P)||w.disabled)return;let C=P.currentTarget;n({type:"ITEM_CLICK",target:C,id:M,closeOnSelect:k});}})}return {highlightedValue:f,open:l,setOpen(T){i.hasTag("open")!==T&&n({type:T?"OPEN":"CLOSE"});},triggerValue:g,setTriggerValue(T){n({type:"TRIGGER_VALUE.SET",value:T});},setHighlightedValue(T){n({type:"HIGHLIGHTED.SET",value:T});},setParent(T){n({type:"PARENT.SET",value:T,id:T.prop("id")});},setChild(T){n({type:"CHILD.SET",value:T,id:T.prop("id")});},reposition(T={}){n({type:"POSITIONING.SET",options:T});},addItemListener(T){let k=a.getById(T.id);if(!k)return;let x=()=>T.onSelect?.();return k.addEventListener(Hl,x),()=>k.removeEventListener(Hl,x)},getContextTriggerProps(T={}){let{value:k}=T,x=k==null?false:g===k,L=Bl(a,k);return e.element({...We.contextTrigger.attrs,dir:s("dir"),id:L,"data-ownedby":a.id,"data-value":k,"data-current":mt(x),"data-state":l?"open":"closed",onPointerDown(w){if(w.pointerType==="mouse")return;let M=ci(w);n({type:"CONTEXT_MENU_START",point:M,value:k});},onPointerCancel(w){w.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerMove(w){w.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerUp(w){w.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onContextMenu(w){let M=ci(w),P=l&&k!=null&&!x;n({type:P?"TRIGGER_VALUE.SET":"CONTEXT_MENU",point:M,value:k}),w.preventDefault();},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}})},getTriggerItemProps(T){let k=T.getTriggerProps();return sf(E({value:k.id}),k)},getTriggerProps(T={}){let{value:k}=T,x=k==null?false:g===k,L=en(a,k);return e.button({...c?We.triggerItem.attrs:We.trigger.attrs,"data-placement":h,"data-side":p,type:"button",dir:s("dir"),id:L,...k!=null&&{"data-ownedby":a.id,"data-value":k,"data-current":mt(x)},"data-uid":s("id"),"aria-haspopup":d?"menu":"dialog","aria-controls":Hn(a),"data-controls":Hn(a),"aria-expanded":k==null?l:l&&x,"data-state":l?"open":"closed",onPointerMove(w){if(w.pointerType!=="mouse"||$o(w.currentTarget)||!c)return;let P=ci(w);n({type:"TRIGGER_POINTERMOVE",target:w.currentTarget,point:P});},onPointerLeave(w){if($o(w.currentTarget)||w.pointerType!=="mouse"||!c)return;$n(r.refs.get("parent"),true);let M=ci(w);n({type:"TRIGGER_POINTERLEAVE",target:w.currentTarget,point:M});},onPointerDown(w){$o(w.currentTarget)||ml(w)||w.preventDefault();},onClick(w){if(w.defaultPrevented||$o(w.currentTarget))return;let M=l&&k!=null&&!x;n({type:M?"TRIGGER_VALUE.SET":"TRIGGER_CLICK",target:w.currentTarget,value:k});},onBlur(){n({type:"TRIGGER_BLUR"});},onFocus(){n({type:"TRIGGER_FOCUS"});},onKeyDown(w){if(w.defaultPrevented)return;let M={ArrowDown(){n({type:"ARROW_DOWN",value:k});},ArrowUp(){n({type:"ARROW_UP",value:k});},Enter(){n({type:"ARROW_DOWN",src:"enter",value:k});},Space(){n({type:"ARROW_DOWN",src:"space",value:k});}},P=ad(w,{orientation:"vertical",dir:s("dir")}),C=M[P];C&&(w.preventDefault(),C(w));}})},getIndicatorProps(){return e.element({...We.indicator.attrs,dir:s("dir"),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...We.positioner.attrs,dir:s("dir"),id:Sd(a),style:b.floating})},getArrowProps(){return e.element({id:rb(a),...We.arrow.attrs,dir:s("dir"),style:b.arrow})},getArrowTipProps(){return e.element({...We.arrowTip.attrs,dir:s("dir"),style:b.arrowTip})},getContentProps(){return e.element({...We.content.attrs,id:Hn(a),"aria-label":s("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:d?"menu":"dialog",tabIndex:0,dir:s("dir"),"aria-activedescendant":o("highlightedId")||void 0,"aria-labelledby":m?Bl(a,g??void 0):en(a,g??void 0),"data-placement":h,"data-side":p,onPointerEnter(T){T.pointerType==="mouse"&&n({type:"MENU_POINTERENTER"});},onKeyDown(T){if(T.defaultPrevented||!rt(T.currentTarget,De(T)))return;let k=De(T);if(!(k?.closest("[role=menu]")===T.currentTarget||k===T.currentTarget))return;if(T.key==="Tab"&&!Hf(T)){T.preventDefault();return}let L={ArrowDown(){n({type:"ARROW_DOWN"});},ArrowUp(){n({type:"ARROW_UP"});},ArrowLeft(){n({type:"ARROW_LEFT"});},ArrowRight(){n({type:"ARROW_RIGHT"});},Enter(){n({type:"ENTER"});},Space(P){u?n({type:"TYPEAHEAD",key:P.key}):L.Enter?.(P);},Home(){n({type:"HOME"});},End(){n({type:"END"});}},w=ad(T,{dir:s("dir")}),M=L[w];if(M){M(T),T.stopPropagation(),T.preventDefault();return}s("typeahead")&&Df(T)&&(Nf(T)||si(k)||(n({type:"TYPEAHEAD",key:T.key}),T.preventDefault()));}})},getSeparatorProps(){return e.element({...We.separator.attrs,role:"separator",dir:s("dir"),"aria-orientation":"horizontal"})},getItemState:y,getItemProps:E,getOptionItemState:S,getOptionItemProps(T){let{type:k,disabled:x,closeOnSelect:L}=T,w=v(T),M=S(T);return {...E(w),...e.element({"data-type":k,...We.item.attrs,dir:s("dir"),"data-value":w.value,role:`menuitem${k}`,"aria-checked":!!M.checked,"data-state":M.checked?"checked":"unchecked",onClick(P){if(x||sd(P)||od(P))return;let C=P.currentTarget;n({type:"ITEM_CLICK",target:C,option:w,closeOnSelect:L});}})}},getItemIndicatorProps(T){let k=S(Gu(T)),x=k.checked?"checked":"unchecked";return e.element({...We.itemIndicator.attrs,dir:s("dir"),"data-disabled":mt(k.disabled),"data-highlighted":mt(k.highlighted),"data-state":wo(T,"checked")?x:void 0,hidden:wo(T,"checked")?!k.checked:void 0})},getItemTextProps(T){let k=S(Gu(T)),x=k.checked?"checked":"unchecked";return e.element({...We.itemText.attrs,dir:s("dir"),"data-disabled":mt(k.disabled),"data-highlighted":mt(k.highlighted),"data-state":wo(T,"checked")?x:void 0})},getItemGroupLabelProps(T){return e.element({...We.itemGroupLabel.attrs,id:Cd(a,T.htmlFor),dir:s("dir")})},getItemGroupProps(T){return e.element({id:ib(a,T.id),...We.itemGroup.attrs,dir:s("dir"),"aria-labelledby":Cd(a,T.id),role:"group"})}}}function xb(r){let e={each(t){for(let n=0;n<r.frames?.length;n+=1){let i=r.frames[n];i&&t(i);}},addEventListener(t,n,i){return e.each(o=>{try{o.document.addEventListener(t,n,i);}catch{}}),()=>{try{e.removeEventListener(t,n,i);}catch{}}},removeEventListener(t,n,i){e.each(o=>{try{o.document.removeEventListener(t,n,i);}catch{}});}};return e}function Sb(r){let e=r.frameElement!=null?r.parent:null;return {addEventListener:(t,n,i)=>{try{e?.addEventListener(t,n,i);}catch{}return ()=>{try{e?.removeEventListener(t,n,i);}catch{}}},removeEventListener:(t,n,i)=>{try{e?.removeEventListener(t,n,i);}catch{}}}}var Cb="pointerdown.outside",Tb="focus.outside";function Nk(r){for(let e of r)if(ce(e)&&ft(e))return true;return false}var Lb=r=>"clientY"in r;function Fk(r,e){if(!Lb(e)||!r)return false;let t=r.getBoundingClientRect();return t.width===0||t.height===0?false:t.top<=e.clientY&&e.clientY<=t.top+t.height&&t.left<=e.clientX&&e.clientX<=t.left+t.width}function Vk(r,e){return r.y<=e.y&&e.y<=r.y+r.height&&r.x<=e.x&&e.x<=r.x+r.width}function kb(r,e){if(!e||!Lb(r))return false;let t=e.scrollHeight>e.clientHeight,n=t&&r.clientX>e.offsetLeft+e.clientWidth,i=e.scrollWidth>e.clientWidth,o=i&&r.clientY>e.offsetTop+e.clientHeight,s={x:e.offsetLeft,y:e.offsetTop,width:e.clientWidth+(t?16:0),height:e.clientHeight+(i?16:0)},a={x:r.clientX,y:r.clientY};return Vk(s,a)?n||o:false}function _k(r,e){let{exclude:t,onFocusOutside:n,onPointerDownOutside:i,onInteractOutside:o,defer:s,followControlledElements:a=true}=e;if(!r)return;let l=Le(r),c=Ce(r),u=xb(c),d=Sb(c);function h(S,E){if(!ce(E)||!E.isConnected||rt(r,E)||Fk(r,S)||a&&pl(r,E))return false;let T=l.querySelector(`[aria-controls="${r.id}"]`);if(T){let x=bl(T);if(kb(S,x))return false}let k=bl(r);return kb(S,k)?false:!t?.(E)}let p=new Set,m=wr(r?.getRootNode()),f=false;function g(S){f=true;let E=()=>{f=false;};l.addEventListener("pointerup",E,{once:true}),c.addEventListener("pointerup",E,{once:true});function T(k){let x=s&&!id()?Ie:M=>M(),L=k??S,w=L?.composedPath?.()??[L?.target];x(()=>{let M=m?w[0]:De(S);if(!(!r||!h(S,M))){if(i||o){let P=Nn(i,o);r.addEventListener(Cb,P,{once:true});}Eb(r,Cb,{bubbles:false,cancelable:true,detail:{originalEvent:L,contextmenu:ml(L),focusable:Nk(w),target:M}});}});}S.pointerType==="touch"?(p.forEach(k=>k()),p.add(je(l,"click",T,{once:true})),p.add(d.addEventListener("click",T,{once:true})),p.add(u.addEventListener("click",T,{once:true}))):T();}let b=new Set,y=setTimeout(()=>{b.add(je(l,"pointerdown",g,true)),b.add(d.addEventListener("pointerdown",g,true)),b.add(u.addEventListener("pointerdown",g,true));},0);function v(S){if(f)return;(s?Ie:T=>T())(()=>{let T=S?.composedPath?.()??[S?.target],k=m?T[0]:De(S);if(!(!r||!h(S,k))){if(n||o){let x=Nn(n,o);r.addEventListener(Tb,x,{once:true});}Eb(r,Tb,{bubbles:false,cancelable:true,detail:{originalEvent:S,contextmenu:false,focusable:ft(k),target:k}});}});}return id()||(b.add(je(l,"focusin",v,true)),b.add(d.addEventListener("focusin",v,true)),b.add(u.addEventListener("focusin",v,true))),()=>{clearTimeout(y),p.forEach(S=>S()),b.forEach(S=>S());}}function Mb(r,e){let{defer:t}=e,n=t?Ie:o=>o(),i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(_k(o,e));})),()=>{i.forEach(o=>o?.());}}function Eb(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,t);return r.dispatchEvent(i)}function Pb(r,e){let t=n=>{n.key==="Escape"&&(n.isComposing||e?.(n));};return je(Le(r),"keydown",t,{capture:true})}var Ib="layer:request-dismiss",Ge={layers:[],branches:[],recentlyRemoved:new Set,count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(r=>r.pointerBlocking)},topMostPointerBlockingLayer(){return [...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(r){let e=this.indexOf(r),t=this.topMostPointerBlockingLayer()?this.indexOf(this.topMostPointerBlockingLayer()?.node):-1;return e<t},isTopMost(r){return this.layers[this.count()-1]?.node===r},getNestedLayers(r){return Array.from(this.layers).slice(this.indexOf(r)+1)},getLayersByType(r){return this.layers.filter(e=>e.type===r)},getNestedLayersByType(r,e){let t=this.indexOf(r);return t===-1?[]:this.layers.slice(t+1).filter(n=>n.type===e)},getParentLayerOfType(r,e){let t=this.indexOf(r);if(!(t<=0))return this.layers.slice(0,t).reverse().find(n=>n.type===e)},countNestedLayersOfType(r,e){return this.getNestedLayersByType(r,e).length},isInNestedLayer(r,e){return !!(this.getNestedLayers(r).some(n=>rt(n.node,e))||this.recentlyRemoved.size>0)},isInBranch(r){return Array.from(this.branches).some(e=>rt(e,r))},add(r){let e=this.indexOf(r.node);e!==-1&&this.layers.splice(e,1),this.layers.push(r),this.syncLayers();},addBranch(r){this.branches.push(r);},remove(r){let e=this.indexOf(r);if(e<0)return;this.layers[e].styleTargets?.forEach(n=>{let i=n();i&&Bk(i);}),this.recentlyRemoved.add(r),$f(()=>this.recentlyRemoved.delete(r)),e<this.count()-1&&this.getNestedLayers(r).forEach(i=>Ge.dismiss(i.node,r)),this.layers.splice(e,1),this.syncLayers();},removeBranch(r){let e=this.branches.indexOf(r);e>=0&&this.branches.splice(e,1);},syncLayers(){this.layers.forEach((r,e)=>{Ab(r,e,r.node),r.styleTargets?.forEach(t=>{let n=t();if(!n||n===r.node)return;Ab(r,e,n);let{zIndex:i}=ai(r.node);n.style.setProperty("--z-index",i);});});},indexOf(r){return this.layers.findIndex(e=>e.node===r)},dismiss(r,e){let t=this.indexOf(r);if(t===-1)return;let n=this.layers[t];zk(r,Ib,i=>{n.requestDismiss?.(i),i.defaultPrevented||n?.dismiss();}),Hk(r,Ib,{originalLayer:r,targetLayer:e,originalIndex:t,targetIndex:e?this.indexOf(e):-1}),this.syncLayers();},clear(){this.remove(this.layers[0].node);}};function Ab(r,e,t){t.style.setProperty("--layer-index",`${e}`),t.removeAttribute("data-nested"),t.removeAttribute("data-has-nested"),Ge.getParentLayerOfType(r.node,r.type)&&t.setAttribute("data-nested",r.type);let i=Ge.countNestedLayersOfType(r.node,r.type);i>0&&t.setAttribute("data-has-nested",r.type),t.style.setProperty("--nested-layer-count",`${i}`);}function Bk(r){r.style.removeProperty("--layer-index"),r.style.removeProperty("--nested-layer-count"),r.style.removeProperty("--z-index"),r.removeAttribute("data-nested"),r.removeAttribute("data-has-nested");}function Hk(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,{cancelable:true,bubbles:true,detail:t});return r.dispatchEvent(i)}function zk(r,e,t){r.addEventListener(e,t,{once:true});}var Od=new WeakMap,Go=new WeakMap;function $k(r){return Ge.isBelowPointerBlockingLayer(r)?"none":"auto"}function Rb(r){let e=$k(r);r.style.pointerEvents!==e&&(r.style.pointerEvents=e);}function Wk(r){if(Go.has(r))return;let e=Ce(r);if(typeof e.MutationObserver>"u")return;let t=new e.MutationObserver(()=>{Go.has(r)&&Rb(r);});t.observe(r,{attributes:true,attributeFilter:["style"]}),Go.set(r,t);}function Nd(){Ge.layers.forEach(({node:r})=>{Rb(r),Wk(r);});}function Db(r){let e=Go.get(r);e&&(e.disconnect(),Go.delete(r)),r.style.pointerEvents="";}function Ob(r,e){let t=Le(r),n=[];return Ge.hasPointerBlockingLayer()&&!t.body.hasAttribute("data-inert")&&(Od.set(t.body,t.body.style.pointerEvents),queueMicrotask(()=>{let i=t.body;i&&(i.style.pointerEvents="none",i.setAttribute("data-inert",""));})),e?.forEach(i=>{let[o,s]=qf(()=>{let a=i();return ce(a)?a:null},{timeout:1e3});o.then(a=>n.push(Po(a,{pointerEvents:"auto"}))),n.push(s);}),()=>{Ge.hasPointerBlockingLayer()||(queueMicrotask(()=>{let i=t.body;if(!i)return;let o=Od.get(i);o!==void 0&&(i.style.pointerEvents=o,Od.delete(i)),i.removeAttribute("data-inert"),i.style.length===0&&i.removeAttribute("style");}),n.forEach(i=>i()));}}function Gk(r,e){let{warnOnMissingNode:t=true}=e;if(t&&!r){ri("[@zag-js/dismissable] node is `null` or `undefined`");return}if(!r)return;let{onDismiss:n,onRequestDismiss:i,pointerBlocking:o,exclude:s,debug:a,type:l="dialog",layerStyleTargets:c}=e,u={dismiss:n,node:r,type:l,pointerBlocking:o,requestDismiss:i,styleTargets:c};Ge.add(u),Nd();function d(g){let b=De(g.detail.originalEvent);Ge.isBelowPointerBlockingLayer(r)||Ge.isInBranch(b)||(e.onPointerDownOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onPointerDownOutside:",g.detail.originalEvent),n?.()));}function h(g){let b=De(g.detail.originalEvent);Ge.isInBranch(b)||(e.onFocusOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onFocusOutside:",g.detail.originalEvent),n?.()));}function p(g){Ge.isTopMost(r)&&(e.onEscapeKeyDown?.(g),!g.defaultPrevented&&n&&(g.preventDefault(),n()));}function m(g){if(!r)return false;let b=typeof s=="function"?s():s,y=Array.isArray(b)?b:[b],v=e.persistentElements?.map(S=>S()).filter(ce);return v&&y.push(...v),y.some(S=>rt(S,g))||Ge.isInNestedLayer(r,g)}let f=[o?Ob(r,e.persistentElements):void 0,Pb(r,p),Mb(r,{exclude:m,onFocusOutside:h,onPointerDownOutside:d,defer:e.defer})];return ()=>{Ge.remove(r),Nd(),Db(r),f.forEach(g=>g?.());}}function $l(r,e){let{defer:t}=e,n=t?Ie:o=>o(),i=[];return i.push(n(()=>{let o=nt(r)?r():r;i.push(Gk(o,e));})),()=>{i.forEach(o=>o?.());}}function Uk(r){return !(r.metaKey||!li()&&r.altKey||r.ctrlKey||r.key==="Control"||r.key==="Shift"||r.key==="Meta")}var Yk=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function Kk(r,e,t){let n=t?De(t):null,i=Le(n),o=Ce(n),s=Xt(i);return r=r||s instanceof o.HTMLInputElement&&!Yk.has(s?.type)||s instanceof o.HTMLTextAreaElement||s instanceof o.HTMLElement&&s.isContentEditable,!(r&&e==="keyboard"&&t instanceof o.KeyboardEvent&&!Reflect.has(Xk,t.key))}var bn=null,Fd=new Set,Wl=new Map,Pr=false,Vd=false,Fb=false,Xk={Tab:true,Escape:true};function Ul(r,e){for(let t of Fd)t(r,e);}function Gl(r){Pr=true,Uk(r)&&(bn="keyboard",Ul("keyboard",r));}function gt(r){bn="pointer",(r.type==="mousedown"||r.type==="pointerdown")&&(Pr=true,Ul("pointer",r));}function Vb(r){Of(r)&&(Pr=true,bn="virtual");}function _b(r){let e=De(r);e===Ce(e)||e===Le(e)||Fb||!r.isTrusted||(!Pr&&!Vd&&(bn="virtual",Ul("virtual",r)),Pr=false,Vd=false);}function Bb(){(Pr=false,Vd=true);}function jk(r){if(typeof window>"u"||Wl.get(Ce(r)))return;let e=Ce(r),t=Le(r),n=e.HTMLElement.prototype.focus;function i(){Pr=true,n.apply(this,arguments);}try{Object.defineProperty(e.HTMLElement.prototype,"focus",{configurable:!0,value:i});}catch{}t.addEventListener("keydown",Gl,true),t.addEventListener("keyup",Gl,true),t.addEventListener("click",Vb,true),e.addEventListener("focus",_b,true),e.addEventListener("blur",Bb,false),typeof e.PointerEvent<"u"?(t.addEventListener("pointerdown",gt,true),t.addEventListener("pointermove",gt,true),t.addEventListener("pointerup",gt,true)):(t.addEventListener("mousedown",gt,true),t.addEventListener("mousemove",gt,true),t.addEventListener("mouseup",gt,true)),e.addEventListener("beforeunload",()=>{qk(r);},{once:true}),Wl.set(e,{focus:n});}var qk=(r,e)=>{let t=Ce(r),n=Le(r);let i=Wl.get(t);if(i){try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus});}catch{}n.removeEventListener("keydown",Gl,true),n.removeEventListener("keyup",Gl,true),n.removeEventListener("click",Vb,true),t.removeEventListener("focus",_b,true),t.removeEventListener("blur",Bb,false),typeof t.PointerEvent<"u"?(n.removeEventListener("pointerdown",gt,true),n.removeEventListener("pointermove",gt,true),n.removeEventListener("pointerup",gt,true)):(n.removeEventListener("mousedown",gt,true),n.removeEventListener("mousemove",gt,true),n.removeEventListener("mouseup",gt,true)),Wl.delete(t);}};function Hb(){return bn}function zb(r){bn=r,Ul(r,null);}function Nb(){return bn==="keyboard"||bn==="virtual"}function $b(r={}){let{isTextInput:e,autoFocus:t,onChange:n,root:i}=r;jk(i),n?.({isFocusVisible:t||Nb(),modality:bn});let o=(s,a)=>{Kk(!!e,s,a)&&n?.({isFocusVisible:Nb(),modality:s});};return Fd.add(o),()=>{Fd.delete(o);}}var{not:bt,and:wi,or:Zk}=gf(),_d=ul({props({props:r}){return {closeOnSelect:true,typeahead:true,composite:true,loopFocus:false,navigate(e){Uf(e.node);},...r,positioning:{placement:"bottom-start",gutter:8,...r.positioning}}},initialState({prop:r}){return r("open")||r("defaultOpen")?"open":"idle"},context({bindable:r,prop:e,scope:t}){return {highlightedValue:r(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(n){e("onHighlightChange")?.({highlightedValue:n});}})),lastHighlightedValue:r(()=>({defaultValue:null})),currentPlacement:r(()=>({defaultValue:void 0})),intentPolygon:r(()=>({defaultValue:null})),anchorPoint:r(()=>({defaultValue:null,hash(n){return `x: ${n?.x}, y: ${n?.y}`}})),isSubmenu:r(()=>({defaultValue:false})),triggerValue:r(()=>({defaultValue:e("defaultTriggerValue")??null,value:e("triggerValue"),onChange(n){let i=e("onTriggerValueChange");if(!i)return;let o=Ho(t,n);i({value:n,triggerElement:o});}})),pointerRoutingMode:r(()=>({defaultValue:"interactive"}))}},refs(){return {parent:null,children:{},pointerRoutingLocked:false,typeaheadState:{...yl.defaultOptions},positioningOverride:{}}},computed:{isRtl:({prop:r})=>r("dir")==="rtl",isTypingAhead:({refs:r})=>r.get("typeaheadState").keysSoFar!=="",highlightedId:({context:r,scope:e,refs:t})=>bb(t.get("children"),r.get("highlightedValue"),e)},watch({track:r,action:e,context:t,prop:n}){r([()=>t.get("isSubmenu")],()=>{e(["setSubmenuPlacement"]);}),r([()=>t.hash("anchorPoint")],()=>{t.get("anchorPoint")&&e(["reposition"]);}),r([()=>n("open")],()=>{e(["toggleVisibility"]);});},on:{"TRIGGER_VALUE.SET":{actions:["setTriggerValue","setAnchorPoint","reposition","focusMenu"]},"PARENT.SET":{actions:["setParentMenu"]},"CHILD.SET":{actions:["setChildMenu"]},OPEN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen"]}],OPEN_AUTOFOCUS:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"HIGHLIGHTED.RESTORE":{actions:["restoreHighlightedItem"]},"HIGHLIGHTED.SET":{actions:["setHighlightedItem"]},"HIGHLIGHTED.SUGGEST":{actions:["suggestHighlightedItem"]}},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_FOCUS:{guard:bt("isSubmenu"),target:"closed"},TRIGGER_POINTERMOVE:{guard:"isSubmenu",target:"opening"}}},"opening:contextmenu":{tags:["closed"],effects:["waitForLongPress"],on:{"CONTROLLED.OPEN":{target:"open",actions:["reposition"]},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},CONTEXT_MENU_CANCEL:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"LONG_PRESS.OPEN":[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen","reposition"]}]}},opening:{tags:["closed"],effects:["waitForOpenDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},BLUR:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],TRIGGER_POINTERLEAVE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"DELAY.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},closing:{tags:["open"],effects:["trackPointerMove","trackInteractOutside","waitForCloseDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]},MENU_POINTERENTER:{target:"open",actions:["clearIntentPolygon"]},POINTER_MOVED_AWAY_FROM_SUBMENU:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]}],"DELAY.CLOSE":[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem","invokeOnClose","releaseParentRoutingLock"]}]}},closed:{tags:["closed"],entry:["clearHighlightedItem","unlockParentOnClose","clearAnchorPoint"],on:{"CONTROLLED.OPEN":[{guard:Zk("isOpenAutoFocusEvent","isArrowDownEvent"),target:"open",actions:["highlightFirstItem"]},{guard:"isArrowUpEvent",target:"open",actions:["highlightLastItem"]},{target:"open"}],CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",target:"opening"},TRIGGER_BLUR:{target:"idle"},ARROW_DOWN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],ARROW_UP:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightLastItem","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackInteractOutside","trackFocusVisible","trackPositioning","scrollToHighlightedItem"],entry:["focusMenu","unlockParentOnOpen"],on:{"CONTROLLED.CLOSE":[{target:"closed",guard:"isArrowLeftEvent",actions:["focusParentMenu"]},{target:"closed",actions:["focusTrigger"]}],TRIGGER_CLICK:[{guard:wi(bt("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:bt("isTriggerItem"),target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],CONTEXT_MENU:{actions:["setAnchorPoint","setTriggerValue","focusMenu"]},ARROW_UP:{actions:["highlightPrevItem","focusMenu"]},ARROW_DOWN:{actions:["highlightNextItem","focusMenu"]},ARROW_LEFT:[{guard:wi("isSubmenu","isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:"isSubmenu",target:"closed",actions:["focusParentMenu","invokeOnClose","releaseParentRoutingLock"]}],HOME:{actions:["highlightFirstItem","focusMenu"]},END:{actions:["highlightLastItem","focusMenu"]},ARROW_RIGHT:{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},ENTER:[{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},{actions:["clickHighlightedItem"]}],ITEM_POINTERMOVE:[{guard:bt("isPointerRoutingLocked"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:wi(bt("isPointerRoutingLocked"),bt("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:wi(bt("isTriggerItemHighlighted"),bt("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock"]},{guard:wi(bt("isTriggerItemHighlighted"),bt("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock","focusTrigger"]},{guard:wi(bt("isTriggerItemHighlighted"),bt("isHighlightedItemEditable")),actions:["invokeOnSelect","setOptionState"]},{actions:["setHighlightedItem"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",actions:["setIntentPolygon"]},TRIGGER_POINTERLEAVE:{target:"closing",actions:["setIntentPolygon"]},ITEM_POINTERDOWN:{actions:["setHighlightedItem"]},TYPEAHEAD:{actions:["highlightMatchedItem"]},FOCUS_MENU:{actions:["focusMenu"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{closeOnSelect:({prop:r,event:e})=>!!(e?.closeOnSelect??r("closeOnSelect")),isTriggerItem:({event:r})=>Pd(r.target),isTriggerItemHighlighted:({event:r,scope:e,computed:t})=>!!(r.target??e.getById(t("highlightedId")))?.hasAttribute("data-controls"),isSubmenu:({context:r})=>r.get("isSubmenu"),isPointerRoutingLocked:({refs:r})=>r.get("pointerRoutingLocked"),isHighlightedItemEditable:({scope:r,computed:e})=>si(r.getById(e("highlightedId"))),isOpenControlled:({prop:r})=>r("open")!==void 0,isArrowLeftEvent:({event:r})=>r.previousEvent?.type==="ARROW_LEFT",isArrowUpEvent:({event:r})=>r.previousEvent?.type==="ARROW_UP",isArrowDownEvent:({event:r})=>r.previousEvent?.type==="ARROW_DOWN",isOpenAutoFocusEvent:({event:r})=>r.previousEvent?.type==="OPEN_AUTOFOCUS"},effects:{waitForOpenDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.OPEN"});},200);return ()=>clearTimeout(e)},waitForCloseDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.CLOSE"});},100);return ()=>clearTimeout(e)},waitForLongPress({send:r}){let e=setTimeout(()=>{r({type:"LONG_PRESS.OPEN"});},700);return ()=>clearTimeout(e)},trackFocusVisible({scope:r}){return $b({root:r.getRootNode?.()})},trackPositioning({context:r,prop:e,scope:t,refs:n}){if(sb(t)||Ld(t).length>0)return;let o={...e("positioning"),...n.get("positioningOverride")};return r.set("currentPlacement",o.placement),_l(()=>Ho(t,r.get("triggerValue")),()=>Td(t),{...o,defer:true,onComplete(l){r.set("currentPlacement",l.placement);}})},trackInteractOutside({refs:r,scope:e,prop:t,context:n,send:i}){let o=()=>Dt(e),s=true,a=l=>Ld(e).some(c=>rt(c,l));return $l(o,{type:"menu",defer:true,exclude:[kd(e),...Ed(e)].filter(Boolean),onInteractOutside:t("onInteractOutside"),onRequestDismiss:t("onRequestDismiss"),onFocusOutside(l){t("onFocusOutside")?.(l);let c=De(l.detail.originalEvent);if(a(c)){l.preventDefault();return}if(Id(c,r.get("children"))){l.preventDefault();return}},onEscapeKeyDown(l){t("onEscapeKeyDown")?.(l),n.get("isSubmenu")&&l.preventDefault(),Rd({parent:r.get("parent")});},onPointerDownOutside(l){t("onPointerDownOutside")?.(l);let c=De(l.detail.originalEvent);if(a(c)&&l.detail.contextmenu){l.preventDefault();return}s=!l.detail.focusable;},onDismiss(){i({type:"CLOSE",src:"interact-outside",restoreFocus:s});}})},trackPointerMove({context:r,scope:e,send:t,refs:n}){let i=n.get("parent");if(!i)return;$n(i,true);let o=e.getDoc();return je(o,"pointermove",s=>{gb(r.get("intentPolygon"),{x:s.clientX,y:s.clientY})||(t({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),$n(i,false));})},scrollToHighlightedItem({scope:r,computed:e}){let t=()=>{if(Hb()==="pointer")return;let o=r.getById(e("highlightedId")),s=Dt(r);Kf(o,{rootEl:s,block:"nearest"});};return Ie(()=>{zb("virtual"),t();}),Gf(()=>Dt(r),{attributes:["aria-activedescendant"],callback:t})}},actions:{setAnchorPoint({context:r,event:e}){r.set("anchorPoint",t=>ti(t,e.point)?t:e.point);},setSubmenuPlacement({context:r,computed:e,refs:t}){if(!r.get("isSubmenu"))return;let n=e("isRtl")?"left-start":"right-start";t.set("positioningOverride",{placement:n,gutter:0});},reposition({context:r,scope:e,prop:t,event:n,refs:i}){let o=()=>Td(e),s=n.point??r.get("anchorPoint"),a=s?()=>({width:0,height:0,...s}):void 0,l={...t("positioning"),...i.get("positioningOverride")},c=n.value??r.get("triggerValue");_l(()=>Ho(e,c),o,{...l,defer:true,getAnchorRect:a,...n.options??{},listeners:false,onComplete(d){r.set("currentPlacement",d.placement);}});},setOptionState({event:r}){if(!r.option)return;let{checked:e,onCheckedChange:t,type:n}=r.option;n==="radio"?t?.(true):n==="checkbox"&&t?.(!e);},clickHighlightedItem({scope:r,computed:e,prop:t,context:n}){let i=r.getById(e("highlightedId"));if(!i||i.dataset.disabled)return;let o=n.get("highlightedValue");xf(i)?t("navigate")?.({value:o,node:i,href:i.href}):queueMicrotask(()=>i.click());},setIntentPolygon({context:r,scope:e,event:t}){let n=Dt(e),i=r.get("currentPlacement");if(!n||!i)return;let o=n.getBoundingClientRect(),s=fb(o,i);if(!s)return;let l=Bo(i)==="right"?-5:5;r.set("intentPolygon",[{...t.point,x:t.point.x+l},...s]);},clearIntentPolygon({context:r}){r.set("intentPolygon",null);},clearAnchorPoint({context:r}){r.set("anchorPoint",null);},unlockParentOnOpen({refs:r,context:e,scope:t}){let n=r.get("parent");if(e.get("isSubmenu")){let i=en(t);n?.send({type:"HIGHLIGHTED.SUGGEST",value:i});}$n(n,false);},unlockParentOnClose({refs:r,context:e}){yb(r.get("parent"),e.get("isSubmenu"));},setHighlightedItem({context:r,event:e}){let t=e.value||zn(e.target);r.set("highlightedValue",t);},clearHighlightedItem({context:r}){r.set("highlightedValue",null);},focusMenu({scope:r}){Ie(()=>{let e=Dt(r);gl({root:e,enabled:!rt(e,r.getActiveElement()),filter(n){return !n.role?.startsWith("menuitem")}})?.focus({preventScroll:true});});},highlightFirstItem({context:r,scope:e}){(Dt(e)?queueMicrotask:Ie)(()=>{let n=ab(e);n&&r.set("highlightedValue",zn(n));});},highlightLastItem({context:r,scope:e}){(Dt(e)?queueMicrotask:Ie)(()=>{let n=lb(e);n&&r.set("highlightedValue",zn(n));});},highlightNextItem({context:r,scope:e,event:t,prop:n}){let i=cb(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",zn(i));},highlightPrevItem({context:r,scope:e,event:t,prop:n}){let i=ub(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",zn(i));},invokeOnSelect({context:r,prop:e,scope:t}){let n=r.get("highlightedValue");if(n==null)return;let i=ob(t,n);hb(i,n),e("onSelect")?.({value:n});},focusTrigger({scope:r,context:e,event:t}){e.get("isSubmenu")||e.get("anchorPoint")||t.restoreFocus===false||queueMicrotask(()=>{Ho(r,e.get("triggerValue"))?.focus({preventScroll:true});});},highlightMatchedItem({scope:r,context:e,event:t,refs:n}){let i=db(r,{key:t.key,value:e.get("highlightedValue"),typeaheadState:n.get("typeaheadState")});i&&e.set("highlightedValue",zn(i));},setParentMenu({refs:r,event:e,context:t}){r.set("parent",e.value),t.set("isSubmenu",true);},setChildMenu({refs:r,event:e}){let t=r.get("children");t[e.id]=e.value,r.set("children",t);},closeSiblingMenus({refs:r,event:e,scope:t}){let n=e.target;if(!Pd(n))return;let i=n?.getAttribute("data-uid"),o=r.get("children");for(let s in o){if(s===i)continue;let a=o[s],l=a.context.get("intentPolygon");l&&e.point&&zl(l,e.point)||(Dt(t)?.focus({preventScroll:true}),a.send({type:"CLOSE"}));}},closeRootMenu({refs:r}){Rd({parent:r.get("parent")});},openSubmenu({refs:r,scope:e,computed:t}){let i=e.getById(t("highlightedId"))?.getAttribute("data-uid"),o=r.get("children");(i?o[i]:null)?.send({type:"OPEN_AUTOFOCUS"});},focusParentMenu({refs:r}){r.get("parent")?.send({type:"FOCUS_MENU"});},setLastHighlightedItem({context:r,event:e}){r.set("lastHighlightedValue",zn(e.target));},suggestHighlightedItem({context:r,event:e}){let t=e.value;if(t){if(r.get("highlightedValue")!=null){r.set("lastHighlightedValue",t);return}r.set("highlightedValue",t);}},restoreHighlightedItem({context:r}){let e=r.get("lastHighlightedValue");r.set("lastHighlightedValue",null),e&&r.set("highlightedValue",e);},restoreParentHighlightedItem({refs:r}){r.get("parent")?.send({type:"HIGHLIGHTED.RESTORE"});},invokeOnOpen({prop:r}){r("onOpenChange")?.({open:true});},invokeOnClose({prop:r}){r("onOpenChange")?.({open:false});},releaseParentRoutingLock({refs:r,context:e}){e.get("isSubmenu")&&wb(r.get("parent"));},toggleVisibility({prop:r,event:e,send:t}){t({type:r("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e});},setTriggerValue({context:r,event:e}){e.value!==void 0&&r.set("triggerValue",e.value);}}}});function Wb(r){return {machine:_d,props:{id:r.id??El("vela-menu"),ids:r.triggerId?{trigger:r.triggerId}:void 0,positioning:{placement:r.placement??"bottom-start",...r.getAnchorRect?{getAnchorRect:()=>r.getAnchorRect()}:{}},onSelect:e=>r.onSelect?.(e.value),onOpenChange:e=>r.onOpenChange?.(e.open)},connect:e=>Dd(e,pi)}}var Gb="vela-ui-menu",Ub=`
|
|
4
25
|
.vela-menu {
|
|
5
26
|
/* The list is a <ul>: without this, block rows (the separator) paint a ::marker dot. */
|
|
6
27
|
list-style: none;
|
|
7
28
|
margin: 0;
|
|
8
|
-
background: var(--vela-surface
|
|
29
|
+
background: var(--vela-surface);
|
|
9
30
|
color: var(--vela-fg);
|
|
10
31
|
border: 1px solid var(--vela-border-strong);
|
|
11
32
|
border-radius: 6px;
|
|
@@ -117,28 +138,7 @@ var Vela=(function(exports){'use strict';function Vt(r,e,t=1e3){return r===true?
|
|
|
117
138
|
color: var(--vela-fg-faint);
|
|
118
139
|
}
|
|
119
140
|
.vela-menu-item[data-state='open'] { background: var(--vela-hover); }
|
|
120
|
-
`;var
|
|
121
|
-
`),Uk=`
|
|
122
|
-
.vela-ui, .vela-ui-layer {
|
|
123
|
-
${Gk}
|
|
124
|
-
font-family: var(--vela-font, -apple-system, system-ui, sans-serif);
|
|
125
|
-
box-sizing: border-box;
|
|
126
|
-
/* Chrome text (titles, buttons, menus, readouts) is UI, not copy \u2014 never selectable. */
|
|
127
|
-
user-select: none;
|
|
128
|
-
-webkit-user-select: none;
|
|
129
|
-
}
|
|
130
|
-
.vela-ui *, .vela-ui-layer * { box-sizing: border-box; }
|
|
131
|
-
/* Text ENTRY is the one exception: selection is part of editing. */
|
|
132
|
-
.vela-ui :is(input, textarea), .vela-ui-layer :is(input, textarea) { user-select: text; -webkit-user-select: text; }
|
|
133
|
-
/* iOS Safari zooms the page when a focused field is under 16px, and often
|
|
134
|
-
keeps that zoom after the field blurs or a dialog closes. The shell's
|
|
135
|
-
mobile size class is the honest gate \u2014 not a media query \u2014 so an embedded
|
|
136
|
-
chart on a wide desktop still gets the rule when it is in the phone layout.
|
|
137
|
-
Scoped to the kit root so a host page's own [data-layout] is never touched. */
|
|
138
|
-
.vela-ui[data-layout='mobile'] :is(input, textarea, select) { font-size: 16px; }
|
|
139
|
-
.vela-icon { display: inline-flex; align-items: center; flex: none; }
|
|
140
|
-
.vela-icon svg { display: block; }
|
|
141
|
-
`;function Yk(r,e){let t=ol(e);for(let n in t)r.style.setProperty(n,t[n]);}function Hb(r,e){he(Wk,Uk,r.getRootNode()),r.classList.add("vela-ui"),e&&Yk(r,e);}function zb(r,e){return {left:r.left+e,top:r.top+e,right:r.right-e,bottom:r.bottom-e,width:r.width-e*2,height:r.height-e*2}}function $b(r,e,t){return {left:t,top:t,right:r-t,bottom:e-t,width:r-t*2,height:e-t*2}}function Wb(r,e){let t=Math.max(r.left,e.left),n=Math.max(r.top,e.top),i=Math.min(r.right,e.right),o=Math.min(r.bottom,e.bottom);return {left:t,top:n,right:i,bottom:o,width:i-t,height:o-n}}function Gb(r){let e=r.align==="end"?r.trigger.right-r.pop.width:r.align==="center"?r.trigger.left+r.trigger.width/2-r.pop.width/2:r.trigger.left,t=r.trigger.bottom+r.gap,n=r.trigger.top-r.pop.height-r.gap,i=t+r.pop.height<=r.clamp.bottom,o=n>=r.clamp.top,s=t;return !i&&(o||r.trigger.top-r.clamp.top>r.clamp.bottom-r.trigger.bottom)&&(s=Math.max(r.clamp.top,n)),e+r.pop.width>r.clamp.right&&(e=r.clamp.right-r.pop.width),e<r.clamp.left&&(e=r.clamp.left),s+r.pop.height>r.clamp.bottom&&(s=r.clamp.bottom-r.pop.height),s<r.clamp.top&&(s=r.clamp.top),{left:Math.round(e-r.originX),top:Math.round(s-r.originY)}}function Ub(r={}){return {gap:r.gap??4,align:r.align??"start",matchWidth:r.matchWidth??false,position:r.position??"fixed",boundaryInset:r.boundaryInset??0,viewportInset:r.viewportInset??6,onClose:r.onClose}}var Yb="vela-ui-popover",Kb=`
|
|
141
|
+
`;var Bd=class r{constructor(e,t){this.items=[];this.subs=new Map;this.pinnedAnchor=null;this.doc=e,this.host=t.host,this.onSelect=t.onSelect,this.onFavorite=t.onFavorite,this.checkmarks=t.checkmarks===true,this.positioner=e.createElement("div"),this.positioner.className="vela-ui-layer",this.list=e.createElement("ul"),this.list.className="vela-menu",t.minWidth&&(this.list.style.minWidth=t.minWidth),this.positioner.appendChild(this.list),this.host.appendChild(this.positioner);let n=t.trigger;this.ctrl=Wb({items:[],id:t.id,placement:t.placement,onSelect:i=>this.onSelect(i),getAnchorRect:()=>this.pinnedAnchor,onOpenChange:i=>{if(i&&n){let o=n.getBoundingClientRect();this.pinnedAnchor={x:o.x,y:o.y,width:o.width,height:o.height};}else this.pinnedAnchor=null;t.onOpenChange?.(i);},triggerId:t.triggerId}),this.mid=String(this.ctrl.props.id),t.triggerId&&n&&(n.id=t.triggerId),this.handle=kl(this.ctrl.machine,this.ctrl.props,i=>{let o=this.ctrl.connect(i);n&&it(n,o.getTriggerProps(),this.mid),it(this.positioner,o.getPositionerProps(),this.mid),it(this.list,o.getContentProps(),this.mid),this.project(o);});}get api(){return this.ctrl.connect(this.handle.service)}setItems(e){this.items=e;for(let n of this.subs.values())n.destroy();this.subs.clear(),this.build();let t=this.api;for(let n of this.subs.values())t.setChild(n.handle.service),n.api.setParent(this.handle.service);this.handle.flush(),this.subs.size>0&&queueMicrotask(()=>this.handle.flush());}destroy(){for(let e of this.subs.values())e.destroy();this.subs.clear(),this.handle.stop(),this.positioner.remove();}byId(e){return this.items.find(t=>t.id===e)}project(e){for(let t of this.list.children){let n=t.dataset.veiId;if(!n)continue;let i=this.subs.get(n);if(i){it(t,e.getTriggerItemProps(i.api),this.mid);continue}let o=this.byId(n);it(t,e.getItemProps({value:n,disabled:o?.disabled,closeOnSelect:o?.toggle?false:void 0}),this.mid);}}build(){let e=this.doc;this.list.replaceChildren();let t=this.checkmarks&&this.items.some(n=>!(n.submenu&&n.submenu.length>0)&&!n.toggle&&n.checked!==void 0);for(let n of this.items){if(n.separatorBefore){let a=e.createElement("li");a.className="vela-menu-sep",a.setAttribute("role","separator"),this.list.appendChild(a);}let i=n.submenu!==void 0&&n.submenu.length>0,o=e.createElement("li");if(o.className="vela-menu-item",o.dataset.veiId=n.id,n.toggle&&(o.dataset.toggle="1"),t){let a=e.createElement("span");a.className="vela-menu-mark",!i&&!n.toggle&&n.checked&&(a.appendChild(qe("check",e)),o.dataset.checkmark="1"),o.appendChild(a);}else !i&&!n.toggle&&n.checked&&(o.dataset.checked="1");n.icon&&o.appendChild(qe(n.icon,e));let s=e.createElement("span");if(s.className="vela-menu-label",s.textContent=n.label,o.appendChild(s),n.hint){let a=e.createElement("span");a.className="vela-menu-hint",a.textContent=n.hint,o.appendChild(a);}if(n.favorite!==void 0&&this.onFavorite){let a=n.favorite,l=qe(a?"star-filled":"star",e);l.classList.add("vela-menu-star"),a&&l.classList.add("vela-fav"),l.removeAttribute("aria-hidden"),l.setAttribute("role","button"),l.setAttribute("aria-label",a?"Remove from favorites":"Add to favorites"),l.setAttribute("aria-pressed",a?"true":"false");for(let c of ["pointerdown","pointerup","mousedown","mouseup"])l.addEventListener(c,u=>u.stopPropagation());l.addEventListener("click",c=>{c.stopPropagation(),c.preventDefault(),this.onFavorite?.(n.id,!a);}),o.appendChild(l);}if(n.toggle){let a=e.createElement("span");a.className="vela-menu-switch"+(n.checked?" on":""),a.setAttribute("aria-hidden","true"),o.appendChild(a);}if(i){o.dataset.branch="1";let a=qe("chevron-right",e);a.classList.add("vela-menu-arrow"),o.appendChild(a);let l=new r(e,{host:this.host,placement:"right-start",onSelect:this.onSelect,onFavorite:this.onFavorite,checkmarks:this.checkmarks,id:`${this.mid}--${n.id}`});l.setItems(n.submenu??[]),this.subs.set(n.id,l);}this.list.appendChild(o);}}},xi=class{constructor(e){let t=e.trigger??e.host??document.body,n=t.ownerDocument;he(Gb,Ub,n);let i=Ll(e.host??t,n.body);this.root=new Bd(n,{host:i,placement:e.placement,onSelect:o=>e.onSelect?.(o),onOpenChange:e.onOpenChange,trigger:e.trigger,triggerId:e.triggerId,id:e.id,minWidth:e.minWidth,onFavorite:e.onFavorite,checkmarks:e.checkmarks}),this.root.setItems(e.items);}get api(){return this.root.api}open(){this.api.setOpen(true);}openAt(e,t){let n=this.api;n.setOpen(true),n.reposition({getAnchorRect:()=>({x:e,y:t,width:0,height:0})});}close(){this.api.setOpen(false);}setItems(e){this.root.setItems(e);}destroy(){this.root.destroy();}};function Yb(r,e){return {left:r.left+e,top:r.top+e,right:r.right-e,bottom:r.bottom-e,width:r.width-e*2,height:r.height-e*2}}function Kb(r,e,t){return {left:t,top:t,right:r-t,bottom:e-t,width:r-t*2,height:e-t*2}}function Xb(r,e){let t=Math.max(r.left,e.left),n=Math.max(r.top,e.top),i=Math.min(r.right,e.right),o=Math.min(r.bottom,e.bottom);return {left:t,top:n,right:i,bottom:o,width:i-t,height:o-n}}function jb(r){let e=r.align==="end"?r.trigger.right-r.pop.width:r.align==="center"?r.trigger.left+r.trigger.width/2-r.pop.width/2:r.trigger.left,t=r.trigger.bottom+r.gap,n=r.trigger.top-r.pop.height-r.gap,i=t+r.pop.height<=r.clamp.bottom,o=n>=r.clamp.top,s=t;return !i&&(o||r.trigger.top-r.clamp.top>r.clamp.bottom-r.trigger.bottom)&&(s=Math.max(r.clamp.top,n)),e+r.pop.width>r.clamp.right&&(e=r.clamp.right-r.pop.width),e<r.clamp.left&&(e=r.clamp.left),s+r.pop.height>r.clamp.bottom&&(s=r.clamp.bottom-r.pop.height),s<r.clamp.top&&(s=r.clamp.top),{left:Math.round(e-r.originX),top:Math.round(s-r.originY)}}function qb(r={}){return {gap:r.gap??4,align:r.align??"start",matchWidth:r.matchWidth??false,position:r.position??"fixed",boundaryInset:r.boundaryInset??0,viewportInset:r.viewportInset??6,onClose:r.onClose}}var Zb="vela-ui-popover",Jb=`
|
|
142
142
|
.vela-popover {
|
|
143
143
|
position: fixed;
|
|
144
144
|
z-index: var(--vela-z-popover);
|
|
@@ -149,7 +149,7 @@ ${Gk}
|
|
|
149
149
|
}
|
|
150
150
|
.vela-popover[data-position='absolute'] { position: absolute; }
|
|
151
151
|
.vela-popover[hidden] { display: none !important; }
|
|
152
|
-
`;var
|
|
152
|
+
`;var vn=null;function Te(){vn?.hide();}function tn(){return vn!==null}function yn(){return vn?.trigger??null}var ev="__velaPopoverDismiss";function Qk(r){r[ev]=true;}function Ir(r){return r[ev]===true}function Qb(r){return {left:r.left,top:r.top,right:r.right,bottom:r.bottom,width:r.width,height:r.height}}var $e=class{constructor(e){this.onOutside=null;this.onKey=null;this.onReflow=null;this.shown=false;this.leaveTimer=null;let t=e.trigger.ownerDocument;he(Zb,Jb,t),this.trigger=e.trigger,this.host=e.host??Ll(e.trigger,t.body),this.inheritsTokens=!e.host&&this.host!==t.body,this.ctrl=qb(e),this.boundary=e.boundary??"viewport",this.theme=e.theme,this.fadeMs=Math.max(0,e.fadeMs??0),this.el=t.createElement("div"),this.el.className="vela-popover vela-ui-layer"+(e.className?` ${e.className}`:""),this.el.dataset.position=this.ctrl.position,e.zIndex!==void 0&&(this.el.style.zIndex=String(e.zIndex)),this.el.addEventListener("pointerdown",n=>n.stopPropagation()),e.content instanceof Node?this.el.appendChild(e.content):typeof e.content=="function"&&e.content(this.el);}get open(){return this.shown}get position(){return this.ctrl.position}get align(){return this.ctrl.align}show(){if(this.shown){this.place();return}vn&&vn!==this&&vn.hide(),this.leaveTimer!==null&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),ag(this.el,this.inheritsTokens?void 0:this.theme),this.fadeMs>0&&(this.el.style.transition=`opacity ${this.fadeMs}ms ease`,this.el.style.opacity="0",this.el.style.pointerEvents=""),this.host.appendChild(this.el),this.shown=true,vn=this,this.place(),this.fadeMs>0&&(this.el.style.opacity="1");let e=i=>{let o=i.target;this.el.contains(o)||this.trigger.contains(o)||(Qk(i),this.hide());},t=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),this.hide());},n=()=>this.place();setTimeout(()=>document.addEventListener("pointerdown",e,true),0),document.addEventListener("keydown",t,true),window.addEventListener("resize",n,true),document.addEventListener("scroll",n,true),this.onOutside=e,this.onKey=t,this.onReflow=n;}hide(){this.shown&&(this.onOutside&&document.removeEventListener("pointerdown",this.onOutside,true),this.onKey&&document.removeEventListener("keydown",this.onKey,true),this.onReflow&&(window.removeEventListener("resize",this.onReflow,true),document.removeEventListener("scroll",this.onReflow,true)),this.onOutside=null,this.onKey=null,this.onReflow=null,this.fadeMs>0?(this.el.style.opacity="0",this.el.style.pointerEvents="none",this.leaveTimer=setTimeout(()=>{this.leaveTimer=null,this.el.remove();},this.fadeMs)):this.el.remove(),this.shown=false,vn===this&&(vn=null),this.ctrl.onClose?.());}toggle(){this.shown?this.hide():this.show();}destroy(){this.hide();}reposition(){this.shown&&this.place();}clampRect(){let e=Kb(window.innerWidth,window.innerHeight,this.ctrl.viewportInset),t=this.readBoundary();if(!t)return e;let n=Yb(t,this.ctrl.boundaryInset);return Xb(e,n)}readBoundary(){let e=this.boundary;if(e==="viewport")return null;let t=typeof e=="function"?e():e.getBoundingClientRect();return t?Qb(t):null}place(){let e=this.trigger.getBoundingClientRect();this.ctrl.matchWidth&&(this.el.style.minWidth=`${Math.round(Math.max(this.el.offsetWidth,e.width))}px`);let t=this.ctrl.position==="absolute"?this.host.getBoundingClientRect():{left:0,top:0},n=jb({trigger:Qb(e),pop:{width:this.el.offsetWidth,height:this.el.offsetHeight},gap:this.ctrl.gap,align:this.ctrl.align,clamp:this.clampRect(),originX:t.left,originY:t.top});this.el.style.left=`${n.left}px`,this.el.style.top=`${n.top}px`;}};function tv(r){return r.close!==false}function nv(r){let e=[];for(let t of r){if(t.type==="text"){e.push({type:"text",text:t.text});continue}let n=e[e.length-1];n&&n.type==="buttons"?n.buttons.push(t):e.push({type:"buttons",buttons:[t]});}return e}var Uo="vela-ui-callout-bubble",Yo=`
|
|
153
153
|
.vela-callout {
|
|
154
154
|
display: inline-grid;
|
|
155
155
|
place-items: center;
|
|
@@ -197,7 +197,7 @@ ${Gk}
|
|
|
197
197
|
.vela-callout-btn:hover { background: var(--vela-hover); color: var(--vela-fg-bright); border-color: var(--vela-fg-muted); }
|
|
198
198
|
.vela-callout-btn-primary { border-color: var(--vela-selected-bg); background: var(--vela-selected-bg); color: var(--vela-selected-fg); }
|
|
199
199
|
.vela-callout-btn-primary:hover { background: var(--vela-selected-bg); color: var(--vela-selected-fg); opacity: 0.85; border-color: var(--vela-selected-bg); }
|
|
200
|
-
`;var
|
|
200
|
+
`;var Ko=class{constructor(e){this.pop=null;this.spec={icon:e.icon,background:e.background,label:e.label},e.color!==void 0&&(this.spec.color=e.color),e.panel!==void 0&&(this.spec.panel=e.panel),this.size=e.size??16,this.host=e.host,this.theme=e.theme,this.boundary=e.boundary;let t=(e.host??document.body).ownerDocument;he(Uo,Yo,t),this.el=t.createElement("span"),this.el.className="vela-callout",this.el.style.width=`${this.size}px`,this.el.style.height=`${this.size}px`,this.el.addEventListener("click",n=>{this.spec.panel&&(n.stopPropagation(),this.toggle());}),this.el.addEventListener("dblclick",n=>{this.spec.panel&&n.stopPropagation();}),this.el.addEventListener("keydown",n=>{!this.spec.panel||n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggle());}),this.dress();}set(e){this.spec={...this.spec,...e},"panel"in e&&this.pop?.hide(),this.dress();}get open(){return this.pop?.open??false}hidePanel(){this.pop?.hide();}destroy(){this.pop?.destroy(),this.pop=null,this.el.remove();}dress(){let e=this.spec.panel!==void 0;this.el.style.background=this.spec.background,this.el.style.color=this.spec.color??"",this.el.innerHTML=ye(this.spec.icon,this.size-4),this.el.setAttribute("aria-label",this.spec.label),e?(this.el.setAttribute("role","button"),this.el.tabIndex=0):(this.el.removeAttribute("role"),this.el.removeAttribute("tabindex"));}toggle(){if(this.pop?.open){this.pop.hide();return}let e=this.spec.panel;e&&(this.pop?.destroy(),this.pop=new $e({trigger:this.el,gap:6,content:t=>this.buildPanel(t,e),...this.host?{host:this.host}:{},...this.theme?{theme:this.theme()}:{},...this.boundary?{boundary:this.boundary}:{}}),this.pop.show());}buildPanel(e,t){let n=e.ownerDocument,i=n.createElement("div");if(i.className="vela-callout-panel",t.title){let o=n.createElement("div");o.className="vela-callout-title",o.textContent=t.title,i.appendChild(o);}for(let o of nv(t.items)){if(o.type==="text"){let a=n.createElement("div");a.className="vela-callout-text",a.textContent=o.text,i.appendChild(a);continue}let s=n.createElement("div");s.className="vela-callout-actions";for(let a of o.buttons){let l=n.createElement("button");l.type="button",l.className="vela-callout-btn"+(a.primary?" vela-callout-btn-primary":""),l.textContent=a.label,l.addEventListener("click",()=>{a.run(),tv(a)&&this.pop?.hide();}),s.appendChild(l);}i.appendChild(s);}e.appendChild(i);}};function Xo(r,e){return r?(Array.isArray(r)?r:[r]).every(n=>n.anyOf?n.anyOf.some(i=>i===e[n.key]):e[n.key]===n.equals):true}function rv(r,e){let t={};for(let n of r){let i=e[n.key];i!==void 0&&JSON.stringify(i)!==JSON.stringify(n.defval)&&(t[n.key]=i);}return Object.keys(t).length>0?t:void 0}function iv(r){let e=r.options,t=r.value??e[0]?.value??"",n=r.size??"md";return {options:e,get value(){return t},size:n,fill:r.fill??n!=="sm",disabled:r.disabled??false,setValue(i){t=i;},labelOf(i){return e.find(o=>o.value===i)?.label??i},pick(i){t=i;let o=e.find(s=>s.value===i)?.label??i;return r.onChange?.(i,o),{value:i,label:o}}}}var ov="vela-ui-select-3",sv=`
|
|
201
201
|
.vela-select { position: relative; display: inline-block; min-width: 0; }
|
|
202
202
|
.vela-select[data-fill] { width: 100%; }
|
|
203
203
|
/* Closed trigger matches NumberInput / TextField (100px). Long labels ellipsis;
|
|
@@ -292,7 +292,7 @@ ${Gk}
|
|
|
292
292
|
.vela-select-item:hover { background: var(--vela-hover); }
|
|
293
293
|
.vela-select-item[data-checked] { background: var(--vela-hover-strong); color: var(--vela-fg-bright); }
|
|
294
294
|
.vela-select-item[data-checked]:hover { background: var(--vela-hover-strong); }
|
|
295
|
-
`;function rv(r){he(ev,tv,r);}function nv(r,e){let t=r.clientHeight,n=r.scrollHeight;if(n<=t){e.style.height="0";return}let i=Math.max(20,t/n*t),o=r.scrollTop/(n-t)*(t-i);e.style.height=`${Math.round(i)}px`,e.style.transform=`translateY(${Math.round(o)}px`;}function iv(r,e,t,n){r.replaceChildren();let i=r.ownerDocument.createElement("div");i.className="vela-select-items";for(let o of e){let s=r.ownerDocument.createElement("button");s.type="button",s.className="vela-select-item",s.textContent=o.label,o.value===t&&(s.dataset.checked="1"),s.addEventListener("click",a=>{a.stopPropagation(),n(o.value,o.label);}),i.appendChild(s);}r.appendChild(i);}function ov(r){let e=r.querySelector(".vela-select-items");if(e){if(e.scrollHeight>240){r.classList.add("is-scroll");let t=r.ownerDocument.createElement("div");t.className="vela-select-rail";let n=r.ownerDocument.createElement("div");n.className="vela-select-thumb",t.appendChild(n),r.appendChild(t),e.addEventListener("scroll",()=>nv(e,n)),nv(e,n);}r.querySelector(".vela-select-item[data-checked]")?.scrollIntoView({block:"nearest"}),e.dispatchEvent(new Event("scroll"));}}function Wl(r,e,t,n,i={}){return vn()===r?(Te(),null):sv(r,e,t,n,i)}function sv(r,e,t,n,i={}){rv(r.ownerDocument),Te();let o=new $e({trigger:r,theme:i.theme,matchWidth:i.matchWidth??true,boundary:i.boundary,boundaryInset:i.boundaryInset,gap:i.gap??4,align:i.align??"start",host:i.host,position:i.position,zIndex:i.zIndex,className:"vela-select-list",onClose:i.onClose,content:s=>{i.size&&(s.dataset.size=i.size),iv(s,e,t,(a,l)=>{o.hide(),n(a,l);});}});return o.show(),ov(o.el),o.reposition(),o}var Xo=class{constructor(e){this.list=null;let t=e.list?.host?.ownerDocument??document;rv(t),this.ctrl=Qb(e),this.listOpts={...e.list,theme:e.theme??e.list?.theme,size:this.ctrl.size};let n=t.createElement("div");n.className="vela-select",n.dataset.size=this.ctrl.size,this.ctrl.fill&&(n.dataset.fill="");let i=t.createElement("button");i.type="button",e.id&&(i.id=e.id),i.className="vela-select-trigger",this.ctrl.disabled&&(i.disabled=true);let o=t.createElement("span");o.className="vela-select-label",o.textContent=this.ctrl.labelOf(this.ctrl.value);let s=t.createElement("span");if(s.className="vela-select-chevron",s.appendChild(qe("chevron-down",t)),i.append(o,s),n.appendChild(i),this.ctrl.size==="sm"){let a=t.createElement("div");a.className="vela-select-sizer",a.setAttribute("aria-hidden","true");for(let l of this.ctrl.options){let c=t.createElement("span");c.textContent=l.label,a.appendChild(c);}n.appendChild(a);}i.addEventListener("pointerdown",a=>{a.preventDefault(),i.focus({preventScroll:true});}),i.addEventListener("click",a=>{a.stopPropagation(),this.toggle();}),this.el=n,this.trigger=i,this.labelEl=o;}get value(){return this.ctrl.value}setValue(e){this.ctrl.setValue(e),this.labelEl.textContent=this.ctrl.labelOf(e);}toggle(){this.list=Wl(this.trigger,this.ctrl.options,this.ctrl.value,(e,t)=>{this.ctrl.pick(e),this.labelEl.textContent=t,this.list=null;},{...this.listOpts,onClose:()=>{this.list=null,this.listOpts.onClose?.();}});}destroy(){this.list?.hide(),this.list=null;}};var Xk=pn("dialog").parts("trigger","backdrop","positioner","content","title","description","closeTrigger"),$n=Xk.build();var Vd=r=>r.ids?.positioner??`dialog:${r.id}:positioner`,_d=r=>r.ids?.backdrop??`dialog:${r.id}:backdrop`,Gl=r=>r.ids?.content??`dialog:${r.id}:content`,Ul=(r,e)=>{let t=r.ids?.trigger;return t!=null?nt(t)?t(e):t:e?`dialog:${r.id}:trigger:${e}`:`dialog:${r.id}:trigger`},Yl=r=>r.ids?.title??`dialog:${r.id}:title`,Kl=r=>r.ids?.description??`dialog:${r.id}:description`,Bd=r=>r.ids?.closeTrigger??`dialog:${r.id}:close`,jo=r=>r.getById(Gl(r)),av=r=>r.getById(Vd(r)),lv=r=>r.getById(_d(r)),Hd=r=>r.getById(Ul(r)),cv=r=>r.getById(Yl(r)),uv=r=>r.getById(Kl(r)),dv=r=>r.getById(Bd(r)),Xl=r=>di(r.getRootNode(),`[data-scope="dialog"][data-part="trigger"][data-ownedby="${r.id}"]`),zd=(r,e)=>e==null?Hd(r)??Xl(r)[0]:r.getById(Ul(r,e));function $d(r,e){let{state:t,send:n,context:i,prop:o,scope:s}=r,a=o("aria-label"),l=t.matches("open"),c=i.get("triggerValue");return {open:l,setOpen(u){t.matches("open")!==u&&n({type:u?"OPEN":"CLOSE"});},triggerValue:c,setTriggerValue(u){n({type:"TRIGGER_VALUE.SET",value:u});},getTriggerProps(u={}){let{value:d}=u,h=d==null?false:c===d;return e.button({...$n.trigger.attrs,dir:o("dir"),id:Ul(s,d),"data-ownedby":s.id,"data-value":d,"aria-haspopup":"dialog",type:"button","aria-expanded":d==null?l:l&&h,"data-state":l?"open":"closed","aria-controls":Gl(s),"data-current":mt(h),onClick(p){if(p.defaultPrevented)return;let m=l&&d!=null&&!h;n({type:m?"TRIGGER_VALUE.SET":"TOGGLE",value:d});}})},getBackdropProps(){return e.element({...$n.backdrop.attrs,dir:o("dir"),hidden:!l,id:_d(s),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...$n.positioner.attrs,dir:o("dir"),id:Vd(s),style:Nn({pointerEvents:!l||!o("modal")?"none":void 0})})},getContentProps(){let u=i.get("rendered");return e.element({...$n.content.attrs,dir:o("dir"),role:o("role"),hidden:!l,id:Gl(s),tabIndex:-1,"data-state":l?"open":"closed","aria-modal":o("modal"),"aria-label":a||void 0,"aria-labelledby":a||!u.title?void 0:Yl(s),"aria-describedby":u.description?Kl(s):void 0,style:Nn({pointerEvents:o("modal")?void 0:"auto"})})},getTitleProps(){return e.element({...$n.title.attrs,dir:o("dir"),id:Yl(s)})},getDescriptionProps(){return e.element({...$n.description.attrs,dir:o("dir"),id:Kl(s)})},getCloseTriggerProps(){return e.button({...$n.closeTrigger.attrs,dir:o("dir"),id:Bd(s),type:"button",onClick(u){u.defaultPrevented||(u.stopPropagation(),n({type:"CLOSE"}));}})}}}var xi=new WeakMap,jl=new WeakMap,ql={},Wd=0,pv=r=>r&&(r.host||pv(r.parentNode)),jk=(r,e)=>e.map(t=>{if(r.contains(t))return t;let n=pv(t);return n&&r.contains(n)?n:(console.error("[zag-js > ariaHidden] target",t,"in not contained inside",r,". Doing nothing"),null)}).filter(t=>!!t),qk=new Set(["script","output","status","next-route-announcer"]),Zk=r=>qk.has(r.localName)||r.role==="status"||r.hasAttribute("aria-live")?true:r.matches("[data-live-announcer]"),mv=(r,e)=>{let{parentNode:t,markerName:n,controlAttribute:i,explicitBooleanValue:o,followControlledElements:s=true}=e,a=jk(t,Array.isArray(r)?r:[r]);ql[n]||(ql[n]=new WeakMap);let l=ql[n],c=[],u=new Set,d=new Set(a),h=m=>{!m||u.has(m)||(u.add(m),h(m.parentNode));};a.forEach(m=>{h(m),s&&ce(m)&&Ju(m,f=>{h(f);});});let p=m=>{!m||d.has(m)||Array.prototype.forEach.call(m.children,f=>{if(u.has(f))p(f);else try{if(Zk(f))return;let g=f.getAttribute(i),b=o?g==="true":g!==null&&g!=="false",y=(xi.get(f)||0)+1,v=(l.get(f)||0)+1;xi.set(f,y),l.set(f,v),c.push(f),y===1&&b&&jl.set(f,!0),v===1&&f.setAttribute(n,""),b||f.setAttribute(i,o?"true":"");}catch(g){console.error("[zag-js > ariaHidden] cannot operate on ",f,g);}});};return p(t),u.clear(),Wd++,()=>{c.forEach(m=>{let f=xi.get(m)-1,g=l.get(m)-1;xi.set(m,f),l.set(m,g),f||(jl.has(m)||m.removeAttribute(i),jl.delete(m)),g||m.removeAttribute(n);}),Wd--,Wd||(xi=new WeakMap,xi=new WeakMap,jl=new WeakMap,ql={});}};var Jk=r=>(Array.isArray(r)?r[0]:r).ownerDocument.body,fv=(r,e=Jk(r),t="data-aria-hidden",n=true)=>{if(e)return mv(r,{parentNode:e,markerName:t,controlAttribute:"aria-hidden",explicitBooleanValue:true,followControlledElements:n})};var Qk=r=>{let e=requestAnimationFrame(()=>r());return ()=>cancelAnimationFrame(e)};function gv(r,e={}){let{defer:t=true}=e,n=t?Qk:o=>o(),i=[];return i.push(n(()=>{let s=(typeof r=="function"?r():r).filter(Boolean);s.length!==0&&i.push(fv(s));})),()=>{i.forEach(o=>o?.());}}var eE=Object.defineProperty,tE=(r,e,t)=>e in r?eE(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ve=(r,e,t)=>tE(r,typeof e!="symbol"?e+"":e,t);var bv={activateTrap(r,e){if(r.length>0){let n=r[r.length-1];n!==e&&n.pause();}let t=r.indexOf(e);t===-1||r.splice(t,1),r.push(e);},deactivateTrap(r,e){let t=r.indexOf(e);t!==-1&&r.splice(t,1),r.length>0&&r[r.length-1].unpause();}},nE=[],yv=class{constructor(r,e){ve(this,"trapStack"),ve(this,"config"),ve(this,"doc"),ve(this,"state",{containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:false,paused:false,delayInitialFocusTimer:void 0,recentNavEvent:void 0}),ve(this,"portalContainers",new Set),ve(this,"listenerCleanups",[]),ve(this,"handleFocus",n=>{let i=De(n),o=this.findContainerIndex(i,n)>=0;if(o||Eo(i))o&&(this.state.mostRecentlyFocusedNode=i);else {n.stopImmediatePropagation();let s,a=true;if(this.state.mostRecentlyFocusedNode)if(ui(this.state.mostRecentlyFocusedNode)>0){let l=this.findContainerIndex(this.state.mostRecentlyFocusedNode),{tabbableNodes:c}=this.state.containerGroups[l];if(c.length>0){let u=c.findIndex(d=>d===this.state.mostRecentlyFocusedNode);u>=0&&(this.config.isKeyForward(this.state.recentNavEvent)?u+1<c.length&&(s=c[u+1],a=false):u-1>=0&&(s=c[u-1],a=false));}}else this.state.containerGroups.some(l=>l.tabbableNodes.some(c=>ui(c)>0))||(a=false);else a=false;a&&(s=this.findNextNavNode({target:this.state.mostRecentlyFocusedNode,isBackward:this.config.isKeyBackward(this.state.recentNavEvent)})),s?this.tryFocus(s):this.tryFocus(this.state.mostRecentlyFocusedNode||this.getInitialFocusNode());}this.state.recentNavEvent=void 0;}),ve(this,"handlePointerDown",n=>{let i=De(n);if(!(this.findContainerIndex(i,n)>=0)){if(qo(this.config.clickOutsideDeactivates,n)){this.deactivate({returnFocus:this.config.returnFocusOnDeactivate});return}qo(this.config.allowOutsideClick,n)||n.preventDefault();}}),ve(this,"handleClick",n=>{let i=De(n);this.findContainerIndex(i,n)>=0||qo(this.config.clickOutsideDeactivates,n)||qo(this.config.allowOutsideClick,n)||(n.preventDefault(),n.stopImmediatePropagation());}),ve(this,"handleTabKey",n=>{if(this.config.isKeyForward(n)||this.config.isKeyBackward(n)){this.state.recentNavEvent=n;let i=this.config.isKeyBackward(n),o=this.findNextNavNode({event:n,isBackward:i});if(!o)return;Gd(n)&&n.preventDefault(),this.tryFocus(o);}}),ve(this,"handleEscapeKey",n=>{oE(n)&&qo(this.config.escapeDeactivates,n)!==false&&(n.preventDefault(),this.deactivate());}),ve(this,"_mutationObserver"),ve(this,"setupMutationObserver",()=>{let n=this.doc.defaultView||window;this._mutationObserver=new n.MutationObserver(i=>{i.some(a=>Array.from(a.removedNodes).some(c=>c===this.state.mostRecentlyFocusedNode))&&this.tryFocus(this.getInitialFocusNode()),i.some(a=>a.type==="attributes"&&(a.attributeName==="aria-controls"||a.attributeName==="aria-expanded")?true:a.type==="childList"&&a.addedNodes.length>0?Array.from(a.addedNodes).some(l=>{if(l.nodeType!==Node.ELEMENT_NODE)return false;let c=l;return xf(c)?true:c.id&&!this.state.containers.some(u=>u.contains(c))?Sf(c):false}):false)&&this.state.active&&!this.state.paused&&(this.updateTabbableNodes(),this.updatePortalContainers());});}),ve(this,"updateObservedNodes",()=>{this._mutationObserver?.disconnect(),this.state.active&&!this.state.paused&&(this.state.containers.map(n=>{this._mutationObserver?.observe(n,{subtree:true,childList:true,attributes:true,attributeFilter:["aria-controls","aria-expanded"]});}),this.portalContainers.forEach(n=>{this.observePortalContainer(n);}));}),ve(this,"getInitialFocusNode",()=>{let n=this.getNodeForOption("initialFocus",{hasFallback:true});if(n===false)return false;if(n===void 0||n&&!ft(n)){let i=Kt(this.doc);if(i&&this.findContainerIndex(i)>=0)n=i;else {let o=this.state.tabbableGroups[0];n=o&&o.firstTabbableNode||this.getNodeForOption("fallbackFocus");}}else n===null&&(n=this.getNodeForOption("fallbackFocus"));if(!n)throw new Error("Your focus-trap needs to have at least one focusable element");if(n.isConnected||(n=this.getNodeForOption("fallbackFocus")),!n||!n.isConnected)throw new Error("Your focus-trap needs to have at least one focusable element");return n}),ve(this,"tryFocus",n=>{if(n!==false&&n!==Kt(this.doc)){if(!n||!n.focus){this.tryFocus(this.getInitialFocusNode());return}n.focus({preventScroll:!!this.config.preventScroll}),this.state.mostRecentlyFocusedNode=n,sE(n)&&n.select();}}),ve(this,"deactivate",n=>{if(!this.state.active)return this;let i={onDeactivate:this.config.onDeactivate,onPostDeactivate:this.config.onPostDeactivate,checkCanReturnFocus:this.config.checkCanReturnFocus,...n};clearTimeout(this.state.delayInitialFocusTimer),this.state.delayInitialFocusTimer=void 0,this.removeListeners(),this.state.active=false,this.state.paused=false,this.updateObservedNodes(),bv.deactivateTrap(this.trapStack,this),this.portalContainers.clear();let o=this.getOption(i,"onDeactivate"),s=this.getOption(i,"onPostDeactivate"),a=this.getOption(i,"checkCanReturnFocus"),l=this.getOption(i,"returnFocus","returnFocusOnDeactivate");o?.();let c=()=>{vv(()=>{if(l){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);this.tryFocus(u);}s?.();});};if(l&&a){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);return a(u).then(c,c),this}return c(),this}),ve(this,"pause",n=>{if(this.state.paused||!this.state.active)return this;let i=this.getOption(n,"onPause"),o=this.getOption(n,"onPostPause");return this.state.paused=true,i?.(),this.removeListeners(),this.updateObservedNodes(),o?.(),this}),ve(this,"unpause",n=>{if(!this.state.paused||!this.state.active)return this;let i=this.getOption(n,"onUnpause"),o=this.getOption(n,"onPostUnpause");return this.state.paused=false,i?.(),this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),o?.(),this}),ve(this,"updateContainerElements",n=>(this.state.containers=Array.isArray(n)?n.filter(Boolean):[n].filter(Boolean),this.state.active&&this.updateTabbableNodes(),this.updateObservedNodes(),this)),ve(this,"getReturnFocusNode",n=>{let i=this.getNodeForOption("setReturnFocus",{params:[n]});return i||(i===false?false:n)}),ve(this,"getOption",(n,i,o)=>n&&n[i]!==void 0?n[i]:this.config[o||i]),ve(this,"getNodeForOption",(n,{hasFallback:i=false,params:o=[]}={})=>{let s=this.config[n];if(typeof s=="function"&&(s=s(...o)),s===true&&(s=void 0),!s){if(s===void 0||s===false)return s;throw new Error(`\`${n}\` was specified but was not a node, or did not return a node`)}let a=s;if(typeof s=="string"){try{a=this.doc.querySelector(s);}catch(l){throw new Error(`\`${n}\` appears to be an invalid selector; error="${l.message}"`)}if(!a&&!i)throw new Error(`\`${n}\` as selector refers to no known node`)}return a}),ve(this,"findNextNavNode",n=>{let{event:i,isBackward:o=false}=n,s=n.target||De(i);this.updateTabbableNodes();let a=null;if(this.state.tabbableGroups.length>0){let l=this.findContainerIndex(s,i),c=l>=0?this.state.containerGroups[l]:void 0;if(l<0)o?a=this.state.tabbableGroups[this.state.tabbableGroups.length-1].lastTabbableNode:a=this.state.tabbableGroups[0].firstTabbableNode;else if(o){let u=this.state.tabbableGroups.findIndex(({firstTabbableNode:d})=>s===d);if(u<0&&(c?.container===s||ft(s)&&!Vn(s)&&!c?.nextTabbableNode(s,false))&&(u=l),u>=0){let d=u===0?this.state.tabbableGroups.length-1:u-1,h=this.state.tabbableGroups[d];a=ui(s)>=0?h.lastTabbableNode:h.lastDomTabbableNode;}else Gd(i)||(a=c?.nextTabbableNode(s,false));}else {let u=this.state.tabbableGroups.findIndex(({lastTabbableNode:d})=>s===d);if(u<0&&(c?.container===s||ft(s)&&!Vn(s)&&!c?.nextTabbableNode(s))&&(u=l),u>=0){let d=u===this.state.tabbableGroups.length-1?0:u+1,h=this.state.tabbableGroups[d];a=ui(s)>=0?h.firstTabbableNode:h.firstDomTabbableNode;}else Gd(i)||(a=c?.nextTabbableNode(s));}}else a=this.getNodeForOption("fallbackFocus");return a}),this.trapStack=e.trapStack||nE;let t={returnFocusOnDeactivate:true,escapeDeactivates:true,delayInitialFocus:true,followControlledElements:true,isKeyForward:rE,isKeyBackward:iE,...e};this.doc=t.document||Me(Array.isArray(r)?r[0]:r),this.config=t,this.updateContainerElements(r),this.setupMutationObserver();}addPortalContainer(r){let e=r.parentElement;e&&!this.portalContainers.has(e)&&(this.portalContainers.add(e),this.state.active&&!this.state.paused&&this.observePortalContainer(e));}observePortalContainer(r){this._mutationObserver?.observe(r,{subtree:true,childList:true,attributes:true,attributeFilter:["aria-controls","aria-expanded"]});}updatePortalContainers(){this.config.followControlledElements&&this.state.containers.forEach(r=>{wf(r).forEach(t=>{this.addPortalContainer(t);});});}get active(){return this.state.active}get paused(){return this.state.paused}findContainerIndex(r,e){let t=typeof e?.composedPath=="function"?e.composedPath():void 0;return this.state.containerGroups.findIndex(({container:n,tabbableNodes:i})=>n.contains(r)||t?.includes(n)||i.find(o=>o===r)||this.isControlledElement(n,r))}isControlledElement(r,e){return this.config.followControlledElements?dl(r,e):false}updateTabbableNodes(){if(this.state.containerGroups=this.state.containers.map(r=>{let e=ci(r,{getShadowRoot:this.config.getShadowRoot}),t=od(r,{getShadowRoot:this.config.getShadowRoot}),n=e[0],i=e[e.length-1],o=n,s=i,a=false;for(let c=0;c<e.length;c++)if(ui(e[c])>0){a=true;break}function l(c,u=true){let d=e.indexOf(c);if(d>=0)return e[d+(u?1:-1)];let h=t.indexOf(c);if(!(h<0)){if(u){for(let p=h+1;p<t.length;p++)if(Vn(t[p]))return t[p]}else for(let p=h-1;p>=0;p--)if(Vn(t[p]))return t[p]}}return {container:r,tabbableNodes:e,focusableNodes:t,posTabIndexesFound:a,firstTabbableNode:n,lastTabbableNode:i,firstDomTabbableNode:o,lastDomTabbableNode:s,nextTabbableNode:l}}),this.state.tabbableGroups=this.state.containerGroups.filter(r=>r.tabbableNodes.length>0),this.state.tabbableGroups.length<=0&&!this.getNodeForOption("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(this.state.containerGroups.find(r=>r.posTabIndexesFound)&&this.state.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")}addListeners(){if(this.state.active)return bv.activateTrap(this.trapStack,this),this.state.delayInitialFocusTimer=this.config.delayInitialFocus?vv(()=>{this.tryFocus(this.getInitialFocusNode());}):this.tryFocus(this.getInitialFocusNode()),this.listenerCleanups.push(je(this.doc,"focusin",this.handleFocus,true),je(this.doc,"mousedown",this.handlePointerDown,{capture:true,passive:false}),je(this.doc,"touchstart",this.handlePointerDown,{capture:true,passive:false}),je(this.doc,"click",this.handleClick,{capture:true,passive:false}),je(this.doc,"keydown",this.handleTabKey,{capture:true,passive:false}),je(this.doc,"keydown",this.handleEscapeKey)),this}removeListeners(){if(this.state.active)return this.listenerCleanups.forEach(r=>r()),this.listenerCleanups=[],this}activate(r){if(this.state.active)return this;let e=this.getOption(r,"onActivate"),t=this.getOption(r,"onPostActivate"),n=this.getOption(r,"checkCanFocusTrap");n||this.updateTabbableNodes(),this.state.active=true,this.state.paused=false,this.state.nodeFocusedBeforeActivation=Kt(this.doc),e?.();let i=()=>{n&&this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),t?.();};return n?(n(this.state.containers.concat()).then(i,i),this):(i(),this)}},Ud=r=>r?.type==="keydown",Gd=r=>Ud(r)&&r?.key==="Tab",rE=r=>Ud(r)&&r.key==="Tab"&&!r?.shiftKey,iE=r=>Ud(r)&&r.key==="Tab"&&r?.shiftKey,qo=(r,...e)=>typeof r=="function"?r(...e):r,oE=r=>!r.isComposing&&r.key==="Escape",vv=r=>setTimeout(r,0),sE=r=>r.localName==="input"&&"select"in r&&typeof r.select=="function";function wv(r,e={}){let t,n=Ie(()=>{let o=(Array.isArray(r)?r:[r]).map(a=>typeof a=="function"?a():a).filter(a=>a!=null);if(o.length===0)return;let s=o[0];t=new yv(o,{escapeDeactivates:false,allowOutsideClick:true,preventScroll:true,returnFocusOnDeactivate:true,delayInitialFocus:false,fallbackFocus:s,...e,document:Me(s)});try{t.activate();}catch{}});return function(){t?.deactivate(),n();}}var xv="data-scroll-lock",Yd=new WeakMap;function aE(r){let e=r.getBoundingClientRect().left;return Math.round(e)+r.scrollLeft?"paddingLeft":"paddingRight"}function Sv(r){let t=si(r)?.scrollbarGutter;return t==="stable"||t?.startsWith("stable ")===true}function lE(r){let e=r.defaultView??window,{documentElement:t,body:n}=r,i=Sv(t)||Sv(n),o=e.innerWidth-t.clientWidth;n.setAttribute(xv,"");let s=()=>Gf(t,"--scrollbar-width",`${o}px`),a=aE(t),l=()=>{let d={overflow:"hidden"};return !i&&o>0&&(d[a]=`${o}px`),Lo(n,d)},c=()=>{let{scrollX:d,scrollY:h,visualViewport:p}=e,m=p?.offsetLeft??0,f=p?.offsetTop??0,g={position:"fixed",overflow:"hidden",top:`${-(h-Math.floor(f))}px`,left:`${-(d-Math.floor(m))}px`,right:"0"};!i&&o>0&&(g[a]=`${o}px`);let b=Lo(n,g);return ()=>{b?.(),e.scrollTo({left:d,top:h,behavior:"instant"});}},u=[s(),Tf()?c():l()];return ()=>{u.forEach(d=>d?.()),n.removeAttribute(xv);}}function Cv(r){let e=r??document,t=Yd.get(e);t||(t={count:0,cleanup:lE(e)},Yd.set(e,t)),t.count++;let n=t,i=false;return ()=>{i||(i=true,n.count--,n.count===0&&(n.cleanup(),Yd.delete(e)));}}var Kd=ll({props({props:r,scope:e}){let t=r.role==="alertdialog",n=t?()=>dv(e):void 0,i=typeof r.modal=="boolean"?r.modal:true;return {role:"dialog",modal:i,trapFocus:i,preventScroll:i,closeOnInteractOutside:i&&!t,closeOnEscape:true,restoreFocus:true,initialFocusEl:n,...r}},initialState({prop:r}){return r("open")||r("defaultOpen")?"open":"closed"},context({bindable:r,prop:e,scope:t}){return {rendered:r(()=>({defaultValue:{title:true,description:true}})),triggerValue:r(()=>({defaultValue:e("defaultTriggerValue")??null,value:e("triggerValue"),onChange(n){let i=e("onTriggerValueChange");if(!i)return;let o=zd(t,n);i({value:n,triggerElement:o});}}))}},watch({track:r,action:e,prop:t}){r([()=>t("open")],()=>{e(["toggleVisibility"]);});},states:{open:{entry:["checkRenderedElements","setInitialFocus"],effects:["trackDismissableElement","trapFocus","preventScroll","hideContentBelow"],on:{"CONTROLLED.CLOSE":{target:"closed"},CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"TRIGGER_VALUE.SET":{actions:["setTriggerValue"]}}},closed:{on:{"CONTROLLED.OPEN":{target:"open"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],"TRIGGER_VALUE.SET":{actions:["setTriggerValue"]}}}},implementations:{guards:{isOpenControlled:({prop:r})=>r("open")!=null},effects:{trackDismissableElement({scope:r,send:e,prop:t}){return Bl(()=>jo(r),{type:"dialog",defer:true,pointerBlocking:t("modal"),layerStyleTargets:[()=>lv(r),()=>av(r)],exclude:[Hd(r),...Xl(r)].filter(Boolean),onInteractOutside(i){t("onInteractOutside")?.(i),t("closeOnInteractOutside")||i.preventDefault();},persistentElements:t("persistentElements"),onFocusOutside:t("onFocusOutside"),onPointerDownOutside:t("onPointerDownOutside"),onRequestDismiss:t("onRequestDismiss"),onEscapeKeyDown(i){t("onEscapeKeyDown")?.(i),t("closeOnEscape")||i.preventDefault();},onDismiss(){e({type:"CLOSE",src:"interact-outside"});}})},preventScroll({scope:r,prop:e}){if(e("preventScroll"))return Cv(r.getDoc())},trapFocus({scope:r,prop:e,context:t}){return e("trapFocus")?wv(()=>jo(r),{preventScroll:true,returnFocusOnDeactivate:!!e("restoreFocus"),initialFocus:e("initialFocusEl"),setReturnFocus:i=>{let o=e("finalFocusEl")?.();if(o)return o;let s=t.get("triggerValue");if(s){let l=zd(r,s);if(l)return l}let a=Xl(r)[0];return a||i},getShadowRoot:true}):void 0},hideContentBelow({scope:r,prop:e}){return e("modal")?gv(()=>[jo(r)],{defer:true}):void 0}},actions:{setInitialFocus({prop:r,scope:e}){r("trapFocus")||Ie(()=>{ml({root:jo(e),getInitialEl:r("initialFocusEl")})?.focus({preventScroll:true});});},checkRenderedElements({context:r,scope:e}){Ie(()=>{r.set("rendered",{title:!!cv(e),description:!!uv(e)});});},invokeOnClose({prop:r}){r("onOpenChange")?.({open:false});},invokeOnOpen({prop:r}){r("onOpenChange")?.({open:true});},setTriggerValue({context:r,event:e}){e.value!==void 0&&r.set("triggerValue",e.value);},toggleVisibility({prop:r,send:e,event:t}){e({type:r("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:t});}}}});function Tv(r={}){return {machine:Kd,props:{id:Tl("vela-dialog"),modal:r.modal??true,closeOnEscape:r.closeOnEscape??true,closeOnInteractOutside:r.closeOnInteractOutside??false,initialFocusEl:r.initialFocusEl,onOpenChange:e=>r.onOpenChange?.(e.open)},connect:e=>$d(e,hi)}}var kv="vela-ui-dialog-5",Ev=`
|
|
295
|
+
`;function lv(r){he(ov,sv,r);}function av(r,e){let t=r.clientHeight,n=r.scrollHeight;if(n<=t){e.style.height="0";return}let i=Math.max(20,t/n*t),o=r.scrollTop/(n-t)*(t-i);e.style.height=`${Math.round(i)}px`,e.style.transform=`translateY(${Math.round(o)}px`;}function cv(r,e,t,n){r.replaceChildren();let i=r.ownerDocument.createElement("div");i.className="vela-select-items";for(let o of e){let s=r.ownerDocument.createElement("button");s.type="button",s.className="vela-select-item",s.textContent=o.label,o.value===t&&(s.dataset.checked="1"),s.addEventListener("click",a=>{a.stopPropagation(),n(o.value,o.label);}),i.appendChild(s);}r.appendChild(i);}function uv(r){let e=r.querySelector(".vela-select-items");if(e){if(e.scrollHeight>240){r.classList.add("is-scroll");let t=r.ownerDocument.createElement("div");t.className="vela-select-rail";let n=r.ownerDocument.createElement("div");n.className="vela-select-thumb",t.appendChild(n),r.appendChild(t),e.addEventListener("scroll",()=>av(e,n)),av(e,n);}r.querySelector(".vela-select-item[data-checked]")?.scrollIntoView({block:"nearest"}),e.dispatchEvent(new Event("scroll"));}}function Yl(r,e,t,n,i={}){return yn()===r?(Te(),null):dv(r,e,t,n,i)}function dv(r,e,t,n,i={}){lv(r.ownerDocument),Te();let o=new $e({trigger:r,theme:i.theme,matchWidth:i.matchWidth??true,boundary:i.boundary,boundaryInset:i.boundaryInset,gap:i.gap??4,align:i.align??"start",host:i.host,position:i.position,zIndex:i.zIndex,className:"vela-select-list",onClose:i.onClose,content:s=>{i.size&&(s.dataset.size=i.size),cv(s,e,t,(a,l)=>{o.hide(),n(a,l);});}});return o.show(),uv(o.el),o.reposition(),o}var jo=class{constructor(e){this.list=null;let t=e.list?.host?.ownerDocument??document;lv(t),this.ctrl=iv(e),this.listOpts={...e.list,theme:e.theme??e.list?.theme,size:this.ctrl.size};let n=t.createElement("div");n.className="vela-select",n.dataset.size=this.ctrl.size,this.ctrl.fill&&(n.dataset.fill="");let i=t.createElement("button");i.type="button",e.id&&(i.id=e.id),i.className="vela-select-trigger",this.ctrl.disabled&&(i.disabled=true);let o=t.createElement("span");o.className="vela-select-label",o.textContent=this.ctrl.labelOf(this.ctrl.value);let s=t.createElement("span");if(s.className="vela-select-chevron",s.appendChild(qe("chevron-down",t)),i.append(o,s),n.appendChild(i),this.ctrl.size==="sm"){let a=t.createElement("div");a.className="vela-select-sizer",a.setAttribute("aria-hidden","true");for(let l of this.ctrl.options){let c=t.createElement("span");c.textContent=l.label,a.appendChild(c);}n.appendChild(a);}i.addEventListener("pointerdown",a=>{a.preventDefault(),i.focus({preventScroll:true});}),i.addEventListener("click",a=>{a.stopPropagation(),this.toggle();}),this.el=n,this.trigger=i,this.labelEl=o;}get value(){return this.ctrl.value}setValue(e){this.ctrl.setValue(e),this.labelEl.textContent=this.ctrl.labelOf(e);}toggle(){this.list=Yl(this.trigger,this.ctrl.options,this.ctrl.value,(e,t)=>{this.ctrl.pick(e),this.labelEl.textContent=t,this.list=null;},{...this.listOpts,onClose:()=>{this.list=null,this.listOpts.onClose?.();}});}destroy(){this.list?.hide(),this.list=null;}};var eE=mn("dialog").parts("trigger","backdrop","positioner","content","title","description","closeTrigger"),Wn=eE.build();var Hd=r=>r.ids?.positioner??`dialog:${r.id}:positioner`,zd=r=>r.ids?.backdrop??`dialog:${r.id}:backdrop`,Kl=r=>r.ids?.content??`dialog:${r.id}:content`,Xl=(r,e)=>{let t=r.ids?.trigger;return t!=null?nt(t)?t(e):t:e?`dialog:${r.id}:trigger:${e}`:`dialog:${r.id}:trigger`},jl=r=>r.ids?.title??`dialog:${r.id}:title`,ql=r=>r.ids?.description??`dialog:${r.id}:description`,$d=r=>r.ids?.closeTrigger??`dialog:${r.id}:close`,qo=r=>r.getById(Kl(r)),hv=r=>r.getById(Hd(r)),pv=r=>r.getById(zd(r)),Wd=r=>r.getById(Xl(r)),mv=r=>r.getById(jl(r)),fv=r=>r.getById(ql(r)),gv=r=>r.getById($d(r)),Zl=r=>hi(r.getRootNode(),`[data-scope="dialog"][data-part="trigger"][data-ownedby="${r.id}"]`),Gd=(r,e)=>e==null?Wd(r)??Zl(r)[0]:r.getById(Xl(r,e));function Ud(r,e){let{state:t,send:n,context:i,prop:o,scope:s}=r,a=o("aria-label"),l=t.matches("open"),c=i.get("triggerValue");return {open:l,setOpen(u){t.matches("open")!==u&&n({type:u?"OPEN":"CLOSE"});},triggerValue:c,setTriggerValue(u){n({type:"TRIGGER_VALUE.SET",value:u});},getTriggerProps(u={}){let{value:d}=u,h=d==null?false:c===d;return e.button({...Wn.trigger.attrs,dir:o("dir"),id:Xl(s,d),"data-ownedby":s.id,"data-value":d,"aria-haspopup":"dialog",type:"button","aria-expanded":d==null?l:l&&h,"data-state":l?"open":"closed","aria-controls":Kl(s),"data-current":mt(h),onClick(p){if(p.defaultPrevented)return;let m=l&&d!=null&&!h;n({type:m?"TRIGGER_VALUE.SET":"TOGGLE",value:d});}})},getBackdropProps(){return e.element({...Wn.backdrop.attrs,dir:o("dir"),hidden:!l,id:zd(s),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...Wn.positioner.attrs,dir:o("dir"),id:Hd(s),style:Fn({pointerEvents:!l||!o("modal")?"none":void 0})})},getContentProps(){let u=i.get("rendered");return e.element({...Wn.content.attrs,dir:o("dir"),role:o("role"),hidden:!l,id:Kl(s),tabIndex:-1,"data-state":l?"open":"closed","aria-modal":o("modal"),"aria-label":a||void 0,"aria-labelledby":a||!u.title?void 0:jl(s),"aria-describedby":u.description?ql(s):void 0,style:Fn({pointerEvents:o("modal")?void 0:"auto"})})},getTitleProps(){return e.element({...Wn.title.attrs,dir:o("dir"),id:jl(s)})},getDescriptionProps(){return e.element({...Wn.description.attrs,dir:o("dir"),id:ql(s)})},getCloseTriggerProps(){return e.button({...Wn.closeTrigger.attrs,dir:o("dir"),id:$d(s),type:"button",onClick(u){u.defaultPrevented||(u.stopPropagation(),n({type:"CLOSE"}));}})}}}var Si=new WeakMap,Jl=new WeakMap,Ql={},Yd=0,vv=r=>r&&(r.host||vv(r.parentNode)),tE=(r,e)=>e.map(t=>{if(r.contains(t))return t;let n=vv(t);return n&&r.contains(n)?n:(console.error("[zag-js > ariaHidden] target",t,"in not contained inside",r,". Doing nothing"),null)}).filter(t=>!!t),nE=new Set(["script","output","status","next-route-announcer"]),rE=r=>nE.has(r.localName)||r.role==="status"||r.hasAttribute("aria-live")?true:r.matches("[data-live-announcer]"),yv=(r,e)=>{let{parentNode:t,markerName:n,controlAttribute:i,explicitBooleanValue:o,followControlledElements:s=true}=e,a=tE(t,Array.isArray(r)?r:[r]);Ql[n]||(Ql[n]=new WeakMap);let l=Ql[n],c=[],u=new Set,d=new Set(a),h=m=>{!m||u.has(m)||(u.add(m),h(m.parentNode));};a.forEach(m=>{h(m),s&&ce(m)&&td(m,f=>{h(f);});});let p=m=>{!m||d.has(m)||Array.prototype.forEach.call(m.children,f=>{if(u.has(f))p(f);else try{if(rE(f))return;let g=f.getAttribute(i),b=o?g==="true":g!==null&&g!=="false",y=(Si.get(f)||0)+1,v=(l.get(f)||0)+1;Si.set(f,y),l.set(f,v),c.push(f),y===1&&b&&Jl.set(f,!0),v===1&&f.setAttribute(n,""),b||f.setAttribute(i,o?"true":"");}catch(g){console.error("[zag-js > ariaHidden] cannot operate on ",f,g);}});};return p(t),u.clear(),Yd++,()=>{c.forEach(m=>{let f=Si.get(m)-1,g=l.get(m)-1;Si.set(m,f),l.set(m,g),f||(Jl.has(m)||m.removeAttribute(i),Jl.delete(m)),g||m.removeAttribute(n);}),Yd--,Yd||(Si=new WeakMap,Si=new WeakMap,Jl=new WeakMap,Ql={});}};var iE=r=>(Array.isArray(r)?r[0]:r).ownerDocument.body,wv=(r,e=iE(r),t="data-aria-hidden",n=true)=>{if(e)return yv(r,{parentNode:e,markerName:t,controlAttribute:"aria-hidden",explicitBooleanValue:true,followControlledElements:n})};var oE=r=>{let e=requestAnimationFrame(()=>r());return ()=>cancelAnimationFrame(e)};function xv(r,e={}){let{defer:t=true}=e,n=t?oE:o=>o(),i=[];return i.push(n(()=>{let s=(typeof r=="function"?r():r).filter(Boolean);s.length!==0&&i.push(wv(s));})),()=>{i.forEach(o=>o?.());}}var sE=Object.defineProperty,aE=(r,e,t)=>e in r?sE(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ve=(r,e,t)=>aE(r,typeof e!="symbol"?e+"":e,t);var Sv={activateTrap(r,e){if(r.length>0){let n=r[r.length-1];n!==e&&n.pause();}let t=r.indexOf(e);t===-1||r.splice(t,1),r.push(e);},deactivateTrap(r,e){let t=r.indexOf(e);t!==-1&&r.splice(t,1),r.length>0&&r[r.length-1].unpause();}},lE=[],Tv=class{constructor(r,e){ve(this,"trapStack"),ve(this,"config"),ve(this,"doc"),ve(this,"state",{containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:false,paused:false,delayInitialFocusTimer:void 0,recentNavEvent:void 0}),ve(this,"portalContainers",new Set),ve(this,"listenerCleanups",[]),ve(this,"handleFocus",n=>{let i=De(n),o=this.findContainerIndex(i,n)>=0;if(o||Lo(i))o&&(this.state.mostRecentlyFocusedNode=i);else {n.stopImmediatePropagation();let s,a=true;if(this.state.mostRecentlyFocusedNode)if(di(this.state.mostRecentlyFocusedNode)>0){let l=this.findContainerIndex(this.state.mostRecentlyFocusedNode),{tabbableNodes:c}=this.state.containerGroups[l];if(c.length>0){let u=c.findIndex(d=>d===this.state.mostRecentlyFocusedNode);u>=0&&(this.config.isKeyForward(this.state.recentNavEvent)?u+1<c.length&&(s=c[u+1],a=false):u-1>=0&&(s=c[u-1],a=false));}}else this.state.containerGroups.some(l=>l.tabbableNodes.some(c=>di(c)>0))||(a=false);else a=false;a&&(s=this.findNextNavNode({target:this.state.mostRecentlyFocusedNode,isBackward:this.config.isKeyBackward(this.state.recentNavEvent)})),s?this.tryFocus(s):this.tryFocus(this.state.mostRecentlyFocusedNode||this.getInitialFocusNode());}this.state.recentNavEvent=void 0;}),ve(this,"handlePointerDown",n=>{let i=De(n);if(!(this.findContainerIndex(i,n)>=0)){if(Zo(this.config.clickOutsideDeactivates,n)){this.deactivate({returnFocus:this.config.returnFocusOnDeactivate});return}Zo(this.config.allowOutsideClick,n)||n.preventDefault();}}),ve(this,"handleClick",n=>{let i=De(n);this.findContainerIndex(i,n)>=0||Zo(this.config.clickOutsideDeactivates,n)||Zo(this.config.allowOutsideClick,n)||(n.preventDefault(),n.stopImmediatePropagation());}),ve(this,"handleTabKey",n=>{if(this.config.isKeyForward(n)||this.config.isKeyBackward(n)){this.state.recentNavEvent=n;let i=this.config.isKeyBackward(n),o=this.findNextNavNode({event:n,isBackward:i});if(!o)return;Kd(n)&&n.preventDefault(),this.tryFocus(o);}}),ve(this,"handleEscapeKey",n=>{dE(n)&&Zo(this.config.escapeDeactivates,n)!==false&&(n.preventDefault(),this.deactivate());}),ve(this,"_mutationObserver"),ve(this,"setupMutationObserver",()=>{let n=this.doc.defaultView||window;this._mutationObserver=new n.MutationObserver(i=>{i.some(a=>Array.from(a.removedNodes).some(c=>c===this.state.mostRecentlyFocusedNode))&&this.tryFocus(this.getInitialFocusNode()),i.some(a=>a.type==="attributes"&&(a.attributeName==="aria-controls"||a.attributeName==="aria-expanded")?true:a.type==="childList"&&a.addedNodes.length>0?Array.from(a.addedNodes).some(l=>{if(l.nodeType!==Node.ELEMENT_NODE)return false;let c=l;return Ef(c)?true:c.id&&!this.state.containers.some(u=>u.contains(c))?Lf(c):false}):false)&&this.state.active&&!this.state.paused&&(this.updateTabbableNodes(),this.updatePortalContainers());});}),ve(this,"updateObservedNodes",()=>{this._mutationObserver?.disconnect(),this.state.active&&!this.state.paused&&(this.state.containers.map(n=>{this._mutationObserver?.observe(n,{subtree:true,childList:true,attributes:true,attributeFilter:["aria-controls","aria-expanded"]});}),this.portalContainers.forEach(n=>{this.observePortalContainer(n);}));}),ve(this,"getInitialFocusNode",()=>{let n=this.getNodeForOption("initialFocus",{hasFallback:true});if(n===false)return false;if(n===void 0||n&&!ft(n)){let i=Xt(this.doc);if(i&&this.findContainerIndex(i)>=0)n=i;else {let o=this.state.tabbableGroups[0];n=o&&o.firstTabbableNode||this.getNodeForOption("fallbackFocus");}}else n===null&&(n=this.getNodeForOption("fallbackFocus"));if(!n)throw new Error("Your focus-trap needs to have at least one focusable element");if(n.isConnected||(n=this.getNodeForOption("fallbackFocus")),!n||!n.isConnected)throw new Error("Your focus-trap needs to have at least one focusable element");return n}),ve(this,"tryFocus",n=>{if(n!==false&&n!==Xt(this.doc)){if(!n||!n.focus){this.tryFocus(this.getInitialFocusNode());return}n.focus({preventScroll:!!this.config.preventScroll}),this.state.mostRecentlyFocusedNode=n,hE(n)&&n.select();}}),ve(this,"deactivate",n=>{if(!this.state.active)return this;let i={onDeactivate:this.config.onDeactivate,onPostDeactivate:this.config.onPostDeactivate,checkCanReturnFocus:this.config.checkCanReturnFocus,...n};clearTimeout(this.state.delayInitialFocusTimer),this.state.delayInitialFocusTimer=void 0,this.removeListeners(),this.state.active=false,this.state.paused=false,this.updateObservedNodes(),Sv.deactivateTrap(this.trapStack,this),this.portalContainers.clear();let o=this.getOption(i,"onDeactivate"),s=this.getOption(i,"onPostDeactivate"),a=this.getOption(i,"checkCanReturnFocus"),l=this.getOption(i,"returnFocus","returnFocusOnDeactivate");o?.();let c=()=>{Cv(()=>{if(l){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);this.tryFocus(u);}s?.();});};if(l&&a){let u=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);return a(u).then(c,c),this}return c(),this}),ve(this,"pause",n=>{if(this.state.paused||!this.state.active)return this;let i=this.getOption(n,"onPause"),o=this.getOption(n,"onPostPause");return this.state.paused=true,i?.(),this.removeListeners(),this.updateObservedNodes(),o?.(),this}),ve(this,"unpause",n=>{if(!this.state.paused||!this.state.active)return this;let i=this.getOption(n,"onUnpause"),o=this.getOption(n,"onPostUnpause");return this.state.paused=false,i?.(),this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),o?.(),this}),ve(this,"updateContainerElements",n=>(this.state.containers=Array.isArray(n)?n.filter(Boolean):[n].filter(Boolean),this.state.active&&this.updateTabbableNodes(),this.updateObservedNodes(),this)),ve(this,"getReturnFocusNode",n=>{let i=this.getNodeForOption("setReturnFocus",{params:[n]});return i||(i===false?false:n)}),ve(this,"getOption",(n,i,o)=>n&&n[i]!==void 0?n[i]:this.config[o||i]),ve(this,"getNodeForOption",(n,{hasFallback:i=false,params:o=[]}={})=>{let s=this.config[n];if(typeof s=="function"&&(s=s(...o)),s===true&&(s=void 0),!s){if(s===void 0||s===false)return s;throw new Error(`\`${n}\` was specified but was not a node, or did not return a node`)}let a=s;if(typeof s=="string"){try{a=this.doc.querySelector(s);}catch(l){throw new Error(`\`${n}\` appears to be an invalid selector; error="${l.message}"`)}if(!a&&!i)throw new Error(`\`${n}\` as selector refers to no known node`)}return a}),ve(this,"findNextNavNode",n=>{let{event:i,isBackward:o=false}=n,s=n.target||De(i);this.updateTabbableNodes();let a=null;if(this.state.tabbableGroups.length>0){let l=this.findContainerIndex(s,i),c=l>=0?this.state.containerGroups[l]:void 0;if(l<0)o?a=this.state.tabbableGroups[this.state.tabbableGroups.length-1].lastTabbableNode:a=this.state.tabbableGroups[0].firstTabbableNode;else if(o){let u=this.state.tabbableGroups.findIndex(({firstTabbableNode:d})=>s===d);if(u<0&&(c?.container===s||ft(s)&&!_n(s)&&!c?.nextTabbableNode(s,false))&&(u=l),u>=0){let d=u===0?this.state.tabbableGroups.length-1:u-1,h=this.state.tabbableGroups[d];a=di(s)>=0?h.lastTabbableNode:h.lastDomTabbableNode;}else Kd(i)||(a=c?.nextTabbableNode(s,false));}else {let u=this.state.tabbableGroups.findIndex(({lastTabbableNode:d})=>s===d);if(u<0&&(c?.container===s||ft(s)&&!_n(s)&&!c?.nextTabbableNode(s))&&(u=l),u>=0){let d=u===this.state.tabbableGroups.length-1?0:u+1,h=this.state.tabbableGroups[d];a=di(s)>=0?h.firstTabbableNode:h.firstDomTabbableNode;}else Kd(i)||(a=c?.nextTabbableNode(s));}}else a=this.getNodeForOption("fallbackFocus");return a}),this.trapStack=e.trapStack||lE;let t={returnFocusOnDeactivate:true,escapeDeactivates:true,delayInitialFocus:true,followControlledElements:true,isKeyForward:cE,isKeyBackward:uE,...e};this.doc=t.document||Le(Array.isArray(r)?r[0]:r),this.config=t,this.updateContainerElements(r),this.setupMutationObserver();}addPortalContainer(r){let e=r.parentElement;e&&!this.portalContainers.has(e)&&(this.portalContainers.add(e),this.state.active&&!this.state.paused&&this.observePortalContainer(e));}observePortalContainer(r){this._mutationObserver?.observe(r,{subtree:true,childList:true,attributes:true,attributeFilter:["aria-controls","aria-expanded"]});}updatePortalContainers(){this.config.followControlledElements&&this.state.containers.forEach(r=>{kf(r).forEach(t=>{this.addPortalContainer(t);});});}get active(){return this.state.active}get paused(){return this.state.paused}findContainerIndex(r,e){let t=typeof e?.composedPath=="function"?e.composedPath():void 0;return this.state.containerGroups.findIndex(({container:n,tabbableNodes:i})=>n.contains(r)||t?.includes(n)||i.find(o=>o===r)||this.isControlledElement(n,r))}isControlledElement(r,e){return this.config.followControlledElements?pl(r,e):false}updateTabbableNodes(){if(this.state.containerGroups=this.state.containers.map(r=>{let e=ui(r,{getShadowRoot:this.config.getShadowRoot}),t=ld(r,{getShadowRoot:this.config.getShadowRoot}),n=e[0],i=e[e.length-1],o=n,s=i,a=false;for(let c=0;c<e.length;c++)if(di(e[c])>0){a=true;break}function l(c,u=true){let d=e.indexOf(c);if(d>=0)return e[d+(u?1:-1)];let h=t.indexOf(c);if(!(h<0)){if(u){for(let p=h+1;p<t.length;p++)if(_n(t[p]))return t[p]}else for(let p=h-1;p>=0;p--)if(_n(t[p]))return t[p]}}return {container:r,tabbableNodes:e,focusableNodes:t,posTabIndexesFound:a,firstTabbableNode:n,lastTabbableNode:i,firstDomTabbableNode:o,lastDomTabbableNode:s,nextTabbableNode:l}}),this.state.tabbableGroups=this.state.containerGroups.filter(r=>r.tabbableNodes.length>0),this.state.tabbableGroups.length<=0&&!this.getNodeForOption("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(this.state.containerGroups.find(r=>r.posTabIndexesFound)&&this.state.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")}addListeners(){if(this.state.active)return Sv.activateTrap(this.trapStack,this),this.state.delayInitialFocusTimer=this.config.delayInitialFocus?Cv(()=>{this.tryFocus(this.getInitialFocusNode());}):this.tryFocus(this.getInitialFocusNode()),this.listenerCleanups.push(je(this.doc,"focusin",this.handleFocus,true),je(this.doc,"mousedown",this.handlePointerDown,{capture:true,passive:false}),je(this.doc,"touchstart",this.handlePointerDown,{capture:true,passive:false}),je(this.doc,"click",this.handleClick,{capture:true,passive:false}),je(this.doc,"keydown",this.handleTabKey,{capture:true,passive:false}),je(this.doc,"keydown",this.handleEscapeKey)),this}removeListeners(){if(this.state.active)return this.listenerCleanups.forEach(r=>r()),this.listenerCleanups=[],this}activate(r){if(this.state.active)return this;let e=this.getOption(r,"onActivate"),t=this.getOption(r,"onPostActivate"),n=this.getOption(r,"checkCanFocusTrap");n||this.updateTabbableNodes(),this.state.active=true,this.state.paused=false,this.state.nodeFocusedBeforeActivation=Xt(this.doc),e?.();let i=()=>{n&&this.updateTabbableNodes(),this.addListeners(),this.updateObservedNodes(),t?.();};return n?(n(this.state.containers.concat()).then(i,i),this):(i(),this)}},Xd=r=>r?.type==="keydown",Kd=r=>Xd(r)&&r?.key==="Tab",cE=r=>Xd(r)&&r.key==="Tab"&&!r?.shiftKey,uE=r=>Xd(r)&&r.key==="Tab"&&r?.shiftKey,Zo=(r,...e)=>typeof r=="function"?r(...e):r,dE=r=>!r.isComposing&&r.key==="Escape",Cv=r=>setTimeout(r,0),hE=r=>r.localName==="input"&&"select"in r&&typeof r.select=="function";function kv(r,e={}){let t,n=Ie(()=>{let o=(Array.isArray(r)?r:[r]).map(a=>typeof a=="function"?a():a).filter(a=>a!=null);if(o.length===0)return;let s=o[0];t=new Tv(o,{escapeDeactivates:false,allowOutsideClick:true,preventScroll:true,returnFocusOnDeactivate:true,delayInitialFocus:false,fallbackFocus:s,...e,document:Le(s)});try{t.activate();}catch{}});return function(){t?.deactivate(),n();}}var Ev="data-scroll-lock",jd=new WeakMap;function pE(r){let e=r.getBoundingClientRect().left;return Math.round(e)+r.scrollLeft?"paddingLeft":"paddingRight"}function Lv(r){let t=ai(r)?.scrollbarGutter;return t==="stable"||t?.startsWith("stable ")===true}function mE(r){let e=r.defaultView??window,{documentElement:t,body:n}=r,i=Lv(t)||Lv(n),o=e.innerWidth-t.clientWidth;n.setAttribute(Ev,"");let s=()=>jf(t,"--scrollbar-width",`${o}px`),a=pE(t),l=()=>{let d={overflow:"hidden"};return !i&&o>0&&(d[a]=`${o}px`),Po(n,d)},c=()=>{let{scrollX:d,scrollY:h,visualViewport:p}=e,m=p?.offsetLeft??0,f=p?.offsetTop??0,g={position:"fixed",overflow:"hidden",top:`${-(h-Math.floor(f))}px`,left:`${-(d-Math.floor(m))}px`,right:"0"};!i&&o>0&&(g[a]=`${o}px`);let b=Po(n,g);return ()=>{b?.(),e.scrollTo({left:d,top:h,behavior:"instant"});}},u=[s(),Pf()?c():l()];return ()=>{u.forEach(d=>d?.()),n.removeAttribute(Ev);}}function Mv(r){let e=r??document,t=jd.get(e);t||(t={count:0,cleanup:mE(e)},jd.set(e,t)),t.count++;let n=t,i=false;return ()=>{i||(i=true,n.count--,n.count===0&&(n.cleanup(),jd.delete(e)));}}var qd=ul({props({props:r,scope:e}){let t=r.role==="alertdialog",n=t?()=>gv(e):void 0,i=typeof r.modal=="boolean"?r.modal:true;return {role:"dialog",modal:i,trapFocus:i,preventScroll:i,closeOnInteractOutside:i&&!t,closeOnEscape:true,restoreFocus:true,initialFocusEl:n,...r}},initialState({prop:r}){return r("open")||r("defaultOpen")?"open":"closed"},context({bindable:r,prop:e,scope:t}){return {rendered:r(()=>({defaultValue:{title:true,description:true}})),triggerValue:r(()=>({defaultValue:e("defaultTriggerValue")??null,value:e("triggerValue"),onChange(n){let i=e("onTriggerValueChange");if(!i)return;let o=Gd(t,n);i({value:n,triggerElement:o});}}))}},watch({track:r,action:e,prop:t}){r([()=>t("open")],()=>{e(["toggleVisibility"]);});},states:{open:{entry:["checkRenderedElements","setInitialFocus"],effects:["trackDismissableElement","trapFocus","preventScroll","hideContentBelow"],on:{"CONTROLLED.CLOSE":{target:"closed"},CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["invokeOnClose"]}],"TRIGGER_VALUE.SET":{actions:["setTriggerValue"]}}},closed:{on:{"CONTROLLED.OPEN":{target:"open"},OPEN:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TOGGLE:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],"TRIGGER_VALUE.SET":{actions:["setTriggerValue"]}}}},implementations:{guards:{isOpenControlled:({prop:r})=>r("open")!=null},effects:{trackDismissableElement({scope:r,send:e,prop:t}){return $l(()=>qo(r),{type:"dialog",defer:true,pointerBlocking:t("modal"),layerStyleTargets:[()=>pv(r),()=>hv(r)],exclude:[Wd(r),...Zl(r)].filter(Boolean),onInteractOutside(i){t("onInteractOutside")?.(i),t("closeOnInteractOutside")||i.preventDefault();},persistentElements:t("persistentElements"),onFocusOutside:t("onFocusOutside"),onPointerDownOutside:t("onPointerDownOutside"),onRequestDismiss:t("onRequestDismiss"),onEscapeKeyDown(i){t("onEscapeKeyDown")?.(i),t("closeOnEscape")||i.preventDefault();},onDismiss(){e({type:"CLOSE",src:"interact-outside"});}})},preventScroll({scope:r,prop:e}){if(e("preventScroll"))return Mv(r.getDoc())},trapFocus({scope:r,prop:e,context:t}){return e("trapFocus")?kv(()=>qo(r),{preventScroll:true,returnFocusOnDeactivate:!!e("restoreFocus"),initialFocus:e("initialFocusEl"),setReturnFocus:i=>{let o=e("finalFocusEl")?.();if(o)return o;let s=t.get("triggerValue");if(s){let l=Gd(r,s);if(l)return l}let a=Zl(r)[0];return a||i},getShadowRoot:true}):void 0},hideContentBelow({scope:r,prop:e}){return e("modal")?xv(()=>[qo(r)],{defer:true}):void 0}},actions:{setInitialFocus({prop:r,scope:e}){r("trapFocus")||Ie(()=>{gl({root:qo(e),getInitialEl:r("initialFocusEl")})?.focus({preventScroll:true});});},checkRenderedElements({context:r,scope:e}){Ie(()=>{r.set("rendered",{title:!!mv(e),description:!!fv(e)});});},invokeOnClose({prop:r}){r("onOpenChange")?.({open:false});},invokeOnOpen({prop:r}){r("onOpenChange")?.({open:true});},setTriggerValue({context:r,event:e}){e.value!==void 0&&r.set("triggerValue",e.value);},toggleVisibility({prop:r,send:e,event:t}){e({type:r("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:t});}}}});function Pv(r={}){return {machine:qd,props:{id:El("vela-dialog"),modal:r.modal??true,closeOnEscape:r.closeOnEscape??true,closeOnInteractOutside:r.closeOnInteractOutside??false,initialFocusEl:r.initialFocusEl,onOpenChange:e=>r.onOpenChange?.(e.open)},connect:e=>Ud(e,pi)}}var Iv="vela-ui-dialog-5",Av=`
|
|
296
296
|
.vela-dialog-backdrop {
|
|
297
297
|
position: fixed;
|
|
298
298
|
inset: 0;
|
|
@@ -403,11 +403,11 @@ ${Gk}
|
|
|
403
403
|
.vela-dialog-btn:hover { background: var(--vela-hover); color: var(--vela-fg-bright); border-color: var(--vela-fg-muted); }
|
|
404
404
|
.vela-dialog-btn-primary { border-color: var(--vela-selected-bg); background: var(--vela-selected-bg); color: var(--vela-selected-fg); }
|
|
405
405
|
.vela-dialog-btn-primary:hover { background: var(--vela-selected-bg); color: var(--vela-selected-fg); opacity: 0.85; border-color: var(--vela-selected-bg); }
|
|
406
|
-
${
|
|
406
|
+
${Sr(".vela-dialog-body")}
|
|
407
407
|
/* Scrollers NESTED in a dialog (a flush body's grid, a tab pane) get the same thin
|
|
408
408
|
overlay bars \u2014 the two-class selectors below stay overridable by more specific
|
|
409
409
|
per-dialog sheets. */
|
|
410
|
-
${
|
|
410
|
+
${Sr(".vela-dialog *")}
|
|
411
411
|
/* \u2500\u2500 mobile chrome: dialogs fill the shell \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
412
412
|
Inside a shell in the mobile size class ([data-layout='mobile'] on the widget root,
|
|
413
413
|
which is position:relative) every kit dialog presents fullscreen: desktop cards are
|
|
@@ -431,7 +431,7 @@ ${xr(".vela-dialog *")}
|
|
|
431
431
|
}
|
|
432
432
|
[data-layout='mobile'] .vela-dialog-close { width: 40px; height: 40px; }
|
|
433
433
|
[data-layout='mobile'] .vela-dialog-body { padding-bottom: calc(var(--vela-space-4) + env(safe-area-inset-bottom, 0px)); }
|
|
434
|
-
`;var
|
|
434
|
+
`;var wn=class{constructor(e={}){let t=(e.host??document.body).ownerDocument;he(Iv,Av,t);let n=e.host??t.body;if(this.backdrop=t.createElement("div"),this.backdrop.className="vela-dialog-backdrop vela-ui-layer",e.dimBackdrop!==true&&this.backdrop.classList.add("vela-dialog-backdrop--clear"),this.positioner=t.createElement("div"),this.positioner.className="vela-dialog-positioner vela-ui-layer",e.contained&&(this.backdrop.dataset.contained="",this.positioner.dataset.contained=""),this.positioner.dataset.align=e.align??"top",this.panel=t.createElement("div"),this.panel.className="vela-dialog",e.className)for(let l of e.className.split(/\s+/))l&&this.panel.classList.add(l);this.panel.tabIndex=-1,this.panel.addEventListener("keydown",l=>{l.key!=="Escape"&&l.stopPropagation();});let i=t.createElement("div");if(i.className="vela-dialog-header",e.draggable){i.style.cursor="move";let l=0,c=0,u=0,d=0,h=false;i.addEventListener("pointerdown",p=>{p.target.closest(".vela-dialog-close")||(h=true,l=p.clientX-u,c=p.clientY-d,i.setPointerCapture(p.pointerId));}),i.addEventListener("pointermove",p=>{h&&(u=p.clientX-l,d=p.clientY-c,this.panel.style.transform=`translate(${u}px, ${d}px)`);}),i.addEventListener("pointerup",()=>h=false);}e.headerStart&&i.appendChild(e.headerStart);let o=t.createElement("div");o.className="vela-dialog-title",o.textContent=e.title??"",this.titleEl=o;let s=t.createElement("button");if(s.className="vela-dialog-close",s.appendChild(qe("close",t)),i.append(o,s),this.body=t.createElement("div"),this.body.className="vela-dialog-body",e.flush&&(this.body.dataset.flush=""),e.content instanceof Node?this.body.appendChild(e.content):typeof e.content=="function"&&e.content(this.body),this.panel.append(i,this.body),e.footer){let l=t.createElement("div");l.className="vela-dialog-footer",e.footer instanceof Node?l.appendChild(e.footer):e.footer(l),this.panel.appendChild(l),this.footer=l;}else this.footer=null;if(this.positioner.appendChild(this.panel),n.append(this.backdrop,this.positioner),e.closeOnBackdrop){let l=c=>{if(!(c.target!==this.backdrop&&c.target!==this.positioner)){if(tn()||Ir(c)){Te();return}this.hide();}};this.backdrop.addEventListener("pointerdown",l),this.positioner.addEventListener("pointerdown",l);}this.ctrl=Pv({...e,initialFocusEl:()=>this.positioner.closest('[data-layout="mobile"]')?this.panel:e.initialFocusEl?.()??null});let a=String(this.ctrl.props.id);this.handle=kl(this.ctrl.machine,this.ctrl.props,l=>{let c=this.ctrl.connect(l);it(this.backdrop,c.getBackdropProps(),a),it(this.positioner,c.getPositionerProps(),a),it(this.panel,c.getContentProps(),a),it(o,c.getTitleProps(),a),it(s,c.getCloseTriggerProps(),a),this.backdrop.style.display=c.open?"":"none",this.positioner.style.display=c.open?"":"none";});}get open(){return this.ctrl.connect(this.handle.service).open}show(){this.ctrl.connect(this.handle.service).setOpen(true);}hide(){this.ctrl.connect(this.handle.service).setOpen(false);}contains(e){return e==null?false:this.panel.contains(e)||this.backdrop.contains(e)||this.positioner.contains(e)?true:(e instanceof Element?e:e.parentElement)?.closest(".vela-popover, .vela-menu")!=null}destroy(){this.open&&this.hide(),this.handle.stop(),this.backdrop.remove(),this.positioner.remove();}};function Rv(r={}){let e=r.checked??false,t=r.disabled??false;return {get checked(){return e},disabled:t,size:r.size??"md",tone:r.tone??"bright",setChecked(n){e=n;},toggle(){return t||(e=!e,r.onChange?.(e)),e}}}var Dv="vela-ui-switch",Ov=`
|
|
435
435
|
.vela-switch {
|
|
436
436
|
width: 20px;
|
|
437
437
|
height: 20px;
|
|
@@ -469,7 +469,7 @@ ${xr(".vela-dialog *")}
|
|
|
469
469
|
color: var(--vela-selected-fg);
|
|
470
470
|
}
|
|
471
471
|
.vela-switch[disabled] { opacity: 0.4; cursor: default; }
|
|
472
|
-
`;var
|
|
472
|
+
`;var Ar=class{constructor(e={}){he(Dv,Ov,document),this.ctrl=Rv(e);let t=document.createElement("button");t.type="button",e.id&&(t.id=e.id),t.className="vela-switch",t.dataset.size=this.ctrl.size,t.dataset.tone=this.ctrl.tone,t.setAttribute("role","switch"),this.ctrl.disabled&&(t.disabled=true),t.appendChild(qe("check",t.ownerDocument)),this.el=t,this.paint(),t.addEventListener("pointerdown",n=>{n.preventDefault(),t.focus({preventScroll:true});}),t.addEventListener("click",()=>{this.ctrl.toggle(),this.paint();});}get checked(){return this.ctrl.checked}setChecked(e){this.ctrl.setChecked(e),this.paint();}paint(){let e=this.ctrl.checked;this.el.setAttribute("aria-checked",e?"true":"false"),e?this.el.dataset.checked="":delete this.el.dataset.checked;}};function gE(r,e){let t=r;return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),e.integer&&(t=Math.round(t)),t}function Nv(r){let e=String(r),t=e.search(/[eE]/);if(t>=0){let n=e.slice(0,t).split(".")[1]?.length??0;return Math.max(0,Math.min(20,n-Number(e.slice(t+1))))}return e.split(".")[1]?.length??0}function Zd(r,e,t){let n=Math.min(20,Math.max(Nv(e),Nv(t)));return Number(r.toFixed(n))}function Fv(r){let e=r.value,t=r.integer??false,n=r.commit??"blur",i=r.clamp??n==="blur",o=r.step??(t?1:.1),s=r.onChange,a=c=>i?gE(c,{min:r.min,max:r.max,integer:t}):c,l=c=>{if(!Number.isFinite(c))return null;let u=a(c);return u!==e&&(e=u,s?.(u)),u};return {get value(){return e},min:r.min,max:r.max,step:o,integer:t,size:r.size??"md",commit:n,steppers:r.steppers??n==="blur",clamp:i,disabled:r.disabled??false,apply:l,sync(c){let u=Number.isFinite(c)?a(c):e;return e=u,u},nudge(c){return l(Zd(e+c*o,e,o))}}}var Vv="vela-ui-number-3",_v=`
|
|
473
473
|
.vela-num { position: relative; display: inline-block; min-width: 0; }
|
|
474
474
|
.vela-num[data-fill] { width: 100%; }
|
|
475
475
|
.vela-num:not([data-fill]) { width: 100px; flex: none; justify-self: start; }
|
|
@@ -540,7 +540,7 @@ ${xr(".vela-dialog *")}
|
|
|
540
540
|
}
|
|
541
541
|
.vela-num-step button:hover { background: var(--vela-hover); color: var(--vela-fg-bright); }
|
|
542
542
|
.vela-num-step .vela-icon, .vela-num-step svg { width: 12px; height: 12px; display: block; }
|
|
543
|
-
`;var
|
|
543
|
+
`;var Rr=class{constructor(e){let t=document;he(Vv,_v,t),this.ctrl=Fv(e),this.placeholderMode=e.placeholder!==void 0,this.emptyValue=e.emptyValue??e.value,this.last=String(e.value);let n=t.createElement("div");n.className="vela-num",n.dataset.size=this.ctrl.size,(e.fill??this.ctrl.size!=="sm")&&(n.dataset.fill=""),e.compact&&(n.dataset.compact=""),this.ctrl.steppers&&(n.dataset.steppers="");let i=t.createElement("input");i.type="number",e.id&&(i.id=e.id),e.title&&(i.title=e.title),e.min!==void 0&&(i.min=String(e.min)),e.max!==void 0&&(i.max=String(e.max)),i.step=String(this.ctrl.step),this.ctrl.disabled&&(i.disabled=true),this.placeholderMode?(i.placeholder=e.placeholder??"",i.value=e.value!==this.emptyValue?String(e.value):""):i.value=String(e.value);let o=s=>{let a=this.ctrl.apply(s);if(a===null){i.value=this.placeholderMode&&this.ctrl.value===this.emptyValue?"":this.last;return}this.last=String(a),this.placeholderMode&&a===this.emptyValue?i.value="":i.value=String(a);};this.placeholderMode?i.addEventListener("change",()=>{let s=i.value.trim()===""?this.emptyValue:Number(i.value);o(Number.isFinite(s)?s:this.emptyValue);}):this.ctrl.commit==="live"?i.addEventListener("input",()=>{let s=Number(i.value);Number.isFinite(s)&&this.ctrl.apply(s);}):(i.addEventListener("blur",()=>o(Number(i.value))),i.addEventListener("keydown",s=>{s.key==="Enter"&&(s.preventDefault(),i.blur());})),n.appendChild(i),this.ctrl.steppers&&n.appendChild(this.buildSteppers(t,s=>{let a=Number(i.value),l=Number.isFinite(a)?a:this.ctrl.value;o(Zd(l+s*this.ctrl.step,l,this.ctrl.step));})),this.el=n,this.input=i;}get value(){return this.ctrl.value}setValue(e){let t=this.ctrl.sync(e);this.last=String(t),this.placeholderMode&&t===this.emptyValue?this.input.value="":this.input.value=String(t);}buildSteppers(e,t){let n=e.createElement("div");n.className="vela-num-step";let i=(o,s,a)=>{let l=e.createElement("button");l.type="button",l.tabIndex=-1,l.setAttribute("aria-label",a),l.appendChild(qe(s,e));let c=0,u=()=>t(o),d=()=>{c&&(window.clearTimeout(c),c=0);};return l.addEventListener("pointerdown",h=>{h.preventDefault(),h.stopPropagation(),u(),c=window.setTimeout(function p(){u(),c=window.setTimeout(p,60);},400);}),l.addEventListener("pointerup",d),l.addEventListener("pointerleave",d),l.addEventListener("pointercancel",d),l};return n.append(i(1,"chevron-up","Increase"),i(-1,"chevron-down","Decrease")),n}};function Bv(r={}){let e=r.value??"",t=r.size??"md";return {get value(){return e},size:t,fill:r.fill??t!=="sm",disabled:r.disabled??false,commit(n){return n===e?null:(e=n,r.onChange?.(n),n)},sync(n){e=n;}}}var Hv="vela-ui-text-2",zv=`
|
|
544
544
|
.vela-text {
|
|
545
545
|
display: inline-block;
|
|
546
546
|
min-width: 0;
|
|
@@ -576,7 +576,7 @@ ${xr(".vela-dialog *")}
|
|
|
576
576
|
color: var(--vela-fg);
|
|
577
577
|
font-size: 13px;
|
|
578
578
|
}
|
|
579
|
-
`;var
|
|
579
|
+
`;var Jo=class{constructor(e={}){let t=document;he(Hv,zv,t),this.ctrl=Bv(e);let n=t.createElement("div");n.className="vela-text",n.dataset.size=this.ctrl.size,this.ctrl.fill&&(n.dataset.fill="");let i=t.createElement("input");i.type="text",i.size=1,e.id&&(i.id=e.id),i.value=this.ctrl.value,i.className="vela-text-field",this.ctrl.disabled&&(i.disabled=true),i.addEventListener("blur",()=>{this.ctrl.commit(i.value);}),i.addEventListener("keydown",o=>{o.key==="Enter"&&(o.preventDefault(),i.blur());}),n.appendChild(i),this.el=n,this.input=i;}get value(){return this.ctrl.value}setValue(e){this.ctrl.sync(e),this.input.value=e;}};function $v(r={}){let e=r.value??"";return {get value(){return e},size:r.size??"md",rows:r.rows??3,disabled:r.disabled??false,commit(t){return t===e?null:(e=t,r.onChange?.(t),t)},sync(t){e=t;}}}var Wv="vela-ui-textarea",Gv=`
|
|
580
580
|
.vela-textarea { display: block; width: 100%; min-width: 0; }
|
|
581
581
|
.vela-textarea-field {
|
|
582
582
|
display: block;
|
|
@@ -608,14 +608,14 @@ ${xr(".vela-dialog *")}
|
|
|
608
608
|
padding: 6px 9px;
|
|
609
609
|
line-height: 18px;
|
|
610
610
|
}
|
|
611
|
-
`;var
|
|
611
|
+
`;var Dr=class{constructor(e={}){let t=document;he(Wv,Gv,t),this.ctrl=$v(e),this.autoGrow=e.autoGrow===true,this.maxLines=e.maxLines??4;let n=t.createElement("div");n.className="vela-textarea",n.dataset.size=this.ctrl.size,this.autoGrow&&(n.dataset.autogrow="");let i=t.createElement("textarea");i.className="vela-textarea-field",e.id&&(i.id=e.id),e.placeholder&&(i.placeholder=e.placeholder),i.rows=this.ctrl.rows,i.value=this.ctrl.value,this.ctrl.disabled&&(i.disabled=true),i.addEventListener("blur",()=>{this.ctrl.commit(i.value);}),this.autoGrow&&i.addEventListener("input",()=>this.grow()),n.appendChild(i),this.el=n,this.input=i,this.autoGrow&&this.grow();}get value(){return this.ctrl.value}setValue(e){this.ctrl.sync(e),this.input.value=e,this.autoGrow&&this.grow();}grow(){let e=this.input,t=parseFloat(getComputedStyle(e).lineHeight)||18,n=e.clientHeight-(e.offsetHeight?t*(e.rows||1):0),i=t*this.maxLines+(Number.isFinite(n)&&n>0?n:12);e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,i)}px`,e.style.overflowY=e.scrollHeight>i?"auto":"hidden";}};function Gn(r){let e=String(r??"").trim(),t=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(e);if(t)return {hex6:`#${t[1].toLowerCase()}`,alpha:t[2]?parseInt(t[2],16)/255:1};if(t=/^#([0-9a-f]{3})$/i.exec(e),t){let i=t[1].toLowerCase();return {hex6:`#${i[0]}${i[0]}${i[1]}${i[1]}${i[2]}${i[2]}`,alpha:1}}let n=/^rgba?\(([^)]+)\)/i.exec(e);if(n){let i=n[1].split(",").map(a=>a.trim()),o=a=>Math.max(0,Math.min(255,Math.round(a))).toString(16).padStart(2,"0"),s=i[3]!=null?Math.max(0,Math.min(1,parseFloat(i[3]))):1;return {hex6:`#${o(parseInt(i[0]??"0",10))}${o(parseInt(i[1]??"0",10))}${o(parseInt(i[2]??"0",10))}`,alpha:s}}return {hex6:$r,alpha:1}}function ec(r,e){let t=Math.max(0,Math.min(1,e));return t>=.999?r:`${r}${Math.round(t*255).toString(16).padStart(2,"0")}`}function Qd(r,e,t){let n=h=>{let p=parseInt(Gn(h).hex6.slice(1),16);return [p>>16&255,p>>8&255,p&255]},[i,o,s]=n(r),[a,l,c]=n(e),u=Math.max(0,Math.min(1,t)),d=h=>Math.round(h).toString(16).padStart(2,"0");return `#${d(i*u+a*(1-u))}${d(o*u+l*(1-u))}${d(s*u+c*(1-u))}`}function Jd(r,e,t){let n=e/100,i=t/100,o=c=>(c+r/30)%12,s=n*Math.min(i,1-i),a=c=>i-s*Math.max(-1,Math.min(o(c)-3,Math.min(9-o(c),1))),l=c=>Math.round(c*255).toString(16).padStart(2,"0");return `#${l(a(0))}${l(a(8))}${l(a(4))}`}function eh(){let r=[100,90,80,68,56,45,35,25,14,0].map(n=>Jd(0,0,n)),e=[4,28,50,96,140,174,200,224,270,322];return [r,...[[82,56],[58,84],[62,74],[66,62],[70,50],[64,39],[54,29]].map(([n,i])=>e.map(o=>Jd(o,n,i)))]}function tc(r){return `repeating-conic-gradient(#9aa0a6 0% 25%, #d3d6da 0% 50%) 0 0 / ${r}px ${r}px`}var Uv="vela-ui-color",Yv=`
|
|
612
612
|
.vela-color-field{width:24px;height:24px;padding:2px;border:1px solid var(--vela-border);border-radius:0;background:var(--vela-surface-sunken);cursor:pointer;display:inline-flex;flex:none;}
|
|
613
613
|
.vela-color-field:hover{border-color:var(--vela-fg-muted);}
|
|
614
614
|
.vela-color-field-swatch{display:block;width:100%;height:100%;border-radius:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,0.25);}
|
|
615
615
|
.vela-color-field-circle{width:26px;height:26px;padding:3px;border:1px solid var(--vela-border-strong);border-radius:4px;background:transparent;overflow:hidden;}
|
|
616
616
|
.vela-color-field-circle .vela-color-field-swatch{border-radius:2px;box-shadow:none;}
|
|
617
617
|
.vela-color-field-pop{background:var(--vela-surface-overlay);border:1px solid var(--vela-border);border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow);padding:10px;}
|
|
618
|
-
`;var
|
|
618
|
+
`;var bE=eh(),vE=tc(10),yE=tc(8),Ci=[Ke,z,W,ue,J];function wE(r){let e=Ci.findIndex(t=>t.toLowerCase()===r.toLowerCase());e>=0&&Ci.splice(e,1),Ci.unshift(r),Ci.length>10&&(Ci.length=10);}function Qo(r,e,t){let n=Gn(r),i=n.hex6,o=n.alpha,s=document.createElement("div");s.style.cssText="display:flex;flex-direction:column;gap:9px;width:236px;";let a=document.createElement("div");a.style.cssText="display:grid;grid-template-columns:repeat(10,1fr);gap:4px;";let l=[];for(let w of bE)for(let M of w){let P=document.createElement("button");P.type="button",P.dataset.c=M,P.style.cssText=`width:100%;aspect-ratio:1;border-radius:4px;border:none;cursor:pointer;background:${M};padding:0;`,P.addEventListener("click",C=>{C.stopPropagation(),L(M);}),a.appendChild(P),l.push(P);}let c=()=>{for(let w of l){let M=(w.dataset.c??"").toLowerCase()===i.toLowerCase();w.style.outline=M?`2px solid ${e.textColor}`:"none",w.style.outlineOffset="2px",w.style.zIndex=M?"1":"",w.style.position=M?"relative":"";}},u=document.createElement("div");u.style.cssText="display:flex;align-items:center;gap:5px;flex-wrap:wrap;border-top:1px solid var(--vela-border);padding-top:9px;";let d=document.createElement("div");d.style.cssText="display:contents;";let h=document.createElement("label");h.style.cssText=`width:17px;height:17px;border-radius:var(--vela-radius-sm);border:1px dashed var(--vela-border-strong);cursor:pointer;display:flex;align-items:center;justify-content:center;color:${e.textColor};font:14px ${e.fontFamily};position:relative;`,h.textContent="+";let p=document.createElement("input");p.type="color",p.value=i,p.style.cssText="position:absolute;inset:0;opacity:0;cursor:pointer;",p.addEventListener("input",()=>x(p.value)),p.addEventListener("change",()=>L(p.value,true)),h.appendChild(p),u.append(d,h);let m=()=>{d.replaceChildren();for(let w of Ci){let M=document.createElement("button");M.type="button",M.style.cssText=`width:17px;height:17px;border-radius:var(--vela-radius-sm);border:1px solid var(--vela-border);cursor:pointer;background:${w};padding:0;`,M.addEventListener("click",P=>{P.stopPropagation(),L(w);}),d.appendChild(M);}},f=document.createElement("div");f.textContent="Opacity",f.style.cssText=`font:11px ${e.fontFamily};color:var(--vela-fg-muted);`;let g=document.createElement("div");g.style.cssText="display:flex;align-items:center;gap:10px;";let b=document.createElement("div");b.style.cssText="flex:1;position:relative;height:13px;border-radius:7px;cursor:pointer;";let y=document.createElement("div");y.style.cssText="position:absolute;top:50%;width:15px;height:15px;border-radius:50%;background:var(--vela-selected-bg);box-shadow:0 1px 3px rgba(0,0,0,0.55);transform:translate(-50%,-50%);pointer-events:none;",b.appendChild(y);let v=document.createElement("div");v.style.cssText=`min-width:42px;text-align:center;font:var(--vela-font-size-md) ${e.fontFamily};color:var(--vela-fg);border:1px solid var(--vela-border);border-radius:5px;padding:3px 4px;`,g.append(b,v);let S=()=>{b.style.background=`linear-gradient(to right, ${i}00, ${i}ff), ${vE}`,y.style.left=`${o*100}%`,v.textContent=`${Math.round(o*100)}%`;},E=false,T=w=>{let M=b.getBoundingClientRect();o=Math.max(0,Math.min(1,(w-M.left)/M.width)),S(),k();};b.addEventListener("pointerdown",w=>{w.stopPropagation(),E=true,b.setPointerCapture(w.pointerId),T(w.clientX);}),b.addEventListener("pointermove",w=>{E&&T(w.clientX);}),b.addEventListener("pointerup",()=>E=false);function k(){t(ec(i,o));}function x(w){i=Gn(w).hex6,c(),S(),k();}function L(w,M=false){x(w),wE(i),p.value=i,M&&m();}return m(),c(),S(),s.append(a,u,f,g),s}function th(r,e,t,n){return new nc({theme:r,getVal:e,onVal:t,shape:n?.shape,id:n?.id,popover:n?.popover}).el}var nc=class{constructor(e){he(Uv,Yv,document),this.theme=e.theme,this.getVal=e.getVal,this.onVal=e.onVal,this.popoverOpts=e.popover;let t=document.createElement("button");t.type="button",e.id&&(t.id=e.id),t.className=e.shape==="circle"?"vela-color-field vela-color-field-circle":"vela-color-field";let n=document.createElement("span");n.className="vela-color-field-swatch",t.appendChild(n),this.el=t,this.swatch=n,this.paint(),t.addEventListener("vela-sync",()=>this.paint()),t.addEventListener("pointerdown",i=>{i.preventDefault(),t.focus({preventScroll:true});}),t.addEventListener("click",i=>{i.stopPropagation(),this.toggle();});}paint(){let e=this.getVal();this.swatch.style.background=`linear-gradient(${e}, ${e}), ${yE}`;}toggle(){if(yn()===this.el){Te();return}new $e({trigger:this.el,theme:this.theme,align:this.popoverOpts?.align??"end",gap:this.popoverOpts?.gap??6,host:this.popoverOpts?.host,position:this.popoverOpts?.position,boundary:this.popoverOpts?.boundary,zIndex:this.popoverOpts?.zIndex,className:"vela-color-field-pop",content:Qo(this.getVal(),this.theme,t=>{this.onVal(t),this.paint();})}).show();}};function Kv(r){let e=r.value;return {options:r.options,get value(){return e},setValue(t){e=t;},optionOf(t){return r.options.find(n=>n.value===t)},pick(t){return e=t,r.onChange?.(t),t}}}var xE=[1,2,3,4,5];function SE(r){return `<svg width="22" height="14" viewBox="0 0 22 14" fill="none"><line x1="2" y1="7" x2="20" y2="7" stroke="currentColor" stroke-width="${r}" stroke-linecap="round"/></svg>`}function Xv(){return xE.map(r=>({value:r,label:`${r}px`,glyph:SE(r)}))}var jv="vela-ui-glyph-select",qv=`
|
|
619
619
|
.vela-glyph-select {
|
|
620
620
|
height: 34px;
|
|
621
621
|
padding: 0 26px 0 8px;
|
|
@@ -676,7 +676,7 @@ ${xr(".vela-dialog *")}
|
|
|
676
676
|
}
|
|
677
677
|
.vela-glyph-select-item:hover { background: var(--vela-hover); }
|
|
678
678
|
.vela-glyph-select-item[data-active='1'] { background: var(--vela-hover-strong); color: var(--vela-fg-bright); }
|
|
679
|
-
`;var
|
|
679
|
+
`;var rc=class{constructor(e){he(jv,qv,document),this.ctrl=Kv(e),this.theme=e.theme,this.get=e.get??(()=>this.ctrl.value);let t=document.createElement("button");t.type="button",t.className="vela-glyph-select",e.title&&(t.title=e.title),this.el=t,this.paint(),t.addEventListener("pointerdown",n=>{n.preventDefault(),t.focus({preventScroll:true});}),t.addEventListener("click",n=>{n.stopPropagation(),this.toggle();}),t.addEventListener("vela-sync",()=>{this.ctrl.setValue(this.get()),this.paint();});}setValue(e){this.ctrl.setValue(e),this.paint();}paint(){let e=this.get(),t=this.ctrl.optionOf(e),n=document.createElement("span");n.style.display="flex",n.innerHTML=t?.glyph??"";let i=document.createElement("span");i.className="vela-glyph-select-caret",i.appendChild(qe("chevron-down",this.el.ownerDocument)),this.el.replaceChildren(n,i);}toggle(){if(yn()===this.el){Te();return}let e=this.get(),t=new $e({trigger:this.el,theme:this.theme,align:"end",gap:6,className:"vela-glyph-select-pop",content:n=>{n.style.font=`var(--vela-font-size-md) ${this.theme.fontFamily}`;for(let i of this.ctrl.options){let o=document.createElement("button");o.type="button",o.className="vela-glyph-select-item",o.dataset.active=i.value===e?"1":"0",o.innerHTML=`<span style="display:flex;flex:none;">${i.glyph}</span><span style="flex:1;font-variant-numeric:tabular-nums;">${i.label}</span>`,o.addEventListener("click",s=>{s.stopPropagation(),t.hide(),this.ctrl.pick(i.value),this.paint();}),n.appendChild(o);}}});t.show();}};function nh(r,e,t){return new rc({theme:r,options:Xv(),value:e(),get:e,onChange:t}).el}function rh(){Te();}function es(r,e){return r==="inputs"?e?"minmax(0,1fr) auto":"max-content 1fr":e?"minmax(0,1fr) max-content":"max-content max-content"}var Zv="vela-ui-field",Jv=`
|
|
680
680
|
.vela-field-grid {
|
|
681
681
|
display: grid;
|
|
682
682
|
align-items: center;
|
|
@@ -729,10 +729,10 @@ ${xr(".vela-dialog *")}
|
|
|
729
729
|
.vela-field-section[data-variant='inputs'][data-first] { padding-top: 4px; }
|
|
730
730
|
.vela-field-sep { grid-column: 1 / -1; height: 14px; }
|
|
731
731
|
.vela-field-dim { opacity: 0.4 !important; pointer-events: none !important; }
|
|
732
|
-
`;function rc(r=document){he(Yv,Kv,r);}function ts(r={}){rc();let e=document.createElement("div");e.className="vela-field-grid";let t=r.variant??"inputs";return e.dataset.variant=t,r.mobile&&(e.dataset.mobile=""),e.style.gridTemplateColumns=Qo(t,r.mobile===true),e}function wn(r,e={}){rc();let t=document.createElement("div");return t.className="vela-field-section",e.variant&&(t.dataset.variant=e.variant),e.first&&(t.dataset.first=""),t.textContent=r,t}function nh(){rc();let r=document.createElement("div");return r.className="vela-field-sep",r}function es(r,e){let t=document.createElement("span");t.className="vela-field-label",e.size&&(t.dataset.size=e.size),t.textContent=r;let n=e.id;return n&&(t.id=`${n}--title`,queueMicrotask(()=>{t.ownerDocument.getElementById(n)?.setAttribute("aria-labelledby",t.id);})),t}function Xv(r){return r?Array.isArray(r)?r:[r]:[]}function nc(r,e){if(e)for(let t of e.split(/\s+/))t&&r.classList.add(t);}function th(r,e){for(let t of r)t.dataset.sdSelfGated!=="1"&&t.classList.toggle("vela-field-dim",!e);}function Ae(r){rc();let e=r.labelSize;if(r.inline){let o=document.createElement("div");o.className="vela-field-span vela-field-inline";for(let s of r.inline){let a=document.createElement("div");if(a.className="vela-field-inline-item",s.toggleFirst&&(a.style.flexDirection="row-reverse"),s.label&&a.appendChild(es(s.label,{id:s.id,size:e})),s.fit)a.appendChild(s.control);else {let l=document.createElement("div");l.style.width="100px",l.appendChild(s.control),a.appendChild(l);}o.appendChild(a);}return r.info&&o.appendChild(r.info),nc(o,r.className),o}if(r.bool){let o=document.createElement("div");o.className="vela-field-span vela-field-bool";let s=new Ir({id:r.toggle?.id??r.id,checked:r.toggle?.checked??false,size:"md",tone:"bright",onChange:a=>r.toggle?.onChange(a)});if(o.append(s.el,es(r.label,{id:r.toggle?.id??r.id,size:e})),r.info&&o.appendChild(r.info),r.toggle?.get){let a=r.toggle.get;o.addEventListener("vela-sync",()=>{s.setChecked(a());});}return nc(o,r.className),o}if(r.stacked){let o=document.createElement("div");o.className="vela-field-span vela-field-stacked";let s=document.createElement("div");s.className="vela-field-stacked-head",s.appendChild(es(r.label,{id:r.id,size:e})),r.info&&s.appendChild(r.info),o.appendChild(s);for(let a of Xv(r.control))o.appendChild(a);return nc(o,r.className),o}let t=document.createElement("div");t.className="vela-field-row";let n=Xv(r.control);if(r.toggle){let o=document.createElement("div");o.className="vela-field-toggle-label";let s=new Ir({id:r.toggle.id??r.id,checked:r.toggle.checked,size:"md",tone:"bright",onChange:a=>{r.toggle.onChange(a),n.length>0&&th(n,a);}});if(o.append(s.el,es(r.label,{id:r.toggle.id??r.id,size:e})),t.appendChild(o),n.length>0&&th(n,r.toggle.checked),r.toggle.get){let a=r.toggle.get;t.addEventListener("vela-sync",()=>{let l=a();s.setChecked(l),n.length>0&&th(n,l);});}}else t.appendChild(es(r.label,{id:r.id,size:e}));let i=document.createElement("div");if(i.className="vela-field-cell",r.controlWidth!=null&&n.length===1&&!r.fit){let o=document.createElement("div");o.style.width=`${r.controlWidth}px`,o.appendChild(n[0]),i.appendChild(o);}else for(let o of n)i.appendChild(o);return r.info&&i.appendChild(r.info),t.appendChild(i),nc(t,r.className),t}function se(r){if(r.kind==="number"){let t=new Ar({id:r.id,value:r.value,min:r.min,max:r.max,step:r.step,integer:r.integer,size:"md",fill:r.fill,compact:r.compact,commit:r.commit,steppers:r.steppers,clamp:r.clamp,placeholder:r.placeholder,emptyValue:r.emptyValue,title:r.title,onChange:r.onChange});if(r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(Number(n))}}if(r.kind==="select"){let t=new Xo({id:r.id,options:r.options,value:r.value,size:"md",fill:r.fill,theme:r.theme,list:r.list,onChange:r.onChange});if(r.title&&(t.el.title=r.title),r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(String(n))}}if(r.kind==="switch"){let t=new Ir({id:r.id,checked:r.checked,size:"md",tone:"bright",onChange:r.onChange});if(r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setChecked(n());});}return {el:t.el,setValue:n=>t.setChecked(!!n)}}if(r.kind==="color"){let t=Jd(r.theme,r.get,r.onChange,{shape:"circle",id:r.id,popover:r.popover});return r.title&&(t.title=r.title),{el:t}}if(r.kind==="text"){let t=new Zo({id:r.id,value:r.value,size:"md",fill:r.fill,onChange:r.onChange});if(r.placeholder&&(t.input.placeholder=r.placeholder),r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(String(n))}}if(r.kind==="textarea"){let t=new Rr({id:r.id,value:r.value,rows:r.rows,autoGrow:r.autoGrow,maxLines:r.maxLines,placeholder:r.placeholder,onChange:r.onChange});if(r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(String(n))}}let e=Qd(r.theme,r.get,r.onChange);return r.title&&(e.title=r.title),{el:e}}var jv="Properties";function ic(r,e){return e.prop?r.propValues:r.values}var bE=["close","open","high","low","hl2","hlc3","ohlc4","volume"],ac=class{constructor(e){this.host=e;this.dialog=null;this.backdrop=null;this.uiDialog=null;this.openId=null;this.row=null;this.snapshot=null;this.propSnapshot=null;this.dialogTips=[];this.refreshVisibility=null;this.choicePop=null;this.calendarPop=null;this.calendarAnchor=null;this.onDialogKey=e=>{if(e.key==="Escape"){if(e.preventDefault(),en()){Te();return}this.close();}};}isOpen(){return this.dialog!==null}open(e){if(this.close(),e.inputs.length===0&&e.props.length===0)return;this.row=e,this.openId=e.id,this.snapshot={...e.values},this.propSnapshot={...e.propValues},lc();let t=this.host.theme(),n="var(--vela-border)",i="var(--vela-fg-bright)",o=this.host.dialogHost()??this.host.container,s=new yn({host:o,title:e.title,modal:false,contained:true,align:"center",draggable:!this.host.mobile(),flush:true,className:"vela-dialog--form vela-ind-dialog",closeOnEscape:false,footer:g=>{g.append(this.resetAction(),this.dialogButton("Cancel",false,()=>this.revertAndClose()),this.dialogButton("Ok",true,()=>this.close()));},onOpenChange:g=>{!g&&this.uiDialog===s&&this.close();}});Re(s.panel,t),s.panel.style.colorScheme=this.isDarkTheme()?"dark":"light",this.dialogTips.push(Yt(s.panel.querySelector(".vela-dialog-close"),{host:this.host.container,theme:()=>this.host.theme(),text:()=>"Close"}));let a=yE(e.inputs);if(e.props.length>0){let g=e.props.map(y=>{let v={...y,prop:true};return delete v.tab,v}),b=a.find(y=>y.name===jv);b?b.inputs.push(...g):a.push({name:jv,inputs:g});}let l=document.createElement("div");l.style.cssText=`display:flex;gap:12px;padding:0 20px;border-bottom:1px solid ${n};flex:0 0 auto;`;let c=[],u=[],d=[],h=0,p=g=>{h=g;for(let b=0;b<c.length;b+=1){let y=b===g,v=c[b];v.style.borderBottomColor=y?i:"transparent",v.style.color=y?"inherit":"var(--vela-fg-muted)",v.classList.toggle("vela-ind-tab-active",y),u[b].style.display=y?"grid":"none";}};for(let[g,b]of a.entries()){let y=document.createElement("div");y.textContent=b.name,y.className="vela-ind-tab",y.style.cssText=`padding:0 0 8px;margin-bottom:-1px;border-bottom:2px solid transparent;${a.length>1?"cursor:pointer;":""}`,y.addEventListener("click",()=>p(g)),l.appendChild(y),c.push(y),u.push(this.buildTabBody(b.inputs,e,d)),b.inputs.every(v=>v.when)&&d.push({el:y,visible:v=>b.inputs.some(S=>Ko(S.when,v))});}s.body.appendChild(l);for(let g of u)s.body.appendChild(g);p(0);let m=()=>{let g=wE(e);for(let b of d)b.el.style.display=b.visible(g)?"":"none";if(c[h]?.style.display==="none"){let b=c.findIndex(y=>y.style.display!=="none");b>=0&&p(b);}};this.refreshVisibility=m,m();let f=g=>{if(!(g.target!==s.backdrop&&g.target!==s.positioner)){if(en()||Pr(g)){Te();return}this.close(),this.host.onBackdropClose();}};s.backdrop.addEventListener("pointerdown",f),s.positioner.addEventListener("pointerdown",f),this.uiDialog=s,this.dialog=s.panel,this.backdrop=s.backdrop,s.show(),document.addEventListener("keydown",this.onDialogKey);}buildTabBody(e,t,n){let i=document.createElement("div");i.style.cssText=vE(this.host.mobile());for(let o of xE(e)){let s=document.createElement("div");s.style.cssText="display:contents;";let a=null;o.name&&(a=wn(o.name,{variant:"inputs",first:i.childElementCount===0}),s.appendChild(a));for(let l of o.rows){let c=this.buildInputRow(s,l,t);l.some(u=>u.when)&&n.push({el:c,visible:u=>Zv(l,u)});}if(a&&o.rows.every(l=>l.every(c=>c.when))){let l=o.rows;n.push({el:a,visible:c=>l.some(u=>Zv(u,c))});}i.appendChild(s);}return i}close(){document.removeEventListener("keydown",this.onDialogKey),Te(),this.refreshVisibility=null,this.choicePop=null,this.calendarPop=null,this.calendarAnchor=null;for(let t of this.dialogTips.splice(0))t();let e=this.uiDialog;this.uiDialog=null,this.backdrop=null,this.dialog=null,this.openId=null,this.row=null,this.snapshot=null,this.propSnapshot=null,e?.destroy();}revertAndClose(){let e=this.row,t=this.snapshot;if(e&&t)for(let i of e.inputs){let o=t[i.key],s=o!==void 0?o:i.defval;e.values[i.key]!==s&&(e.values[i.key]=s,this.host.onChange?.({indicatorId:e.id,key:i.key,value:s}));}let n=this.propSnapshot;if(e&&n)for(let i of e.props){let o=n[i.key],s=o!==void 0?o:i.defval;e.propValues[i.key]!==s&&(e.propValues[i.key]=s,this.host.onChange?.({indicatorId:e.id,key:i.key,value:s,kind:"prop"}));}this.close();}resetAction(){let e=this.dialogButton("Reset defaults",false,()=>this.resetToDefaults());return e.style.marginRight="auto",e}resetToDefaults(){let e=this.row;if(!e)return;let t=this.snapshot,n=this.propSnapshot;for(let i of e.inputs)e.values[i.key]!==i.defval&&(e.values[i.key]=i.defval,this.host.onChange?.({indicatorId:e.id,key:i.key,value:i.defval}));for(let i of e.props)e.propValues[i.key]!==i.defval&&(e.propValues[i.key]=i.defval,this.host.onChange?.({indicatorId:e.id,key:i.key,value:i.defval,kind:"prop"}));this.open(e),t&&(this.snapshot=t),n&&(this.propSnapshot=n);}commit(e,t,n){ic(e,t)[t.key]=n,this.host.onChange?.({indicatorId:e.id,key:t.key,value:n,...t.prop?{kind:"prop"}:{}}),this.refreshVisibility?.();}buildInputRow(e,t,n){let i=u=>`vela-inp-${n.id}-${u.key}`,o=u=>(e.appendChild(u),u);if(t.length>1)return o(Ae({label:"",inline:t.map(u=>({label:oc(u)||void 0,id:i(u),control:this.buildControl(n,u,i(u)),toggleFirst:u.type==="bool",fit:u.type==="color"||u.type==="bool"})),info:[...t].reverse().find(u=>u.tooltip)?.tooltip?this.infoButton([...t].reverse().find(u=>u.tooltip).tooltip):void 0}));let s=t[0],a=i(s),l=s.tooltip?this.infoButton(s.tooltip):void 0;if(s.type==="bool"){let u=!!(ic(n,s)[s.key]??s.defval);return o(Ae({label:oc(s),id:a,bool:true,info:l,toggle:{id:a,checked:u,onChange:d=>this.commit(n,s,d)}}))}if(s.type==="text_area")return o(Ae({label:oc(s),id:a,stacked:true,info:l,control:this.buildControl(n,s,a)}));let c=s.type==="color"||s.type==="session"||s.type==="time";return o(Ae({label:oc(s),id:a,fit:c,controlWidth:c?void 0:100,info:l,control:this.buildControl(n,s,a)}))}buildControl(e,t,n){let i=ic(e,t)[t.key]??t.defval,o=s=>this.commit(e,t,s);return t.type==="bool"?se({kind:"switch",id:n,checked:!!i,onChange:s=>o(s)}).el:t.options&&t.options.length>0?this.select(n,t.options.map(String),String(i),o):t.type==="source"?this.select(n,bE,String(i),o):t.type==="color"?se({kind:"color",id:n,theme:this.host.theme(),get:()=>String(ic(e,t)[t.key]??t.defval),onChange:s=>o(s)}).el:t.type==="symbol"?this.buildSymbol(n,String(i),o):t.type==="timeframe"?this.selectPairs(n,TE,String(i),o):t.type==="session"?this.buildSession(n,String(i),o):t.type==="time"?this.buildTime(n,Number(i)||0,o):t.type==="text_area"?se({kind:"textarea",id:n,value:String(i),onChange:s=>o(s)}).el:t.type==="int"||t.type==="float"||t.type==="price"?se({kind:"number",id:n,value:Number(i),min:t.min,max:t.max,step:t.step??(t.type==="int"?1:.1),integer:t.type==="int",commit:"blur",onChange:s=>o(s)}).el:this.buildTextField(n,String(i),o)}buildTextField(e,t,n){return se({kind:"text",id:e,value:t,onChange:n}).el}infoButton(e){let{el:t,dispose:n}=sl(e,{host:this.host.container,theme:()=>this.host.theme(),size:18});return this.dialogTips.push(n),t}select(e,t,n,i){return this.selectPairs(e,t.map(o=>({value:o,label:o})),n,i)}selectPairs(e,t,n,i){return se({kind:"select",id:e,options:t,value:n,theme:this.host.theme(),list:this.listPopover(),onChange:i}).el}buildSession(e,t,n){let[i,o]=IE(t),s=document.createElement("div");s.style.cssText="display:flex;align-items:center;gap:6px;";let a=i,l=o,c=()=>n(AE(a,l));return s.append(this.timeCombobox(e,a,86,u=>{a=u,c();}),this.timeCombobox(`${e}-end`,l,86,u=>{l=u,c();})),s}buildTime(e,t,n){let i=RE(t),o=document.createElement("div");o.style.cssText="display:flex;align-items:center;gap:6px;";let s=i.date,a=i.time,l=()=>{if(!s)return;let d=Date.parse(`${s}T${a}:00`);Number.isFinite(d)&&n(d);},c=this.dateField(e,s,d=>{s=d,l();}),u=this.timeCombobox(`${e}-time`,a,86,d=>{a=d,l();});return o.append(c,u),o}timeCombobox(e,t,n,i){let o=document.createElement("div");o.className="vela-ind-combo",o.style.cssText=`position:relative;width:${n}px;`;let s=document.createElement("input");s.type="text",s.id=e,s.value=t,s.autocomplete="off",s.spellcheck=false,s.style.cssText=`${this.ctrlStyle()}padding-right:26px;`;let a=document.createElement("button");a.type="button",a.tabIndex=-1,a.className="vela-ind-combo-chevron",a.setAttribute("aria-label","Open time list"),a.innerHTML=CE;let l=t,c=()=>{let p=PE(s.value);if(!p){s.value=l;return}s.value=p,p!==l&&(l=p,i(p));};s.addEventListener("blur",()=>{en()||c();});let u=p=>{l=p,s.value=p,i(p);},d=()=>{this.choicePop=Wl(o,kE,l,u,{...this.listPopover(),onClose:()=>{this.choicePop=null;}});};s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),c(),s.blur()),p.key==="ArrowDown"&&(p.preventDefault(),d());});let h=p=>{p.preventDefault(),p.stopPropagation(),d();};return s.addEventListener("click",h),a.addEventListener("mousedown",p=>p.preventDefault()),a.addEventListener("click",h),o.append(s,a),o}dateField(e,t,n){let i=document.createElement("div");i.className="vela-ind-combo",i.style.cssText="position:relative;width:128px;";let o=document.createElement("input");o.type="text",o.id=e,o.value=t,o.autocomplete="off",o.spellcheck=false,o.style.cssText=`${this.ctrlStyle()}padding-right:26px;`;let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="vela-ind-combo-chevron",s.setAttribute("aria-label","Open calendar"),s.innerHTML=SE;let a=t,l=()=>{let d=ty(o.value);if(!d){o.value=a;return}o.value=d,d!==a&&(a=d,n(d));};o.addEventListener("blur",()=>{en()||l();});let c=d=>{a=d,o.value=d,n(d);};o.addEventListener("keydown",d=>{d.key==="Enter"&&(d.preventDefault(),l(),o.blur()),d.key==="ArrowDown"&&(d.preventDefault(),this.openCalendar(i,a,c));});let u=d=>{if(d.preventDefault(),d.stopPropagation(),vn()===i){Te();return}this.openCalendar(i,a,c);};return o.addEventListener("click",u),s.addEventListener("mousedown",d=>d.preventDefault()),s.addEventListener("click",u),i.append(o,s),i}listPopover(){return {theme:this.host.theme(),matchWidth:true,boundary:this.dialog??"viewport",boundaryInset:8,gap:4}}openCalendar(e,t,n){let i=LE(t),o=i?.getFullYear()??new Date().getFullYear(),s=i?.getMonth()??new Date().getMonth(),a=i?rh(i):t,l=new $e({trigger:e,theme:this.host.theme(),className:"vela-ind-cal",boundary:this.dialog??"viewport",boundaryInset:8,gap:4,onClose:()=>{this.calendarPop=null,this.calendarAnchor=null;},content:c=>{let u=document.createElement("div");u.className="vela-ind-cal-title";let d=document.createElement("button");d.type="button",d.className="vela-ind-cal-nav",d.setAttribute("aria-label","Previous month"),d.innerHTML=ye("chevron-left",14);let h=document.createElement("button");h.type="button",h.className="vela-ind-cal-nav",h.setAttribute("aria-label","Next month"),h.innerHTML=ye("chevron-right",14);let p=document.createElement("div");p.className="vela-ind-cal-head",p.append(d,u,h);let m=document.createElement("div");m.className="vela-ind-cal-week";for(let b of ME){let y=document.createElement("span");y.textContent=b,m.appendChild(y);}let f=document.createElement("div");f.className="vela-ind-cal-grid";let g=()=>{u.textContent=`${EE[s]} ${o}`,f.replaceChildren();let y=new Date(o,s,1).getDay(),v=new Date(o,s+1,0).getDate(),S=rh(new Date);for(let E=0;E<y;E++){let T=document.createElement("span");T.className="vela-ind-cal-blank",f.appendChild(T);}for(let E=1;E<=v;E++){let T=`${o}-${String(s+1).padStart(2,"0")}-${String(E).padStart(2,"0")}`,k=document.createElement("button");k.type="button",k.className="vela-ind-cal-day",k.textContent=String(E),T===a&&(k.dataset.checked="1"),T===S&&(k.dataset.today="1"),k.addEventListener("click",x=>{x.stopPropagation(),l.hide(),n(T);}),f.appendChild(k);}};d.addEventListener("click",b=>{b.stopPropagation(),s-=1,s<0&&(s=11,o-=1),g();}),h.addEventListener("click",b=>{b.stopPropagation(),s+=1,s>11&&(s=0,o+=1),g();}),g(),c.append(p,m,f);}});this.calendarPop=l,this.calendarAnchor=e,l.show();}buildSymbol(e,t,n){let i=this.host.symbolPicker();if(!i)return this.buildTextField(e,t,n);let o=t,s=document.createElement("button");s.type="button",s.id=e,s.style.cssText=`${this.ctrlStyle()}display:flex;align-items:center;cursor:pointer;text-align:left;`;let a=document.createElement("span");return a.textContent=o||"Select symbol\u2026",a.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",s.append(a),s.addEventListener("click",()=>i(o,l=>{l&&(o=l,a.textContent=l,n(l));})),s}ctrlStyle(){return "width:100%;box-sizing:border-box;height:34px;background:transparent;border:1px solid var(--vela-border-strong);color:var(--vela-fg-bright);border-radius:6px;padding:0 8px;font-size:14px;font-family:inherit;outline:none;"}isDarkTheme(){return lt(this.host.theme().background)}dialogButton(e,t,n){let i=document.createElement("button");return i.type="button",i.textContent=e,i.className=t?"vela-dialog-btn vela-dialog-btn-primary":"vela-dialog-btn",i.addEventListener("click",n),i}};function oc(r){let e=r.title;return e.length>0?e.charAt(0).toUpperCase()+e.slice(1):""}var qv=16;function vE(r){return `padding:16px 20px;overflow-y:auto;overflow-x:hidden;overflow-anchor:none;flex:1 1 auto;display:grid;grid-template-columns:${Qo("inputs",r)};align-items:center;align-content:start;column-gap:${qv}px;row-gap:${qv}px;`}var sc="Inputs";function yE(r){let e=new Map;for(let n of r){let i=n.tab&&n.tab.length>0?n.tab:sc;e.has(i)||e.set(i,[]),e.get(i).push(n);}let t=[...e.keys()];return t.includes(sc)&&(t.splice(t.indexOf(sc),1),t.unshift(sc)),t.map(n=>({name:n,inputs:e.get(n)}))}function Zv(r,e){return r.some(t=>Ko(t.when,e))}function wE(r){let e={};for(let t of r.inputs)e[t.key]=r.values[t.key]??t.defval;return e}function xE(r){let e=[],t=new Map;for(let n of r){let i=n.group&&n.group.length>0?n.group:null;t.has(i)||(t.set(i,[]),e.push(i)),t.get(i).push(n);}return e.map(n=>{let i=t.get(n),o=[],s=new Map;for(let a of i){let l=a.inline&&a.inline.length>0?a.inline:null;l&&s.has(l)?o[s.get(l)].push(a):(l&&s.set(l,o.length),o.push([a]));}return {name:n,rows:o}})}var SE=ye("calendar",14),CE=ye("clock",14),Jv="vela-ind-dialog-styles",Qv="29",ey=16;function lc(){if(typeof document>"u")return;let r=document.getElementById(Jv);if(r?.dataset.rev===Qv)return;let e=r??document.createElement("style");e.id=Jv,e.dataset.rev=Qv,e.textContent=`
|
|
733
|
-
.vela-ind-combo input{${
|
|
732
|
+
`;function sc(r=document){he(Zv,Jv,r);}function ns(r={}){sc();let e=document.createElement("div");e.className="vela-field-grid";let t=r.variant??"inputs";return e.dataset.variant=t,r.mobile&&(e.dataset.mobile=""),e.style.gridTemplateColumns=es(t,r.mobile===true),e}function xn(r,e={}){sc();let t=document.createElement("div");return t.className="vela-field-section",e.variant&&(t.dataset.variant=e.variant),e.first&&(t.dataset.first=""),t.textContent=r,t}function oh(){sc();let r=document.createElement("div");return r.className="vela-field-sep",r}function ts(r,e){let t=document.createElement("span");t.className="vela-field-label",e.size&&(t.dataset.size=e.size),t.textContent=r;let n=e.id;return n&&(t.id=`${n}--title`,queueMicrotask(()=>{t.ownerDocument.getElementById(n)?.setAttribute("aria-labelledby",t.id);})),t}function Qv(r){return r?Array.isArray(r)?r:[r]:[]}function oc(r,e){if(e)for(let t of e.split(/\s+/))t&&r.classList.add(t);}function ih(r,e){for(let t of r)t.dataset.sdSelfGated!=="1"&&t.classList.toggle("vela-field-dim",!e);}function Ae(r){sc();let e=r.labelSize;if(r.inline){let o=document.createElement("div");o.className="vela-field-span vela-field-inline";for(let s of r.inline){let a=document.createElement("div");if(a.className="vela-field-inline-item",s.toggleFirst&&(a.style.flexDirection="row-reverse"),s.label&&a.appendChild(ts(s.label,{id:s.id,size:e})),s.fit)a.appendChild(s.control);else {let l=document.createElement("div");l.style.width="100px",l.appendChild(s.control),a.appendChild(l);}o.appendChild(a);}return r.info&&o.appendChild(r.info),oc(o,r.className),o}if(r.bool){let o=document.createElement("div");o.className="vela-field-span vela-field-bool";let s=new Ar({id:r.toggle?.id??r.id,checked:r.toggle?.checked??false,size:"md",tone:"bright",onChange:a=>r.toggle?.onChange(a)});if(o.append(s.el,ts(r.label,{id:r.toggle?.id??r.id,size:e})),r.info&&o.appendChild(r.info),r.toggle?.get){let a=r.toggle.get;o.addEventListener("vela-sync",()=>{s.setChecked(a());});}return oc(o,r.className),o}if(r.stacked){let o=document.createElement("div");o.className="vela-field-span vela-field-stacked";let s=document.createElement("div");s.className="vela-field-stacked-head",s.appendChild(ts(r.label,{id:r.id,size:e})),r.info&&s.appendChild(r.info),o.appendChild(s);for(let a of Qv(r.control))o.appendChild(a);return oc(o,r.className),o}let t=document.createElement("div");t.className="vela-field-row";let n=Qv(r.control);if(r.toggle){let o=document.createElement("div");o.className="vela-field-toggle-label";let s=new Ar({id:r.toggle.id??r.id,checked:r.toggle.checked,size:"md",tone:"bright",onChange:a=>{r.toggle.onChange(a),n.length>0&&ih(n,a);}});if(o.append(s.el,ts(r.label,{id:r.toggle.id??r.id,size:e})),t.appendChild(o),n.length>0&&ih(n,r.toggle.checked),r.toggle.get){let a=r.toggle.get;t.addEventListener("vela-sync",()=>{let l=a();s.setChecked(l),n.length>0&&ih(n,l);});}}else t.appendChild(ts(r.label,{id:r.id,size:e}));let i=document.createElement("div");if(i.className="vela-field-cell",r.controlWidth!=null&&n.length===1&&!r.fit){let o=document.createElement("div");o.style.width=`${r.controlWidth}px`,o.appendChild(n[0]),i.appendChild(o);}else for(let o of n)i.appendChild(o);return r.info&&i.appendChild(r.info),t.appendChild(i),oc(t,r.className),t}function se(r){if(r.kind==="number"){let t=new Rr({id:r.id,value:r.value,min:r.min,max:r.max,step:r.step,integer:r.integer,size:"md",fill:r.fill,compact:r.compact,commit:r.commit,steppers:r.steppers,clamp:r.clamp,placeholder:r.placeholder,emptyValue:r.emptyValue,title:r.title,onChange:r.onChange});if(r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(Number(n))}}if(r.kind==="select"){let t=new jo({id:r.id,options:r.options,value:r.value,size:"md",fill:r.fill,theme:r.theme,list:r.list,onChange:r.onChange});if(r.title&&(t.el.title=r.title),r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(String(n))}}if(r.kind==="switch"){let t=new Ar({id:r.id,checked:r.checked,size:"md",tone:"bright",onChange:r.onChange});if(r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setChecked(n());});}return {el:t.el,setValue:n=>t.setChecked(!!n)}}if(r.kind==="color"){let t=th(r.theme,r.get,r.onChange,{shape:"circle",id:r.id,popover:r.popover});return r.title&&(t.title=r.title),{el:t}}if(r.kind==="text"){let t=new Jo({id:r.id,value:r.value,size:"md",fill:r.fill,onChange:r.onChange});if(r.placeholder&&(t.input.placeholder=r.placeholder),r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(String(n))}}if(r.kind==="textarea"){let t=new Dr({id:r.id,value:r.value,rows:r.rows,autoGrow:r.autoGrow,maxLines:r.maxLines,placeholder:r.placeholder,onChange:r.onChange});if(r.sync){let n=r.sync;t.el.addEventListener("vela-sync",()=>{t.setValue(n());});}return {el:t.el,setValue:n=>t.setValue(String(n))}}let e=nh(r.theme,r.get,r.onChange);return r.title&&(e.title=r.title),{el:e}}var ey="Properties";function ac(r,e){return e.prop?r.propValues:r.values}var CE=["close","open","high","low","hl2","hlc3","ohlc4","volume"],uc=class{constructor(e){this.host=e;this.dialog=null;this.backdrop=null;this.uiDialog=null;this.openId=null;this.row=null;this.snapshot=null;this.propSnapshot=null;this.dialogTips=[];this.refreshVisibility=null;this.choicePop=null;this.calendarPop=null;this.calendarAnchor=null;this.onDialogKey=e=>{if(e.key==="Escape"){if(e.preventDefault(),tn()){Te();return}this.close();}};}isOpen(){return this.dialog!==null}open(e){if(this.close(),e.inputs.length===0&&e.props.length===0)return;this.row=e,this.openId=e.id,this.snapshot={...e.values},this.propSnapshot={...e.propValues},dc();let t=this.host.theme(),n="var(--vela-border)",i="var(--vela-fg-bright)",o=this.host.dialogHost()??this.host.container,s=new wn({host:o,title:e.title,modal:false,contained:true,align:"center",draggable:!this.host.mobile(),flush:true,className:"vela-dialog--form vela-ind-dialog",closeOnEscape:false,footer:g=>{g.append(this.resetAction(),this.dialogButton("Cancel",false,()=>this.revertAndClose()),this.dialogButton("Ok",true,()=>this.close()));},onOpenChange:g=>{!g&&this.uiDialog===s&&this.close();}});Re(s.panel,t),s.panel.style.colorScheme=this.isDarkTheme()?"dark":"light",this.dialogTips.push(Kt(s.panel.querySelector(".vela-dialog-close"),{host:this.host.container,theme:()=>this.host.theme(),text:()=>"Close"}));let a=kE(e.inputs);if(e.props.length>0){let g=e.props.map(y=>{let v={...y,prop:true};return delete v.tab,v}),b=a.find(y=>y.name===ey);b?b.inputs.push(...g):a.push({name:ey,inputs:g});}let l=document.createElement("div");l.style.cssText=`display:flex;gap:12px;padding:0 20px;border-bottom:1px solid ${n};flex:0 0 auto;`;let c=[],u=[],d=[],h=0,p=g=>{h=g;for(let b=0;b<c.length;b+=1){let y=b===g,v=c[b];v.style.borderBottomColor=y?i:"transparent",v.style.color=y?"inherit":"var(--vela-fg-muted)",v.classList.toggle("vela-ind-tab-active",y),u[b].style.display=y?"grid":"none";}};for(let[g,b]of a.entries()){let y=document.createElement("div");y.textContent=b.name,y.className="vela-ind-tab",y.style.cssText=`padding:0 0 8px;margin-bottom:-1px;border-bottom:2px solid transparent;${a.length>1?"cursor:pointer;":""}`,y.addEventListener("click",()=>p(g)),l.appendChild(y),c.push(y),u.push(this.buildTabBody(b.inputs,e,d)),b.inputs.every(v=>v.when)&&d.push({el:y,visible:v=>b.inputs.some(S=>Xo(S.when,v))});}s.body.appendChild(l);for(let g of u)s.body.appendChild(g);p(0);let m=()=>{let g=EE(e);for(let b of d)b.el.style.display=b.visible(g)?"":"none";if(c[h]?.style.display==="none"){let b=c.findIndex(y=>y.style.display!=="none");b>=0&&p(b);}};this.refreshVisibility=m,m();let f=g=>{if(!(g.target!==s.backdrop&&g.target!==s.positioner)){if(tn()||Ir(g)){Te();return}this.close(),this.host.onBackdropClose();}};s.backdrop.addEventListener("pointerdown",f),s.positioner.addEventListener("pointerdown",f),this.uiDialog=s,this.dialog=s.panel,this.backdrop=s.backdrop,s.show(),document.addEventListener("keydown",this.onDialogKey);}buildTabBody(e,t,n){let i=document.createElement("div");i.style.cssText=TE(this.host.mobile());for(let o of LE(e)){let s=document.createElement("div");s.style.cssText="display:contents;";let a=null;o.name&&(a=xn(o.name,{variant:"inputs",first:i.childElementCount===0}),s.appendChild(a));for(let l of o.rows){let c=this.buildInputRow(s,l,t);l.some(u=>u.when)&&n.push({el:c,visible:u=>ny(l,u)});}if(a&&o.rows.every(l=>l.every(c=>c.when))){let l=o.rows;n.push({el:a,visible:c=>l.some(u=>ny(u,c))});}i.appendChild(s);}return i}close(){document.removeEventListener("keydown",this.onDialogKey),Te(),this.refreshVisibility=null,this.choicePop=null,this.calendarPop=null,this.calendarAnchor=null;for(let t of this.dialogTips.splice(0))t();let e=this.uiDialog;this.uiDialog=null,this.backdrop=null,this.dialog=null,this.openId=null,this.row=null,this.snapshot=null,this.propSnapshot=null,e?.destroy();}revertAndClose(){let e=this.row,t=this.snapshot;if(e&&t)for(let i of e.inputs){let o=t[i.key],s=o!==void 0?o:i.defval;e.values[i.key]!==s&&(e.values[i.key]=s,this.host.onChange?.({indicatorId:e.id,key:i.key,value:s}));}let n=this.propSnapshot;if(e&&n)for(let i of e.props){let o=n[i.key],s=o!==void 0?o:i.defval;e.propValues[i.key]!==s&&(e.propValues[i.key]=s,this.host.onChange?.({indicatorId:e.id,key:i.key,value:s,kind:"prop"}));}this.close();}resetAction(){let e=this.dialogButton("Reset defaults",false,()=>this.resetToDefaults());return e.style.marginRight="auto",e}resetToDefaults(){let e=this.row;if(!e)return;let t=this.snapshot,n=this.propSnapshot;for(let i of e.inputs)e.values[i.key]!==i.defval&&(e.values[i.key]=i.defval,this.host.onChange?.({indicatorId:e.id,key:i.key,value:i.defval}));for(let i of e.props)e.propValues[i.key]!==i.defval&&(e.propValues[i.key]=i.defval,this.host.onChange?.({indicatorId:e.id,key:i.key,value:i.defval,kind:"prop"}));this.open(e),t&&(this.snapshot=t),n&&(this.propSnapshot=n);}commit(e,t,n){ac(e,t)[t.key]=n,this.host.onChange?.({indicatorId:e.id,key:t.key,value:n,...t.prop?{kind:"prop"}:{}}),this.refreshVisibility?.();}buildInputRow(e,t,n){let i=u=>`vela-inp-${n.id}-${u.key}`,o=u=>(e.appendChild(u),u);if(t.length>1)return o(Ae({label:"",inline:t.map(u=>({label:lc(u)||void 0,id:i(u),control:this.buildControl(n,u,i(u)),toggleFirst:u.type==="bool",fit:u.type==="color"||u.type==="bool"})),info:[...t].reverse().find(u=>u.tooltip)?.tooltip?this.infoButton([...t].reverse().find(u=>u.tooltip).tooltip):void 0}));let s=t[0],a=i(s),l=s.tooltip?this.infoButton(s.tooltip):void 0;if(s.type==="bool"){let u=!!(ac(n,s)[s.key]??s.defval);return o(Ae({label:lc(s),id:a,bool:true,info:l,toggle:{id:a,checked:u,onChange:d=>this.commit(n,s,d)}}))}if(s.type==="text_area")return o(Ae({label:lc(s),id:a,stacked:true,info:l,control:this.buildControl(n,s,a)}));let c=s.type==="color"||s.type==="session"||s.type==="time";return o(Ae({label:lc(s),id:a,fit:c,controlWidth:c?void 0:100,info:l,control:this.buildControl(n,s,a)}))}buildControl(e,t,n){let i=ac(e,t)[t.key]??t.defval,o=s=>this.commit(e,t,s);return t.type==="bool"?se({kind:"switch",id:n,checked:!!i,onChange:s=>o(s)}).el:t.options&&t.options.length>0?this.select(n,t.options.map(String),String(i),o):t.type==="source"?this.select(n,CE,String(i),o):t.type==="color"?se({kind:"color",id:n,theme:this.host.theme(),get:()=>String(ac(e,t)[t.key]??t.defval),onChange:s=>o(s)}).el:t.type==="symbol"?this.buildSymbol(n,String(i),o):t.type==="timeframe"?this.selectPairs(n,IE,String(i),o):t.type==="session"?this.buildSession(n,String(i),o):t.type==="time"?this.buildTime(n,Number(i)||0,o):t.type==="text_area"?se({kind:"textarea",id:n,value:String(i),onChange:s=>o(s)}).el:t.type==="int"||t.type==="float"||t.type==="price"?se({kind:"number",id:n,value:Number(i),min:t.min,max:t.max,step:t.step??(t.type==="int"?1:.1),integer:t.type==="int",commit:"blur",onChange:s=>o(s)}).el:this.buildTextField(n,String(i),o)}buildTextField(e,t,n){return se({kind:"text",id:e,value:t,onChange:n}).el}infoButton(e){let{el:t,dispose:n}=ll(e,{host:this.host.container,theme:()=>this.host.theme(),size:18});return this.dialogTips.push(n),t}select(e,t,n,i){return this.selectPairs(e,t.map(o=>({value:o,label:o})),n,i)}selectPairs(e,t,n,i){return se({kind:"select",id:e,options:t,value:n,theme:this.host.theme(),list:this.listPopover(),onChange:i}).el}buildSession(e,t,n){let[i,o]=FE(t),s=document.createElement("div");s.style.cssText="display:flex;align-items:center;gap:6px;";let a=i,l=o,c=()=>n(VE(a,l));return s.append(this.timeCombobox(e,a,86,u=>{a=u,c();}),this.timeCombobox(`${e}-end`,l,86,u=>{l=u,c();})),s}buildTime(e,t,n){let i=_E(t),o=document.createElement("div");o.style.cssText="display:flex;align-items:center;gap:6px;";let s=i.date,a=i.time,l=()=>{if(!s)return;let d=Date.parse(`${s}T${a}:00`);Number.isFinite(d)&&n(d);},c=this.dateField(e,s,d=>{s=d,l();}),u=this.timeCombobox(`${e}-time`,a,86,d=>{a=d,l();});return o.append(c,u),o}timeCombobox(e,t,n,i){let o=document.createElement("div");o.className="vela-ind-combo",o.style.cssText=`position:relative;width:${n}px;`;let s=document.createElement("input");s.type="text",s.id=e,s.value=t,s.autocomplete="off",s.spellcheck=false,s.style.cssText=`${this.ctrlStyle()}padding-right:26px;`;let a=document.createElement("button");a.type="button",a.tabIndex=-1,a.className="vela-ind-combo-chevron",a.setAttribute("aria-label","Open time list"),a.innerHTML=PE;let l=t,c=()=>{let p=NE(s.value);if(!p){s.value=l;return}s.value=p,p!==l&&(l=p,i(p));};s.addEventListener("blur",()=>{tn()||c();});let u=p=>{l=p,s.value=p,i(p);},d=()=>{this.choicePop=Yl(o,AE,l,u,{...this.listPopover(),onClose:()=>{this.choicePop=null;}});};s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),c(),s.blur()),p.key==="ArrowDown"&&(p.preventDefault(),d());});let h=p=>{p.preventDefault(),p.stopPropagation(),d();};return s.addEventListener("click",h),a.addEventListener("mousedown",p=>p.preventDefault()),a.addEventListener("click",h),o.append(s,a),o}dateField(e,t,n){let i=document.createElement("div");i.className="vela-ind-combo",i.style.cssText="position:relative;width:128px;";let o=document.createElement("input");o.type="text",o.id=e,o.value=t,o.autocomplete="off",o.spellcheck=false,o.style.cssText=`${this.ctrlStyle()}padding-right:26px;`;let s=document.createElement("button");s.type="button",s.tabIndex=-1,s.className="vela-ind-combo-chevron",s.setAttribute("aria-label","Open calendar"),s.innerHTML=ME;let a=t,l=()=>{let d=sy(o.value);if(!d){o.value=a;return}o.value=d,d!==a&&(a=d,n(d));};o.addEventListener("blur",()=>{tn()||l();});let c=d=>{a=d,o.value=d,n(d);};o.addEventListener("keydown",d=>{d.key==="Enter"&&(d.preventDefault(),l(),o.blur()),d.key==="ArrowDown"&&(d.preventDefault(),this.openCalendar(i,a,c));});let u=d=>{if(d.preventDefault(),d.stopPropagation(),yn()===i){Te();return}this.openCalendar(i,a,c);};return o.addEventListener("click",u),s.addEventListener("mousedown",d=>d.preventDefault()),s.addEventListener("click",u),i.append(o,s),i}listPopover(){return {theme:this.host.theme(),matchWidth:true,boundary:this.dialog??"viewport",boundaryInset:8,gap:4}}openCalendar(e,t,n){let i=OE(t),o=i?.getFullYear()??new Date().getFullYear(),s=i?.getMonth()??new Date().getMonth(),a=i?sh(i):t,l=new $e({trigger:e,theme:this.host.theme(),className:"vela-ind-cal",boundary:this.dialog??"viewport",boundaryInset:8,gap:4,onClose:()=>{this.calendarPop=null,this.calendarAnchor=null;},content:c=>{let u=document.createElement("div");u.className="vela-ind-cal-title";let d=document.createElement("button");d.type="button",d.className="vela-ind-cal-nav",d.setAttribute("aria-label","Previous month"),d.innerHTML=ye("chevron-left",14);let h=document.createElement("button");h.type="button",h.className="vela-ind-cal-nav",h.setAttribute("aria-label","Next month"),h.innerHTML=ye("chevron-right",14);let p=document.createElement("div");p.className="vela-ind-cal-head",p.append(d,u,h);let m=document.createElement("div");m.className="vela-ind-cal-week";for(let b of DE){let y=document.createElement("span");y.textContent=b,m.appendChild(y);}let f=document.createElement("div");f.className="vela-ind-cal-grid";let g=()=>{u.textContent=`${RE[s]} ${o}`,f.replaceChildren();let y=new Date(o,s,1).getDay(),v=new Date(o,s+1,0).getDate(),S=sh(new Date);for(let E=0;E<y;E++){let T=document.createElement("span");T.className="vela-ind-cal-blank",f.appendChild(T);}for(let E=1;E<=v;E++){let T=`${o}-${String(s+1).padStart(2,"0")}-${String(E).padStart(2,"0")}`,k=document.createElement("button");k.type="button",k.className="vela-ind-cal-day",k.textContent=String(E),T===a&&(k.dataset.checked="1"),T===S&&(k.dataset.today="1"),k.addEventListener("click",x=>{x.stopPropagation(),l.hide(),n(T);}),f.appendChild(k);}};d.addEventListener("click",b=>{b.stopPropagation(),s-=1,s<0&&(s=11,o-=1),g();}),h.addEventListener("click",b=>{b.stopPropagation(),s+=1,s>11&&(s=0,o+=1),g();}),g(),c.append(p,m,f);}});this.calendarPop=l,this.calendarAnchor=e,l.show();}buildSymbol(e,t,n){let i=this.host.symbolPicker();if(!i)return this.buildTextField(e,t,n);let o=t,s=document.createElement("button");s.type="button",s.id=e,s.style.cssText=`${this.ctrlStyle()}display:flex;align-items:center;cursor:pointer;text-align:left;`;let a=document.createElement("span");return a.textContent=o||"Select symbol\u2026",a.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",s.append(a),s.addEventListener("click",()=>i(o,l=>{l&&(o=l,a.textContent=l,n(l));})),s}ctrlStyle(){return "width:100%;box-sizing:border-box;height:34px;background:transparent;border:1px solid var(--vela-border-strong);color:var(--vela-fg-bright);border-radius:6px;padding:0 8px;font-size:14px;font-family:inherit;outline:none;"}isDarkTheme(){return lt(this.host.theme().background)}dialogButton(e,t,n){let i=document.createElement("button");return i.type="button",i.textContent=e,i.className=t?"vela-dialog-btn vela-dialog-btn-primary":"vela-dialog-btn",i.addEventListener("click",n),i}};function lc(r){let e=r.title;return e.length>0?e.charAt(0).toUpperCase()+e.slice(1):""}var ty=16;function TE(r){return `padding:16px 20px;overflow-y:auto;overflow-x:hidden;overflow-anchor:none;flex:1 1 auto;display:grid;grid-template-columns:${es("inputs",r)};align-items:center;align-content:start;column-gap:${ty}px;row-gap:${ty}px;`}var cc="Inputs";function kE(r){let e=new Map;for(let n of r){let i=n.tab&&n.tab.length>0?n.tab:cc;e.has(i)||e.set(i,[]),e.get(i).push(n);}let t=[...e.keys()];return t.includes(cc)&&(t.splice(t.indexOf(cc),1),t.unshift(cc)),t.map(n=>({name:n,inputs:e.get(n)}))}function ny(r,e){return r.some(t=>Xo(t.when,e))}function EE(r){let e={};for(let t of r.inputs)e[t.key]=r.values[t.key]??t.defval;return e}function LE(r){let e=[],t=new Map;for(let n of r){let i=n.group&&n.group.length>0?n.group:null;t.has(i)||(t.set(i,[]),e.push(i)),t.get(i).push(n);}return e.map(n=>{let i=t.get(n),o=[],s=new Map;for(let a of i){let l=a.inline&&a.inline.length>0?a.inline:null;l&&s.has(l)?o[s.get(l)].push(a):(l&&s.set(l,o.length),o.push([a]));}return {name:n,rows:o}})}var ME=ye("calendar",14),PE=ye("clock",14),ry="vela-ind-dialog-styles",iy="29",oy=16;function dc(){if(typeof document>"u")return;let r=document.getElementById(ry);if(r?.dataset.rev===iy)return;let e=r??document.createElement("style");e.id=ry,e.dataset.rev=iy,e.textContent=`
|
|
733
|
+
.vela-ind-combo input{${og}}
|
|
734
734
|
.vela-ind-combo input:hover{border-color:var(--vela-fg-muted);}
|
|
735
|
-
.vela-ind-combo input:focus{${
|
|
735
|
+
.vela-ind-combo input:focus{${sg}}
|
|
736
736
|
.vela-ind-combo-chevron{position:absolute;right:0;top:0;bottom:0;width:26px;border:none;background:transparent;color:inherit;opacity:0.55;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;}
|
|
737
737
|
.vela-ind-combo-chevron:hover{opacity:0.9;}
|
|
738
738
|
.vela-ind-cal{background:var(--vela-bg);color:var(--vela-fg);border:none;border-radius:6px;box-shadow:var(--vela-shadow);font:14px var(--vela-font);padding:10px 12px;user-select:none;}
|
|
@@ -748,24 +748,24 @@ ${xr(".vela-dialog *")}
|
|
|
748
748
|
.vela-ind-cal-day:hover{background:var(--vela-hover);}
|
|
749
749
|
.vela-ind-cal-day[data-checked]{background:var(--vela-hover-strong);color:var(--vela-fg-bright);}
|
|
750
750
|
.vela-ind-cal-day[data-today]:not([data-checked]){box-shadow:inset 0 0 0 1px var(--vela-border-strong);}
|
|
751
|
-
${
|
|
751
|
+
${Sr(".vela-dialog.vela-ind-dialog *",9)}
|
|
752
752
|
.vela-ind-tab{font-weight:600;font-size:13px;line-height:20px;transition:color var(--vela-dur-fast) ease,border-color var(--vela-dur-fast) ease;}
|
|
753
753
|
.vela-ind-tab:not(.vela-ind-tab-active):hover{color:var(--vela-fg-bright);}
|
|
754
754
|
.vela-ind-ctl,.vela-ind-close{background-color:transparent;color:inherit;transition:color var(--vela-dur-fast) ease,background-color var(--vela-dur-fast) ease;}
|
|
755
|
-
.vela-ind-ctl svg,.vela-ind-close svg{width:${
|
|
755
|
+
.vela-ind-ctl svg,.vela-ind-close svg{width:${oy}px;height:${oy}px;display:block;flex:none;stroke-width:1;}
|
|
756
756
|
.vela-ind-ctl:hover{background-color:var(--vela-hover-strong);}
|
|
757
757
|
.vela-ind-close:hover{color:var(--vela-danger) !important;background-color:var(--vela-hover-strong);}
|
|
758
758
|
.vela-ind-fold{transition:border-color var(--vela-dur-fast) ease,opacity var(--vela-dur-fast) ease;}
|
|
759
|
-
.vela-ind-fold:hover{border-color:var(--vela-border-strong);opacity:0.9;}`,r||document.head.appendChild(e);}var TE=[{value:"",label:"Chart"},{value:"1",label:"1 minute"},{value:"3",label:"3 minutes"},{value:"5",label:"5 minutes"},{value:"15",label:"15 minutes"},{value:"30",label:"30 minutes"},{value:"45",label:"45 minutes"},{value:"60",label:"1 hour"},{value:"120",label:"2 hours"},{value:"180",label:"3 hours"},{value:"240",label:"4 hours"},{value:"D",label:"1 day"},{value:"W",label:"1 week"},{value:"M",label:"1 month"}],kE=Array.from({length:48},(r,e)=>{let t=String(Math.floor(e/2)).padStart(2,"0"),n=e%2===0?"00":"30",i=`${t}:${n}`;return {value:i,label:i}}),EE=["January","February","March","April","May","June","July","August","September","October","November","December"],ME=["Su","Mo","Tu","We","Th","Fr","Sa"];function ty(r){let e=r.trim(),t=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(e);if(!t)return null;let n=Number(t[1]),i=Number(t[2]),o=Number(t[3]),s=new Date(n,i-1,o);return s.getFullYear()!==n||s.getMonth()!==i-1||s.getDate()!==o?null:rh(s)}function LE(r){let e=ty(r);if(!e)return null;let[t,n,i]=e.split("-").map(Number);return new Date(t,n-1,i)}function rh(r){return `${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function PE(r){let e=r.trim(),t=/^(\d{1,2}):(\d{2})$/.exec(e)??/^(\d{2})(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),i=Number(t[2]);return n>23||i>59?null:`${String(n).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function IE(r){let e=/^(\d{2})(\d{2})-(\d{2})(\d{2})$/.exec(r.trim());return e?[`${e[1]}:${e[2]}`,`${e[3]}:${e[4]}`]:["09:00","16:00"]}function AE(r,e){return `${r.replace(":","")}-${e.replace(":","")}`}function RE(r){if(!r)return {date:"",time:"09:30"};let e=r<1e12?r*1e3:r,t=new Date(e);if(Number.isNaN(t.getTime()))return {date:"",time:"09:30"};let n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,i=Math.round((t.getHours()*60+t.getMinutes())/30)*30,o=String(Math.floor(i/60)%24).padStart(2,"0"),s=String(i%60).padStart(2,"0");return {date:n,time:`${o}:${s}`}}var DE="data-vela-pane-at-top",OE="@keyframes vela-ind-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.6)}}",xn=16,oh=18,sy=2,ny=6,NE=6,ih=8,ry=6,ns=`cursor:pointer;display:inline-flex;align-items:center;justify-content:center;border:none;line-height:0;padding:0;width:${oh}px;height:${oh}px;border-radius:3px;box-sizing:border-box;flex:none;`,FE=oh+sy*2,iy=ye("eye",xn),VE=ye("eye-off",xn),_E=ye("gear",xn),BE=ye("close",xn),HE=ye("chevron-up",xn),zE=ye("chevron-down",xn),$E=ye("objects",xn);function oy(r,e){return !r&&e?"inline-flex":"none"}var cc=class{constructor(e,t,n){this.container=e;this.theme=t;this.paneBoundsOf=n;this.legends=new Map;this.rows=new Map;this.selectedId=null;this.onChange=null;this.onRemove=null;this.onToggleVisible=null;this.symbolPicker=null;this.mobileLayout=false;this.moveApi=null;this.legendActions=null;this.legendCallouts=null;this.rowTips=new Map;this.extrasTips=new Map;this.calloutTips=new Map;this.moveMenu=null;this.moveTargets=[];this.moveMenuId=null;this.paneCollapse=new Map;this.legendFolded=false;this.titlesVisible=true;this.valuesVisible=true;this.rowMenu=null;this.rowMenuId=null;this.foldToggle=null;this.overviewAction=null;this.onDocClick=e=>{if(!this.selectedId)return;let t=e.target;if(t){for(let n of this.rows.values())if(n.el.contains(t))return}this.clearSelection();};this.dialogHost=null;e.style.position||(e.style.position="relative"),typeof document<"u"&&document.addEventListener("click",this.onDocClick),lc(),this.inputsDialog=new ac({container:e,theme:()=>this.theme,mobile:()=>this.mobileLayout,dialogHost:()=>this.dialogHost,symbolPicker:()=>this.symbolPicker,onChange:i=>this.onChange?.(i),onBackdropClose:()=>this.clearSelection()});}setDialogHost(e){this.dialogHost=e,e&&getComputedStyle(e).position==="static"&&(e.style.position="relative");}setLayoutMode(e){let t=e==="mobile";if(t!==this.mobileLayout&&(this.mobileLayout=t,this.overviewAction===null&&(this.legendFolded=t),this.syncFoldToggle(),this.inputsDialog.openId!==null)){let n=this.inputsDialog.openId;this.closeOpenDialog(),this.openDialog(n);}}setLegendOverviewAction(e){e!==this.overviewAction&&(this.overviewAction=e,this.legendFolded=e!==null?true:this.mobileLayout,this.syncFoldToggle());}openSettingsFor(e){this.rows.has(e)&&this.openDialog(e);}tip(e,t,n,i,o=false){let s=e.get(t)??[];s.push(Yt(n,{host:this.container,theme:()=>this.theme,text:typeof i=="function"?i:()=>i,wrap:o})),e.set(t,s);}disposeTips(e,t){for(let n of e.get(t)??[])n();e.delete(t);}setOnChange(e){this.onChange=e;}setOnRemove(e){this.onRemove=e;}setOnToggleVisible(e){this.onToggleVisible=e;}setTheme(e){this.theme=e;for(let t of this.legends.values())Re(t,e);for(let t of this.rows.values())t.el.style.background=t.highlighted?e.background:this.idleRowFill(),t.el.style.color=e.textColor;this.foldToggle&&this.syncFoldToggle();}setSymbolPicker(e){this.symbolPicker=e;}setMoveApi(e){this.moveApi=e;}setLegendActions(e){this.legendActions=e;for(let t of this.rows.values())this.renderExtras(t.id,t.extrasEl);}renderExtras(e,t){this.disposeTips(this.extrasTips,e),t.replaceChildren();for(let n of this.legendActions?.(e)??[]){let i=document.createElement("button");i.type="button",i.setAttribute("aria-label",n.tooltip),this.tip(this.extrasTips,e,i,n.tooltip),i.innerHTML=ye(n.icon,xn),i.className="vela-ind-ctl",i.dataset.legendAction=n.id,i.style.cssText=ns,i.addEventListener("click",o=>{o.stopPropagation(),n.run();}),t.appendChild(i);}}setLegendCallouts(e){this.legendCallouts=e;for(let t of this.rows.values())this.renderCallouts(t);}renderCallouts(e){this.disposeTips(this.calloutTips,e.id);for(let n of e.callouts)n.destroy();e.callouts=[],e.calloutsEl.replaceChildren();let t=this.legendCallouts?.(e.id)??[];e.calloutsEl.style.display=oy(e.highlighted,t.length>0);for(let n of t){let i=new Yo({icon:n.icon,background:n.background,...n.color!==void 0?{color:n.color}:{},label:n.tooltip,...n.content!==void 0?{panel:n.content}:{},host:this.container,theme:()=>this.theme});i.el.dataset.legendCallout=n.id,this.tip(this.calloutTips,e.id,i.el,n.tooltip),e.callouts.push(i),e.calloutsEl.appendChild(i.el);}}reposition(){for(let[e,t]of this.legends)this.positionLegend(t,e);}setTitlesVisible(e){this.titlesVisible!==e&&(this.titlesVisible=e,this.reposition());}setValuesVisible(e){this.valuesVisible=e;for(let t of this.rows.values())t.showValues=null,this.renderRowValues(t);}setPlotValues(e){for(let t of this.rows.values()){let n=e.get(t.id)??[],i=n.map(o=>`${o.value}|${o.color}`).join("\0");i!==t.plotValuesKey&&(t.plotValues=n,t.plotValuesKey=i,this.renderRowValues(t));}}rowValuesShown(e){return e.showValues??this.valuesVisible}renderRowValues(e){if(!this.rowValuesShown(e)||e.plotValues.length===0||e.highlighted){e.valuesEl.style.display="none",e.valuesEl.replaceChildren();return}e.valuesEl.style.display="inline-flex",e.valuesEl.replaceChildren();for(let t of e.plotValues){let n=document.createElement("span");n.textContent=t.value,n.style.color=t.color,e.valuesEl.appendChild(n);}}openMoveMenu(e,t){this.closeMoveMenu();let n=this.moveApi;if(!n)return;let o=this.rows.get(e)?.paneId??"price",s=n.panes(),a=[];for(let d of s)d.id!==o&&a.push({label:`Move to ${d.label}`,target:d.kind==="price"?"price":{pane:d.id}});o!=="price"&&[...this.rows.values()].filter(d=>d.paneId===o).length<=1||(o!=="price"&&a.push({label:"New pane above",target:{newPane:{before:o}}}),a.push({label:"New pane below",target:{newPane:{after:o}}})),this.moveTargets=a.map(d=>d.target),this.moveMenuId=e;let c=a.map((d,h)=>({id:String(h),label:d.label}));this.moveMenu?this.moveMenu.setItems(c):this.moveMenu=new wi({host:this.container,items:c,placement:"bottom-start",onSelect:d=>{let h=this.moveTargets[Number(d)],p=this.moveMenuId;h&&p&&n.move(p,h);}});let u=t.getBoundingClientRect();this.moveMenu.openAt(u.left,u.bottom+4);}closeMoveMenu(){this.moveMenu?.close();}openRowMenu(e,t,n){this.closeRowMenu(),this.closeMoveMenu();let i=this.rows.get(e);if(!i)return;this.rowMenuId=e;let o=[{id:"values",label:"Indicator values",checked:this.rowValuesShown(i)}];this.rowMenu?this.rowMenu.setItems(o):this.rowMenu=new wi({host:this.container,items:o,placement:"bottom-start",checkmarks:true,onSelect:s=>{if(s!=="values"||!this.rowMenuId)return;let a=this.rows.get(this.rowMenuId);a&&(a.showValues=!this.rowValuesShown(a),this.renderRowValues(a));}}),this.rowMenu.openAt(t,n);}closeRowMenu(){this.rowMenu?.close();}setPane(e,t){let n=this.rows.get(e);if(!n||n.paneId===t)return;let i=n.paneId;if(n.paneId=t,this.attach(this.legendFor(t),n.el,n.native),this.syncFoldToggle(),i!=="price"){let o=this.legends.get(i);o&&o.childElementCount===0&&(o.remove(),this.legends.delete(i));}}legendFor(e){let t=this.legends.get(e);return t||(t=document.createElement("div"),t.dataset.velaPane=e,t.style.cssText="position:absolute;left:10px;z-index:5;display:flex;flex-direction:column;align-items:flex-start;gap:0;pointer-events:none;font:12px -apple-system,Segoe UI,sans-serif;",Re(t,this.theme),this.positionLegend(t,e),this.container.appendChild(t),this.legends.set(e,t)),t}positionLegend(e,t){let n=this.paneBoundsOf?this.paneBoundsOf(t):{top:0,height:1/0};e.toggleAttribute(DE,n.top===0),e.style.display=n.height<4||!this.titlesVisible?"none":"flex";let i=this.paneCollapse.has(t),o=this.paneCollapse.get(t)??null;for(let a of this.rows.values())a.paneId===t&&(a.el.style.display=(i?a.id!==o:this.legendFolded)?"none":"flex");let s=n.top+8;if(i&&Number.isFinite(n.height)){let a=e.offsetHeight||20;s=n.top+Math.max(1,Math.round((n.height-a)/2));}e.style.top=`${s}px`;}setCollapsedPanes(e){this.paneCollapse=e;}syncFoldToggle(){let e=this.rows.size,t=this.overviewAction!==null||this.mobileLayout?1:2;if(e<t){let a=this.legendFolded;e>0&&(this.legendFolded=false),this.foldToggle&&(this.foldToggle.remove(),this.foldToggle=null,this.disposeTips(this.rowTips,"fold")),a&&e>0&&this.reposition();return}let n=this.foldToggle;n||(n=document.createElement("button"),n.type="button",n.className="vela-ind-fold",this.tip(this.rowTips,"fold",n,()=>this.overviewAction!==null?"Indicators":this.legendFolded?"Show indicator legend":"Hide indicator legend"),n.addEventListener("click",()=>{if(this.overviewAction!==null){this.overviewAction();return}this.legendFolded=!this.legendFolded,this.syncFoldToggle();}),this.foldToggle=n);let i=this.legendFolded;n.setAttribute("aria-label",this.overviewAction!==null?"Indicators":i?"Show indicator legend":"Hide indicator legend");let o=this.theme.textColor;n.style.cssText=`pointer-events:auto;display:inline-flex;align-items:center;gap:4px;background:${this.theme.background};color:${o};border:1px solid ${this.theme.borderColor};border-radius:4px;padding:2px 6px;margin-top:6px;cursor:pointer;font:inherit;line-height:0;`,n.replaceChildren();let s=document.createElement("span");if(s.style.cssText="display:inline-flex;align-items:center;line-height:0;opacity:0.7;",s.innerHTML=this.overviewAction!==null?$E:i?zE:HE,n.appendChild(s),i){let a=document.createElement("span");a.textContent=String(e),a.style.cssText=`font-weight:600;line-height:normal;font-size:12px;color:${o};`,n.appendChild(a);}this.legendFor("price").appendChild(n),this.reposition();}upsert(e,t,n,i,o="price",s={}){let a=this.rows.get(e);if(a){a.title=t,a.inputs=n,a.values={...i},a.props=s.props??[],a.propValues={...s.propValues??{}},a.titleEl.textContent=t,a.paneId!==o&&(a.paneId=o,this.attach(this.legendFor(o),a.el,a.native),this.syncFoldToggle());return}lc();let l=document.createElement("div");l.style.cssText=`pointer-events:auto;display:flex;align-items:center;background:${this.idleRowFill()};border-radius:4px;padding:${sy}px ${ny}px;margin-left:-${ny}px;min-height:${FE}px;box-sizing:border-box;color:${this.theme.textColor};user-select:none;-webkit-user-select:none;`,l.addEventListener("mouseleave",()=>{this.selectedId!==e&&this.setRowHighlighted(e,false);}),l.addEventListener("click",v=>{v.button!==0||v.target.closest("button")||this.selectRow(e);}),l.addEventListener("dblclick",v=>{v.target.closest("button")||this.openDialog(e);}),l.addEventListener("mousedown",v=>{v.button===1&&v.preventDefault();}),l.addEventListener("auxclick",v=>{v.button===1&&(v.preventDefault(),this.onRemove?.(e));}),l.addEventListener("contextmenu",v=>{v.preventDefault(),v.stopPropagation(),this.openRowMenu(e,v.clientX,v.clientY);});let c=document.createElement("span");c.style.cssText="display:none;box-sizing:border-box;flex:none;";let u=document.createElement("span");u.style.cssText="white-space:nowrap;",u.addEventListener("mouseenter",()=>this.setRowHighlighted(e,true));let d=document.createElement("span");if(d.textContent=t,d.style.cssText="font-weight:600;",u.appendChild(d),s.beta){let v=document.createElement("sup");v.textContent="beta",v.style.cssText="font-size:8px;font-weight:700;opacity:0.7;margin-left:1px;letter-spacing:0.2px;",u.appendChild(v);}l.appendChild(u);let h=document.createElement("span");h.style.cssText=`display:none;align-items:center;gap:4px;flex:none;margin-left:${ih}px;`,l.appendChild(h),l.appendChild(c);let p=document.createElement("span");p.style.cssText=`display:none;align-items:center;gap:5px;margin-left:${NE}px;white-space:nowrap;font-variant-numeric:tabular-nums;`,l.appendChild(p);let m=document.createElement("span");m.style.cssText=`display:none;align-items:center;gap:${ry}px;flex:none;margin-left:${ry}px;`;let f=null;if(this.onToggleVisible){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Hide"),this.tip(this.rowTips,e,v,()=>this.rows.get(e)?.hidden?"Show":"Hide"),v.innerHTML=iy,v.className="vela-ind-ctl",v.style.cssText=ns,v.addEventListener("click",()=>{let S=this.rows.get(e);this.onToggleVisible?.(e,!!S?.hidden);}),m.appendChild(v),f=v;}if(n.length>0||(s.props??[]).length>0){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Settings"),this.tip(this.rowTips,e,v,"Settings"),v.innerHTML=_E,v.className="vela-ind-ctl",v.style.cssText=ns,v.addEventListener("click",()=>this.openDialog(e)),m.appendChild(v);}if(this.moveApi){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Move to pane"),this.tip(this.rowTips,e,v,"Move to pane"),v.innerHTML=ye("move",xn),v.className="vela-ind-ctl",v.style.cssText=ns,v.addEventListener("click",S=>{S.stopPropagation(),this.openMoveMenu(e,v);}),m.appendChild(v);}let g=document.createElement("span");g.style.cssText="display:contents;",this.renderExtras(e,g),m.appendChild(g);let b=document.createElement("button");b.type="button",b.setAttribute("aria-label","Remove indicator"),this.tip(this.rowTips,e,b,"Remove indicator"),b.innerHTML=BE,b.className="vela-ind-close",b.style.cssText=ns,b.addEventListener("click",()=>this.onRemove?.(e)),m.appendChild(b),l.appendChild(m),this.attach(this.legendFor(o),l,!!s.native);let y={id:e,title:t,inputs:n,values:{...i},props:s.props??[],propValues:{...s.propValues??{}},el:l,titleEl:d,statusEl:c,valuesEl:p,plotValues:[],plotValuesKey:"",showValues:null,highlighted:false,paneId:o,hidden:false,eyeEl:f,controlsEl:m,extrasEl:g,calloutsEl:h,callouts:[],native:!!s.native};this.rows.set(e,y),this.renderCallouts(y),this.syncFoldToggle();}attach(e,t,n){n?e.prepend(t):e.appendChild(t);}setValues(e,t,n){let i=this.rows.get(e);i&&(i.values={...i.values,...t},n&&(i.propValues={...i.propValues,...n}));}setStatus(e,t){let n=this.rows.get(e);if(!n)return;let i=n.statusEl;if(i.replaceChildren(),t==="idle"){i.style.cssText="display:none;box-sizing:border-box;flex:none;";return}if(t==="loading"){i.style.cssText=`display:inline-flex;align-items:center;gap:3px;box-sizing:border-box;flex:none;margin-left:${ih}px;line-height:0;transform:translateY(1px);`;for(let o=0;o<3;o+=1){let s=document.createElement("span");s.style.cssText="width:4px;height:4px;border-radius:50%;background:currentColor;opacity:0.15;flex:none;",s.animate?.([{opacity:.12},{opacity:.55}],{duration:800,iterations:1/0,direction:"alternate",easing:"ease-in-out",delay:-o*260}),i.appendChild(s);}return}this.ensureStatusKeyframes(),i.style.cssText=`display:inline-block;box-sizing:border-box;flex:none;width:8px;height:8px;border-radius:50%;margin-left:${ih}px;transform:translateY(1px);background:${this.theme.upColor};animation:vela-ind-pulse 1.2s ease-in-out infinite;`;}ensureStatusKeyframes(){if(typeof document>"u"||document.getElementById("vela-ind-status-kf"))return;let e=document.createElement("style");e.id="vela-ind-status-kf",e.textContent=OE,document.head.appendChild(e);}setVisible(e,t){let n=this.rows.get(e);n&&(n.hidden=!t,n.el.style.opacity=t?"1":"0.5",n.eyeEl&&(n.eyeEl.innerHTML=t?iy:VE,n.eyeEl.setAttribute("aria-label",t?"Hide":"Show")),this.syncRowActions(n));}selectRow(e){this.selectedId!==e&&(this.clearSelection(),this.selectedId=e,this.setRowHighlighted(e,true));}setRowHighlighted(e,t){let n=this.rows.get(e);n&&(n.highlighted=t,this.renderRowValues(n),n.el.style.boxShadow=t?`inset 0 0 0 1px ${this.neutralBorder()}`:"none",n.el.style.background=t?this.theme.background:this.idleRowFill(),this.syncRowActions(n));}syncRowActions(e){let t=e.highlighted;if(e.controlsEl.style.display=t||e.hidden?"inline-flex":"none",t){e.el.appendChild(e.statusEl);for(let n of e.callouts)n.hidePanel();}else e.el.insertBefore(e.statusEl,e.valuesEl);e.calloutsEl.style.display=oy(t,e.callouts.length>0);for(let n of Array.from(e.controlsEl.children))if(!(!(n instanceof HTMLElement)||n===e.eyeEl)){if(n===e.extrasEl){n.style.display=t?"contents":"none";continue}n.style.display=t?"inline-flex":"none";}}clearSelection(){this.selectedId&&(this.setRowHighlighted(this.selectedId,false),this.selectedId=null);}remove(e){let t=this.rows.get(e);for(let n of t?.callouts??[])n.destroy();if(t?.el.remove(),this.rows.delete(e),this.disposeTips(this.rowTips,e),this.disposeTips(this.extrasTips,e),this.disposeTips(this.calloutTips,e),this.selectedId===e&&(this.selectedId=null),this.inputsDialog.openId===e&&this.inputsDialog.close(),this.syncFoldToggle(),t&&t.paneId!=="price"){let n=this.legends.get(t.paneId);n&&n.childElementCount===0&&(n.remove(),this.legends.delete(t.paneId));}}destroy(){this.inputsDialog.close(),this.moveMenu?.destroy(),this.moveMenu=null,this.rowMenu?.destroy(),this.rowMenu=null;for(let e of [...this.rowTips.keys()])this.disposeTips(this.rowTips,e);for(let e of [...this.extrasTips.keys()])this.disposeTips(this.extrasTips,e);for(let e of [...this.calloutTips.keys()])this.disposeTips(this.calloutTips,e);for(let e of this.rows.values())for(let t of e.callouts)t.destroy();for(let e of this.legends.values())e.remove();this.legends.clear(),this.rows.clear(),this.foldToggle=null,this.legendFolded=false,this.selectedId=null,typeof document<"u"&&document.removeEventListener("click",this.onDocClick);}isDialogOpen(){return this.inputsDialog.isOpen()}closeOpenDialog(){this.inputsDialog.close();}openDialog(e){let t=this.rows.get(e);t&&this.inputsDialog.open(t);}idleRowFill(){return q(this.theme.background,.6)}neutralBorder(){return "var(--vela-border)"}};var Ci={up:Z("chevron-up"),down:Z("chevron-down"),collapse:Z("pane-collapse"),expand:Z("pane-expand"),maximize:Z("maximize"),restore:Z("restore")},ay="vela-pane-controls",WE=12,ly="rgba(0,0,0,0.65)";function GE(){if(typeof document>"u"||document.getElementById(ay))return;let r=document.createElement("style");r.id=ay,r.textContent=`
|
|
760
|
-
.vela-pc-btn{display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;border-radius:var(--vela-radius-sm);background:transparent;line-height:0;font-size:${
|
|
759
|
+
.vela-ind-fold:hover{border-color:var(--vela-border-strong);opacity:0.9;}`,r||document.head.appendChild(e);}var IE=[{value:"",label:"Chart"},{value:"1",label:"1 minute"},{value:"3",label:"3 minutes"},{value:"5",label:"5 minutes"},{value:"15",label:"15 minutes"},{value:"30",label:"30 minutes"},{value:"45",label:"45 minutes"},{value:"60",label:"1 hour"},{value:"120",label:"2 hours"},{value:"180",label:"3 hours"},{value:"240",label:"4 hours"},{value:"D",label:"1 day"},{value:"W",label:"1 week"},{value:"M",label:"1 month"}],AE=Array.from({length:48},(r,e)=>{let t=String(Math.floor(e/2)).padStart(2,"0"),n=e%2===0?"00":"30",i=`${t}:${n}`;return {value:i,label:i}}),RE=["January","February","March","April","May","June","July","August","September","October","November","December"],DE=["Su","Mo","Tu","We","Th","Fr","Sa"];function sy(r){let e=r.trim(),t=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(e);if(!t)return null;let n=Number(t[1]),i=Number(t[2]),o=Number(t[3]),s=new Date(n,i-1,o);return s.getFullYear()!==n||s.getMonth()!==i-1||s.getDate()!==o?null:sh(s)}function OE(r){let e=sy(r);if(!e)return null;let[t,n,i]=e.split("-").map(Number);return new Date(t,n-1,i)}function sh(r){return `${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function NE(r){let e=r.trim(),t=/^(\d{1,2}):(\d{2})$/.exec(e)??/^(\d{2})(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),i=Number(t[2]);return n>23||i>59?null:`${String(n).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function FE(r){let e=/^(\d{2})(\d{2})-(\d{2})(\d{2})$/.exec(r.trim());return e?[`${e[1]}:${e[2]}`,`${e[3]}:${e[4]}`]:["09:00","16:00"]}function VE(r,e){return `${r.replace(":","")}-${e.replace(":","")}`}function _E(r){if(!r)return {date:"",time:"09:30"};let e=r<1e12?r*1e3:r,t=new Date(e);if(Number.isNaN(t.getTime()))return {date:"",time:"09:30"};let n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,i=Math.round((t.getHours()*60+t.getMinutes())/30)*30,o=String(Math.floor(i/60)%24).padStart(2,"0"),s=String(i%60).padStart(2,"0");return {date:n,time:`${o}:${s}`}}var BE="data-vela-pane-at-top",HE="@keyframes vela-ind-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.6)}}",Sn=16,lh=18,dy=2,ay=6,zE=6,ah=8,ly=6,rs=`cursor:pointer;display:inline-flex;align-items:center;justify-content:center;border:none;line-height:0;padding:0;width:${lh}px;height:${lh}px;border-radius:3px;box-sizing:border-box;flex:none;`,$E=lh+dy*2,cy=ye("eye",Sn),WE=ye("eye-off",Sn),GE=ye("gear",Sn),UE=ye("close",Sn),YE=ye("chevron-up",Sn),KE=ye("chevron-down",Sn),XE=ye("objects",Sn);function uy(r,e){return !r&&e?"inline-flex":"none"}var hc=class{constructor(e,t,n){this.container=e;this.theme=t;this.paneBoundsOf=n;this.legends=new Map;this.rows=new Map;this.selectedId=null;this.onChange=null;this.onRemove=null;this.onToggleVisible=null;this.symbolPicker=null;this.mobileLayout=false;this.moveApi=null;this.legendActions=null;this.legendCallouts=null;this.rowTips=new Map;this.extrasTips=new Map;this.calloutTips=new Map;this.moveMenu=null;this.moveTargets=[];this.moveMenuId=null;this.paneCollapse=new Map;this.legendFolded=false;this.titlesVisible=true;this.valuesVisible=true;this.rowMenu=null;this.rowMenuId=null;this.foldToggle=null;this.overviewAction=null;this.onDocClick=e=>{if(!this.selectedId)return;let t=e.target;if(t){for(let n of this.rows.values())if(n.el.contains(t))return}this.clearSelection();};this.dialogHost=null;e.style.position||(e.style.position="relative"),typeof document<"u"&&document.addEventListener("click",this.onDocClick),dc(),this.inputsDialog=new uc({container:e,theme:()=>this.theme,mobile:()=>this.mobileLayout,dialogHost:()=>this.dialogHost,symbolPicker:()=>this.symbolPicker,onChange:i=>this.onChange?.(i),onBackdropClose:()=>this.clearSelection()});}setDialogHost(e){this.dialogHost=e,e&&getComputedStyle(e).position==="static"&&(e.style.position="relative");}setLayoutMode(e){let t=e==="mobile";if(t!==this.mobileLayout&&(this.mobileLayout=t,this.overviewAction===null&&(this.legendFolded=t),this.syncFoldToggle(),this.inputsDialog.openId!==null)){let n=this.inputsDialog.openId;this.closeOpenDialog(),this.openDialog(n);}}setLegendOverviewAction(e){e!==this.overviewAction&&(this.overviewAction=e,this.legendFolded=e!==null?true:this.mobileLayout,this.syncFoldToggle());}openSettingsFor(e){this.rows.has(e)&&this.openDialog(e);}tip(e,t,n,i,o=false){let s=e.get(t)??[];s.push(Kt(n,{host:this.container,theme:()=>this.theme,text:typeof i=="function"?i:()=>i,wrap:o})),e.set(t,s);}disposeTips(e,t){for(let n of e.get(t)??[])n();e.delete(t);}setOnChange(e){this.onChange=e;}setOnRemove(e){this.onRemove=e;}setOnToggleVisible(e){this.onToggleVisible=e;}setTheme(e){this.theme=e;for(let t of this.legends.values())Re(t,e);for(let t of this.rows.values())t.el.style.background=t.highlighted?e.background:this.idleRowFill(),t.el.style.color=e.textColor;this.foldToggle&&this.syncFoldToggle();}setSymbolPicker(e){this.symbolPicker=e;}setMoveApi(e){this.moveApi=e;}setLegendActions(e){this.legendActions=e;for(let t of this.rows.values())this.renderExtras(t.id,t.extrasEl);}renderExtras(e,t){this.disposeTips(this.extrasTips,e),t.replaceChildren();for(let n of this.legendActions?.(e)??[]){let i=document.createElement("button");i.type="button",i.setAttribute("aria-label",n.tooltip),this.tip(this.extrasTips,e,i,n.tooltip),i.innerHTML=ye(n.icon,Sn),i.className="vela-ind-ctl",i.dataset.legendAction=n.id,i.style.cssText=rs,i.addEventListener("click",o=>{o.stopPropagation(),n.run();}),t.appendChild(i);}}setLegendCallouts(e){this.legendCallouts=e;for(let t of this.rows.values())this.renderCallouts(t);}renderCallouts(e){this.disposeTips(this.calloutTips,e.id);for(let n of e.callouts)n.destroy();e.callouts=[],e.calloutsEl.replaceChildren();let t=this.legendCallouts?.(e.id)??[];e.calloutsEl.style.display=uy(e.highlighted,t.length>0);for(let n of t){let i=new Ko({icon:n.icon,background:n.background,...n.color!==void 0?{color:n.color}:{},label:n.tooltip,...n.content!==void 0?{panel:n.content}:{},host:this.container,theme:()=>this.theme});i.el.dataset.legendCallout=n.id,this.tip(this.calloutTips,e.id,i.el,n.tooltip),e.callouts.push(i),e.calloutsEl.appendChild(i.el);}}reposition(){for(let[e,t]of this.legends)this.positionLegend(t,e);}setTitlesVisible(e){this.titlesVisible!==e&&(this.titlesVisible=e,this.reposition());}setValuesVisible(e){this.valuesVisible=e;for(let t of this.rows.values())t.showValues=null,this.renderRowValues(t);}setPlotValues(e){for(let t of this.rows.values()){let n=e.get(t.id)??[],i=n.map(o=>`${o.value}|${o.color}`).join("\0");i!==t.plotValuesKey&&(t.plotValues=n,t.plotValuesKey=i,this.renderRowValues(t));}}rowValuesShown(e){return e.showValues??this.valuesVisible}renderRowValues(e){if(!this.rowValuesShown(e)||e.plotValues.length===0||e.highlighted){e.valuesEl.style.display="none",e.valuesEl.replaceChildren();return}e.valuesEl.style.display="inline-flex",e.valuesEl.replaceChildren();for(let t of e.plotValues){let n=document.createElement("span");n.textContent=t.value,n.style.color=t.color,e.valuesEl.appendChild(n);}}openMoveMenu(e,t){this.closeMoveMenu();let n=this.moveApi;if(!n)return;let o=this.rows.get(e)?.paneId??"price",s=n.panes(),a=[];for(let d of s)d.id!==o&&a.push({label:`Move to ${d.label}`,target:d.kind==="price"?"price":{pane:d.id}});o!=="price"&&[...this.rows.values()].filter(d=>d.paneId===o).length<=1||(o!=="price"&&a.push({label:"New pane above",target:{newPane:{before:o}}}),a.push({label:"New pane below",target:{newPane:{after:o}}})),this.moveTargets=a.map(d=>d.target),this.moveMenuId=e;let c=a.map((d,h)=>({id:String(h),label:d.label}));this.moveMenu?this.moveMenu.setItems(c):this.moveMenu=new xi({host:this.container,items:c,placement:"bottom-start",onSelect:d=>{let h=this.moveTargets[Number(d)],p=this.moveMenuId;h&&p&&n.move(p,h);}});let u=t.getBoundingClientRect();this.moveMenu.openAt(u.left,u.bottom+4);}closeMoveMenu(){this.moveMenu?.close();}openRowMenu(e,t,n){this.closeRowMenu(),this.closeMoveMenu();let i=this.rows.get(e);if(!i)return;this.rowMenuId=e;let o=[{id:"values",label:"Indicator values",checked:this.rowValuesShown(i)}];this.rowMenu?this.rowMenu.setItems(o):this.rowMenu=new xi({host:this.container,items:o,placement:"bottom-start",checkmarks:true,onSelect:s=>{if(s!=="values"||!this.rowMenuId)return;let a=this.rows.get(this.rowMenuId);a&&(a.showValues=!this.rowValuesShown(a),this.renderRowValues(a));}}),this.rowMenu.openAt(t,n);}closeRowMenu(){this.rowMenu?.close();}setPane(e,t){let n=this.rows.get(e);if(!n||n.paneId===t)return;let i=n.paneId;if(n.paneId=t,this.attach(this.legendFor(t),n.el,n.native),this.syncFoldToggle(),i!=="price"){let o=this.legends.get(i);o&&o.childElementCount===0&&(o.remove(),this.legends.delete(i));}}legendFor(e){let t=this.legends.get(e);return t||(t=document.createElement("div"),t.dataset.velaPane=e,t.style.cssText="position:absolute;left:10px;z-index:5;display:flex;flex-direction:column;align-items:flex-start;gap:0;pointer-events:none;font:12px -apple-system,Segoe UI,sans-serif;",Re(t,this.theme),this.positionLegend(t,e),this.container.appendChild(t),this.legends.set(e,t)),t}positionLegend(e,t){let n=this.paneBoundsOf?this.paneBoundsOf(t):{top:0,height:1/0};e.toggleAttribute(BE,n.top===0),e.style.display=n.height<4||!this.titlesVisible?"none":"flex";let i=this.paneCollapse.has(t),o=this.paneCollapse.get(t)??null;for(let a of this.rows.values())a.paneId===t&&(a.el.style.display=(i?a.id!==o:this.legendFolded)?"none":"flex");let s=n.top+8;if(i&&Number.isFinite(n.height)){let a=e.offsetHeight||20;s=n.top+Math.max(1,Math.round((n.height-a)/2));}e.style.top=`${s}px`;}setCollapsedPanes(e){this.paneCollapse=e;}syncFoldToggle(){let e=this.rows.size,t=this.overviewAction!==null||this.mobileLayout?1:2;if(e<t){let a=this.legendFolded;e>0&&(this.legendFolded=false),this.foldToggle&&(this.foldToggle.remove(),this.foldToggle=null,this.disposeTips(this.rowTips,"fold")),a&&e>0&&this.reposition();return}let n=this.foldToggle;n||(n=document.createElement("button"),n.type="button",n.className="vela-ind-fold",this.tip(this.rowTips,"fold",n,()=>this.overviewAction!==null?"Indicators":this.legendFolded?"Show indicator legend":"Hide indicator legend"),n.addEventListener("click",()=>{if(this.overviewAction!==null){this.overviewAction();return}this.legendFolded=!this.legendFolded,this.syncFoldToggle();}),this.foldToggle=n);let i=this.legendFolded;n.setAttribute("aria-label",this.overviewAction!==null?"Indicators":i?"Show indicator legend":"Hide indicator legend");let o=this.theme.textColor;n.style.cssText=`pointer-events:auto;display:inline-flex;align-items:center;gap:4px;background:${this.theme.background};color:${o};border:1px solid ${this.theme.borderColor};border-radius:4px;padding:2px 6px;margin-top:6px;cursor:pointer;font:inherit;line-height:0;`,n.replaceChildren();let s=document.createElement("span");if(s.style.cssText="display:inline-flex;align-items:center;line-height:0;opacity:0.7;",s.innerHTML=this.overviewAction!==null?XE:i?KE:YE,n.appendChild(s),i){let a=document.createElement("span");a.textContent=String(e),a.style.cssText=`font-weight:600;line-height:normal;font-size:12px;color:${o};`,n.appendChild(a);}this.legendFor("price").appendChild(n),this.reposition();}upsert(e,t,n,i,o="price",s={}){let a=this.rows.get(e);if(a){a.title=t,a.inputs=n,a.values={...i},a.props=s.props??[],a.propValues={...s.propValues??{}},a.titleEl.textContent=t,a.paneId!==o&&(a.paneId=o,this.attach(this.legendFor(o),a.el,a.native),this.syncFoldToggle());return}dc();let l=document.createElement("div");l.style.cssText=`pointer-events:auto;display:flex;align-items:center;background:${this.idleRowFill()};border-radius:4px;padding:${dy}px ${ay}px;margin-left:-${ay}px;min-height:${$E}px;box-sizing:border-box;color:${this.theme.textColor};user-select:none;-webkit-user-select:none;`,l.addEventListener("mouseleave",()=>{this.selectedId!==e&&this.setRowHighlighted(e,false);}),l.addEventListener("click",v=>{v.button!==0||v.target.closest("button")||this.selectRow(e);}),l.addEventListener("dblclick",v=>{v.target.closest("button")||this.openDialog(e);}),l.addEventListener("mousedown",v=>{v.button===1&&v.preventDefault();}),l.addEventListener("auxclick",v=>{v.button===1&&(v.preventDefault(),this.onRemove?.(e));}),l.addEventListener("contextmenu",v=>{v.preventDefault(),v.stopPropagation(),this.openRowMenu(e,v.clientX,v.clientY);});let c=document.createElement("span");c.style.cssText="display:none;box-sizing:border-box;flex:none;";let u=document.createElement("span");u.style.cssText="white-space:nowrap;",u.addEventListener("mouseenter",()=>this.setRowHighlighted(e,true));let d=document.createElement("span");if(d.textContent=t,d.style.cssText="font-weight:600;",u.appendChild(d),s.beta){let v=document.createElement("sup");v.textContent="beta",v.style.cssText="font-size:8px;font-weight:700;opacity:0.7;margin-left:1px;letter-spacing:0.2px;",u.appendChild(v);}l.appendChild(u);let h=document.createElement("span");h.style.cssText=`display:none;align-items:center;gap:4px;flex:none;margin-left:${ah}px;`,l.appendChild(h),l.appendChild(c);let p=document.createElement("span");p.style.cssText=`display:none;align-items:center;gap:5px;margin-left:${zE}px;white-space:nowrap;font-variant-numeric:tabular-nums;`,l.appendChild(p);let m=document.createElement("span");m.style.cssText=`display:none;align-items:center;gap:${ly}px;flex:none;margin-left:${ly}px;`;let f=null;if(this.onToggleVisible){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Hide"),this.tip(this.rowTips,e,v,()=>this.rows.get(e)?.hidden?"Show":"Hide"),v.innerHTML=cy,v.className="vela-ind-ctl",v.style.cssText=rs,v.addEventListener("click",()=>{let S=this.rows.get(e);this.onToggleVisible?.(e,!!S?.hidden);}),m.appendChild(v),f=v;}if(n.length>0||(s.props??[]).length>0){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Settings"),this.tip(this.rowTips,e,v,"Settings"),v.innerHTML=GE,v.className="vela-ind-ctl",v.style.cssText=rs,v.addEventListener("click",()=>this.openDialog(e)),m.appendChild(v);}if(this.moveApi){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Move to pane"),this.tip(this.rowTips,e,v,"Move to pane"),v.innerHTML=ye("move",Sn),v.className="vela-ind-ctl",v.style.cssText=rs,v.addEventListener("click",S=>{S.stopPropagation(),this.openMoveMenu(e,v);}),m.appendChild(v);}let g=document.createElement("span");g.style.cssText="display:contents;",this.renderExtras(e,g),m.appendChild(g);let b=document.createElement("button");b.type="button",b.setAttribute("aria-label","Remove indicator"),this.tip(this.rowTips,e,b,"Remove indicator"),b.innerHTML=UE,b.className="vela-ind-close",b.style.cssText=rs,b.addEventListener("click",()=>this.onRemove?.(e)),m.appendChild(b),l.appendChild(m),this.attach(this.legendFor(o),l,!!s.native);let y={id:e,title:t,inputs:n,values:{...i},props:s.props??[],propValues:{...s.propValues??{}},el:l,titleEl:d,statusEl:c,valuesEl:p,plotValues:[],plotValuesKey:"",showValues:null,highlighted:false,paneId:o,hidden:false,eyeEl:f,controlsEl:m,extrasEl:g,calloutsEl:h,callouts:[],native:!!s.native};this.rows.set(e,y),this.renderCallouts(y),this.syncFoldToggle();}attach(e,t,n){n?e.prepend(t):e.appendChild(t);}setValues(e,t,n){let i=this.rows.get(e);i&&(i.values={...i.values,...t},n&&(i.propValues={...i.propValues,...n}));}setStatus(e,t){let n=this.rows.get(e);if(!n)return;let i=n.statusEl;if(i.replaceChildren(),t==="idle"){i.style.cssText="display:none;box-sizing:border-box;flex:none;";return}if(t==="loading"){i.style.cssText=`display:inline-flex;align-items:center;gap:3px;box-sizing:border-box;flex:none;margin-left:${ah}px;line-height:0;transform:translateY(1px);`;for(let o=0;o<3;o+=1){let s=document.createElement("span");s.style.cssText="width:4px;height:4px;border-radius:50%;background:currentColor;opacity:0.15;flex:none;",s.animate?.([{opacity:.12},{opacity:.55}],{duration:800,iterations:1/0,direction:"alternate",easing:"ease-in-out",delay:-o*260}),i.appendChild(s);}return}this.ensureStatusKeyframes(),i.style.cssText=`display:inline-block;box-sizing:border-box;flex:none;width:8px;height:8px;border-radius:50%;margin-left:${ah}px;transform:translateY(1px);background:${this.theme.upColor};animation:vela-ind-pulse 1.2s ease-in-out infinite;`;}ensureStatusKeyframes(){if(typeof document>"u"||document.getElementById("vela-ind-status-kf"))return;let e=document.createElement("style");e.id="vela-ind-status-kf",e.textContent=HE,document.head.appendChild(e);}setVisible(e,t){let n=this.rows.get(e);n&&(n.hidden=!t,n.el.style.opacity=t?"1":"0.5",n.eyeEl&&(n.eyeEl.innerHTML=t?cy:WE,n.eyeEl.setAttribute("aria-label",t?"Hide":"Show")),this.syncRowActions(n));}selectRow(e){this.selectedId!==e&&(this.clearSelection(),this.selectedId=e,this.setRowHighlighted(e,true));}setRowHighlighted(e,t){let n=this.rows.get(e);n&&(n.highlighted=t,this.renderRowValues(n),n.el.style.boxShadow=t?`inset 0 0 0 1px ${this.neutralBorder()}`:"none",n.el.style.background=t?this.theme.background:this.idleRowFill(),this.syncRowActions(n));}syncRowActions(e){let t=e.highlighted;if(e.controlsEl.style.display=t||e.hidden?"inline-flex":"none",t){e.el.appendChild(e.statusEl);for(let n of e.callouts)n.hidePanel();}else e.el.insertBefore(e.statusEl,e.valuesEl);e.calloutsEl.style.display=uy(t,e.callouts.length>0);for(let n of Array.from(e.controlsEl.children))if(!(!(n instanceof HTMLElement)||n===e.eyeEl)){if(n===e.extrasEl){n.style.display=t?"contents":"none";continue}n.style.display=t?"inline-flex":"none";}}clearSelection(){this.selectedId&&(this.setRowHighlighted(this.selectedId,false),this.selectedId=null);}remove(e){let t=this.rows.get(e);for(let n of t?.callouts??[])n.destroy();if(t?.el.remove(),this.rows.delete(e),this.disposeTips(this.rowTips,e),this.disposeTips(this.extrasTips,e),this.disposeTips(this.calloutTips,e),this.selectedId===e&&(this.selectedId=null),this.inputsDialog.openId===e&&this.inputsDialog.close(),this.syncFoldToggle(),t&&t.paneId!=="price"){let n=this.legends.get(t.paneId);n&&n.childElementCount===0&&(n.remove(),this.legends.delete(t.paneId));}}destroy(){this.inputsDialog.close(),this.moveMenu?.destroy(),this.moveMenu=null,this.rowMenu?.destroy(),this.rowMenu=null;for(let e of [...this.rowTips.keys()])this.disposeTips(this.rowTips,e);for(let e of [...this.extrasTips.keys()])this.disposeTips(this.extrasTips,e);for(let e of [...this.calloutTips.keys()])this.disposeTips(this.calloutTips,e);for(let e of this.rows.values())for(let t of e.callouts)t.destroy();for(let e of this.legends.values())e.remove();this.legends.clear(),this.rows.clear(),this.foldToggle=null,this.legendFolded=false,this.selectedId=null,typeof document<"u"&&document.removeEventListener("click",this.onDocClick);}isDialogOpen(){return this.inputsDialog.isOpen()}closeOpenDialog(){this.inputsDialog.close();}openDialog(e){let t=this.rows.get(e);t&&this.inputsDialog.open(t);}idleRowFill(){return q(this.theme.background,.6)}neutralBorder(){return "var(--vela-border)"}};var Ti={up:Z("chevron-up"),down:Z("chevron-down"),collapse:Z("pane-collapse"),expand:Z("pane-expand"),maximize:Z("maximize"),restore:Z("restore")},hy="vela-pane-controls",jE=12,py="rgba(0,0,0,0.65)";function qE(){if(typeof document>"u"||document.getElementById(hy))return;let r=document.createElement("style");r.id=hy,r.textContent=`
|
|
760
|
+
.vela-pc-btn{display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;border-radius:var(--vela-radius-sm);background:transparent;line-height:0;font-size:${jE}px;color:var(--vela-fg-muted);}
|
|
761
761
|
.vela-pc-btn svg{display:block;}
|
|
762
762
|
.vela-pc-btn:not(:disabled):hover{opacity:1 !important;background:var(--vela-active);color:var(--vela-fg-bright);}
|
|
763
763
|
.vela-pc-on,.vela-pc-on:not(:disabled):hover{background:var(--vela-selected-bg);color:var(--vela-selected-fg);}
|
|
764
|
-
`,document.head.appendChild(r);}var
|
|
764
|
+
`,document.head.appendChild(r);}var pc=class{constructor(e,t,n){this.plot=e;this.theme=t;this.deps=n;this.clusters=new Map;this.hoverPaneId=null;this.suspended=false;this.onPlotMove=e=>{if(this.suspended)return;let t=this.plot.getBoundingClientRect(),n=e.clientY-t.top,i=null;for(let o of this.deps.panes())if(n>=o.top&&n<=o.top+o.height){i=o.id;break}this.setHoverPane(i);};this.onPlotLeave=()=>this.setHoverPane(null);qE(),this.root=document.createElement("div"),Object.assign(this.root.style,{position:"absolute",inset:"0",pointerEvents:"none",zIndex:"6"}),this.plot.appendChild(this.root),this.plot.addEventListener("pointermove",this.onPlotMove),this.plot.addEventListener("pointerleave",this.onPlotLeave),this.refresh();}setTheme(e){this.theme=e,this.refresh();}refresh(){let e=this.deps.panes(),t=new Set;for(let n of e){t.add(n.id);let i=this.clusters.get(n.id);i||(i=document.createElement("div"),Object.assign(i.style,{position:"absolute",display:"flex",gap:"2px",padding:"2px",borderRadius:"var(--vela-radius-md)",background:py,pointerEvents:"auto"}),this.root.appendChild(i),this.clusters.set(n.id,i)),this.buildButtons(i,n);}for(let[n,i]of this.clusters)t.has(n)||(i.remove(),this.clusters.delete(n));this.reposition();}buildButtons(e,t){e.textContent="",t.kind==="study"&&(e.appendChild(this.button(Ti.up,"Move pane up",t.index<=1,()=>this.deps.onMove(t.id,"up"),{role:"up"})),e.appendChild(this.button(Ti.down,"Move pane down",t.index>=t.count-1,()=>this.deps.onMove(t.id,"down"),{role:"down"})),e.appendChild(this.button(t.collapsed?Ti.expand:Ti.collapse,t.collapsed?"Expand pane":"Collapse pane",false,()=>this.deps.onToggleCollapse(t.id),{role:"collapse",selected:t.collapsed}))),t.count>1&&e.appendChild(this.button(t.maximized?Ti.restore:Ti.maximize,t.maximized?"Restore pane":"Maximize pane",false,()=>this.deps.onToggleMaximize(t.id),{role:"maximize",selected:t.maximized}));}button(e,t,n,i,o){let s=document.createElement("button");s.type="button",s.title=t,s.innerHTML=e,s.disabled=n,s.dataset.role=o.role;let a=o.selected===true;return s.className=a?"vela-pc-btn vela-pc-on":"vela-pc-btn",Object.assign(s.style,{cursor:n?"default":"pointer",width:"20px",height:"20px",opacity:n?"0.3":"1"}),n||s.addEventListener("click",l=>{l.stopPropagation(),i();}),s}reposition(){let e=this.deps.rightAxis()+6,t=new Map(this.deps.panes().map(n=>[n.id,n]));for(let[n,i]of this.clusters){let o=t.get(n);if(!o){i.style.display="none";continue}let s=n===this.hoverPaneId,a=i.children.length>0,l=o.collapsed?"collapse":!this.suspended&&o.maximized?"maximize":null,c=a&&(s||l!=null)&&o.height>8;if(i.style.right=`${e}px`,i.style.top=o.collapsed?`${o.top+Math.max(1,Math.round((o.height-24)/2))}px`:`${o.top+4}px`,i.style.display=c?"flex":"none",!c)continue;let u=l!=null&&!s;i.style.background=u?"transparent":py;for(let d of i.children){let h=d;h.style.display="inline-flex",h.style.visibility=u&&h.dataset.role!==l?"hidden":"visible";}}}setHoverPane(e){this.hoverPaneId!==e&&(this.hoverPaneId=e,this.reposition());}setSuspended(e){e!==this.suspended&&(this.suspended=e,e&&(this.hoverPaneId=null),this.reposition());}destroy(){this.plot.removeEventListener("pointermove",this.onPlotMove),this.plot.removeEventListener("pointerleave",this.onPlotLeave),this.root.remove(),this.clusters.clear();}};function my(r,e){return e===0?r:r+64+(e-1)*56}var fy="vela-axis-scale-buttons",ch=18,ZE=4,JE=1,QE=64-JE,by=8,vy=6,eL=ch+by+vy,gy=48;function tL(){if(typeof document>"u"||document.getElementById(fy))return;let r=document.createElement("style");r.id=fy,r.textContent=`
|
|
765
765
|
.vela-axis-btn{display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;border-radius:var(--vela-radius-sm);background:transparent;cursor:pointer;font:600 10px/1 -apple-system,Segoe UI,sans-serif;color:var(--vela-fg-muted);}
|
|
766
766
|
.vela-axis-btn:hover{background:var(--vela-active);color:var(--vela-fg-bright);}
|
|
767
767
|
.vela-axis-on,.vela-axis-on:hover{background:var(--vela-selected-bg);color:var(--vela-selected-fg);}
|
|
768
|
-
`,document.head.appendChild(r);}var dc=class{constructor(e,t,n){this.plot=e;this.theme=t;this.deps=n;this.tipDisposers=[];this.hoverPaneId=null;this.onPlotMove=e=>{if(e.pointerType!=="mouse")return;let t=this.plot.getBoundingClientRect(),n=e.clientX-t.left,i=t.width-this.deps.rightAxis(),o=null;if(n>=i&&n<=i+64){let s=e.clientY-t.top;for(let a of this.deps.panes())if(!(a.collapsed||a.height<dy)&&s>=a.top&&s<=a.top+a.height){o=a.id;break}}this.setHoverPane(o),o&&this.sync();};this.onPlotLeave=()=>this.setHoverPane(null);jE(),this.cluster=document.createElement("div"),Object.assign(this.cluster.style,{position:"absolute",display:"none",justifyContent:"center",alignItems:"center",gap:`${UE}px`,padding:`${hy}px 0 ${py}px`,width:`${KE}px`,boxSizing:"border-box",zIndex:"6",pointerEvents:"auto"}),this.applyTheme(),this.autoBtn=this.button("A","Auto (fits data to screen)",()=>this.deps.onToggleAuto(this.hoverPaneId??"")),this.logBtn=this.button("L","Logarithmic scale",()=>this.deps.onToggleLog(this.hoverPaneId??"")),this.cluster.append(this.autoBtn,this.logBtn),this.plot.appendChild(this.cluster),this.plot.addEventListener("pointermove",this.onPlotMove),this.plot.addEventListener("pointerleave",this.onPlotLeave);}button(e,t,n){let i=document.createElement("button");return i.type="button",i.setAttribute("aria-label",t),i.textContent=e,i.className="vela-axis-btn",Object.assign(i.style,{width:`${sh}px`,height:`${sh}px`}),this.tipDisposers.push(Yt(i,{host:this.plot,theme:()=>this.theme,text:()=>t,placement:"above"})),i.addEventListener("click",o=>{o.stopPropagation(),n(),this.sync();}),i}setTheme(e){this.theme=e,this.applyTheme();}applyTheme(){this.cluster.style.background=this.theme.background;}setHoverPane(e){this.hoverPaneId!==e&&(this.hoverPaneId=e,this.reposition());}reposition(){let e=this.hoverPaneId?this.deps.panes().find(t=>t.id===this.hoverPaneId):void 0;if(!e||e.collapsed||e.height<dy){this.cluster.style.display="none";return}this.cluster.style.right=`${this.deps.rightAxis()-64}px`,this.cluster.style.top=`${e.top+e.height-XE}px`,this.cluster.style.display="flex",this.sync();}sync(){let e=this.deps.panes().find(t=>t.id===this.hoverPaneId);e&&(this.autoBtn.classList.toggle("vela-axis-on",e.auto),this.logBtn.classList.toggle("vela-axis-on",e.log));}destroy(){this.plot.removeEventListener("pointermove",this.onPlotMove),this.plot.removeEventListener("pointerleave",this.onPlotLeave);for(let e of this.tipDisposers)e();this.tipDisposers.length=0,this.cluster.remove();}};var my={panes:true,paneManagement:true,fills:"native",bgcolor:"native",hline:"native",markers:true,barcolor:"native",perPointColor:true,drawings:true,userDrawings:true,drawingDepth:true,tables:true,trades:true,timelineMarks:true,inputsUI:true},is=null;function fy(){if(is!==null)return is;try{is=!!document.createElement("canvas").getContext("webgl2");}catch{is=false;}return is}function os(r){let e=Math.max(.5,Math.floor(r*.7)/2);return Math.max(1,Math.min(1.5,e))}function Ti(r){return r<1?"aggregate":r<3?"wick":"full"}function tn(r,e){return Math.round(r*e)/e}function hc(r,e,t,n=1){let i=Math.max(1,Math.round(os(e)*t)),o=Math.round(r*t-i/2),s=Math.max(i,Math.round(Math.floor(e*.7*n)*t));(s-i)%2!==0&&(s+=1);let a=(s-i)/2;return {wickX:o/t,wickW:i/t,bodyX:(o-a)/t,bodyW:s/t,center:(o+i/2)/t}}function pc(r,e,t,n,i){let o=[],s=NaN,a=[],l=()=>{if(a.length===0)return;let c=[a[0]];for(let u=1;u<a.length;u+=1){let d=c[c.length-1],h=a[u];Math.abs(i(d.hi)-i(h.lo))<1?(d.hi=h.hi,h.headIdx<d.headIdx&&(d.headIdx=h.headIdx,d.headTime=h.headTime,d.open=h.open),h.lastIdx>d.lastIdx&&(d.lastIdx=h.lastIdx,d.close=h.close)):c.push(h);}for(let u of c)o.push({x:s,hi:u.hi,lo:u.lo,headTime:u.headTime,open:u.open,close:u.close});a=[];};for(let c=e;c<=t;c+=1){let u=r[c];if(!u||u.high<=u.low)continue;let d=Math.round(n(c));d!==s&&(l(),s=d);let h=u.low,p=u.high,m=c,f=u.time,g=u.open;for(let y=a.length-1;y>=0;y-=1){let v=a[y];v.lo>p||v.hi<h||(v.lo<h&&(h=v.lo),v.hi>p&&(p=v.hi),v.headIdx<m&&(m=v.headIdx,f=v.headTime,g=v.open),a.splice(y,1));}let b=0;for(;b<a.length&&a[b].lo<h;)b+=1;a.splice(b,0,{lo:h,hi:p,headIdx:m,headTime:f,open:g,lastIdx:c,close:u.close});}return l(),o}var lh=1,ki=z,Ei=W,Sn=.25,Cn=.05,qE=50,ZE=q(ue,.08),gy=q(Ke,.08),JE=gy;function by(){return {chartTypes:{},fontSize:11,gridVert:{visible:true,color:null},gridHorz:{visible:true,color:null},borderColor:null,separatorColor:null,crosshair:{color:Kp,width:1,style:"dashed",opacity:.4,labelBackground:qp},candle:{bodyVisible:true,borderVisible:false,borderUpColor:null,borderDownColor:null,wickVisible:true,wickUpColor:null,wickDownColor:null},bars:{upColor:null,downColor:null},line:{color:_,width:2},area:{lineColor:_,width:2,topColor:q(_,.28),bottomColor:q(_,.02)},baseline:{topLineColor:null,bottomLineColor:null,topFillColor:null,topFillColor2:null,bottomFillColor:null,bottomFillColor2:null,width:2,baselineLevel:qE},sessions:{premarketColor:ZE,postmarketColor:gy,extendedColor:JE}}}var QE=["solid","dashed","dotted"],vy=["candles","bars","line","area","baseline","heikinashi"];function ch(r){for(let e of Mt())if(e.id===r)return e.basePainting??"candles";return "candles"}function ss(r){if(vy.includes(r))return false;for(let e of Mt())if(e.id===r)return (e.basePainting??"candles")==="candles";return false}function mc(r,e){if(!ss(r))return null;let t=e[r]??{},n=o=>re(o)?o:null,i=o=>Le(o)?o:null;return {upColor:n(t.candleUpColor),downColor:n(t.candleDownColor),bodyVisible:i(t.candleBodyVisible),borderVisible:i(t.candleBorderVisible),borderUpColor:n(t.candleBorderUpColor),borderDownColor:n(t.candleBorderDownColor),wickVisible:i(t.candleWickVisible),wickUpColor:n(t.candleWickUpColor),wickDownColor:n(t.candleWickDownColor)}}function Mi(r,e,t,n){return e?{up:e.upColor??t,down:e.downColor??n,candle:{bodyVisible:e.bodyVisible??r.bodyVisible,borderVisible:e.borderVisible??r.borderVisible,borderUpColor:e.borderUpColor??r.borderUpColor,borderDownColor:e.borderDownColor??r.borderDownColor,wickVisible:e.wickVisible??r.wickVisible,wickUpColor:e.wickUpColor??r.wickUpColor,wickDownColor:e.wickDownColor??r.wickDownColor}}:{up:t,down:n,candle:r}}function Li(){let r=[...vy];for(let e of Mt())r.includes(e.id)||r.push(e.id);return r}function re(r){return typeof r=="string"&&r.trim().length>0}function Le(r){return typeof r=="boolean"}function Dt(r){return typeof r=="number"&&Number.isFinite(r)}function eM(r){return typeof r=="string"&&QE.includes(r)}function tM(r){return typeof r=="string"&&Li().includes(r)}function nM(r){return r==="price"||r==="percent"||r==="indexed"}function we(r){return r&&typeof r=="object"?r:{}}function rM(r){return r<0?0:r>1?1:r}function ah(r){return r<1?1:r>10?10:r}function iM(r){return r<0?0:r>100?100:r}function oM(r){return r<.1?.1:r>10?10:r}function yy(r){let e={};for(let t of Mt()){let n=t.settings;if(!n)continue;let i={},o=s=>{for(let a of s??[])for(let l of oo(a))i[l.key]=l.defval;};for(let s of n.instances??[])s.enableKey&&(i[s.enableKey]=false),o(s.rows);for(let s of n.subsections??[])s.enableKey&&(i[s.enableKey]=false),o(s.rows);n.instances||o(n.rows),e[t.id]=i;}for(let[t,n]of Object.entries(r.chartTypes))e[t]={...e[t]??{},...n};return {...r,chartTypes:e}}function wy(r,e){let t=we(e),n=we(t.chartTypes),i={...r.chartTypes};for(let[w,L]of Object.entries(n))i[w]={...i[w]??{},...we(L)};let o=we(t.layout),s=we(t.grid),a=we(s.vertLines),l=we(s.horzLines),c=we(t.crosshair),u=we(t.priceScale),d=we(t.animations),h=we(t.panes),p=we(t.trades),m=we(t.timeScale),f=we(t.marks),g=we(f.groups),b=we(t.candles),y=we(t.bars),v=we(t.line),S=we(t.area),E=we(t.baseline),T=we(t.series),k=we(t.sessions),x=we(t.stacking),M=we(x.series);return {version:lh,chartTypes:i,layout:{background:re(o.background)?o.background:r.layout.background,textColor:re(o.textColor)?o.textColor:r.layout.textColor,fontFamily:re(o.fontFamily)?o.fontFamily:r.layout.fontFamily,fontSize:Dt(o.fontSize)?Math.max(6,Math.min(32,o.fontSize)):r.layout.fontSize},grid:{vertLines:{visible:Le(a.visible)?a.visible:r.grid.vertLines.visible,color:re(a.color)?a.color:r.grid.vertLines.color},horzLines:{visible:Le(l.visible)?l.visible:r.grid.horzLines.visible,color:re(l.color)?l.color:r.grid.horzLines.color}},crosshair:{color:re(c.color)?c.color:r.crosshair.color,width:Dt(c.width)?Math.max(.5,Math.min(8,c.width)):r.crosshair.width,style:eM(c.style)?c.style:r.crosshair.style,opacity:Dt(c.opacity)?rM(c.opacity):r.crosshair.opacity,labelBackground:re(c.labelBackground)?c.labelBackground:r.crosshair.labelBackground},priceScale:{mode:nM(u.mode)?u.mode:r.priceScale.mode,log:Le(u.log)?u.log:r.priceScale.log,invert:Le(u.invert)?u.invert:r.priceScale.invert,borderColor:re(u.borderColor)?u.borderColor:r.priceScale.borderColor,labelsVisible:Le(u.labelsVisible)?u.labelsVisible:r.priceScale.labelsVisible,currentPriceLine:Le(u.currentPriceLine)?u.currentPriceLine:r.priceScale.currentPriceLine,priceLabel:Le(u.priceLabel)?u.priceLabel:r.priceScale.priceLabel,countdown:Le(u.countdown)?u.countdown:r.priceScale.countdown,animateLastPrice:Le(u.animateLastPrice)?u.animateLastPrice:r.priceScale.animateLastPrice},animations:{zoom:Le(d.zoom)?d.zoom:r.animations.zoom,pan:Le(d.pan)?d.pan:r.animations.pan,autoscale:Le(d.autoscale)?d.autoscale:r.animations.autoscale,intro:Le(d.intro)?d.intro:r.animations.intro},panes:{separatorColor:re(h.separatorColor)?h.separatorColor:r.panes.separatorColor},trades:{visible:Le(p.visible)?p.visible:r.trades.visible,labels:Le(p.labels)?p.labels:r.trades.labels,qty:Le(p.qty)?p.qty:r.trades.qty,longColor:re(p.longColor)?p.longColor:r.trades.longColor,shortColor:re(p.shortColor)?p.shortColor:r.trades.shortColor,exitColor:re(p.exitColor)?p.exitColor:r.trades.exitColor},timeScale:{timezone:typeof m.timezone=="string"&&m.timezone?m.timezone:r.timeScale.timezone},marks:{visible:Le(f.visible)?f.visible:r.marks.visible,groups:{...r.marks.groups,...Object.fromEntries(Object.entries(g).filter(([,w])=>Le(w)))}},candles:{upColor:re(b.upColor)?b.upColor:r.candles.upColor,downColor:re(b.downColor)?b.downColor:r.candles.downColor,bodyVisible:Le(b.bodyVisible)?b.bodyVisible:r.candles.bodyVisible,borderVisible:Le(b.borderVisible)?b.borderVisible:r.candles.borderVisible,borderUpColor:re(b.borderUpColor)?b.borderUpColor:r.candles.borderUpColor,borderDownColor:re(b.borderDownColor)?b.borderDownColor:r.candles.borderDownColor,wickVisible:Le(b.wickVisible)?b.wickVisible:r.candles.wickVisible,wickUpColor:re(b.wickUpColor)?b.wickUpColor:r.candles.wickUpColor,wickDownColor:re(b.wickDownColor)?b.wickDownColor:r.candles.wickDownColor},bars:{upColor:re(y.upColor)?y.upColor:r.bars.upColor,downColor:re(y.downColor)?y.downColor:r.bars.downColor},line:{color:re(v.color)?v.color:r.line.color,width:Dt(v.width)?ah(v.width):r.line.width},area:{lineColor:re(S.lineColor)?S.lineColor:r.area.lineColor,width:Dt(S.width)?ah(S.width):r.area.width,topColor:re(S.topColor)?S.topColor:r.area.topColor,bottomColor:re(S.bottomColor)?S.bottomColor:r.area.bottomColor},baseline:{topLineColor:re(E.topLineColor)?E.topLineColor:r.baseline.topLineColor,bottomLineColor:re(E.bottomLineColor)?E.bottomLineColor:r.baseline.bottomLineColor,topFillColor:re(E.topFillColor)?E.topFillColor:r.baseline.topFillColor,topFillColor2:re(E.topFillColor2)?E.topFillColor2:r.baseline.topFillColor2,bottomFillColor:re(E.bottomFillColor)?E.bottomFillColor:r.baseline.bottomFillColor,bottomFillColor2:re(E.bottomFillColor2)?E.bottomFillColor2:r.baseline.bottomFillColor2,width:Dt(E.width)?ah(E.width):r.baseline.width,baselineLevel:Dt(E.baselineLevel)?iM(E.baselineLevel):r.baseline.baselineLevel},series:{style:tM(T.style)?T.style:r.series.style,baseline:T.baseline===null?null:Dt(T.baseline)?T.baseline:r.series.baseline,spacing:Dt(T.spacing)?oM(T.spacing):r.series.spacing},sessions:{premarketColor:re(k.premarketColor)?k.premarketColor:r.sessions.premarketColor,postmarketColor:re(k.postmarketColor)?k.postmarketColor:r.sessions.postmarketColor,extendedColor:re(k.extendedColor)?k.extendedColor:r.sessions.extendedColor},stacking:{candles:Dt(x.candles)?x.candles:r.stacking.candles,series:{...r.stacking.series,...Object.fromEntries(Object.entries(M).filter(([,w])=>Dt(w)))}}}}var as=class{constructor(e=4096){this.n=0;this.alpha=1;this.buf=new Float32Array(e*8);}reset(){this.n=0;}get vertexCount(){return this.n/8}get view(){return this.buf.subarray(0,this.n)}ensure(e){let t=this.n+e*8;if(t<=this.buf.length)return;let n=this.buf.length||8;for(;n<t;)n*=2;let i=new Float32Array(n);i.set(this.buf.subarray(0,this.n)),this.buf=i;}v(e,t,n,i=0,o=-1){let s=this.buf,a=this.n;s[a++]=e,s[a++]=t,s[a++]=n[0],s[a++]=n[1],s[a++]=n[2],s[a++]=n[3]*this.alpha,s[a++]=i,s[a++]=o,this.n=a;}tri(e,t,n,i,o,s,a,l,c){this.ensure(3),this.v(e,t,n),this.v(i,o,s),this.v(a,l,c);}quad4(e,t,n,i,o,s,a,l,c,u,d,h){this.ensure(6),this.v(e,t,n),this.v(i,o,s),this.v(a,l,c),this.v(e,t,n),this.v(a,l,c),this.v(u,d,h);}quad(e,t,n,i,o,s,a,l,c){this.quad4(e,t,c,n,i,c,o,s,c,a,l,c);}rect(e,t,n,i,o){this.quad(e,t,e+n,t,e+n,t+i,e,t+i,o);}seg(e,t,n,i,o,s){let a=n-e,l=i-t,c=Math.hypot(a,l);if(c<1e-6)return;let u=o/2,d=u+1,h=-l/c*d,p=a/c*d,m=e+h,f=t+p,g=n+h,b=i+p,y=n-h,v=i-p,S=e-h,E=t-p;this.ensure(6),this.v(m,f,s,d,u),this.v(g,b,s,d,u),this.v(y,v,s,-d,u),this.v(m,f,s,d,u),this.v(y,v,s,-d,u),this.v(S,E,s,-d,u);}dashedSeg(e,t,n,i,o,s,a){if(!a){this.seg(e,t,n,i,o,s);return}let l=n-e,c=i-t,u=Math.hypot(l,c);if(u<1e-6)return;let d=l/u,h=c/u,p=a[0]+a[1];if(p<=0){this.seg(e,t,n,i,o,s);return}let m=0;for(;m<u;){let f=Math.min(a[0],u-m),g=m,b=m+f;this.seg(e+d*g,t+h*g,e+d*b,t+h*b,o,s),m+=p;}}rectStroke(e,t,n,i,o,s){this.seg(e,t,e+n,t,o,s),this.seg(e+n,t,e+n,t+i,o,s),this.seg(e+n,t+i,e,t+i,o,s),this.seg(e,t+i,e,t,o,s);}circle(e,t,n,i,o=16){let s=e+n,a=t;for(let l=1;l<=o;l+=1){let c=l/o*Math.PI*2,u=e+Math.cos(c)*n,d=t+Math.sin(c)*n;this.tri(e,t,i,s,a,i,u,d,i),s=u,a=d;}}};var Sy=[0,0,0,1],Gn=null,sM=8192,Pi=new Map,xy=new Map;function te(r){if(!r)return Sy;let e=Pi.get(r);return e||(e=xy.get(r),e?(Pi.set(r,e),e):(e=aM(r),Pi.set(r,e),Pi.size>=sM&&(xy=Pi,Pi=new Map),e))}function Cy(r,e="#000000"){let[t,n,i,o]=te(r),s=t,a=n,l=i;if(o<1){let[h,p,m]=te(e);s=t*o+h*(1-o),a=n*o+p*(1-o),l=i*o+m*(1-o);}let c=.2126*uh(s)+.7152*uh(a)+.0722*uh(l),u=(c+.05)/.05,d=1.05/(c+.05);return u>=d?"#000000":"#ffffff"}function uh(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function aM(r){if(!Gn){let t=document.createElement("canvas");t.width=1,t.height=1,Gn=t.getContext("2d",{willReadFrequently:true});}if(!Gn)return Sy;Gn.clearRect(0,0,1,1),Gn.fillStyle="#000",Gn.fillStyle=r,Gn.fillRect(0,0,1,1);let e=Gn.getImageData(0,0,1,1).data;return [e[0]/255,e[1]/255,e[2]/255,e[3]/255]}var lM=`#version 300 es
|
|
768
|
+
`,document.head.appendChild(r);}var mc=class{constructor(e,t,n){this.plot=e;this.theme=t;this.deps=n;this.tipDisposers=[];this.hoverPaneId=null;this.onPlotMove=e=>{if(e.pointerType!=="mouse")return;let t=this.plot.getBoundingClientRect(),n=e.clientX-t.left,i=t.width-this.deps.rightAxis(),o=null;if(n>=i&&n<=i+64){let s=e.clientY-t.top;for(let a of this.deps.panes())if(!(a.collapsed||a.height<gy)&&s>=a.top&&s<=a.top+a.height){o=a.id;break}}this.setHoverPane(o),o&&this.sync();};this.onPlotLeave=()=>this.setHoverPane(null);tL(),this.cluster=document.createElement("div"),Object.assign(this.cluster.style,{position:"absolute",display:"none",justifyContent:"center",alignItems:"center",gap:`${ZE}px`,padding:`${by}px 0 ${vy}px`,width:`${QE}px`,boxSizing:"border-box",zIndex:"6",pointerEvents:"auto"}),this.applyTheme(),this.autoBtn=this.button("A","Auto (fits data to screen)",()=>this.deps.onToggleAuto(this.hoverPaneId??"")),this.logBtn=this.button("L","Logarithmic scale",()=>this.deps.onToggleLog(this.hoverPaneId??"")),this.cluster.append(this.autoBtn,this.logBtn),this.plot.appendChild(this.cluster),this.plot.addEventListener("pointermove",this.onPlotMove),this.plot.addEventListener("pointerleave",this.onPlotLeave);}button(e,t,n){let i=document.createElement("button");return i.type="button",i.setAttribute("aria-label",t),i.textContent=e,i.className="vela-axis-btn",Object.assign(i.style,{width:`${ch}px`,height:`${ch}px`}),this.tipDisposers.push(Kt(i,{host:this.plot,theme:()=>this.theme,text:()=>t,placement:"above"})),i.addEventListener("click",o=>{o.stopPropagation(),n(),this.sync();}),i}setTheme(e){this.theme=e,this.applyTheme();}applyTheme(){this.cluster.style.background=this.theme.background;}setHoverPane(e){this.hoverPaneId!==e&&(this.hoverPaneId=e,this.reposition());}reposition(){let e=this.hoverPaneId?this.deps.panes().find(t=>t.id===this.hoverPaneId):void 0;if(!e||e.collapsed||e.height<gy){this.cluster.style.display="none";return}this.cluster.style.right=`${this.deps.rightAxis()-64}px`,this.cluster.style.top=`${e.top+e.height-eL}px`,this.cluster.style.display="flex",this.sync();}sync(){let e=this.deps.panes().find(t=>t.id===this.hoverPaneId);e&&(this.autoBtn.classList.toggle("vela-axis-on",e.auto),this.logBtn.classList.toggle("vela-axis-on",e.log));}destroy(){this.plot.removeEventListener("pointermove",this.onPlotMove),this.plot.removeEventListener("pointerleave",this.onPlotLeave);for(let e of this.tipDisposers)e();this.tipDisposers.length=0,this.cluster.remove();}};var yy={panes:true,paneManagement:true,fills:"native",bgcolor:"native",hline:"native",markers:true,barcolor:"native",perPointColor:true,drawings:true,userDrawings:true,drawingDepth:true,tables:true,trades:true,timelineMarks:true,inputsUI:true},os=null;function wy(){if(os!==null)return os;try{os=!!document.createElement("canvas").getContext("webgl2");}catch{os=false;}return os}function ss(r){let e=Math.max(.5,Math.floor(r*.7)/2);return Math.max(1,Math.min(1.5,e))}function ki(r){return r<1?"aggregate":r<3?"wick":"full"}function nn(r,e){return Math.round(r*e)/e}function fc(r,e,t,n=1){let i=Math.max(1,Math.round(ss(e)*t)),o=Math.round(r*t-i/2),s=Math.max(i,Math.round(Math.floor(e*.7*n)*t));(s-i)%2!==0&&(s+=1);let a=(s-i)/2;return {wickX:o/t,wickW:i/t,bodyX:(o-a)/t,bodyW:s/t,center:(o+i/2)/t}}function gc(r,e,t,n,i,o){let s=[],a=NaN,l=[],c=()=>{if(l.length===0)return;l.sort((d,h)=>d.lo-h.lo);let u=[];for(let d of l){let h;for(let p=u.length-1;p>=0;p-=1)if(u[p].color===d.color){h=u[p];break}h&&Math.abs(i(h.hi)-i(d.lo))<1?(h.hi=d.hi,d.lastIdx>h.lastIdx&&(h.lastIdx=d.lastIdx)):u.push(d);}u.sort((d,h)=>d.lastIdx-h.lastIdx);for(let d of u)s.push({x:a,hi:d.hi,lo:d.lo,color:d.color});l=[];};for(let u=e;u<=t;u+=1){let d=r[u];if(!d||d.high<=d.low)continue;let h=Math.round(n(u));h!==a&&(c(),a=h);let p=o(d),m=d.low,f=d.high;for(let g=l.length-1;g>=0;g-=1){let b=l[g];b.color!==p||b.lo>f||b.hi<m||(b.lo<m&&(m=b.lo),b.hi>f&&(f=b.hi),l.splice(g,1));}l.push({lo:m,hi:f,color:p,lastIdx:u});}return c(),s}var dh=1,Ei=z,Li=W,Cn=.25,Tn=.05,nL=50,rL=q(ue,.08),xy=q(Ke,.08),iL=xy;function Sy(){return {chartTypes:{},fontSize:11,gridVert:{visible:true,color:null},gridHorz:{visible:true,color:null},borderColor:null,separatorColor:null,crosshair:{color:Zp,width:1,style:"dashed",opacity:.4,labelBackground:em},candle:{bodyVisible:true,borderVisible:false,borderUpColor:null,borderDownColor:null,wickVisible:true,wickUpColor:null,wickDownColor:null},bars:{upColor:null,downColor:null},line:{color:_,width:2},area:{lineColor:_,width:2,topColor:q(_,.28),bottomColor:q(_,.02)},baseline:{topLineColor:null,bottomLineColor:null,topFillColor:null,topFillColor2:null,bottomFillColor:null,bottomFillColor2:null,width:2,baselineLevel:nL},sessions:{premarketColor:rL,postmarketColor:xy,extendedColor:iL}}}var oL=["solid","dashed","dotted"],Cy=["candles","bars","line","area","baseline","heikinashi"];function hh(r){for(let e of Mt())if(e.id===r)return e.basePainting??"candles";return "candles"}function as(r){if(Cy.includes(r))return false;for(let e of Mt())if(e.id===r)return (e.basePainting??"candles")==="candles";return false}function bc(r,e){if(!as(r))return null;let t=e[r]??{},n=o=>re(o)?o:null,i=o=>Me(o)?o:null;return {upColor:n(t.candleUpColor),downColor:n(t.candleDownColor),bodyVisible:i(t.candleBodyVisible),borderVisible:i(t.candleBorderVisible),borderUpColor:n(t.candleBorderUpColor),borderDownColor:n(t.candleBorderDownColor),wickVisible:i(t.candleWickVisible),wickUpColor:n(t.candleWickUpColor),wickDownColor:n(t.candleWickDownColor)}}function Mi(r,e,t,n){return e?{up:e.upColor??t,down:e.downColor??n,candle:{bodyVisible:e.bodyVisible??r.bodyVisible,borderVisible:e.borderVisible??r.borderVisible,borderUpColor:e.borderUpColor??r.borderUpColor,borderDownColor:e.borderDownColor??r.borderDownColor,wickVisible:e.wickVisible??r.wickVisible,wickUpColor:e.wickUpColor??r.wickUpColor,wickDownColor:e.wickDownColor??r.wickDownColor}}:{up:t,down:n,candle:r}}function Pi(){let r=[...Cy];for(let e of Mt())r.includes(e.id)||r.push(e.id);return r}function re(r){return typeof r=="string"&&r.trim().length>0}function Me(r){return typeof r=="boolean"}function Ot(r){return typeof r=="number"&&Number.isFinite(r)}function sL(r){return typeof r=="string"&&oL.includes(r)}function aL(r){return typeof r=="string"&&Pi().includes(r)}function lL(r){return r==="price"||r==="percent"||r==="indexed"}function we(r){return r&&typeof r=="object"?r:{}}function cL(r){return r<0?0:r>1?1:r}function uh(r){return r<1?1:r>10?10:r}function uL(r){return r<0?0:r>100?100:r}function dL(r){return r<.1?.1:r>10?10:r}function Ty(r){let e={};for(let t of Mt()){let n=t.settings;if(!n)continue;let i={},o=s=>{for(let a of s??[])for(let l of so(a))i[l.key]=l.defval;};for(let s of n.instances??[])s.enableKey&&(i[s.enableKey]=false),o(s.rows);for(let s of n.subsections??[])s.enableKey&&(i[s.enableKey]=false),o(s.rows);n.instances||o(n.rows),e[t.id]=i;}for(let[t,n]of Object.entries(r.chartTypes))e[t]={...e[t]??{},...n};return {...r,chartTypes:e}}function ky(r,e){let t=we(e),n=we(t.chartTypes),i={...r.chartTypes};for(let[w,M]of Object.entries(n))i[w]={...i[w]??{},...we(M)};let o=we(t.layout),s=we(t.grid),a=we(s.vertLines),l=we(s.horzLines),c=we(t.crosshair),u=we(t.priceScale),d=we(t.animations),h=we(t.panes),p=we(t.trades),m=we(t.timeScale),f=we(t.marks),g=we(f.groups),b=we(t.candles),y=we(t.bars),v=we(t.line),S=we(t.area),E=we(t.baseline),T=we(t.series),k=we(t.sessions),x=we(t.stacking),L=we(x.series);return {version:dh,chartTypes:i,layout:{background:re(o.background)?o.background:r.layout.background,textColor:re(o.textColor)?o.textColor:r.layout.textColor,fontFamily:re(o.fontFamily)?o.fontFamily:r.layout.fontFamily,fontSize:Ot(o.fontSize)?Math.max(6,Math.min(32,o.fontSize)):r.layout.fontSize},grid:{vertLines:{visible:Me(a.visible)?a.visible:r.grid.vertLines.visible,color:re(a.color)?a.color:r.grid.vertLines.color},horzLines:{visible:Me(l.visible)?l.visible:r.grid.horzLines.visible,color:re(l.color)?l.color:r.grid.horzLines.color}},crosshair:{color:re(c.color)?c.color:r.crosshair.color,width:Ot(c.width)?Math.max(.5,Math.min(8,c.width)):r.crosshair.width,style:sL(c.style)?c.style:r.crosshair.style,opacity:Ot(c.opacity)?cL(c.opacity):r.crosshair.opacity,labelBackground:re(c.labelBackground)?c.labelBackground:r.crosshair.labelBackground},priceScale:{mode:lL(u.mode)?u.mode:r.priceScale.mode,log:Me(u.log)?u.log:r.priceScale.log,invert:Me(u.invert)?u.invert:r.priceScale.invert,borderColor:re(u.borderColor)?u.borderColor:r.priceScale.borderColor,labelsVisible:Me(u.labelsVisible)?u.labelsVisible:r.priceScale.labelsVisible,currentPriceLine:Me(u.currentPriceLine)?u.currentPriceLine:r.priceScale.currentPriceLine,priceLabel:Me(u.priceLabel)?u.priceLabel:r.priceScale.priceLabel,countdown:Me(u.countdown)?u.countdown:r.priceScale.countdown,animateLastPrice:Me(u.animateLastPrice)?u.animateLastPrice:r.priceScale.animateLastPrice},animations:{zoom:Me(d.zoom)?d.zoom:r.animations.zoom,pan:Me(d.pan)?d.pan:r.animations.pan,autoscale:Me(d.autoscale)?d.autoscale:r.animations.autoscale,intro:Me(d.intro)?d.intro:r.animations.intro},panes:{separatorColor:re(h.separatorColor)?h.separatorColor:r.panes.separatorColor},trades:{visible:Me(p.visible)?p.visible:r.trades.visible,labels:Me(p.labels)?p.labels:r.trades.labels,qty:Me(p.qty)?p.qty:r.trades.qty,longColor:re(p.longColor)?p.longColor:r.trades.longColor,shortColor:re(p.shortColor)?p.shortColor:r.trades.shortColor,exitColor:re(p.exitColor)?p.exitColor:r.trades.exitColor},timeScale:{timezone:typeof m.timezone=="string"&&m.timezone?m.timezone:r.timeScale.timezone},marks:{visible:Me(f.visible)?f.visible:r.marks.visible,groups:{...r.marks.groups,...Object.fromEntries(Object.entries(g).filter(([,w])=>Me(w)))}},candles:{upColor:re(b.upColor)?b.upColor:r.candles.upColor,downColor:re(b.downColor)?b.downColor:r.candles.downColor,bodyVisible:Me(b.bodyVisible)?b.bodyVisible:r.candles.bodyVisible,borderVisible:Me(b.borderVisible)?b.borderVisible:r.candles.borderVisible,borderUpColor:re(b.borderUpColor)?b.borderUpColor:r.candles.borderUpColor,borderDownColor:re(b.borderDownColor)?b.borderDownColor:r.candles.borderDownColor,wickVisible:Me(b.wickVisible)?b.wickVisible:r.candles.wickVisible,wickUpColor:re(b.wickUpColor)?b.wickUpColor:r.candles.wickUpColor,wickDownColor:re(b.wickDownColor)?b.wickDownColor:r.candles.wickDownColor},bars:{upColor:re(y.upColor)?y.upColor:r.bars.upColor,downColor:re(y.downColor)?y.downColor:r.bars.downColor},line:{color:re(v.color)?v.color:r.line.color,width:Ot(v.width)?uh(v.width):r.line.width},area:{lineColor:re(S.lineColor)?S.lineColor:r.area.lineColor,width:Ot(S.width)?uh(S.width):r.area.width,topColor:re(S.topColor)?S.topColor:r.area.topColor,bottomColor:re(S.bottomColor)?S.bottomColor:r.area.bottomColor},baseline:{topLineColor:re(E.topLineColor)?E.topLineColor:r.baseline.topLineColor,bottomLineColor:re(E.bottomLineColor)?E.bottomLineColor:r.baseline.bottomLineColor,topFillColor:re(E.topFillColor)?E.topFillColor:r.baseline.topFillColor,topFillColor2:re(E.topFillColor2)?E.topFillColor2:r.baseline.topFillColor2,bottomFillColor:re(E.bottomFillColor)?E.bottomFillColor:r.baseline.bottomFillColor,bottomFillColor2:re(E.bottomFillColor2)?E.bottomFillColor2:r.baseline.bottomFillColor2,width:Ot(E.width)?uh(E.width):r.baseline.width,baselineLevel:Ot(E.baselineLevel)?uL(E.baselineLevel):r.baseline.baselineLevel},series:{style:aL(T.style)?T.style:r.series.style,baseline:T.baseline===null?null:Ot(T.baseline)?T.baseline:r.series.baseline,spacing:Ot(T.spacing)?dL(T.spacing):r.series.spacing},sessions:{premarketColor:re(k.premarketColor)?k.premarketColor:r.sessions.premarketColor,postmarketColor:re(k.postmarketColor)?k.postmarketColor:r.sessions.postmarketColor,extendedColor:re(k.extendedColor)?k.extendedColor:r.sessions.extendedColor},stacking:{candles:Ot(x.candles)?x.candles:r.stacking.candles,series:{...r.stacking.series,...Object.fromEntries(Object.entries(L).filter(([,w])=>Ot(w)))}}}}var ls=class{constructor(e=4096){this.n=0;this.alpha=1;this.buf=new Float32Array(e*8);}reset(){this.n=0;}get vertexCount(){return this.n/8}get view(){return this.buf.subarray(0,this.n)}ensure(e){let t=this.n+e*8;if(t<=this.buf.length)return;let n=this.buf.length||8;for(;n<t;)n*=2;let i=new Float32Array(n);i.set(this.buf.subarray(0,this.n)),this.buf=i;}v(e,t,n,i=0,o=-1){let s=this.buf,a=this.n;s[a++]=e,s[a++]=t,s[a++]=n[0],s[a++]=n[1],s[a++]=n[2],s[a++]=n[3]*this.alpha,s[a++]=i,s[a++]=o,this.n=a;}tri(e,t,n,i,o,s,a,l,c){this.ensure(3),this.v(e,t,n),this.v(i,o,s),this.v(a,l,c);}quad4(e,t,n,i,o,s,a,l,c,u,d,h){this.ensure(6),this.v(e,t,n),this.v(i,o,s),this.v(a,l,c),this.v(e,t,n),this.v(a,l,c),this.v(u,d,h);}quad(e,t,n,i,o,s,a,l,c){this.quad4(e,t,c,n,i,c,o,s,c,a,l,c);}rect(e,t,n,i,o){this.quad(e,t,e+n,t,e+n,t+i,e,t+i,o);}seg(e,t,n,i,o,s){let a=n-e,l=i-t,c=Math.hypot(a,l);if(c<1e-6)return;let u=o/2,d=u+1,h=-l/c*d,p=a/c*d,m=e+h,f=t+p,g=n+h,b=i+p,y=n-h,v=i-p,S=e-h,E=t-p;this.ensure(6),this.v(m,f,s,d,u),this.v(g,b,s,d,u),this.v(y,v,s,-d,u),this.v(m,f,s,d,u),this.v(y,v,s,-d,u),this.v(S,E,s,-d,u);}dashedSeg(e,t,n,i,o,s,a){if(!a){this.seg(e,t,n,i,o,s);return}let l=n-e,c=i-t,u=Math.hypot(l,c);if(u<1e-6)return;let d=l/u,h=c/u,p=a[0]+a[1];if(p<=0){this.seg(e,t,n,i,o,s);return}let m=0;for(;m<u;){let f=Math.min(a[0],u-m),g=m,b=m+f;this.seg(e+d*g,t+h*g,e+d*b,t+h*b,o,s),m+=p;}}rectStroke(e,t,n,i,o,s){this.seg(e,t,e+n,t,o,s),this.seg(e+n,t,e+n,t+i,o,s),this.seg(e+n,t+i,e,t+i,o,s),this.seg(e,t+i,e,t,o,s);}circle(e,t,n,i,o=16){let s=e+n,a=t;for(let l=1;l<=o;l+=1){let c=l/o*Math.PI*2,u=e+Math.cos(c)*n,d=t+Math.sin(c)*n;this.tri(e,t,i,s,a,i,u,d,i),s=u,a=d;}}};var Ly=[0,0,0,1],Un=null,hL=8192,Ii=new Map,Ey=new Map;function te(r){if(!r)return Ly;let e=Ii.get(r);return e||(e=Ey.get(r),e?(Ii.set(r,e),e):(e=pL(r),Ii.set(r,e),Ii.size>=hL&&(Ey=Ii,Ii=new Map),e))}function My(r,e="#000000"){let[t,n,i,o]=te(r),s=t,a=n,l=i;if(o<1){let[h,p,m]=te(e);s=t*o+h*(1-o),a=n*o+p*(1-o),l=i*o+m*(1-o);}let c=.2126*ph(s)+.7152*ph(a)+.0722*ph(l),u=(c+.05)/.05,d=1.05/(c+.05);return u>=d?"#000000":"#ffffff"}function ph(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function pL(r){if(!Un){let t=document.createElement("canvas");t.width=1,t.height=1,Un=t.getContext("2d",{willReadFrequently:true});}if(!Un)return Ly;Un.clearRect(0,0,1,1),Un.fillStyle="#000",Un.fillStyle=r,Un.fillRect(0,0,1,1);let e=Un.getImageData(0,0,1,1).data;return [e[0]/255,e[1]/255,e[2]/255,e[3]/255]}var mL=`#version 300 es
|
|
769
769
|
layout(location=0) in vec2 aPos;
|
|
770
770
|
layout(location=1) in vec4 aColor;
|
|
771
771
|
layout(location=2) in vec2 aEdge; // (signed perpendicular distance from line center, half-width)
|
|
@@ -777,7 +777,7 @@ void main() {
|
|
|
777
777
|
gl_Position = vec4(clip, 0.0, 1.0);
|
|
778
778
|
vColor = aColor;
|
|
779
779
|
vEdge = aEdge;
|
|
780
|
-
}`,
|
|
780
|
+
}`,fL=`#version 300 es
|
|
781
781
|
precision highp float;
|
|
782
782
|
in vec4 vColor;
|
|
783
783
|
in vec2 vEdge;
|
|
@@ -787,13 +787,13 @@ void main() {
|
|
|
787
787
|
float aa = fwidth(vEdge.x);
|
|
788
788
|
float cov = clamp((vEdge.y - abs(vEdge.x)) / max(aa, 1e-4) + 0.5, 0.0, 1.0);
|
|
789
789
|
frag = vec4(vColor.rgb, vColor.a * cov);
|
|
790
|
-
}`,
|
|
790
|
+
}`,gL=`#version 300 es
|
|
791
791
|
layout(location=0) in vec2 aPos;
|
|
792
792
|
out vec2 vUv;
|
|
793
793
|
void main() {
|
|
794
794
|
vUv = aPos * 0.5 + 0.5;
|
|
795
795
|
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
796
|
-
}`,
|
|
796
|
+
}`,bL=`#version 300 es
|
|
797
797
|
precision mediump float;
|
|
798
798
|
in vec2 vUv;
|
|
799
799
|
uniform sampler2D uTex;
|
|
@@ -813,15 +813,15 @@ void main() {
|
|
|
813
813
|
sum += texture(uTex, vUv + o2) * 0.0702702703;
|
|
814
814
|
sum += texture(uTex, vUv - o2) * 0.0702702703;
|
|
815
815
|
frag = sum;
|
|
816
|
-
}`,dh={solid:null,dashed:[6,4],dotted:[2,3]};function Ty(r){return Math.max(6,Math.min(20,Math.round(r*4)))}var bc=class{constructor(){this.kind="webgl2";this.modelAlpha=1;this.candleBodyAlpha=1;this.candleStructureAlpha=1;this.candleBodyScale=1;this.onNeedsRedraw=null;this.onContextFailed=null;this.glow=0;this.canvas=null;this.gl=null;this.program=null;this.vao=null;this.vbo=null;this.uRes=null;this.batch=new as;this.contextLost=false;this.screenProgram=null;this.uTex=null;this.uDir=null;this.uIntensity=null;this.quadVao=null;this.quadVbo=null;this.fboA=null;this.texA=null;this.fboB=null;this.texB=null;this.fboW=0;this.fboH=0;this.glowBatch=new as;this.sliceTex=new Map;this.onLost=e=>{e.preventDefault(),this.contextLost=true;};this.onRestored=()=>{this.contextLost=false,this.initGL()?this.onNeedsRedraw?.():this.onContextFailed?.();};}get ok(){return this.gl!==null}mount(e){if(this.canvas=e,this.gl=e.getContext("webgl2",{alpha:true,antialias:true,depth:false,stencil:false,premultipliedAlpha:true}),!!this.gl){if(!this.initGL()){this.gl=null;return}e.addEventListener("webglcontextlost",this.onLost,false),e.addEventListener("webglcontextrestored",this.onRestored,false);}}initGL(){let e=this.gl;if(!e)return false;this.screenProgram=null,this.quadVao=null,this.quadVbo=null,this.fboA=this.fboB=null,this.texA=this.texB=null,this.fboW=this.fboH=0,this.sliceTex.clear();let t=fc(e,e.VERTEX_SHADER,lM),n=fc(e,e.FRAGMENT_SHADER,cM),i=e.createProgram();if(!t||!n||!i)return t&&e.deleteShader(t),n&&e.deleteShader(n),i&&e.deleteProgram(i),false;if(e.attachShader(i,t),e.attachShader(i,n),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))return e.deleteProgram(i),e.deleteShader(t),e.deleteShader(n),false;e.deleteShader(t),e.deleteShader(n),this.program=i,this.uRes=e.getUniformLocation(i,"uRes"),this.vbo=e.createBuffer(),this.vao=e.createVertexArray(),e.bindVertexArray(this.vao),e.bindBuffer(e.ARRAY_BUFFER,this.vbo);let o=32;return e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,false,o,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,4,e.FLOAT,false,o,8),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,false,o,24),e.bindVertexArray(null),this.glow>0&&!this.ensureScreenPipeline()&&(this.glow=0),true}ensureScreenPipeline(){if(this.screenProgram&&this.quadVao)return true;let e=this.gl;if(!e)return false;let t=fc(e,e.VERTEX_SHADER,uM),n=fc(e,e.FRAGMENT_SHADER,dM),i=e.createProgram();return !t||!n||!i?(t&&e.deleteShader(t),n&&e.deleteShader(n),i&&e.deleteProgram(i),false):(e.attachShader(i,t),e.attachShader(i,n),e.linkProgram(i),e.getProgramParameter(i,e.LINK_STATUS)?(e.deleteShader(t),e.deleteShader(n),this.screenProgram=i,this.uTex=e.getUniformLocation(i,"uTex"),this.uDir=e.getUniformLocation(i,"uDir"),this.uIntensity=e.getUniformLocation(i,"uIntensity"),this.quadVbo=e.createBuffer(),this.quadVao=e.createVertexArray(),e.bindVertexArray(this.quadVao),e.bindBuffer(e.ARRAY_BUFFER,this.quadVbo),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,false,0,0),e.bindVertexArray(null),true):(e.deleteProgram(i),false))}ensureFbos(e,t,n){if(this.fboA&&this.fboW===t&&this.fboH===n)return true;this.deleteFbos(e);let i=()=>{let a=e.createTexture();e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);let l=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a,0),{tex:a,fbo:l}},o=i(),s=i();return e.bindFramebuffer(e.FRAMEBUFFER,null),this.texA=o.tex,this.fboA=o.fbo,this.texB=s.tex,this.fboB=s.fbo,this.fboW=t,this.fboH=n,!!(this.fboA&&this.fboB)}deleteFbos(e){this.fboA&&e.deleteFramebuffer(this.fboA),this.fboB&&e.deleteFramebuffer(this.fboB),this.texA&&e.deleteTexture(this.texA),this.texB&&e.deleteTexture(this.texB),this.fboA=this.fboB=null,this.texA=this.texB=null,this.fboW=this.fboH=0;}render(e,t,n){let i=this.gl,o=this.canvas;if(!i||!o||!this.program||this.contextLost||i.isContextLost())return;let s=t.dpr,a=t.width;i.viewport(0,0,o.width,o.height),i.disable(i.SCISSOR_TEST),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT);let l=t.barCount;if(l===0)return;let c=t.visibleLogicalRange(),u=Math.max(0,Math.floor(c.from)),d=Math.min(l-1,Math.ceil(c.to));if(d<u)return;i.enable(i.BLEND),i.enable(i.SCISSOR_TEST);let h=mM(e.indicators),p=e.orderedPanes(),m=new Set;for(let f of p){let g=this.batch;g.reset();let b=Math.round(f.bounds.top*s),y=Math.round((f.bounds.top+f.bounds.height)*s);i.scissor(0,o.height-y,Math.round(a*s),y-b);let v=()=>{g.vertexCount!==0&&(i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA),i.useProgram(this.program),i.bindVertexArray(this.vao),i.uniform2f(this.uRes,o.width/s,o.height/s),i.bindBuffer(i.ARRAY_BUFFER,this.vbo),i.bufferData(i.ARRAY_BUFFER,g.view,i.DYNAMIC_DRAW),i.drawArrays(i.TRIANGLES,0,g.vertexCount),g.reset());},S=f.collapsed?[]:e.drawingSlices.get(f.id)??[],E=0,T=k=>{for(;E<S.length&&S[E].beforeZ<=k;E+=1)v(),this.drawSliceTexture(i,S[E].canvas)&&m.add(S[E].canvas);};if(g.alpha=1,!f.collapsed){let k=e.orderedIndicatorsForPane(f.id),x=f.kind==="price",M=P=>{let C=e.scaleFor(P,f);return C===f.scale?f:{...f,scale:C}};g.alpha=this.modelAlpha;for(let P of k)for(let C of P.backgrounds)C.overlay!==true&&this.emitBackground(g,C,f,t);if(x)for(let P of e.indicators.values())for(let C of P.backgrounds)C.overlay===true&&this.emitBackground(g,C,f,t);let w=x&&!e.candlesHidden,L=false;for(let P of k){w&&!L&&e.zOf(P.id)>=e.candleZ&&(T(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,u,d,t,f,n,h,a),L=true),T(e.zOf(P.id)),g.alpha=this.modelAlpha;let C=e.offsetOf(P.id),A=M(P);for(let $ of P.fills)$.overlay!==true&&this.emitFill(g,P,$,A,t,u,d,C);for(let $ of P.series)$.overlay!==true&&this.emitSeries(g,$,A,t,u,d,n,C);}if(w&&!L&&(T(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,u,d,t,f,n,h,a)),g.alpha=this.modelAlpha,x){for(let P of e.indicators.values()){let C=e.offsetOf(P.id);for(let A of P.fills)A.overlay===true&&this.emitFill(g,P,A,f,t,u,d,C);}for(let P of e.indicators.values()){let C=e.offsetOf(P.id);for(let A of P.series)A.overlay===true&&this.emitSeries(g,A,f,t,u,d,n,C);}}T(1/0);for(let P of k){let C=M(P);for(let A of P.priceLines)this.emitHline(g,A,C,t,a,n);}g.alpha=1;}v();}i.disable(i.SCISSOR_TEST);for(let[f,g]of this.sliceTex)m.has(f)||(i.deleteTexture(g),this.sliceTex.delete(f));this.glow>0&&!this.screenProgram&&!this.ensureScreenPipeline()&&(this.glow=0),this.glow>0&&this.screenProgram&&(this.glowBatch.alpha=this.modelAlpha,this.renderGlow(i,e,t,u,d));}renderGlow(e,t,n,i,o){let s=this.canvas,a=Math.max(1,s.width>>1),l=Math.max(1,s.height>>1);if(!this.ensureFbos(e,a,l))return;let c=n.dpr,u=n.width;e.bindFramebuffer(e.FRAMEBUFFER,this.fboA),e.viewport(0,0,a,l),e.disable(e.SCISSOR_TEST),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),e.useProgram(this.program),e.bindVertexArray(this.vao),e.uniform2f(this.uRes,s.width/c,s.height/c),e.enable(e.SCISSOR_TEST);for(let d of t.orderedPanes()){let h=this.glowBatch;if(h.reset(),this.emitGlowSources(h,t,d,n,i,o),h.vertexCount===0)continue;let p=Math.round(d.bounds.top*c*.5),m=Math.round((d.bounds.top+d.bounds.height)*c*.5);e.scissor(0,l-m,Math.round(u*c*.5),m-p),e.bindBuffer(e.ARRAY_BUFFER,this.vbo),e.bufferData(e.ARRAY_BUFFER,h.view,e.DYNAMIC_DRAW),e.drawArrays(e.TRIANGLES,0,h.vertexCount);}e.disable(e.SCISSOR_TEST),e.useProgram(this.screenProgram),e.bindVertexArray(this.quadVao),e.uniform1i(this.uTex,0),e.uniform1f(this.uIntensity,1),e.activeTexture(e.TEXTURE0),e.disable(e.BLEND),e.bindFramebuffer(e.FRAMEBUFFER,this.fboB),e.bindTexture(e.TEXTURE_2D,this.texA),e.uniform2f(this.uDir,1/a,0),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindFramebuffer(e.FRAMEBUFFER,this.fboA),e.bindTexture(e.TEXTURE_2D,this.texB),e.uniform2f(this.uDir,0,1/l),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,s.width,s.height),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE),e.bindTexture(e.TEXTURE_2D,this.texA),e.uniform2f(this.uDir,0,0),e.uniform1f(this.uIntensity,this.glow),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindTexture(e.TEXTURE_2D,null),e.bindVertexArray(null);}drawSliceTexture(e,t){if(!this.ensureScreenPipeline()||!this.screenProgram)return false;let n=this.sliceTex.get(t)??null;if(!n){if(n=e.createTexture(),!n)return false;this.sliceTex.set(t,n),e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);}return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,n),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,true),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,true),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,false),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,false),e.useProgram(this.screenProgram),e.bindVertexArray(this.quadVao),e.uniform1i(this.uTex,0),e.uniform2f(this.uDir,0,0),e.uniform1f(this.uIntensity,1),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindVertexArray(null),true}emitGlowSources(e,t,n,i,o,s){let a=(l,c)=>{!Fe(l)||l.visible===false||l.kind==="histogram"||l.kind==="columns"||(l.kind==="circles"||l.kind==="cross"?this.emitPointMarkers(e,l,n,i,o,s,c):this.emitPolyline(e,l,n,i,o,s,l.kind==="step",c));};for(let l of t.indicatorsForPane(n.id)){let c=t.offsetOf(l.id);for(let u of l.series)u.overlay!==true&&a(u,c);}if(n.kind==="price")for(let l of t.indicators.values()){let c=t.offsetOf(l.id);for(let u of l.series)u.overlay===true&&a(u,c);}}destroy(){let e=this.gl;if(this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.onLost),this.canvas.removeEventListener("webglcontextrestored",this.onRestored)),e){this.program&&e.deleteProgram(this.program),this.vbo&&e.deleteBuffer(this.vbo),this.vao&&e.deleteVertexArray(this.vao),this.screenProgram&&e.deleteProgram(this.screenProgram),this.quadVbo&&e.deleteBuffer(this.quadVbo),this.quadVao&&e.deleteVertexArray(this.quadVao);for(let t of this.sliceTex.values())e.deleteTexture(t);this.sliceTex.clear(),this.deleteFbos(e),e.getExtension("WEBGL_lose_context")?.loseContext();}this.gl=null,this.canvas=null,this.program=null,this.vao=null,this.vbo=null,this.screenProgram=null;}emitBackground(e,t,n,i){let o=i.timeToX(t.from),s=i.timeToX(t.to);s<0||o>i.width||s<=o||e.rect(o,n.bounds.top,s-o,n.bounds.height,te(t.color));}emitFill(e,t,n,i,o,s,a,l=0){let c=Ey(t,n.fromSeriesId),u=Ey(t,n.toSeriesId);if(!(!c||!u))for(let d=Math.max(1,s);d<=a;d+=1){let h=c[d-1-l],p=u[d-1-l],m=c[d-l],f=u[d-l];if(!h||!p||!m||!f||h.value===null||p.value===null||m.value===null||f.value===null)continue;let g=o.logicalToX(d-1),b=o.logicalToX(d),y=o.priceToY(h.value,i.scale,i.bounds),v=o.priceToY(p.value,i.scale,i.bounds),S=o.priceToY(m.value,i.scale,i.bounds),E=o.priceToY(f.value,i.scale,i.bounds),T=n.gradient?.[d-1-l];if(T){let k=o.priceToY(T.topValue,i.scale,i.bounds),x=o.priceToY(T.bottomValue,i.scale,i.bounds),M=x===k?k+1:x,w=te(T.topColor),L=te(T.bottomColor),P=M-k,C=A=>hh(w,L,gc((A-k)/P));e.quad4(g,y,C(y),b,S,C(S),b,E,C(E),g,v,C(v));}else {let k=n.colors?n.colors[d-1-l]:n.color;if(!k)continue;e.quad(g,y,b,S,b,E,g,v,te(k));}}}emitPriceSeries(e,t,n,i,o,s,a,l,c){if(t.basePainting==="none")return;let u=t.bars,d=t.style;switch(t.priceStyle){case "bars":this.emitBars(e,u,n,i,o,s,d.bars.upColor??a.upColor,d.bars.downColor??a.downColor,l);return;case "line":this.emitPriceLine(e,u,n,i,o,s,te(d.line.color??a.upColor),d.line.width);return;case "area":{let h=d.area.lineColor??a.upColor;this.emitPriceArea(e,u,n,i,o,s,te(d.area.topColor??h),te(d.area.bottomColor??"rgba(0,0,0,0)")),this.emitPriceLine(e,u,n,i,o,s,te(h),d.area.width);return}case "baseline":this.emitBaseline(e,u,n,i,o,s,t,a,c);return;default:this.emitCandles(e,t,u,n,i,o,s,a,l);}}emitBars(e,t,n,i,o,s,a,l,c){let u=o.bodySpacing(),d=Ti(u);if(d==="aggregate"){this.emitCandlesAggregated(e,t,n,i,o,s,a,l,c);return}let h=Math.max(1,Math.round(u*.35)),p=d==="full";for(let m=n;m<=i;m+=1){let f=t[m];if(!f||f.high<=f.low)continue;let g=te(c.get(f.time)??(f.close>=f.open?a:l)),b=Math.round(o.logicalToX(m)),y=o.priceToY(f.high,s.scale,s.bounds),v=o.priceToY(f.low,s.scale,s.bounds);if(e.rect(b-.5,y,1,v-y,g),p){let S=o.priceToY(f.open,s.scale,s.bounds),E=o.priceToY(f.close,s.scale,s.bounds);e.rect(b-h,S-.5,h,1,g),e.rect(b,E-.5,h,1,g);}}}emitPriceLine(e,t,n,i,o,s,a,l){let c=Math.max(1,l)/2,u=Ty(c),d=false,h=0,p=0;for(let m=Math.max(0,n-1);m<=i;m+=1){let f=t[m];if(!f){d=false;continue}let g=o.logicalToX(m),b=o.priceToY(f.close,s.scale,s.bounds);d&&e.seg(h,p,g,b,l,a),e.circle(g,b,c,a,u),h=g,p=b,d=true;}}emitPriceArea(e,t,n,i,o,s,a,l){let c=s.bounds.top+s.bounds.height,u=[],d=1/0,h=()=>{if(u.length>=2){let p=c-d,m=f=>hh(a,l,p<1e-6?0:gc((f-d)/p));for(let f=1;f<u.length;f+=1){let g=u[f-1],b=u[f];e.quad4(g.x,g.y,m(g.y),b.x,b.y,m(b.y),b.x,c,l,g.x,c,l);}}u.length=0,d=1/0;};for(let p=Math.max(0,n-1);p<=i;p+=1){let m=t[p];if(!m){h();continue}let f=o.logicalToX(p),g=o.priceToY(m.close,s.scale,s.bounds);u.push({x:f,y:g}),g<d&&(d=g);}h();}emitBaseline(e,t,n,i,o,s,a,l,c){let u=a.baselinePriceFor(s.scale),d=o.priceToY(u,s.scale,s.bounds),h=a.style.baseline,p=h.topLineColor??ki,m=h.bottomLineColor??Ei,f=te(p),g=te(m),b=te(h.topFillColor??q(p,Sn)),y=te(h.topFillColor2??q(p,Cn)),v=te(h.bottomFillColor??q(m,Sn)),S=te(h.bottomFillColor2??q(m,Cn)),E=[];for(let w=Math.max(0,n-1);w<=i;w+=1){let L=t[w];L&&E.push({x:o.logicalToX(w),y:o.priceToY(L.close,s.scale,s.bounds)});}if(E.length<2)return;let T=s.bounds.top,k=s.bounds.top+s.bounds.height,x=w=>w<=d?y:S,M=w=>{let L=w<=d,P=L?d-T:k-d,C=P>0?gc(Math.abs(w-d)/P):0;return hh(L?y:S,L?b:v,C)};for(let w=1;w<E.length;w+=1){let L=E[w-1],P=E[w];if(L.y<=d!=P.y<=d&&P.y!==L.y){let C=(d-L.y)/(P.y-L.y),A=L.x+(P.x-L.x)*C;e.tri(L.x,L.y,M(L.y),A,d,x(L.y),L.x,d,x(L.y)),e.tri(A,d,x(P.y),P.x,P.y,M(P.y),P.x,d,x(P.y));}else e.quad4(L.x,L.y,M(L.y),P.x,P.y,M(P.y),P.x,d,x(P.y),L.x,d,x(L.y));}e.dashedSeg(0,d,c,d,1,te(a.style.borderColor??l.borderColor),dh.dashed??null);for(let w=1;w<E.length;w+=1){let L=E[w-1],P=E[w],C=L.y<=d,A=P.y<=d;if(C!==A&&P.y!==L.y){let $=(d-L.y)/(P.y-L.y),ie=L.x+(P.x-L.x)*$;e.seg(L.x,L.y,ie,d,h.width,C?f:g),e.seg(ie,d,P.x,P.y,h.width,A?f:g);}else e.seg(L.x,L.y,P.x,P.y,h.width,C?f:g);}}emitCandles(e,t,n,i,o,s,a,l,c){let u=s.bodySpacing(),d=Ti(u),h=Mi(t.style.candle,t.candleOverride,l.upColor,l.downColor);if(d==="aggregate"){this.emitCandlesAggregated(e,n,i,o,s,a,h.up,h.down,c);return}let p=d==="full",m=h.up,f=h.down,g=h.candle,b=this.candleStructureAlpha>this.candleBodyAlpha+.001;for(let y=i;y<=o;y+=1){let v=n[y];if(!v||v.high<=v.low)continue;let S=hc(s.logicalToX(y),u,s.dpr,this.candleBodyScale),E=v.close>=v.open,T=E?m:f,x=c.get(v.time)??T,M=te(x),w=0,L=0;if(p){let P=s.priceToY(v.open,a.scale,a.bounds),C=s.priceToY(v.close,a.scale,a.bounds);w=tn(Math.min(P,C),s.dpr),L=Math.max(1/s.dpr,tn(Math.max(P,C),s.dpr)-w);}if(g.wickVisible){let P=tn(s.priceToY(v.high,a.scale,a.bounds),s.dpr),C=tn(s.priceToY(v.low,a.scale,a.bounds),s.dpr);e.alpha=this.candleStructureAlpha;let A=te((E?g.wickUpColor:g.wickDownColor)??(p?T:x));p?(e.rect(S.wickX,P,S.wickW,Math.max(0,w-P),A),e.rect(S.wickX,w+L,S.wickW,Math.max(0,C-(w+L)),A)):e.rect(S.wickX,P,S.wickW,C-P,A);}if(p&&(g.bodyVisible&&(e.alpha=this.candleBodyAlpha,e.rect(S.bodyX,w,S.bodyW,L,M)),g.borderVisible||b&&g.bodyVisible)){e.alpha=this.candleStructureAlpha;let P=g.borderVisible?te((E?g.borderUpColor:g.borderDownColor)??x):M,C=Math.max(0,S.bodyW-1),A=Math.max(0,L-1);e.rectStroke(S.bodyX+.5,w+.5,C,A,1,P);}}}emitCandlesAggregated(e,t,n,i,o,s,a,l,c){let u=d=>o.priceToY(d,s.scale,s.bounds);for(let d of pc(t,n,i,h=>o.logicalToX(h),u)){let h=te(c.get(d.headTime)??(d.close>=d.open?a:l)),p=u(d.hi);e.rect(d.x-.5,p,1,u(d.lo)-p,h);}}emitSeries(e,t,n,i,o,s,a,l=0){if(t.kind==="candle"||t.kind==="bar"){this.emitPlotCandles(e,t,n,i,o,s,a,l);return}if(!(!Fe(t)||t.visible===false))switch(t.kind){case "histogram":case "columns":this.emitHistogram(e,t,n,i,o,s,l);break;case "area":this.emitArea(e,t,n,i,o,s,l),this.emitPolyline(e,t,n,i,o,s,false,l);break;case "circles":case "cross":this.emitPointMarkers(e,t,n,i,o,s,l);break;case "step":this.emitPolyline(e,t,n,i,o,s,true,l);break;default:this.emitPolyline(e,t,n,i,o,s,false,l);}}emitPolyline(e,t,n,i,o,s,a,l=0){let c=Math.max(1,t.style.width),u=c/2,d=dh[t.style.lineStyle]??null,h=!d&&!a,p=Ty(u),m=false;for(let f=Math.max(1,o-1);f<=s;f+=1){let g=t.points[f-l],b=t.points[f-1-l];if(!g||g.value===null||!b||b.value===null){m=false;continue}let y=i.logicalToX(f),v=i.priceToY(g.value,n.scale,n.bounds),S=i.logicalToX(f-1),E=i.priceToY(b.value,n.scale,n.bounds),T=te(g.color??t.style.color);a?(e.dashedSeg(S,E,y,E,c,T,d),e.dashedSeg(y,E,y,v,c,T,d)):e.dashedSeg(S,E,y,v,c,T,d),h&&(m||e.circle(S,E,u,te(b.color??t.style.color),p),e.circle(y,v,u,T,p)),m=true;}}emitArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=te(t.style.color),u=[],d=1/0,h=()=>{if(u.length<1){u=[],d=1/0;return}let p=l-d,m=f=>hM(c,p<1e-6?0:gc((f-d)/p));for(let f=1;f<u.length;f+=1){let g=u[f-1],b=u[f];e.quad4(g.x,g.y,m(g.y),b.x,b.y,m(b.y),b.x,l,ky,g.x,l,ky);}u=[],d=1/0;};for(let p=o;p<=s;p+=1){let m=t.points[p-a];if(!m||m.value===null){h();continue}let f=i.logicalToX(p),g=i.priceToY(m.value,n.scale,n.bounds);u.push({x:f,y:g}),g<d&&(d=g);}h();}emitHistogram(e,t,n,i,o,s,a=0){let l=i.bodySpacing(),c=Math.max(1,(t.kind==="columns"?.7:.8)*l),u=c/2,d=t.style.base??0,h=i.priceToY(d,n.scale,n.bounds);for(let p=o;p<=s;p+=1){let m=t.points[p-a];if(!m||m.value===null)continue;let f=i.logicalToX(p),g=i.priceToY(m.value,n.scale,n.bounds);e.rect(f-u,Math.min(h,g),c,Math.max(1,Math.abs(g-h)),te(m.color??t.style.color));}}emitPointMarkers(e,t,n,i,o,s,a=0){let l=Math.max(1.5,t.style.width);for(let c=o;c<=s;c+=1){let u=t.points[c-a];if(!u||u.value===null)continue;let d=i.logicalToX(c),h=i.priceToY(u.value,n.scale,n.bounds),p=te(u.color??t.style.color);t.kind==="cross"?(e.seg(d-l,h,d+l,h,1,p),e.seg(d,h-l,d,h+l,1,p)):e.circle(d,h,l,p,Math.max(16,Math.ceil(l*2)));}}emitPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),u=t.style?.up??a.upColor,d=t.style?.down??a.downColor,h=t.kind==="bar",p=Math.max(.5,Math.floor(c*.7)/2),m=Math.max(1,Math.round(c*.35));for(let f=o;f<=s;f+=1){let g=t.bars[f-l];if(!g)continue;let b=t.barColors?.[f-l],y=te(b?.color??(g.close>=g.open?u:d)),v=Math.round(i.logicalToX(f)),S=i.priceToY(g.high,n.scale,n.bounds),E=i.priceToY(g.low,n.scale,n.bounds),T=i.priceToY(g.open,n.scale,n.bounds),k=i.priceToY(g.close,n.scale,n.bounds);if(h){e.rect(v-.5,S,1,E-S,y),e.rect(v-m,T-.5,m,1,y),e.rect(v,k-.5,m,1,y);continue}let x=Math.max(1,Math.round(os(c)*i.dpr)),M=(Math.round(v*i.dpr)-(x>>1))/i.dpr;e.rect(M,S,x/i.dpr,E-S,te(b?.wickColor??b?.color??(g.close>=g.open?u:d)));let w=Math.min(T,k),L=Math.max(1,Math.abs(k-T));if(e.rect(v-p,w,p*2,L,y),b?.borderColor){let P=te(b.borderColor);e.rect(v-p,w,p*2,1,P),e.rect(v-p,w+L-1,p*2,1,P),e.rect(v-p,w,1,L,P),e.rect(v+p-1,w,1,L,P);}}}emitHline(e,t,n,i,o,s){let a=Math.round(i.priceToY(t.price,n.scale,n.bounds));a<n.bounds.top||a>n.bounds.top+n.bounds.height||e.dashedSeg(0,a,o,a,t.width??1,te(t.color??s.textColor),dh[t.lineStyle??"solid"]??null);}};function fc(r,e,t){let n=r.createShader(e);return n?(r.shaderSource(n,t),r.compileShader(n),r.getShaderParameter(n,r.COMPILE_STATUS)?n:(r.deleteShader(n),null)):null}var ky=[0,0,0,0];function gc(r){return r<0?0:r>1?1:r}function hh(r,e,t){return [r[0]+(e[0]-r[0])*t,r[1]+(e[1]-r[1])*t,r[2]+(e[2]-r[2])*t,r[3]+(e[3]-r[3])*t]}function hM(r,e){let t=1-e;return [r[0]*t,r[1]*t,r[2]*t,r[3]*t]}function Ey(r,e){let t=r.series.find(n=>n.id===e);return t&&Fe(t)?t.points:null}var pM=new Map;function mM(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return pM;let t=new Map;for(let n of r.values())if(n.barColors)for(let i of n.barColors)t.set(i.time,i.color);return t}function ls(){return {barSpacing:8,rightOffset:6}}function nn(r){return Math.max(.5,Math.min(1e3,r))}function ph(r){if(r.length<2)return 0;let e=[];for(let t=1;t<r.length;t+=1){let n=r[t]-r[t-1];n>0&&e.push(n);}return e.length===0?0:(e.sort((t,n)=>t-n),e[Math.floor(e.length/2)])}function My(r,e,t){let n=e.length;if(n===0)return 0;let i=e[0],o=e[n-1];if(r<=i)return t>0?(r-i)/t:0;if(r>=o)return n-1+(t>0?(r-o)/t:0);let s=0,a=n-1;for(;a-s>1;){let c=s+a>>1;e[c]<=r?s=c:a=c;}let l=e[a]-e[s];return l>0?s+(r-e[s])/l:s}function Ly(r,e,t){let n=e.length;if(n===0)return 0;if(r<=0)return e[0]+(t>0?r*t:0);if(r>=n-1)return e[n-1]+(t>0?(r-(n-1))*t:0);let i=Math.floor(r),o=r-i;return e[i]+(e[i+1]-e[i])*o}var vc=class{constructor(){this.widthPx=0;this.dataHeightPx=0;this.devicePixelRatio=1;this.viewport=ls();this.pitchScale=1;this.times=[];this.intervalMs=0;}setSize(e,t,n){this.widthPx=e,this.dataHeightPx=t,this.devicePixelRatio=n>0?n:1;}setBars(e){this.times=e.slice(),this.intervalMs=ph(this.times);}appendBar(e){this.times.push(e),this.intervalMs<=0&&this.times.length>=2&&(this.intervalMs=ph(this.times));}setViewport(e){this.viewport=e;}getViewport(){return this.viewport}setPitchScale(e){this.pitchScale=Number.isFinite(e)&&e>0?e:1;}get spacingScale(){return this.pitchScale}pxPerBar(){return this.viewport.barSpacing*this.pitchScale}bodySpacing(){return this.viewport.barSpacing*Math.min(1,this.pitchScale)}get width(){return this.widthPx}get height(){return this.dataHeightPx}get dpr(){return this.devicePixelRatio}get barCount(){return this.times.length}get barInterval(){return this.intervalMs}get rightEdgeLogical(){return this.barCount-1+this.viewport.rightOffset}logicalToX(e){return this.widthPx-(this.rightEdgeLogical-e)*this.pxPerBar()}xToLogical(e){return this.rightEdgeLogical-(this.widthPx-e)/this.pxPerBar()}timeToLogical(e){return My(e,this.times,this.intervalMs)}logicalToTime(e){return Ly(e,this.times,this.intervalMs)}timeToX(e){return this.logicalToX(this.timeToLogical(e))}priceToY(e,t,n){if(t.log&&t.min>0&&t.max>t.min&&e>0){let s=Math.log(t.min),a=(Math.log(e)-s)/(Math.log(t.max)-s);return n.top+n.height*(t.invert?a:1-a)}let i=t.max-t.min;if(i<=0)return n.top+n.height/2;let o=(e-t.min)/i;return n.top+n.height*(t.invert?o:1-o)}yToPrice(e,t,n){if(n.height<=0)return t.min;let i=(e-n.top)/n.height,o=t.invert?i:1-i;if(t.log&&t.min>0&&t.max>t.min){let s=Math.log(t.min);return Math.exp(s+o*(Math.log(t.max)-s))}return t.min+(t.max-t.min)*o}visibleLogicalRange(){return {from:this.xToLogical(0),to:this.xToLogical(this.widthPx)}}visibleTimeRange(){let e=this.visibleLogicalRange();return {from:this.logicalToTime(e.from),to:this.logicalToTime(e.to)}}toBitmap(e){return Math.round(e*this.devicePixelRatio)}};function mh(r){return r>=3}function Py(r){return r>=2}var yc=class{constructor(e,t,n){this.onFrame=e;this.level=0;this.handle=null;this.raf=t??(i=>requestAnimationFrame(i)),this.cancel=n??(i=>cancelAnimationFrame(i));}invalidate(e){e<=0||(e>this.level&&(this.level=e),this.handle===null&&(this.handle=this.raf(()=>this.flush())));}flushNow(e){this.handle!==null&&(this.cancel(this.handle),this.handle=null),e>this.level&&(this.level=e),this.flush();}flush(){this.handle=null;let e=this.level;this.level=0,e!==0&&this.onFrame(e);}destroy(){this.handle!==null&&(this.cancel(this.handle),this.handle=null),this.level=0;}};var wc=class{constructor(e,t,n,i){this.tick=e;this.handle=null;this.last=0;this.stopped=false;this.loop=()=>{let e=this.now(),t=e-this.last;this.last=e;let n=this.tick(Math.min(t,64));this.handle=n&&!this.stopped?this.raf(this.loop):null;};this.raf=t??(o=>requestAnimationFrame(o)),this.cancel=n??(o=>cancelAnimationFrame(o)),this.now=i??(()=>performance.now());}get active(){return this.handle!==null}start(){this.stopped=false,this.handle===null&&(this.last=this.now(),this.handle=this.raf(this.loop));}stop(){this.stopped=true,this.handle!==null&&(this.cancel(this.handle),this.handle=null);}},Un=class{constructor(e,t=e){this.onMs=e,this.ms=t;}get tau(){return this.ms}get on(){return this.ms>0}set(e){this.ms=e,e>0&&(this.onMs=e);}toggle(e){this.ms=e?this.onMs:0;}};function vt(r,e,t,n){return n<=0?e:r+(e-r)*(1-Math.exp(-t/n))}var fM=.04,gM=60,bM=2,vM=350,Iy=8,yM=14,wM=350,xM=30,SM=.004,CM=.004,TM=.25;function kM(r,e,t){return t?{logical:r.rightEdgeLogical,x:r.width}:{logical:r.xToLogical(e),x:e}}function EM(r,e){return Math.abs(r)>Math.abs(e)}function MM(r,e,t){return r+e/t}function LM(r,e,t){return EM(r,e)?r:t?e:null}function PM(r,e){return r?"strong":e}function IM(r,e,t){return nn(r*(t/Math.max(1,e)))}function AM(r,e,t,n,i){return r-(e-1)+(t-n)/i}var xc=class{constructor(e){this.deps=e;this.rightEdgeZoom=true;this.axisDrag=true;this.paneResize=true;this.el=null;this.dragging=false;this.moved=false;this.region="data";this.verticalPan=false;this.startX=0;this.startY=0;this.startRightOffset=0;this.startBarSpacing=0;this.lastX=0;this.lastT=0;this.vx=0;this.middleDeleted=false;this.rightCancelled=false;this.cursorX=NaN;this.cursorY=NaN;this.touches=new Map;this.lpTimer=null;this.pinchStartDist=1;this.pinchStartBarSpacing=0;this.pinchAnchorLogical=0;this.lastTapT=0;this.lastTapX=0;this.lastTapY=0;this.onTouchContextMenu=e=>{this.touches.size!==0&&(!(e.target instanceof Node)||!this.el?.contains(e.target)||(e.preventDefault(),e.stopImmediatePropagation()));};this.onMiddleGuard=e=>{e.button===1&&this.middleDeleted&&e.preventDefault();};this.onContextGuard=e=>{this.rightCancelled&&(this.rightCancelled=false,e.preventDefault(),e.stopPropagation());};this.onModifier=e=>{e.repeat||e.key!=="Shift"&&e.key!=="Control"&&e.key!=="Meta"||Number.isNaN(this.cursorX)||this.dragging&&this.region!=="drawing"||this.deps.drawingsPointerMove?.(this.cursorX,this.cursorY,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey);};this.onDown=e=>{if(e.button===1){let{x:o,y:s}=this.local(e);this.middleDeleted=this.deps.drawingsDeleteAt?.(o,s)??false,this.middleDeleted&&e.preventDefault();return}if(e.button===2){this.rightCancelled=this.deps.drawingsCancelPlacement?.()??false,this.rightCancelled&&e.preventDefault();return}if(e.button!==0)return;let{x:t,y:n}=this.local(e);if(e.pointerType==="touch"){if(this.touches.size===1&&this.dragging&&(this.region==="data"||this.region==="crosshair")){this.touches.set(e.pointerId,{x:t,y:n}),this.beginPinch(e);return}if(this.touches.size>=1)return;this.touches.set(e.pointerId,{x:t,y:n});}if(this.deps.drawingsClearTransient?.(),this.dragging=true,this.moved=false,this.startX=t,this.startY=n,this.deps.drawingsClaim?.(t,n)){this.region="drawing",this.deps.drawingsPointerDown?.(t,n,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey),this.capture(e.pointerId);return}if(e.shiftKey&&this.regionAt(t,n)==="data"&&this.deps.drawingsMeasureStart?.(t,n,this.snapMode(e))){this.region="drawing",this.capture(e.pointerId);return}if((e.ctrlKey||e.metaKey)&&this.regionAt(t,n)==="data"&&this.deps.drawingsMarqueeStart?.(t,n)){this.region="drawing",this.capture(e.pointerId);return}let i=this.deps.getCoords().getViewport();this.deps.apply(i),this.startRightOffset=i.rightOffset,this.startBarSpacing=i.barSpacing,this.region=this.regionAt(t,n),this.verticalPan=false,this.region==="price"?this.deps.beginPriceScale(t,n):this.region==="separator"?this.deps.beginPaneResize(n):this.region==="data"&&(this.verticalPan=this.deps.beginPricePan(n)),e.pointerType==="touch"&&(this.region==="data"||this.region==="price"||this.region==="time")&&this.startLongPress(t,n,this.region),this.lastX=t,this.lastT=e.timeStamp,this.vx=0,this.capture(e.pointerId);};this.onMove=e=>{let{x:t,y:n}=this.local(e);if(this.cursorX=t,this.cursorY=n,e.pointerType==="touch"&&this.touches.has(e.pointerId)&&this.touches.set(e.pointerId,{x:t,y:n}),this.dragging&&this.region==="pinch"){this.applyPinch();return}if(this.dragging&&this.region==="crosshair"){this.deps.onPointerMove(t,n);return}if(this.dragging&&this.region==="axis-sheet")return;this.lpTimer!==null&&Math.hypot(t-this.startX,n-this.startY)>Iy&&this.cancelLongPress();let i=e.pointerType==="touch"?Iy:bM;if(this.dragging)if(this.region==="price")Math.abs(n-this.startY)>i&&(this.moved=true),this.deps.priceScaleBy(n-this.startY);else if(this.region==="separator")Math.abs(n-this.startY)>i&&(this.moved=true),this.deps.paneResizeBy(n-this.startY);else if(this.region==="time"){Math.abs(t-this.startX)>i&&(this.moved=true);let o=nn(this.startBarSpacing*Math.exp((this.startX-t)*SM));this.deps.apply({barSpacing:o,rightOffset:this.startRightOffset});}else if(this.region==="drawing")(Math.abs(t-this.startX)>i||Math.abs(n-this.startY)>i)&&(this.moved=true),this.deps.drawingsPointerMove?.(t,n,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey);else {let o=this.deps.getCoords(),s=o.getViewport(),a=t-this.startX;Math.abs(a)>i&&(this.moved=true),this.deps.apply({barSpacing:s.barSpacing,rightOffset:this.startRightOffset-a/o.pxPerBar()}),this.verticalPan&&(Math.abs(n-this.startY)>i&&(this.moved=true),this.deps.pricePanBy(n-this.startY));let l=e.timeStamp-this.lastT;if(l>0){let c=(t-this.lastX)/l;this.vx=this.vx*.6+c*.4,this.lastX=t,this.lastT=e.timeStamp;}}else if(this.el){let o=this.deps.drawingsCursor?.(t,n),s=this.regionAt(t,n);this.el.style.cursor=o??(s==="price"?"ns-resize":s==="time"?"ew-resize":s==="separator"?"row-resize":""),this.deps.drawingsPointerMove?.(t,n,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey);}e.pointerType!=="touch"&&this.deps.onPointerMove(t,n);};this.onUp=e=>{if(e.pointerType==="touch"&&this.touches.delete(e.pointerId),this.cancelLongPress(),this.dragging&&this.region==="pinch"){if(this.touches.size===1){let a=[...this.touches.values()][0],l=this.deps.getCoords().getViewport();this.region="data",this.verticalPan=false,this.startX=a.x,this.startY=a.y,this.startRightOffset=l.rightOffset,this.startBarSpacing=l.barSpacing,this.lastX=a.x,this.lastT=e.timeStamp,this.vx=0;return}this.endGesture(e);return}if(this.dragging&&this.region==="crosshair"){this.deps.onPointerMove(null,null),this.endGesture(e);return}if(this.dragging&&this.region==="axis-sheet"){this.endGesture(e);return}let{x:t,y:n}=this.local(e),i=e.pointerType==="touch",o=this.dragging&&!this.moved&&(!i||Math.hypot(t-this.startX,n-this.startY)<=yM);if(this.dragging&&this.region==="drawing")this.deps.drawingsPointerUp?.(t,n,this.snapMode(e));else if(o&&this.region==="data")this.deps.onClick(t,n);else if(this.dragging&&this.region==="data"&&!(e.timeStamp-this.lastT>gM)&&Math.abs(this.vx)>fM){let l=this.deps.getCoords().pxPerBar();this.deps.fling(-this.vx/l);}let s=i&&o;this.endGesture(e),i&&this.deps.onPointerMove(null,null),s&&this.registerTap(e.timeStamp,t,n);};this.onCancel=e=>{e.pointerType==="touch"&&this.touches.delete(e.pointerId),this.cancelLongPress(),this.dragging&&(this.region==="drawing"&&!Number.isNaN(this.cursorX)&&this.deps.drawingsPointerUp?.(this.cursorX,this.cursorY,this.snapMode(e)),(this.region==="crosshair"||e.pointerType==="touch")&&this.deps.onPointerMove(null,null),this.endGesture(e));};this.onLeave=()=>{this.cursorX=NaN,this.cursorY=NaN,this.deps.onPointerMove(null,null);};this.onDblClick=e=>{let{x:t,y:n}=this.local(e);this.doubleActivate(t,n);};this.onWheel=e=>{e.preventDefault(),this.deps.drawingsClearTransient?.();let{x:t,y:n}=this.local(e);if(this.regionAt(t,n)==="price"&&e.deltaY!==0){this.deps.beginPriceScale(t,n),this.deps.priceScaleBy(e.deltaY*TM);return}let i=this.deps.getCoords(),o=i.getViewport(),s=LM(e.deltaX,e.deltaY,e.shiftKey);if(s!=null){this.deps.apply({barSpacing:o.barSpacing,rightOffset:MM(o.rightOffset,s,i.pxPerBar())});return}let a=this.rightEdgeZoom&&!(e.ctrlKey||e.metaKey),l=kM(i,t,a),c=nn(o.barSpacing*Math.exp(-e.deltaY*CM));this.deps.zoomTo(c,l.logical,l.x);};}attach(e){this.el=e,e.style!==void 0&&(e.style.touchAction="none",e.style.userSelect="none",e.style.setProperty("-webkit-user-select","none"),e.style.setProperty("-webkit-touch-callout","none")),e.addEventListener("pointerdown",this.onDown),e.addEventListener("pointermove",this.onMove),e.addEventListener("pointerup",this.onUp),e.addEventListener("pointerleave",this.onLeave),e.addEventListener("pointercancel",this.onCancel),e.addEventListener("dblclick",this.onDblClick),e.addEventListener("wheel",this.onWheel,{passive:false}),e.addEventListener("mousedown",this.onMiddleGuard),e.addEventListener("auxclick",this.onMiddleGuard),e.addEventListener("contextmenu",this.onContextGuard);let t=e.ownerDocument?.defaultView;t?.addEventListener("keydown",this.onModifier),t?.addEventListener("keyup",this.onModifier),t?.addEventListener("contextmenu",this.onTouchContextMenu,true);}detach(){let e=this.el;if(!e)return;let t=e.ownerDocument?.defaultView;t?.removeEventListener("keydown",this.onModifier),t?.removeEventListener("keyup",this.onModifier),t?.removeEventListener("contextmenu",this.onTouchContextMenu,true),e.removeEventListener("pointerdown",this.onDown),e.removeEventListener("pointermove",this.onMove),e.removeEventListener("pointerup",this.onUp),e.removeEventListener("pointerleave",this.onLeave),e.removeEventListener("pointercancel",this.onCancel),e.removeEventListener("dblclick",this.onDblClick),e.removeEventListener("wheel",this.onWheel),e.removeEventListener("mousedown",this.onMiddleGuard),e.removeEventListener("auxclick",this.onMiddleGuard),e.removeEventListener("contextmenu",this.onContextGuard),this.cancelLongPress(),this.touches.clear(),this.el=null;}local(e){let t=this.el.getBoundingClientRect();return {x:e.clientX-t.left,y:e.clientY-t.top}}regionAt(e,t){let n=this.deps.getCoords();if(this.paneResize&&t<=n.height&&this.deps.paneSeparatorAt(t))return "separator";if(this.axisDrag){if(e>n.width&&t<=n.height)return "price";if(t>n.height&&e<=n.width)return "time"}return "data"}snapMode(e){return PM(e.ctrlKey||e.metaKey,this.deps.drawingsSnapMode?.()??"off")}startLongPress(e,t,n){this.cancelLongPress(),this.lpTimer=setTimeout(()=>{if(this.lpTimer=null,!(!this.dragging||this.region!==n)){if(n==="data"){this.region="crosshair",this.deps.onPointerMove(e,t);return}this.region="axis-sheet",this.moved=true,this.deps.onAxisLongPress?.(n,e,t);}},vM);}cancelLongPress(){this.lpTimer!==null&&clearTimeout(this.lpTimer),this.lpTimer=null;}beginPinch(e){this.cancelLongPress(),this.region==="crosshair"&&this.deps.onPointerMove(null,null);let t=this.deps.getCoords(),n=t.getViewport();this.deps.apply(n);let[i,o]=[...this.touches.values()];this.pinchStartDist=Math.max(1,Math.hypot(i.x-o.x,i.y-o.y)),this.pinchStartBarSpacing=n.barSpacing,this.pinchAnchorLogical=t.xToLogical((i.x+o.x)/2),this.region="pinch",this.dragging=true,this.moved=true,this.vx=0,this.capture(e.pointerId);}applyPinch(){let e=this.deps.getCoords(),t=[...this.touches.values()];if(t.length<2)return;let[n,i]=t,o=IM(this.pinchStartBarSpacing,this.pinchStartDist,Math.hypot(n.x-i.x,n.y-i.y)),s=e.getViewport(),a=s.barSpacing>0?e.pxPerBar()/s.barSpacing:1,l=(n.x+i.x)/2;this.deps.apply({barSpacing:o,rightOffset:AM(this.pinchAnchorLogical,e.barCount,e.width,l,o*a)});}capture(e){try{this.el?.setPointerCapture(e);}catch{}}registerTap(e,t,n){if(this.lastTapT>0&&e-this.lastTapT<=wM&&Math.hypot(t-this.lastTapX,n-this.lastTapY)<=xM){this.lastTapT=0,this.doubleActivate(this.lastTapX,this.lastTapY);return}this.lastTapT=e,this.lastTapX=t,this.lastTapY=n;}endGesture(e){this.dragging=false;try{this.el?.releasePointerCapture(e.pointerId);}catch{}}doubleActivate(e,t){if(this.deps.drawingsDblClick?.(e,t))return;let n=this.regionAt(e,t);n==="price"?this.deps.resetPriceScale(e,t):n==="separator"?this.deps.resetPaneSize(t):n==="time"?this.deps.resetView():this.deps.dataDblClick(e,t);}};function RM(r){if(r.ctrlKey||r.metaKey)return null;switch(r.key){case "ArrowLeft":return r.shiftKey?{kind:"pan",bars:-10}:{kind:"step",delta:-1};case "ArrowRight":return r.altKey&&r.shiftKey?{kind:"realtime"}:r.shiftKey?{kind:"pan",bars:10}:{kind:"step",delta:1};case "+":case "=":return {kind:"zoom",direction:1};case "-":case "_":return {kind:"zoom",direction:-1};case "Home":return {kind:"edge",edge:"first"};case "End":return {kind:"edge",edge:"last"};case "0":return {kind:"reset"};case "Escape":return {kind:"clear"};default:return null}}var Sc=class{constructor(e){this.deps=e;this.el=null;this.onKey=e=>{if(this.deps.preempt?.(e)){e.preventDefault();return}let t=RM(e);if(t)switch(e.preventDefault(),t.kind){case "pan":this.deps.panByBars(t.bars);break;case "zoom":this.deps.zoomByStep(t.direction);break;case "step":this.deps.stepCrosshair(t.delta);break;case "edge":this.deps.jumpToEdge(t.edge);break;case "reset":this.deps.resetView();break;case "realtime":this.deps.scrollToRealtime();break;case "clear":this.deps.clearCrosshair();break}};}attach(e){this.el=e,e.addEventListener("keydown",this.onKey);}detach(){this.el?.removeEventListener("keydown",this.onKey),this.el=null;}};var DM=Zp,OM=Jp,NM=Qp;function Vy(){return {visible:true,labels:true,qty:true,colors:{long:DM,short:OM,exit:NM}}}function _y(r,e){let t=e&&typeof e=="object"?e:{},n=t.colors&&typeof t.colors=="object"?t.colors:{},i=(s,a)=>typeof s=="boolean"?s:a,o=(s,a)=>typeof s=="string"&&s.trim().length>0?s:a;return {visible:i(t.visible,r.visible),labels:i(t.labels,r.labels),qty:i(t.qty,r.qty),colors:{long:o(n.long,r.colors.long),short:o(n.short,r.colors.short),exit:o(n.exit,r.colors.exit)}}}var fh=10,Yn=9,Dr=6,Ii=14,Cc=3,gh=2,By=2,bh=3,vh=6,Ay=6,Ry=8;function Hy(r){return r+4}function FM(r){if(r.qty==null||!Number.isFinite(r.qty))return null;let e=Number(Math.abs(r.qty).toFixed(8));return `${r.side==="buy"?"+":"-"}${e}`}function VM(r,e,t){let n=[];if(e.labels&&r.label&&n.push(r.label),e.qty){let i=FM(r);i&&n.push(i);}return {exec:r,lines:n,height:Ii+(n.length?bh+n.length*t:0)}}function zy(r,e,t,n,i,o){let s=new Map;for(let a of r){let l=Math.round(t.timeToLogical(a.time));if(l<n||l>i)continue;let c=s.get(l);c||(c={logical:l,buys:[],sells:[]},s.set(l,c)),(a.side==="buy"?c.buys:c.sells).push(VM(a,e,o));}return [...s.values()]}function Dy(r){if(r.length===0)return 0;let e=fh;for(let t of r)e+=t.height;return e+(r.length-1)*vh}function $y(r,e,t,n,i,o){if(r.length===0)return null;let s=Hy(o),a=1/0,l=-1/0,c=0,u=0;for(let d of zy(r,e,t,Math.floor(n),Math.ceil(i),s)){let h=t.barAt(d.logical);h&&(h.low<a&&(a=h.low),h.high>l&&(l=h.high),u=Math.max(u,Dy(d.buys)),c=Math.max(c,Dy(d.sells)));}return !Number.isFinite(a)||!Number.isFinite(l)?null:{min:a,max:l,abovePx:c,belowPx:u}}function Wy(r,e,t,n,i,o,s,a,l){if(e.length===0)return;let c=Hy(s.fontSize),u=zy(e,t,n,-1/0,1/0,c);if(u.length!==0){r.save(),r.font=`${s.fontSize}px ${s.fontFamily}`,r.textAlign="center",r.textBaseline="middle";for(let d of u){let h=i(d.logical);if(h<-150||h>a+150)continue;let p=n.barAt(d.logical);if(!p)continue;let m=Math.max(o(p.low),o(p.high)),f=Math.min(o(p.low),o(p.high)),g=m+fh;for(let b of d.buys)r.fillStyle=Oy(b.exec,t.colors),_M(r,h,g,b.exec.kind==="exit"),Ny(r,b.exec.side,h,o(b.exec.price),l),Fy(r,b.lines,h,g+Ii+bh+c/2,c,s.color),g+=b.height+vh;g=f-fh;for(let b of d.sells)r.fillStyle=Oy(b.exec,t.colors),BM(r,h,g,b.exec.kind==="exit"),Ny(r,b.exec.side,h,o(b.exec.price),l),Fy(r,b.lines,h,g-Ii-bh-c/2,-c,s.color),g-=b.height+vh;}r.restore();}}function Oy(r,e){return r.kind==="exit"?e.exit:r.side==="buy"?e.long:e.short}function _M(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-Yn/2,t+Dr),r.lineTo(e+Yn/2,t+Dr),r.closePath(),r.fill(),r.fillRect(e-Cc/2,t+Dr,Cc,Ii-Dr),n&&r.fillRect(e-Yn/2,t-By-gh,Yn,gh);}function BM(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-Yn/2,t-Dr),r.lineTo(e+Yn/2,t-Dr),r.closePath(),r.fill(),r.fillRect(e-Cc/2,t-Ii,Cc,Ii-Dr),n&&r.fillRect(e-Yn/2,t+By,Yn,gh);}function Ny(r,e,t,n,i){let o=e==="buy"?t-i:t+i,s=e==="buy"?o-Ay:o+Ay;r.beginPath(),r.moveTo(o,n),r.lineTo(s,n-Ry/2),r.lineTo(s,n+Ry/2),r.closePath(),r.fill();}function Fy(r,e,t,n,i,o){if(e.length!==0){r.fillStyle=o;for(let s=0;s<e.length;s+=1)r.fillText(e[s],t,n+s*i);}}function Gy(){return {visible:true,groups:{}}}function Uy(r,e){if(typeof e=="boolean")return {visible:e,groups:{...r.groups}};let t=e&&typeof e=="object"?e:{},n=t.groups&&typeof t.groups=="object"?t.groups:{},i={...r.groups};for(let[o,s]of Object.entries(n))typeof s=="boolean"&&(i[o]=s);return {visible:typeof t.visible=="boolean"?t.visible:r.visible,groups:i}}function Tc(r,e,t){if(e===void 0)return true;let n=r.groups[e];return typeof n=="boolean"?n:t.find(i=>i.id===e)?.visible!==false}var kc=class{constructor(){this.panes=new Map;this.indicators=new Map;this.bars=[];this.volumeLayer=null;this.nativeData=new Map;this.nativePending=new Map;this.vpvrLayer=null;this.crosshair=null;this.priceStyle="candles";this.basePainting="candles";this.candleOverride=null;this.baselineValue=null;this.showPriceLine=true;this.showPriceLabel=true;this.showCountdown=true;this.logScale=false;this.invertScale=false;this.priceMintick=void 0;this.scaleMode="price";this.percentBaseline=0;this.timezone="UTC";this.showGrid=true;this.style=by();this.showAxisLabels=true;this.tradeMarkers=Vy();this.marks=Gy();this.timelineMarks=[];this.markGroups=[];this.marksExpandedStack=null;this.marksHoverKey=null;this.marksHoverSince=0;this.marksActiveKey=null;this.marksFlash=null;this.highlights=[];this.sessionZones=null;this.candleZ=0;this.candlesHidden=false;this.seriesZ=new Map;this.drawingSlices=new Map;this.anchorOffsets=new Map;this.indicatorScales=new Map;this.orderedCache=null;}orderedPanes(){return this.orderedCache||(this.orderedCache=[...this.panes.values()].sort((e,t)=>e.order-t.order)),this.orderedCache}sessionHighlightBands(){if(!this.sessionZones)return [];let e=[];for(let[t,n]of this.sessionZones.pre)e.push({from:t,to:n,color:this.style.sessions.premarketColor});for(let[t,n]of this.sessionZones.post)e.push({from:t,to:n,color:this.style.sessions.postmarketColor});for(let[t,n]of this.sessionZones.extended)e.push({from:t,to:n,color:this.style.sessions.extendedColor});return e}indicatorsForPane(e){let t=[];for(let n of this.indicators.values())n.paneId===e&&t.push(n);return t}ownScaleIndicatorsForPane(e){return this.orderedIndicatorsForPane(e).filter(t=>t.ownScale===true)}ensureIndicatorScale(e,t){let n=this.indicatorScales.get(e);if(!n){let i=t??{min:0,max:1};n={scale:{...i},scaleTarget:{...i},initialized:false,manualScale:null},this.indicatorScales.set(e,n);}return n}dropIndicatorScale(e){this.indicatorScales.delete(e);}scaleFor(e,t){if(e.ownScale===true){let n=this.indicatorScales.get(e.id);if(n)return n.scale}return t.scale}orderPanes(e){e.forEach((t,n)=>{let i=this.panes.get(t);i&&(i.order=n);}),this.orderedCache=null;}orderedIndicatorsForPane(e){return this.indicatorsForPane(e).sort((t,n)=>this.zOf(t.id)-this.zOf(n.id))}zOf(e){return this.seriesZ.get(e)??0}offsetOf(e){return this.anchorOffsets.get(e)??0}setAnchorOffset(e,t){t!==0&&Number.isFinite(t)?this.anchorOffsets.set(e,t):this.anchorOffsets.delete(e);}forgetAnchorOffset(e){this.anchorOffsets.delete(e);}baselinePriceFor(e){if(this.baselineValue!=null)return this.baselineValue;let t=this.style.baseline.baselineLevel/100;if(e.log&&e.min>0&&e.max>e.min){let n=Math.log(e.min);return Math.exp(n+t*(Math.log(e.max)-n))}return e.min+(e.max-e.min)*t}assignIndicatorZ(e){this.seriesZ.has(e)||this.seriesZ.set(e,this.bottomZ()-1);}assignIndicatorZTop(e){this.seriesZ.has(e)||this.seriesZ.set(e,this.topZ()+1);}forgetIndicatorZ(e){this.seriesZ.delete(e);}setIndicatorZ(e,t){this.seriesZ.set(e,t);}indicatorZOrder(){return [...this.seriesZ.entries()].map(([e,t])=>({id:e,z:t})).sort((e,t)=>e.z-t.z)}seriesBoundaries(e){let t=new Set;e==="price"&&t.add(this.candleZ);for(let n of this.indicatorsForPane(e))t.add(this.zOf(n.id));return [...t].sort((n,i)=>n-i)}bringIndicatorToFront(e){this.seriesZ.set(e,this.topZ()+1);}sendIndicatorToBack(e){this.seriesZ.set(e,this.bottomZ()-1);}topZ(){let e=this.candleZ;for(let t of this.seriesZ.values())t>e&&(e=t);return e}bottomZ(){let e=this.candleZ;for(let t of this.seriesZ.values())t<e&&(e=t);return e}ensurePane(e,t,n,i){this.orderedCache=null;let o=this.panes.get(e);if(o)return o.order=n,o.heightWeight=i,o.kind=t,o;let s={id:e,kind:t,order:n,heightWeight:i,bounds:{top:0,height:0},scale:{min:0,max:1},scaleTarget:{min:0,max:1},initialized:false,manualScale:null,collapsed:false,percentBaseline:0};return this.panes.set(e,s),s}removePane(e){this.panes.delete(e),this.orderedCache=null;}};function yh(r,e){return e.kind==="price"?r.scaleMode:e.scaleMode??"price"}function Ai(r,e){return e.kind==="price"?r.logScale:e.logScale??false}function wh(r,e){return e.kind==="price"?r.invertScale:e.invert??false}function Tn(r,e){let t=yh(r,e);if(t!=="percent"&&t!=="indexed")return;let n=e.percentBaseline;if(!(!Number.isFinite(n)||n===0))return {baseline:n,indexed:t==="indexed"}}var cs=class{constructor(){this.kind="canvas2d";this.modelAlpha=1;this.candleBodyAlpha=1;this.candleStructureAlpha=1;this.candleBodyScale=1;this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}render(e,t,n){let i=this.ctx,o=this.canvas;if(!i||!o)return;let s=t.dpr,a=o.width/s,l=o.height/s,c=t.width;i.setTransform(s,0,0,s,0,0),i.clearRect(0,0,a,l);let u=t.barCount;if(u===0)return;let d=t.visibleLogicalRange(),h=Math.max(0,Math.floor(d.from)),p=Math.min(u-1,Math.ceil(d.to));if(p<h)return;let m=zM(e.indicators),f=e.orderedPanes();for(let g of f){if(g.collapsed)continue;let b=e.orderedIndicatorsForPane(g.id),y=g.kind==="price";i.save(),i.beginPath(),i.rect(0,g.bounds.top,c,g.bounds.height),i.clip();let v=M=>{let w=e.scaleFor(M,g);return w===g.scale?g:{...g,scale:w}};i.globalAlpha=this.modelAlpha;for(let M of b)for(let w of M.backgrounds)w.overlay!==true&&this.drawBackground(i,w,g,t);if(y)for(let M of e.indicators.values())for(let w of M.backgrounds)w.overlay===true&&this.drawBackground(i,w,g,t);let S=e.drawingSlices.get(g.id)??[],E=0,T=M=>{for(;E<S.length&&S[E].beforeZ<=M;E+=1)i.globalAlpha=1,i.drawImage(S[E].canvas,0,0,a,l);},k=y&&!e.candlesHidden,x=false;for(let M of b){k&&!x&&e.zOf(M.id)>=e.candleZ&&(T(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c),x=true),T(e.zOf(M.id)),i.globalAlpha=this.modelAlpha;let w=e.offsetOf(M.id),L=v(M);for(let P of M.fills)P.overlay!==true&&this.drawFill(i,M,P,L,t,h,p,w);for(let P of M.series)P.overlay!==true&&this.drawSeries(i,P,L,t,h,p,n,w);}if(k&&!x&&(T(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c)),y){i.globalAlpha=this.modelAlpha;for(let M of e.indicators.values()){let w=e.offsetOf(M.id);for(let L of M.fills)L.overlay===true&&this.drawFill(i,M,L,g,t,h,p,w);}for(let M of e.indicators.values()){let w=e.offsetOf(M.id);for(let L of M.series)L.overlay===true&&this.drawSeries(i,L,g,t,h,p,n,w);}}T(1/0),i.globalAlpha=this.modelAlpha;for(let M of b){let w=v(M);for(let L of M.priceLines)this.drawHline(i,L,w,t,c,n);}i.restore();}}destroy(){this.canvas=null,this.ctx=null;}drawPriceSeries(e,t,n,i,o,s,a,l,c){if(t.basePainting==="none")return;let u=t.bars,d=t.style;switch(t.priceStyle){case "bars":this.drawBars(e,u,n,i,o,s,d.bars.upColor??a.upColor,d.bars.downColor??a.downColor,l);return;case "line":this.drawPriceLine(e,u,n,i,o,s,d.line.color??a.upColor,d.line.width);return;case "area":{let h=d.area.lineColor??a.upColor;this.drawPriceArea(e,u,n,i,o,s,d.area.topColor??h,d.area.bottomColor??"rgba(0,0,0,0)"),this.drawPriceLine(e,u,n,i,o,s,h,d.area.width);return}case "baseline":this.drawBaseline(e,u,n,i,o,s,t,a,c);return;default:this.drawCandles(e,t,u,n,i,o,s,a,l);}}drawBars(e,t,n,i,o,s,a,l,c){let u=o.bodySpacing(),d=Ti(u);if(d==="aggregate"){this.drawCandlesAggregated(e,t,n,i,o,s,a,l,c);return}let h=Math.max(1,Math.round(u*.35)),p=d==="full";e.lineWidth=1;for(let m=n;m<=i;m+=1){let f=t[m];if(!f||f.high<=f.low)continue;let g=Math.round(o.logicalToX(m))+.5,b=c.get(f.time)??(f.close>=f.open?a:l),y=o.priceToY(f.high,s.scale,s.bounds),v=o.priceToY(f.low,s.scale,s.bounds);if(e.strokeStyle=b,e.beginPath(),e.moveTo(g,y),e.lineTo(g,v),p){let S=o.priceToY(f.open,s.scale,s.bounds),E=o.priceToY(f.close,s.scale,s.bounds);e.moveTo(g-h,S),e.lineTo(g,S),e.moveTo(g,E),e.lineTo(g+h,E);}e.stroke();}}drawPriceLine(e,t,n,i,o,s,a,l){e.lineWidth=l,e.lineJoin="round",e.lineCap="round",e.strokeStyle=a,e.beginPath();let c=false;for(let u=Math.max(0,n-1);u<=i;u+=1){let d=t[u];if(!d){c=false;continue}let h=o.logicalToX(u),p=o.priceToY(d.close,s.scale,s.bounds);c?e.lineTo(h,p):(e.moveTo(h,p),c=true);}e.stroke(),e.lineCap="butt";}drawPriceArea(e,t,n,i,o,s,a,l){let c=s.bounds.top+s.bounds.height,u=[],d=1/0;for(let p=Math.max(0,n-1);p<=i;p+=1){let m=t[p];if(!m)continue;let f=o.logicalToX(p),g=o.priceToY(m.close,s.scale,s.bounds);u.push({x:f,y:g}),g<d&&(d=g);}if(u.length<2)return;let h=e.createLinearGradient(0,d,0,c);h.addColorStop(0,a),h.addColorStop(1,l),e.fillStyle=h,e.beginPath(),e.moveTo(u[0].x,c);for(let p of u)e.lineTo(p.x,p.y);e.lineTo(u[u.length-1].x,c),e.closePath(),e.fill();}drawBaseline(e,t,n,i,o,s,a,l,c){let u=a.baselinePriceFor(s.scale),d=o.priceToY(u,s.scale,s.bounds),h=s.bounds.top,p=s.bounds.top+s.bounds.height,m=a.style.baseline,f=m.topLineColor??ki,g=m.bottomLineColor??Ei,b=m.topFillColor??q(f,Sn),y=m.topFillColor2??q(f,Cn),v=m.bottomFillColor??q(g,Sn),S=m.bottomFillColor2??q(g,Cn),E=[];for(let x=Math.max(0,n-1);x<=i;x+=1){let M=t[x];M&&E.push({x:o.logicalToX(x),y:o.priceToY(M.close,s.scale,s.bounds)});}if(E.length<2)return;let T=()=>{e.beginPath(),e.moveTo(E[0].x,d);for(let x of E)e.lineTo(x.x,x.y);e.lineTo(E[E.length-1].x,d),e.closePath();};if(d>h){e.save(),e.beginPath(),e.rect(0,h,c,d-h),e.clip();let x=e.createLinearGradient(0,h,0,d);x.addColorStop(0,b),x.addColorStop(1,y),e.fillStyle=x,T(),e.fill(),e.restore();}if(d<p){e.save(),e.beginPath(),e.rect(0,d,c,p-d),e.clip();let x=e.createLinearGradient(0,d,0,p);x.addColorStop(0,S),x.addColorStop(1,v),e.fillStyle=x,T(),e.fill(),e.restore();}e.strokeStyle=a.style.borderColor??l.borderColor,e.lineWidth=1,Ri(e,"dashed"),e.beginPath(),e.moveTo(0,Math.round(d)+.5),e.lineTo(c,Math.round(d)+.5),e.stroke(),Ri(e,"solid"),e.lineWidth=m.width,e.lineJoin="round",e.lineCap="round";let k=(x,M,w,L,P)=>{e.strokeStyle=P,e.beginPath(),e.moveTo(x,M),e.lineTo(w,L),e.stroke();};for(let x=1;x<E.length;x+=1){let M=E[x-1],w=E[x],L=M.y<=d,P=w.y<=d;if(L!==P&&w.y!==M.y){let C=(d-M.y)/(w.y-M.y),A=M.x+(w.x-M.x)*C;k(M.x,M.y,A,d,L?f:g),k(A,d,w.x,w.y,P?f:g);}else k(M.x,M.y,w.x,w.y,L?f:g);}e.lineCap="butt";}drawCandles(e,t,n,i,o,s,a,l,c){let u=s.bodySpacing(),d=Ti(u),h=Mi(t.style.candle,t.candleOverride,l.upColor,l.downColor);if(d==="aggregate"){this.drawCandlesAggregated(e,n,i,o,s,a,h.up,h.down,c);return}let p=d==="full",m=h.candle,f=this.candleStructureAlpha>this.candleBodyAlpha+.001;for(let g=i;g<=o;g+=1){let b=n[g];if(!b||b.high<=b.low)continue;let y=hc(s.logicalToX(g),u,s.dpr,this.candleBodyScale),v=y.center,S=b.close>=b.open,E=S?h.up:h.down,k=c.get(b.time)??E,x=0,M=0;if(p){let w=s.priceToY(b.open,a.scale,a.bounds),L=s.priceToY(b.close,a.scale,a.bounds);x=tn(Math.min(w,L),s.dpr),M=Math.max(1/s.dpr,tn(Math.max(w,L),s.dpr)-x);}if(m.wickVisible){let w=(S?m.wickUpColor:m.wickDownColor)??(p?E:k),L=tn(s.priceToY(b.high,a.scale,a.bounds),s.dpr),P=tn(s.priceToY(b.low,a.scale,a.bounds),s.dpr);e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=w,e.lineWidth=y.wickW,e.beginPath(),p?(e.moveTo(v,L),e.lineTo(v,x),e.moveTo(v,x+M),e.lineTo(v,P)):(e.moveTo(v,L),e.lineTo(v,P)),e.stroke();}if(p&&(m.bodyVisible&&(e.globalAlpha=this.candleBodyAlpha,e.fillStyle=k,e.fillRect(y.bodyX,x,y.bodyW,M)),m.borderVisible||f&&m.bodyVisible)){e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=m.borderVisible?(S?m.borderUpColor:m.borderDownColor)??k:k,e.lineWidth=1;let w=Math.max(0,y.bodyW-1),L=Math.max(0,M-1);e.strokeRect(y.bodyX+.5,x+.5,w,L);}}}drawCandlesAggregated(e,t,n,i,o,s,a,l,c){let u=d=>o.priceToY(d,s.scale,s.bounds);e.lineWidth=1;for(let d of pc(t,n,i,h=>o.logicalToX(h),u)){let h=d.x+.5;e.strokeStyle=c.get(d.headTime)??(d.close>=d.open?a:l),e.beginPath(),e.moveTo(h,u(d.hi)),e.lineTo(h,u(d.lo)),e.stroke();}}drawSeries(e,t,n,i,o,s,a,l=0){if(t.kind==="candle"||t.kind==="bar"){this.drawPlotCandles(e,t,n,i,o,s,a,l);return}if(!(!Fe(t)||t.visible===false))switch(t.kind){case "histogram":case "columns":this.drawHistogram(e,t,n,i,o,s,l);break;case "area":this.drawArea(e,t,n,i,o,s,l),this.drawPolyline(e,t,n,i,o,s,false,l);break;case "circles":case "cross":this.drawPointMarkers(e,t,n,i,o,s,l);break;case "step":this.drawPolyline(e,t,n,i,o,s,true,l);break;default:this.drawPolyline(e,t,n,i,o,s,false,l);}}drawPolyline(e,t,n,i,o,s,a,l=0){e.lineWidth=Math.max(1,t.style.width),e.lineJoin="round",Ri(e,t.style.lineStyle);let c=0,u=0,d=false;for(let h=Math.max(1,o-1);h<=s;h+=1){let p=t.points[h-l],m=t.points[h-1-l];if(!p||p.value===null||!m||m.value===null){d=false;continue}let f=i.logicalToX(h),g=i.priceToY(p.value,n.scale,n.bounds);d||(c=i.logicalToX(h-1),u=i.priceToY(m.value,n.scale,n.bounds)),e.strokeStyle=p.color??t.style.color,e.beginPath(),e.moveTo(c,u),a&&e.lineTo(f,u),e.lineTo(f,g),e.stroke(),c=f,u=g,d=true;}Ri(e,"solid");}drawArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=[],u=1/0,d=()=>{if(c.length===0)return;let h=e.createLinearGradient(0,u,0,l);h.addColorStop(0,t.style.color),h.addColorStop(1,"rgba(0,0,0,0)"),e.fillStyle=h,e.beginPath(),e.moveTo(c[0].x,l);for(let p of c)e.lineTo(p.x,p.y);e.lineTo(c[c.length-1].x,l),e.closePath(),e.fill(),c=[],u=1/0;};for(let h=o;h<=s;h+=1){let p=t.points[h-a];if(!p||p.value===null){d();continue}let m=i.logicalToX(h),f=i.priceToY(p.value,n.scale,n.bounds);c.push({x:m,y:f}),f<u&&(u=f);}d();}drawHistogram(e,t,n,i,o,s,a=0){let l=i.bodySpacing(),c=Math.max(1,(t.kind==="columns"?.7:.8)*l),u=c/2,d=t.style.base??0,h=i.priceToY(d,n.scale,n.bounds);for(let p=o;p<=s;p+=1){let m=t.points[p-a];if(!m||m.value===null)continue;let f=i.logicalToX(p),g=i.priceToY(m.value,n.scale,n.bounds);e.fillStyle=m.color??t.style.color,e.fillRect(f-u,Math.min(h,g),c,Math.max(1,Math.abs(g-h)));}}drawPointMarkers(e,t,n,i,o,s,a=0){let l=Math.max(1.5,t.style.width);for(let c=o;c<=s;c+=1){let u=t.points[c-a];if(!u||u.value===null)continue;let d=i.logicalToX(c),h=i.priceToY(u.value,n.scale,n.bounds);e.strokeStyle=u.color??t.style.color,e.fillStyle=u.color??t.style.color,t.kind==="cross"?(e.lineWidth=1,e.beginPath(),e.moveTo(d-l,h),e.lineTo(d+l,h),e.moveTo(d,h-l),e.lineTo(d,h+l),e.stroke()):(e.beginPath(),e.arc(d,h,l,0,Math.PI*2),e.fill());}}drawPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),u=t.style?.up??a.upColor,d=t.style?.down??a.downColor,h=t.kind==="bar",p=Math.max(.5,Math.floor(c*.7)/2),m=Math.max(1,Math.round(c*.35));for(let f=o;f<=s;f+=1){let g=t.bars[f-l];if(!g)continue;let b=t.barColors?.[f-l],y=b?.color??(g.close>=g.open?u:d),v=Math.round(i.logicalToX(f))+.5,S=i.priceToY(g.high,n.scale,n.bounds),E=i.priceToY(g.low,n.scale,n.bounds),T=i.priceToY(g.open,n.scale,n.bounds),k=i.priceToY(g.close,n.scale,n.bounds);if(h){e.strokeStyle=y,e.lineWidth=1,e.beginPath(),e.moveTo(v,S),e.lineTo(v,E),e.moveTo(v-m,T),e.lineTo(v,T),e.moveTo(v,k),e.lineTo(v+m,k),e.stroke();continue}e.strokeStyle=b?.wickColor??y,e.lineWidth=os(c),e.beginPath(),e.moveTo(v,S),e.lineTo(v,E),e.stroke(),e.fillStyle=y,e.fillRect(v-p,Math.min(T,k),p*2,Math.max(1,Math.abs(k-T))),b?.borderColor&&(e.strokeStyle=b.borderColor,e.strokeRect(v-p,Math.min(T,k),p*2,Math.max(1,Math.abs(k-T))));}}drawFill(e,t,n,i,o,s,a,l=0){let c=Yy(t,n.fromSeriesId),u=Yy(t,n.toSeriesId);if(!c||!u)return;let d=NaN,h=NaN,p="",m="",f=null;for(let g=Math.max(1,s);g<=a;g+=1){let b=c[g-1-l],y=u[g-1-l],v=c[g-l],S=u[g-l];if(!b||!y||!v||!S||b.value===null||y.value===null||v.value===null||S.value===null)continue;let E=o.logicalToX(g-1),T=o.logicalToX(g),k=o.priceToY(b.value,i.scale,i.bounds),x=o.priceToY(y.value,i.scale,i.bounds),M=o.priceToY(v.value,i.scale,i.bounds),w=o.priceToY(S.value,i.scale,i.bounds),L=n.gradient?.[g-1-l];if(L){let P=o.priceToY(L.topValue,i.scale,i.bounds),C=o.priceToY(L.bottomValue,i.scale,i.bounds),A=C===P?P+1:C;(!f||P!==d||A!==h||L.topColor!==p||L.bottomColor!==m)&&(f=e.createLinearGradient(0,P,0,A),f.addColorStop(0,L.topColor),f.addColorStop(1,L.bottomColor),d=P,h=A,p=L.topColor,m=L.bottomColor),e.fillStyle=f;}else {let P=n.colors?n.colors[g-1-l]:n.color;if(!P)continue;e.fillStyle=P;}e.beginPath(),e.moveTo(E,k),e.lineTo(T,M),e.lineTo(T,w),e.lineTo(E,x),e.closePath(),e.fill();}}drawBackground(e,t,n,i){let o=i.timeToX(t.from),s=i.timeToX(t.to);s<0||o>i.width||s<=o||(e.fillStyle=t.color,e.fillRect(o,n.bounds.top,s-o,n.bounds.height));}drawHline(e,t,n,i,o,s){let a=Math.round(i.priceToY(t.price,n.scale,n.bounds))+.5;a<n.bounds.top||a>n.bounds.top+n.bounds.height||(e.strokeStyle=t.color??s.textColor,e.lineWidth=t.width??1,Ri(e,t.lineStyle??"solid"),e.beginPath(),e.moveTo(0,a),e.lineTo(o,a),e.stroke(),Ri(e,"solid"));}};function Ri(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function Yy(r,e){let t=r.series.find(n=>n.id===e);return t&&Fe(t)?t.points:null}var HM=new Map;function zM(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return HM;let t=new Map;for(let n of r.values())if(n.barColors)for(let i of n.barColors)t.set(i.time,i.color);return t}function Kn(r,e){let t=Math.max(1,e);return r==="dotted"?[t,t*2]:r==="dashed"?[t*4,t*3]:[]}function Di(r,e,t,n,i,o,s){if(i==="none")return [r,e,t,n];let a=t-r,l=i==="left"||i==="both",c=i==="right"||i==="both";if(Math.abs(a)<1e-6){if(l&&c)return [r,0,t,s];let m=n>=e;return c?m?[r,e,t,s]:[r,e,t,0]:m?[r,0,t,n]:[r,s,t,n]}let u=(n-e)/a,d=m=>e+u*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,d(h),p,d(p)]}function Ky(r,e,t,n){let i=Math.atan2(n-e,t-r);return i>Math.PI/2&&(i-=Math.PI),i<-Math.PI/2&&(i+=Math.PI),i}function $M(r){let e=r.trim(),t=/^#([0-9a-f]{3})$/i.exec(e);if(t){let n=t[1];return {r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:1}}if(t=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(e),t){let n=t[1];return {r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16),a:t[2]?parseInt(t[2],16)/255:1}}if(t=/^rgba?\(([^)]+)\)$/i.exec(e),t){let n=t[1].split(",").map(i=>parseFloat(i.trim()));return {r:n[0]??0,g:n[1]??0,b:n[2]??0,a:n[3]??1}}return null}function WM(r,e,t){return (.299*r+.587*e+.114*t)/255}function _e(r){if(!r)return "#000000";let e=$M(r);return e?WM(e.r,e.g,e.b)>.55?"#000000":"#ffffff":"#000000"}function rn(r){return Math.round(r*1.4)}var Or=5,Nr=3;function Be(r){switch(r){case "tiny":return 10;case "small":return 12;case "large":return 18;case "huge":return 28;case "normal":return 14;default:return 0}}function Xy(r,e,t,n){let i=1;for(let l of r)l.length>i&&(i=l.length);let o=n?.62:.55,s=e*.9/(i*o),a=t*.85/(r.length*1.3);return Math.max(6,Math.min(s,a,48))}var GM={lines:[],boxes:[],labels:[],polylines:[],linefills:[]};function Ni(r,e){let t=n=>!!n.overlay===e;return {lines:(r.lines??[]).filter(t),boxes:(r.boxes??[]).filter(t),labels:(r.labels??[]).filter(t),polylines:(r.polylines??[]).filter(t),linefills:(r.linefills??[]).filter(t)}}function xh(r){return !r.lines.length&&!r.boxes.length&&!r.labels.length&&!r.polylines.length&&!r.linefills.length}function jy(r){return r==="auto"?12:Be(r)}function UM(r,e,t,n,i){let o=Math.min(r,e),s=Math.max(r,e);return r===e?r>=n&&r<=i:t==="both"?true:t==="left"?s>=n:(t==="right"||s>=n)&&o<=i}var Oi=class{constructor(e,t=GM){this.deps=e;this.set=t;this.widthCache=new Map;this.tipRegions=[];this.indexOffset=0;}setSet(e,t=0){this.set=e,this.indexOffset=t;}setDeps(e){this.deps=e;}isEmpty(){let e=this.set;return !e.lines.length&&!e.boxes.length&&!e.labels.length&&!e.polylines.length&&!e.linefills.length}labelTipRegions(){return this.tipRegions}render(e,t,n,i,o){this.tipRegions=[],!this.isEmpty()&&(e.save(),this.drawLinefills(e,t,n,i,o),this.drawBoxes(e,t,n,i,o),this.drawPolylines(e,t,i,o),this.drawLines(e,t,n,i,o),this.drawLabels(e,t,n,i,o),e.restore());}priceRange(e,t){let n=Math.min(e,t),i=Math.max(e,t),o=(d,h,p)=>p==="both"?true:p==="left"?Math.max(d,h)>=n:(p==="right"||Math.max(d,h)>=n)&&Math.min(d,h)<=i,s=1/0,a=-1/0,l=d=>{d<s&&(s=d),d>a&&(a=d);};for(let d of this.set.lines)d.invisible||UM(this.logicalOf(d.xloc,d.x1),this.logicalOf(d.xloc,d.x2),d.extend,n,i)&&(l(d.y1),l(d.y2));for(let d of this.set.boxes)!d.bgColor&&!(d.borderColor&&d.borderWidth>0)&&!d.text||o(this.logicalOf(d.xloc,d.left),this.logicalOf(d.xloc,d.right),d.extend)&&(l(d.top),l(d.bottom));for(let d of this.set.linefills){if(!d.color)continue;let h=[d.line1.x1,d.line1.x2,d.line2.x1,d.line2.x2].map((m,f)=>this.logicalOf(f<2?d.line1.xloc:d.line2.xloc,m)),p=d.line1.extend!=="none"||d.line2.extend!=="none"?"both":"none";o(Math.min(...h),Math.max(...h),p)&&(l(d.line1.y1),l(d.line1.y2),l(d.line2.y1),l(d.line2.y2));}for(let d of this.set.polylines){if(d.points.length<2)continue;let h=d.points.map(p=>this.logicalOf(p.xloc,p.x));if(o(Math.min(...h),Math.max(...h),"none"))for(let p of d.points)l(p.price);}let c=0,u=0;for(let d of this.set.labels){let h=this.logicalOf(d.xloc,d.x);if(!o(h,h,"none"))continue;if(d.yloc==="price"){l(d.y);continue}if(d.yloc==="top"||d.yloc==="bottom")continue;let p=this.deps.barAt(h);if(!p)continue;l(d.yloc==="abovebar"?p.high:p.low);let m=jy(d.size),f=Math.max(1,(d.text??"").split(`
|
|
817
|
-
`).length),g=this.isPointShape(d.style)?14+Math.max(4,m*.6)+2:14+m*1.25*f+8+7;d.yloc==="abovebar"?c=Math.max(c,g):u=Math.max(u,g);}return !Number.isFinite(s)||!Number.isFinite(a)?null:{min:s,max:a,aboveMargin:c,belowMargin:u}}logicalOf(e,t){return e==="bar_time"?this.deps.timeToLogical(t):t+this.indexOffset}drawLines(e,t,n,i,o){for(let s of this.set.lines){if(s.invisible)continue;let a=i(this.logicalOf(s.xloc,s.x1)),l=i(this.logicalOf(s.xloc,s.x2)),c=o(s.y1),u=o(s.y2);if(c===null||u===null)continue;let d=s.extend==="left"||s.extend==="both",h=s.extend==="right"||s.extend==="both";if(!d&&!h&&(Math.max(a,l)<0||Math.min(a,l)>t))continue;let[p,m,f,g]=
|
|
816
|
+
}`,mh={solid:null,dashed:[6,4],dotted:[2,3]};function Py(r){return Math.max(6,Math.min(20,Math.round(r*4)))}var wc=class{constructor(){this.kind="webgl2";this.modelAlpha=1;this.candleBodyAlpha=1;this.candleStructureAlpha=1;this.candleBodyScale=1;this.onNeedsRedraw=null;this.onContextFailed=null;this.glow=0;this.canvas=null;this.gl=null;this.program=null;this.vao=null;this.vbo=null;this.uRes=null;this.batch=new ls;this.contextLost=false;this.screenProgram=null;this.uTex=null;this.uDir=null;this.uIntensity=null;this.quadVao=null;this.quadVbo=null;this.fboA=null;this.texA=null;this.fboB=null;this.texB=null;this.fboW=0;this.fboH=0;this.glowBatch=new ls;this.sliceTex=new Map;this.onLost=e=>{e.preventDefault(),this.contextLost=true;};this.onRestored=()=>{this.contextLost=false,this.initGL()?this.onNeedsRedraw?.():this.onContextFailed?.();};}get ok(){return this.gl!==null}mount(e){if(this.canvas=e,this.gl=e.getContext("webgl2",{alpha:true,antialias:true,depth:false,stencil:false,premultipliedAlpha:true}),!!this.gl){if(!this.initGL()){this.gl=null;return}e.addEventListener("webglcontextlost",this.onLost,false),e.addEventListener("webglcontextrestored",this.onRestored,false);}}initGL(){let e=this.gl;if(!e)return false;this.screenProgram=null,this.quadVao=null,this.quadVbo=null,this.fboA=this.fboB=null,this.texA=this.texB=null,this.fboW=this.fboH=0,this.sliceTex.clear();let t=vc(e,e.VERTEX_SHADER,mL),n=vc(e,e.FRAGMENT_SHADER,fL),i=e.createProgram();if(!t||!n||!i)return t&&e.deleteShader(t),n&&e.deleteShader(n),i&&e.deleteProgram(i),false;if(e.attachShader(i,t),e.attachShader(i,n),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))return e.deleteProgram(i),e.deleteShader(t),e.deleteShader(n),false;e.deleteShader(t),e.deleteShader(n),this.program=i,this.uRes=e.getUniformLocation(i,"uRes"),this.vbo=e.createBuffer(),this.vao=e.createVertexArray(),e.bindVertexArray(this.vao),e.bindBuffer(e.ARRAY_BUFFER,this.vbo);let o=32;return e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,false,o,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,4,e.FLOAT,false,o,8),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,false,o,24),e.bindVertexArray(null),this.glow>0&&!this.ensureScreenPipeline()&&(this.glow=0),true}ensureScreenPipeline(){if(this.screenProgram&&this.quadVao)return true;let e=this.gl;if(!e)return false;let t=vc(e,e.VERTEX_SHADER,gL),n=vc(e,e.FRAGMENT_SHADER,bL),i=e.createProgram();return !t||!n||!i?(t&&e.deleteShader(t),n&&e.deleteShader(n),i&&e.deleteProgram(i),false):(e.attachShader(i,t),e.attachShader(i,n),e.linkProgram(i),e.getProgramParameter(i,e.LINK_STATUS)?(e.deleteShader(t),e.deleteShader(n),this.screenProgram=i,this.uTex=e.getUniformLocation(i,"uTex"),this.uDir=e.getUniformLocation(i,"uDir"),this.uIntensity=e.getUniformLocation(i,"uIntensity"),this.quadVbo=e.createBuffer(),this.quadVao=e.createVertexArray(),e.bindVertexArray(this.quadVao),e.bindBuffer(e.ARRAY_BUFFER,this.quadVbo),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,false,0,0),e.bindVertexArray(null),true):(e.deleteProgram(i),false))}ensureFbos(e,t,n){if(this.fboA&&this.fboW===t&&this.fboH===n)return true;this.deleteFbos(e);let i=()=>{let a=e.createTexture();e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);let l=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,l),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a,0),{tex:a,fbo:l}},o=i(),s=i();return e.bindFramebuffer(e.FRAMEBUFFER,null),this.texA=o.tex,this.fboA=o.fbo,this.texB=s.tex,this.fboB=s.fbo,this.fboW=t,this.fboH=n,!!(this.fboA&&this.fboB)}deleteFbos(e){this.fboA&&e.deleteFramebuffer(this.fboA),this.fboB&&e.deleteFramebuffer(this.fboB),this.texA&&e.deleteTexture(this.texA),this.texB&&e.deleteTexture(this.texB),this.fboA=this.fboB=null,this.texA=this.texB=null,this.fboW=this.fboH=0;}render(e,t,n){let i=this.gl,o=this.canvas;if(!i||!o||!this.program||this.contextLost||i.isContextLost())return;let s=t.dpr,a=t.width;i.viewport(0,0,o.width,o.height),i.disable(i.SCISSOR_TEST),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT);let l=t.barCount;if(l===0)return;let c=t.visibleLogicalRange(),u=Math.max(0,Math.floor(c.from)),d=Math.min(l-1,Math.ceil(c.to));if(d<u)return;i.enable(i.BLEND),i.enable(i.SCISSOR_TEST);let h=wL(e.indicators),p=e.orderedPanes(),m=new Set;for(let f of p){let g=this.batch;g.reset();let b=Math.round(f.bounds.top*s),y=Math.round((f.bounds.top+f.bounds.height)*s);i.scissor(0,o.height-y,Math.round(a*s),y-b);let v=()=>{g.vertexCount!==0&&(i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA),i.useProgram(this.program),i.bindVertexArray(this.vao),i.uniform2f(this.uRes,o.width/s,o.height/s),i.bindBuffer(i.ARRAY_BUFFER,this.vbo),i.bufferData(i.ARRAY_BUFFER,g.view,i.DYNAMIC_DRAW),i.drawArrays(i.TRIANGLES,0,g.vertexCount),g.reset());},S=f.collapsed?[]:e.drawingSlices.get(f.id)??[],E=0,T=k=>{for(;E<S.length&&S[E].beforeZ<=k;E+=1)v(),this.drawSliceTexture(i,S[E].canvas)&&m.add(S[E].canvas);};if(g.alpha=1,!f.collapsed){let k=e.orderedIndicatorsForPane(f.id),x=f.kind==="price",L=P=>{let C=e.scaleFor(P,f);return C===f.scale?f:{...f,scale:C}};g.alpha=this.modelAlpha;for(let P of k)for(let C of P.backgrounds)C.overlay!==true&&this.emitBackground(g,C,f,t);if(x)for(let P of e.indicators.values())for(let C of P.backgrounds)C.overlay===true&&this.emitBackground(g,C,f,t);let w=x&&!e.candlesHidden,M=false;for(let P of k){w&&!M&&e.zOf(P.id)>=e.candleZ&&(T(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,u,d,t,f,n,h,a),M=true),T(e.zOf(P.id)),g.alpha=this.modelAlpha;let C=e.offsetOf(P.id),A=L(P);for(let $ of P.fills)$.overlay!==true&&this.emitFill(g,P,$,A,t,u,d,C);for(let $ of P.series)$.overlay!==true&&this.emitSeries(g,$,A,t,u,d,n,C);}if(w&&!M&&(T(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,u,d,t,f,n,h,a)),g.alpha=this.modelAlpha,x){for(let P of e.indicators.values()){let C=e.offsetOf(P.id);for(let A of P.fills)A.overlay===true&&this.emitFill(g,P,A,f,t,u,d,C);}for(let P of e.indicators.values()){let C=e.offsetOf(P.id);for(let A of P.series)A.overlay===true&&this.emitSeries(g,A,f,t,u,d,n,C);}}T(1/0);for(let P of k){let C=L(P);for(let A of P.priceLines)this.emitHline(g,A,C,t,a,n);}g.alpha=1;}v();}i.disable(i.SCISSOR_TEST);for(let[f,g]of this.sliceTex)m.has(f)||(i.deleteTexture(g),this.sliceTex.delete(f));this.glow>0&&!this.screenProgram&&!this.ensureScreenPipeline()&&(this.glow=0),this.glow>0&&this.screenProgram&&(this.glowBatch.alpha=this.modelAlpha,this.renderGlow(i,e,t,u,d));}renderGlow(e,t,n,i,o){let s=this.canvas,a=Math.max(1,s.width>>1),l=Math.max(1,s.height>>1);if(!this.ensureFbos(e,a,l))return;let c=n.dpr,u=n.width;e.bindFramebuffer(e.FRAMEBUFFER,this.fboA),e.viewport(0,0,a,l),e.disable(e.SCISSOR_TEST),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),e.useProgram(this.program),e.bindVertexArray(this.vao),e.uniform2f(this.uRes,s.width/c,s.height/c),e.enable(e.SCISSOR_TEST);for(let d of t.orderedPanes()){let h=this.glowBatch;if(h.reset(),this.emitGlowSources(h,t,d,n,i,o),h.vertexCount===0)continue;let p=Math.round(d.bounds.top*c*.5),m=Math.round((d.bounds.top+d.bounds.height)*c*.5);e.scissor(0,l-m,Math.round(u*c*.5),m-p),e.bindBuffer(e.ARRAY_BUFFER,this.vbo),e.bufferData(e.ARRAY_BUFFER,h.view,e.DYNAMIC_DRAW),e.drawArrays(e.TRIANGLES,0,h.vertexCount);}e.disable(e.SCISSOR_TEST),e.useProgram(this.screenProgram),e.bindVertexArray(this.quadVao),e.uniform1i(this.uTex,0),e.uniform1f(this.uIntensity,1),e.activeTexture(e.TEXTURE0),e.disable(e.BLEND),e.bindFramebuffer(e.FRAMEBUFFER,this.fboB),e.bindTexture(e.TEXTURE_2D,this.texA),e.uniform2f(this.uDir,1/a,0),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindFramebuffer(e.FRAMEBUFFER,this.fboA),e.bindTexture(e.TEXTURE_2D,this.texB),e.uniform2f(this.uDir,0,1/l),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,s.width,s.height),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE),e.bindTexture(e.TEXTURE_2D,this.texA),e.uniform2f(this.uDir,0,0),e.uniform1f(this.uIntensity,this.glow),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindTexture(e.TEXTURE_2D,null),e.bindVertexArray(null);}drawSliceTexture(e,t){if(!this.ensureScreenPipeline()||!this.screenProgram)return false;let n=this.sliceTex.get(t)??null;if(!n){if(n=e.createTexture(),!n)return false;this.sliceTex.set(t,n),e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);}return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,n),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,true),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,true),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,false),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,false),e.useProgram(this.screenProgram),e.bindVertexArray(this.quadVao),e.uniform1i(this.uTex,0),e.uniform2f(this.uDir,0,0),e.uniform1f(this.uIntensity,1),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindVertexArray(null),true}emitGlowSources(e,t,n,i,o,s){let a=(l,c)=>{!Fe(l)||!Ct(l,"pane")||l.kind==="histogram"||l.kind==="columns"||(l.kind==="circles"||l.kind==="cross"?this.emitPointMarkers(e,l,n,i,o,s,c):this.emitPolyline(e,l,n,i,o,s,l.kind==="step",c));};for(let l of t.indicatorsForPane(n.id)){let c=t.offsetOf(l.id);for(let u of l.series)u.overlay!==true&&a(u,c);}if(n.kind==="price")for(let l of t.indicators.values()){let c=t.offsetOf(l.id);for(let u of l.series)u.overlay===true&&a(u,c);}}destroy(){let e=this.gl;if(this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.onLost),this.canvas.removeEventListener("webglcontextrestored",this.onRestored)),e){this.program&&e.deleteProgram(this.program),this.vbo&&e.deleteBuffer(this.vbo),this.vao&&e.deleteVertexArray(this.vao),this.screenProgram&&e.deleteProgram(this.screenProgram),this.quadVbo&&e.deleteBuffer(this.quadVbo),this.quadVao&&e.deleteVertexArray(this.quadVao);for(let t of this.sliceTex.values())e.deleteTexture(t);this.sliceTex.clear(),this.deleteFbos(e),e.getExtension("WEBGL_lose_context")?.loseContext();}this.gl=null,this.canvas=null,this.program=null,this.vao=null,this.vbo=null,this.screenProgram=null;}emitBackground(e,t,n,i){let o=i.timeToX(t.from),s=i.timeToX(t.to);s<0||o>i.width||s<=o||e.rect(o,n.bounds.top,s-o,n.bounds.height,te(t.color));}emitFill(e,t,n,i,o,s,a,l=0){let c=Ay(t,n.fromSeriesId),u=Ay(t,n.toSeriesId);if(!(!c||!u))for(let d=Math.max(1,s);d<=a;d+=1){let h=c[d-1-l],p=u[d-1-l],m=c[d-l],f=u[d-l];if(!h||!p||!m||!f||h.value===null||p.value===null||m.value===null||f.value===null)continue;let g=o.logicalToX(d-1),b=o.logicalToX(d),y=o.priceToY(h.value,i.scale,i.bounds),v=o.priceToY(p.value,i.scale,i.bounds),S=o.priceToY(m.value,i.scale,i.bounds),E=o.priceToY(f.value,i.scale,i.bounds),T=n.gradient?.[d-1-l];if(T){let k=o.priceToY(T.topValue,i.scale,i.bounds),x=o.priceToY(T.bottomValue,i.scale,i.bounds),L=x===k?k+1:x,w=te(T.topColor),M=te(T.bottomColor),P=L-k,C=A=>fh(w,M,yc((A-k)/P));e.quad4(g,y,C(y),b,S,C(S),b,E,C(E),g,v,C(v));}else {let k=n.colors?n.colors[d-1-l]:n.color;if(!k)continue;e.quad(g,y,b,S,b,E,g,v,te(k));}}}emitPriceSeries(e,t,n,i,o,s,a,l,c){if(t.basePainting==="none")return;let u=t.bars,d=t.style;switch(t.priceStyle){case "bars":this.emitBars(e,u,n,i,o,s,d.bars.upColor??a.upColor,d.bars.downColor??a.downColor,l);return;case "line":this.emitPriceLine(e,u,n,i,o,s,te(d.line.color??a.upColor),d.line.width);return;case "area":{let h=d.area.lineColor??a.upColor;this.emitPriceArea(e,u,n,i,o,s,te(d.area.topColor??h),te(d.area.bottomColor??"rgba(0,0,0,0)")),this.emitPriceLine(e,u,n,i,o,s,te(h),d.area.width);return}case "baseline":this.emitBaseline(e,u,n,i,o,s,t,a,c);return;default:this.emitCandles(e,t,u,n,i,o,s,a,l);}}emitBars(e,t,n,i,o,s,a,l,c){let u=o.bodySpacing(),d=ki(u);if(d==="aggregate"){this.emitCandlesAggregated(e,t,n,i,o,s,m=>c.get(m.time)??(m.close>=m.open?a:l));return}let h=Math.max(1,Math.round(u*.35)),p=d==="full";for(let m=n;m<=i;m+=1){let f=t[m];if(!f||f.high<=f.low)continue;let g=te(c.get(f.time)??(f.close>=f.open?a:l)),b=Math.round(o.logicalToX(m)),y=o.priceToY(f.high,s.scale,s.bounds),v=o.priceToY(f.low,s.scale,s.bounds);if(e.rect(b-.5,y,1,v-y,g),p){let S=o.priceToY(f.open,s.scale,s.bounds),E=o.priceToY(f.close,s.scale,s.bounds);e.rect(b-h,S-.5,h,1,g),e.rect(b,E-.5,h,1,g);}}}emitPriceLine(e,t,n,i,o,s,a,l){let c=Math.max(1,l)/2,u=Py(c),d=false,h=0,p=0;for(let m=Math.max(0,n-1);m<=i;m+=1){let f=t[m];if(!f){d=false;continue}let g=o.logicalToX(m),b=o.priceToY(f.close,s.scale,s.bounds);d&&e.seg(h,p,g,b,l,a),e.circle(g,b,c,a,u),h=g,p=b,d=true;}}emitPriceArea(e,t,n,i,o,s,a,l){let c=s.bounds.top+s.bounds.height,u=[],d=1/0,h=()=>{if(u.length>=2){let p=c-d,m=f=>fh(a,l,p<1e-6?0:yc((f-d)/p));for(let f=1;f<u.length;f+=1){let g=u[f-1],b=u[f];e.quad4(g.x,g.y,m(g.y),b.x,b.y,m(b.y),b.x,c,l,g.x,c,l);}}u.length=0,d=1/0;};for(let p=Math.max(0,n-1);p<=i;p+=1){let m=t[p];if(!m){h();continue}let f=o.logicalToX(p),g=o.priceToY(m.close,s.scale,s.bounds);u.push({x:f,y:g}),g<d&&(d=g);}h();}emitBaseline(e,t,n,i,o,s,a,l,c){let u=a.baselinePriceFor(s.scale),d=o.priceToY(u,s.scale,s.bounds),h=a.style.baseline,p=h.topLineColor??Ei,m=h.bottomLineColor??Li,f=te(p),g=te(m),b=te(h.topFillColor??q(p,Cn)),y=te(h.topFillColor2??q(p,Tn)),v=te(h.bottomFillColor??q(m,Cn)),S=te(h.bottomFillColor2??q(m,Tn)),E=[];for(let w=Math.max(0,n-1);w<=i;w+=1){let M=t[w];M&&E.push({x:o.logicalToX(w),y:o.priceToY(M.close,s.scale,s.bounds)});}if(E.length<2)return;let T=s.bounds.top,k=s.bounds.top+s.bounds.height,x=w=>w<=d?y:S,L=w=>{let M=w<=d,P=M?d-T:k-d,C=P>0?yc(Math.abs(w-d)/P):0;return fh(M?y:S,M?b:v,C)};for(let w=1;w<E.length;w+=1){let M=E[w-1],P=E[w];if(M.y<=d!=P.y<=d&&P.y!==M.y){let C=(d-M.y)/(P.y-M.y),A=M.x+(P.x-M.x)*C;e.tri(M.x,M.y,L(M.y),A,d,x(M.y),M.x,d,x(M.y)),e.tri(A,d,x(P.y),P.x,P.y,L(P.y),P.x,d,x(P.y));}else e.quad4(M.x,M.y,L(M.y),P.x,P.y,L(P.y),P.x,d,x(P.y),M.x,d,x(M.y));}e.dashedSeg(0,d,c,d,1,te(a.style.borderColor??l.borderColor),mh.dashed??null);for(let w=1;w<E.length;w+=1){let M=E[w-1],P=E[w],C=M.y<=d,A=P.y<=d;if(C!==A&&P.y!==M.y){let $=(d-M.y)/(P.y-M.y),ie=M.x+(P.x-M.x)*$;e.seg(M.x,M.y,ie,d,h.width,C?f:g),e.seg(ie,d,P.x,P.y,h.width,A?f:g);}else e.seg(M.x,M.y,P.x,P.y,h.width,C?f:g);}}emitCandles(e,t,n,i,o,s,a,l,c){let u=s.bodySpacing(),d=ki(u),h=Mi(t.style.candle,t.candleOverride,l.upColor,l.downColor),p=h.up,m=h.down,f=h.candle;if(d==="aggregate"){this.emitCandlesAggregated(e,n,i,o,s,a,y=>{let v=y.close>=y.open;return (v?f.wickUpColor:f.wickDownColor)??c.get(y.time)??(v?p:m)});return}let g=d==="full",b=this.candleStructureAlpha>this.candleBodyAlpha+.001;for(let y=i;y<=o;y+=1){let v=n[y];if(!v||v.high<=v.low)continue;let S=fc(s.logicalToX(y),u,s.dpr,this.candleBodyScale),E=v.close>=v.open,T=E?p:m,x=c.get(v.time)??T,L=te(x),w=0,M=0;if(g){let P=s.priceToY(v.open,a.scale,a.bounds),C=s.priceToY(v.close,a.scale,a.bounds);w=nn(Math.min(P,C),s.dpr),M=Math.max(1/s.dpr,nn(Math.max(P,C),s.dpr)-w);}if(f.wickVisible){let P=nn(s.priceToY(v.high,a.scale,a.bounds),s.dpr),C=nn(s.priceToY(v.low,a.scale,a.bounds),s.dpr);e.alpha=this.candleStructureAlpha;let A=te((E?f.wickUpColor:f.wickDownColor)??(g?T:x));g?(e.rect(S.wickX,P,S.wickW,Math.max(0,w-P),A),e.rect(S.wickX,w+M,S.wickW,Math.max(0,C-(w+M)),A)):e.rect(S.wickX,P,S.wickW,C-P,A);}if(g&&(f.bodyVisible&&(e.alpha=this.candleBodyAlpha,e.rect(S.bodyX,w,S.bodyW,M,L)),f.borderVisible||b&&f.bodyVisible)){e.alpha=this.candleStructureAlpha;let P=f.borderVisible?te((E?f.borderUpColor:f.borderDownColor)??x):L,C=Math.max(0,S.bodyW-1),A=Math.max(0,M-1);e.rectStroke(S.bodyX+.5,w+.5,C,A,1,P);}}}emitCandlesAggregated(e,t,n,i,o,s,a){let l=c=>o.priceToY(c,s.scale,s.bounds);for(let c of gc(t,n,i,u=>o.logicalToX(u),l,a)){let u=te(c.color),d=l(c.hi);e.rect(c.x-.5,d,1,l(c.lo)-d,u);}}emitSeries(e,t,n,i,o,s,a,l=0){if(Ct(t,"pane")){if(t.kind==="candle"||t.kind==="bar"){this.emitPlotCandles(e,t,n,i,o,s,a,l);return}if(Fe(t))switch(t.kind){case "histogram":case "columns":this.emitHistogram(e,t,n,i,o,s,l);break;case "area":this.emitArea(e,t,n,i,o,s,l),this.emitPolyline(e,t,n,i,o,s,false,l);break;case "circles":case "cross":this.emitPointMarkers(e,t,n,i,o,s,l);break;case "step":this.emitPolyline(e,t,n,i,o,s,true,l);break;default:this.emitPolyline(e,t,n,i,o,s,false,l);}}}emitPolyline(e,t,n,i,o,s,a,l=0){let c=Math.max(1,t.style.width),u=c/2,d=mh[t.style.lineStyle]??null,h=!d&&!a,p=Py(u),m=false;for(let f=Math.max(1,o-1);f<=s;f+=1){let g=t.points[f-l],b=t.points[f-1-l];if(!g||g.value===null||!b||b.value===null){m=false;continue}let y=i.logicalToX(f),v=i.priceToY(g.value,n.scale,n.bounds),S=i.logicalToX(f-1),E=i.priceToY(b.value,n.scale,n.bounds),T=te(g.color??t.style.color);a?(e.dashedSeg(S,E,y,E,c,T,d),e.dashedSeg(y,E,y,v,c,T,d)):e.dashedSeg(S,E,y,v,c,T,d),h&&(m||e.circle(S,E,u,te(b.color??t.style.color),p),e.circle(y,v,u,T,p)),m=true;}}emitArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=te(t.style.color),u=[],d=1/0,h=()=>{if(u.length<1){u=[],d=1/0;return}let p=l-d,m=f=>vL(c,p<1e-6?0:yc((f-d)/p));for(let f=1;f<u.length;f+=1){let g=u[f-1],b=u[f];e.quad4(g.x,g.y,m(g.y),b.x,b.y,m(b.y),b.x,l,Iy,g.x,l,Iy);}u=[],d=1/0;};for(let p=o;p<=s;p+=1){let m=t.points[p-a];if(!m||m.value===null){h();continue}let f=i.logicalToX(p),g=i.priceToY(m.value,n.scale,n.bounds);u.push({x:f,y:g}),g<d&&(d=g);}h();}emitHistogram(e,t,n,i,o,s,a=0){let l=i.bodySpacing(),c=Math.max(1,(t.kind==="columns"?.7:.8)*l),u=c/2,d=t.style.base??0,h=i.priceToY(d,n.scale,n.bounds);for(let p=o;p<=s;p+=1){let m=t.points[p-a];if(!m||m.value===null)continue;let f=i.logicalToX(p),g=i.priceToY(m.value,n.scale,n.bounds);e.rect(f-u,Math.min(h,g),c,Math.max(1,Math.abs(g-h)),te(m.color??t.style.color));}}emitPointMarkers(e,t,n,i,o,s,a=0){let l=Math.max(1.5,t.style.width);for(let c=o;c<=s;c+=1){let u=t.points[c-a];if(!u||u.value===null)continue;let d=i.logicalToX(c),h=i.priceToY(u.value,n.scale,n.bounds),p=te(u.color??t.style.color);t.kind==="cross"?(e.seg(d-l,h,d+l,h,1,p),e.seg(d,h-l,d,h+l,1,p)):e.circle(d,h,l,p,Math.max(16,Math.ceil(l*2)));}}emitPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),u=t.style?.up??a.upColor,d=t.style?.down??a.downColor,h=t.kind==="bar",p=Math.max(.5,Math.floor(c*.7)/2),m=Math.max(1,Math.round(c*.35));for(let f=o;f<=s;f+=1){let g=t.bars[f-l];if(!g)continue;let b=t.barColors?.[f-l],y=te(b?.color??(g.close>=g.open?u:d)),v=Math.round(i.logicalToX(f)),S=i.priceToY(g.high,n.scale,n.bounds),E=i.priceToY(g.low,n.scale,n.bounds),T=i.priceToY(g.open,n.scale,n.bounds),k=i.priceToY(g.close,n.scale,n.bounds);if(h){e.rect(v-.5,S,1,E-S,y),e.rect(v-m,T-.5,m,1,y),e.rect(v,k-.5,m,1,y);continue}let x=Math.max(1,Math.round(ss(c)*i.dpr)),L=(Math.round(v*i.dpr)-(x>>1))/i.dpr;e.rect(L,S,x/i.dpr,E-S,te(b?.wickColor??b?.color??(g.close>=g.open?u:d)));let w=Math.min(T,k),M=Math.max(1,Math.abs(k-T));if(e.rect(v-p,w,p*2,M,y),b?.borderColor){let P=te(b.borderColor);e.rect(v-p,w,p*2,1,P),e.rect(v-p,w+M-1,p*2,1,P),e.rect(v-p,w,1,M,P),e.rect(v+p-1,w,1,M,P);}}}emitHline(e,t,n,i,o,s){let a=Math.round(i.priceToY(t.price,n.scale,n.bounds));a<n.bounds.top||a>n.bounds.top+n.bounds.height||e.dashedSeg(0,a,o,a,t.width??1,te(t.color??s.textColor),mh[t.lineStyle??"solid"]??null);}};function vc(r,e,t){let n=r.createShader(e);return n?(r.shaderSource(n,t),r.compileShader(n),r.getShaderParameter(n,r.COMPILE_STATUS)?n:(r.deleteShader(n),null)):null}var Iy=[0,0,0,0];function yc(r){return r<0?0:r>1?1:r}function fh(r,e,t){return [r[0]+(e[0]-r[0])*t,r[1]+(e[1]-r[1])*t,r[2]+(e[2]-r[2])*t,r[3]+(e[3]-r[3])*t]}function vL(r,e){let t=1-e;return [r[0]*t,r[1]*t,r[2]*t,r[3]*t]}function Ay(r,e){let t=r.series.find(n=>n.id===e);return t&&Fe(t)?t.points:null}var yL=new Map;function wL(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return yL;let t=new Map;for(let n of r.values())if(n.barColors)for(let i of n.barColors)t.set(i.time,i.color);return t}function cs(){return {barSpacing:8,rightOffset:6}}function rn(r){return Math.max(.5,Math.min(1e3,r))}function gh(r){if(r.length<2)return 0;let e=[];for(let t=1;t<r.length;t+=1){let n=r[t]-r[t-1];n>0&&e.push(n);}return e.length===0?0:(e.sort((t,n)=>t-n),e[Math.floor(e.length/2)])}function Ry(r,e,t){let n=e.length;if(n===0)return 0;let i=e[0],o=e[n-1];if(r<=i)return t>0?(r-i)/t:0;if(r>=o)return n-1+(t>0?(r-o)/t:0);let s=0,a=n-1;for(;a-s>1;){let c=s+a>>1;e[c]<=r?s=c:a=c;}let l=e[a]-e[s];return l>0?s+(r-e[s])/l:s}function Dy(r,e,t){let n=e.length;if(n===0)return 0;if(r<=0)return e[0]+(t>0?r*t:0);if(r>=n-1)return e[n-1]+(t>0?(r-(n-1))*t:0);let i=Math.floor(r),o=r-i;return e[i]+(e[i+1]-e[i])*o}var xc=class{constructor(){this.widthPx=0;this.dataHeightPx=0;this.devicePixelRatio=1;this.viewport=cs();this.pitchScale=1;this.times=[];this.intervalMs=0;}setSize(e,t,n){this.widthPx=e,this.dataHeightPx=t,this.devicePixelRatio=n>0?n:1;}setBars(e){this.times=e.slice(),this.intervalMs=gh(this.times);}appendBar(e){this.times.push(e),this.intervalMs<=0&&this.times.length>=2&&(this.intervalMs=gh(this.times));}setViewport(e){this.viewport=e;}getViewport(){return this.viewport}setPitchScale(e){this.pitchScale=Number.isFinite(e)&&e>0?e:1;}get spacingScale(){return this.pitchScale}pxPerBar(){return this.viewport.barSpacing*this.pitchScale}bodySpacing(){return this.viewport.barSpacing*Math.min(1,this.pitchScale)}get width(){return this.widthPx}get height(){return this.dataHeightPx}get dpr(){return this.devicePixelRatio}get barCount(){return this.times.length}get barInterval(){return this.intervalMs}get rightEdgeLogical(){return this.barCount-1+this.viewport.rightOffset}logicalToX(e){return this.widthPx-(this.rightEdgeLogical-e)*this.pxPerBar()}xToLogical(e){return this.rightEdgeLogical-(this.widthPx-e)/this.pxPerBar()}timeToLogical(e){return Ry(e,this.times,this.intervalMs)}logicalToTime(e){return Dy(e,this.times,this.intervalMs)}timeToX(e){return this.logicalToX(this.timeToLogical(e))}priceToY(e,t,n){if(t.log&&t.min>0&&t.max>t.min&&e>0){let s=Math.log(t.min),a=(Math.log(e)-s)/(Math.log(t.max)-s);return n.top+n.height*(t.invert?a:1-a)}let i=t.max-t.min;if(i<=0)return n.top+n.height/2;let o=(e-t.min)/i;return n.top+n.height*(t.invert?o:1-o)}yToPrice(e,t,n){if(n.height<=0)return t.min;let i=(e-n.top)/n.height,o=t.invert?i:1-i;if(t.log&&t.min>0&&t.max>t.min){let s=Math.log(t.min);return Math.exp(s+o*(Math.log(t.max)-s))}return t.min+(t.max-t.min)*o}visibleLogicalRange(){return {from:this.xToLogical(0),to:this.xToLogical(this.widthPx)}}visibleTimeRange(){let e=this.visibleLogicalRange();return {from:this.logicalToTime(e.from),to:this.logicalToTime(e.to)}}toBitmap(e){return Math.round(e*this.devicePixelRatio)}};function bh(r){return r>=3}function Oy(r){return r>=2}var Sc=class{constructor(e,t,n){this.onFrame=e;this.level=0;this.handle=null;this.raf=t??(i=>requestAnimationFrame(i)),this.cancel=n??(i=>cancelAnimationFrame(i));}invalidate(e){e<=0||(e>this.level&&(this.level=e),this.handle===null&&(this.handle=this.raf(()=>this.flush())));}flushNow(e){this.handle!==null&&(this.cancel(this.handle),this.handle=null),e>this.level&&(this.level=e),this.flush();}flush(){this.handle=null;let e=this.level;this.level=0,e!==0&&this.onFrame(e);}destroy(){this.handle!==null&&(this.cancel(this.handle),this.handle=null),this.level=0;}};var Cc=class{constructor(e,t,n,i){this.tick=e;this.handle=null;this.last=0;this.stopped=false;this.loop=()=>{let e=this.now(),t=e-this.last;this.last=e;let n=this.tick(Math.min(t,64));this.handle=n&&!this.stopped?this.raf(this.loop):null;};this.raf=t??(o=>requestAnimationFrame(o)),this.cancel=n??(o=>cancelAnimationFrame(o)),this.now=i??(()=>performance.now());}get active(){return this.handle!==null}start(){this.stopped=false,this.handle===null&&(this.last=this.now(),this.handle=this.raf(this.loop));}stop(){this.stopped=true,this.handle!==null&&(this.cancel(this.handle),this.handle=null);}},Yn=class{constructor(e,t=e){this.onMs=e,this.ms=t;}get tau(){return this.ms}get on(){return this.ms>0}set(e){this.ms=e,e>0&&(this.onMs=e);}toggle(e){this.ms=e?this.onMs:0;}};function vt(r,e,t,n){return n<=0?e:r+(e-r)*(1-Math.exp(-t/n))}var xL=.04,SL=60,CL=2,TL=350,Ny=8,kL=14,EL=350,LL=30,ML=.004,PL=.004,IL=.25;function AL(r,e,t){return t?{logical:r.rightEdgeLogical,x:r.width}:{logical:r.xToLogical(e),x:e}}function RL(r,e){return Math.abs(r)>Math.abs(e)}function DL(r,e,t){return r+e/t}function OL(r,e,t){return RL(r,e)?r:t?e:null}function NL(r,e){return r?"strong":e}function FL(r,e,t){return rn(r*(t/Math.max(1,e)))}function VL(r,e,t,n,i){return r-(e-1)+(t-n)/i}var Tc=class{constructor(e){this.deps=e;this.rightEdgeZoom=true;this.axisDrag=true;this.paneResize=true;this.el=null;this.dragging=false;this.moved=false;this.region="data";this.verticalPan=false;this.startX=0;this.startY=0;this.startRightOffset=0;this.startBarSpacing=0;this.lastX=0;this.lastT=0;this.vx=0;this.middleDeleted=false;this.rightCancelled=false;this.cursorX=NaN;this.cursorY=NaN;this.touches=new Map;this.lpTimer=null;this.pinchStartDist=1;this.pinchStartBarSpacing=0;this.pinchAnchorLogical=0;this.lastTapT=0;this.lastTapX=0;this.lastTapY=0;this.onTouchContextMenu=e=>{this.touches.size!==0&&(!(e.target instanceof Node)||!this.el?.contains(e.target)||(e.preventDefault(),e.stopImmediatePropagation()));};this.onMiddleGuard=e=>{e.button===1&&this.middleDeleted&&e.preventDefault();};this.onContextGuard=e=>{this.rightCancelled&&(this.rightCancelled=false,e.preventDefault(),e.stopPropagation());};this.onModifier=e=>{e.repeat||e.key!=="Shift"&&e.key!=="Control"&&e.key!=="Meta"||Number.isNaN(this.cursorX)||this.dragging&&this.region!=="drawing"||this.deps.drawingsPointerMove?.(this.cursorX,this.cursorY,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey);};this.onDown=e=>{if(e.button===1){let{x:o,y:s}=this.local(e);this.middleDeleted=this.deps.drawingsDeleteAt?.(o,s)??false,this.middleDeleted&&e.preventDefault();return}if(e.button===2){this.rightCancelled=this.deps.drawingsCancelPlacement?.()??false,this.rightCancelled&&e.preventDefault();return}if(e.button!==0)return;let{x:t,y:n}=this.local(e);if(e.pointerType==="touch"){if(this.touches.size===1&&this.dragging&&(this.region==="data"||this.region==="crosshair")){this.touches.set(e.pointerId,{x:t,y:n}),this.beginPinch(e);return}if(this.touches.size>=1)return;this.touches.set(e.pointerId,{x:t,y:n});}if(this.deps.drawingsClearTransient?.(),this.dragging=true,this.moved=false,this.startX=t,this.startY=n,this.deps.drawingsClaim?.(t,n)){this.region="drawing",this.deps.drawingsPointerDown?.(t,n,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey),this.capture(e.pointerId);return}if(e.shiftKey&&this.regionAt(t,n)==="data"&&this.deps.drawingsMeasureStart?.(t,n,this.snapMode(e))){this.region="drawing",this.capture(e.pointerId);return}if((e.ctrlKey||e.metaKey)&&this.regionAt(t,n)==="data"&&this.deps.drawingsMarqueeStart?.(t,n)){this.region="drawing",this.capture(e.pointerId);return}let i=this.deps.getCoords().getViewport();this.deps.apply(i),this.startRightOffset=i.rightOffset,this.startBarSpacing=i.barSpacing,this.region=this.regionAt(t,n),this.verticalPan=false,this.region==="price"?this.deps.beginPriceScale(t,n):this.region==="separator"?this.deps.beginPaneResize(n):this.region==="data"&&(this.verticalPan=this.deps.beginPricePan(n)),e.pointerType==="touch"&&(this.region==="data"||this.region==="price"||this.region==="time")&&this.startLongPress(t,n,this.region),this.lastX=t,this.lastT=e.timeStamp,this.vx=0,this.capture(e.pointerId);};this.onMove=e=>{let{x:t,y:n}=this.local(e);if(this.cursorX=t,this.cursorY=n,e.pointerType==="touch"&&this.touches.has(e.pointerId)&&this.touches.set(e.pointerId,{x:t,y:n}),this.dragging&&this.region==="pinch"){this.applyPinch();return}if(this.dragging&&this.region==="crosshair"){this.deps.onPointerMove(t,n);return}if(this.dragging&&this.region==="axis-sheet")return;this.lpTimer!==null&&Math.hypot(t-this.startX,n-this.startY)>Ny&&this.cancelLongPress();let i=e.pointerType==="touch"?Ny:CL;if(this.dragging)if(this.region==="price")Math.abs(n-this.startY)>i&&(this.moved=true),this.deps.priceScaleBy(n-this.startY);else if(this.region==="separator")Math.abs(n-this.startY)>i&&(this.moved=true),this.deps.paneResizeBy(n-this.startY);else if(this.region==="time"){Math.abs(t-this.startX)>i&&(this.moved=true);let o=rn(this.startBarSpacing*Math.exp((this.startX-t)*ML));this.deps.apply({barSpacing:o,rightOffset:this.startRightOffset});}else if(this.region==="drawing")(Math.abs(t-this.startX)>i||Math.abs(n-this.startY)>i)&&(this.moved=true),this.deps.drawingsPointerMove?.(t,n,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey);else {let o=this.deps.getCoords(),s=o.getViewport(),a=t-this.startX;Math.abs(a)>i&&(this.moved=true),this.deps.apply({barSpacing:s.barSpacing,rightOffset:this.startRightOffset-a/o.pxPerBar()}),this.verticalPan&&(Math.abs(n-this.startY)>i&&(this.moved=true),this.deps.pricePanBy(n-this.startY));let l=e.timeStamp-this.lastT;if(l>0){let c=(t-this.lastX)/l;this.vx=this.vx*.6+c*.4,this.lastX=t,this.lastT=e.timeStamp;}}else if(this.el){let o=this.deps.drawingsCursor?.(t,n),s=this.regionAt(t,n);this.el.style.cursor=o??(s==="price"?"ns-resize":s==="time"?"ew-resize":s==="separator"?"row-resize":""),this.deps.drawingsPointerMove?.(t,n,this.snapMode(e),e.shiftKey,e.ctrlKey||e.metaKey);}e.pointerType!=="touch"&&this.deps.onPointerMove(t,n);};this.onUp=e=>{if(e.pointerType==="touch"&&this.touches.delete(e.pointerId),this.cancelLongPress(),this.dragging&&this.region==="pinch"){if(this.touches.size===1){let a=[...this.touches.values()][0],l=this.deps.getCoords().getViewport();this.region="data",this.verticalPan=false,this.startX=a.x,this.startY=a.y,this.startRightOffset=l.rightOffset,this.startBarSpacing=l.barSpacing,this.lastX=a.x,this.lastT=e.timeStamp,this.vx=0;return}this.endGesture(e);return}if(this.dragging&&this.region==="crosshair"){this.deps.onPointerMove(null,null),this.endGesture(e);return}if(this.dragging&&this.region==="axis-sheet"){this.endGesture(e);return}let{x:t,y:n}=this.local(e),i=e.pointerType==="touch",o=this.dragging&&!this.moved&&(!i||Math.hypot(t-this.startX,n-this.startY)<=kL);if(this.dragging&&this.region==="drawing")this.deps.drawingsPointerUp?.(t,n,this.snapMode(e));else if(o&&this.region==="data")this.deps.onClick(t,n);else if(this.dragging&&this.region==="data"&&!(e.timeStamp-this.lastT>SL)&&Math.abs(this.vx)>xL){let l=this.deps.getCoords().pxPerBar();this.deps.fling(-this.vx/l);}let s=i&&o;this.endGesture(e),i&&this.deps.onPointerMove(null,null),s&&this.registerTap(e.timeStamp,t,n);};this.onCancel=e=>{e.pointerType==="touch"&&this.touches.delete(e.pointerId),this.cancelLongPress(),this.dragging&&(this.region==="drawing"&&!Number.isNaN(this.cursorX)&&this.deps.drawingsPointerUp?.(this.cursorX,this.cursorY,this.snapMode(e)),(this.region==="crosshair"||e.pointerType==="touch")&&this.deps.onPointerMove(null,null),this.endGesture(e));};this.onLeave=()=>{this.cursorX=NaN,this.cursorY=NaN,this.deps.onPointerMove(null,null);};this.onDblClick=e=>{let{x:t,y:n}=this.local(e);this.doubleActivate(t,n);};this.onWheel=e=>{e.preventDefault(),this.deps.drawingsClearTransient?.();let{x:t,y:n}=this.local(e);if(this.regionAt(t,n)==="price"&&e.deltaY!==0){this.deps.beginPriceScale(t,n),this.deps.priceScaleBy(e.deltaY*IL);return}let i=this.deps.getCoords(),o=i.getViewport(),s=OL(e.deltaX,e.deltaY,e.shiftKey);if(s!=null){this.deps.apply({barSpacing:o.barSpacing,rightOffset:DL(o.rightOffset,s,i.pxPerBar())});return}let a=this.rightEdgeZoom&&!(e.ctrlKey||e.metaKey),l=AL(i,t,a),c=rn(o.barSpacing*Math.exp(-e.deltaY*PL));this.deps.zoomTo(c,l.logical,l.x);};}attach(e){this.el=e,e.style!==void 0&&(e.style.touchAction="none",e.style.userSelect="none",e.style.setProperty("-webkit-user-select","none"),e.style.setProperty("-webkit-touch-callout","none")),e.addEventListener("pointerdown",this.onDown),e.addEventListener("pointermove",this.onMove),e.addEventListener("pointerup",this.onUp),e.addEventListener("pointerleave",this.onLeave),e.addEventListener("pointercancel",this.onCancel),e.addEventListener("dblclick",this.onDblClick),e.addEventListener("wheel",this.onWheel,{passive:false}),e.addEventListener("mousedown",this.onMiddleGuard),e.addEventListener("auxclick",this.onMiddleGuard),e.addEventListener("contextmenu",this.onContextGuard);let t=e.ownerDocument?.defaultView;t?.addEventListener("keydown",this.onModifier),t?.addEventListener("keyup",this.onModifier),t?.addEventListener("contextmenu",this.onTouchContextMenu,true);}detach(){let e=this.el;if(!e)return;let t=e.ownerDocument?.defaultView;t?.removeEventListener("keydown",this.onModifier),t?.removeEventListener("keyup",this.onModifier),t?.removeEventListener("contextmenu",this.onTouchContextMenu,true),e.removeEventListener("pointerdown",this.onDown),e.removeEventListener("pointermove",this.onMove),e.removeEventListener("pointerup",this.onUp),e.removeEventListener("pointerleave",this.onLeave),e.removeEventListener("pointercancel",this.onCancel),e.removeEventListener("dblclick",this.onDblClick),e.removeEventListener("wheel",this.onWheel),e.removeEventListener("mousedown",this.onMiddleGuard),e.removeEventListener("auxclick",this.onMiddleGuard),e.removeEventListener("contextmenu",this.onContextGuard),this.cancelLongPress(),this.touches.clear(),this.el=null;}local(e){let t=this.el.getBoundingClientRect();return {x:e.clientX-t.left,y:e.clientY-t.top}}regionAt(e,t){let n=this.deps.getCoords();if(this.paneResize&&t<=n.height&&this.deps.paneSeparatorAt(t))return "separator";if(this.axisDrag){if(e>n.width&&t<=n.height)return "price";if(t>n.height&&e<=n.width)return "time"}return "data"}snapMode(e){return NL(e.ctrlKey||e.metaKey,this.deps.drawingsSnapMode?.()??"off")}startLongPress(e,t,n){this.cancelLongPress(),this.lpTimer=setTimeout(()=>{if(this.lpTimer=null,!(!this.dragging||this.region!==n)){if(n==="data"){this.region="crosshair",this.deps.onPointerMove(e,t);return}this.region="axis-sheet",this.moved=true,this.deps.onAxisLongPress?.(n,e,t);}},TL);}cancelLongPress(){this.lpTimer!==null&&clearTimeout(this.lpTimer),this.lpTimer=null;}beginPinch(e){this.cancelLongPress(),this.region==="crosshair"&&this.deps.onPointerMove(null,null);let t=this.deps.getCoords(),n=t.getViewport();this.deps.apply(n);let[i,o]=[...this.touches.values()];this.pinchStartDist=Math.max(1,Math.hypot(i.x-o.x,i.y-o.y)),this.pinchStartBarSpacing=n.barSpacing,this.pinchAnchorLogical=t.xToLogical((i.x+o.x)/2),this.region="pinch",this.dragging=true,this.moved=true,this.vx=0,this.capture(e.pointerId);}applyPinch(){let e=this.deps.getCoords(),t=[...this.touches.values()];if(t.length<2)return;let[n,i]=t,o=FL(this.pinchStartBarSpacing,this.pinchStartDist,Math.hypot(n.x-i.x,n.y-i.y)),s=e.getViewport(),a=s.barSpacing>0?e.pxPerBar()/s.barSpacing:1,l=(n.x+i.x)/2;this.deps.apply({barSpacing:o,rightOffset:VL(this.pinchAnchorLogical,e.barCount,e.width,l,o*a)});}capture(e){try{this.el?.setPointerCapture(e);}catch{}}registerTap(e,t,n){if(this.lastTapT>0&&e-this.lastTapT<=EL&&Math.hypot(t-this.lastTapX,n-this.lastTapY)<=LL){this.lastTapT=0,this.doubleActivate(this.lastTapX,this.lastTapY);return}this.lastTapT=e,this.lastTapX=t,this.lastTapY=n;}endGesture(e){this.dragging=false;try{this.el?.releasePointerCapture(e.pointerId);}catch{}}doubleActivate(e,t){if(this.deps.drawingsDblClick?.(e,t))return;let n=this.regionAt(e,t);n==="price"?this.deps.resetPriceScale(e,t):n==="separator"?this.deps.resetPaneSize(t):n==="time"?this.deps.resetView():this.deps.dataDblClick(e,t);}};function _L(r){if(r.ctrlKey||r.metaKey)return null;switch(r.key){case "ArrowLeft":return r.shiftKey?{kind:"pan",bars:-10}:{kind:"step",delta:-1};case "ArrowRight":return r.altKey&&r.shiftKey?{kind:"realtime"}:r.shiftKey?{kind:"pan",bars:10}:{kind:"step",delta:1};case "+":case "=":return {kind:"zoom",direction:1};case "-":case "_":return {kind:"zoom",direction:-1};case "Home":return {kind:"edge",edge:"first"};case "End":return {kind:"edge",edge:"last"};case "0":return {kind:"reset"};case "Escape":return {kind:"clear"};default:return null}}var kc=class{constructor(e){this.deps=e;this.el=null;this.onKey=e=>{if(this.deps.preempt?.(e)){e.preventDefault();return}let t=_L(e);if(t)switch(e.preventDefault(),t.kind){case "pan":this.deps.panByBars(t.bars);break;case "zoom":this.deps.zoomByStep(t.direction);break;case "step":this.deps.stepCrosshair(t.delta);break;case "edge":this.deps.jumpToEdge(t.edge);break;case "reset":this.deps.resetView();break;case "realtime":this.deps.scrollToRealtime();break;case "clear":this.deps.clearCrosshair();break}};}attach(e){this.el=e,e.addEventListener("keydown",this.onKey);}detach(){this.el?.removeEventListener("keydown",this.onKey),this.el=null;}};var BL=tm,HL=nm,zL=rm;function $y(){return {visible:true,labels:true,qty:true,colors:{long:BL,short:HL,exit:zL}}}function Wy(r,e){let t=e&&typeof e=="object"?e:{},n=t.colors&&typeof t.colors=="object"?t.colors:{},i=(s,a)=>typeof s=="boolean"?s:a,o=(s,a)=>typeof s=="string"&&s.trim().length>0?s:a;return {visible:i(t.visible,r.visible),labels:i(t.labels,r.labels),qty:i(t.qty,r.qty),colors:{long:o(n.long,r.colors.long),short:o(n.short,r.colors.short),exit:o(n.exit,r.colors.exit)}}}var vh=10,Kn=9,Or=6,Ai=14,Ec=3,yh=2,Gy=2,wh=3,xh=6,Fy=6,Vy=8;function Uy(r){return r+4}function $L(r){if(r.qty==null||!Number.isFinite(r.qty))return null;let e=Number(Math.abs(r.qty).toFixed(8));return `${r.side==="buy"?"+":"-"}${e}`}function WL(r,e,t){let n=[];if(e.labels&&r.label&&n.push(r.label),e.qty){let i=$L(r);i&&n.push(i);}return {exec:r,lines:n,height:Ai+(n.length?wh+n.length*t:0)}}function Yy(r,e,t,n,i,o){let s=new Map;for(let a of r){let l=Math.round(t.timeToLogical(a.time));if(l<n||l>i)continue;let c=s.get(l);c||(c={logical:l,buys:[],sells:[]},s.set(l,c)),(a.side==="buy"?c.buys:c.sells).push(WL(a,e,o));}return [...s.values()]}function _y(r){if(r.length===0)return 0;let e=vh;for(let t of r)e+=t.height;return e+(r.length-1)*xh}function Ky(r,e,t,n,i,o){if(r.length===0)return null;let s=Uy(o),a=1/0,l=-1/0,c=0,u=0;for(let d of Yy(r,e,t,Math.floor(n),Math.ceil(i),s)){let h=t.barAt(d.logical);h&&(h.low<a&&(a=h.low),h.high>l&&(l=h.high),u=Math.max(u,_y(d.buys)),c=Math.max(c,_y(d.sells)));}return !Number.isFinite(a)||!Number.isFinite(l)?null:{min:a,max:l,abovePx:c,belowPx:u}}function Xy(r,e,t,n,i,o,s,a,l){if(e.length===0)return;let c=Uy(s.fontSize),u=Yy(e,t,n,-1/0,1/0,c);if(u.length!==0){r.save(),r.font=`${s.fontSize}px ${s.fontFamily}`,r.textAlign="center",r.textBaseline="middle";for(let d of u){let h=i(d.logical);if(h<-150||h>a+150)continue;let p=n.barAt(d.logical);if(!p)continue;let m=Math.max(o(p.low),o(p.high)),f=Math.min(o(p.low),o(p.high)),g=m+vh;for(let b of d.buys)r.fillStyle=By(b.exec,t.colors),GL(r,h,g,b.exec.kind==="exit"),Hy(r,b.exec.side,h,o(b.exec.price),l),zy(r,b.lines,h,g+Ai+wh+c/2,c,s.color),g+=b.height+xh;g=f-vh;for(let b of d.sells)r.fillStyle=By(b.exec,t.colors),UL(r,h,g,b.exec.kind==="exit"),Hy(r,b.exec.side,h,o(b.exec.price),l),zy(r,b.lines,h,g-Ai-wh-c/2,-c,s.color),g-=b.height+xh;}r.restore();}}function By(r,e){return r.kind==="exit"?e.exit:r.side==="buy"?e.long:e.short}function GL(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-Kn/2,t+Or),r.lineTo(e+Kn/2,t+Or),r.closePath(),r.fill(),r.fillRect(e-Ec/2,t+Or,Ec,Ai-Or),n&&r.fillRect(e-Kn/2,t-Gy-yh,Kn,yh);}function UL(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-Kn/2,t-Or),r.lineTo(e+Kn/2,t-Or),r.closePath(),r.fill(),r.fillRect(e-Ec/2,t-Ai,Ec,Ai-Or),n&&r.fillRect(e-Kn/2,t+Gy,Kn,yh);}function Hy(r,e,t,n,i){let o=e==="buy"?t-i:t+i,s=e==="buy"?o-Fy:o+Fy;r.beginPath(),r.moveTo(o,n),r.lineTo(s,n-Vy/2),r.lineTo(s,n+Vy/2),r.closePath(),r.fill();}function zy(r,e,t,n,i,o){if(e.length!==0){r.fillStyle=o;for(let s=0;s<e.length;s+=1)r.fillText(e[s],t,n+s*i);}}function jy(){return {visible:true,groups:{}}}function qy(r,e){if(typeof e=="boolean")return {visible:e,groups:{...r.groups}};let t=e&&typeof e=="object"?e:{},n=t.groups&&typeof t.groups=="object"?t.groups:{},i={...r.groups};for(let[o,s]of Object.entries(n))typeof s=="boolean"&&(i[o]=s);return {visible:typeof t.visible=="boolean"?t.visible:r.visible,groups:i}}function Lc(r,e,t){if(e===void 0)return true;let n=r.groups[e];return typeof n=="boolean"?n:t.find(i=>i.id===e)?.visible!==false}var Mc=class{constructor(){this.panes=new Map;this.indicators=new Map;this.bars=[];this.volumeLayer=null;this.nativeData=new Map;this.nativePending=new Map;this.vpvrLayer=null;this.crosshair=null;this.priceStyle="candles";this.basePainting="candles";this.candleOverride=null;this.baselineValue=null;this.showPriceLine=true;this.showPriceLabel=true;this.showCountdown=true;this.logScale=false;this.invertScale=false;this.priceMintick=void 0;this.scaleMode="price";this.percentBaseline=0;this.timezone="UTC";this.showGrid=true;this.style=Sy();this.showAxisLabels=true;this.tradeMarkers=$y();this.marks=jy();this.timelineMarks=[];this.markGroups=[];this.marksExpandedStack=null;this.marksHoverKey=null;this.marksHoverSince=0;this.marksActiveKey=null;this.marksFlash=null;this.highlights=[];this.sessionZones=null;this.candleZ=0;this.candlesHidden=false;this.seriesZ=new Map;this.drawingSlices=new Map;this.anchorOffsets=new Map;this.indicatorScales=new Map;this.orderedCache=null;}orderedPanes(){return this.orderedCache||(this.orderedCache=[...this.panes.values()].sort((e,t)=>e.order-t.order)),this.orderedCache}sessionHighlightBands(){if(!this.sessionZones)return [];let e=[];for(let[t,n]of this.sessionZones.pre)e.push({from:t,to:n,color:this.style.sessions.premarketColor});for(let[t,n]of this.sessionZones.post)e.push({from:t,to:n,color:this.style.sessions.postmarketColor});for(let[t,n]of this.sessionZones.extended)e.push({from:t,to:n,color:this.style.sessions.extendedColor});return e}indicatorsForPane(e){let t=[];for(let n of this.indicators.values())n.paneId===e&&t.push(n);return t}ownScaleIndicatorsForPane(e){return this.orderedIndicatorsForPane(e).filter(t=>t.ownScale===true)}ensureIndicatorScale(e,t){let n=this.indicatorScales.get(e);if(!n){let i=t??{min:0,max:1};n={scale:{...i},scaleTarget:{...i},initialized:false,manualScale:null},this.indicatorScales.set(e,n);}return n}dropIndicatorScale(e){this.indicatorScales.delete(e);}scaleFor(e,t){if(e.ownScale===true){let n=this.indicatorScales.get(e.id);if(n)return n.scale}return t.scale}orderPanes(e){e.forEach((t,n)=>{let i=this.panes.get(t);i&&(i.order=n);}),this.orderedCache=null;}orderedIndicatorsForPane(e){return this.indicatorsForPane(e).sort((t,n)=>this.zOf(t.id)-this.zOf(n.id))}zOf(e){return this.seriesZ.get(e)??0}offsetOf(e){return this.anchorOffsets.get(e)??0}setAnchorOffset(e,t){t!==0&&Number.isFinite(t)?this.anchorOffsets.set(e,t):this.anchorOffsets.delete(e);}forgetAnchorOffset(e){this.anchorOffsets.delete(e);}baselinePriceFor(e){if(this.baselineValue!=null)return this.baselineValue;let t=this.style.baseline.baselineLevel/100;if(e.log&&e.min>0&&e.max>e.min){let n=Math.log(e.min);return Math.exp(n+t*(Math.log(e.max)-n))}return e.min+(e.max-e.min)*t}assignIndicatorZ(e){this.seriesZ.has(e)||this.seriesZ.set(e,this.bottomZ()-1);}assignIndicatorZTop(e){this.seriesZ.has(e)||this.seriesZ.set(e,this.topZ()+1);}forgetIndicatorZ(e){this.seriesZ.delete(e);}setIndicatorZ(e,t){this.seriesZ.set(e,t);}indicatorZOrder(){return [...this.seriesZ.entries()].map(([e,t])=>({id:e,z:t})).sort((e,t)=>e.z-t.z)}seriesBoundaries(e){let t=new Set;e==="price"&&t.add(this.candleZ);for(let n of this.indicatorsForPane(e))t.add(this.zOf(n.id));return [...t].sort((n,i)=>n-i)}bringIndicatorToFront(e){this.seriesZ.set(e,this.topZ()+1);}sendIndicatorToBack(e){this.seriesZ.set(e,this.bottomZ()-1);}topZ(){let e=this.candleZ;for(let t of this.seriesZ.values())t>e&&(e=t);return e}bottomZ(){let e=this.candleZ;for(let t of this.seriesZ.values())t<e&&(e=t);return e}ensurePane(e,t,n,i){this.orderedCache=null;let o=this.panes.get(e);if(o)return o.order=n,o.heightWeight=i,o.kind=t,o;let s={id:e,kind:t,order:n,heightWeight:i,bounds:{top:0,height:0},scale:{min:0,max:1},scaleTarget:{min:0,max:1},initialized:false,manualScale:null,collapsed:false,percentBaseline:0};return this.panes.set(e,s),s}removePane(e){this.panes.delete(e),this.orderedCache=null;}};function Sh(r,e){return e.kind==="price"?r.scaleMode:e.scaleMode??"price"}function Ri(r,e){return e.kind==="price"?r.logScale:e.logScale??false}function Ch(r,e){return e.kind==="price"?r.invertScale:e.invert??false}function kn(r,e){let t=Sh(r,e);if(t!=="percent"&&t!=="indexed")return;let n=e.percentBaseline;if(!(!Number.isFinite(n)||n===0))return {baseline:n,indexed:t==="indexed"}}var us=class{constructor(){this.kind="canvas2d";this.modelAlpha=1;this.candleBodyAlpha=1;this.candleStructureAlpha=1;this.candleBodyScale=1;this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}render(e,t,n){let i=this.ctx,o=this.canvas;if(!i||!o)return;let s=t.dpr,a=o.width/s,l=o.height/s,c=t.width;i.setTransform(s,0,0,s,0,0),i.clearRect(0,0,a,l);let u=t.barCount;if(u===0)return;let d=t.visibleLogicalRange(),h=Math.max(0,Math.floor(d.from)),p=Math.min(u-1,Math.ceil(d.to));if(p<h)return;let m=KL(e.indicators),f=e.orderedPanes();for(let g of f){if(g.collapsed)continue;let b=e.orderedIndicatorsForPane(g.id),y=g.kind==="price";i.save(),i.beginPath(),i.rect(0,g.bounds.top,c,g.bounds.height),i.clip();let v=L=>{let w=e.scaleFor(L,g);return w===g.scale?g:{...g,scale:w}};i.globalAlpha=this.modelAlpha;for(let L of b)for(let w of L.backgrounds)w.overlay!==true&&this.drawBackground(i,w,g,t);if(y)for(let L of e.indicators.values())for(let w of L.backgrounds)w.overlay===true&&this.drawBackground(i,w,g,t);let S=e.drawingSlices.get(g.id)??[],E=0,T=L=>{for(;E<S.length&&S[E].beforeZ<=L;E+=1)i.globalAlpha=1,i.drawImage(S[E].canvas,0,0,a,l);},k=y&&!e.candlesHidden,x=false;for(let L of b){k&&!x&&e.zOf(L.id)>=e.candleZ&&(T(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c),x=true),T(e.zOf(L.id)),i.globalAlpha=this.modelAlpha;let w=e.offsetOf(L.id),M=v(L);for(let P of L.fills)P.overlay!==true&&this.drawFill(i,L,P,M,t,h,p,w);for(let P of L.series)P.overlay!==true&&this.drawSeries(i,P,M,t,h,p,n,w);}if(k&&!x&&(T(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c)),y){i.globalAlpha=this.modelAlpha;for(let L of e.indicators.values()){let w=e.offsetOf(L.id);for(let M of L.fills)M.overlay===true&&this.drawFill(i,L,M,g,t,h,p,w);}for(let L of e.indicators.values()){let w=e.offsetOf(L.id);for(let M of L.series)M.overlay===true&&this.drawSeries(i,M,g,t,h,p,n,w);}}T(1/0),i.globalAlpha=this.modelAlpha;for(let L of b){let w=v(L);for(let M of L.priceLines)this.drawHline(i,M,w,t,c,n);}i.restore();}}destroy(){this.canvas=null,this.ctx=null;}drawPriceSeries(e,t,n,i,o,s,a,l,c){if(t.basePainting==="none")return;let u=t.bars,d=t.style;switch(t.priceStyle){case "bars":this.drawBars(e,u,n,i,o,s,d.bars.upColor??a.upColor,d.bars.downColor??a.downColor,l);return;case "line":this.drawPriceLine(e,u,n,i,o,s,d.line.color??a.upColor,d.line.width);return;case "area":{let h=d.area.lineColor??a.upColor;this.drawPriceArea(e,u,n,i,o,s,d.area.topColor??h,d.area.bottomColor??"rgba(0,0,0,0)"),this.drawPriceLine(e,u,n,i,o,s,h,d.area.width);return}case "baseline":this.drawBaseline(e,u,n,i,o,s,t,a,c);return;default:this.drawCandles(e,t,u,n,i,o,s,a,l);}}drawBars(e,t,n,i,o,s,a,l,c){let u=o.bodySpacing(),d=ki(u);if(d==="aggregate"){this.drawCandlesAggregated(e,t,n,i,o,s,m=>c.get(m.time)??(m.close>=m.open?a:l));return}let h=Math.max(1,Math.round(u*.35)),p=d==="full";e.lineWidth=1;for(let m=n;m<=i;m+=1){let f=t[m];if(!f||f.high<=f.low)continue;let g=Math.round(o.logicalToX(m))+.5,b=c.get(f.time)??(f.close>=f.open?a:l),y=o.priceToY(f.high,s.scale,s.bounds),v=o.priceToY(f.low,s.scale,s.bounds);if(e.strokeStyle=b,e.beginPath(),e.moveTo(g,y),e.lineTo(g,v),p){let S=o.priceToY(f.open,s.scale,s.bounds),E=o.priceToY(f.close,s.scale,s.bounds);e.moveTo(g-h,S),e.lineTo(g,S),e.moveTo(g,E),e.lineTo(g+h,E);}e.stroke();}}drawPriceLine(e,t,n,i,o,s,a,l){e.lineWidth=l,e.lineJoin="round",e.lineCap="round",e.strokeStyle=a,e.beginPath();let c=false;for(let u=Math.max(0,n-1);u<=i;u+=1){let d=t[u];if(!d){c=false;continue}let h=o.logicalToX(u),p=o.priceToY(d.close,s.scale,s.bounds);c?e.lineTo(h,p):(e.moveTo(h,p),c=true);}e.stroke(),e.lineCap="butt";}drawPriceArea(e,t,n,i,o,s,a,l){let c=s.bounds.top+s.bounds.height,u=[],d=1/0;for(let p=Math.max(0,n-1);p<=i;p+=1){let m=t[p];if(!m)continue;let f=o.logicalToX(p),g=o.priceToY(m.close,s.scale,s.bounds);u.push({x:f,y:g}),g<d&&(d=g);}if(u.length<2)return;let h=e.createLinearGradient(0,d,0,c);h.addColorStop(0,a),h.addColorStop(1,l),e.fillStyle=h,e.beginPath(),e.moveTo(u[0].x,c);for(let p of u)e.lineTo(p.x,p.y);e.lineTo(u[u.length-1].x,c),e.closePath(),e.fill();}drawBaseline(e,t,n,i,o,s,a,l,c){let u=a.baselinePriceFor(s.scale),d=o.priceToY(u,s.scale,s.bounds),h=s.bounds.top,p=s.bounds.top+s.bounds.height,m=a.style.baseline,f=m.topLineColor??Ei,g=m.bottomLineColor??Li,b=m.topFillColor??q(f,Cn),y=m.topFillColor2??q(f,Tn),v=m.bottomFillColor??q(g,Cn),S=m.bottomFillColor2??q(g,Tn),E=[];for(let x=Math.max(0,n-1);x<=i;x+=1){let L=t[x];L&&E.push({x:o.logicalToX(x),y:o.priceToY(L.close,s.scale,s.bounds)});}if(E.length<2)return;let T=()=>{e.beginPath(),e.moveTo(E[0].x,d);for(let x of E)e.lineTo(x.x,x.y);e.lineTo(E[E.length-1].x,d),e.closePath();};if(d>h){e.save(),e.beginPath(),e.rect(0,h,c,d-h),e.clip();let x=e.createLinearGradient(0,h,0,d);x.addColorStop(0,b),x.addColorStop(1,y),e.fillStyle=x,T(),e.fill(),e.restore();}if(d<p){e.save(),e.beginPath(),e.rect(0,d,c,p-d),e.clip();let x=e.createLinearGradient(0,d,0,p);x.addColorStop(0,S),x.addColorStop(1,v),e.fillStyle=x,T(),e.fill(),e.restore();}e.strokeStyle=a.style.borderColor??l.borderColor,e.lineWidth=1,Di(e,"dashed"),e.beginPath(),e.moveTo(0,Math.round(d)+.5),e.lineTo(c,Math.round(d)+.5),e.stroke(),Di(e,"solid"),e.lineWidth=m.width,e.lineJoin="round",e.lineCap="round";let k=(x,L,w,M,P)=>{e.strokeStyle=P,e.beginPath(),e.moveTo(x,L),e.lineTo(w,M),e.stroke();};for(let x=1;x<E.length;x+=1){let L=E[x-1],w=E[x],M=L.y<=d,P=w.y<=d;if(M!==P&&w.y!==L.y){let C=(d-L.y)/(w.y-L.y),A=L.x+(w.x-L.x)*C;k(L.x,L.y,A,d,M?f:g),k(A,d,w.x,w.y,P?f:g);}else k(L.x,L.y,w.x,w.y,M?f:g);}e.lineCap="butt";}drawCandles(e,t,n,i,o,s,a,l,c){let u=s.bodySpacing(),d=ki(u),h=Mi(t.style.candle,t.candleOverride,l.upColor,l.downColor),p=h.candle;if(d==="aggregate"){this.drawCandlesAggregated(e,n,i,o,s,a,g=>{let b=g.close>=g.open;return (b?p.wickUpColor:p.wickDownColor)??c.get(g.time)??(b?h.up:h.down)});return}let m=d==="full",f=this.candleStructureAlpha>this.candleBodyAlpha+.001;for(let g=i;g<=o;g+=1){let b=n[g];if(!b||b.high<=b.low)continue;let y=fc(s.logicalToX(g),u,s.dpr,this.candleBodyScale),v=y.center,S=b.close>=b.open,E=S?h.up:h.down,k=c.get(b.time)??E,x=0,L=0;if(m){let w=s.priceToY(b.open,a.scale,a.bounds),M=s.priceToY(b.close,a.scale,a.bounds);x=nn(Math.min(w,M),s.dpr),L=Math.max(1/s.dpr,nn(Math.max(w,M),s.dpr)-x);}if(p.wickVisible){let w=(S?p.wickUpColor:p.wickDownColor)??(m?E:k),M=nn(s.priceToY(b.high,a.scale,a.bounds),s.dpr),P=nn(s.priceToY(b.low,a.scale,a.bounds),s.dpr);e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=w,e.lineWidth=y.wickW,e.beginPath(),m?(e.moveTo(v,M),e.lineTo(v,x),e.moveTo(v,x+L),e.lineTo(v,P)):(e.moveTo(v,M),e.lineTo(v,P)),e.stroke();}if(m&&(p.bodyVisible&&(e.globalAlpha=this.candleBodyAlpha,e.fillStyle=k,e.fillRect(y.bodyX,x,y.bodyW,L)),p.borderVisible||f&&p.bodyVisible)){e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=p.borderVisible?(S?p.borderUpColor:p.borderDownColor)??k:k,e.lineWidth=1;let w=Math.max(0,y.bodyW-1),M=Math.max(0,L-1);e.strokeRect(y.bodyX+.5,x+.5,w,M);}}}drawCandlesAggregated(e,t,n,i,o,s,a){let l=c=>o.priceToY(c,s.scale,s.bounds);e.lineWidth=1;for(let c of gc(t,n,i,u=>o.logicalToX(u),l,a)){let u=c.x+.5;e.strokeStyle=c.color,e.beginPath(),e.moveTo(u,l(c.hi)),e.lineTo(u,l(c.lo)),e.stroke();}}drawSeries(e,t,n,i,o,s,a,l=0){if(Ct(t,"pane")){if(t.kind==="candle"||t.kind==="bar"){this.drawPlotCandles(e,t,n,i,o,s,a,l);return}if(Fe(t))switch(t.kind){case "histogram":case "columns":this.drawHistogram(e,t,n,i,o,s,l);break;case "area":this.drawArea(e,t,n,i,o,s,l),this.drawPolyline(e,t,n,i,o,s,false,l);break;case "circles":case "cross":this.drawPointMarkers(e,t,n,i,o,s,l);break;case "step":this.drawPolyline(e,t,n,i,o,s,true,l);break;default:this.drawPolyline(e,t,n,i,o,s,false,l);}}}drawPolyline(e,t,n,i,o,s,a,l=0){e.lineWidth=Math.max(1,t.style.width),e.lineJoin="round",Di(e,t.style.lineStyle);let c=0,u=0,d=false;for(let h=Math.max(1,o-1);h<=s;h+=1){let p=t.points[h-l],m=t.points[h-1-l];if(!p||p.value===null||!m||m.value===null){d=false;continue}let f=i.logicalToX(h),g=i.priceToY(p.value,n.scale,n.bounds);d||(c=i.logicalToX(h-1),u=i.priceToY(m.value,n.scale,n.bounds)),e.strokeStyle=p.color??t.style.color,e.beginPath(),e.moveTo(c,u),a&&e.lineTo(f,u),e.lineTo(f,g),e.stroke(),c=f,u=g,d=true;}Di(e,"solid");}drawArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=[],u=1/0,d=()=>{if(c.length===0)return;let h=e.createLinearGradient(0,u,0,l);h.addColorStop(0,t.style.color),h.addColorStop(1,"rgba(0,0,0,0)"),e.fillStyle=h,e.beginPath(),e.moveTo(c[0].x,l);for(let p of c)e.lineTo(p.x,p.y);e.lineTo(c[c.length-1].x,l),e.closePath(),e.fill(),c=[],u=1/0;};for(let h=o;h<=s;h+=1){let p=t.points[h-a];if(!p||p.value===null){d();continue}let m=i.logicalToX(h),f=i.priceToY(p.value,n.scale,n.bounds);c.push({x:m,y:f}),f<u&&(u=f);}d();}drawHistogram(e,t,n,i,o,s,a=0){let l=i.bodySpacing(),c=Math.max(1,(t.kind==="columns"?.7:.8)*l),u=c/2,d=t.style.base??0,h=i.priceToY(d,n.scale,n.bounds);for(let p=o;p<=s;p+=1){let m=t.points[p-a];if(!m||m.value===null)continue;let f=i.logicalToX(p),g=i.priceToY(m.value,n.scale,n.bounds);e.fillStyle=m.color??t.style.color,e.fillRect(f-u,Math.min(h,g),c,Math.max(1,Math.abs(g-h)));}}drawPointMarkers(e,t,n,i,o,s,a=0){let l=Math.max(1.5,t.style.width);for(let c=o;c<=s;c+=1){let u=t.points[c-a];if(!u||u.value===null)continue;let d=i.logicalToX(c),h=i.priceToY(u.value,n.scale,n.bounds);e.strokeStyle=u.color??t.style.color,e.fillStyle=u.color??t.style.color,t.kind==="cross"?(e.lineWidth=1,e.beginPath(),e.moveTo(d-l,h),e.lineTo(d+l,h),e.moveTo(d,h-l),e.lineTo(d,h+l),e.stroke()):(e.beginPath(),e.arc(d,h,l,0,Math.PI*2),e.fill());}}drawPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),u=t.style?.up??a.upColor,d=t.style?.down??a.downColor,h=t.kind==="bar",p=Math.max(.5,Math.floor(c*.7)/2),m=Math.max(1,Math.round(c*.35));for(let f=o;f<=s;f+=1){let g=t.bars[f-l];if(!g)continue;let b=t.barColors?.[f-l],y=b?.color??(g.close>=g.open?u:d),v=Math.round(i.logicalToX(f))+.5,S=i.priceToY(g.high,n.scale,n.bounds),E=i.priceToY(g.low,n.scale,n.bounds),T=i.priceToY(g.open,n.scale,n.bounds),k=i.priceToY(g.close,n.scale,n.bounds);if(h){e.strokeStyle=y,e.lineWidth=1,e.beginPath(),e.moveTo(v,S),e.lineTo(v,E),e.moveTo(v-m,T),e.lineTo(v,T),e.moveTo(v,k),e.lineTo(v+m,k),e.stroke();continue}e.strokeStyle=b?.wickColor??y,e.lineWidth=ss(c),e.beginPath(),e.moveTo(v,S),e.lineTo(v,E),e.stroke(),e.fillStyle=y,e.fillRect(v-p,Math.min(T,k),p*2,Math.max(1,Math.abs(k-T))),b?.borderColor&&(e.strokeStyle=b.borderColor,e.strokeRect(v-p,Math.min(T,k),p*2,Math.max(1,Math.abs(k-T))));}}drawFill(e,t,n,i,o,s,a,l=0){let c=Zy(t,n.fromSeriesId),u=Zy(t,n.toSeriesId);if(!c||!u)return;let d=NaN,h=NaN,p="",m="",f=null;for(let g=Math.max(1,s);g<=a;g+=1){let b=c[g-1-l],y=u[g-1-l],v=c[g-l],S=u[g-l];if(!b||!y||!v||!S||b.value===null||y.value===null||v.value===null||S.value===null)continue;let E=o.logicalToX(g-1),T=o.logicalToX(g),k=o.priceToY(b.value,i.scale,i.bounds),x=o.priceToY(y.value,i.scale,i.bounds),L=o.priceToY(v.value,i.scale,i.bounds),w=o.priceToY(S.value,i.scale,i.bounds),M=n.gradient?.[g-1-l];if(M){let P=o.priceToY(M.topValue,i.scale,i.bounds),C=o.priceToY(M.bottomValue,i.scale,i.bounds),A=C===P?P+1:C;(!f||P!==d||A!==h||M.topColor!==p||M.bottomColor!==m)&&(f=e.createLinearGradient(0,P,0,A),f.addColorStop(0,M.topColor),f.addColorStop(1,M.bottomColor),d=P,h=A,p=M.topColor,m=M.bottomColor),e.fillStyle=f;}else {let P=n.colors?n.colors[g-1-l]:n.color;if(!P)continue;e.fillStyle=P;}e.beginPath(),e.moveTo(E,k),e.lineTo(T,L),e.lineTo(T,w),e.lineTo(E,x),e.closePath(),e.fill();}}drawBackground(e,t,n,i){let o=i.timeToX(t.from),s=i.timeToX(t.to);s<0||o>i.width||s<=o||(e.fillStyle=t.color,e.fillRect(o,n.bounds.top,s-o,n.bounds.height));}drawHline(e,t,n,i,o,s){let a=Math.round(i.priceToY(t.price,n.scale,n.bounds))+.5;a<n.bounds.top||a>n.bounds.top+n.bounds.height||(e.strokeStyle=t.color??s.textColor,e.lineWidth=t.width??1,Di(e,t.lineStyle??"solid"),e.beginPath(),e.moveTo(0,a),e.lineTo(o,a),e.stroke(),Di(e,"solid"));}};function Di(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function Zy(r,e){let t=r.series.find(n=>n.id===e);return t&&Fe(t)?t.points:null}var YL=new Map;function KL(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return YL;let t=new Map;for(let n of r.values())if(n.barColors)for(let i of n.barColors)t.set(i.time,i.color);return t}function Xn(r,e){let t=Math.max(1,e);return r==="dotted"?[t,t*2]:r==="dashed"?[t*4,t*3]:[]}function Oi(r,e,t,n,i,o,s){if(i==="none")return [r,e,t,n];let a=t-r,l=i==="left"||i==="both",c=i==="right"||i==="both";if(Math.abs(a)<1e-6){if(l&&c)return [r,0,t,s];let m=n>=e;return c?m?[r,e,t,s]:[r,e,t,0]:m?[r,0,t,n]:[r,s,t,n]}let u=(n-e)/a,d=m=>e+u*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,d(h),p,d(p)]}function Jy(r,e,t,n){let i=Math.atan2(n-e,t-r);return i>Math.PI/2&&(i-=Math.PI),i<-Math.PI/2&&(i+=Math.PI),i}function XL(r){let e=r.trim(),t=/^#([0-9a-f]{3})$/i.exec(e);if(t){let n=t[1];return {r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:1}}if(t=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(e),t){let n=t[1];return {r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16),a:t[2]?parseInt(t[2],16)/255:1}}if(t=/^rgba?\(([^)]+)\)$/i.exec(e),t){let n=t[1].split(",").map(i=>parseFloat(i.trim()));return {r:n[0]??0,g:n[1]??0,b:n[2]??0,a:n[3]??1}}return null}function jL(r,e,t){return (.299*r+.587*e+.114*t)/255}function _e(r){if(!r)return "#000000";let e=XL(r);return e?jL(e.r,e.g,e.b)>.55?"#000000":"#ffffff":"#000000"}function on(r){return Math.round(r*1.4)}var Nr=5,Fr=3;function Be(r){switch(r){case "tiny":return 10;case "small":return 12;case "large":return 18;case "huge":return 28;case "normal":return 14;default:return 0}}function Qy(r,e,t,n){let i=1;for(let l of r)l.length>i&&(i=l.length);let o=n?.62:.55,s=e*.9/(i*o),a=t*.85/(r.length*1.3);return Math.max(6,Math.min(s,a,48))}var qL={lines:[],boxes:[],labels:[],polylines:[],linefills:[]};function Fi(r,e){let t=n=>!!n.overlay===e;return {lines:(r.lines??[]).filter(t),boxes:(r.boxes??[]).filter(t),labels:(r.labels??[]).filter(t),polylines:(r.polylines??[]).filter(t),linefills:(r.linefills??[]).filter(t)}}function Th(r){return !r.lines.length&&!r.boxes.length&&!r.labels.length&&!r.polylines.length&&!r.linefills.length}function ew(r){return r==="auto"?12:Be(r)}function ZL(r,e,t,n,i){let o=Math.min(r,e),s=Math.max(r,e);return r===e?r>=n&&r<=i:t==="both"?true:t==="left"?s>=n:(t==="right"||s>=n)&&o<=i}var Ni=class{constructor(e,t=qL){this.deps=e;this.set=t;this.widthCache=new Map;this.tipRegions=[];this.indexOffset=0;}setSet(e,t=0){this.set=e,this.indexOffset=t;}setDeps(e){this.deps=e;}isEmpty(){let e=this.set;return !e.lines.length&&!e.boxes.length&&!e.labels.length&&!e.polylines.length&&!e.linefills.length}labelTipRegions(){return this.tipRegions}render(e,t,n,i,o){this.tipRegions=[],!this.isEmpty()&&(e.save(),this.drawLinefills(e,t,n,i,o),this.drawBoxes(e,t,n,i,o),this.drawPolylines(e,t,i,o),this.drawLines(e,t,n,i,o),this.drawLabels(e,t,n,i,o),e.restore());}priceRange(e,t){let n=Math.min(e,t),i=Math.max(e,t),o=(d,h,p)=>p==="both"?true:p==="left"?Math.max(d,h)>=n:(p==="right"||Math.max(d,h)>=n)&&Math.min(d,h)<=i,s=1/0,a=-1/0,l=d=>{d<s&&(s=d),d>a&&(a=d);};for(let d of this.set.lines)d.invisible||ZL(this.logicalOf(d.xloc,d.x1),this.logicalOf(d.xloc,d.x2),d.extend,n,i)&&(l(d.y1),l(d.y2));for(let d of this.set.boxes)!d.bgColor&&!(d.borderColor&&d.borderWidth>0)&&!d.text||o(this.logicalOf(d.xloc,d.left),this.logicalOf(d.xloc,d.right),d.extend)&&(l(d.top),l(d.bottom));for(let d of this.set.linefills){if(!d.color)continue;let h=[d.line1.x1,d.line1.x2,d.line2.x1,d.line2.x2].map((m,f)=>this.logicalOf(f<2?d.line1.xloc:d.line2.xloc,m)),p=d.line1.extend!=="none"||d.line2.extend!=="none"?"both":"none";o(Math.min(...h),Math.max(...h),p)&&(l(d.line1.y1),l(d.line1.y2),l(d.line2.y1),l(d.line2.y2));}for(let d of this.set.polylines){if(d.points.length<2)continue;let h=d.points.map(p=>this.logicalOf(p.xloc,p.x));if(o(Math.min(...h),Math.max(...h),"none"))for(let p of d.points)l(p.price);}let c=0,u=0;for(let d of this.set.labels){let h=this.logicalOf(d.xloc,d.x);if(!o(h,h,"none"))continue;if(d.yloc==="price"){l(d.y);continue}if(d.yloc==="top"||d.yloc==="bottom")continue;let p=this.deps.barAt(h);if(!p)continue;l(d.yloc==="abovebar"?p.high:p.low);let m=ew(d.size),f=Math.max(1,(d.text??"").split(`
|
|
817
|
+
`).length),g=this.isPointShape(d.style)?14+Math.max(4,m*.6)+2:14+m*1.25*f+8+7;d.yloc==="abovebar"?c=Math.max(c,g):u=Math.max(u,g);}return !Number.isFinite(s)||!Number.isFinite(a)?null:{min:s,max:a,aboveMargin:c,belowMargin:u}}logicalOf(e,t){return e==="bar_time"?this.deps.timeToLogical(t):t+this.indexOffset}drawLines(e,t,n,i,o){for(let s of this.set.lines){if(s.invisible)continue;let a=i(this.logicalOf(s.xloc,s.x1)),l=i(this.logicalOf(s.xloc,s.x2)),c=o(s.y1),u=o(s.y2);if(c===null||u===null)continue;let d=s.extend==="left"||s.extend==="both",h=s.extend==="right"||s.extend==="both";if(!d&&!h&&(Math.max(a,l)<0||Math.min(a,l)>t))continue;let[p,m,f,g]=Oi(a,c,l,u,s.extend,t,n),b=s.color??this.deps.theme.textColor;e.beginPath(),e.moveTo(p,m),e.lineTo(f,g),e.strokeStyle=b,e.lineWidth=s.width,e.setLineDash(Xn(s.style,s.width)),e.stroke(),e.setLineDash([]);let y=l>=a;if(s.arrowRight){let v=(y?h:d)?y?[f,g]:[p,m]:[l,u];this.drawArrow(e,v[0],v[1],a,c,s.width,b);}if(s.arrowLeft){let v=(y?d:h)?y?[p,m]:[f,g]:[a,c];this.drawArrow(e,v[0],v[1],l,u,s.width,b);}}}drawArrow(e,t,n,i,o,s,a){let l=Math.atan2(n-o,t-i),c=6+s*2,u=.45;e.beginPath(),e.moveTo(t,n),e.lineTo(t-c*Math.cos(l-u),n-c*Math.sin(l-u)),e.lineTo(t-c*Math.cos(l+u),n-c*Math.sin(l+u)),e.closePath(),e.fillStyle=a,e.fill();}drawLinefills(e,t,n,i,o){for(let s of this.set.linefills){if(!s.color)continue;let a=this.resolveLine(s.line1,t,n,i,o),l=this.resolveLine(s.line2,t,n,i,o);if(!a||!l)continue;let c=h=>h[0]>h[2]||h[0]===h[2]&&h[1]>h[3]?[h[2],h[3],h[0],h[1]]:h,u=c(a),d=c(l);e.beginPath(),e.moveTo(u[0],u[1]),e.lineTo(u[2],u[3]),e.lineTo(d[2],d[3]),e.lineTo(d[0],d[1]),e.closePath(),e.fillStyle=s.color,e.fill();}}resolveLine(e,t,n,i,o){let s=i(this.logicalOf(e.xloc,e.x1)),a=i(this.logicalOf(e.xloc,e.x2)),l=o(e.y1),c=o(e.y2);return l===null||c===null?null:Oi(s,l,a,c,e.extend,t,n)}drawPolylines(e,t,n,i){for(let o of this.set.polylines){let s=[];for(let c of o.points){let u=i(c.price);u!==null&&s.push([n(this.logicalOf(c.xloc,c.x)),u]);}if(s.length<2)continue;let a=1/0,l=-1/0;for(let c of s)c[0]<a&&(a=c[0]),c[0]>l&&(l=c[0]);if(!(l<0||a>t)){if(e.beginPath(),o.curved)this.curvedPath(e,s,o.closed);else {e.moveTo(s[0][0],s[0][1]);for(let c=1;c<s.length;c+=1)e.lineTo(s[c][0],s[c][1]);}if(o.closed&&e.closePath(),o.fillColor&&(e.fillStyle=o.fillColor,e.fill()),o.lineColor&&(e.strokeStyle=o.lineColor,e.lineWidth=o.lineWidth,e.setLineDash(Xn(o.lineStyle,o.lineWidth)),e.stroke(),e.setLineDash([]),o.arrowLeft||o.arrowRight)){let c=o.closed?s.length:s.length-1;for(let u=0;u<c;u+=1){let d=s[u],h=s[(u+1)%s.length];o.arrowRight&&this.drawArrow(e,h[0],h[1],d[0],d[1],o.lineWidth,o.lineColor),o.arrowLeft&&this.drawArrow(e,d[0],d[1],h[0],h[1],o.lineWidth,o.lineColor);}}}}}curvedPath(e,t,n){let i=t.length,o=a=>n?t[(a%i+i)%i]:t[Math.max(0,Math.min(i-1,a))];e.moveTo(t[0][0],t[0][1]);let s=n?i:i-1;for(let a=0;a<s;a+=1){let l=o(a-1),c=o(a),u=o(a+1),d=o(a+2),h=c[0]+(u[0]-l[0])/6,p=c[1]+(u[1]-l[1])/6,m=u[0]-(d[0]-c[0])/6,f=u[1]-(d[1]-c[1])/6;e.bezierCurveTo(h,p,m,f,u[0],u[1]);}}drawBoxes(e,t,n,i,o){for(let s of this.set.boxes){let a=i(this.logicalOf(s.xloc,s.left)),l=i(this.logicalOf(s.xloc,s.right));(s.extend==="left"||s.extend==="both")&&(a=-2),(s.extend==="right"||s.extend==="both")&&(l=t+2);let c=o(s.top),u=o(s.bottom);if(c===null||u===null)continue;let d=Math.min(a,l),h=Math.max(a,l),p=Math.min(c,u),m=Math.max(c,u),f=h-d,g=m-p;h<0||d>t||m<0||p>n||(s.bgColor&&(e.fillStyle=s.bgColor,e.fillRect(d,p,f,g)),s.borderColor&&s.borderWidth>0&&(e.strokeStyle=s.borderColor,e.lineWidth=s.borderWidth,e.setLineDash(Xn(s.borderStyle,s.borderWidth)),e.strokeRect(d,p,f,g),e.setLineDash([])),s.text&&this.drawBoxText(e,s,d,p,f,g));}}measure(e,t,n){let i=`${t} ${n}`,o=this.widthCache.get(i);return o===void 0&&(e.font=t,o=e.measureText(n).width,this.widthCache.set(i,o)),o}wrapText(e,t,n,i){let o=[];for(let s of n.split(`
|
|
818
818
|
`)){if(this.measure(e,t,s)<=i){o.push(s);continue}let a="";for(let l of s.split(/(\s+)/)){let c=a+l;a&&this.measure(e,t,c)>i?(o.push(a.trimEnd()),a=l.trimStart()):a=c;}a.trim()&&o.push(a.trimEnd());}return o}drawBoxText(e,t,n,i,o,s){let a=t.text,l=t.fontFamily==="monospace"?"monospace":this.deps.theme.fontFamily||"sans-serif",c=`${t.italic?"italic ":""}${t.bold?"bold ":""}`,u=4,d=Be(t.textSize),h;if(d===0){let b=`${c}14px ${l}`;h=t.wrap?this.wrapText(e,b,a,Math.max(1,o-u*2)):a.split(`
|
|
819
|
-
`),d=
|
|
820
|
-
`);}e.font=`${c}${d}px ${l}`,e.fillStyle=t.textColor??_e(t.bgColor);let p=d*1.3,m=p*h.length,f;t.hAlign==="left"?(e.textAlign="left",f=n+u):t.hAlign==="right"?(e.textAlign="right",f=n+o-u):(e.textAlign="center",f=n+o/2),e.textBaseline="top";let g;t.vAlign==="top"?g=i+u:t.vAlign==="bottom"?g=i+s-u-m:g=i+(s-m)/2,e.save(),e.beginPath(),e.rect(n,i,o,s),e.clip();for(let b=0;b<h.length;b+=1)e.fillText(h[b],f,g+b*p);e.restore();}drawLabels(e,t,n,i,o){for(let s of this.set.labels){let a=i(this.logicalOf(s.xloc,s.x));if(a<-50||a>t+50)continue;let l;if(s.yloc==="price")l=o(s.y);else if(s.yloc==="top")l=14;else if(s.yloc==="bottom")l=n-14;else {let d=this.deps.barAt(this.logicalOf(s.xloc,s.x));if(!d)continue;let h=o(s.yloc==="abovebar"?d.high:d.low);l=h===null?null:h+(s.yloc==="abovebar"?-14:14);}if(l===null)continue;let c=s.color??this.deps.theme.textColor,u=
|
|
819
|
+
`),d=Qy(h,o,s,t.bold);}else {let b=`${c}${d}px ${l}`;h=t.wrap?this.wrapText(e,b,a,Math.max(1,o-u*2)):a.split(`
|
|
820
|
+
`);}e.font=`${c}${d}px ${l}`,e.fillStyle=t.textColor??_e(t.bgColor);let p=d*1.3,m=p*h.length,f;t.hAlign==="left"?(e.textAlign="left",f=n+u):t.hAlign==="right"?(e.textAlign="right",f=n+o-u):(e.textAlign="center",f=n+o/2),e.textBaseline="top";let g;t.vAlign==="top"?g=i+u:t.vAlign==="bottom"?g=i+s-u-m:g=i+(s-m)/2,e.save(),e.beginPath(),e.rect(n,i,o,s),e.clip();for(let b=0;b<h.length;b+=1)e.fillText(h[b],f,g+b*p);e.restore();}drawLabels(e,t,n,i,o){for(let s of this.set.labels){let a=i(this.logicalOf(s.xloc,s.x));if(a<-50||a>t+50)continue;let l;if(s.yloc==="price")l=o(s.y);else if(s.yloc==="top")l=14;else if(s.yloc==="bottom")l=n-14;else {let d=this.deps.barAt(this.logicalOf(s.xloc,s.x));if(!d)continue;let h=o(s.yloc==="abovebar"?d.high:d.low);l=h===null?null:h+(s.yloc==="abovebar"?-14:14);}if(l===null)continue;let c=s.color??this.deps.theme.textColor,u=ew(s.size);if(this.isPointShape(s.style)){if(s.noFill||this.drawLabelShape(e,s.style,a,l,u,c),s.text&&this.drawLabelText(e,s,a,l+u,u),s.tooltip){let d=Math.max(4,u*.6)+3;this.tipRegions.push({left:a-d,top:l-d,right:a+d,bottom:l+d,text:s.tooltip});}}else if(s.style==="none"||s.style==="text_outline")s.text&&(this.drawLabelText(e,s,a,l,u,s.style==="text_outline"),s.tooltip&&this.tipRegions.push(this.textRegion(e,s,a,l,u,s.tooltip)));else {let d=this.drawBubble(e,s,a,l,u,c);s.tooltip&&this.tipRegions.push({left:d.x,top:d.y,right:d.x+d.w,bottom:d.y+d.h,text:s.tooltip});}}}labelFont(e,t){let n=e.fontFamily==="monospace"?"monospace":this.deps.theme.fontFamily||"sans-serif";return `${e.italic?"italic ":""}${e.bold?"bold ":""}${t}px ${n}`}textRegion(e,t,n,i,o,s){let a=this.labelFont(t,o),l=(t.text??"").split(`
|
|
821
821
|
`),c=Math.max(1,...l.map(h=>this.measure(e,a,h))),u=o*1.25*l.length,d=t.textAlign==="left"?n:t.textAlign==="right"?n-c:n-c/2;return {left:d,top:i-u/2,right:d+c,bottom:i+u/2,text:s}}isPointShape(e){switch(e){case "circle":case "square":case "diamond":case "flag":case "arrowup":case "arrowdown":case "triangleup":case "triangledown":case "cross":case "xcross":return true;default:return false}}drawLabelText(e,t,n,i,o,s=false){e.font=this.labelFont(t,o),e.textAlign=t.textAlign==="left"?"left":t.textAlign==="right"?"right":"center",e.textBaseline="middle";let a=t.text.split(`
|
|
822
822
|
`),l=o*1.25,c=i-l*(a.length-1)/2;if(s){e.lineWidth=3,e.strokeStyle=_e(t.textColor??this.deps.theme.textColor);for(let u=0;u<a.length;u+=1)e.strokeText(a[u],n,c+u*l);}e.fillStyle=t.textColor??this.deps.theme.textColor;for(let u=0;u<a.length;u+=1)e.fillText(a[u],n,c+u*l);}drawLabelShape(e,t,n,i,o,s){let a=Math.max(4,o*.6);switch(e.fillStyle=s,e.strokeStyle=s,e.lineWidth=Math.max(1,a*.3),e.beginPath(),t){case "circle":e.arc(n,i,a,0,Math.PI*2),e.fill();break;case "square":e.fillRect(n-a,i-a,a*2,a*2);break;case "diamond":e.moveTo(n,i-a),e.lineTo(n+a,i),e.lineTo(n,i+a),e.lineTo(n-a,i),e.closePath(),e.fill();break;case "triangleup":case "arrowup":e.moveTo(n,i-a),e.lineTo(n+a,i+a),e.lineTo(n-a,i+a),e.closePath(),e.fill();break;case "triangledown":case "arrowdown":e.moveTo(n,i+a),e.lineTo(n+a,i-a),e.lineTo(n-a,i-a),e.closePath(),e.fill();break;case "flag":e.moveTo(n-a*.7,i-a),e.lineTo(n-a*.7,i+a),e.moveTo(n-a*.7,i-a),e.lineTo(n+a,i-a*.4),e.lineTo(n-a*.7,i+a*.2),e.stroke(),e.fill();break;case "cross":e.moveTo(n,i-a),e.lineTo(n,i+a),e.moveTo(n-a,i),e.lineTo(n+a,i),e.stroke();break;case "xcross":e.moveTo(n-a,i-a),e.lineTo(n+a,i+a),e.moveTo(n+a,i-a),e.lineTo(n-a,i+a),e.stroke();break;default:e.arc(n,i,a,0,Math.PI*2),e.fill();}}drawBubble(e,t,n,i,o,s){e.font=this.labelFont(t,o);let a=(t.text??"").split(`
|
|
823
|
-
`),l=6,c=4,u=o*1.25,h=Math.max(1,...a.map(y=>this.measure(e,e.font,y)))+l*2,p=u*a.length+c*2,m=7,f=n-h/2,g=i-p-m,b="down";switch(t.style){case "label_up":f=n-h/2,g=i+m,b="up";break;case "label_left":f=n+m,g=i-p/2,b="left";break;case "label_right":f=n-h-m,g=i-p/2,b="right";break;case "label_center":f=n-h/2,g=i-p/2,b="none";break;case "label_lower_left":f=n+m,g=i-p-m,b="none";break;case "label_lower_right":f=n-h-m,g=i-p-m,b="none";break;case "label_upper_left":f=n+m,g=i+m,b="none";break;case "label_upper_right":f=n-h-m,g=i+m,b="none";break;default:f=n-h/2,g=i-p-m,b="down";}if(t.noFill||(e.fillStyle=s,this.roundRect(e,f,g,h,p,4),e.fill(),b!=="none"&&(e.beginPath(),b==="down"?(e.moveTo(n-m,g+p),e.lineTo(n+m,g+p),e.lineTo(n,i)):b==="up"?(e.moveTo(n-m,g),e.lineTo(n+m,g),e.lineTo(n,i)):b==="left"?(e.moveTo(f,i-m),e.lineTo(f,i+m),e.lineTo(n,i)):(e.moveTo(f+h,i-m),e.lineTo(f+h,i+m),e.lineTo(n,i)),e.closePath(),e.fill())),t.text){e.fillStyle=t.textColor??(t.noFill?this.deps.theme.textColor:_e(s)),e.textBaseline="middle";let y;t.textAlign==="left"?(e.textAlign="left",y=f+l):t.textAlign==="right"?(e.textAlign="right",y=f+h-l):(e.textAlign="center",y=f+h/2);let v=g+c+u/2;for(let S=0;S<a.length;S+=1)e.fillText(a[S],y,v+S*u);}return {x:f,y:g,w:h,h:p}}roundRect(e,t,n,i,o,s){let a=Math.min(s,i/2,o/2);e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+i,n,t+i,n+o,a),e.arcTo(t+i,n+o,t,n+o,a),e.arcTo(t,n+o,t,n,a),e.arcTo(t,n,t+i,n,a),e.closePath();}};function us(r,e){if(!e||e==="UTC")return 0;try{let n=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(r)),i=s=>Number(n.find(a=>a.type===s)?.value);return Date.UTC(i("year"),i("month")-1,i("day"),i("hour")%24,i("minute"),i("second"))-r}catch{return 0}}function Ec(r,e){return new Date(r+us(r,e))}function Pc(r,e,t=6){if(!(e>r)||!Number.isFinite(r)||!Number.isFinite(e))return [];let n=(e-r)/Math.max(1,t),i=Math.pow(10,Math.floor(Math.log10(n))),o=n/i,s=(o<1.5?1:o<3?2:o<7?5:10)*i,a=Math.max(0,-Math.floor(Math.log10(s))+1),l=[],c=Math.ceil(r/s)*s;for(let u=c;u<=e+s*1e-6;u+=s)l.push(Number(u.toFixed(a)));return l}function YM(r,e,t=6){if(!(e>r))return 2;let n=(e-r)/Math.max(1,t),i=Math.pow(10,Math.floor(Math.log10(n))),o=n/i,s=(o<1.5?1:o<3?2:o<7?5:10)*i;return Math.max(0,Math.min(8,-Math.floor(Math.log10(s))+1))}function KM(r,e,t=6){if(r<=0||!(e>r)||!Number.isFinite(r)||!Number.isFinite(e))return [];if(Math.log10(e)-Math.log10(r)<1.1)return Pc(r,e,t);let n=[],i=Math.floor(Math.log10(r)),o=Math.ceil(Math.log10(e));for(let s=i;s<=o;s+=1)for(let a of [1,2,5]){let l=a*Math.pow(10,s);l>=r&&l<=e&&n.push(l);}return n}function kh(r){let e=Math.abs(r);return e>=100?0:e>=1?2:e>=.01?4:6}function XM(r){if(!(r>0)||!Number.isFinite(r))return 2;for(let e=0;e<=8;e+=1)if(Math.abs(Number(r.toFixed(e))-r)<=r*1e-6)return e;return 8}function jM(r,e,t){let n=t!=null&&t>0?XM(t):YM(r.min,r.max,ms(e));return n===0?2:n}function ms(r){return Math.max(2,Math.min(16,Math.round(r/50)))}function qy(r,e){return r.log?KM(r.min,r.max,ms(e)):Pc(r.min,r.max,ms(e))}function Ch(r,e){return (r/e-1)*100}function Th(r,e){return r/e*100}function Jy(r){return `${r>=0?"+":"-"}${Math.abs(r).toFixed(2)}%`}function Qy(r){return r.toFixed(2)}function ew(r){let e=Math.abs(r);return e>=1e9?`${Mc(r/1e9)}B`:e>=1e6?`${Mc(r/1e6)}M`:e>=1e3?`${Mc(r/1e3)}K`:Mc(r)}function Mc(r){return Number(r.toFixed(2)).toString()}function fs(r,e,t,n,i){if(i==="none")return [];if(t){let{baseline:o,indexed:s}=t,a=Math.min(r.min,r.max),l=Math.max(r.min,r.max);if(s){let d=Th(a,o),h=Th(l,o);return Pc(d,h,ms(e)).map(p=>({price:o*p/100,label:Qy(p)}))}let c=Ch(a,o),u=Ch(l,o);return Pc(c,u,ms(e)).map(d=>({price:o*(1+d/100),label:Jy(d)}))}return i==="volume"?qy(r,e).map(o=>({price:o,label:ew(o)})):qy(r,e).map(o=>({price:o,label:Ic(r,e,o,n)}))}function gs(r,e,t,n,i,o){return o==="none"?"":n?n.indexed?Qy(Th(t,n.baseline)):Jy(Ch(t,n.baseline)):o==="volume"?ew(t):Ic(r,e,t,i)}function Ic(r,e,t,n){if(r.log&&Math.log10(r.max)-Math.log10(r.min)>=1.1){let o=kh(t);return t.toFixed(o===0?2:o)}return t.toFixed(jM(r,e,n))}var ds=1e3,hs=60*ds,Fi=60*hs,Fr=24*Fi,qM=7*Fr,Zy=30*Fr,tw=365*Fr,Sh=[ds,5*ds,15*ds,30*ds,hs,5*hs,15*hs,30*hs,Fi,2*Fi,4*Fi,6*Fi,12*Fi,Fr,2*Fr,qM,Zy,3*Zy,tw],Lc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ZM=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ps=r=>r<10?`0${r}`:String(r);function Eh(r,e,t){let n=Ec(r,e),i=`${ZM[n.getUTCDay()]} ${n.getUTCDate()} ${Lc[n.getUTCMonth()]} '${ps(n.getUTCFullYear()%100)}`;return t>=Fr?i:`${i} ${ps(n.getUTCHours())}:${ps(n.getUTCMinutes())}`}function JM(r){for(let e of Sh)if(e>=r)return e;return Sh[Sh.length-1]}function Ac(r,e,t=8,n=0){let i=e-r;if(!(i>0))return [];let o=JM(i/Math.max(1,t)),s=r+n,a=e+n,l=Math.ceil(s/o)*o,c=[];for(let u=l;u<=a;u+=o){let d=u-n,h=new Date(u),p,m=false;if(o<Fr){let f=h.getUTCHours(),g=h.getUTCMinutes();f===0&&g===0?(p=`${Lc[h.getUTCMonth()]} ${h.getUTCDate()}`,m=true):p=`${ps(f)}:${ps(g)}`;}else o<tw?(p=`${Lc[h.getUTCMonth()]} ${h.getUTCDate()}`,h.getUTCDate()===1&&(p=Lc[h.getUTCMonth()],m=true)):(p=String(h.getUTCFullYear()),m=true);c.push({time:d,label:p,major:m});}return c}function nw(r,e,t){if(!(e>0))return null;let n=r+e-t;return n<=0?null:QM(n)}function QM(r){let e=Math.max(0,Math.ceil(r/1e3)),t=e%60,n=Math.floor(e/60)%60,i=Math.floor(e/3600),o=s=>String(s).padStart(2,"0");return i>0?`${i}:${o(n)}:${o(t)}`:`${o(n)}:${o(t)}`}function rw(r,e){let[t,n,i,o]=te(r),s=t,a=n,l=i;if(o<1){let[d,h,p]=te(e);s=t*o+d*(1-o),a=n*o+h*(1-o),l=i*o+p*(1-o);}let c=d=>d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4);return .2126*c(s)+.7152*c(a)+.0722*c(l)>=.4?"#000000":"#ffffff"}function eL(r,e,t){let n=e.length;if(n===0||!(t>0)||!Number.isFinite(r)||r<e[0])return null;let i=e[n-1];if(r>=i+t)return n-1+Math.floor((r-i)/t);let o=0,s=n-1;for(;o<s;){let a=o+s+1>>1;e[a]<=r?o=a:s=a-1;}return r<e[o]+t?o:o+1}function tL(r,e,t,n){let i=new Map;r.forEach((s,a)=>{if(s.group!==void 0&&n(s.group))return;let l=eL(s.time,e,t);if(l===null)return;let c=`${l}|${s.group??""}`,u=i.get(c);u||(u={key:c,bar:l,group:s.group,marks:[],seq:[]},i.set(c,u)),u.marks.push(s),u.seq.push(a);});let o=[];for(let s of i.values()){let a=s.marks.map((l,c)=>({m:l,seq:s.seq[c]})).sort((l,c)=>l.m.time-c.m.time||l.seq-c.seq);o.push({key:s.key,bar:s.bar,group:s.group,marks:a.map(l=>l.m)});}return o}function nL(r,e){let t=new Map;r.forEach((n,i)=>t.set(n.id,i));for(let n of e)n.group!==void 0&&!t.has(n.group)&&t.set(n.group,t.size);return n=>n===void 0?Number.MAX_SAFE_INTEGER:t.get(n)??Number.MAX_SAFE_INTEGER-1}function iw(r){let e=tL(r.marks,r.barTimes,r.intervalMs,r.hidden),t=nL(r.groups,e),n=new Map;for(let s of e){let a=n.get(s.bar);a?a.push(s):n.set(s.bar,[s]);}let i=[],o=new Map;for(let[s,a]of n){let l=r.xOf(s);if(!Number.isFinite(l)||l<-20||l>r.dataW+20)continue;a.sort((f,g)=>t(f.group)-t(g.group));let c=a.length>1,u=c&&r.expanded===s,d=c&&!u,h=[],p=a[0].marks.length>1?20:16,m=r.axisY-4;a.forEach((f,g)=>{let b=d?p:f.marks.length>1?20:16,y;u?(y=m-b/2,m-=b+4):y=r.axisY-4-b/2-g*3,h.push({cluster:f,x:l,y,size:b,stack:s,depth:g,decked:d});});for(let f=h.length-1;f>=0;f--)i.push(h[f]);o.set(s,h);}return {glyphs:i,stacks:o}}function ow(r,e,t){for(let n=r.glyphs.length-1;n>=0;n--){let i=r.glyphs[n];if(i.decked&&i.depth!==0)continue;let o=i.size/2+3;if(Math.abs(e-i.x)<=o&&Math.abs(t-i.y)<=o)return i}return null}function sw(r,e,t){for(let[n,i]of r.stacks){for(let o of i){let s=o.size/2+3;if(Math.abs(e-o.x)<=s&&Math.abs(t-o.y)<=s)return n}if(i.length>1&&!i[0].decked){let o=i[i.length-1],s=i[0],a=Math.max(o.size,s.size)/2+3;if(Math.abs(e-s.x)<=a&&t>=o.y-o.size/2-8&&t<=s.y+s.size/2+3)return n}}return null}function aw(r,e){let t=r.marks[0];return t?r.marks.length===1?t.tooltip??t.title??null:`${r.group!==void 0?lw(r.group,e):t.title??t.tooltip??"Marks"} \xB7 ${r.marks.length}`:null}function lw(r,e){let t=e.find(n=>n.id===r);return t?t.label:r.charAt(0).toUpperCase()+r.slice(1)}function cw(r,e){let t=e.map(i=>({...i})),n=new Set(t.map(i=>i.id));for(let i of r)i.group===void 0||n.has(i.group)||(n.add(i.group),t.push({id:i.group,label:lw(i.group,e)}));return t}var Rc=360,rL=.1,iL="#ffffff";function oL(r){return !(r>0)||r>=Rc?1:1+rL*Math.sin(Math.PI*r/Rc)}function uw(r,e,t){if(e.glyphs.length!==0){r.save(),r.setLineDash([]),r.textAlign="center",r.textBaseline="middle";for(let n of e.glyphs){let i=n.cluster.marks[0];if(!i)continue;let o=n.cluster.key,s=i.glyph.color,a=o===t.activeKey||o===t.flashKey,l=n.size*(o===t.hoverKey?oL(t.nowMs-t.hoverSince):1);if(n.depth===0){let p=Math.round(n.x)+.5;r.lineWidth=1,r.strokeStyle=t.stemColor,r.beginPath(),r.moveTo(p,n.y+n.size/2),r.lineTo(p,t.axisY),r.stroke();}let c=i.glyph.shape??"circle",u=sL(r,c,n.x,n.y,l);r.lineWidth=4,r.strokeStyle=t.background,r.stroke(),r.fillStyle=a?s:t.background,r.fill(),r.lineWidth=1.5,r.strokeStyle=s,r.stroke();let d=a?iL:s,h=Math.round(l*.62);if(i.glyph.icon){let p=t.icons.get(i.glyph.icon,d,h,t.dpr);p&&r.drawImage(p,u.x-h/2,u.y-h/2,h,h);}else i.glyph.letter&&(r.fillStyle=d,r.font=`600 ${Math.round(l*.58)}px ${t.fontFamily}`,r.fillText(i.glyph.letter.slice(0,2),u.x,u.y+.5));}r.restore();}}function sL(r,e,t,n,i){let o=i/2;switch(r.beginPath(),e){case "square":{let s=Math.min(3,o/2);return aL(r,t-o,n-o,i,i,s),{x:t,y:n}}case "diamond":return r.moveTo(t,n-o),r.lineTo(t+o,n),r.lineTo(t,n+o),r.lineTo(t-o,n),r.closePath(),{x:t,y:n};case "pin":{let s=o*.82,a=n-o+s;return r.arc(t,a,s,Math.PI*.75,Math.PI*.25,false),r.lineTo(t,n+o),r.closePath(),{x:t,y:a}}default:return r.arc(t,n,o,0,Math.PI*2),{x:t,y:n}}}function aL(r,e,t,n,i,o){r.moveTo(e+o,t),r.lineTo(e+n-o,t),r.quadraticCurveTo(e+n,t,e+n,t+o),r.lineTo(e+n,t+i-o),r.quadraticCurveTo(e+n,t+i,e+n-o,t+i),r.lineTo(e+o,t+i),r.quadraticCurveTo(e,t+i,e,t+i-o),r.lineTo(e,t+o),r.quadraticCurveTo(e,t,e+o,t),r.closePath();}var Dc=class{constructor(e){this.onReady=e;this.cache=new Map;}get(e,t,n,i){let o=`${e}|${t}|${n}|${i}`;if(this.cache.has(o)){let c=this.cache.get(o);return c&&c.complete&&c.naturalWidth>0?c:null}let s=$r(e);if(!s||typeof document>"u"||typeof Image>"u"||typeof XMLSerializer>"u")return this.cache.set(o,null),null;let a=lL(s,t,Math.max(1,Math.ceil(n*i)));if(!a)return this.cache.set(o,null),null;let l=new Image;return l.onload=()=>this.onReady(),l.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,this.cache.set(o,l),null}clear(){this.cache.clear();}};function lL(r,e,t){let n=document.createElement("template");n.innerHTML=r;let i=n.content.firstElementChild;return !i||i.tagName.toLowerCase()!=="svg"?null:(i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width",String(t)),i.setAttribute("height",String(t)),i.setAttribute("color",e),new XMLSerializer().serializeToString(i))}var Oc=class{constructor(){this.canvas=null;this.ctx=null;this.axisTextColor=Ut.textColor;this.drawScene=new Oi({timeToLogical:()=>0,barAt:()=>null,theme:{}});this.markLayout={glyphs:[],stacks:new Map};this.markIcons=new Dc(()=>this.onMarkIconReady?.());this.onMarkIconReady=null;this.barTimesSrc=null;this.barTimesCache=[];}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}setMarkIconReady(e){this.onMarkIconReady=e;}markGlyphAt(e,t){return ow(this.markLayout,e,t)}markStackAt(e,t){return sw(this.markLayout,e,t)}markGlyphByKey(e){return this.markLayout.glyphs.find(t=>t.cluster.key===e)??null}markTooltipAt(e,t,n){let i=this.markGlyphAt(e,t);return i?aw(i.cluster,n):null}prepare(e,t,n){this.drawScene.setDeps({timeToLogical:i=>t.timeToLogical(i),barAt:i=>{let o=e.bars[Math.round(i)];return o?{high:o.high,low:o.low}:null},theme:n});}paneDrawingsRange(e,t,n,i){let o=null;for(let s of e)o=dw(o,this.drawingsRange(Ni(s,false),i,t.offsetOf(s.id)));if(n)for(let s of t.indicators.values())o=dw(o,this.drawingsRange(Ni(s,true),i,t.offsetOf(s.id)));return o}render(e,t,n,i){let o=this.ctx,s=this.canvas;if(!o||!s)return;let a=t.dpr,l=s.width/a,c=s.height/a,u=t.width,d=t.height;this.axisTextColor=i?.textColor??n.textColor,o.setTransform(a,0,0,a,0,0),o.clearRect(0,0,l,c),i&&(l>u||c>d)&&(o.fillStyle=i.background,l>u&&o.fillRect(u,0,l-u,c),c>d&&o.fillRect(0,d,u,c-d)),o.font=`${e.style.fontSize}px ${n.fontFamily}`,o.textBaseline="middle";let h=e.orderedPanes();if(t.barCount===0){this.drawPaneSeparators(o,e,n,l,h),this.markLayout={glyphs:[],stacks:new Map};return}let p=h.find(m=>m.kind==="price")??null;if(p&&!p.collapsed&&e.tradeMarkers.visible)for(let m of e.indicators.values())m.trades?.length&&this.renderTrades(o,t,e,n,m.trades,p,u);this.drawPriceAxes(o,e,t,n,u,h),this.drawMergedScaleColumns(o,e,t,u),this.drawPaneSeparators(o,e,n,l,h),this.drawPriceLineAndCountdown(o,e,t,n,u,p),this.drawTimeAxis(o,e,t,n,u,d,c),this.drawMarkLane(o,e,t,n,u,d);}drawMarkLane(e,t,n,i,o,s){if(!t.marks.visible||t.timelineMarks.length===0){this.markLayout={glyphs:[],stacks:new Map};return}this.markLayout=iw({marks:t.timelineMarks,groups:t.markGroups,hidden:l=>!Tc(t.marks,l,t.markGroups),barTimes:this.barTimes(t),intervalMs:n.barInterval,xOf:l=>n.logicalToX(l),axisY:s,dataW:o,expanded:t.marksExpandedStack});let a=typeof performance<"u"?performance.now():Date.now();uw(e,this.markLayout,{axisY:s,background:i.background,stemColor:t.style.borderColor??i.borderColor,fontFamily:i.fontFamily,dpr:n.dpr,icons:this.markIcons,hoverKey:t.marksHoverKey,hoverSince:t.marksHoverSince,activeKey:t.marksActiveKey,flashKey:t.marksFlash&&t.marksFlash.until>a?t.marksFlash.key:null,nowMs:a});}barTimes(e){return (this.barTimesSrc!==e.bars||this.barTimesCache.length!==e.bars.length)&&(this.barTimesSrc=e.bars,this.barTimesCache=e.bars.map(t=>t.time)),this.barTimesCache}destroy(){this.canvas=null,this.ctx=null;}drawingsRange(e,t,n=0){if(this.drawScene.setSet(e,n),this.drawScene.isEmpty())return null;let i=this.drawScene.priceRange(t.from,t.to);return i?{min:i.min,max:i.max}:null}renderTrades(e,t,n,i,o,s,a){e.save(),e.translate(0,s.bounds.top),e.beginPath(),e.rect(0,0,a,s.bounds.height),e.clip(),Wy(e,o,n.tradeMarkers,{timeToLogical:l=>t.timeToLogical(l),barAt:l=>{let c=n.bars[Math.round(l)];return c?{high:c.high,low:c.low}:null}},l=>t.logicalToX(l),l=>t.priceToY(l,s.scale,s.bounds)-s.bounds.top,{fontSize:n.style.fontSize,fontFamily:i.fontFamily,color:i.textColor},a,Math.max(1.5,t.bodySpacing()*.4)),e.restore();}drawPriceAxes(e,t,n,i,o,s){if(e.strokeStyle=t.style.borderColor??i.borderColor,e.lineWidth=1,e.beginPath(),e.moveTo(o+.5,0),e.lineTo(o+.5,n.height),e.stroke(),!!t.showAxisLabels){e.fillStyle=this.axisTextColor,e.textAlign="left";for(let a of s){if(a.collapsed)continue;let l=Tn(t,a);for(let c of fs(a.scale,a.bounds.height,l,t.priceMintick,a.axisFormat)){let u=n.priceToY(c.price,a.scale,a.bounds);u<a.bounds.top+6||u>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,u);}if(a.axisBands)for(let c of a.axisBands){let u=a.bounds.top+c.frac*a.bounds.height;u<a.bounds.top+6||u>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,u);}}e.textAlign="start";}}drawPaneSeparators(e,t,n,i,o){e.fillStyle=t.style.separatorColor??n.borderColor;for(let s of o)s.order<=0||e.fillRect(0,Math.round(s.bounds.top)-1,i,3);}drawMergedScaleColumns(e,t,n,i){if(t.showAxisLabels){e.textAlign="left",e.fillStyle=this.axisTextColor;for(let o of t.orderedPanes()){if(o.collapsed)continue;t.ownScaleIndicatorsForPane(o.id).forEach((a,l)=>{let c=t.indicatorScales.get(a.id)?.scale;if(!c)return;let u=cy(i,l+1);for(let d of fs(c,o.bounds.height,void 0,t.priceMintick)){let h=n.priceToY(d.price,c,o.bounds);h<o.bounds.top+6||h>o.bounds.top+o.bounds.height-4||e.fillText(d.label,u+5,h);}});}e.textAlign="start";}}drawPriceLineAndCountdown(e,t,n,i,o,s){let a=t.bars.length;if(!s||a===0||t.candlesHidden||s.collapsed||s.bounds.height<=0)return;let l=t.bars[a-1],c=n.priceToY(l.close,s.scale,s.bounds);if(c<s.bounds.top||c>s.bounds.top+s.bounds.height)return;let u=this.priceElementColor(t,n,i,l);if(t.showPriceLine){let S=Math.round(c)+.5;e.strokeStyle=u,e.lineWidth=1,hw(e,"dotted"),e.beginPath(),e.moveTo(0,S),e.lineTo(o,S),e.stroke(),hw(e,"solid");}let d=t.showCountdown?nw(l.time,n.barInterval,Date.now()):null,h=d!==null,p=t.showPriceLabel;if(!p&&!h)return;let m=gs(s.scale,s.bounds.height,l.close,Tn(t,s),t.priceMintick),f=8,g=o+1,b=rw(u,i.background);if(e.textBaseline="middle",p&&d!==null){let S=Math.max(e.measureText(m).width,e.measureText(d).width)+f,E=c-8,T=g+f/2;e.fillStyle=u,e.fillRect(g,E,S,32),e.fillStyle=b,e.textAlign="left",e.fillText(m,T,E+8),e.fillText(d,T,E+24),e.textAlign="start";return}let y=p?m:d??"",v=e.measureText(y).width+f;e.fillStyle=u,e.fillRect(g,c-8,v,16),e.fillStyle=b,e.textAlign="center",e.fillText(y,g+v/2,c),e.textAlign="start";}priceElementColor(e,t,n,i){let o=e.style;switch(e.priceStyle){case "bars":return i.close>=i.open?o.bars.upColor??n.upColor:o.bars.downColor??n.downColor;case "line":return o.line.color??n.upColor;case "area":return o.area.lineColor??n.upColor;case "baseline":{let s=Math.max(0,Math.floor(t.visibleLogicalRange().from)),a=e.baselineValue??e.bars[s]?.close??0;return i.close>=a?o.baseline.topLineColor??n.upColor:o.baseline.bottomLineColor??n.downColor}default:return i.close>=i.open?n.upColor:n.downColor}}drawTimeAxis(e,t,n,i,o,s,a){if(e.strokeStyle=t.style.borderColor??i.borderColor,e.lineWidth=1,e.beginPath(),e.moveTo(0,s+.5),e.lineTo(o,s+.5),e.stroke(),!t.showAxisLabels)return;e.fillStyle=this.axisTextColor,e.textAlign="center";let l=s+(a-s)/2,c=n.visibleTimeRange(),u=us((c.from+c.to)/2,t.timezone),d=Math.max(3,Math.min(8,Math.floor(o/64))),h=Ac(c.from,c.to,d,u).map(g=>({...g,x:n.timeToX(g.time),half:e.measureText(g.label).width/2})).filter(g=>g.x>=20&&g.x<=o-20),p=12,m=[],f=g=>{let b=g.x-g.half,y=g.x+g.half;m.every(v=>y+p<=v.l||b-p>=v.r)&&(m.push({l:b,r:y}),e.fillText(g.label,g.x,l));};for(let g of h)g.major&&f(g);for(let g of h)g.major||f(g);e.textAlign="start";}};function dw(r,e){return r?e?{min:Math.min(r.min,e.min),max:Math.max(r.max,e.max)}:r:e}function hw(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}var uL=350,Nc=class{constructor(e,t){this.plot=e;this.deps=t;this.tip=null;this.timer=null;this.current=null;this.onMove=e=>{if(e.pointerType!=="mouse")return;let t=this.plot.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top,o=this.deps.lookup(n,i);if(!o){this.clear();return}o!==this.current&&(this.clear(),this.current=o,this.timer=window.setTimeout(()=>this.show(o,n,i),uL));};this.onLeave=()=>{this.clear();};e.addEventListener("pointermove",this.onMove),e.addEventListener("pointerleave",this.onLeave),e.addEventListener("pointerdown",this.onLeave);}destroy(){this.plot.removeEventListener("pointermove",this.onMove),this.plot.removeEventListener("pointerleave",this.onLeave),this.plot.removeEventListener("pointerdown",this.onLeave),this.clear();}show(e,t,n){let o=this.plot.ownerDocument.createElement("div");o.textContent=e,o.style.cssText="position:absolute;z-index:var(--vela-z-tooltip);pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);max-width:260px;",Re(o,this.deps.theme()),this.plot.appendChild(o);let s=this.plot.clientWidth,a=this.plot.clientHeight;o.style.left=`${Math.max(0,Math.min(t+12,s-o.offsetWidth-4))}px`,o.style.top=`${Math.max(0,Math.min(n+16,a-o.offsetHeight-4))}px`,this.tip=o;}clear(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.tip?.remove(),this.tip=null,this.current=null;}};var Fc=class{constructor(){this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}render(e,t,n,i=null,o=null){let s=this.ctx,a=this.canvas;if(!s||!a)return;let l=t.dpr;s.setTransform(l,0,0,l,0,0),s.clearRect(0,0,a.width/l,a.height/l),i!==null&&this.drawSeparatorHover(s,a.width/l,n,i),o&&this.drawExternal(s,o,e,t,n);let c=e.crosshair,u=t.width,d=t.height;if(!c||c.x<0||c.x>u||c.y<0||c.y>d)return;let h=e.style.crosshair;s.font=`${e.style.fontSize}px ${n.fontFamily}`,s.textBaseline="middle";let p=Math.round(t.xToLogical(c.x)),m=Math.round(t.logicalToX(p))+.5;s.strokeStyle=h.color??n.textColor,s.lineWidth=h.width,s.globalAlpha=h.opacity,pw(s,h.style),s.beginPath(),s.moveTo(m,0),s.lineTo(m,d),s.moveTo(0,Math.round(c.y)+.5),s.lineTo(u,Math.round(c.y)+.5),s.stroke(),s.setLineDash([]),s.lineWidth=1,s.globalAlpha=1;let f;for(let b of e.panes.values())if(c.y>=b.bounds.top&&c.y<=b.bounds.top+b.bounds.height){f=b;break}let g=h.labelBackground??n.borderColor;if(f&&f.axisFormat!=="none"){let b=t.yToPrice(c.y,f.scale,f.bounds);this.chip(s,u+1,c.y,gs(f.scale,f.bounds.height,b,Tn(e,f),e.priceMintick,f.axisFormat),g,"left",false,n.background);}this.chip(s,m,d+1,Eh(t.logicalToTime(p),e.timezone,t.barInterval),g,"center",true,n.background);}destroy(){this.canvas=null,this.ctx=null;}drawExternal(e,t,n,i,o){let s=n.style.crosshair,a=i.width,l=i.height,c=Math.round(t.x)+.5;if(c<0||c>a)return;e.font=`${n.style.fontSize}px ${o.fontFamily}`,e.textBaseline="middle",e.strokeStyle=s.color??o.textColor,e.lineWidth=s.width,e.globalAlpha=s.opacity*.55,pw(e,s.style),e.beginPath(),e.moveTo(c,0),e.lineTo(c,l),t.y!=null&&(e.moveTo(0,Math.round(t.y)+.5),e.lineTo(a,Math.round(t.y)+.5)),e.stroke(),e.setLineDash([]),e.lineWidth=1,e.globalAlpha=.8;let u=s.labelBackground??o.borderColor;if(t.y!=null&&t.price!=null){let d;for(let h of n.panes.values())if(t.y>=h.bounds.top&&t.y<=h.bounds.top+h.bounds.height){d=h;break}d&&d.axisFormat!=="none"&&this.chip(e,a+1,t.y,gs(d.scale,d.bounds.height,t.price,Tn(n,d),n.priceMintick,d.axisFormat),u,"left",false,o.background);}this.chip(e,c,l+1,Eh(t.time,n.timezone,i.barInterval),u,"center",true,o.background),e.globalAlpha=1;}drawSeparatorHover(e,t,n,i){let o=Math.round(i);e.fillStyle=n.textColor,e.globalAlpha=.1,e.fillRect(0,o-4,t,8),e.globalAlpha=.55,e.fillRect(0,o-1,t,2),e.globalAlpha=1;}chip(e,t,n,i,o,s,a=false,l="#000000"){let c=e.measureText(i).width+8,u=16,d=s==="left"?t:t-c/2,h=a?n:n-u/2;e.fillStyle=o,e.fillRect(d,h,c,u),e.fillStyle=Cy(o,l),e.textAlign="center",e.fillText(i,d+c/2,h+u/2+(a?2:0)),e.textAlign="start";}};function pw(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}var Mh=[{value:"Etc/UTC",label:"UTC"},{value:"Etc/GMT+12",label:"International Date Line West"},{value:"Pacific/Pago_Pago",label:"Pago Pago"},{value:"Pacific/Honolulu",label:"Honolulu"},{value:"Pacific/Marquesas",label:"Marquesas Islands"},{value:"America/Anchorage",label:"Anchorage"},{value:"America/Los_Angeles",label:"Los Angeles"},{value:"America/Phoenix",label:"Phoenix"},{value:"America/Denver",label:"Denver"},{value:"America/Chicago",label:"Chicago"},{value:"America/Mexico_City",label:"Mexico City"},{value:"America/New_York",label:"New York"},{value:"America/Bogota",label:"Bogot\xE1"},{value:"America/Caracas",label:"Caracas"},{value:"America/Santiago",label:"Santiago"},{value:"America/St_Johns",label:"St. John's"},{value:"America/Sao_Paulo",label:"S\xE3o Paulo"},{value:"America/Argentina/Buenos_Aires",label:"Buenos Aires"},{value:"America/Noronha",label:"Fernando de Noronha"},{value:"Atlantic/Azores",label:"Azores"},{value:"Atlantic/Reykjavik",label:"Reykjavik"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris"},{value:"Europe/Berlin",label:"Berlin"},{value:"Europe/Athens",label:"Athens"},{value:"Africa/Cairo",label:"Cairo"},{value:"Africa/Johannesburg",label:"Johannesburg"},{value:"Europe/Moscow",label:"Moscow"},{value:"Europe/Istanbul",label:"Istanbul"},{value:"Asia/Tehran",label:"Tehran"},{value:"Asia/Dubai",label:"Dubai"},{value:"Asia/Kabul",label:"Kabul"},{value:"Asia/Karachi",label:"Karachi"},{value:"Asia/Kolkata",label:"Mumbai"},{value:"Asia/Kathmandu",label:"Kathmandu"},{value:"Asia/Dhaka",label:"Dhaka"},{value:"Asia/Yangon",label:"Yangon"},{value:"Asia/Bangkok",label:"Bangkok"},{value:"Asia/Shanghai",label:"Shanghai"},{value:"Asia/Hong_Kong",label:"Hong Kong"},{value:"Asia/Singapore",label:"Singapore"},{value:"Australia/Eucla",label:"Eucla"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Seoul",label:"Seoul"},{value:"Australia/Adelaide",label:"Adelaide"},{value:"Australia/Sydney",label:"Sydney"},{value:"Australia/Lord_Howe",label:"Lord Howe Island"},{value:"Pacific/Noumea",label:"Noum\xE9a"},{value:"Pacific/Auckland",label:"Auckland"},{value:"Pacific/Chatham",label:"Chatham Islands"},{value:"Pacific/Apia",label:"Apia"},{value:"Pacific/Kiritimati",label:"Kiritimati"}];function Vc(r){return r==="UTC"||r==="Etc/UTC"||r==="Etc/GMT"?"Etc/UTC":r}function dL(r,e=new Date){try{let i=(new Intl.DateTimeFormat("en-US",{timeZone:r,timeZoneName:"shortOffset"}).formatToParts(e).find(l=>l.type==="timeZoneName")?.value??"").match(/GMT(?:(\+|-)(\d{1,2})(?::(\d{2}))?)?/);if(!i||!i[1])return "UTC";let o=i[1]==="-"?"-":"+",s=i[2]??"0",a=i[3]??"";return a?`UTC${o}${s}:${a}`:`UTC${o}${s}`}catch{return "UTC"}}function Lh(r,e){return Vc(r)==="Etc/UTC"?e:`(${dL(r)}) ${e}`}function Xn(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var Ph="events",_c="events.groups";function Ih(r){return `${_c}.${Xn(r)}`}function yt(r,e){if(e.size===0)return false;let t=r;for(;;){if(e.has(t))return true;let n=t.lastIndexOf(".");if(n<0)return false;t=t.slice(0,n);}}function mw(r){if(r.kind==="heading"||r.kind==="header")return Xn(r.label);let e=qr(r);if(e.toggle)return e.toggle.key;for(let t of e.controls)if(t.kind!=="hint")return t.key;return Xn(e.label)}function Bc(r,e,t){if(t.size===0)return [...r];let n=[],i=false,o=false;for(let s of r){let a=`${e}.${mw(s)}`;if(s.kind==="heading"){i=yt(a,t),o=false,i||n.push(s);continue}if(s.kind==="header"){if(i)continue;o=yt(a,t),o||n.push(s);continue}i||o||yt(a,t)||n.push(s);}return n}function Ah(r){return r.id??Xn(r.title)}function fw(r){return r.id??Xn(r.label)}function gw(r,e,t){if(t.size===0)return [...r];let n=[],i=false;for(let o of r){let s=`${e}.${fw(o)}`;if(o.kind==="heading"){i=yt(s,t),i||n.push(o);continue}i||yt(s,t)||n.push(o);}return n}var hL=["symbol","symbol.type","symbol.style.candles","symbol.style.candles.body","symbol.style.candles.borders","symbol.style.candles.wick","symbol.style.candles.spacing","symbol.style.bars","symbol.style.bars.up-color","symbol.style.bars.down-color","symbol.style.bars.spacing","symbol.style.line","symbol.style.line.color","symbol.style.line.width","symbol.style.area","symbol.style.area.line-color","symbol.style.area.width","symbol.style.area.top-fill","symbol.style.area.bottom-fill","symbol.style.baseline","symbol.style.baseline.top-line","symbol.style.baseline.bottom-line","symbol.style.baseline.fill-top","symbol.style.baseline.fill-bottom","symbol.style.baseline.base-level","symbol.style.baseline.width","symbol.animation","symbol.animation.zoom","symbol.animation.pan","symbol.animation.autoscale","symbol.animation.price-changes","symbol.animation.intro","symbol.timezone","scales","scales.price-scale","scales.price-scale.mode","scales.price-scale.invert","scales.price-scale.last-price-line","scales.price-scale.last-price-label","scales.price-scale.countdown","scales.price-scale.axis-labels","scales.price-scale.border-color","scales.crosshair","scales.crosshair.color","scales.crosshair.width","scales.crosshair.style","canvas","canvas.background","canvas.background.color","canvas.background.text-color","canvas.background.text-size","canvas.background.pane-separator","canvas.grid","canvas.grid.vertical","canvas.grid.horizontal","canvas.theme"];function bw(r,e=[]){let t=new Set(hL);if(e.length>0){t.add(Ph),t.add(_c);for(let n of e)t.add(Ih(n.id));}for(let n of Mt()){if(ss(n.id)){let a=`symbol.style.${n.id}`;for(let l of ["",".body",".borders",".wick",".spacing"])t.add(a+l);}let i=n.settings;if(!i)continue;let o=`type:${n.id}`;t.add(o);let s=a=>{for(let l of a)t.add(`${o}.${mw(l)}`);};i.rows&&s(i.rows);for(let a of i.instances??[])s(a.rows);for(let a of i.subsections??[])t.add(`${o}.${Xn(a.title)}`),s(a.rows);}for(let n of r){let i=Ah(n);t.add(i);for(let o of n.rows)t.add(`${i}.${fw(o)}`);}return [...t]}var pL={candles:"Candles",bars:"Bars",line:"Line",area:"Area",baseline:"Baseline"};function mL(r){return hn(r)?.label??pL[r]??r}var vw="vela-settings-controls",yw="6";var fL="var(--vela-border)";function gL(){if(typeof document>"u")return;let r=document.getElementById(vw);if(r?.dataset.rev===yw)return;let e=r??document.createElement("style");e.id=vw,e.dataset.rev=yw,e.textContent=`
|
|
824
|
-
${
|
|
823
|
+
`),l=6,c=4,u=o*1.25,h=Math.max(1,...a.map(y=>this.measure(e,e.font,y)))+l*2,p=u*a.length+c*2,m=7,f=n-h/2,g=i-p-m,b="down";switch(t.style){case "label_up":f=n-h/2,g=i+m,b="up";break;case "label_left":f=n+m,g=i-p/2,b="left";break;case "label_right":f=n-h-m,g=i-p/2,b="right";break;case "label_center":f=n-h/2,g=i-p/2,b="none";break;case "label_lower_left":f=n+m,g=i-p-m,b="none";break;case "label_lower_right":f=n-h-m,g=i-p-m,b="none";break;case "label_upper_left":f=n+m,g=i+m,b="none";break;case "label_upper_right":f=n-h-m,g=i+m,b="none";break;default:f=n-h/2,g=i-p-m,b="down";}if(t.noFill||(e.fillStyle=s,this.roundRect(e,f,g,h,p,4),e.fill(),b!=="none"&&(e.beginPath(),b==="down"?(e.moveTo(n-m,g+p),e.lineTo(n+m,g+p),e.lineTo(n,i)):b==="up"?(e.moveTo(n-m,g),e.lineTo(n+m,g),e.lineTo(n,i)):b==="left"?(e.moveTo(f,i-m),e.lineTo(f,i+m),e.lineTo(n,i)):(e.moveTo(f+h,i-m),e.lineTo(f+h,i+m),e.lineTo(n,i)),e.closePath(),e.fill())),t.text){e.fillStyle=t.textColor??(t.noFill?this.deps.theme.textColor:_e(s)),e.textBaseline="middle";let y;t.textAlign==="left"?(e.textAlign="left",y=f+l):t.textAlign==="right"?(e.textAlign="right",y=f+h-l):(e.textAlign="center",y=f+h/2);let v=g+c+u/2;for(let S=0;S<a.length;S+=1)e.fillText(a[S],y,v+S*u);}return {x:f,y:g,w:h,h:p}}roundRect(e,t,n,i,o,s){let a=Math.min(s,i/2,o/2);e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+i,n,t+i,n+o,a),e.arcTo(t+i,n+o,t,n+o,a),e.arcTo(t,n+o,t,n,a),e.arcTo(t,n,t+i,n,a),e.closePath();}};function ds(r,e){if(!e||e==="UTC")return 0;try{let n=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(r)),i=s=>Number(n.find(a=>a.type===s)?.value);return Date.UTC(i("year"),i("month")-1,i("day"),i("hour")%24,i("minute"),i("second"))-r}catch{return 0}}function Pc(r,e){return new Date(r+ds(r,e))}function Rc(r,e,t=6){if(!(e>r)||!Number.isFinite(r)||!Number.isFinite(e))return [];let n=(e-r)/Math.max(1,t),i=Math.pow(10,Math.floor(Math.log10(n))),o=n/i,s=(o<1.5?1:o<3?2:o<7?5:10)*i,a=Math.max(0,-Math.floor(Math.log10(s))+1),l=[],c=Math.ceil(r/s)*s;for(let u=c;u<=e+s*1e-6;u+=s)l.push(Number(u.toFixed(a)));return l}function JL(r,e,t=6){if(!(e>r))return 2;let n=(e-r)/Math.max(1,t),i=Math.pow(10,Math.floor(Math.log10(n))),o=n/i,s=(o<1.5?1:o<3?2:o<7?5:10)*i;return Math.max(0,Math.min(8,-Math.floor(Math.log10(s))+1))}function QL(r,e,t=6){if(r<=0||!(e>r)||!Number.isFinite(r)||!Number.isFinite(e))return [];if(Math.log10(e)-Math.log10(r)<1.1)return Rc(r,e,t);let n=[],i=Math.floor(Math.log10(r)),o=Math.ceil(Math.log10(e));for(let s=i;s<=o;s+=1)for(let a of [1,2,5]){let l=a*Math.pow(10,s);l>=r&&l<=e&&n.push(l);}return n}function Mh(r){let e=Math.abs(r);return e>=100?0:e>=1?2:e>=.01?4:6}function eM(r){if(!(r>0)||!Number.isFinite(r))return 2;for(let e=0;e<=8;e+=1)if(Math.abs(Number(r.toFixed(e))-r)<=r*1e-6)return e;return 8}function tM(r,e,t){let n=t!=null&&t>0?eM(t):JL(r.min,r.max,fs(e));return n===0?2:n}function fs(r){return Math.max(2,Math.min(16,Math.round(r/50)))}function tw(r,e){return r.log?QL(r.min,r.max,fs(e)):Rc(r.min,r.max,fs(e))}function Eh(r,e){return (r/e-1)*100}function Lh(r,e){return r/e*100}function rw(r){return `${r>=0?"+":"-"}${Math.abs(r).toFixed(2)}%`}function iw(r){return r.toFixed(2)}function ow(r){let e=Math.abs(r);return e>=1e9?`${Ic(r/1e9)}B`:e>=1e6?`${Ic(r/1e6)}M`:e>=1e3?`${Ic(r/1e3)}K`:Ic(r)}function Ic(r){return Number(r.toFixed(2)).toString()}function gs(r,e,t,n,i){if(i==="none")return [];if(t){let{baseline:o,indexed:s}=t,a=Math.min(r.min,r.max),l=Math.max(r.min,r.max);if(s){let d=Lh(a,o),h=Lh(l,o);return Rc(d,h,fs(e)).map(p=>({price:o*p/100,label:iw(p)}))}let c=Eh(a,o),u=Eh(l,o);return Rc(c,u,fs(e)).map(d=>({price:o*(1+d/100),label:rw(d)}))}return i==="volume"?tw(r,e).map(o=>({price:o,label:ow(o)})):tw(r,e).map(o=>({price:o,label:Dc(r,e,o,n)}))}function bs(r,e,t,n,i,o){return o==="none"?"":n?n.indexed?iw(Lh(t,n.baseline)):rw(Eh(t,n.baseline)):o==="volume"?ow(t):Dc(r,e,t,i)}function Dc(r,e,t,n){if(r.log&&Math.log10(r.max)-Math.log10(r.min)>=1.1){let o=Mh(t);return t.toFixed(o===0?2:o)}return t.toFixed(tM(r,e,n))}var hs=1e3,ps=60*hs,Vi=60*ps,Vr=24*Vi,nM=7*Vr,nw=30*Vr,sw=365*Vr,kh=[hs,5*hs,15*hs,30*hs,ps,5*ps,15*ps,30*ps,Vi,2*Vi,4*Vi,6*Vi,12*Vi,Vr,2*Vr,nM,nw,3*nw,sw],Ac=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rM=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ms=r=>r<10?`0${r}`:String(r);function Ph(r,e,t){let n=Pc(r,e),i=`${rM[n.getUTCDay()]} ${n.getUTCDate()} ${Ac[n.getUTCMonth()]} '${ms(n.getUTCFullYear()%100)}`;return t>=Vr?i:`${i} ${ms(n.getUTCHours())}:${ms(n.getUTCMinutes())}`}function iM(r){for(let e of kh)if(e>=r)return e;return kh[kh.length-1]}function Oc(r,e,t=8,n=0){let i=e-r;if(!(i>0))return [];let o=iM(i/Math.max(1,t)),s=r+n,a=e+n,l=Math.ceil(s/o)*o,c=[];for(let u=l;u<=a;u+=o){let d=u-n,h=new Date(u),p,m=false;if(o<Vr){let f=h.getUTCHours(),g=h.getUTCMinutes();f===0&&g===0?(p=`${Ac[h.getUTCMonth()]} ${h.getUTCDate()}`,m=true):p=`${ms(f)}:${ms(g)}`;}else o<sw?(p=`${Ac[h.getUTCMonth()]} ${h.getUTCDate()}`,h.getUTCDate()===1&&(p=Ac[h.getUTCMonth()],m=true)):(p=String(h.getUTCFullYear()),m=true);c.push({time:d,label:p,major:m});}return c}function aw(r,e,t){if(!(e>0))return null;let n=r+e-t;return n<=0?null:oM(n)}function oM(r){let e=Math.max(0,Math.ceil(r/1e3)),t=e%60,n=Math.floor(e/60)%60,i=Math.floor(e/3600),o=s=>String(s).padStart(2,"0");return i>0?`${i}:${o(n)}:${o(t)}`:`${o(n)}:${o(t)}`}function lw(r,e){let[t,n,i,o]=te(r),s=t,a=n,l=i;if(o<1){let[d,h,p]=te(e);s=t*o+d*(1-o),a=n*o+h*(1-o),l=i*o+p*(1-o);}let c=d=>d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4);return .2126*c(s)+.7152*c(a)+.0722*c(l)>=.4?"#000000":"#ffffff"}function sM(r,e,t){let n=e.length;if(n===0||!(t>0)||!Number.isFinite(r)||r<e[0])return null;let i=e[n-1];if(r>=i+t)return n-1+Math.floor((r-i)/t);let o=0,s=n-1;for(;o<s;){let a=o+s+1>>1;e[a]<=r?o=a:s=a-1;}return r<e[o]+t?o:o+1}function aM(r,e,t,n){let i=new Map;r.forEach((s,a)=>{if(s.group!==void 0&&n(s.group))return;let l=sM(s.time,e,t);if(l===null)return;let c=`${l}|${s.group??""}`,u=i.get(c);u||(u={key:c,bar:l,group:s.group,marks:[],seq:[]},i.set(c,u)),u.marks.push(s),u.seq.push(a);});let o=[];for(let s of i.values()){let a=s.marks.map((l,c)=>({m:l,seq:s.seq[c]})).sort((l,c)=>l.m.time-c.m.time||l.seq-c.seq);o.push({key:s.key,bar:s.bar,group:s.group,marks:a.map(l=>l.m)});}return o}function lM(r,e){let t=new Map;r.forEach((n,i)=>t.set(n.id,i));for(let n of e)n.group!==void 0&&!t.has(n.group)&&t.set(n.group,t.size);return n=>n===void 0?Number.MAX_SAFE_INTEGER:t.get(n)??Number.MAX_SAFE_INTEGER-1}function cw(r){let e=aM(r.marks,r.barTimes,r.intervalMs,r.hidden),t=lM(r.groups,e),n=new Map;for(let s of e){let a=n.get(s.bar);a?a.push(s):n.set(s.bar,[s]);}let i=[],o=new Map;for(let[s,a]of n){let l=r.xOf(s);if(!Number.isFinite(l)||l<-20||l>r.dataW+20)continue;a.sort((f,g)=>t(f.group)-t(g.group));let c=a.length>1,u=c&&r.expanded===s,d=c&&!u,h=[],p=a[0].marks.length>1?20:16,m=r.axisY-4;a.forEach((f,g)=>{let b=d?p:f.marks.length>1?20:16,y;u?(y=m-b/2,m-=b+4):y=r.axisY-4-b/2-g*3,h.push({cluster:f,x:l,y,size:b,stack:s,depth:g,decked:d});});for(let f=h.length-1;f>=0;f--)i.push(h[f]);o.set(s,h);}return {glyphs:i,stacks:o}}function uw(r,e,t){for(let n=r.glyphs.length-1;n>=0;n--){let i=r.glyphs[n];if(i.decked&&i.depth!==0)continue;let o=i.size/2+3;if(Math.abs(e-i.x)<=o&&Math.abs(t-i.y)<=o)return i}return null}function dw(r,e,t){for(let[n,i]of r.stacks){for(let o of i){let s=o.size/2+3;if(Math.abs(e-o.x)<=s&&Math.abs(t-o.y)<=s)return n}if(i.length>1&&!i[0].decked){let o=i[i.length-1],s=i[0],a=Math.max(o.size,s.size)/2+3;if(Math.abs(e-s.x)<=a&&t>=o.y-o.size/2-8&&t<=s.y+s.size/2+3)return n}}return null}function hw(r,e){let t=r.marks[0];return t?r.marks.length===1?t.tooltip??t.title??null:`${r.group!==void 0?pw(r.group,e):t.title??t.tooltip??"Marks"} \xB7 ${r.marks.length}`:null}function pw(r,e){let t=e.find(n=>n.id===r);return t?t.label:r.charAt(0).toUpperCase()+r.slice(1)}function mw(r,e){let t=e.map(i=>({...i})),n=new Set(t.map(i=>i.id));for(let i of r)i.group===void 0||n.has(i.group)||(n.add(i.group),t.push({id:i.group,label:pw(i.group,e)}));return t}var Nc=360,cM=.1,uM="#ffffff";function dM(r){return !(r>0)||r>=Nc?1:1+cM*Math.sin(Math.PI*r/Nc)}function fw(r,e,t){if(e.glyphs.length!==0){r.save(),r.setLineDash([]),r.textAlign="center",r.textBaseline="middle";for(let n of e.glyphs){let i=n.cluster.marks[0];if(!i)continue;let o=n.cluster.key,s=i.glyph.color,a=o===t.activeKey||o===t.flashKey,l=n.size*(o===t.hoverKey?dM(t.nowMs-t.hoverSince):1);if(n.depth===0){let p=Math.round(n.x)+.5;r.lineWidth=1,r.strokeStyle=t.stemColor,r.beginPath(),r.moveTo(p,n.y+n.size/2),r.lineTo(p,t.axisY),r.stroke();}let c=i.glyph.shape??"circle",u=hM(r,c,n.x,n.y,l);r.lineWidth=4,r.strokeStyle=t.background,r.stroke(),r.fillStyle=a?s:t.background,r.fill(),r.lineWidth=1.5,r.strokeStyle=s,r.stroke();let d=a?uM:s,h=Math.round(l*.62);if(i.glyph.icon){let p=t.icons.get(i.glyph.icon,d,h,t.dpr);p&&r.drawImage(p,u.x-h/2,u.y-h/2,h,h);}else i.glyph.letter&&(r.fillStyle=d,r.font=`600 ${Math.round(l*.58)}px ${t.fontFamily}`,r.fillText(i.glyph.letter.slice(0,2),u.x,u.y+.5));}r.restore();}}function hM(r,e,t,n,i){let o=i/2;switch(r.beginPath(),e){case "square":{let s=Math.min(3,o/2);return pM(r,t-o,n-o,i,i,s),{x:t,y:n}}case "diamond":return r.moveTo(t,n-o),r.lineTo(t+o,n),r.lineTo(t,n+o),r.lineTo(t-o,n),r.closePath(),{x:t,y:n};case "pin":{let s=o*.82,a=n-o+s;return r.arc(t,a,s,Math.PI*.75,Math.PI*.25,false),r.lineTo(t,n+o),r.closePath(),{x:t,y:a}}default:return r.arc(t,n,o,0,Math.PI*2),{x:t,y:n}}}function pM(r,e,t,n,i,o){r.moveTo(e+o,t),r.lineTo(e+n-o,t),r.quadraticCurveTo(e+n,t,e+n,t+o),r.lineTo(e+n,t+i-o),r.quadraticCurveTo(e+n,t+i,e+n-o,t+i),r.lineTo(e+o,t+i),r.quadraticCurveTo(e,t+i,e,t+i-o),r.lineTo(e,t+o),r.quadraticCurveTo(e,t,e+o,t),r.closePath();}var Fc=class{constructor(e){this.onReady=e;this.cache=new Map;}get(e,t,n,i){let o=`${e}|${t}|${n}|${i}`;if(this.cache.has(o)){let c=this.cache.get(o);return c&&c.complete&&c.naturalWidth>0?c:null}let s=Wr(e);if(!s||typeof document>"u"||typeof Image>"u"||typeof XMLSerializer>"u")return this.cache.set(o,null),null;let a=mM(s,t,Math.max(1,Math.ceil(n*i)));if(!a)return this.cache.set(o,null),null;let l=new Image;return l.onload=()=>this.onReady(),l.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,this.cache.set(o,l),null}clear(){this.cache.clear();}};function mM(r,e,t){let n=document.createElement("template");n.innerHTML=r;let i=n.content.firstElementChild;return !i||i.tagName.toLowerCase()!=="svg"?null:(i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width",String(t)),i.setAttribute("height",String(t)),i.setAttribute("color",e),new XMLSerializer().serializeToString(i))}var Vc=class{constructor(){this.canvas=null;this.ctx=null;this.axisTextColor=Yt.textColor;this.drawScene=new Ni({timeToLogical:()=>0,barAt:()=>null,theme:{}});this.markLayout={glyphs:[],stacks:new Map};this.markIcons=new Fc(()=>this.onMarkIconReady?.());this.onMarkIconReady=null;this.barTimesSrc=null;this.barTimesCache=[];}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}setMarkIconReady(e){this.onMarkIconReady=e;}markGlyphAt(e,t){return uw(this.markLayout,e,t)}markStackAt(e,t){return dw(this.markLayout,e,t)}markGlyphByKey(e){return this.markLayout.glyphs.find(t=>t.cluster.key===e)??null}markTooltipAt(e,t,n){let i=this.markGlyphAt(e,t);return i?hw(i.cluster,n):null}prepare(e,t,n){this.drawScene.setDeps({timeToLogical:i=>t.timeToLogical(i),barAt:i=>{let o=e.bars[Math.round(i)];return o?{high:o.high,low:o.low}:null},theme:n});}paneDrawingsRange(e,t,n,i){let o=null;for(let s of e)o=gw(o,this.drawingsRange(Fi(s,false),i,t.offsetOf(s.id)));if(n)for(let s of t.indicators.values())o=gw(o,this.drawingsRange(Fi(s,true),i,t.offsetOf(s.id)));return o}render(e,t,n,i){let o=this.ctx,s=this.canvas;if(!o||!s)return;let a=t.dpr,l=s.width/a,c=s.height/a,u=t.width,d=t.height;this.axisTextColor=i?.textColor??n.textColor,o.setTransform(a,0,0,a,0,0),o.clearRect(0,0,l,c),i&&(l>u||c>d)&&(o.fillStyle=i.background,l>u&&o.fillRect(u,0,l-u,c),c>d&&o.fillRect(0,d,u,c-d)),o.font=`${e.style.fontSize}px ${n.fontFamily}`,o.textBaseline="middle";let h=e.orderedPanes();if(t.barCount===0){this.drawPaneSeparators(o,e,n,l,h),this.markLayout={glyphs:[],stacks:new Map};return}let p=h.find(m=>m.kind==="price")??null;if(p&&!p.collapsed&&e.tradeMarkers.visible)for(let m of e.indicators.values())m.trades?.length&&this.renderTrades(o,t,e,n,m.trades,p,u);this.drawPriceAxes(o,e,t,n,u,h),this.drawMergedScaleColumns(o,e,t,u),this.drawPaneSeparators(o,e,n,l,h),this.drawPriceLineAndCountdown(o,e,t,n,u,p),this.drawTimeAxis(o,e,t,n,u,d,c),this.drawMarkLane(o,e,t,n,u,d);}drawMarkLane(e,t,n,i,o,s){if(!t.marks.visible||t.timelineMarks.length===0){this.markLayout={glyphs:[],stacks:new Map};return}this.markLayout=cw({marks:t.timelineMarks,groups:t.markGroups,hidden:l=>!Lc(t.marks,l,t.markGroups),barTimes:this.barTimes(t),intervalMs:n.barInterval,xOf:l=>n.logicalToX(l),axisY:s,dataW:o,expanded:t.marksExpandedStack});let a=typeof performance<"u"?performance.now():Date.now();fw(e,this.markLayout,{axisY:s,background:i.background,stemColor:t.style.borderColor??i.borderColor,fontFamily:i.fontFamily,dpr:n.dpr,icons:this.markIcons,hoverKey:t.marksHoverKey,hoverSince:t.marksHoverSince,activeKey:t.marksActiveKey,flashKey:t.marksFlash&&t.marksFlash.until>a?t.marksFlash.key:null,nowMs:a});}barTimes(e){return (this.barTimesSrc!==e.bars||this.barTimesCache.length!==e.bars.length)&&(this.barTimesSrc=e.bars,this.barTimesCache=e.bars.map(t=>t.time)),this.barTimesCache}destroy(){this.canvas=null,this.ctx=null;}drawingsRange(e,t,n=0){if(this.drawScene.setSet(e,n),this.drawScene.isEmpty())return null;let i=this.drawScene.priceRange(t.from,t.to);return i?{min:i.min,max:i.max}:null}renderTrades(e,t,n,i,o,s,a){e.save(),e.translate(0,s.bounds.top),e.beginPath(),e.rect(0,0,a,s.bounds.height),e.clip(),Xy(e,o,n.tradeMarkers,{timeToLogical:l=>t.timeToLogical(l),barAt:l=>{let c=n.bars[Math.round(l)];return c?{high:c.high,low:c.low}:null}},l=>t.logicalToX(l),l=>t.priceToY(l,s.scale,s.bounds)-s.bounds.top,{fontSize:n.style.fontSize,fontFamily:i.fontFamily,color:i.textColor},a,Math.max(1.5,t.bodySpacing()*.4)),e.restore();}drawPriceAxes(e,t,n,i,o,s){if(e.strokeStyle=t.style.borderColor??i.borderColor,e.lineWidth=1,e.beginPath(),e.moveTo(o+.5,0),e.lineTo(o+.5,n.height),e.stroke(),!!t.showAxisLabels){e.fillStyle=this.axisTextColor,e.textAlign="left";for(let a of s){if(a.collapsed)continue;let l=kn(t,a);for(let c of gs(a.scale,a.bounds.height,l,t.priceMintick,a.axisFormat)){let u=n.priceToY(c.price,a.scale,a.bounds);u<a.bounds.top+6||u>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,u);}if(a.axisBands)for(let c of a.axisBands){let u=a.bounds.top+c.frac*a.bounds.height;u<a.bounds.top+6||u>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,u);}}e.textAlign="start";}}drawPaneSeparators(e,t,n,i,o){e.fillStyle=t.style.separatorColor??n.borderColor;for(let s of o)s.order<=0||e.fillRect(0,Math.round(s.bounds.top)-1,i,3);}drawMergedScaleColumns(e,t,n,i){if(t.showAxisLabels){e.textAlign="left",e.fillStyle=this.axisTextColor;for(let o of t.orderedPanes()){if(o.collapsed)continue;t.ownScaleIndicatorsForPane(o.id).forEach((a,l)=>{let c=t.indicatorScales.get(a.id)?.scale;if(!c)return;let u=my(i,l+1);for(let d of gs(c,o.bounds.height,void 0,t.priceMintick)){let h=n.priceToY(d.price,c,o.bounds);h<o.bounds.top+6||h>o.bounds.top+o.bounds.height-4||e.fillText(d.label,u+5,h);}});}e.textAlign="start";}}drawPriceLineAndCountdown(e,t,n,i,o,s){let a=t.bars.length;if(!s||a===0||t.candlesHidden||s.collapsed||s.bounds.height<=0)return;let l=t.bars[a-1],c=n.priceToY(l.close,s.scale,s.bounds);if(c<s.bounds.top||c>s.bounds.top+s.bounds.height)return;let u=this.priceElementColor(t,n,i,l);if(t.showPriceLine){let S=Math.round(c)+.5;e.strokeStyle=u,e.lineWidth=1,bw(e,"dotted"),e.beginPath(),e.moveTo(0,S),e.lineTo(o,S),e.stroke(),bw(e,"solid");}let d=t.showCountdown?aw(l.time,n.barInterval,Date.now()):null,h=d!==null,p=t.showPriceLabel;if(!p&&!h)return;let m=bs(s.scale,s.bounds.height,l.close,kn(t,s),t.priceMintick),f=8,g=o+1,b=lw(u,i.background);if(e.textBaseline="middle",p&&d!==null){let S=Math.max(e.measureText(m).width,e.measureText(d).width)+f,E=c-8,T=g+f/2;e.fillStyle=u,e.fillRect(g,E,S,32),e.fillStyle=b,e.textAlign="left",e.fillText(m,T,E+8),e.fillText(d,T,E+24),e.textAlign="start";return}let y=p?m:d??"",v=e.measureText(y).width+f;e.fillStyle=u,e.fillRect(g,c-8,v,16),e.fillStyle=b,e.textAlign="center",e.fillText(y,g+v/2,c),e.textAlign="start";}priceElementColor(e,t,n,i){let o=e.style;switch(e.priceStyle){case "bars":return i.close>=i.open?o.bars.upColor??n.upColor:o.bars.downColor??n.downColor;case "line":return o.line.color??n.upColor;case "area":return o.area.lineColor??n.upColor;case "baseline":{let s=Math.max(0,Math.floor(t.visibleLogicalRange().from)),a=e.baselineValue??e.bars[s]?.close??0;return i.close>=a?o.baseline.topLineColor??n.upColor:o.baseline.bottomLineColor??n.downColor}default:return i.close>=i.open?n.upColor:n.downColor}}drawTimeAxis(e,t,n,i,o,s,a){if(e.strokeStyle=t.style.borderColor??i.borderColor,e.lineWidth=1,e.beginPath(),e.moveTo(0,s+.5),e.lineTo(o,s+.5),e.stroke(),!t.showAxisLabels)return;e.fillStyle=this.axisTextColor,e.textAlign="center";let l=s+(a-s)/2,c=n.visibleTimeRange(),u=ds((c.from+c.to)/2,t.timezone),d=Math.max(3,Math.min(8,Math.floor(o/64))),h=Oc(c.from,c.to,d,u).map(g=>({...g,x:n.timeToX(g.time),half:e.measureText(g.label).width/2})).filter(g=>g.x>=20&&g.x<=o-20),p=12,m=[],f=g=>{let b=g.x-g.half,y=g.x+g.half;m.every(v=>y+p<=v.l||b-p>=v.r)&&(m.push({l:b,r:y}),e.fillText(g.label,g.x,l));};for(let g of h)g.major&&f(g);for(let g of h)g.major||f(g);e.textAlign="start";}};function gw(r,e){return r?e?{min:Math.min(r.min,e.min),max:Math.max(r.max,e.max)}:r:e}function bw(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}var gM=350,_c=class{constructor(e,t){this.plot=e;this.deps=t;this.tip=null;this.timer=null;this.current=null;this.onMove=e=>{if(e.pointerType!=="mouse")return;let t=this.plot.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top,o=this.deps.lookup(n,i);if(!o){this.clear();return}o!==this.current&&(this.clear(),this.current=o,this.timer=window.setTimeout(()=>this.show(o,n,i),gM));};this.onLeave=()=>{this.clear();};e.addEventListener("pointermove",this.onMove),e.addEventListener("pointerleave",this.onLeave),e.addEventListener("pointerdown",this.onLeave);}destroy(){this.plot.removeEventListener("pointermove",this.onMove),this.plot.removeEventListener("pointerleave",this.onLeave),this.plot.removeEventListener("pointerdown",this.onLeave),this.clear();}show(e,t,n){let o=this.plot.ownerDocument.createElement("div");o.textContent=e,o.style.cssText="position:absolute;z-index:var(--vela-z-tooltip);pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);max-width:260px;",Re(o,this.deps.theme()),this.plot.appendChild(o);let s=this.plot.clientWidth,a=this.plot.clientHeight;o.style.left=`${Math.max(0,Math.min(t+12,s-o.offsetWidth-4))}px`,o.style.top=`${Math.max(0,Math.min(n+16,a-o.offsetHeight-4))}px`,this.tip=o;}clear(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.tip?.remove(),this.tip=null,this.current=null;}};var Bc=class{constructor(){this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}render(e,t,n,i=null,o=null){let s=this.ctx,a=this.canvas;if(!s||!a)return;let l=t.dpr;s.setTransform(l,0,0,l,0,0),s.clearRect(0,0,a.width/l,a.height/l),i!==null&&this.drawSeparatorHover(s,a.width/l,n,i),o&&this.drawExternal(s,o,e,t,n);let c=e.crosshair,u=t.width,d=t.height;if(!c||c.x<0||c.x>u||c.y<0||c.y>d)return;let h=e.style.crosshair;s.font=`${e.style.fontSize}px ${n.fontFamily}`,s.textBaseline="middle";let p=Math.round(t.xToLogical(c.x)),m=Math.round(t.logicalToX(p))+.5;s.strokeStyle=h.color??n.textColor,s.lineWidth=h.width,s.globalAlpha=h.opacity,vw(s,h.style),s.beginPath(),s.moveTo(m,0),s.lineTo(m,d),s.moveTo(0,Math.round(c.y)+.5),s.lineTo(u,Math.round(c.y)+.5),s.stroke(),s.setLineDash([]),s.lineWidth=1,s.globalAlpha=1;let f;for(let b of e.panes.values())if(c.y>=b.bounds.top&&c.y<=b.bounds.top+b.bounds.height){f=b;break}let g=h.labelBackground??n.borderColor;if(f&&f.axisFormat!=="none"){let b=t.yToPrice(c.y,f.scale,f.bounds);this.chip(s,u+1,c.y,bs(f.scale,f.bounds.height,b,kn(e,f),e.priceMintick,f.axisFormat),g,"left",false,n.background);}this.chip(s,m,d+1,Ph(t.logicalToTime(p),e.timezone,t.barInterval),g,"center",true,n.background);}destroy(){this.canvas=null,this.ctx=null;}drawExternal(e,t,n,i,o){let s=n.style.crosshair,a=i.width,l=i.height,c=Math.round(t.x)+.5;if(c<0||c>a)return;e.font=`${n.style.fontSize}px ${o.fontFamily}`,e.textBaseline="middle",e.strokeStyle=s.color??o.textColor,e.lineWidth=s.width,e.globalAlpha=s.opacity*.55,vw(e,s.style),e.beginPath(),e.moveTo(c,0),e.lineTo(c,l),t.y!=null&&(e.moveTo(0,Math.round(t.y)+.5),e.lineTo(a,Math.round(t.y)+.5)),e.stroke(),e.setLineDash([]),e.lineWidth=1,e.globalAlpha=.8;let u=s.labelBackground??o.borderColor;if(t.y!=null&&t.price!=null){let d;for(let h of n.panes.values())if(t.y>=h.bounds.top&&t.y<=h.bounds.top+h.bounds.height){d=h;break}d&&d.axisFormat!=="none"&&this.chip(e,a+1,t.y,bs(d.scale,d.bounds.height,t.price,kn(n,d),n.priceMintick,d.axisFormat),u,"left",false,o.background);}this.chip(e,c,l+1,Ph(t.time,n.timezone,i.barInterval),u,"center",true,o.background),e.globalAlpha=1;}drawSeparatorHover(e,t,n,i){let o=Math.round(i);e.fillStyle=n.textColor,e.globalAlpha=.1,e.fillRect(0,o-4,t,8),e.globalAlpha=.55,e.fillRect(0,o-1,t,2),e.globalAlpha=1;}chip(e,t,n,i,o,s,a=false,l="#000000"){let c=e.measureText(i).width+8,u=16,d=s==="left"?t:t-c/2,h=a?n:n-u/2;e.fillStyle=o,e.fillRect(d,h,c,u),e.fillStyle=My(o,l),e.textAlign="center",e.fillText(i,d+c/2,h+u/2+(a?2:0)),e.textAlign="start";}};function vw(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}var Ih=[{value:"Etc/UTC",label:"UTC"},{value:"Etc/GMT+12",label:"International Date Line West"},{value:"Pacific/Pago_Pago",label:"Pago Pago"},{value:"Pacific/Honolulu",label:"Honolulu"},{value:"Pacific/Marquesas",label:"Marquesas Islands"},{value:"America/Anchorage",label:"Anchorage"},{value:"America/Los_Angeles",label:"Los Angeles"},{value:"America/Phoenix",label:"Phoenix"},{value:"America/Denver",label:"Denver"},{value:"America/Chicago",label:"Chicago"},{value:"America/Mexico_City",label:"Mexico City"},{value:"America/New_York",label:"New York"},{value:"America/Bogota",label:"Bogot\xE1"},{value:"America/Caracas",label:"Caracas"},{value:"America/Santiago",label:"Santiago"},{value:"America/St_Johns",label:"St. John's"},{value:"America/Sao_Paulo",label:"S\xE3o Paulo"},{value:"America/Argentina/Buenos_Aires",label:"Buenos Aires"},{value:"America/Noronha",label:"Fernando de Noronha"},{value:"Atlantic/Azores",label:"Azores"},{value:"Atlantic/Reykjavik",label:"Reykjavik"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris"},{value:"Europe/Berlin",label:"Berlin"},{value:"Europe/Athens",label:"Athens"},{value:"Africa/Cairo",label:"Cairo"},{value:"Africa/Johannesburg",label:"Johannesburg"},{value:"Europe/Moscow",label:"Moscow"},{value:"Europe/Istanbul",label:"Istanbul"},{value:"Asia/Tehran",label:"Tehran"},{value:"Asia/Dubai",label:"Dubai"},{value:"Asia/Kabul",label:"Kabul"},{value:"Asia/Karachi",label:"Karachi"},{value:"Asia/Kolkata",label:"Mumbai"},{value:"Asia/Kathmandu",label:"Kathmandu"},{value:"Asia/Dhaka",label:"Dhaka"},{value:"Asia/Yangon",label:"Yangon"},{value:"Asia/Bangkok",label:"Bangkok"},{value:"Asia/Shanghai",label:"Shanghai"},{value:"Asia/Hong_Kong",label:"Hong Kong"},{value:"Asia/Singapore",label:"Singapore"},{value:"Australia/Eucla",label:"Eucla"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Seoul",label:"Seoul"},{value:"Australia/Adelaide",label:"Adelaide"},{value:"Australia/Sydney",label:"Sydney"},{value:"Australia/Lord_Howe",label:"Lord Howe Island"},{value:"Pacific/Noumea",label:"Noum\xE9a"},{value:"Pacific/Auckland",label:"Auckland"},{value:"Pacific/Chatham",label:"Chatham Islands"},{value:"Pacific/Apia",label:"Apia"},{value:"Pacific/Kiritimati",label:"Kiritimati"}];function Hc(r){return r==="UTC"||r==="Etc/UTC"||r==="Etc/GMT"?"Etc/UTC":r}function bM(r,e=new Date){try{let i=(new Intl.DateTimeFormat("en-US",{timeZone:r,timeZoneName:"shortOffset"}).formatToParts(e).find(l=>l.type==="timeZoneName")?.value??"").match(/GMT(?:(\+|-)(\d{1,2})(?::(\d{2}))?)?/);if(!i||!i[1])return "UTC";let o=i[1]==="-"?"-":"+",s=i[2]??"0",a=i[3]??"";return a?`UTC${o}${s}:${a}`:`UTC${o}${s}`}catch{return "UTC"}}function Ah(r,e){return Hc(r)==="Etc/UTC"?e:`(${bM(r)}) ${e}`}function jn(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var Rh="events",zc="events.groups";function Dh(r){return `${zc}.${jn(r)}`}function yt(r,e){if(e.size===0)return false;let t=r;for(;;){if(e.has(t))return true;let n=t.lastIndexOf(".");if(n<0)return false;t=t.slice(0,n);}}function yw(r){if(r.kind==="heading"||r.kind==="header")return jn(r.label);let e=Zr(r);if(e.toggle)return e.toggle.key;for(let t of e.controls)if(t.kind!=="hint")return t.key;return jn(e.label)}function $c(r,e,t){if(t.size===0)return [...r];let n=[],i=false,o=false;for(let s of r){let a=`${e}.${yw(s)}`;if(s.kind==="heading"){i=yt(a,t),o=false,i||n.push(s);continue}if(s.kind==="header"){if(i)continue;o=yt(a,t),o||n.push(s);continue}i||o||yt(a,t)||n.push(s);}return n}function Oh(r){return r.id??jn(r.title)}function ww(r){return r.id??jn(r.label)}function xw(r,e,t){if(t.size===0)return [...r];let n=[],i=false;for(let o of r){let s=`${e}.${ww(o)}`;if(o.kind==="heading"){i=yt(s,t),i||n.push(o);continue}i||yt(s,t)||n.push(o);}return n}var vM=["symbol","symbol.type","symbol.style.candles","symbol.style.candles.body","symbol.style.candles.borders","symbol.style.candles.wick","symbol.style.candles.spacing","symbol.style.bars","symbol.style.bars.up-color","symbol.style.bars.down-color","symbol.style.bars.spacing","symbol.style.line","symbol.style.line.color","symbol.style.line.width","symbol.style.area","symbol.style.area.line-color","symbol.style.area.width","symbol.style.area.top-fill","symbol.style.area.bottom-fill","symbol.style.baseline","symbol.style.baseline.top-line","symbol.style.baseline.bottom-line","symbol.style.baseline.fill-top","symbol.style.baseline.fill-bottom","symbol.style.baseline.base-level","symbol.style.baseline.width","symbol.animation","symbol.animation.zoom","symbol.animation.pan","symbol.animation.autoscale","symbol.animation.price-changes","symbol.animation.intro","symbol.timezone","scales","scales.price-scale","scales.price-scale.mode","scales.price-scale.invert","scales.price-scale.last-price-line","scales.price-scale.last-price-label","scales.price-scale.countdown","scales.price-scale.axis-labels","scales.price-scale.border-color","scales.crosshair","scales.crosshair.color","scales.crosshair.width","scales.crosshair.style","canvas","canvas.background","canvas.background.color","canvas.background.text-color","canvas.background.text-size","canvas.background.pane-separator","canvas.grid","canvas.grid.vertical","canvas.grid.horizontal","canvas.theme"];function Sw(r,e=[]){let t=new Set(vM);if(e.length>0){t.add(Rh),t.add(zc);for(let n of e)t.add(Dh(n.id));}for(let n of Mt()){if(as(n.id)){let a=`symbol.style.${n.id}`;for(let l of ["",".body",".borders",".wick",".spacing"])t.add(a+l);}let i=n.settings;if(!i)continue;let o=`type:${n.id}`;t.add(o);let s=a=>{for(let l of a)t.add(`${o}.${yw(l)}`);};i.rows&&s(i.rows);for(let a of i.instances??[])s(a.rows);for(let a of i.subsections??[])t.add(`${o}.${jn(a.title)}`),s(a.rows);}for(let n of r){let i=Oh(n);t.add(i);for(let o of n.rows)t.add(`${i}.${ww(o)}`);}return [...t]}var yM={candles:"Candles",bars:"Bars",line:"Line",area:"Area",baseline:"Baseline"};function wM(r){return pn(r)?.label??yM[r]??r}var Cw="vela-settings-controls",Tw="6";var xM="var(--vela-border)";function SM(){if(typeof document>"u")return;let r=document.getElementById(Cw);if(r?.dataset.rev===Tw)return;let e=r??document.createElement("style");e.id=Cw,e.dataset.rev=Tw,e.textContent=`
|
|
824
|
+
${Sr(".vela-sd-pane")}
|
|
825
825
|
/* Tab rail / footer button / header close: base styles live HERE, not inline on the
|
|
826
826
|
elements \u2014 inline declarations always beat stylesheet :hover rules, which is exactly
|
|
827
827
|
what killed these hovers before. Active tab state is the .on class,
|
|
@@ -895,11 +895,11 @@ ${xr(".vela-sd-pane")}
|
|
|
895
895
|
alignment device; on mobile the trigger hugs its value instead (the grid's control
|
|
896
896
|
column is max-content), capped so a long option still ellipsizes before the label. */
|
|
897
897
|
.vela-sd-mobile .vela-select-trigger .vela-select-label{white-space:nowrap !important;}
|
|
898
|
-
.vela-sd-mobile .vela-select:not([data-fill]){width:auto;min-width:100px;max-width:min(220px,55vw);}`,r||document.head.appendChild(e);}var bs=class{constructor(e,t){this.container=e;this.theme=t;this.root=null;this.ui=null;this.onChange=null;this.onImport=null;this.onReset=null;this.config=null;this.syncTypeTabs=null;this.hostSections=[];this.markGroups=[];this.markGroupVisible=()=>true;this.themeControl=null;this.tabs=[];this.hintTips=[];this.typeActiveInstance=new Map;this.typeActiveGroup=new Map;this.activeSection=null;this.mobileLayout=false;this.hiddenSettings=new Set;getComputedStyle(e).position==="static"&&(e.style.position="relative");}setHostSections(e){this.hostSections=e;}setMarkGroups(e,t){this.markGroups=e,this.markGroupVisible=t;}setHiddenSettings(e){let t=new Set(e),n=t.size===this.hiddenSettings.size&&[...t].every(i=>this.hiddenSettings.has(i));this.hiddenSettings=t,n||this.reopenIfLive();}setThemeControl(e,t){this.themeControl={current:e,onSelect:t};}refreshConfig(e){this.config&&(this.config=e);}setTheme(e){this.theme=e,this.reopenIfLive();}setLayoutMode(e){let t=e==="mobile";t!==this.mobileLayout&&(this.mobileLayout=t,this.reopenIfLive());}reopenIfLive(){if(!this.root)return;let e=this.config,t=this.onChange,n=this.onImport,i=this.onReset,o=this.activeSection;this.close(),e&&t&&this.open(e,t,n??void 0,i??void 0,o??void 0);}isOpen(){return this.root!==null}toggle(e,t,n,i,o){this.root?this.close():this.open(e,t,n,i,o);}showSection(e){this.tabs.find(t=>t.title.toLowerCase()===e.toLowerCase())?.show();}open(e,t,n,i,o){this.close(),this.config=e,this.onChange=t,this.onImport=n??null,this.onReset=i??null,gL();let s=this.mobileLayout,a=null,l;s&&(l=document.createElement("button"),l.type="button",l.className="vela-sd-burger",l.innerHTML=ye("burger",16),l.title="Sections",l.addEventListener("click",()=>a?.()));let c=document.createElement("div");c.style.cssText="display:flex;flex-direction:column;gap:0;";let u=(C,A)=>(C.dataset.sdId=A,C);c.append(u(this.section("Symbol"),"symbol")),c.append(u(this.sectionTitle("Chart type"),"symbol.type"));let d={},h=C=>{let A=C==="heikinashi"?"candles":C;for(let $ of Li())d[$]?.classList.toggle("vela-sd-hide",$!==A);};c.append(u(this.selectRowLabeled("Type",e.series.style,Li().map(C=>[C,mL(C)]),C=>{this.emit({series:{style:C}}),h(C),this.syncTypeTabs?.(C);}),"symbol.type"));let p=u(this.group(),"symbol.style.candles");p.append(this.sectionTitle("Candles")),p.append(u(this.toggleRow("Body",e.candles.bodyVisible,C=>this.emit({candles:{bodyVisible:C}}),[this.swatch(e.candles.upColor,C=>this.emit({candles:{upColor:C}})),this.swatch(e.candles.downColor,C=>this.emit({candles:{downColor:C}}))]),"symbol.style.candles.body")),p.append(u(this.toggleRow("Borders",e.candles.borderVisible,C=>this.emit({candles:{borderVisible:C}}),[this.swatch(e.candles.borderUpColor,C=>this.emit({candles:{borderUpColor:C}})),this.swatch(e.candles.borderDownColor,C=>this.emit({candles:{borderDownColor:C}}))]),"symbol.style.candles.borders")),p.append(u(this.toggleRow("Wick",e.candles.wickVisible,C=>this.emit({candles:{wickVisible:C}}),[this.swatch(e.candles.wickUpColor,C=>this.emit({candles:{wickUpColor:C}})),this.swatch(e.candles.wickDownColor,C=>this.emit({candles:{wickDownColor:C}}))]),"symbol.style.candles.wick")),p.append(u(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.candles.spacing")),d.candles=p,c.append(p);let m=u(this.group(),"symbol.style.bars");m.append(this.sectionTitle("Bars")),m.append(u(this.colorRow("Color Up",e.bars.upColor,C=>this.emit({bars:{upColor:C}})),"symbol.style.bars.up-color")),m.append(u(this.colorRow("Color Down",e.bars.downColor,C=>this.emit({bars:{downColor:C}})),"symbol.style.bars.down-color")),m.append(u(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.bars.spacing")),d.bars=m,c.append(m);let f=u(this.group(),"symbol.style.line");f.append(this.sectionTitle("Line")),f.append(u(this.colorRow("Color",e.line.color,C=>this.emit({line:{color:C}})),"symbol.style.line.color")),f.append(u(this.numberRow("Width",e.line.width,1,10,1,C=>this.emit({line:{width:C}})),"symbol.style.line.width")),d.line=f,c.append(f);let g=u(this.group(),"symbol.style.area");g.append(this.sectionTitle("Area")),g.append(u(this.colorRow("Line color",e.area.lineColor,C=>this.emit({area:{lineColor:C}})),"symbol.style.area.line-color")),g.append(u(this.numberRow("Width",e.area.width,1,10,1,C=>this.emit({area:{width:C}})),"symbol.style.area.width")),g.append(u(this.colorRow("Top fill",e.area.topColor,C=>this.emit({area:{topColor:C}})),"symbol.style.area.top-fill")),g.append(u(this.colorRow("Bottom fill",e.area.bottomColor,C=>this.emit({area:{bottomColor:C}})),"symbol.style.area.bottom-fill")),d.area=g,c.append(g);let b=u(this.group(),"symbol.style.baseline");b.append(this.sectionTitle("Baseline")),b.append(u(this.rowWith("Top line",[this.swatch(e.baseline.topLineColor,C=>this.emit({baseline:{topLineColor:C}}))]),"symbol.style.baseline.top-line")),b.append(u(this.rowWith("Bottom line",[this.swatch(e.baseline.bottomLineColor,C=>this.emit({baseline:{bottomLineColor:C}}))]),"symbol.style.baseline.bottom-line")),b.append(u(this.rowWith("Fill top area",[this.swatch(e.baseline.topFillColor,C=>this.emit({baseline:{topFillColor:C}})),this.swatch(e.baseline.topFillColor2,C=>this.emit({baseline:{topFillColor2:C}}))]),"symbol.style.baseline.fill-top")),b.append(u(this.rowWith("Fill bottom area",[this.swatch(e.baseline.bottomFillColor2,C=>this.emit({baseline:{bottomFillColor2:C}})),this.swatch(e.baseline.bottomFillColor,C=>this.emit({baseline:{bottomFillColor:C}}))]),"symbol.style.baseline.fill-bottom")),b.append(u(this.numberRow("Base level %",e.baseline.baselineLevel,0,100,1,C=>this.emit({baseline:{baselineLevel:C}})),"symbol.style.baseline.base-level")),b.append(u(this.numberRow("Width",e.baseline.width,1,10,1,C=>this.emit({baseline:{width:C}})),"symbol.style.baseline.width")),d.baseline=b,c.append(b);for(let C of Mt()){if(!ss(C.id))continue;let A=e.chartTypes[C.id]??{},$=(j,ut)=>typeof A[j]=="string"&&A[j]!==""?A[j]:ut,ie=(j,ut)=>typeof A[j]=="boolean"?A[j]:ut,oe=u(this.group(),`symbol.style.${C.id}`);oe.append(this.sectionTitle("Candles")),oe.append(u(this.toggleRow("Body",ie("candleBodyVisible",e.candles.bodyVisible),j=>this.emitType(C.id,"candleBodyVisible",j),[this.swatch($("candleUpColor",e.candles.upColor),j=>this.emitType(C.id,"candleUpColor",j)),this.swatch($("candleDownColor",e.candles.downColor),j=>this.emitType(C.id,"candleDownColor",j))]),`symbol.style.${C.id}.body`)),oe.append(u(this.toggleRow("Borders",ie("candleBorderVisible",e.candles.borderVisible),j=>this.emitType(C.id,"candleBorderVisible",j),[this.swatch($("candleBorderUpColor",e.candles.borderUpColor),j=>this.emitType(C.id,"candleBorderUpColor",j)),this.swatch($("candleBorderDownColor",e.candles.borderDownColor),j=>this.emitType(C.id,"candleBorderDownColor",j))]),`symbol.style.${C.id}.borders`)),oe.append(u(this.toggleRow("Wick",ie("candleWickVisible",e.candles.wickVisible),j=>this.emitType(C.id,"candleWickVisible",j),[this.swatch($("candleWickUpColor",e.candles.wickUpColor),j=>this.emitType(C.id,"candleWickUpColor",j)),this.swatch($("candleWickDownColor",e.candles.wickDownColor),j=>this.emitType(C.id,"candleWickDownColor",j))]),`symbol.style.${C.id}.wick`)),oe.append(u(this.numberRow("Spacing",e.series.spacing,.1,10,.1,j=>this.emit({series:{spacing:j}})),`symbol.style.${C.id}.spacing`)),d[C.id]=oe,c.append(oe);}h(e.series.style),c.append(u(this.sectionTitle("Animation"),"symbol.animation")),c.append(u(this.boolRow("Animate zoom",e.animations.zoom,C=>this.emit({animations:{zoom:C}}),this.hint("Glide the chart to each zoom step instead of jumping.")),"symbol.animation.zoom")),c.append(u(this.boolRow("Pan momentum",e.animations.pan,C=>this.emit({animations:{pan:C}}),this.hint("Keep gliding briefly after a drag release, and ease scroll-to-latest and keyboard pans.")),"symbol.animation.pan")),c.append(u(this.boolRow("Animate price scale",e.animations.autoscale,C=>this.emit({animations:{autoscale:C}}),this.hint("Glide the price scale to its new range while zooming or panning.")),"symbol.animation.autoscale")),c.append(u(this.boolRow("Animate price changes",e.priceScale.animateLastPrice,C=>this.emit({priceScale:{animateLastPrice:C}}),this.hint("Glide the live bar to each new price instead of snapping.")),"symbol.animation.price-changes")),c.append(u(this.boolRow("Reveal on load",e.animations.intro,C=>this.emit({animations:{intro:C}}),this.hint("Draw the candles in when a chart first loads. Takes effect on the next load.")),"symbol.animation.intro")),c.append(u(this.sectionTitle("Time zone"),"symbol.timezone")),c.append(u(this.selectRowLabeled("Time zone",Vc(e.timeScale.timezone),vL(e.timeScale.timezone),C=>this.emit({timeScale:{timezone:C}})),"symbol.timezone"));let y=C=>{for(let A of this.hostSections){if((A.placement??"after-symbol")!==C)continue;let $=Ah(A);if(yt($,this.hiddenSettings))continue;let ie=gw(A.rows,$,this.hiddenSettings);if(ie.length!==0){c.append(C==="symbol"?this.sectionTitle(A.title):this.section(A.title));for(let oe of ie)oe.kind==="heading"?c.append(this.sectionTitle(oe.label)):oe.kind==="toggle"?c.append(this.boolRow(oe.label,oe.get(),j=>oe.set(j))):oe.kind==="color"?c.append(this.colorRow(oe.label,oe.get(),j=>oe.set(j))):c.append(this.selectRowLabeled(oe.label,oe.get(),oe.options.map(j=>[j,j]),j=>oe.set(j)));}}},v=C=>{for(let A of Mt()){let $=A.settings;$&&($.placement??"end")===C&&(yt(`type:${A.id}`,this.hiddenSettings)||this.chartTypeSection(A.id,$,e,c));}};if(y("symbol"),v("after-symbol"),y("after-symbol"),c.append(u(this.section("Scales and lines"),"scales")),c.append(u(this.sectionTitle("Price scale"),"scales.price-scale")),c.append(u(this.selectRowLabeled("Mode",e.priceScale.log?"log":e.priceScale.mode,[["price","Regular"],["percent","Percent"],["indexed","Indexed to 100"],["log","Logarithmic"]],C=>this.emit({priceScale:C==="log"?{mode:"price",log:true}:{mode:C,log:false}})),"scales.price-scale.mode")),c.append(u(this.boolRow("Invert scale",e.priceScale.invert,C=>this.emit({priceScale:{invert:C}})),"scales.price-scale.invert")),c.append(u(this.separator(),"scales.price-scale")),c.append(u(this.boolRow("Last Price Line",e.priceScale.currentPriceLine,C=>this.emit({priceScale:{currentPriceLine:C}})),"scales.price-scale.last-price-line")),c.append(u(this.boolRow("Last price label",e.priceScale.priceLabel,C=>this.emit({priceScale:{priceLabel:C}})),"scales.price-scale.last-price-label")),c.append(u(this.boolRow("Countdown to bar close",e.priceScale.countdown,C=>this.emit({priceScale:{countdown:C}})),"scales.price-scale.countdown")),c.append(u(this.boolRow("Axis labels",e.priceScale.labelsVisible,C=>this.emit({priceScale:{labelsVisible:C}})),"scales.price-scale.axis-labels")),c.append(u(this.colorRow("Scale border color",e.priceScale.borderColor,C=>this.emit({priceScale:{borderColor:C}})),"scales.price-scale.border-color")),c.append(u(this.sectionTitle("Crosshair"),"scales.crosshair")),c.append(u(this.colorRow("Color",e.crosshair.color,C=>this.emit({crosshair:{color:C}})),"scales.crosshair.color")),c.append(u(this.numberRow("Width",e.crosshair.width,.5,8,.5,C=>this.emit({crosshair:{width:C}})),"scales.crosshair.width")),c.append(u(this.selectRowLabeled("Style",e.crosshair.style,[["solid","Solid"],["dashed","Dashed"],["dotted","Dotted"]],C=>this.emit({crosshair:{style:C}})),"scales.crosshair.style")),c.append(u(this.section("Canvas"),"canvas")),c.append(u(this.sectionTitle("Background & text"),"canvas.background")),c.append(u(this.colorRow("Background",e.layout.background,C=>this.emit({layout:{background:C}})),"canvas.background.color")),c.append(u(this.colorRow("Text color",e.layout.textColor,C=>this.emit({layout:{textColor:C}})),"canvas.background.text-color")),c.append(u(this.numberRow("Text size",e.layout.fontSize,6,32,1,C=>this.emit({layout:{fontSize:C}})),"canvas.background.text-size")),c.append(u(this.colorRow("Pane separator color",e.panes.separatorColor,C=>this.emit({panes:{separatorColor:C}})),"canvas.background.pane-separator")),c.append(u(this.sectionTitle("Grid"),"canvas.grid")),c.append(u(this.toggleRow("Vertical",e.grid.vertLines.visible,C=>this.emit({grid:{vertLines:{visible:C}}}),[this.swatch(e.grid.vertLines.color,C=>this.emit({grid:{vertLines:{color:C}}}))]),"canvas.grid.vertical")),c.append(u(this.toggleRow("Horizontal",e.grid.horzLines.visible,C=>this.emit({grid:{horzLines:{visible:C}}}),[this.swatch(e.grid.horzLines.color,C=>this.emit({grid:{horzLines:{color:C}}}))]),"canvas.grid.horizontal")),this.themeControl){let C=this.themeControl;c.append(u(this.sectionTitle("Theme"),"canvas.theme")),c.append(u(this.selectRow("Color theme",C.current==="dark"?"Dark":"Light",["Dark","Light"],A=>C.onSelect(A==="Dark"?"dark":"light")),"canvas.theme"));}if(this.markGroups.length>0){c.append(u(this.section("Events"),Ph)),c.append(u(this.sectionTitle("Visible events"),_c));for(let C of this.markGroups)c.append(u(this.boolRow(C.label,this.markGroupVisible(C.id),A=>this.emit({marks:{groups:{[C.id]:A}}})),Ih(C.id)));}if(v("end"),y("end"),this.hiddenSettings.size>0){let C=false;for(let A of [...c.children]){if(A.dataset.sdTab!==void 0&&(C=A.dataset.sdId!==void 0&&yt(A.dataset.sdId,this.hiddenSettings)),C||A.dataset.sdId!==void 0&&yt(A.dataset.sdId,this.hiddenSettings)){A.remove();continue}for(let $ of [...A.querySelectorAll("[data-sd-id]")])yt($.dataset.sdId,this.hiddenSettings)&&$.remove();}}let S=document.createElement("div");S.style.cssText=s?"display:flex;min-height:0;flex:1 1 auto;position:relative;overflow:hidden;":"display:flex;min-height:360px;max-height:calc(70vh - 100px);flex:1 1 auto;";let E=document.createElement("div");E.className="vela-sd-rail",E.style.cssText=s?"display:flex;flex-direction:column;gap:2px;padding:10px 8px;overflow-y:auto;":`flex:0 0 170px;display:flex;flex-direction:column;gap:2px;padding:10px 8px;border-right:1px solid ${fL};overflow-y:auto;`;let T=null;s&&(T=document.createElement("div"),T.className="vela-sd-railscrim",T.addEventListener("click",()=>a?.()),a=C=>{let A=C??!E.classList.contains("open");E.classList.toggle("open",A),T?.classList.toggle("open",A);});let k=document.createElement("div");k.className="vela-sd-pane",k.style.cssText=s?"flex:1;min-width:0;overflow-y:auto;overflow-anchor:none;padding:6px 14px calc(14px + env(safe-area-inset-bottom, 0px));":"flex:1;overflow-y:auto;overflow-anchor:none;padding:6px 18px 14px;";let x=[],M=null;for(let C of [...c.children]){let A=C.dataset.sdTab;if(A!==void 0){let $=document.createElement("div");$.style.display="none";let ie=document.createElement("button");ie.type="button",ie.textContent=A,ie.className="vela-sd-tab"+(C.dataset.sdSub!==void 0?" vela-sd-tab-sub":""),x.push({title:A,el:$,tab:ie,style:C.dataset.sdStyle,visibility:C.dataset.sdVisibility}),M=$,C.remove();continue}M&&M.appendChild(C);}for(let C=x.length-1;C>=0;C--)x[C].el.childElementCount===0&&x.splice(C,1);this.syncTypeTabs=C=>{let A=false;x.forEach(($,ie)=>{if(!$.style)return;let oe=$.visibility==="always"||$.style===C||C==="heikinashi"&&$.style==="heikinashi";$.tab.style.display=oe?"":"none",!oe&&$.el.style.display==="block"&&(A=true);}),A&&L(0);};let w=new yn({host:this.container,title:"Chart settings",modal:false,contained:true,align:"top",draggable:!s,flush:true,className:"vela-dialog--settings",headerStart:l,closeOnBackdrop:true,footer:C=>{C.style.cssText="padding:10px 14px;display:flex;align-items:center;justify-content:flex-start;gap:8px;";let A=document.createElement("button");A.type="button",A.textContent="Reset defaults",A.className="vela-sd-btn",A.addEventListener("click",()=>this.onReset?.()),C.appendChild(A);},onOpenChange:C=>{C||this.close();}});s&&w.positioner.classList.add("vela-sd-mobile"),w.positioner.style.paddingTop=s?"0":"8vh";let L=C=>{x.forEach((A,$)=>{A.el.style.display=$===C?"block":"none",A.tab.classList.toggle("on",$===C);}),this.activeSection=x[C]?.title??null,s&&(w.titleEl.textContent=x[C]?.title??"Chart settings",a?.(false));};x.forEach((C,A)=>{C.tab.addEventListener("click",()=>L(A)),E.appendChild(C.tab),k.appendChild(C.el);}),this.tabs=x.map((C,A)=>({title:C.title,show:()=>L(A)}));let P=o!==void 0?x.findIndex(C=>C.title.toLowerCase()===o.toLowerCase()):x.findIndex(C=>C.style===e.series.style&&!C.tab.classList.contains("vela-sd-tab-sub"));L(P>=0?P:0),this.syncTypeTabs?.(e.series.style),S.append(E,k),T&&S.append(T),w.body.appendChild(S),this.root=w.positioner,this.ui=w,w.show();for(let C of x){let A=[...C.el.querySelectorAll("[data-sd-rows-host]")];if(A.length===0){this.layoutSettingsGrids(C.el);continue}for(let $ of A)this.layoutSettingsGrids($);}}close(){Te(),eh();let e=this.ui;this.ui=null,this.root=null,this.tabs=[];for(let t of this.hintTips)t();this.hintTips=[],e?.destroy();}destroy(){this.close(),this.onChange=null,this.onImport=null,this.config=null;}emitType(e,t,n){this.emit({chartTypes:{[e]:{[t]:n}}});}emit(e){this.onChange?.(e);}sectionTitle(e){return wn(e)}chartTypeSection(e,t,n,i){let o=this.section(t.title);o.dataset.sdStyle=e,o.dataset.sdVisibility=t.visibility??"active",i.append(o);let s=n.chartTypes[e]??{},a={},l=h=>{for(let p of h)for(let m of oo(p)){let f=s[m.key];a[m.key]=typeof f===m.type?f:m.defval;}};t.rows&&l(t.rows);for(let h of t.instances??[])l(h.rows);for(let h of t.subsections??[])l(h.rows);for(let h of t.instances??[])!h.enableKey||h.enableKey in a||(a[h.enableKey]=s[h.enableKey]===true);for(let h of t.subsections??[])!h.enableKey||h.enableKey in a||(a[h.enableKey]=s[h.enableKey]===true);let c=[],u=(h,p)=>{a[h]=p,this.emitType(e,h,p);for(let m of c)m();},d=`type:${e}`;if(t.instances&&t.instances.length>0){let h=t.instances.map(p=>({...p,rows:Bc(p.rows,d,this.hiddenSettings)}));i.append(this.instancesBlock(e,h,a,u,c));}else if(t.rows){let h=Bc(t.rows,d,this.hiddenSettings);t.layout==="grouped"?i.append(this.groupedRows(`${e}/rows`,h,a,u,c)):this.flatTypeRows(h,a,u,c,i);}for(let h of t.subsections??[]){if(yt(`${d}.${Xn(h.title)}`,this.hiddenSettings))continue;let p=Bc(h.rows,d,this.hiddenSettings);if(p.length===0)continue;let m=this.section(h.title);m.dataset.sdStyle=e,m.dataset.sdVisibility=t.visibility??"active",m.dataset.sdSub="1",i.append(m),i.append(this.groupedRows(`${e}/${h.title}`,p,a,u,c,h.enableKey));}for(let h of c)h();}flatTypeRows(e,t,n,i,o){let s=[];for(let a of e){let l=a.kind==="heading"||a.kind==="header"?this.sectionTitle(a.label):this.typeRow(a,t,n,i);s.push({el:l,when:a.when}),o.append(l);}i.push(()=>{for(let a of s)a.el.classList.toggle("vela-sd-hide",!gr(a.when,t));});}typeRow(e,t,n,i){let o=qr(e),s=[];for(let a of o.controls){let l=this.inlineControl(a,t,n,o.toggle!==void 0);if(a.kind!=="hint"&&i.push(()=>l.dispatchEvent(new Event("vela-sync"))),a.kind!=="hint"&&a.when){l.dataset.sdSelfGated="1";let c=a.when;i.push(()=>{l.style.display=gr(c,t)?"":"none";});}s.push(l);}if(o.toggle){let a=o.toggle,l=this.toggleRow(o.label,t[a.key],c=>n(a.key,c),s,()=>t[a.key]===true);return i.push(()=>l.dispatchEvent(new Event("vela-sync"))),l}return this.rowWith(o.label,s)}inlineControl(e,t,n,i){if(e.kind==="hint"){let s=document.createElement("span");return s.textContent=e.text,s.style.cssText="color:var(--vela-fg-muted);",s}if(e.kind==="color")return se({kind:"color",theme:this.theme,get:()=>t[e.key],onChange:s=>n(e.key,s),title:e.label}).el;if(e.kind==="width"){let s=typeof t[e.key]=="number"?t[e.key]:e.defval;return se({kind:"width",theme:this.theme,get:()=>typeof t[e.key]=="number"?t[e.key]:s,onChange:a=>n(e.key,a),title:e.label}).el}if(e.kind==="select"){let s=typeof t[e.key]=="string"?t[e.key]:e.defval;return se({kind:"select",options:bL(e.options).map(([a,l])=>({value:a,label:l})),value:s,fill:false,theme:this.theme,title:e.label,onChange:a=>n(e.key,a),sync:()=>typeof t[e.key]=="string"?t[e.key]:e.defval}).el}let o=typeof t[e.key]=="number"?t[e.key]:e.defval;return se({kind:"number",value:o,min:e.min,max:e.max,step:e.step??1,fill:false,commit:"live",clamp:e.placeholder!==void 0,steppers:true,compact:i,title:e.label,placeholder:e.placeholder,emptyValue:e.placeholder!==void 0?e.defval:void 0,onChange:s=>n(e.key,s),sync:()=>typeof t[e.key]=="number"?t[e.key]:e.defval}).el}instancesBlock(e,t,n,i,o){let s=document.createElement("div"),a=document.createElement("div");a.className="vela-sd-itabs",(t.length>1||t[0]?.enableKey!==void 0)&&s.append(a);let l=t.map((d,h)=>{let p=this.groupedRows(`${e}/#${h}`,d.rows,n,i,o);return s.append(p),p}),c=d=>!d.enableKey||n[d.enableKey]===true,u=()=>{let d=this.typeActiveInstance.get(e)??0;c(t[d]??t[0])||(d=0),this.typeActiveInstance.set(e,d),a.replaceChildren(),t.forEach((p,m)=>{if(!c(p))return;let f=document.createElement("button");f.type="button",f.className="vela-sd-itab"+(m===d?" on":"");let g=document.createElement("span");if(g.textContent=p.label,f.append(g),m===d&&p.enableKey){let b=document.createElement("span");b.className="vela-sd-ix",b.textContent="\u2715",b.title=`Remove ${p.label}`,b.addEventListener("click",y=>{y.stopPropagation(),this.typeActiveInstance.set(e,0),i(p.enableKey,false);}),f.append(b);}f.addEventListener("click",()=>{this.typeActiveInstance.set(e,m),u();}),a.append(f);});let h=t.findIndex(p=>!c(p));if(h>=0){let p=document.createElement("button");p.type="button",p.className="vela-sd-itab vela-sd-itab-add",p.textContent="+",p.title=`Add ${t[h].label}`,p.addEventListener("click",()=>{this.typeActiveInstance.set(e,h),i(t[h].enableKey,true);}),a.append(p);}l.forEach((p,m)=>p.classList.toggle("vela-sd-hide",m!==d));};return o.push(u),s}groupedRows(e,t,n,i,o,s){let a=document.createElement("div");a.className="vela-sd-struct";let l=document.createElement("div");l.className="vela-sd-toc";let c=document.createElement("div");c.dataset.sdRowsHost="1",c.style.cssText="flex:1 1 auto;min-width:0;",a.append(l,c);let u=[],d=[],h=[],p=-1;for(let f of t){if(f.kind==="heading"){p=d.length,d.push(f.label),h.push(f.when);continue}if(f.kind==="header"){u.push({el:this.sectionTitle(f.label),when:f.when,group:p,header:true}),c.append(u[u.length-1].el);continue}let g=this.typeRow(f,n,i,o),b=f.kind==="row"?f.toggle?.key:f.kind==="range"?void 0:f.key;u.push({el:g,when:f.when,group:p,key:b}),c.append(g);}let m=()=>{let f=d.map((v,S)=>gr(h[S],n)&&u.some(E=>E.group===S&&!E.header&&gr(E.when,n))),g=d.indexOf(this.typeActiveGroup.get(e)??"");(g<0||!f[g])&&(g=f.findIndex(Boolean)),g>=0&&this.typeActiveGroup.set(e,d[g]),l.replaceChildren(),d.forEach((v,S)=>{if(!f[S])return;let E=document.createElement("button");E.type="button",E.className="vela-sd-toc-btn"+(S===g?" on":""),E.textContent=v,E.addEventListener("click",()=>{this.typeActiveGroup.set(e,v),m();}),l.append(E);});let b=f.some(Boolean);l.classList.toggle("vela-sd-hide",!b),a.classList.toggle("no-toc",!b);let y=!s||n[s]===true;for(let v=0;v<u.length;v++){let S=u[v],E=(S.group===-1||S.group===g)&&gr(S.when,n);if(E&&S.header){let T=false;for(let k=v+1;k<u.length;k++){let x=u[k];if(x.group!==S.group||x.header)break;if(gr(x.when,n)){T=true;break}}E=T;}S.el.classList.toggle("vela-sd-hide",!E),S.el.classList.toggle("vela-sd-soft",E&&!y&&S.key!==s);}};return o.push(m),a}separator(){return nh()}layoutSettingsGrids(e){if(e.childElementCount===0)return;let t=ts({variant:"settings",mobile:this.mobileLayout});for(;e.firstChild;)t.appendChild(e.firstChild);e.appendChild(t);for(let n of [...t.children])n.dataset.sdGroup!==void 0&&this.flattenGroup(n,t);}flattenGroup(e,t){e.style.display="contents";for(let n of [...e.children])n.dataset.sdGroup!==void 0&&this.flattenGroup(n,t);}swatch(e,t,n){let i=e;return se({kind:"color",theme:this.theme,get:()=>n?n():i,onChange:o=>{i=o,t(o);}}).el}rowWith(e,t){return Ae({label:e,labelSize:"sm",control:t,className:"vela-sd-row"})}section(e){let t=document.createElement("div");return t.dataset.sdTab=e,t.style.display="none",t}group(){let e=document.createElement("div");return e.dataset.sdGroup="",e.style.cssText="display:contents;",e}colorRow(e,t,n){let i=t;return Ae({label:e,labelSize:"sm",fit:true,className:"vela-sd-row",control:se({kind:"color",theme:this.theme,get:()=>i,onChange:o=>{i=o,n(o);}}).el})}boolRow(e,t,n,i){return this.toggleRow(e,t,n,[],void 0,i)}toggleRow(e,t,n,i,o,s){return Ae({label:e,labelSize:"sm",bool:i.length===0,toggle:{checked:t,onChange:n,get:o},control:i,info:s,className:i.length===0?"vela-sd-bool":"vela-sd-row"})}hint(e){let{el:t,dispose:n}=sl(e,{host:this.container,theme:()=>this.theme});return this.hintTips.push(n),t}numberRow(e,t,n,i,o,s){return Ae({label:e,labelSize:"sm",className:"vela-sd-row",control:se({kind:"number",value:t,min:n,max:i,step:o,fill:false,commit:"live",steppers:true,onChange:s}).el})}selectRowLabeled(e,t,n,i){return Ae({label:e,labelSize:"sm",className:"vela-sd-row",control:se({kind:"select",options:n.map(([o,s])=>({value:o,label:s})),value:t,fill:false,theme:this.theme,onChange:i}).el})}selectRow(e,t,n,i){return this.selectRowLabeled(e,t,n.map(o=>[o,o]),i)}};function bL(r){return r.map(e=>typeof e=="string"?[e,e]:e)}function vL(r){let e=Mh.map(n=>[n.value,Lh(n.value,n.label)]),t=Vc(r);return Mh.some(n=>n.value===t)?e:[[t,Lh(t,t)],...e]}var vs=_s,ys=Bs;function wt(r,e){if(r instanceof Ne){if(!r.fillTriangles().length)return null;let t=r.valid();return r.style.fillColor??(t==null?r.style.lineColor:t?vs:ys)}return r instanceof dt?r.style.fillColor??e.background:r.style.fillColor??null}var yL=4.5,Rh=O,wL=q(J,.55),xL=.7,ww=Xp,SL=jp,xw={selected:.3,hovered:.12};function Dh(r){let e=new Set(r.selected);return r.dragged&&e.add(r.dragged),r.hovered&&e.add(r.hovered),r.mutedLabel&&e.delete(r.mutedLabel),e}var Hc=class{constructor(){this.targets={};this.seriesLook={style:"candles",upColor:z,downColor:W,lineColor:z};}paintAll(e,t,n,i,o={}){this.targets=o;for(let s of t)s.visible&&this.paintClipped(e,s,n,()=>this.paintOne(e,s,n,i));this.targets={},this.paintHighlights(e,t,n,Dh(o));}paintHighlights(e,t,n,i){if(i.size!==0)for(let o of t)o.visible&&i.has(o.id)&&this.paintClipped(e,o,n,()=>this.paintHandles(e,o.handlePoints(n)));}paintClipped(e,t,n,i){if(!n.paneRect){i();return}let o=n.paneRect(t.paneId);!o||o.height<=0||(e.save(),e.beginPath(),e.rect(0,o.top,n.width,o.height),e.clip(),i(),e.restore());}paintGhost(e,t,n,i){e.globalAlpha=xL,t instanceof cn||t instanceof at?this.paintTimeSpanGhost(e,t,n):t instanceof tt?this.paintMagnifierGhost(e,t,n,i):this.paintOne(e,t,n,i),e.globalAlpha=1;}paintTimeSpanGhost(e,t,n){let i=t.anchors[0],o=t.anchors[1];if(!i)return;let s=t instanceof cn?t.reg?.midColor||J:J,a=d=>{let h=n.xOf(d);e.save(),e.strokeStyle=s,e.globalAlpha=.6*e.globalAlpha,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(h,0),e.lineTo(h,n.height),e.stroke(),e.restore();};a(i.time),o&&a(o.time);let l=n.yOf(i.price,t.paneId),c=o?n.yOf(o.price,t.paneId):null,u=[];l!=null&&u.push([n.xOf(i.time),l]),o&&c!=null&&(e.save(),e.strokeStyle=s,e.lineWidth=1,e.setLineDash([]),e.beginPath(),e.moveTo(n.xOf(i.time),l??c),e.lineTo(n.xOf(o.time),c),e.stroke(),e.restore(),u.push([n.xOf(o.time),c])),this.paintHandles(e,u);}paintMarquee(e,t){e.save(),e.fillStyle=q(Rh,.08),e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Rh,e.lineWidth=1,e.setLineDash([4,3]),e.strokeRect(t.x+.5,t.y+.5,t.w,t.h),e.restore();}paintSnapRing(e,t,n,i){e.setLineDash([]),e.globalAlpha=.9,e.beginPath(),e.arc(t,n,5.5,0,Math.PI*2),e.strokeStyle=i.textColor,e.lineWidth=1.5,e.stroke(),e.globalAlpha=1;}paintOne(e,t,n,i){if(t.type==="highlighter"&&t instanceof pe){this.paintHighlighter(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof pe){if(this.paintSegments(e,t,n),t.type==="path"){let o=t.handlePoints(n);o.length>=2&&this.paintArrowhead(e,o[o.length-2],o[o.length-1],t.style);}this.paintLabel(e,t,n,i);return}if(t instanceof sr){this.paintArrowMark(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof ar){this.paintGlyphStamp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof Tt){this.paintRadialFib(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof dr){this.paintFibSpiral(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof pr){this.paintDedekind(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Qe){this.paintMachFigure(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof hr){this.paintFibRatios(e,t,n,i),this.paintGannArcs(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof fe){this.paintFibRatios(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof mr){this.paintMeasureBox(e,t,n,i);return}if(t instanceof ht){this.paintPosition(e,t,n,i);return}if(t instanceof cn){this.paintRegressionChannel(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof or){this.paintAnchoredVwap(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof at){this.paintFixedRangeVp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof tt){this.paintMagnifier(e,t,n,i);return}if(t instanceof Ne){this.paintPattern(e,t,n,i);return}if(t instanceof rr){this.paintComment(e,t,n,i);return}if(t instanceof nr){this.paintPriceNote(e,t,n,i);return}if(t instanceof ir){this.paintSignpost(e,t,n,i);return}if(t instanceof Bt){this.paintCallout(e,t,n,i);return}if(t instanceof er){this.paintNote(e,t,n,i);return}if(t instanceof tr){this.paintPriceLabel(e,t,n,i);return}switch(t.type){case "hline":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(0,o[0][1]),e.lineTo(n.width,o[0][1]);});break}case "trendline":case "arrow":{let o=t.handlePoints(n);if(o.length<2)return;this.stroke(e,t.style,()=>{e.moveTo(o[0][0],o[0][1]),e.lineTo(o[1][0],o[1][1]);}),t.style.arrowRight&&this.paintArrowhead(e,o[0],o[1],t.style),t.style.arrowLeft&&this.paintArrowhead(e,o[1],o[0],t.style);break}case "ellipse":{let o=t.handlePoints(n);if(o.length<2)return;let s=(o[0][0]+o[1][0])/2,a=(o[0][1]+o[1][1])/2,l=Math.abs(o[1][0]-o[0][0])/2,c=Math.abs(o[1][1]-o[0][1])/2;t.style.fillColor&&(e.save(),e.fillStyle=t.style.fillColor,e.beginPath(),e.ellipse(s,a,l,c,0,0,Math.PI*2),e.fill(),e.restore()),this.applyStroke(e,t.style),e.beginPath(),e.ellipse(s,a,l,c,0,0,Math.PI*2),e.stroke(),e.setLineDash([]);break}case "ray":{let o=t.handlePoints(n);if(o.length<2)return;let[s,a,l,c]=Di(o[0][0],o[0][1],o[1][0],o[1][1],"right",n.width,n.height);this.stroke(e,t.style,()=>{e.moveTo(s,a),e.lineTo(l,c);});break}case "extendedline":{let o=t.handlePoints(n);if(o.length<2)return;let[s,a,l,c]=Di(o[0][0],o[0][1],o[1][0],o[1][1],"both",n.width,n.height);this.stroke(e,t.style,()=>{e.moveTo(s,a),e.lineTo(l,c);});break}case "vline":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(o[0][0],0),e.lineTo(o[0][0],n.height);});break}case "hray":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(o[0][0],o[0][1]),e.lineTo(n.width,o[0][1]);});break}case "crossline":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(0,o[0][1]),e.lineTo(n.width,o[0][1]),e.moveTo(o[0][0],0),e.lineTo(o[0][0],n.height);});break}case "infoline":this.paintInfoLine(e,t,n);break;case "trendangle":this.paintTrendAngle(e,t,n,i);break;case "circle":{let o=t.handlePoints(n);if(o.length<2)return;let s=o[0][0],a=o[0][1],l=Math.hypot(o[1][0]-s,o[1][1]-a);if(l<1)return;t.style.fillColor&&(e.save(),e.fillStyle=t.style.fillColor,e.beginPath(),e.arc(s,a,l,0,Math.PI*2),e.fill(),e.restore()),this.applyStroke(e,t.style),e.beginPath(),e.arc(s,a,l,0,Math.PI*2),e.stroke(),e.setLineDash([]);break}case "box":{let o=t.handlePoints(n);if(o.length<2)return;let s=Math.min(o[0][0],o[1][0]),a=Math.min(o[0][1],o[1][1]),l=Math.abs(o[1][0]-o[0][0]),c=Math.abs(o[1][1]-o[0][1]);t.style.fillColor&&(e.save(),e.fillStyle=t.style.fillColor,e.fillRect(s,a,l,c),e.restore()),this.applyStroke(e,t.style),e.strokeRect(s,a,l,c),e.setLineDash([]);break}}this.paintLabel(e,t,n,i);}paintLabel(e,t,n,i){let o=t.text;if(!o||!o.value||t.id===this.targets.mutedLabel)return;let s=TL(t,n);if(!s)return;let a=Be(o.size);e.save(),s.rotate&&(e.translate(s.rotate.cx,s.rotate.cy),e.rotate(s.rotate.angle)),e.font=`${o.bold?"bold ":""}${o.italic?"italic ":""}${a}px ${i.fontFamily}`,e.textBaseline="top",e.textAlign=s.align,e.fillStyle=o.color??i.textColor;let l=rn(a),c=o.value.split(`
|
|
899
|
-
`);c.forEach((u,d)=>e.fillText(u,s.x,s.top+d*l)),t.type==="text"&&this.paintTextFrame(e,t.id,s.x,s.top,c,a,i),e.restore();}paintTextFrame(e,t,n,i,o,s,a){let l=this.targets,c=l.selected?.has(t)?xw.selected:l.hovered===t?xw.hovered:0;if(c===0)return;let u=rn(s),d=Math.max(8,...o.map(h=>e.measureText(h).width));e.save(),e.setLineDash([]),e.lineWidth=1,e.strokeStyle=q(a.textColor,c),Ot(e,n-Or,i-(u-s)/2-Nr,d+Or*2,o.length*u+Nr*2,4),e.stroke(),e.restore();}paintFibRatios(e,t,n,i){let o=t.entryLines(n);if(!o||o.length===0)return;for(let l of t.fillBands(n))e.save(),e.globalAlpha=.06*e.globalAlpha,e.fillStyle=l.color,e.fillRect(l.x,l.y,l.w,l.h),e.restore();e.textBaseline="middle";let s=`${Be(t.numbersSize)}px ${i.fontFamily}`,a=`${Be(t.labelsSize)}px ${i.fontFamily}`;for(let l of o)this.stroke(e,{...t.style,lineColor:l.color},()=>{e.moveTo(l.x1,l.y1),e.lineTo(l.x2,l.y2);}),e.fillStyle=l.color,e.font=s,e.textAlign=l.numberAlign,e.fillText(l.numberText,l.numberX,l.numberY),l.label&&(e.font=a,e.textAlign="center",e.fillText(l.label,l.labelX,l.labelY));e.textAlign="left",e.textBaseline="alphabetic";}paintRadialFib(e,t,n,i){let o=t.radial(n);if(o&&o.R0>=1){let s=`${Be(t.numbersSize)}px ${i.fontFamily}`,a=(o.a0+o.a1)/2;e.textBaseline="middle";for(let l of t.levels){if(!l.enabled)continue;let c=o.R0*l.ratio;c<.5||(this.applyStroke(e,{...t.style,lineColor:l.color}),e.beginPath(),e.arc(o.cx,o.cy,c,o.a0,o.a1),e.stroke(),e.setLineDash([]),e.fillStyle=l.color,e.font=s,e.textAlign="left",e.fillText(String(l.ratio),o.cx+Math.cos(a)*c+3,o.cy+Math.sin(a)*c));}e.textBaseline="alphabetic",e.textAlign="left";}for(let s of t.boundingLines(n))this.stroke(e,t.style,()=>{e.moveTo(s[0],s[1]),e.lineTo(s[2],s[3]);});}paintGannArcs(e,t,n){let i=t.arcGeom(n);if(!i||Math.abs(i.bx)<1||Math.abs(i.py)<1)return;let o=24;for(let s of Lu){this.applyStroke(e,{...t.style,lineColor:s.color}),e.beginPath();for(let a=0;a<=o;a+=1){let l=a/o*(Math.PI/2),c=i.ox+s.k*i.bx*Math.cos(l),u=i.oy+s.k*i.py*Math.sin(l);a===0?e.moveTo(c,u):e.lineTo(c,u);}e.stroke();}e.setLineDash([]);}paintFibSpiral(e,t,n){let i=t.spiralPoints(n);!i||i.length<2||this.stroke(e,t.style,()=>{e.moveTo(i[0][0],i[0][1]);for(let o=1;o<i.length;o+=1)e.lineTo(i[o][0],i[o][1]);});}paintMachFigure(e,t,n,i){let o=t.geom(n);if(o){for(let s of o.circles)this.applyStroke(e,{...t.style,lineColor:s.color}),e.beginPath(),e.arc(s.cx,s.cy,s.r,0,Math.PI*2),e.stroke();this.applyStroke(e,t.style),e.lineWidth=t.style.lineWidth+.5;for(let s of o.rays)e.beginPath(),e.moveTo(s[0],s[1]),e.lineTo(s[2],s[3]),e.stroke();if(e.beginPath(),e.arc(o.noseX,o.noseY,Math.max(2.5,t.style.lineWidth+1.5),0,Math.PI*2),e.fillStyle=t.style.lineColor,e.fill(),e.setLineDash([]),t.showRatios!==false){let s=`${Be("small")}px ${i.fontFamily}`;e.font=s,e.textBaseline="middle",e.textAlign="left";for(let a of o.circles){let l=a.cx+o.fx*a.r+4,c=a.cy+o.fy*a.r;e.fillStyle=a.color,e.fillText(CL(a.ratio),l,c);}e.textBaseline="alphabetic",e.textAlign="left";}}}paintDedekind(e,t,n){let i=t.box(n),o=t.geodesics(n);if(!i||!o)return;let{left:s,right:a,top:l,bot:c}=i;e.save(),this.applyStroke(e,t.style),e.globalAlpha*=.45,e.strokeRect(s,l,a-s,c-l),e.restore(),e.save(),e.beginPath(),e.rect(s,l,a-s,c-l),e.clip(),this.applyStroke(e,t.style);for(let u of o)e.beginPath(),u.kind==="vline"?(e.moveTo(u.x,u.y0),e.lineTo(u.x,u.y1)):e.arc(u.cx,u.cy,u.r,Math.PI,0,false),e.stroke();e.setLineDash([]),e.restore();}paintMeasureBox(e,t,n,i){let o=t.handlePoints(n);if(o.length<2)return;let s=Math.min(o[0][0],o[1][0]),a=Math.min(o[0][1],o[1][1]),l=Math.abs(o[1][0]-o[0][0]),c=Math.abs(o[1][1]-o[0][1]),u=t.isUp()?z:W;e.save(),e.globalAlpha=.12*e.globalAlpha,e.fillStyle=u,e.fillRect(s,a,l,c),e.restore(),e.setLineDash(Kn(t.style.lineStyle,t.style.lineWidth)),e.strokeStyle=u,e.lineWidth=t.style.lineWidth,e.strokeRect(s,a,l,c),e.setLineDash([]);let d=t.measureLabel(n),h=Be(t.text?.size??"normal");e.fillStyle=t.text?.color??i.textColor,e.font=`${h}px ${i.fontFamily}`,e.textAlign="center",e.textBaseline="middle";let p=Math.round(h*1.35),m=a+c/2-(d.length-1)*p/2;d.forEach((f,g)=>e.fillText(f,s+l/2,m+g*p)),e.textAlign="left",e.textBaseline="alphabetic";}paintPosition(e,t,n,i){let o=t.layout(n);if(!o)return;let{x1:s,x2:a,ey:l,sy:c,ty:u}=o,d=a-s,h=(b,y,v)=>{e.save(),e.globalAlpha=.13*e.globalAlpha,e.fillStyle=v,e.fillRect(s,Math.min(b,y),d,Math.abs(y-b)),e.restore();};h(l,u,t.profitColor),h(l,c,t.lossColor);let p=(b,y)=>this.stroke(e,{...t.style,lineColor:y},()=>{e.moveTo(s,b),e.lineTo(a,b);});if(p(u,t.profitColor),p(c,t.lossColor),p(l,t.style.lineColor),!t.showText)return;let m=Be(t.text?.size??"normal");e.fillStyle=t.text?.color??i.textColor,e.textAlign="center",e.textBaseline="middle",e.font=`${m}px ${i.fontFamily}`;let f=s+d/2,g=Math.min(l,c,u)-9;t.showHeader&&e.fillText(t.headerLabel(),f,t.showLossSize?g-Math.round(m*1.15):g),e.font=`${Math.max(10,m-1)}px ${i.fontFamily}`,t.showLossSize&&e.fillText(t.lossSizeLabel(),f,g),t.showTargetLabel&&e.fillText(t.targetLabel(),f,(l+u)/2),t.showStopLabel&&e.fillText(t.stopLabel(),f,(l+c)/2),e.textAlign="left",e.textBaseline="alphabetic";}paintRegressionChannel(e,t,n,i){let o=t.layout(n);if(!o)return;let s=t.reg,a=(c,u,d,h,p)=>{e.save(),e.fillStyle=c,e.beginPath(),e.moveTo(o.x0,u),e.lineTo(o.x1,d),e.lineTo(o.x1,p),e.lineTo(o.x0,h),e.closePath(),e.fill(),e.restore();};a(s.upperFill,o.midY0,o.midY1,o.upperY0,o.upperY1),a(s.lowerFill,o.midY0,o.midY1,o.lowerY0,o.lowerY1);let l=(c,u,d,h)=>this.stroke(e,{lineColor:c,lineWidth:t.style.lineWidth,lineStyle:u},()=>{e.moveTo(o.x0,d),e.lineTo(o.x1,h);});if(l(s.upperColor,s.upperStyle,o.upperY0,o.upperY1),l(s.lowerColor,s.lowerStyle,o.lowerY0,o.lowerY1),l(s.midColor,s.midStyle,o.midY0,o.midY1),o.showR2){let c=`R\xB2 ${Math.round(o.r2*100)}%`;e.font=`11px ${i.fontFamily}`;let u=e.measureText(c).width,d=5,h=4,p=u+d*2,m=o.x0-h-p,f=o.midY0-9;e.save(),e.globalAlpha=.9*e.globalAlpha,Ot(e,m,f-8,p,16,3),e.fillStyle=ww,e.fill(),e.restore(),e.fillStyle=i.textColor,e.textAlign="left",e.textBaseline="middle",e.fillText(c,m+d,f),e.textBaseline="alphabetic";}}paintMagnifierGhost(e,t,n,i){let o=t.rect(n);o&&(e.save(),e.strokeStyle=t.style.lineColor||_e(i.background),e.lineWidth=1,e.setLineDash([4,4]),e.strokeRect(Math.min(o.x1,o.x2),Math.min(o.y1,o.y2),Math.abs(o.x2-o.x1),Math.abs(o.y2-o.y1)),e.restore());}paintMagnifier(e,t,n,i){let o=t.rect(n),s=t.anchors[0],a=t.anchors[1];if(!o||!s||!a)return;let l=Math.min(o.x1,o.x2),c=Math.max(o.x1,o.x2),u=Math.min(o.y1,o.y2),d=Math.max(o.y1,o.y2),h=c-l,p=d-u;e.save(),e.globalAlpha=1,e.fillStyle=i.background,e.fillRect(l,u,h,p),e.restore();let m=Math.min(s.time,a.time),f=Math.max(s.time,a.time),g=n.barsBetween?n.barsBetween(m,f):0,b=g>0?(f-m)/g:0,y=n.seriesInRange&&b>0&&h>1&&p>1?n.seriesInRange(t.magnifier.timeframe,m,f+b):void 0,v=y?.state==="ready"||y?.state==="loading"?y.bars??[]:[];if(y&&(y.state==="ready"||y.state==="loading")&&v.length>0){let S=this.seriesLook,E=S.style!=="candles"?Zr(S.style):null;E&&(v=E.full(v));let T=S.style==="bars"?"bars":S.style==="line"||S.style==="baseline"?"line":S.style==="area"?"area":"candles",k=(n.xOf(m+b)-n.xOf(m))/2;e.save(),e.beginPath(),e.rect(l,u,h,p),e.clip(),T==="line"||T==="area"?this.paintMagnifierLine(e,t,n,v,y.barMs,k,d,T==="area",t.magnifier.upColor||S.lineColor):this.paintMagnifierBars(e,t,n,v,y.barMs,k,l,c,T,t.magnifier.upColor||S.upColor,t.magnifier.downColor||S.downColor),e.restore();}else if(y){let S=y.state==="loading"?"Loading\u2026":y.state==="ready"?"No lower-timeframe data":y.reason==="too-wide"?"Area too wide for this timeframe":y.reason==="none-lower"?"No lower timeframe available":y.reason==="not-lower"?"Pick a timeframe below the chart":"No data source";this.paintMagnifierNotice(e,S,l,u,h,p,i);}if(e.save(),e.strokeStyle=t.style.lineColor||_e(i.background),e.lineWidth=t.style.lineWidth||1,e.setLineDash(Kn(t.style.lineStyle,t.style.lineWidth||1)),e.strokeRect(l,u,h,p),e.restore(),h>44){let S=eo(y?.state==="ready"||y?.state==="loading"?y.timeframe:t.magnifier.timeframe),E=17,T=4,k=n.paneRect?.(t.paneId),x=k?k.top+k.height:n.height,w=d+T+E<=x?d+T:d-T-E;e.save(),e.font=`10px ${i.fontFamily}`;let L=e.measureText(S).width,C=L+12+11;Ot(e,l,w,C,E,3),e.fillStyle=i.background,e.fill(),e.strokeStyle=q(i.textColor,.28),e.lineWidth=1,e.setLineDash([]),e.stroke(),e.fillStyle=i.textColor,e.textAlign="left",e.textBaseline="middle",e.fillText(S,l+6,w+E/2+.5);let A=l+6+L+5,$=w+E/2;e.strokeStyle=q(i.textColor,.7),e.lineWidth=1.2,e.beginPath(),e.moveTo(A,$-1.5),e.lineTo(A+2.5,$+1.5),e.lineTo(A+5,$-1.5),e.stroke(),e.restore(),t.chipRect={x:l,y:w,w:C,h:E};}else t.chipRect=null;}paintMagnifierBars(e,t,n,i,o,s,a,l,c,u,d){e.setLineDash([]),e.lineWidth=1;for(let h of i){let p=n.xOf(h.time)-s,m=n.xOf(h.time+o)-s;if(m<a||p>l)continue;let f=n.yOf(h.high,t.paneId),g=n.yOf(h.low,t.paneId),b=n.yOf(h.open,t.paneId),y=n.yOf(h.close,t.paneId);if(f==null||g==null||b==null||y==null)continue;let v=h.close>=h.open?u:d,S=m-p,E=(p+m)/2;if(e.strokeStyle=v,e.beginPath(),e.moveTo(E,f),e.lineTo(E,g),e.stroke(),!(S<3))if(c==="bars"){let T=Math.max(1,S*.35);e.beginPath(),e.moveTo(E-T,b),e.lineTo(E,b),e.moveTo(E,y),e.lineTo(E+T,y),e.stroke();}else {let T=Math.max(1,S*.7);e.fillStyle=v,e.fillRect(E-T/2,Math.min(b,y),T,Math.max(1,Math.abs(y-b)));}}}paintMagnifierLine(e,t,n,i,o,s,a,l,c){let u=[];for(let d of i){let h=n.yOf(d.close,t.paneId);h!=null&&u.push([n.xOf(d.time+o/2)-s,h]);}if(!(u.length<2)){if(l){e.beginPath(),e.moveTo(u[0][0],a);for(let[d,h]of u)e.lineTo(d,h);e.lineTo(u[u.length-1][0],a),e.closePath(),e.fillStyle=q(c,.15),e.fill();}e.setLineDash([]),e.lineWidth=1.5,e.strokeStyle=c,e.beginPath(),e.moveTo(u[0][0],u[0][1]);for(let d=1;d<u.length;d+=1)e.lineTo(u[d][0],u[d][1]);e.stroke();}}paintMagnifierNotice(e,t,n,i,o,s,a){o<60||s<20||(e.save(),e.beginPath(),e.rect(n,i,o,s),e.clip(),e.font=`11px ${a.fontFamily}`,e.fillStyle=q(a.textColor,.55),e.textAlign="center",e.textBaseline="middle",e.fillText(t,n+o/2,i+s/2),e.restore());}paintPlacementHint(e,t,n,i,o){e.save(),e.font=`11px ${n.fontFamily}`;let a=e.measureText(t).width+24,l=24,c=(i-a)/2,u=o-l-14;Ot(e,c,u,a,l,l/2),e.fillStyle=n.background,e.fill(),e.strokeStyle=q(n.textColor,.28),e.lineWidth=1,e.setLineDash([]),e.stroke(),e.fillStyle=n.textColor,e.textAlign="center",e.textBaseline="middle",e.fillText(t,i/2,u+l/2+.5),e.restore();}paintFixedRangeVp(e,t,n,i){let o=t.layout(n);if(!o)return;let s=t.frvp,{profile:a,maxW:l,anchorX:c,grow:u,yEdges:d}=o;if(a.maxTotal<=0||l<=0)return;for(let f=0;f<a.rows.length;f+=1){let g=a.rows[f],b=g.up+g.down;if(b<=0)continue;let y=d[f],v=d[f+1],S=Math.min(y,v),E=Math.max(1,Math.abs(v-y)-1),T=b/a.maxTotal*l,k=g.up/b*T,x=f>=a.vaFrom&&f<=a.vaTo,M=x?s.vaUpColor:s.upColor,w=x?s.vaDownColor:s.downColor,L=u===1?c:c-T;k>0&&(e.fillStyle=M,e.fillRect(L,S,k,E)),T-k>0&&(e.fillStyle=w,e.fillRect(L+k,S,T-k,E));}let h=t.style.lineWidth,p=(f,g,b,y)=>{!f||y==null||Sw(g)||this.stroke(e,{lineColor:g,lineWidth:h,lineStyle:b},()=>{e.moveTo(o.x0,y),e.lineTo(o.x1,y);});};p(s.showVah,s.vahColor,s.vahStyle,o.vahY),p(s.showVal,s.valColor,s.valStyle,o.valY),p(s.showPoc,s.pocColor??_e(i.background),s.pocStyle,o.pocY);let m=Math.max(1,h);if(s.showDevelopingPoc&&this.strokePolyline(e,o.developingPoc,{lineColor:s.developingPocColor,lineWidth:m,lineStyle:s.developingPocStyle}),s.showDevelopingVa){let f={lineColor:s.developingVaColor,lineWidth:m,lineStyle:s.developingVaStyle};this.strokePolyline(e,o.developingVaHigh,f),this.strokePolyline(e,o.developingVaLow,f);}}paintAnchoredVwap(e,t,n){let i=t.layout(n);if(!i)return;let o=t.vwap,s=t.style.lineWidth;if(i.upper.length>=2&&o.bandFill){e.save(),e.fillStyle=o.bandFill,e.beginPath(),e.moveTo(i.upper[0][0],i.upper[0][1]);for(let a=1;a<i.upper.length;a+=1)e.lineTo(i.upper[a][0],i.upper[a][1]);for(let a=i.lower.length-1;a>=0;a-=1)e.lineTo(i.lower[a][0],i.lower[a][1]);e.closePath(),e.fill(),e.restore();}this.strokePolyline(e,i.upper,{lineColor:o.upperColor,lineWidth:s,lineStyle:o.upperStyle}),this.strokePolyline(e,i.lower,{lineColor:o.lowerColor,lineWidth:s,lineStyle:o.lowerStyle}),this.strokePolyline(e,i.mid,{lineColor:o.midColor,lineWidth:s,lineStyle:o.midStyle});}strokePolyline(e,t,n){t.length<2||Sw(n.lineColor)||this.stroke(e,n,()=>{e.moveTo(t[0][0],t[0][1]);for(let i=1;i<t.length;i+=1)e.lineTo(t[i][0],t[i][1]);});}paintCallout(e,t,n,i){this.paintBubble(e,t,n,i,5);}paintComment(e,t,n,i){this.paintBubble(e,t,n,i,999);}paintBubble(e,t,n,i,o){let s=t.points(n);if(!s)return;let a=s[0][0],l=s[0][1],c=s[1][0],u=s[1][1],d=t.text,h=Be(d?.size??"normal");e.font=`${d?.bold?"bold ":""}${d?.italic?"italic ":""}${h}px ${i.fontFamily}`;let p=(d?.value??"").split(`
|
|
900
|
-
`),m=Math.max(8,...p.map(P=>e.measureText(P).width)),f=9,g=6,b=
|
|
901
|
-
`),l=Math.max(8,...a.map(c=>e.measureText(c).width));return {lines:a,tw:l,fs:s,lh:
|
|
902
|
-
`).length,o=rn(Be(t.size));switch(r.type){case "text":return n[0]?{x:n[0][0]+2,top:n[0][1]+2,align:"left"}:null;case "hline":return n[0]?{x:n[0][0]+8,top:n[0][1]-4-o*i,align:"left"}:null;case "trendline":case "ray":case "extendedline":case "infoline":case "trendangle":{if(n.length<2)return null;let[s,a]=n[0],[l,c]=n[1];return {x:0,top:-6-o*i,align:"center",rotate:{angle:Ky(s,a,l,c),cx:(s+l)/2,cy:(a+c)/2}}}case "box":return n.length<2?null:{x:(n[0][0]+n[1][0])/2,top:(n[0][1]+n[1][1])/2-o*i/2,align:"center"};default:return n[0]?{x:n[0][0],top:n[0][1],align:"left"}:null}}function Vi(r,e,t,n,i=6){for(let o=r.length-1;o>=0;o-=1){let s=r[o];if(!s.visible)continue;let a=n.paneRect?.(s.paneId);if(!(a&&a.height<=0)&&s.hitTest(e,t,n,i))return s}return null}function Oh(r,e){let t=[...r];return t.length<2?t:t.filter(n=>!e.find(i=>i.id===n)?.locked)}function kw(r,e,t,n){return n&&e.size>=2&&e.has(r.id)?Oh(e,t):r.locked?[]:[r.id]}var zc=3,kL=4,Ew=Math.PI/4,Mw=new Set(["trendline","ray","extendedline","infoline","trendangle","arrow"]),$c=class{constructor(e){this.deps=e;this.state={kind:"idle"};this.snapAt=null;}snapMarker(){return this.snapAt}placingMarkers(e){if(this.state.kind!=="placing")return null;let{draft:t}=this.state;if(t.placementMode()==="freehand")return null;let n=[];for(let i of t.anchors){let o=e.yOf(i.price,t.paneId);o!=null&&n.push([e.xOf(i.time),o]);}return n.length?n:null}resolve(e,t,n,i){let o=this.deps.projector().pxToPoint(e,t,n);if(i==="off")return this.snapAt=null,o;let s=this.deps.snap(o,n,i,{x:e,y:t}),a=s.time!==o.time||s.price!==o.price;return this.snapAt=a?{point:s,paneId:n}:null,s}snapCursor(e,t,n){let i=this.deps.projector(),o=i.paneIdAtY(t)??"price",s=this.resolve(e,t,o,n),a=i.yOf(s.price,o);return {x:i.xOf(s.time),y:a??t}}clearSnapMarker(){this.snapAt=null;}resolveAngleSnapped(e,t,n,i){let o=this.deps.projector(),s=o.xOf(e.time),a=o.yOf(e.price,t);if(this.snapAt=null,a==null)return o.pxToPoint(n,i,t);let l=Math.hypot(n-s,i-a);if(l<1)return o.pxToPoint(n,i,t);let c=Math.round(Math.atan2(i-a,n-s)/Ew)*Ew;return o.pxToPoint(s+l*Math.cos(c),a+l*Math.sin(c),t)}placingPivot(e){return Mw.has(e.type)?e.anchors[e.anchors.length-1]??null:null}claim(e,t){return this.deps.activeTool()!=null||this.state.kind!=="idle"?true:this.hitAt(e,t)!=null}cursorAt(e,t){return this.deps.activeTool()!=null?null:this.hitAt(e,t)?"pointer":null}isPlacing(){return this.state.kind==="placing"}isDragging(){return this.state.kind==="pressed"&&this.state.moved}activeDragId(){return this.state.kind==="pressed"&&this.state.moved?this.state.id:null}pressedId(){return this.state.kind==="pressed"?this.state.id:null}dragClones(){return this.state.kind==="pressed"&&this.state.moved&&this.state.clones?this.state.clones.map(e=>e.d):null}marqueeRect(){if(this.state.kind!=="marquee")return null;let{x0:e,y0:t,x1:n,y1:i}=this.state;return {x:Math.min(e,n),y:Math.min(t,i),w:Math.abs(n-e),h:Math.abs(i-t)}}beginMarquee(e,t){return this.state.kind!=="idle"||this.deps.activeTool()!=null?false:(this.state={kind:"marquee",x0:e,y0:t,x1:e,y1:t},true)}down(e,t,n="off",i=false,o=false){let s=this.deps.projector();if(this.state.kind==="placing"){if(this.state.draft.placementMode()!=="click")return;let c=i?this.placingPivot(this.state.draft):null,u=c?this.resolveAngleSnapped(c,this.state.draft.paneId,e,t):this.resolve(e,t,this.state.draft.paneId,n);this.state.draft.anchors.push(this.placementAnchor(this.state.draft,u)),this.state.draft.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let a=this.deps.activeTool();if(a){let c=s.paneIdAtY(t)??"price",u=Dn(a,{paneId:c,anchors:[this.resolve(e,t,c,n)],style:this.deps.lastStyle()});if(!u)return;this.state={kind:"placing",draft:u,need:u.anchorSchema().max,cursor:null},u.placementMode()==="click"&&u.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let l=this.hitAt(e,t);if(l){if(i){this.deps.emit({kind:"select",ids:[l.id],additive:true});return}let c=l.hitHandle(e,t,s,6),u=[];if(c<0&&this.deps.selectedIds().has(l.id))for(let d of this.deps.selectedIds()){let h=d===l.id?null:this.byId(d);h&&!h.locked&&h.visible&&u.push({id:d,orig:Nh(h)});}this.state={kind:"pressed",id:l.id,handle:c,orig:Nh(l),px:e,py:t,moved:false,riders:u,mod:o,clones:null};}}bodyDelta(e,t,n){if(this.state.kind!=="pressed")return {dt:0,dp:0};let i=this.deps.projector(),o=i.pxToPoint(this.state.px,this.state.py,e),s=i.pxToPoint(t,n,e);return {dt:s.time-o.time,dp:s.price-o.price}}dragSources(e){if(this.state.kind!=="pressed")return [];let t=[{d:e,orig:this.state.orig}];for(let n of this.state.riders){let i=this.byId(n.id);i&&t.push({d:i,orig:n.orig});}return t}dragBody(e,t,n){if(this.state.kind==="pressed"){this.snapAt=null,this.state.mod&&!this.state.clones&&(this.state.clones=this.dragSources(e).flatMap(i=>{let o=pt(i.d.serialize());return o?[{d:o,orig:Nh(o)}]:[]}));for(let i of this.state.clones??this.dragSources(e)){let{dt:o,dp:s}=this.bodyDelta(i.d.paneId,t,n);i.d.anchors=i.d.translateBody(o,s,i.orig);}}}move(e,t,n="off",i=false){if(this.state.kind==="idle"){let s=this.deps.activeTool(),a=this.snapAt!=null;s&&n!=="off"?this.resolve(e,t,this.deps.projector().paneIdAtY(t)??"price",n):this.snapAt=null,(this.snapAt!=null||a)&&this.deps.changed();return}if(this.state.kind==="placing"){if(this.state.draft.placementMode()==="freehand"){this.captureFreehand(e,t);return}let s=i?this.placingPivot(this.state.draft):null;this.state.cursor=s?this.resolveAngleSnapped(s,this.state.draft.paneId,e,t):this.resolve(e,t,this.state.draft.paneId,n),this.deps.changed();return}if(this.state.kind==="marquee"){this.state.x1=e,this.state.y1=t,this.deps.changed();return}if(this.state.kind!=="pressed")return;let o=this.byId(this.state.id);if(!(!o||o.locked)&&!(!this.state.moved&&Math.abs(e-this.state.px)<=zc&&Math.abs(t-this.state.py)<=zc)){if(this.state.moved=true,this.state.handle<0)this.dragBody(o,e,t);else {let s=o.anchors[this.state.handle];if(s){let a=i&&Mw.has(o.type)&&o.anchors.length===2?o.anchors[1-this.state.handle]:void 0,l=a?this.resolveAngleSnapped(a,o.paneId,e,t):this.resolve(e,t,o.paneId,n);ML(s,l,o.anchorSchema().slots[this.state.handle]?.free??"both");}o.constrainHandleDrag(this.state.handle);}this.deps.changed();}}up(e,t){if(this.snapAt=null,this.state.kind==="placing"){let c=this.state.draft.placementMode();c==="drag"?(this.state.cursor&&this.state.draft.anchors.push(this.state.cursor),this.state.draft.anchors.length>=this.state.draft.anchorSchema().min?this.finalize():this.discardPlacing()):c==="freehand"&&(this.state.draft.anchors.length>=this.state.draft.anchorSchema().min?this.finalize():this.discardPlacing());return}if(this.state.kind==="marquee"){let c=this.marqueeRect();this.state={kind:"idle"},(c.w>zc||c.h>zc)&&this.selectWithin(c),this.deps.changed();return}if(this.state.kind!=="pressed")return;let{id:n,moved:i,riders:o,mod:s,clones:a}=this.state;this.state={kind:"idle"};let l=this.byId(n);if(!i){s?this.deps.emit({kind:"select",ids:[n],additive:true}):this.deps.openSettings(n,e,t);return}if(a)this.deps.emit({kind:"clone",docs:a.map(c=>c.d.serialize())});else if(l){let c=[l.serialize()];for(let u of o){let d=this.byId(u.id);d&&c.push(d.serialize());}c.length>1?this.deps.emit({kind:"edit-many",docs:c}):this.deps.emit({kind:"edit",doc:c[0]});}this.deps.changed();}selectWithin(e){let t=this.deps.projector(),n=[...this.deps.selectedIds()];for(let i of this.deps.drawings()){if(!i.visible||n.includes(i.id))continue;let o=i.bounds(t);o&&EL(e,o)&&n.push(i.id);}n.length>this.deps.selectedIds().size&&this.deps.emit({kind:"select",ids:n});}cancel(){if(this.snapAt=null,this.state.kind==="placing"){let e=this.state.draft.type;return this.state={kind:"idle"},this.deps.emit({kind:"tool-finished",type:e}),this.deps.changed(),true}if(this.state.kind==="pressed"){if(this.state.moved&&!this.state.clones){let e=this.byId(this.state.id);if(e)for(let t of this.dragSources(e))t.d.anchors=t.orig.map(n=>({time:n.time,price:n.price}));}return this.state={kind:"idle"},this.deps.changed(),true}return this.state.kind==="marquee"?(this.state={kind:"idle"},this.deps.changed(),true):false}onToolCleared(){this.state.kind==="placing"&&(this.state={kind:"idle"},this.deps.changed());}ghost(){if(this.state.kind!=="placing")return null;let{draft:e,cursor:t}=this.state;return t?Dn(e.type,{paneId:e.paneId,anchors:[...e.anchors,this.placementAnchor(e,t)],style:e.style}):e.anchors.length>=1&&e.type==="hline"?e:null}placementAnchor(e,t){if(e.type!=="parallelchannel"||e.anchors.length!==2)return t;let n=e.anchors[0],i=e.anchors[1],o=i.time-n.time,s=o===0?n.price:n.price+(i.price-n.price)*(t.time-n.time)/o,a=t.price-s;return {time:(n.time+i.time)/2,price:(n.price+i.price)/2+a}}captureFreehand(e,t){if(this.state.kind!=="placing")return;this.snapAt=null;let n=this.state.draft,i=this.deps.projector(),o=n.anchors[n.anchors.length-1],s=o?i.xOf(o.time):NaN,a=o?i.yOf(o.price,n.paneId)??NaN:NaN;if(Math.hypot(e-s,t-a)>kL){if(n.anchors.length>=this.state.need){let l=n.anchors.length-1;n.anchors=n.anchors.filter((c,u)=>u%2===0||u===l);}n.anchors.push(i.pxToPoint(e,t,n.paneId));}this.state.cursor=i.pxToPoint(e,t,n.paneId),this.deps.changed();}finishPlacing(e){if(this.state.kind!=="placing")return false;let t=this.state.draft,n=t.anchorSchema();return t.placementMode()!=="click"||n.max<=n.min||(e&&t.anchors.length>n.min&&t.anchors.pop(),t.anchors.length<n.min)?false:(this.finalize(),true)}discardPlacing(){if(this.state.kind!=="placing")return;let e=this.state.draft.type;this.state={kind:"idle"},this.deps.emit({kind:"tool-finished",type:e}),this.deps.changed();}finalize(){if(this.state.kind!=="placing")return;this.snapAt=null;let e=this.state.draft;e.onPlaced(this.deps.projector());let t=e.type;this.state={kind:"idle"},this.deps.emit({kind:"create",doc:e.serialize()}),this.deps.emit({kind:"tool-finished",type:t}),this.deps.changed();}hitAt(e,t){let n=this.deps.projector();for(let i of this.handleDrawings())if(i.hitHandle(e,t,n,6)>=0)return i;return Vi(this.deps.drawings(),e,t,n,6)}handleDrawings(){let e=new Set(this.deps.selectedIds()),t=this.deps.hoveredId();t&&e.add(t);let n=[];for(let i of e){let o=this.byId(i);o&&n.push(o);}return n}byId(e){return this.deps.drawings().find(t=>t.id===e)??null}};function Nh(r){return r.anchors.map(e=>({time:e.time,price:e.price}))}function EL(r,e){return r.x<=e.x+e.w&&e.x<=r.x+r.w&&r.y<=e.y+e.h&&e.y<=r.y+r.h}function ML(r,e,t){(t==="both"||t==="x")&&(r.time=e.time),(t==="both"||t==="y")&&(r.price=e.price);}var LL=[{value:"price",label:"Price"},{value:"points",label:"Points"}],PL=[{value:"right",label:"Right"},{value:"left",label:"Left"}],IL={position:"Position size",frvp:"Volume profile",levels:"Levels"},Wc=class{constructor(e,t){this.host=e;this.ui=null;this.theme=t;}setTheme(e){this.theme=e;}isOpen(){return this.ui!=null}contains(e){return this.ui?.contains(e)===true}open(e,t,n){this.close();let i=$t(e.serialize()),o=ts({variant:"inputs"});if(o.style.padding="16px 20px",o.style.overflowY="auto",o.style.overflowX="hidden",o.style.flex="1 1 auto",n==="position"&&e instanceof ht)this.buildPosition(o,e,t);else if(n==="frvp"&&e instanceof at)this.buildFrvp(o,e,t);else if(n==="levels")this.buildLevels(o,e,t);else return;let s=new yn({host:this.host,title:IL[n],modal:false,contained:true,align:"center",draggable:true,flush:true,className:"vela-dialog--form",closeOnEscape:false,footer:l=>{l.append(Lw("Cancel",false,()=>{t.restore?.(i),this.close();}),Lw("Ok",true,()=>this.close()));},onOpenChange:l=>{l||this.close();}});Re(s.panel,this.theme),s.body.appendChild(o);let a=l=>{if(!(l.target!==s.backdrop&&l.target!==s.positioner)){if(en()||Pr(l)){Te();return}this.close();}};s.backdrop.addEventListener("pointerdown",a),s.positioner.addEventListener("pointerdown",a),s.panel.addEventListener("keydown",l=>{l.key==="Escape"&&(l.preventDefault(),t.restore?.(i),this.close());}),this.ui=s,s.show();}close(){let e=this.ui;this.ui=null,e?.destroy();}destroy(){this.close();}buildPosition(e,t,n){let i=()=>{let p=n.resolve();return p instanceof ht?p:t},o=[],s=()=>o.forEach(p=>p()),a=p=>Math.round(p*1e8)/1e8,l=(p,m,f)=>{let g=se({kind:"number",value:a(i()[m]),min:f?.min,max:f?.max,step:f?.step,integer:f?.integer,fill:false,commit:"blur",onChange:b=>{n.patch({[m]:b}),s();}});o.push(()=>{document.activeElement!==g.el.querySelector("input")&&g.setValue?.(a(i()[m]));}),e.appendChild(Ae({label:p,control:g.el}));},c=(p,m,f)=>{let g="price",b=()=>a(i().levelDisplayValue(f,g)),y=se({kind:"number",value:b(),fill:false,commit:"blur",onChange:S=>{n.patch({[m]:i().levelPriceFromDisplay(f,g,S)}),s();}}),v=se({kind:"select",options:LL,value:g,fill:false,theme:this.theme,onChange:S=>{g=S,y.setValue?.(b());}});o.push(()=>{document.activeElement!==y.el.querySelector("input")&&y.setValue?.(b());}),e.appendChild(Ae({label:p,control:[y.el,v.el]}));};e.appendChild(wn("Account",{variant:"inputs",first:true})),l("Risk %","riskPercent",{min:0,max:100,step:.1}),l("Account balance","accountBalance",{min:0,max:1e12,step:1,integer:true}),l("Position size","quantity"),e.appendChild(wn("Levels",{variant:"inputs"}));let u=se({kind:"select",options:Ua,value:i().direction,fill:false,theme:this.theme,onChange:p=>{n.patch({direction:p}),s();}});o.push(()=>u.setValue?.(i().direction)),e.appendChild(Ae({label:"Direction",control:u.el})),l("Entry price","entryPrice"),c("Stop","stopPrice","stop"),c("Target","targetPrice","target"),e.appendChild(wn("Display",{variant:"inputs"}));let d=[["Show text","showText"],["Show direction & ratio","showHeader"],["Show loss & size","showLossSize"],["Show target label","showTargetLabel"],["Show stop label","showStopLabel"],["Show level prices","showPrices"]];for(let[p,m]of d)e.appendChild(Ae({label:p,bool:true,toggle:{checked:i()[m],onChange:f=>{n.patch({[m]:f}),s();},get:()=>i()[m]}}));let h=document.createElement("div");h.className="vela-field-span",h.style.cssText="opacity:0.7;font-size:11px;line-height:1.4;border-top:1px solid var(--vela-border);padding-top:6px;font-variant-numeric:tabular-nums;",o.push(()=>{let p=i();h.textContent=`${p.headerLabel()} \u2014 ${p.lossSizeLabel()}`;}),e.appendChild(h),s();}buildFrvp(e,t,n){let i=()=>{let u=n.resolve();return u instanceof at?u.frvp:t.frvp},o=i(),s=(u,d,h,p,m,f=true)=>{e.appendChild(Ae({label:u,control:se({kind:"number",value:o[d],min:h,max:p,step:m,integer:f,fill:false,commit:"blur",onChange:g=>n.patch({[`frvp.${d}`]:g})}).el}));};s("Rows","rows",1,500,1),s("Value Area","valueAreaPct",0,100,1),s("Width %","widthPct",0,100,1),e.appendChild(Ae({label:"Anchor",control:se({kind:"select",options:PL,value:o.anchor,fill:false,theme:this.theme,onChange:u=>n.patch({"frvp.anchor":u})}).el}));let a=(u,d)=>{e.appendChild(Ae({label:u,fit:true,control:se({kind:"color",theme:this.theme,get:()=>i()[d],onChange:h=>n.patch({[`frvp.${d}`]:h})}).el}));};a("Up Volume","upColor"),a("Down Volume","downColor"),a("Value Area Up","vaUpColor"),a("Value Area Down","vaDownColor");let l=Xe.map(u=>({value:u.value,label:u.label})),c=(u,d,h,p)=>{let m=document.createElement("div");m.className="vela-field-span",m.style.cssText="display:flex;align-items:center;gap:8px;";let f=se({kind:"switch",checked:!!o[d],onChange:S=>n.patch({[`frvp.${d}`]:S})}),g=document.createElement("span");g.className="vela-field-label",g.style.flex="1",g.textContent=u;let b=o[h]??_e(this.theme.background),y=se({kind:"color",theme:this.theme,get:()=>b,onChange:S=>{b=S,n.patch({[`frvp.${h}`]:S});}}),v=se({kind:"select",options:l,value:o[p],fill:false,theme:this.theme,onChange:S=>n.patch({[`frvp.${p}`]:S})});m.append(f.el,g,y.el,v.el),e.appendChild(m);};c("VAH","showVah","vahColor","vahStyle"),c("VAL","showVal","valColor","valStyle"),c("POC","showPoc","pocColor","pocStyle"),c("Developing POC","showDevelopingPoc","developingPocColor","developingPocStyle"),c("Developing VA","showDevelopingVa","developingVaColor","developingVaStyle");}buildLevels(e,t,n){let i=t.editableLevels();if(!i)return;let o=t instanceof Qe;if(o){let s=t;e.appendChild(Ae({label:"Show ratio labels",bool:true,toggle:{checked:s.showRatios!==false,onChange:a=>n.patch({showRatios:a})}}));}i.forEach((s,a)=>{let l=document.createElement("div");l.className="vela-field-span",l.style.cssText="display:flex;align-items:center;gap:8px;";let c=se({kind:"switch",checked:s.enabled,onChange:m=>n.patch({[`levels.${a}.enabled`]:m})}),u=s.color,d=se({kind:"color",theme:this.theme,get:()=>u,onChange:m=>{u=m,n.patch({[`levels.${a}.color`]:m});}}),h=s.ratio,p=se({kind:"number",value:h,min:0,step:.01,fill:o,compact:!o,commit:"blur",onChange:m=>{if(m<=0){p.setValue?.(h);return}h=m,n.patch({[`levels.${a}.ratio`]:m});}});if(o&&(p.el.style.flex="1"),l.append(c.el,d.el,p.el),!o){let m=se({kind:"text",value:s.label??"",fill:true,placeholder:"label\u2026",onChange:f=>n.patch({[`levels.${a}.label`]:f})});m.el.style.flex="1",m.el.style.minWidth="60px",l.appendChild(m.el);}e.appendChild(l);});}};function Lw(r,e,t){let n=document.createElement("button");return n.type="button",n.textContent=r,n.className=e?"vela-dialog-btn vela-dialog-btn-primary":"vela-dialog-btn",n.addEventListener("click",t),n}var Nt=Symbol("mixed");function AL(r){let[e,...t]=r,n=new Set(e?.schema().fields.map(i=>i.path)??[]);for(let i of t){let o=new Set(i.schema().fields.map(s=>s.path));for(let s of n)o.has(s)||n.delete(s);}return n}function RL(r,e){let t=e(r[0]);return r.every(n=>e(n)===t)?t:Nt}function DL(r,e){return [...new Set(r.map(e))]}var qn=30,OL=21,Pw="vela-drawing-popup-styles",Iw="4";function Aw(){if(typeof document>"u")return;let r=document.getElementById(Pw);if(r?.dataset.rev===Iw)return;let e=r??document.createElement("style");e.id=Pw,e.dataset.rev=Iw,e.textContent=`
|
|
898
|
+
.vela-sd-mobile .vela-select:not([data-fill]){width:auto;min-width:100px;max-width:min(220px,55vw);}`,r||document.head.appendChild(e);}var vs=class{constructor(e,t){this.container=e;this.theme=t;this.root=null;this.ui=null;this.onChange=null;this.onImport=null;this.onReset=null;this.config=null;this.syncTypeTabs=null;this.hostSections=[];this.markGroups=[];this.markGroupVisible=()=>true;this.themeControl=null;this.tabs=[];this.hintTips=[];this.typeActiveInstance=new Map;this.typeActiveGroup=new Map;this.activeSection=null;this.mobileLayout=false;this.hiddenSettings=new Set;getComputedStyle(e).position==="static"&&(e.style.position="relative");}setHostSections(e){this.hostSections=e;}setMarkGroups(e,t){this.markGroups=e,this.markGroupVisible=t;}setHiddenSettings(e){let t=new Set(e),n=t.size===this.hiddenSettings.size&&[...t].every(i=>this.hiddenSettings.has(i));this.hiddenSettings=t,n||this.reopenIfLive();}setThemeControl(e,t){this.themeControl={current:e,onSelect:t};}refreshConfig(e){this.config&&(this.config=e);}setTheme(e){this.theme=e,this.reopenIfLive();}setLayoutMode(e){let t=e==="mobile";t!==this.mobileLayout&&(this.mobileLayout=t,this.reopenIfLive());}reopenIfLive(){if(!this.root)return;let e=this.config,t=this.onChange,n=this.onImport,i=this.onReset,o=this.activeSection;this.close(),e&&t&&this.open(e,t,n??void 0,i??void 0,o??void 0);}isOpen(){return this.root!==null}toggle(e,t,n,i,o){this.root?this.close():this.open(e,t,n,i,o);}showSection(e){this.tabs.find(t=>t.title.toLowerCase()===e.toLowerCase())?.show();}open(e,t,n,i,o){this.close(),this.config=e,this.onChange=t,this.onImport=n??null,this.onReset=i??null,SM();let s=this.mobileLayout,a=null,l;s&&(l=document.createElement("button"),l.type="button",l.className="vela-sd-burger",l.innerHTML=ye("burger",16),l.title="Sections",l.addEventListener("click",()=>a?.()));let c=document.createElement("div");c.style.cssText="display:flex;flex-direction:column;gap:0;";let u=(C,A)=>(C.dataset.sdId=A,C);c.append(u(this.section("Symbol"),"symbol")),c.append(u(this.sectionTitle("Chart type"),"symbol.type"));let d={},h=C=>{let A=C==="heikinashi"?"candles":C;for(let $ of Pi())d[$]?.classList.toggle("vela-sd-hide",$!==A);};c.append(u(this.selectRowLabeled("Type",e.series.style,Pi().map(C=>[C,wM(C)]),C=>{this.emit({series:{style:C}}),h(C),this.syncTypeTabs?.(C);}),"symbol.type"));let p=u(this.group(),"symbol.style.candles");p.append(this.sectionTitle("Candles")),p.append(u(this.toggleRow("Body",e.candles.bodyVisible,C=>this.emit({candles:{bodyVisible:C}}),[this.swatch(e.candles.upColor,C=>this.emit({candles:{upColor:C}})),this.swatch(e.candles.downColor,C=>this.emit({candles:{downColor:C}}))]),"symbol.style.candles.body")),p.append(u(this.toggleRow("Borders",e.candles.borderVisible,C=>this.emit({candles:{borderVisible:C}}),[this.swatch(e.candles.borderUpColor,C=>this.emit({candles:{borderUpColor:C}})),this.swatch(e.candles.borderDownColor,C=>this.emit({candles:{borderDownColor:C}}))]),"symbol.style.candles.borders")),p.append(u(this.toggleRow("Wick",e.candles.wickVisible,C=>this.emit({candles:{wickVisible:C}}),[this.swatch(e.candles.wickUpColor,C=>this.emit({candles:{wickUpColor:C}})),this.swatch(e.candles.wickDownColor,C=>this.emit({candles:{wickDownColor:C}}))]),"symbol.style.candles.wick")),p.append(u(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.candles.spacing")),d.candles=p,c.append(p);let m=u(this.group(),"symbol.style.bars");m.append(this.sectionTitle("Bars")),m.append(u(this.colorRow("Color Up",e.bars.upColor,C=>this.emit({bars:{upColor:C}})),"symbol.style.bars.up-color")),m.append(u(this.colorRow("Color Down",e.bars.downColor,C=>this.emit({bars:{downColor:C}})),"symbol.style.bars.down-color")),m.append(u(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.bars.spacing")),d.bars=m,c.append(m);let f=u(this.group(),"symbol.style.line");f.append(this.sectionTitle("Line")),f.append(u(this.colorRow("Color",e.line.color,C=>this.emit({line:{color:C}})),"symbol.style.line.color")),f.append(u(this.numberRow("Width",e.line.width,1,10,1,C=>this.emit({line:{width:C}})),"symbol.style.line.width")),d.line=f,c.append(f);let g=u(this.group(),"symbol.style.area");g.append(this.sectionTitle("Area")),g.append(u(this.colorRow("Line color",e.area.lineColor,C=>this.emit({area:{lineColor:C}})),"symbol.style.area.line-color")),g.append(u(this.numberRow("Width",e.area.width,1,10,1,C=>this.emit({area:{width:C}})),"symbol.style.area.width")),g.append(u(this.colorRow("Top fill",e.area.topColor,C=>this.emit({area:{topColor:C}})),"symbol.style.area.top-fill")),g.append(u(this.colorRow("Bottom fill",e.area.bottomColor,C=>this.emit({area:{bottomColor:C}})),"symbol.style.area.bottom-fill")),d.area=g,c.append(g);let b=u(this.group(),"symbol.style.baseline");b.append(this.sectionTitle("Baseline")),b.append(u(this.rowWith("Top line",[this.swatch(e.baseline.topLineColor,C=>this.emit({baseline:{topLineColor:C}}))]),"symbol.style.baseline.top-line")),b.append(u(this.rowWith("Bottom line",[this.swatch(e.baseline.bottomLineColor,C=>this.emit({baseline:{bottomLineColor:C}}))]),"symbol.style.baseline.bottom-line")),b.append(u(this.rowWith("Fill top area",[this.swatch(e.baseline.topFillColor,C=>this.emit({baseline:{topFillColor:C}})),this.swatch(e.baseline.topFillColor2,C=>this.emit({baseline:{topFillColor2:C}}))]),"symbol.style.baseline.fill-top")),b.append(u(this.rowWith("Fill bottom area",[this.swatch(e.baseline.bottomFillColor2,C=>this.emit({baseline:{bottomFillColor2:C}})),this.swatch(e.baseline.bottomFillColor,C=>this.emit({baseline:{bottomFillColor:C}}))]),"symbol.style.baseline.fill-bottom")),b.append(u(this.numberRow("Base level %",e.baseline.baselineLevel,0,100,1,C=>this.emit({baseline:{baselineLevel:C}})),"symbol.style.baseline.base-level")),b.append(u(this.numberRow("Width",e.baseline.width,1,10,1,C=>this.emit({baseline:{width:C}})),"symbol.style.baseline.width")),d.baseline=b,c.append(b);for(let C of Mt()){if(!as(C.id))continue;let A=e.chartTypes[C.id]??{},$=(j,ut)=>typeof A[j]=="string"&&A[j]!==""?A[j]:ut,ie=(j,ut)=>typeof A[j]=="boolean"?A[j]:ut,oe=u(this.group(),`symbol.style.${C.id}`);oe.append(this.sectionTitle("Candles")),oe.append(u(this.toggleRow("Body",ie("candleBodyVisible",e.candles.bodyVisible),j=>this.emitType(C.id,"candleBodyVisible",j),[this.swatch($("candleUpColor",e.candles.upColor),j=>this.emitType(C.id,"candleUpColor",j)),this.swatch($("candleDownColor",e.candles.downColor),j=>this.emitType(C.id,"candleDownColor",j))]),`symbol.style.${C.id}.body`)),oe.append(u(this.toggleRow("Borders",ie("candleBorderVisible",e.candles.borderVisible),j=>this.emitType(C.id,"candleBorderVisible",j),[this.swatch($("candleBorderUpColor",e.candles.borderUpColor),j=>this.emitType(C.id,"candleBorderUpColor",j)),this.swatch($("candleBorderDownColor",e.candles.borderDownColor),j=>this.emitType(C.id,"candleBorderDownColor",j))]),`symbol.style.${C.id}.borders`)),oe.append(u(this.toggleRow("Wick",ie("candleWickVisible",e.candles.wickVisible),j=>this.emitType(C.id,"candleWickVisible",j),[this.swatch($("candleWickUpColor",e.candles.wickUpColor),j=>this.emitType(C.id,"candleWickUpColor",j)),this.swatch($("candleWickDownColor",e.candles.wickDownColor),j=>this.emitType(C.id,"candleWickDownColor",j))]),`symbol.style.${C.id}.wick`)),oe.append(u(this.numberRow("Spacing",e.series.spacing,.1,10,.1,j=>this.emit({series:{spacing:j}})),`symbol.style.${C.id}.spacing`)),d[C.id]=oe,c.append(oe);}h(e.series.style),c.append(u(this.sectionTitle("Animation"),"symbol.animation")),c.append(u(this.boolRow("Animate zoom",e.animations.zoom,C=>this.emit({animations:{zoom:C}}),this.hint("Glide the chart to each zoom step instead of jumping.")),"symbol.animation.zoom")),c.append(u(this.boolRow("Pan momentum",e.animations.pan,C=>this.emit({animations:{pan:C}}),this.hint("Keep gliding briefly after a drag release, and ease scroll-to-latest and keyboard pans.")),"symbol.animation.pan")),c.append(u(this.boolRow("Animate price scale",e.animations.autoscale,C=>this.emit({animations:{autoscale:C}}),this.hint("Glide the price scale to its new range while zooming or panning.")),"symbol.animation.autoscale")),c.append(u(this.boolRow("Animate price changes",e.priceScale.animateLastPrice,C=>this.emit({priceScale:{animateLastPrice:C}}),this.hint("Glide the live bar to each new price instead of snapping.")),"symbol.animation.price-changes")),c.append(u(this.boolRow("Reveal on load",e.animations.intro,C=>this.emit({animations:{intro:C}}),this.hint("Draw the candles in when a chart first loads. Takes effect on the next load.")),"symbol.animation.intro")),c.append(u(this.sectionTitle("Time zone"),"symbol.timezone")),c.append(u(this.selectRowLabeled("Time zone",Hc(e.timeScale.timezone),TM(e.timeScale.timezone),C=>this.emit({timeScale:{timezone:C}})),"symbol.timezone"));let y=C=>{for(let A of this.hostSections){if((A.placement??"after-symbol")!==C)continue;let $=Oh(A);if(yt($,this.hiddenSettings))continue;let ie=xw(A.rows,$,this.hiddenSettings);if(ie.length!==0){c.append(C==="symbol"?this.sectionTitle(A.title):this.section(A.title));for(let oe of ie)oe.kind==="heading"?c.append(this.sectionTitle(oe.label)):oe.kind==="toggle"?c.append(this.boolRow(oe.label,oe.get(),j=>oe.set(j))):oe.kind==="color"?c.append(this.colorRow(oe.label,oe.get(),j=>oe.set(j))):c.append(this.selectRowLabeled(oe.label,oe.get(),oe.options.map(j=>[j,j]),j=>oe.set(j)));}}},v=C=>{for(let A of Mt()){let $=A.settings;$&&($.placement??"end")===C&&(yt(`type:${A.id}`,this.hiddenSettings)||this.chartTypeSection(A.id,$,e,c));}};if(y("symbol"),v("after-symbol"),y("after-symbol"),c.append(u(this.section("Scales and lines"),"scales")),c.append(u(this.sectionTitle("Price scale"),"scales.price-scale")),c.append(u(this.selectRowLabeled("Mode",e.priceScale.log?"log":e.priceScale.mode,[["price","Regular"],["percent","Percent"],["indexed","Indexed to 100"],["log","Logarithmic"]],C=>this.emit({priceScale:C==="log"?{mode:"price",log:true}:{mode:C,log:false}})),"scales.price-scale.mode")),c.append(u(this.boolRow("Invert scale",e.priceScale.invert,C=>this.emit({priceScale:{invert:C}})),"scales.price-scale.invert")),c.append(u(this.separator(),"scales.price-scale")),c.append(u(this.boolRow("Last Price Line",e.priceScale.currentPriceLine,C=>this.emit({priceScale:{currentPriceLine:C}})),"scales.price-scale.last-price-line")),c.append(u(this.boolRow("Last price label",e.priceScale.priceLabel,C=>this.emit({priceScale:{priceLabel:C}})),"scales.price-scale.last-price-label")),c.append(u(this.boolRow("Countdown to bar close",e.priceScale.countdown,C=>this.emit({priceScale:{countdown:C}})),"scales.price-scale.countdown")),c.append(u(this.boolRow("Axis labels",e.priceScale.labelsVisible,C=>this.emit({priceScale:{labelsVisible:C}})),"scales.price-scale.axis-labels")),c.append(u(this.colorRow("Scale border color",e.priceScale.borderColor,C=>this.emit({priceScale:{borderColor:C}})),"scales.price-scale.border-color")),c.append(u(this.sectionTitle("Crosshair"),"scales.crosshair")),c.append(u(this.colorRow("Color",e.crosshair.color,C=>this.emit({crosshair:{color:C}})),"scales.crosshair.color")),c.append(u(this.numberRow("Width",e.crosshair.width,.5,8,.5,C=>this.emit({crosshair:{width:C}})),"scales.crosshair.width")),c.append(u(this.selectRowLabeled("Style",e.crosshair.style,[["solid","Solid"],["dashed","Dashed"],["dotted","Dotted"]],C=>this.emit({crosshair:{style:C}})),"scales.crosshair.style")),c.append(u(this.section("Canvas"),"canvas")),c.append(u(this.sectionTitle("Background & text"),"canvas.background")),c.append(u(this.colorRow("Background",e.layout.background,C=>this.emit({layout:{background:C}})),"canvas.background.color")),c.append(u(this.colorRow("Text color",e.layout.textColor,C=>this.emit({layout:{textColor:C}})),"canvas.background.text-color")),c.append(u(this.numberRow("Text size",e.layout.fontSize,6,32,1,C=>this.emit({layout:{fontSize:C}})),"canvas.background.text-size")),c.append(u(this.colorRow("Pane separator color",e.panes.separatorColor,C=>this.emit({panes:{separatorColor:C}})),"canvas.background.pane-separator")),c.append(u(this.sectionTitle("Grid"),"canvas.grid")),c.append(u(this.toggleRow("Vertical",e.grid.vertLines.visible,C=>this.emit({grid:{vertLines:{visible:C}}}),[this.swatch(e.grid.vertLines.color,C=>this.emit({grid:{vertLines:{color:C}}}))]),"canvas.grid.vertical")),c.append(u(this.toggleRow("Horizontal",e.grid.horzLines.visible,C=>this.emit({grid:{horzLines:{visible:C}}}),[this.swatch(e.grid.horzLines.color,C=>this.emit({grid:{horzLines:{color:C}}}))]),"canvas.grid.horizontal")),this.themeControl){let C=this.themeControl;c.append(u(this.sectionTitle("Theme"),"canvas.theme")),c.append(u(this.selectRow("Color theme",C.current==="dark"?"Dark":"Light",["Dark","Light"],A=>C.onSelect(A==="Dark"?"dark":"light")),"canvas.theme"));}if(this.markGroups.length>0){c.append(u(this.section("Events"),Rh)),c.append(u(this.sectionTitle("Visible events"),zc));for(let C of this.markGroups)c.append(u(this.boolRow(C.label,this.markGroupVisible(C.id),A=>this.emit({marks:{groups:{[C.id]:A}}})),Dh(C.id)));}if(v("end"),y("end"),this.hiddenSettings.size>0){let C=false;for(let A of [...c.children]){if(A.dataset.sdTab!==void 0&&(C=A.dataset.sdId!==void 0&&yt(A.dataset.sdId,this.hiddenSettings)),C||A.dataset.sdId!==void 0&&yt(A.dataset.sdId,this.hiddenSettings)){A.remove();continue}for(let $ of [...A.querySelectorAll("[data-sd-id]")])yt($.dataset.sdId,this.hiddenSettings)&&$.remove();}}let S=document.createElement("div");S.style.cssText=s?"display:flex;min-height:0;flex:1 1 auto;position:relative;overflow:hidden;":"display:flex;min-height:360px;max-height:calc(70vh - 100px);flex:1 1 auto;";let E=document.createElement("div");E.className="vela-sd-rail",E.style.cssText=s?"display:flex;flex-direction:column;gap:2px;padding:10px 8px;overflow-y:auto;":`flex:0 0 170px;display:flex;flex-direction:column;gap:2px;padding:10px 8px;border-right:1px solid ${xM};overflow-y:auto;`;let T=null;s&&(T=document.createElement("div"),T.className="vela-sd-railscrim",T.addEventListener("click",()=>a?.()),a=C=>{let A=C??!E.classList.contains("open");E.classList.toggle("open",A),T?.classList.toggle("open",A);});let k=document.createElement("div");k.className="vela-sd-pane",k.style.cssText=s?"flex:1;min-width:0;overflow-y:auto;overflow-anchor:none;padding:6px 14px calc(14px + env(safe-area-inset-bottom, 0px));":"flex:1;overflow-y:auto;overflow-anchor:none;padding:6px 18px 14px;";let x=[],L=null;for(let C of [...c.children]){let A=C.dataset.sdTab;if(A!==void 0){let $=document.createElement("div");$.style.display="none";let ie=document.createElement("button");ie.type="button",ie.textContent=A,ie.className="vela-sd-tab"+(C.dataset.sdSub!==void 0?" vela-sd-tab-sub":""),x.push({title:A,el:$,tab:ie,style:C.dataset.sdStyle,visibility:C.dataset.sdVisibility}),L=$,C.remove();continue}L&&L.appendChild(C);}for(let C=x.length-1;C>=0;C--)x[C].el.childElementCount===0&&x.splice(C,1);this.syncTypeTabs=C=>{let A=false;x.forEach(($,ie)=>{if(!$.style)return;let oe=$.visibility==="always"||$.style===C||C==="heikinashi"&&$.style==="heikinashi";$.tab.style.display=oe?"":"none",!oe&&$.el.style.display==="block"&&(A=true);}),A&&M(0);};let w=new wn({host:this.container,title:"Chart settings",modal:false,contained:true,align:"top",draggable:!s,flush:true,className:"vela-dialog--settings",headerStart:l,closeOnBackdrop:true,footer:C=>{C.style.cssText="padding:10px 14px;display:flex;align-items:center;justify-content:flex-start;gap:8px;";let A=document.createElement("button");A.type="button",A.textContent="Reset defaults",A.className="vela-sd-btn",A.addEventListener("click",()=>this.onReset?.()),C.appendChild(A);},onOpenChange:C=>{C||this.close();}});s&&w.positioner.classList.add("vela-sd-mobile"),w.positioner.style.paddingTop=s?"0":"8vh";let M=C=>{x.forEach((A,$)=>{A.el.style.display=$===C?"block":"none",A.tab.classList.toggle("on",$===C);}),this.activeSection=x[C]?.title??null,s&&(w.titleEl.textContent=x[C]?.title??"Chart settings",a?.(false));};x.forEach((C,A)=>{C.tab.addEventListener("click",()=>M(A)),E.appendChild(C.tab),k.appendChild(C.el);}),this.tabs=x.map((C,A)=>({title:C.title,show:()=>M(A)}));let P=o!==void 0?x.findIndex(C=>C.title.toLowerCase()===o.toLowerCase()):x.findIndex(C=>C.style===e.series.style&&!C.tab.classList.contains("vela-sd-tab-sub"));M(P>=0?P:0),this.syncTypeTabs?.(e.series.style),S.append(E,k),T&&S.append(T),w.body.appendChild(S),this.root=w.positioner,this.ui=w,w.show();for(let C of x){let A=[...C.el.querySelectorAll("[data-sd-rows-host]")];if(A.length===0){this.layoutSettingsGrids(C.el);continue}for(let $ of A)this.layoutSettingsGrids($);}}close(){Te(),rh();let e=this.ui;this.ui=null,this.root=null,this.tabs=[];for(let t of this.hintTips)t();this.hintTips=[],e?.destroy();}destroy(){this.close(),this.onChange=null,this.onImport=null,this.config=null;}emitType(e,t,n){this.emit({chartTypes:{[e]:{[t]:n}}});}emit(e){this.onChange?.(e);}sectionTitle(e){return xn(e)}chartTypeSection(e,t,n,i){let o=this.section(t.title);o.dataset.sdStyle=e,o.dataset.sdVisibility=t.visibility??"active",i.append(o);let s=n.chartTypes[e]??{},a={},l=h=>{for(let p of h)for(let m of so(p)){let f=s[m.key];a[m.key]=typeof f===m.type?f:m.defval;}};t.rows&&l(t.rows);for(let h of t.instances??[])l(h.rows);for(let h of t.subsections??[])l(h.rows);for(let h of t.instances??[])!h.enableKey||h.enableKey in a||(a[h.enableKey]=s[h.enableKey]===true);for(let h of t.subsections??[])!h.enableKey||h.enableKey in a||(a[h.enableKey]=s[h.enableKey]===true);let c=[],u=(h,p)=>{a[h]=p,this.emitType(e,h,p);for(let m of c)m();},d=`type:${e}`;if(t.instances&&t.instances.length>0){let h=t.instances.map(p=>({...p,rows:$c(p.rows,d,this.hiddenSettings)}));i.append(this.instancesBlock(e,h,a,u,c));}else if(t.rows){let h=$c(t.rows,d,this.hiddenSettings);t.layout==="grouped"?i.append(this.groupedRows(`${e}/rows`,h,a,u,c)):this.flatTypeRows(h,a,u,c,i);}for(let h of t.subsections??[]){if(yt(`${d}.${jn(h.title)}`,this.hiddenSettings))continue;let p=$c(h.rows,d,this.hiddenSettings);if(p.length===0)continue;let m=this.section(h.title);m.dataset.sdStyle=e,m.dataset.sdVisibility=t.visibility??"active",m.dataset.sdSub="1",i.append(m),i.append(this.groupedRows(`${e}/${h.title}`,p,a,u,c,h.enableKey));}for(let h of c)h();}flatTypeRows(e,t,n,i,o){let s=[];for(let a of e){let l=a.kind==="heading"||a.kind==="header"?this.sectionTitle(a.label):this.typeRow(a,t,n,i);s.push({el:l,when:a.when}),o.append(l);}i.push(()=>{for(let a of s)a.el.classList.toggle("vela-sd-hide",!br(a.when,t));});}typeRow(e,t,n,i){let o=Zr(e),s=[];for(let a of o.controls){let l=this.inlineControl(a,t,n,o.toggle!==void 0);if(a.kind!=="hint"&&i.push(()=>l.dispatchEvent(new Event("vela-sync"))),a.kind!=="hint"&&a.when){l.dataset.sdSelfGated="1";let c=a.when;i.push(()=>{l.style.display=br(c,t)?"":"none";});}s.push(l);}if(o.toggle){let a=o.toggle,l=this.toggleRow(o.label,t[a.key],c=>n(a.key,c),s,()=>t[a.key]===true);return i.push(()=>l.dispatchEvent(new Event("vela-sync"))),l}return this.rowWith(o.label,s)}inlineControl(e,t,n,i){if(e.kind==="hint"){let s=document.createElement("span");return s.textContent=e.text,s.style.cssText="color:var(--vela-fg-muted);",s}if(e.kind==="color")return se({kind:"color",theme:this.theme,get:()=>t[e.key],onChange:s=>n(e.key,s),title:e.label}).el;if(e.kind==="width"){let s=typeof t[e.key]=="number"?t[e.key]:e.defval;return se({kind:"width",theme:this.theme,get:()=>typeof t[e.key]=="number"?t[e.key]:s,onChange:a=>n(e.key,a),title:e.label}).el}if(e.kind==="select"){let s=typeof t[e.key]=="string"?t[e.key]:e.defval;return se({kind:"select",options:CM(e.options).map(([a,l])=>({value:a,label:l})),value:s,fill:false,theme:this.theme,title:e.label,onChange:a=>n(e.key,a),sync:()=>typeof t[e.key]=="string"?t[e.key]:e.defval}).el}let o=typeof t[e.key]=="number"?t[e.key]:e.defval;return se({kind:"number",value:o,min:e.min,max:e.max,step:e.step??1,fill:false,commit:"live",clamp:e.placeholder!==void 0,steppers:true,compact:i,title:e.label,placeholder:e.placeholder,emptyValue:e.placeholder!==void 0?e.defval:void 0,onChange:s=>n(e.key,s),sync:()=>typeof t[e.key]=="number"?t[e.key]:e.defval}).el}instancesBlock(e,t,n,i,o){let s=document.createElement("div"),a=document.createElement("div");a.className="vela-sd-itabs",(t.length>1||t[0]?.enableKey!==void 0)&&s.append(a);let l=t.map((d,h)=>{let p=this.groupedRows(`${e}/#${h}`,d.rows,n,i,o);return s.append(p),p}),c=d=>!d.enableKey||n[d.enableKey]===true,u=()=>{let d=this.typeActiveInstance.get(e)??0;c(t[d]??t[0])||(d=0),this.typeActiveInstance.set(e,d),a.replaceChildren(),t.forEach((p,m)=>{if(!c(p))return;let f=document.createElement("button");f.type="button",f.className="vela-sd-itab"+(m===d?" on":"");let g=document.createElement("span");if(g.textContent=p.label,f.append(g),m===d&&p.enableKey){let b=document.createElement("span");b.className="vela-sd-ix",b.textContent="\u2715",b.title=`Remove ${p.label}`,b.addEventListener("click",y=>{y.stopPropagation(),this.typeActiveInstance.set(e,0),i(p.enableKey,false);}),f.append(b);}f.addEventListener("click",()=>{this.typeActiveInstance.set(e,m),u();}),a.append(f);});let h=t.findIndex(p=>!c(p));if(h>=0){let p=document.createElement("button");p.type="button",p.className="vela-sd-itab vela-sd-itab-add",p.textContent="+",p.title=`Add ${t[h].label}`,p.addEventListener("click",()=>{this.typeActiveInstance.set(e,h),i(t[h].enableKey,true);}),a.append(p);}l.forEach((p,m)=>p.classList.toggle("vela-sd-hide",m!==d));};return o.push(u),s}groupedRows(e,t,n,i,o,s){let a=document.createElement("div");a.className="vela-sd-struct";let l=document.createElement("div");l.className="vela-sd-toc";let c=document.createElement("div");c.dataset.sdRowsHost="1",c.style.cssText="flex:1 1 auto;min-width:0;",a.append(l,c);let u=[],d=[],h=[],p=-1;for(let f of t){if(f.kind==="heading"){p=d.length,d.push(f.label),h.push(f.when);continue}if(f.kind==="header"){u.push({el:this.sectionTitle(f.label),when:f.when,group:p,header:true}),c.append(u[u.length-1].el);continue}let g=this.typeRow(f,n,i,o),b=f.kind==="row"?f.toggle?.key:f.kind==="range"?void 0:f.key;u.push({el:g,when:f.when,group:p,key:b}),c.append(g);}let m=()=>{let f=d.map((v,S)=>br(h[S],n)&&u.some(E=>E.group===S&&!E.header&&br(E.when,n))),g=d.indexOf(this.typeActiveGroup.get(e)??"");(g<0||!f[g])&&(g=f.findIndex(Boolean)),g>=0&&this.typeActiveGroup.set(e,d[g]),l.replaceChildren(),d.forEach((v,S)=>{if(!f[S])return;let E=document.createElement("button");E.type="button",E.className="vela-sd-toc-btn"+(S===g?" on":""),E.textContent=v,E.addEventListener("click",()=>{this.typeActiveGroup.set(e,v),m();}),l.append(E);});let b=f.some(Boolean);l.classList.toggle("vela-sd-hide",!b),a.classList.toggle("no-toc",!b);let y=!s||n[s]===true;for(let v=0;v<u.length;v++){let S=u[v],E=(S.group===-1||S.group===g)&&br(S.when,n);if(E&&S.header){let T=false;for(let k=v+1;k<u.length;k++){let x=u[k];if(x.group!==S.group||x.header)break;if(br(x.when,n)){T=true;break}}E=T;}S.el.classList.toggle("vela-sd-hide",!E),S.el.classList.toggle("vela-sd-soft",E&&!y&&S.key!==s);}};return o.push(m),a}separator(){return oh()}layoutSettingsGrids(e){if(e.childElementCount===0)return;let t=ns({variant:"settings",mobile:this.mobileLayout});for(;e.firstChild;)t.appendChild(e.firstChild);e.appendChild(t);for(let n of [...t.children])n.dataset.sdGroup!==void 0&&this.flattenGroup(n,t);}flattenGroup(e,t){e.style.display="contents";for(let n of [...e.children])n.dataset.sdGroup!==void 0&&this.flattenGroup(n,t);}swatch(e,t,n){let i=e;return se({kind:"color",theme:this.theme,get:()=>n?n():i,onChange:o=>{i=o,t(o);}}).el}rowWith(e,t){return Ae({label:e,labelSize:"sm",control:t,className:"vela-sd-row"})}section(e){let t=document.createElement("div");return t.dataset.sdTab=e,t.style.display="none",t}group(){let e=document.createElement("div");return e.dataset.sdGroup="",e.style.cssText="display:contents;",e}colorRow(e,t,n){let i=t;return Ae({label:e,labelSize:"sm",fit:true,className:"vela-sd-row",control:se({kind:"color",theme:this.theme,get:()=>i,onChange:o=>{i=o,n(o);}}).el})}boolRow(e,t,n,i){return this.toggleRow(e,t,n,[],void 0,i)}toggleRow(e,t,n,i,o,s){return Ae({label:e,labelSize:"sm",bool:i.length===0,toggle:{checked:t,onChange:n,get:o},control:i,info:s,className:i.length===0?"vela-sd-bool":"vela-sd-row"})}hint(e){let{el:t,dispose:n}=ll(e,{host:this.container,theme:()=>this.theme});return this.hintTips.push(n),t}numberRow(e,t,n,i,o,s){return Ae({label:e,labelSize:"sm",className:"vela-sd-row",control:se({kind:"number",value:t,min:n,max:i,step:o,fill:false,commit:"live",steppers:true,onChange:s}).el})}selectRowLabeled(e,t,n,i){return Ae({label:e,labelSize:"sm",className:"vela-sd-row",control:se({kind:"select",options:n.map(([o,s])=>({value:o,label:s})),value:t,fill:false,theme:this.theme,onChange:i}).el})}selectRow(e,t,n,i){return this.selectRowLabeled(e,t,n.map(o=>[o,o]),i)}};function CM(r){return r.map(e=>typeof e=="string"?[e,e]:e)}function TM(r){let e=Ih.map(n=>[n.value,Ah(n.value,n.label)]),t=Hc(r);return Ih.some(n=>n.value===t)?e:[[t,Ah(t,t)],...e]}var ys=Hs,ws=zs;function wt(r,e){if(r instanceof Ne){if(!r.fillTriangles().length)return null;let t=r.valid();return r.style.fillColor??(t==null?r.style.lineColor:t?ys:ws)}return r instanceof dt?r.style.fillColor??e.background:r.style.fillColor??null}var kM=4.5,Nh=O,EM=q(J,.55),LM=.7,kw=Jp,MM=Qp,Ew={selected:.3,hovered:.12};function Fh(r){let e=new Set(r.selected);return r.dragged&&e.add(r.dragged),r.hovered&&e.add(r.hovered),r.mutedLabel&&e.delete(r.mutedLabel),e}var Wc=class{constructor(){this.targets={};this.seriesLook={style:"candles",upColor:z,downColor:W,lineColor:z};}paintAll(e,t,n,i,o={}){this.targets=o;for(let s of t)s.visible&&this.paintClipped(e,s,n,()=>this.paintOne(e,s,n,i));this.targets={},this.paintHighlights(e,t,n,Fh(o));}paintHighlights(e,t,n,i){if(i.size!==0)for(let o of t)o.visible&&i.has(o.id)&&this.paintClipped(e,o,n,()=>this.paintHandles(e,o.handlePoints(n)));}paintClipped(e,t,n,i){if(!n.paneRect){i();return}let o=n.paneRect(t.paneId);!o||o.height<=0||(e.save(),e.beginPath(),e.rect(0,o.top,n.width,o.height),e.clip(),i(),e.restore());}paintGhost(e,t,n,i){e.globalAlpha=LM,t instanceof un||t instanceof at?this.paintTimeSpanGhost(e,t,n):t instanceof tt?this.paintMagnifierGhost(e,t,n,i):this.paintOne(e,t,n,i),e.globalAlpha=1;}paintTimeSpanGhost(e,t,n){let i=t.anchors[0],o=t.anchors[1];if(!i)return;let s=t instanceof un?t.reg?.midColor||J:J,a=d=>{let h=n.xOf(d);e.save(),e.strokeStyle=s,e.globalAlpha=.6*e.globalAlpha,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(h,0),e.lineTo(h,n.height),e.stroke(),e.restore();};a(i.time),o&&a(o.time);let l=n.yOf(i.price,t.paneId),c=o?n.yOf(o.price,t.paneId):null,u=[];l!=null&&u.push([n.xOf(i.time),l]),o&&c!=null&&(e.save(),e.strokeStyle=s,e.lineWidth=1,e.setLineDash([]),e.beginPath(),e.moveTo(n.xOf(i.time),l??c),e.lineTo(n.xOf(o.time),c),e.stroke(),e.restore(),u.push([n.xOf(o.time),c])),this.paintHandles(e,u);}paintMarquee(e,t){e.save(),e.fillStyle=q(Nh,.08),e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Nh,e.lineWidth=1,e.setLineDash([4,3]),e.strokeRect(t.x+.5,t.y+.5,t.w,t.h),e.restore();}paintSnapRing(e,t,n,i){e.setLineDash([]),e.globalAlpha=.9,e.beginPath(),e.arc(t,n,5.5,0,Math.PI*2),e.strokeStyle=i.textColor,e.lineWidth=1.5,e.stroke(),e.globalAlpha=1;}paintOne(e,t,n,i){if(t.type==="highlighter"&&t instanceof pe){this.paintHighlighter(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof pe){if(this.paintSegments(e,t,n),t.type==="path"){let o=t.handlePoints(n);o.length>=2&&this.paintArrowhead(e,o[o.length-2],o[o.length-1],t.style);}this.paintLabel(e,t,n,i);return}if(t instanceof ar){this.paintArrowMark(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof lr){this.paintGlyphStamp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof kt){this.paintRadialFib(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof hr){this.paintFibSpiral(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof mr){this.paintDedekind(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Qe){this.paintMachFigure(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof pr){this.paintFibRatios(e,t,n,i),this.paintGannArcs(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof fe){this.paintFibRatios(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof fr){this.paintMeasureBox(e,t,n,i);return}if(t instanceof ht){this.paintPosition(e,t,n,i);return}if(t instanceof un){this.paintRegressionChannel(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof sr){this.paintAnchoredVwap(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof at){this.paintFixedRangeVp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof tt){this.paintMagnifier(e,t,n,i);return}if(t instanceof Ne){this.paintPattern(e,t,n,i);return}if(t instanceof ir){this.paintComment(e,t,n,i);return}if(t instanceof rr){this.paintPriceNote(e,t,n,i);return}if(t instanceof or){this.paintSignpost(e,t,n,i);return}if(t instanceof Ht){this.paintCallout(e,t,n,i);return}if(t instanceof tr){this.paintNote(e,t,n,i);return}if(t instanceof nr){this.paintPriceLabel(e,t,n,i);return}switch(t.type){case "hline":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(0,o[0][1]),e.lineTo(n.width,o[0][1]);});break}case "trendline":case "arrow":{let o=t.handlePoints(n);if(o.length<2)return;this.stroke(e,t.style,()=>{e.moveTo(o[0][0],o[0][1]),e.lineTo(o[1][0],o[1][1]);}),t.style.arrowRight&&this.paintArrowhead(e,o[0],o[1],t.style),t.style.arrowLeft&&this.paintArrowhead(e,o[1],o[0],t.style);break}case "ellipse":{let o=t.handlePoints(n);if(o.length<2)return;let s=(o[0][0]+o[1][0])/2,a=(o[0][1]+o[1][1])/2,l=Math.abs(o[1][0]-o[0][0])/2,c=Math.abs(o[1][1]-o[0][1])/2;t.style.fillColor&&(e.save(),e.fillStyle=t.style.fillColor,e.beginPath(),e.ellipse(s,a,l,c,0,0,Math.PI*2),e.fill(),e.restore()),this.applyStroke(e,t.style),e.beginPath(),e.ellipse(s,a,l,c,0,0,Math.PI*2),e.stroke(),e.setLineDash([]);break}case "ray":{let o=t.handlePoints(n);if(o.length<2)return;let[s,a,l,c]=Oi(o[0][0],o[0][1],o[1][0],o[1][1],"right",n.width,n.height);this.stroke(e,t.style,()=>{e.moveTo(s,a),e.lineTo(l,c);});break}case "extendedline":{let o=t.handlePoints(n);if(o.length<2)return;let[s,a,l,c]=Oi(o[0][0],o[0][1],o[1][0],o[1][1],"both",n.width,n.height);this.stroke(e,t.style,()=>{e.moveTo(s,a),e.lineTo(l,c);});break}case "vline":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(o[0][0],0),e.lineTo(o[0][0],n.height);});break}case "hray":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(o[0][0],o[0][1]),e.lineTo(n.width,o[0][1]);});break}case "crossline":{let o=t.handlePoints(n);if(o.length===0)return;this.stroke(e,t.style,()=>{e.moveTo(0,o[0][1]),e.lineTo(n.width,o[0][1]),e.moveTo(o[0][0],0),e.lineTo(o[0][0],n.height);});break}case "infoline":this.paintInfoLine(e,t,n);break;case "trendangle":this.paintTrendAngle(e,t,n,i);break;case "circle":{let o=t.handlePoints(n);if(o.length<2)return;let s=o[0][0],a=o[0][1],l=Math.hypot(o[1][0]-s,o[1][1]-a);if(l<1)return;t.style.fillColor&&(e.save(),e.fillStyle=t.style.fillColor,e.beginPath(),e.arc(s,a,l,0,Math.PI*2),e.fill(),e.restore()),this.applyStroke(e,t.style),e.beginPath(),e.arc(s,a,l,0,Math.PI*2),e.stroke(),e.setLineDash([]);break}case "box":{let o=t.handlePoints(n);if(o.length<2)return;let s=Math.min(o[0][0],o[1][0]),a=Math.min(o[0][1],o[1][1]),l=Math.abs(o[1][0]-o[0][0]),c=Math.abs(o[1][1]-o[0][1]);t.style.fillColor&&(e.save(),e.fillStyle=t.style.fillColor,e.fillRect(s,a,l,c),e.restore()),this.applyStroke(e,t.style),e.strokeRect(s,a,l,c),e.setLineDash([]);break}}this.paintLabel(e,t,n,i);}paintLabel(e,t,n,i){let o=t.text;if(!o||!o.value||t.id===this.targets.mutedLabel)return;let s=IM(t,n);if(!s)return;let a=Be(o.size);e.save(),s.rotate&&(e.translate(s.rotate.cx,s.rotate.cy),e.rotate(s.rotate.angle)),e.font=`${o.bold?"bold ":""}${o.italic?"italic ":""}${a}px ${i.fontFamily}`,e.textBaseline="top",e.textAlign=s.align,e.fillStyle=o.color??i.textColor;let l=on(a),c=o.value.split(`
|
|
899
|
+
`);c.forEach((u,d)=>e.fillText(u,s.x,s.top+d*l)),t.type==="text"&&this.paintTextFrame(e,t.id,s.x,s.top,c,a,i),e.restore();}paintTextFrame(e,t,n,i,o,s,a){let l=this.targets,c=l.selected?.has(t)?Ew.selected:l.hovered===t?Ew.hovered:0;if(c===0)return;let u=on(s),d=Math.max(8,...o.map(h=>e.measureText(h).width));e.save(),e.setLineDash([]),e.lineWidth=1,e.strokeStyle=q(a.textColor,c),Nt(e,n-Nr,i-(u-s)/2-Fr,d+Nr*2,o.length*u+Fr*2,4),e.stroke(),e.restore();}paintFibRatios(e,t,n,i){let o=t.entryLines(n);if(!o||o.length===0)return;for(let l of t.fillBands(n))e.save(),e.globalAlpha=.06*e.globalAlpha,e.fillStyle=l.color,e.fillRect(l.x,l.y,l.w,l.h),e.restore();e.textBaseline="middle";let s=`${Be(t.numbersSize)}px ${i.fontFamily}`,a=`${Be(t.labelsSize)}px ${i.fontFamily}`;for(let l of o)this.stroke(e,{...t.style,lineColor:l.color},()=>{e.moveTo(l.x1,l.y1),e.lineTo(l.x2,l.y2);}),e.fillStyle=l.color,e.font=s,e.textAlign=l.numberAlign,e.fillText(l.numberText,l.numberX,l.numberY),l.label&&(e.font=a,e.textAlign="center",e.fillText(l.label,l.labelX,l.labelY));e.textAlign="left",e.textBaseline="alphabetic";}paintRadialFib(e,t,n,i){let o=t.radial(n);if(o&&o.R0>=1){let s=`${Be(t.numbersSize)}px ${i.fontFamily}`,a=(o.a0+o.a1)/2;e.textBaseline="middle";for(let l of t.levels){if(!l.enabled)continue;let c=o.R0*l.ratio;c<.5||(this.applyStroke(e,{...t.style,lineColor:l.color}),e.beginPath(),e.arc(o.cx,o.cy,c,o.a0,o.a1),e.stroke(),e.setLineDash([]),e.fillStyle=l.color,e.font=s,e.textAlign="left",e.fillText(String(l.ratio),o.cx+Math.cos(a)*c+3,o.cy+Math.sin(a)*c));}e.textBaseline="alphabetic",e.textAlign="left";}for(let s of t.boundingLines(n))this.stroke(e,t.style,()=>{e.moveTo(s[0],s[1]),e.lineTo(s[2],s[3]);});}paintGannArcs(e,t,n){let i=t.arcGeom(n);if(!i||Math.abs(i.bx)<1||Math.abs(i.py)<1)return;let o=24;for(let s of Au){this.applyStroke(e,{...t.style,lineColor:s.color}),e.beginPath();for(let a=0;a<=o;a+=1){let l=a/o*(Math.PI/2),c=i.ox+s.k*i.bx*Math.cos(l),u=i.oy+s.k*i.py*Math.sin(l);a===0?e.moveTo(c,u):e.lineTo(c,u);}e.stroke();}e.setLineDash([]);}paintFibSpiral(e,t,n){let i=t.spiralPoints(n);!i||i.length<2||this.stroke(e,t.style,()=>{e.moveTo(i[0][0],i[0][1]);for(let o=1;o<i.length;o+=1)e.lineTo(i[o][0],i[o][1]);});}paintMachFigure(e,t,n,i){let o=t.geom(n);if(o){for(let s of o.circles)this.applyStroke(e,{...t.style,lineColor:s.color}),e.beginPath(),e.arc(s.cx,s.cy,s.r,0,Math.PI*2),e.stroke();this.applyStroke(e,t.style),e.lineWidth=t.style.lineWidth+.5;for(let s of o.rays)e.beginPath(),e.moveTo(s[0],s[1]),e.lineTo(s[2],s[3]),e.stroke();if(e.beginPath(),e.arc(o.noseX,o.noseY,Math.max(2.5,t.style.lineWidth+1.5),0,Math.PI*2),e.fillStyle=t.style.lineColor,e.fill(),e.setLineDash([]),t.showRatios!==false){let s=`${Be("small")}px ${i.fontFamily}`;e.font=s,e.textBaseline="middle",e.textAlign="left";for(let a of o.circles){let l=a.cx+o.fx*a.r+4,c=a.cy+o.fy*a.r;e.fillStyle=a.color,e.fillText(PM(a.ratio),l,c);}e.textBaseline="alphabetic",e.textAlign="left";}}}paintDedekind(e,t,n){let i=t.box(n),o=t.geodesics(n);if(!i||!o)return;let{left:s,right:a,top:l,bot:c}=i;e.save(),this.applyStroke(e,t.style),e.globalAlpha*=.45,e.strokeRect(s,l,a-s,c-l),e.restore(),e.save(),e.beginPath(),e.rect(s,l,a-s,c-l),e.clip(),this.applyStroke(e,t.style);for(let u of o)e.beginPath(),u.kind==="vline"?(e.moveTo(u.x,u.y0),e.lineTo(u.x,u.y1)):e.arc(u.cx,u.cy,u.r,Math.PI,0,false),e.stroke();e.setLineDash([]),e.restore();}paintMeasureBox(e,t,n,i){let o=t.handlePoints(n);if(o.length<2)return;let s=Math.min(o[0][0],o[1][0]),a=Math.min(o[0][1],o[1][1]),l=Math.abs(o[1][0]-o[0][0]),c=Math.abs(o[1][1]-o[0][1]),u=t.isUp()?z:W;e.save(),e.globalAlpha=.12*e.globalAlpha,e.fillStyle=u,e.fillRect(s,a,l,c),e.restore(),e.setLineDash(Xn(t.style.lineStyle,t.style.lineWidth)),e.strokeStyle=u,e.lineWidth=t.style.lineWidth,e.strokeRect(s,a,l,c),e.setLineDash([]);let d=t.measureLabel(n),h=Be(t.text?.size??"normal");e.fillStyle=t.text?.color??i.textColor,e.font=`${h}px ${i.fontFamily}`,e.textAlign="center",e.textBaseline="middle";let p=Math.round(h*1.35),m=a+c/2-(d.length-1)*p/2;d.forEach((f,g)=>e.fillText(f,s+l/2,m+g*p)),e.textAlign="left",e.textBaseline="alphabetic";}paintPosition(e,t,n,i){let o=t.layout(n);if(!o)return;let{x1:s,x2:a,ey:l,sy:c,ty:u}=o,d=a-s,h=(b,y,v)=>{e.save(),e.globalAlpha=.13*e.globalAlpha,e.fillStyle=v,e.fillRect(s,Math.min(b,y),d,Math.abs(y-b)),e.restore();};h(l,u,t.profitColor),h(l,c,t.lossColor);let p=(b,y)=>this.stroke(e,{...t.style,lineColor:y},()=>{e.moveTo(s,b),e.lineTo(a,b);});if(p(u,t.profitColor),p(c,t.lossColor),p(l,t.style.lineColor),!t.showText)return;let m=Be(t.text?.size??"normal");e.fillStyle=t.text?.color??i.textColor,e.textAlign="center",e.textBaseline="middle",e.font=`${m}px ${i.fontFamily}`;let f=s+d/2,g=Math.min(l,c,u)-9;t.showHeader&&e.fillText(t.headerLabel(),f,t.showLossSize?g-Math.round(m*1.15):g),e.font=`${Math.max(10,m-1)}px ${i.fontFamily}`,t.showLossSize&&e.fillText(t.lossSizeLabel(),f,g),t.showTargetLabel&&e.fillText(t.targetLabel(),f,(l+u)/2),t.showStopLabel&&e.fillText(t.stopLabel(),f,(l+c)/2),e.textAlign="left",e.textBaseline="alphabetic";}paintRegressionChannel(e,t,n,i){let o=t.layout(n);if(!o)return;let s=t.reg,a=(c,u,d,h,p)=>{e.save(),e.fillStyle=c,e.beginPath(),e.moveTo(o.x0,u),e.lineTo(o.x1,d),e.lineTo(o.x1,p),e.lineTo(o.x0,h),e.closePath(),e.fill(),e.restore();};a(s.upperFill,o.midY0,o.midY1,o.upperY0,o.upperY1),a(s.lowerFill,o.midY0,o.midY1,o.lowerY0,o.lowerY1);let l=(c,u,d,h)=>this.stroke(e,{lineColor:c,lineWidth:t.style.lineWidth,lineStyle:u},()=>{e.moveTo(o.x0,d),e.lineTo(o.x1,h);});if(l(s.upperColor,s.upperStyle,o.upperY0,o.upperY1),l(s.lowerColor,s.lowerStyle,o.lowerY0,o.lowerY1),l(s.midColor,s.midStyle,o.midY0,o.midY1),o.showR2){let c=`R\xB2 ${Math.round(o.r2*100)}%`;e.font=`11px ${i.fontFamily}`;let u=e.measureText(c).width,d=5,h=4,p=u+d*2,m=o.x0-h-p,f=o.midY0-9;e.save(),e.globalAlpha=.9*e.globalAlpha,Nt(e,m,f-8,p,16,3),e.fillStyle=kw,e.fill(),e.restore(),e.fillStyle=i.textColor,e.textAlign="left",e.textBaseline="middle",e.fillText(c,m+d,f),e.textBaseline="alphabetic";}}paintMagnifierGhost(e,t,n,i){let o=t.rect(n);o&&(e.save(),e.strokeStyle=t.style.lineColor||_e(i.background),e.lineWidth=1,e.setLineDash([4,4]),e.strokeRect(Math.min(o.x1,o.x2),Math.min(o.y1,o.y2),Math.abs(o.x2-o.x1),Math.abs(o.y2-o.y1)),e.restore());}paintMagnifier(e,t,n,i){let o=t.rect(n),s=t.anchors[0],a=t.anchors[1];if(!o||!s||!a)return;let l=Math.min(o.x1,o.x2),c=Math.max(o.x1,o.x2),u=Math.min(o.y1,o.y2),d=Math.max(o.y1,o.y2),h=c-l,p=d-u;e.save(),e.globalAlpha=1,e.fillStyle=i.background,e.fillRect(l,u,h,p),e.restore();let m=Math.min(s.time,a.time),f=Math.max(s.time,a.time),g=n.barsBetween?n.barsBetween(m,f):0,b=g>0?(f-m)/g:0,y=n.seriesInRange&&b>0&&h>1&&p>1?n.seriesInRange(t.magnifier.timeframe,m,f+b):void 0,v=y?.state==="ready"||y?.state==="loading"?y.bars??[]:[];if(y&&(y.state==="ready"||y.state==="loading")&&v.length>0){let S=this.seriesLook,E=S.style!=="candles"?Jr(S.style):null;E&&(v=E.full(v));let T=S.style==="bars"?"bars":S.style==="line"||S.style==="baseline"?"line":S.style==="area"?"area":"candles",k=(n.xOf(m+b)-n.xOf(m))/2;e.save(),e.beginPath(),e.rect(l,u,h,p),e.clip(),T==="line"||T==="area"?this.paintMagnifierLine(e,t,n,v,y.barMs,k,d,T==="area",t.magnifier.upColor||S.lineColor):this.paintMagnifierBars(e,t,n,v,y.barMs,k,l,c,T,t.magnifier.upColor||S.upColor,t.magnifier.downColor||S.downColor),e.restore();}else if(y){let S=y.state==="loading"?"Loading\u2026":y.state==="ready"?"No lower-timeframe data":y.reason==="too-wide"?"Area too wide for this timeframe":y.reason==="none-lower"?"No lower timeframe available":y.reason==="not-lower"?"Pick a timeframe below the chart":"No data source";this.paintMagnifierNotice(e,S,l,u,h,p,i);}if(e.save(),e.strokeStyle=t.style.lineColor||_e(i.background),e.lineWidth=t.style.lineWidth||1,e.setLineDash(Xn(t.style.lineStyle,t.style.lineWidth||1)),e.strokeRect(l,u,h,p),e.restore(),h>44){let S=to(y?.state==="ready"||y?.state==="loading"?y.timeframe:t.magnifier.timeframe),E=17,T=4,k=n.paneRect?.(t.paneId),x=k?k.top+k.height:n.height,w=d+T+E<=x?d+T:d-T-E;e.save(),e.font=`10px ${i.fontFamily}`;let M=e.measureText(S).width,C=M+12+11;Nt(e,l,w,C,E,3),e.fillStyle=i.background,e.fill(),e.strokeStyle=q(i.textColor,.28),e.lineWidth=1,e.setLineDash([]),e.stroke(),e.fillStyle=i.textColor,e.textAlign="left",e.textBaseline="middle",e.fillText(S,l+6,w+E/2+.5);let A=l+6+M+5,$=w+E/2;e.strokeStyle=q(i.textColor,.7),e.lineWidth=1.2,e.beginPath(),e.moveTo(A,$-1.5),e.lineTo(A+2.5,$+1.5),e.lineTo(A+5,$-1.5),e.stroke(),e.restore(),t.chipRect={x:l,y:w,w:C,h:E};}else t.chipRect=null;}paintMagnifierBars(e,t,n,i,o,s,a,l,c,u,d){e.setLineDash([]),e.lineWidth=1;for(let h of i){let p=n.xOf(h.time)-s,m=n.xOf(h.time+o)-s;if(m<a||p>l)continue;let f=n.yOf(h.high,t.paneId),g=n.yOf(h.low,t.paneId),b=n.yOf(h.open,t.paneId),y=n.yOf(h.close,t.paneId);if(f==null||g==null||b==null||y==null)continue;let v=h.close>=h.open?u:d,S=m-p,E=(p+m)/2;if(e.strokeStyle=v,e.beginPath(),e.moveTo(E,f),e.lineTo(E,g),e.stroke(),!(S<3))if(c==="bars"){let T=Math.max(1,S*.35);e.beginPath(),e.moveTo(E-T,b),e.lineTo(E,b),e.moveTo(E,y),e.lineTo(E+T,y),e.stroke();}else {let T=Math.max(1,S*.7);e.fillStyle=v,e.fillRect(E-T/2,Math.min(b,y),T,Math.max(1,Math.abs(y-b)));}}}paintMagnifierLine(e,t,n,i,o,s,a,l,c){let u=[];for(let d of i){let h=n.yOf(d.close,t.paneId);h!=null&&u.push([n.xOf(d.time+o/2)-s,h]);}if(!(u.length<2)){if(l){e.beginPath(),e.moveTo(u[0][0],a);for(let[d,h]of u)e.lineTo(d,h);e.lineTo(u[u.length-1][0],a),e.closePath(),e.fillStyle=q(c,.15),e.fill();}e.setLineDash([]),e.lineWidth=1.5,e.strokeStyle=c,e.beginPath(),e.moveTo(u[0][0],u[0][1]);for(let d=1;d<u.length;d+=1)e.lineTo(u[d][0],u[d][1]);e.stroke();}}paintMagnifierNotice(e,t,n,i,o,s,a){o<60||s<20||(e.save(),e.beginPath(),e.rect(n,i,o,s),e.clip(),e.font=`11px ${a.fontFamily}`,e.fillStyle=q(a.textColor,.55),e.textAlign="center",e.textBaseline="middle",e.fillText(t,n+o/2,i+s/2),e.restore());}paintPlacementHint(e,t,n,i,o){e.save(),e.font=`11px ${n.fontFamily}`;let a=e.measureText(t).width+24,l=24,c=(i-a)/2,u=o-l-14;Nt(e,c,u,a,l,l/2),e.fillStyle=n.background,e.fill(),e.strokeStyle=q(n.textColor,.28),e.lineWidth=1,e.setLineDash([]),e.stroke(),e.fillStyle=n.textColor,e.textAlign="center",e.textBaseline="middle",e.fillText(t,i/2,u+l/2+.5),e.restore();}paintFixedRangeVp(e,t,n,i){let o=t.layout(n);if(!o)return;let s=t.frvp,{profile:a,maxW:l,anchorX:c,grow:u,yEdges:d}=o;if(a.maxTotal<=0||l<=0)return;for(let f=0;f<a.rows.length;f+=1){let g=a.rows[f],b=g.up+g.down;if(b<=0)continue;let y=d[f],v=d[f+1],S=Math.min(y,v),E=Math.max(1,Math.abs(v-y)-1),T=b/a.maxTotal*l,k=g.up/b*T,x=f>=a.vaFrom&&f<=a.vaTo,L=x?s.vaUpColor:s.upColor,w=x?s.vaDownColor:s.downColor,M=u===1?c:c-T;k>0&&(e.fillStyle=L,e.fillRect(M,S,k,E)),T-k>0&&(e.fillStyle=w,e.fillRect(M+k,S,T-k,E));}let h=t.style.lineWidth,p=(f,g,b,y)=>{!f||y==null||Lw(g)||this.stroke(e,{lineColor:g,lineWidth:h,lineStyle:b},()=>{e.moveTo(o.x0,y),e.lineTo(o.x1,y);});};p(s.showVah,s.vahColor,s.vahStyle,o.vahY),p(s.showVal,s.valColor,s.valStyle,o.valY),p(s.showPoc,s.pocColor??_e(i.background),s.pocStyle,o.pocY);let m=Math.max(1,h);if(s.showDevelopingPoc&&this.strokePolyline(e,o.developingPoc,{lineColor:s.developingPocColor,lineWidth:m,lineStyle:s.developingPocStyle}),s.showDevelopingVa){let f={lineColor:s.developingVaColor,lineWidth:m,lineStyle:s.developingVaStyle};this.strokePolyline(e,o.developingVaHigh,f),this.strokePolyline(e,o.developingVaLow,f);}}paintAnchoredVwap(e,t,n){let i=t.layout(n);if(!i)return;let o=t.vwap,s=t.style.lineWidth;if(i.upper.length>=2&&o.bandFill){e.save(),e.fillStyle=o.bandFill,e.beginPath(),e.moveTo(i.upper[0][0],i.upper[0][1]);for(let a=1;a<i.upper.length;a+=1)e.lineTo(i.upper[a][0],i.upper[a][1]);for(let a=i.lower.length-1;a>=0;a-=1)e.lineTo(i.lower[a][0],i.lower[a][1]);e.closePath(),e.fill(),e.restore();}this.strokePolyline(e,i.upper,{lineColor:o.upperColor,lineWidth:s,lineStyle:o.upperStyle}),this.strokePolyline(e,i.lower,{lineColor:o.lowerColor,lineWidth:s,lineStyle:o.lowerStyle}),this.strokePolyline(e,i.mid,{lineColor:o.midColor,lineWidth:s,lineStyle:o.midStyle});}strokePolyline(e,t,n){t.length<2||Lw(n.lineColor)||this.stroke(e,n,()=>{e.moveTo(t[0][0],t[0][1]);for(let i=1;i<t.length;i+=1)e.lineTo(t[i][0],t[i][1]);});}paintCallout(e,t,n,i){this.paintBubble(e,t,n,i,5);}paintComment(e,t,n,i){this.paintBubble(e,t,n,i,999);}paintBubble(e,t,n,i,o){let s=t.points(n);if(!s)return;let a=s[0][0],l=s[0][1],c=s[1][0],u=s[1][1],d=t.text,h=Be(d?.size??"normal");e.font=`${d?.bold?"bold ":""}${d?.italic?"italic ":""}${h}px ${i.fontFamily}`;let p=(d?.value??"").split(`
|
|
900
|
+
`),m=Math.max(8,...p.map(P=>e.measureText(P).width)),f=9,g=6,b=on(h),y=m+f*2,v=p.length*b+g*2,S=c-y/2,E=u-v/2,T=y/2,k=v/2,x=a-c,L=l-u,w=Math.min(o,y/2,v/2),M=null;if(Math.abs(x)>T||Math.abs(L)>k){let P=Math.max(6,Math.min(y,v)*.18);if(Math.abs(x)/T>=Math.abs(L)/k){let C=x>0?S+y:S,A=Math.max(E+w+P,Math.min(E+v-w-P,u+L*(C-c)/(x||1)));M={edge:x>0?"right":"left",at:A,apex:[a,l],half:P};}else {let C=L>0?E+v:E,A=Math.max(S+w+P,Math.min(S+y-w-P,c+x*(C-u)/(L||1)));M={edge:L>0?"bottom":"top",at:A,apex:[a,l],half:P};}}e.save(),e.fillStyle=wt(t,i)??i.background,Pw(e,S,E,y,v,w,M),e.fill(),e.restore(),this.applyStroke(e,t.style),Pw(e,S,E,y,v,w,M),e.stroke(),e.setLineDash([]),e.fillStyle=d?.color??_e(wt(t,i)??i.background),e.textBaseline="top",e.textAlign="left",p.forEach((P,C)=>e.fillText(P,S+f,E+g+C*b));}paintTextPlate(e,t,n,i,o,s,a,l,c,u,d){e.save(),e.fillStyle=wt(t,n)??n.background,Nt(e,i,o,s,a,5),e.fill(),e.restore(),this.applyStroke(e,t.style),Nt(e,i,o,s,a,5),e.stroke(),e.setLineDash([]),e.fillStyle=t.text?.color??_e(wt(t,n)??n.background),e.textBaseline="top",e.textAlign="left",l.forEach((h,p)=>e.fillText(h,i+u,o+d+p*c));}measureText(e,t,n,i){let o=t.text,s=Be(o?.size??"normal");e.font=`${o?.bold?"bold ":""}${o?.italic?"italic ":""}${s}px ${n.fontFamily}`;let a=(o?.value||i).split(`
|
|
901
|
+
`),l=Math.max(8,...a.map(c=>e.measureText(c).width));return {lines:a,tw:l,fs:s,lh:on(s)}}paintNote(e,t,n,i){let o=t.handlePoints(n);if(!o.length)return;let[s,a]=o[0],{lines:l,tw:c,lh:u}=this.measureText(e,t,i,"Note"),d=8,h=5;this.paintTextPlate(e,t,i,s,a,c+d*2,l.length*u+h*2,l,u,d,h);}paintPriceNote(e,t,n,i){let o=t.points(n),s=t.anchors[0];if(!o||!s)return;let[a,l]=o[0],[c,u]=o[1],d=Mw(s.price),h=t.text,p=Be(h?.size??"normal");e.font=`${h?.bold?"bold ":""}${h?.italic?"italic ":""}${p}px ${i.fontFamily}`;let m=9,f=6,g=e.measureText(d).width+m*2,b=on(p)+f*2,y=c-g/2,v=u-b/2;this.stroke(e,t.style,()=>{e.moveTo(a,l),e.lineTo(c,u);}),e.fillStyle=t.style.lineColor,e.beginPath(),e.arc(a,l,3,0,Math.PI*2),e.fill(),e.save(),e.fillStyle=wt(t,i)??i.background,Nt(e,y,v,g,b,5),e.fill(),e.restore(),this.applyStroke(e,t.style),Nt(e,y,v,g,b,5),e.stroke(),e.setLineDash([]),e.fillStyle=h?.color??_e(wt(t,i)??i.background),e.textBaseline="middle",e.textAlign="center",e.fillText(d,c,u+.5);}paintSignpost(e,t,n,i){let o=t.points(n);if(!o)return;let[s,a]=o[0],[l,c]=o[1],{lines:u,tw:d,lh:h}=this.measureText(e,t,i,"Signpost"),p=9,m=6,f=d+p*2,g=u.length*h+m*2;this.stroke(e,t.style,()=>{e.moveTo(s,a),e.lineTo(l,c);}),e.fillStyle=t.style.lineColor,e.beginPath(),e.arc(s,a,3.5,0,Math.PI*2),e.fill(),this.paintTextPlate(e,t,i,l-f/2,c-g/2,f,g,u,h,p,m);}paintPriceLabel(e,t,n,i){let o=t.handlePoints(n),s=t.anchors[0];if(!o.length||!s)return;let[a,l]=o[0],c=Mw(s.price),u=t.text,d=Be(u?.size??"normal");e.font=`${u?.bold?"bold ":""}${u?.italic?"italic ":""}${d}px ${i.fontFamily}`;let h=e.measureText(c).width,p=8,m=4,f=6,g=h+p*2,b=on(d)+m*2,y=l-b/2,v=wt(t,i)??i.background;e.save(),e.fillStyle=v,e.beginPath(),e.moveTo(a,l),e.lineTo(a+f,l-5),e.lineTo(a+f,l+5),e.closePath(),e.fill(),Nt(e,a+f,y,g,b,4),e.fill(),e.restore(),this.applyStroke(e,t.style),Nt(e,a+f,y,g,b,4),e.stroke(),e.setLineDash([]),e.fillStyle=u?.color??_e(v),e.textBaseline="middle",e.textAlign="left",e.fillText(c,a+f+p,l+.5);}paintPattern(e,t,n,i){let o=t.handlePoints(n);if(o.length<2)return;let s=t.valid(),a=wt(t,i)??t.style.lineColor,l=t.style.fillColor?1:.1;for(let[h,p,m]of t.fillTriangles()){let f=o[h],g=o[p],b=o[m];!f||!g||!b||(e.save(),e.globalAlpha=l*e.globalAlpha,e.fillStyle=a,e.beginPath(),e.moveTo(f[0],f[1]),e.lineTo(g[0],g[1]),e.lineTo(b[0],b[1]),e.closePath(),e.fill(),e.restore());}this.stroke(e,t.style,()=>{e.moveTo(o[0][0],o[0][1]);for(let h=1;h<o.length;h+=1)e.lineTo(o[h][0],o[h][1]);});let c=t.necklineIndices();if(c){let h=o[c[0]],p=o[c[1]],m=o.length;if(h&&p&&m>=2){let f=Mu(h[0],h[1],p[0],p[1],o[0][0],o[0][1],o[1][0],o[1][1])??h,g=Mu(h[0],h[1],p[0],p[1],o[m-2][0],o[m-2][1],o[m-1][0],o[m-1][1])??p;this.stroke(e,{...t.style,lineStyle:"dashed"},()=>{e.moveTo(f[0],f[1]),e.lineTo(g[0],g[1]);});}}let u=t.vertexLabels();if(e.fillStyle=i.textColor,e.font=`bold 12px ${i.fontFamily}`,e.textAlign="center",o.forEach((h,p)=>{let m=u[p];if(!m)return;let f=((o[p-1]?.[1]??h[1])+(o[p+1]?.[1]??h[1]))/2,g=h[1]<=f;e.textBaseline=g?"bottom":"top",e.fillText(m,h[0],g?h[1]-7:h[1]+7);}),t.legRatios()){e.font=`11px ${i.fontFamily}`,e.textAlign="left",e.textBaseline="middle";for(let h=2;h<o.length;h+=1){let p=t.ratioAt(h),m=o[h-1],f=o[h];if(p==null||!m||!f)continue;let g=t.ratioOk(h);e.fillStyle=g===true?ys:g===false?ws:i.textColor,e.fillText(p.toFixed(3),(m[0]+f[0])/2+6,(m[1]+f[1])/2);}}let d=t.patternName();if(d&&o.length>=2){let h=o[o.length-1],p=o[o.length-2],m=p?h[1]<=p[1]:false;e.font=`bold 12px ${i.fontFamily}`,e.fillStyle=s===false?ws:ys,e.textAlign="center",e.textBaseline=m?"bottom":"top",e.fillText(`${d} ${s?"\u2713":"\u2717"}`,h[0],m?h[1]-22:h[1]+22);}e.textAlign="left",e.textBaseline="alphabetic";}paintHighlighter(e,t,n){let i=t.geometry(n);if(!i||i.segments.length===0)return;e.save(),e.strokeStyle=t.style.lineColor,e.lineWidth=t.style.lineWidth,e.lineCap="round",e.lineJoin="round",e.setLineDash([]),e.beginPath();let o=i.segments[0];e.moveTo(o[0],o[1]);for(let s of i.segments)e.lineTo(s[2],s[3]);e.stroke(),e.restore();}paintSegments(e,t,n){let i=t.geometry(n);if(i){if(i.fill&&i.fill.length>=3&&t.style.fillColor){e.save(),e.fillStyle=t.style.fillColor,e.beginPath(),e.moveTo(i.fill[0][0],i.fill[0][1]);for(let o=1;o<i.fill.length;o+=1)e.lineTo(i.fill[o][0],i.fill[o][1]);e.closePath(),e.fill(),e.restore();}for(let o of i.segments)this.stroke(e,t.style,()=>{e.moveTo(o[0],o[1]),e.lineTo(o[2],o[3]);});}}paintInfoLine(e,t,n){let i=t.handlePoints(n);if(i.length<2)return;let[o,s]=i[0],[a,l]=i[1];this.stroke(e,t.style,()=>{e.moveTo(o,s),e.lineTo(a,l);});let c=t.anchors[0],u=t.anchors[1];if(!c||!u)return;let d=u.price-c.price,h=c.price!==0?d/c.price*100:0,p=n.barsBetween?Math.abs(Math.round(n.barsBetween(c.time,u.time))):0,m=d>=0?"+":"",f=`${m}${d.toFixed(2)} (${m}${h.toFixed(2)}%) ${p} bars`,g=(o+a)/2,b=(s+l)/2;e.font="11px monospace";let y=e.measureText(f).width+12,v=18,S=g-2,E=b-v-4;e.save(),e.globalAlpha=.9*e.globalAlpha,Nt(e,S,E,y,v,3),e.fillStyle=kw,e.fill(),e.strokeStyle=MM,e.lineWidth=1,e.stroke(),e.restore(),e.fillStyle=d>=0?z:W,e.textAlign="left",e.textBaseline="middle",e.fillText(f,S+6,E+v/2),e.textBaseline="alphabetic";}paintTrendAngle(e,t,n,i){let o=t.handlePoints(n);if(o.length<2)return;let[s,a]=o[0],[l,c]=o[1];this.stroke(e,t.style,()=>{e.moveTo(s,a),e.lineTo(l,c);});let u=l-s,d=c-a,h=Math.atan2(-d,u),p=h*(180/Math.PI),m=Math.min(30,Math.hypot(u,d)*.3),f=t.style.lineColor;if(e.save(),e.globalAlpha=.4*e.globalAlpha,e.strokeStyle=f,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(s,a),e.lineTo(s+Math.max(Math.abs(u),m+20),a),e.stroke(),e.restore(),e.setLineDash([]),m>1){let g=-h;e.strokeStyle=f,e.lineWidth=1.5,e.beginPath(),e.arc(s,a,m,Math.min(0,g),Math.max(0,g)),e.stroke();}e.fillStyle=f,e.font=`11px ${i.fontFamily}`,e.textAlign="left",e.textBaseline="alphabetic",e.fillText(`${p.toFixed(1)}\xB0`,s+m+6,a+(d<0?-14:2));}paintArrowMark(e,t,n){let i=t.glyphPoints(n);if(!(!i||i.length<3)){e.save(),e.setLineDash([]),e.fillStyle=t.style.lineColor,e.beginPath(),e.moveTo(i[0][0],i[0][1]);for(let o=1;o<i.length;o+=1)e.lineTo(i[o][0],i[o][1]);e.closePath(),e.fill(),e.restore();}}paintGlyphStamp(e,t,n,i){let o=t.center(n);o&&(e.save(),e.setLineDash([]),e.font=`${t.sizePx()}px ${i.fontFamily}`,e.fillStyle=t.style.lineColor,e.textAlign="center",e.textBaseline="middle",e.fillText(t.glyph,o[0],o[1]),e.textAlign="left",e.textBaseline="alphabetic",e.restore());}paintArrowhead(e,t,n,i){let o=Math.atan2(n[1]-t[1],n[0]-t[0]),s=Math.max(9,i.lineWidth*3.5),a=Math.PI/7;e.save(),e.setLineDash([]),e.fillStyle=i.lineColor,e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(n[0]-s*Math.cos(o-a),n[1]-s*Math.sin(o-a)),e.lineTo(n[0]-s*Math.cos(o+a),n[1]-s*Math.sin(o+a)),e.closePath(),e.fill(),e.restore();}stroke(e,t,n){this.applyStroke(e,t),e.beginPath(),n(),e.stroke(),e.setLineDash([]);}applyStroke(e,t){e.strokeStyle=t.lineColor,e.lineWidth=t.lineWidth,e.setLineDash(Xn(t.lineStyle,t.lineWidth));}paintHandles(e,t){e.setLineDash([]),e.lineWidth=1.5;for(let[n,i]of t)e.beginPath(),e.arc(n,i,kM,0,Math.PI*2),e.fillStyle=EM,e.fill(),e.strokeStyle=Nh,e.stroke();}};function Lw(r){let e=r.trim().toLowerCase();if(/^#[0-9a-f]{8}$/.test(e))return e.endsWith("00");let t=/rgba?\([^)]*,\s*([\d.]+)\s*\)$/.exec(e);return t?parseFloat(t[1])===0:false}function Mw(r){let e=Mh(r);return r.toLocaleString("en-US",{minimumFractionDigits:e,maximumFractionDigits:e})}function Nt(r,e,t,n,i,o){let s=Math.min(o,n/2,i/2);r.beginPath(),r.moveTo(e+s,t),r.arcTo(e+n,t,e+n,t+i,s),r.arcTo(e+n,t+i,e,t+i,s),r.arcTo(e,t+i,e,t,s),r.arcTo(e,t,e+n,t,s),r.closePath();}function Pw(r,e,t,n,i,o,s){let a=(l,c,u)=>{if(s&&s.edge===l){let[d,h]=s.apex;l==="top"?(r.lineTo(s.at-s.half,t),r.lineTo(d,h),r.lineTo(s.at+s.half,t)):l==="bottom"?(r.lineTo(s.at+s.half,t+i),r.lineTo(d,h),r.lineTo(s.at-s.half,t+i)):l==="right"?(r.lineTo(e+n,s.at-s.half),r.lineTo(d,h),r.lineTo(e+n,s.at+s.half)):(r.lineTo(e,s.at+s.half),r.lineTo(d,h),r.lineTo(e,s.at-s.half));}r.lineTo(c,u);};r.beginPath(),r.moveTo(e+o,t),a("top",e+n-o,t),r.arcTo(e+n,t,e+n,t+o,o),a("right",e+n,t+i-o),r.arcTo(e+n,t+i,e+n-o,t+i,o),a("bottom",e+o,t+i),r.arcTo(e,t+i,e,t+i-o,o),a("left",e,t+o),r.arcTo(e,t,e+o,t,o),r.closePath();}function PM(r){if(!Number.isFinite(r))return "";let e=Math.round(r*1e3)/1e3;return String(e)}function IM(r,e){let t=r.text;if(!t)return null;let n=r.handlePoints(e),i=t.value.split(`
|
|
902
|
+
`).length,o=on(Be(t.size));switch(r.type){case "text":return n[0]?{x:n[0][0]+2,top:n[0][1]+2,align:"left"}:null;case "hline":return n[0]?{x:n[0][0]+8,top:n[0][1]-4-o*i,align:"left"}:null;case "trendline":case "ray":case "extendedline":case "infoline":case "trendangle":{if(n.length<2)return null;let[s,a]=n[0],[l,c]=n[1];return {x:0,top:-6-o*i,align:"center",rotate:{angle:Jy(s,a,l,c),cx:(s+l)/2,cy:(a+c)/2}}}case "box":return n.length<2?null:{x:(n[0][0]+n[1][0])/2,top:(n[0][1]+n[1][1])/2-o*i/2,align:"center"};default:return n[0]?{x:n[0][0],top:n[0][1],align:"left"}:null}}function _i(r,e,t,n,i=6){for(let o=r.length-1;o>=0;o-=1){let s=r[o];if(!s.visible)continue;let a=n.paneRect?.(s.paneId);if(!(a&&a.height<=0)&&s.hitTest(e,t,n,i))return s}return null}function Vh(r,e){let t=[...r];return t.length<2?t:t.filter(n=>!e.find(i=>i.id===n)?.locked)}function Iw(r,e,t,n){return n&&e.size>=2&&e.has(r.id)?Vh(e,t):r.locked?[]:[r.id]}var Gc=3,AM=4,Aw=Math.PI/4,Rw=new Set(["trendline","ray","extendedline","infoline","trendangle","arrow"]),Uc=class{constructor(e){this.deps=e;this.state={kind:"idle"};this.snapAt=null;}snapMarker(){return this.snapAt}placingMarkers(e){if(this.state.kind!=="placing")return null;let{draft:t}=this.state;if(t.placementMode()==="freehand")return null;let n=[];for(let i of t.anchors){let o=e.yOf(i.price,t.paneId);o!=null&&n.push([e.xOf(i.time),o]);}return n.length?n:null}resolve(e,t,n,i){let o=this.deps.projector().pxToPoint(e,t,n);if(i==="off")return this.snapAt=null,o;let s=this.deps.snap(o,n,i,{x:e,y:t}),a=s.time!==o.time||s.price!==o.price;return this.snapAt=a?{point:s,paneId:n}:null,s}snapCursor(e,t,n){let i=this.deps.projector(),o=i.paneIdAtY(t)??"price",s=this.resolve(e,t,o,n),a=i.yOf(s.price,o);return {x:i.xOf(s.time),y:a??t}}clearSnapMarker(){this.snapAt=null;}resolveAngleSnapped(e,t,n,i){let o=this.deps.projector(),s=o.xOf(e.time),a=o.yOf(e.price,t);if(this.snapAt=null,a==null)return o.pxToPoint(n,i,t);let l=Math.hypot(n-s,i-a);if(l<1)return o.pxToPoint(n,i,t);let c=Math.round(Math.atan2(i-a,n-s)/Aw)*Aw;return o.pxToPoint(s+l*Math.cos(c),a+l*Math.sin(c),t)}placingPivot(e){return Rw.has(e.type)?e.anchors[e.anchors.length-1]??null:null}claim(e,t){return this.deps.activeTool()!=null||this.state.kind!=="idle"?true:this.hitAt(e,t)!=null}cursorAt(e,t){return this.deps.activeTool()!=null?null:this.hitAt(e,t)?"pointer":null}isPlacing(){return this.state.kind==="placing"}isDragging(){return this.state.kind==="pressed"&&this.state.moved}activeDragId(){return this.state.kind==="pressed"&&this.state.moved?this.state.id:null}pressedId(){return this.state.kind==="pressed"?this.state.id:null}dragClones(){return this.state.kind==="pressed"&&this.state.moved&&this.state.clones?this.state.clones.map(e=>e.d):null}marqueeRect(){if(this.state.kind!=="marquee")return null;let{x0:e,y0:t,x1:n,y1:i}=this.state;return {x:Math.min(e,n),y:Math.min(t,i),w:Math.abs(n-e),h:Math.abs(i-t)}}beginMarquee(e,t){return this.state.kind!=="idle"||this.deps.activeTool()!=null?false:(this.state={kind:"marquee",x0:e,y0:t,x1:e,y1:t},true)}down(e,t,n="off",i=false,o=false){let s=this.deps.projector();if(this.state.kind==="placing"){if(this.state.draft.placementMode()!=="click")return;let c=i?this.placingPivot(this.state.draft):null,u=c?this.resolveAngleSnapped(c,this.state.draft.paneId,e,t):this.resolve(e,t,this.state.draft.paneId,n);this.state.draft.anchors.push(this.placementAnchor(this.state.draft,u)),this.state.draft.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let a=this.deps.activeTool();if(a){let c=s.paneIdAtY(t)??"price",u=On(a,{paneId:c,anchors:[this.resolve(e,t,c,n)],style:this.deps.lastStyle()});if(!u)return;this.state={kind:"placing",draft:u,need:u.anchorSchema().max,cursor:null},u.placementMode()==="click"&&u.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let l=this.hitAt(e,t);if(l){if(i){this.deps.emit({kind:"select",ids:[l.id],additive:true});return}let c=l.hitHandle(e,t,s,6),u=[];if(c<0&&this.deps.selectedIds().has(l.id))for(let d of this.deps.selectedIds()){let h=d===l.id?null:this.byId(d);h&&!h.locked&&h.visible&&u.push({id:d,orig:_h(h)});}this.state={kind:"pressed",id:l.id,handle:c,orig:_h(l),px:e,py:t,moved:false,riders:u,mod:o,clones:null};}}bodyDelta(e,t,n){if(this.state.kind!=="pressed")return {dt:0,dp:0};let i=this.deps.projector(),o=i.pxToPoint(this.state.px,this.state.py,e),s=i.pxToPoint(t,n,e);return {dt:s.time-o.time,dp:s.price-o.price}}dragSources(e){if(this.state.kind!=="pressed")return [];let t=[{d:e,orig:this.state.orig}];for(let n of this.state.riders){let i=this.byId(n.id);i&&t.push({d:i,orig:n.orig});}return t}dragBody(e,t,n){if(this.state.kind==="pressed"){this.snapAt=null,this.state.mod&&!this.state.clones&&(this.state.clones=this.dragSources(e).flatMap(i=>{let o=pt(i.d.serialize());return o?[{d:o,orig:_h(o)}]:[]}));for(let i of this.state.clones??this.dragSources(e)){let{dt:o,dp:s}=this.bodyDelta(i.d.paneId,t,n);i.d.anchors=i.d.translateBody(o,s,i.orig);}}}move(e,t,n="off",i=false){if(this.state.kind==="idle"){let s=this.deps.activeTool(),a=this.snapAt!=null;s&&n!=="off"?this.resolve(e,t,this.deps.projector().paneIdAtY(t)??"price",n):this.snapAt=null,(this.snapAt!=null||a)&&this.deps.changed();return}if(this.state.kind==="placing"){if(this.state.draft.placementMode()==="freehand"){this.captureFreehand(e,t);return}let s=i?this.placingPivot(this.state.draft):null;this.state.cursor=s?this.resolveAngleSnapped(s,this.state.draft.paneId,e,t):this.resolve(e,t,this.state.draft.paneId,n),this.deps.changed();return}if(this.state.kind==="marquee"){this.state.x1=e,this.state.y1=t,this.deps.changed();return}if(this.state.kind!=="pressed")return;let o=this.byId(this.state.id);if(!(!o||o.locked)&&!(!this.state.moved&&Math.abs(e-this.state.px)<=Gc&&Math.abs(t-this.state.py)<=Gc)){if(this.state.moved=true,this.state.handle<0)this.dragBody(o,e,t);else {let s=o.anchors[this.state.handle];if(s){let a=i&&Rw.has(o.type)&&o.anchors.length===2?o.anchors[1-this.state.handle]:void 0,l=a?this.resolveAngleSnapped(a,o.paneId,e,t):this.resolve(e,t,o.paneId,n);DM(s,l,o.anchorSchema().slots[this.state.handle]?.free??"both");}o.constrainHandleDrag(this.state.handle);}this.deps.changed();}}up(e,t){if(this.snapAt=null,this.state.kind==="placing"){let c=this.state.draft.placementMode();c==="drag"?(this.state.cursor&&this.state.draft.anchors.push(this.state.cursor),this.state.draft.anchors.length>=this.state.draft.anchorSchema().min?this.finalize():this.discardPlacing()):c==="freehand"&&(this.state.draft.anchors.length>=this.state.draft.anchorSchema().min?this.finalize():this.discardPlacing());return}if(this.state.kind==="marquee"){let c=this.marqueeRect();this.state={kind:"idle"},(c.w>Gc||c.h>Gc)&&this.selectWithin(c),this.deps.changed();return}if(this.state.kind!=="pressed")return;let{id:n,moved:i,riders:o,mod:s,clones:a}=this.state;this.state={kind:"idle"};let l=this.byId(n);if(!i){s?this.deps.emit({kind:"select",ids:[n],additive:true}):this.deps.openSettings(n,e,t);return}if(a)this.deps.emit({kind:"clone",docs:a.map(c=>c.d.serialize())});else if(l){let c=[l.serialize()];for(let u of o){let d=this.byId(u.id);d&&c.push(d.serialize());}c.length>1?this.deps.emit({kind:"edit-many",docs:c}):this.deps.emit({kind:"edit",doc:c[0]});}this.deps.changed();}selectWithin(e){let t=this.deps.projector(),n=[...this.deps.selectedIds()];for(let i of this.deps.drawings()){if(!i.visible||n.includes(i.id))continue;let o=i.bounds(t);o&&RM(e,o)&&n.push(i.id);}n.length>this.deps.selectedIds().size&&this.deps.emit({kind:"select",ids:n});}cancel(){if(this.snapAt=null,this.state.kind==="placing"){let e=this.state.draft.type;return this.state={kind:"idle"},this.deps.emit({kind:"tool-finished",type:e}),this.deps.changed(),true}if(this.state.kind==="pressed"){if(this.state.moved&&!this.state.clones){let e=this.byId(this.state.id);if(e)for(let t of this.dragSources(e))t.d.anchors=t.orig.map(n=>({time:n.time,price:n.price}));}return this.state={kind:"idle"},this.deps.changed(),true}return this.state.kind==="marquee"?(this.state={kind:"idle"},this.deps.changed(),true):false}onToolCleared(){this.state.kind==="placing"&&(this.state={kind:"idle"},this.deps.changed());}ghost(){if(this.state.kind!=="placing")return null;let{draft:e,cursor:t}=this.state;return t?On(e.type,{paneId:e.paneId,anchors:[...e.anchors,this.placementAnchor(e,t)],style:e.style}):e.anchors.length>=1&&e.type==="hline"?e:null}placementAnchor(e,t){if(e.type!=="parallelchannel"||e.anchors.length!==2)return t;let n=e.anchors[0],i=e.anchors[1],o=i.time-n.time,s=o===0?n.price:n.price+(i.price-n.price)*(t.time-n.time)/o,a=t.price-s;return {time:(n.time+i.time)/2,price:(n.price+i.price)/2+a}}captureFreehand(e,t){if(this.state.kind!=="placing")return;this.snapAt=null;let n=this.state.draft,i=this.deps.projector(),o=n.anchors[n.anchors.length-1],s=o?i.xOf(o.time):NaN,a=o?i.yOf(o.price,n.paneId)??NaN:NaN;if(Math.hypot(e-s,t-a)>AM){if(n.anchors.length>=this.state.need){let l=n.anchors.length-1;n.anchors=n.anchors.filter((c,u)=>u%2===0||u===l);}n.anchors.push(i.pxToPoint(e,t,n.paneId));}this.state.cursor=i.pxToPoint(e,t,n.paneId),this.deps.changed();}finishPlacing(e){if(this.state.kind!=="placing")return false;let t=this.state.draft,n=t.anchorSchema();return t.placementMode()!=="click"||n.max<=n.min||(e&&t.anchors.length>n.min&&t.anchors.pop(),t.anchors.length<n.min)?false:(this.finalize(),true)}discardPlacing(){if(this.state.kind!=="placing")return;let e=this.state.draft.type;this.state={kind:"idle"},this.deps.emit({kind:"tool-finished",type:e}),this.deps.changed();}finalize(){if(this.state.kind!=="placing")return;this.snapAt=null;let e=this.state.draft;e.onPlaced(this.deps.projector());let t=e.type;this.state={kind:"idle"},this.deps.emit({kind:"create",doc:e.serialize()}),this.deps.emit({kind:"tool-finished",type:t}),this.deps.changed();}hitAt(e,t){let n=this.deps.projector();for(let i of this.handleDrawings())if(i.hitHandle(e,t,n,6)>=0)return i;return _i(this.deps.drawings(),e,t,n,6)}handleDrawings(){let e=new Set(this.deps.selectedIds()),t=this.deps.hoveredId();t&&e.add(t);let n=[];for(let i of e){let o=this.byId(i);o&&n.push(o);}return n}byId(e){return this.deps.drawings().find(t=>t.id===e)??null}};function _h(r){return r.anchors.map(e=>({time:e.time,price:e.price}))}function RM(r,e){return r.x<=e.x+e.w&&e.x<=r.x+r.w&&r.y<=e.y+e.h&&e.y<=r.y+r.h}function DM(r,e,t){(t==="both"||t==="x")&&(r.time=e.time),(t==="both"||t==="y")&&(r.price=e.price);}var OM=[{value:"price",label:"Price"},{value:"points",label:"Points"}],NM=[{value:"right",label:"Right"},{value:"left",label:"Left"}],FM={position:"Position size",frvp:"Volume profile",levels:"Levels"},Yc=class{constructor(e,t){this.host=e;this.ui=null;this.theme=t;}setTheme(e){this.theme=e;}isOpen(){return this.ui!=null}contains(e){return this.ui?.contains(e)===true}open(e,t,n){this.close();let i=Wt(e.serialize()),o=ns({variant:"inputs"});if(o.style.padding="16px 20px",o.style.overflowY="auto",o.style.overflowX="hidden",o.style.flex="1 1 auto",n==="position"&&e instanceof ht)this.buildPosition(o,e,t);else if(n==="frvp"&&e instanceof at)this.buildFrvp(o,e,t);else if(n==="levels")this.buildLevels(o,e,t);else return;let s=new wn({host:this.host,title:FM[n],modal:false,contained:true,align:"center",draggable:true,flush:true,className:"vela-dialog--form",closeOnEscape:false,footer:l=>{l.append(Dw("Cancel",false,()=>{t.restore?.(i),this.close();}),Dw("Ok",true,()=>this.close()));},onOpenChange:l=>{l||this.close();}});Re(s.panel,this.theme),s.body.appendChild(o);let a=l=>{if(!(l.target!==s.backdrop&&l.target!==s.positioner)){if(tn()||Ir(l)){Te();return}this.close();}};s.backdrop.addEventListener("pointerdown",a),s.positioner.addEventListener("pointerdown",a),s.panel.addEventListener("keydown",l=>{l.key==="Escape"&&(l.preventDefault(),t.restore?.(i),this.close());}),this.ui=s,s.show();}close(){let e=this.ui;this.ui=null,e?.destroy();}destroy(){this.close();}buildPosition(e,t,n){let i=()=>{let p=n.resolve();return p instanceof ht?p:t},o=[],s=()=>o.forEach(p=>p()),a=p=>Math.round(p*1e8)/1e8,l=(p,m,f)=>{let g=se({kind:"number",value:a(i()[m]),min:f?.min,max:f?.max,step:f?.step,integer:f?.integer,fill:false,commit:"blur",onChange:b=>{n.patch({[m]:b}),s();}});o.push(()=>{document.activeElement!==g.el.querySelector("input")&&g.setValue?.(a(i()[m]));}),e.appendChild(Ae({label:p,control:g.el}));},c=(p,m,f)=>{let g="price",b=()=>a(i().levelDisplayValue(f,g)),y=se({kind:"number",value:b(),fill:false,commit:"blur",onChange:S=>{n.patch({[m]:i().levelPriceFromDisplay(f,g,S)}),s();}}),v=se({kind:"select",options:OM,value:g,fill:false,theme:this.theme,onChange:S=>{g=S,y.setValue?.(b());}});o.push(()=>{document.activeElement!==y.el.querySelector("input")&&y.setValue?.(b());}),e.appendChild(Ae({label:p,control:[y.el,v.el]}));};e.appendChild(xn("Account",{variant:"inputs",first:true})),l("Risk %","riskPercent",{min:0,max:100,step:.1}),l("Account balance","accountBalance",{min:0,max:1e12,step:1,integer:true}),l("Position size","quantity"),e.appendChild(xn("Levels",{variant:"inputs"}));let u=se({kind:"select",options:Ka,value:i().direction,fill:false,theme:this.theme,onChange:p=>{n.patch({direction:p}),s();}});o.push(()=>u.setValue?.(i().direction)),e.appendChild(Ae({label:"Direction",control:u.el})),l("Entry price","entryPrice"),c("Stop","stopPrice","stop"),c("Target","targetPrice","target"),e.appendChild(xn("Display",{variant:"inputs"}));let d=[["Show text","showText"],["Show direction & ratio","showHeader"],["Show loss & size","showLossSize"],["Show target label","showTargetLabel"],["Show stop label","showStopLabel"],["Show level prices","showPrices"]];for(let[p,m]of d)e.appendChild(Ae({label:p,bool:true,toggle:{checked:i()[m],onChange:f=>{n.patch({[m]:f}),s();},get:()=>i()[m]}}));let h=document.createElement("div");h.className="vela-field-span",h.style.cssText="opacity:0.7;font-size:11px;line-height:1.4;border-top:1px solid var(--vela-border);padding-top:6px;font-variant-numeric:tabular-nums;",o.push(()=>{let p=i();h.textContent=`${p.headerLabel()} \u2014 ${p.lossSizeLabel()}`;}),e.appendChild(h),s();}buildFrvp(e,t,n){let i=()=>{let u=n.resolve();return u instanceof at?u.frvp:t.frvp},o=i(),s=(u,d,h,p,m,f=true)=>{e.appendChild(Ae({label:u,control:se({kind:"number",value:o[d],min:h,max:p,step:m,integer:f,fill:false,commit:"blur",onChange:g=>n.patch({[`frvp.${d}`]:g})}).el}));};s("Rows","rows",1,500,1),s("Value Area","valueAreaPct",0,100,1),s("Width %","widthPct",0,100,1),e.appendChild(Ae({label:"Anchor",control:se({kind:"select",options:NM,value:o.anchor,fill:false,theme:this.theme,onChange:u=>n.patch({"frvp.anchor":u})}).el}));let a=(u,d)=>{e.appendChild(Ae({label:u,fit:true,control:se({kind:"color",theme:this.theme,get:()=>i()[d],onChange:h=>n.patch({[`frvp.${d}`]:h})}).el}));};a("Up Volume","upColor"),a("Down Volume","downColor"),a("Value Area Up","vaUpColor"),a("Value Area Down","vaDownColor");let l=Xe.map(u=>({value:u.value,label:u.label})),c=(u,d,h,p)=>{let m=document.createElement("div");m.className="vela-field-span",m.style.cssText="display:flex;align-items:center;gap:8px;";let f=se({kind:"switch",checked:!!o[d],onChange:S=>n.patch({[`frvp.${d}`]:S})}),g=document.createElement("span");g.className="vela-field-label",g.style.flex="1",g.textContent=u;let b=o[h]??_e(this.theme.background),y=se({kind:"color",theme:this.theme,get:()=>b,onChange:S=>{b=S,n.patch({[`frvp.${h}`]:S});}}),v=se({kind:"select",options:l,value:o[p],fill:false,theme:this.theme,onChange:S=>n.patch({[`frvp.${p}`]:S})});m.append(f.el,g,y.el,v.el),e.appendChild(m);};c("VAH","showVah","vahColor","vahStyle"),c("VAL","showVal","valColor","valStyle"),c("POC","showPoc","pocColor","pocStyle"),c("Developing POC","showDevelopingPoc","developingPocColor","developingPocStyle"),c("Developing VA","showDevelopingVa","developingVaColor","developingVaStyle");}buildLevels(e,t,n){let i=t.editableLevels();if(!i)return;let o=t instanceof Qe;if(o){let s=t;e.appendChild(Ae({label:"Show ratio labels",bool:true,toggle:{checked:s.showRatios!==false,onChange:a=>n.patch({showRatios:a})}}));}i.forEach((s,a)=>{let l=document.createElement("div");l.className="vela-field-span",l.style.cssText="display:flex;align-items:center;gap:8px;";let c=se({kind:"switch",checked:s.enabled,onChange:m=>n.patch({[`levels.${a}.enabled`]:m})}),u=s.color,d=se({kind:"color",theme:this.theme,get:()=>u,onChange:m=>{u=m,n.patch({[`levels.${a}.color`]:m});}}),h=s.ratio,p=se({kind:"number",value:h,min:0,step:.01,fill:o,compact:!o,commit:"blur",onChange:m=>{if(m<=0){p.setValue?.(h);return}h=m,n.patch({[`levels.${a}.ratio`]:m});}});if(o&&(p.el.style.flex="1"),l.append(c.el,d.el,p.el),!o){let m=se({kind:"text",value:s.label??"",fill:true,placeholder:"label\u2026",onChange:f=>n.patch({[`levels.${a}.label`]:f})});m.el.style.flex="1",m.el.style.minWidth="60px",l.appendChild(m.el);}e.appendChild(l);});}};function Dw(r,e,t){let n=document.createElement("button");return n.type="button",n.textContent=r,n.className=e?"vela-dialog-btn vela-dialog-btn-primary":"vela-dialog-btn",n.addEventListener("click",t),n}var Ft=Symbol("mixed");function VM(r){let[e,...t]=r,n=new Set(e?.schema().fields.map(i=>i.path)??[]);for(let i of t){let o=new Set(i.schema().fields.map(s=>s.path));for(let s of n)o.has(s)||n.delete(s);}return n}function _M(r,e){let t=e(r[0]);return r.every(n=>e(n)===t)?t:Ft}function BM(r,e){return [...new Set(r.map(e))]}var Zn=30,HM=21,Ow="vela-drawing-popup-styles",Nw="4";function Fw(){if(typeof document>"u")return;let r=document.getElementById(Ow);if(r?.dataset.rev===Nw)return;let e=r??document.createElement("style");e.id=Ow,e.dataset.rev=Nw,e.textContent=`
|
|
903
903
|
.vela-dpop-btn{background:transparent;color:var(--vela-fg-muted);transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease;}
|
|
904
904
|
.vela-dpop-btn:hover{background:var(--vela-hover-strong);color:var(--vela-fg-bright);}
|
|
905
905
|
.vela-dpop-btn[data-active='1']{background:var(--vela-active);color:var(--vela-fg-bright);}
|
|
@@ -910,7 +910,7 @@ ${xr(".vela-sd-pane")}
|
|
|
910
910
|
.vela-dpop-item[data-active='1']{background:var(--vela-active);}
|
|
911
911
|
/* A finger needs a wider grab zone than a cursor \u2014 grow the move handle on touch-first
|
|
912
912
|
devices (the glyph stays centered; only the hit target widens). */
|
|
913
|
-
@media (pointer: coarse){.vela-dpop-grip{width:${qn+14}px !important;}}`,r||document.head.appendChild(e);}var Gc=class{constructor(e,t,n=()=>0){this.host=e;this.chartBarMs=n;this.el=null;this.tipEl=null;this.textPanel=null;this.colorPop=null;this.colorOwner=null;this.menuPop=null;this.menuOwner=null;this.onClose=null;this.onOutside=e=>{let t=e.target;if(this.settingsDialog.isOpen()){if(this.settingsDialog.contains(t)||this.isOwnChrome(t))return;this.settingsDialog.close();return}if(this.isOwnChrome(t))return;let n=this.onClose;this.close(),n?.(e);};this.theme=t,this.settingsDialog=new Wc(e,t);}lowerTimeframeOptions(){let e=this.chartBarMs();if(!(e>0))return [...fr];let t=fr.filter(n=>n.ms>0&&n.ms<e);return t.length>0?[fr[0],...t]:[]}setTheme(e){this.theme=e,this.settingsDialog.setTheme(e);}isOpen(){return this.el!=null}contains(e){return e!=null&&(this.isOwnChrome(e)||this.settingsDialog.contains(e))}open(e,t,n,i){this.close();let o=e[0];if(!o)return;Aw(),this.onClose=i??null;let s=this.theme,a=e.length>1,l=o.schema(),c=AL(e),u=x=>RL(e,x),d=x=>e.every(x),h=(x,M,w,L)=>this.colorButton(x,M,u(w),P=>n.patch({[L]:P}),void 0,DL(e,w)),p=a||l.textIsContent===true||!c.has("text.value"),m=document.createElement("div");m.className="vela-dpop",m.style.cssText=`position:absolute;z-index:22;background:${s.background};border:1px solid var(--vela-border);border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow);color:${s.textColor};font:var(--vela-font-size-md) ${s.fontFamily};display:flex;flex-direction:column;pointer-events:auto;overflow:hidden;`,Re(m,s),m.addEventListener("pointerdown",x=>{x.target?.closest(".vela-select-trigger, .vela-color-field")||Te();});let f=document.createElement("div");if(f.style.cssText="display:flex;align-items:center;gap:2px;padding:4px;",f.appendChild(this.dragHandle()),c.has("glyph")){let x=u(M=>M.glyph??qi[0]);f.appendChild(this.dropdown("Icon",qi,x,M=>eP(M),M=>n.patch({glyph:M})));}if(c.has("size")){let x=u(M=>M.size??"normal");f.appendChild(this.dropdown("Icon size",fa,x,M=>tP(M),M=>n.patch({size:M}),{label:ws}));}if(c.has("magnifier.timeframe")&&d(x=>x instanceof tt)){let x=w=>w,M=this.lowerTimeframeOptions();M.length>0&&f.appendChild(this.dropdown("Lower timeframe",M.map(w=>w.value),u(w=>x(w).magnifier.timeframe),()=>"",w=>n.patch({"magnifier.timeframe":w}),{label:w=>eo(String(w)),labelInTrigger:true})),f.appendChild(h("Up candles",jn,w=>x(w).magnifier.upColor||s.upColor,"magnifier.upColor")),f.appendChild(h("Down candles",jn,w=>x(w).magnifier.downColor||s.downColor,"magnifier.downColor"));}if(c.has("style.lineColor")&&f.appendChild(h("Line color",_r,x=>x.style.lineColor||(x instanceof tt?_e(this.theme.background):O),"style.lineColor")),c.has("style.lineWidth")){let x=P=>P.schema().fields.find(C=>C.path==="style.lineWidth"),M=x(o),w=u(P=>P.style.lineWidth);d(P=>{let C=x(P);return C?.kind==="number"&&(C.min??1)>1})&&M?.kind==="number"?f.appendChild(this.widthInput("Line width",w,M.min??1,M.max??60,M.step??1,P=>n.patch({"style.lineWidth":P}))):f.appendChild(this.dropdown("Line width",[1,2,3,4],w,P=>_i(P,"solid"),P=>n.patch({"style.lineWidth":P}),{label:P=>`${P}px`,labelInTrigger:true}));}c.has("style.lineStyle")&&f.appendChild(this.dropdown("Line style",Xe.map(x=>x.value),u(x=>x.style.lineStyle),x=>_i(2,x),x=>n.patch({"style.lineStyle":x}),{label:xs})),c.has("style.fillColor")&&f.appendChild(h("Fill",jn,x=>wt(x,this.theme)??x.style.fillColor??O,"style.fillColor"));let g=c.has("frvp.rows")&&o instanceof at,b=c.has("riskPercent")&&d(x=>x instanceof ht);if(b){let x=M=>M;f.appendChild(h("Profit zone",jn,M=>x(M).profitColor,"profitColor")),f.appendChild(h("Loss zone",jn,M=>x(M).lossColor,"lossColor"));}let y=x=>x.reg;if(c.has("reg.midColor")&&d(x=>y(x)!=null)){let x=w=>y(w),M=Xe.map(w=>w.value);f.appendChild(h("Midline color",_r,w=>x(w).midColor,"reg.midColor")),f.appendChild(this.dropdown("Midline style",M,u(w=>x(w).midStyle),w=>_i(2,w),w=>n.patch({"reg.midStyle":w}),{label:xs})),f.appendChild(h("Upper line color",_r,w=>x(w).upperColor,"reg.upperColor")),f.appendChild(this.dropdown("Upper line style",M,u(w=>x(w).upperStyle),w=>_i(2,w),w=>n.patch({"reg.upperStyle":w}),{label:xs})),f.appendChild(h("Lower line color",_r,w=>x(w).lowerColor,"reg.lowerColor")),f.appendChild(this.dropdown("Lower line style",M,u(w=>x(w).lowerStyle),w=>_i(2,w),w=>n.patch({"reg.lowerStyle":w}),{label:xs})),f.appendChild(h("Upper fill",jn,w=>x(w).upperFill,"reg.upperFill")),f.appendChild(h("Lower fill",jn,w=>x(w).lowerFill,"reg.lowerFill")),f.appendChild(this.toggle("Show R\xB2",KL,u(w=>x(w).showR2),w=>n.patch({"reg.showR2":w})));}let v=x=>x.vwap;if(c.has("vwap.midColor")&&d(x=>v(x)!=null)){let x=L=>v(L),M=Xe.map(L=>L.value),w=[.5,1,1.5,2,2.5,3,4,5];f.appendChild(h("VWAP color",_r,L=>x(L).midColor,"vwap.midColor")),f.appendChild(this.dropdown("VWAP style",M,u(L=>x(L).midStyle),L=>_i(2,L),L=>n.patch({"vwap.midStyle":L}),{label:xs})),f.appendChild(this.dropdown("Band multiplier",w,u(L=>x(L).multiplier),()=>XL,L=>n.patch({"vwap.multiplier":L}),{label:L=>`${L}\u03C3`,labelInTrigger:true})),f.appendChild(h("Upper band color",_r,L=>x(L).upperColor,"vwap.upperColor")),f.appendChild(h("Lower band color",_r,L=>x(L).lowerColor,"vwap.lowerColor")),f.appendChild(h("Band fill",jn,L=>x(L).bandFill,"vwap.bandFill"));}if(c.has("maxCurvature")){let x=u(M=>M.maxCurvature??24);f.appendChild(this.dropdown("Max curvature",Pu,x,()=>jL,M=>n.patch({maxCurvature:M}),{label:M=>`n=${M}`,labelInTrigger:true}));}if(c.has("mach")){let x=u(M=>M.mach??2);f.appendChild(this.dropdown("Mach number",Au,x,()=>ZL,M=>n.patch({mach:M}),{label:M=>`M=${M}`,labelInTrigger:true}));}if(c.has("waveCount")){let x=u(M=>M.waveCount??6);f.appendChild(this.dropdown("Waves",Iu,x,()=>qL,M=>n.patch({waveCount:M}),{label:M=>`${M}`,labelInTrigger:true}));}let S=x=>x;c.has("showPrice")&&f.appendChild(this.toggle("Show price",NL,u(x=>S(x).showPrice!==false),x=>n.patch({showPrice:x}))),c.has("showDate")&&f.appendChild(this.toggle("Show date",FL,u(x=>S(x).showDate!==false),x=>n.patch({showDate:x}))),c.has("text.color")&&p&&f.appendChild(h("Text color",Fh,x=>x.text?.color||s.textColor,"text.color")),c.has("text.size")&&p&&f.appendChild(this.dropdown("Text size",Ct.map(x=>x.value),u(x=>x.text?.size??"normal"),x=>Ow(x),x=>n.patch({"text.size":x}),{label:ws}));let E=!a&&c.has("text.value");c.has("text.bold")&&!E&&f.appendChild(this.toggle("Bold",Rw,u(x=>!!x.text?.bold),x=>n.patch({"text.bold":x}))),c.has("text.italic")&&!E&&f.appendChild(this.toggle("Italic",Dw,u(x=>!!x.text?.italic),x=>n.patch({"text.italic":x}))),E&&f.appendChild(this.iconBtn("Text",Fh,()=>this.toggleTextPanel(o,n,!p)));let T=o.editableLevels();if(T&&d(x=>x.editableLevels()!=null&&!(x instanceof Qe))){let x=w=>w,M=Ct.map(w=>w.value);f.appendChild(this.dropdown("Numbers size",M,u(w=>x(w).numbersSize??"small"),w=>rP(w),w=>n.patch({numbersSize:w}),{label:ws})),f.appendChild(this.dropdown("Label size",M,u(w=>x(w).labelsSize??"normal"),w=>Ow(w),w=>n.patch({labelsSize:w}),{label:ws}));}f.appendChild(this.divider()),!a&&g&&f.appendChild(this.iconBtn("Settings",Vh,()=>this.settingsDialog.open(o,n,"frvp"))),!a&&b&&f.appendChild(this.iconBtn("Position size",Vh,()=>this.settingsDialog.open(o,n,"position"))),!a&&T&&f.appendChild(this.iconBtn("Levels",Vh,()=>this.settingsDialog.open(o,n,"levels"))),f.appendChild(this.toggle("Lock",VL,u(x=>x.locked),x=>n.setLocked(x),_L));let k=this.iconBtn("Delete",zL,()=>n.remove());k.style.color="var(--vela-danger)",f.appendChild(k),f.appendChild(this.kebabButton(n)),m.append(f),this.host.appendChild(m),this.el=m,m.addEventListener("mouseover",x=>{let M=x.target.closest("[data-tip]");M?this.showTip(M):this.hideTip();}),m.addEventListener("mouseleave",()=>this.hideTip()),this.position(t),setTimeout(()=>document.addEventListener("pointerdown",this.onOutside),0);}close(){document.removeEventListener("pointerdown",this.onOutside),this.closeColorPopover(),this.closeMenu(),this.hideTip(),this.settingsDialog.close(),this.el?.remove(),this.el=null,this.textPanel=null,this.onClose=null;}destroy(){this.close();}isOwnChrome(e){if(this.el?.contains(e)||this.colorPop?.el.contains(e)||this.menuPop?.el.contains(e))return true;let t=e instanceof Element?e:e.parentElement;if(!t)return false;let n=t.closest(".vela-popover");return n!=null&&this.host.contains(n)}toggleTextPanel(e,t,n){if(this.textPanel){this.textPanel.remove(),this.textPanel=null,this.reposition();return}let i=e.text,o=document.createElement("div");o.style.cssText="padding:6px;border-top:1px solid var(--vela-border);display:flex;flex-direction:column;gap:4px;";let s=new Rr({value:i?.value??"",rows:1,size:"sm",autoGrow:true,maxLines:4,placeholder:"Label\u2026",onChange:l=>{t.patch({"text.value":l}),this.reposition();}});s.el.style.minWidth="220px",s.input.addEventListener("input",()=>{t.patch({"text.value":s.input.value}),this.reposition();}),s.input.addEventListener("keydown",l=>{if(l.stopPropagation(),l.key==="Escape"){l.preventDefault();let c=this.onClose;this.close(),c?.();}});let a=document.createElement("div");a.style.cssText="display:flex;align-items:center;justify-content:flex-start;gap:0;transform:scale(0.8);transform-origin:left center;",n&&a.append(this.colorButton("Text color",Fh,i?.color||this.theme.textColor,l=>t.patch({"text.color":l}),14),this.dropdown("Text size",Ct.map(l=>l.value),i?.size??"normal",l=>nP(l),l=>t.patch({"text.size":l}),{label:ws})),a.append(this.toggle("Bold",Rw,!!i?.bold,l=>t.patch({"text.bold":l})),this.toggle("Italic",Dw,!!i?.italic,l=>t.patch({"text.italic":l}))),o.append(s.el,a),this.el?.appendChild(o),this.textPanel=o,this.reposition(),s.input.focus();}position(e){let t=this.el;if(!t)return;let n=this.host.getBoundingClientRect(),i=t.offsetWidth,o=t.offsetHeight,s=10,a=n.width/2-i/2,l=12;e&&(a=e.x+e.w/2-i/2,l=e.y-o-s,l<4&&(l=e.y+e.h+s)),t.style.left=`${Math.max(4,Math.min(a,n.width-i-4))}px`,t.style.top=`${Math.max(4,Math.min(l,n.height-o-4))}px`;}reposition(){let e=this.el;if(!e)return;let t=this.host.getBoundingClientRect(),n=e.offsetWidth,i=e.offsetHeight,o=parseFloat(e.style.left)||0,s=parseFloat(e.style.top)||0;e.style.left=`${Math.max(4,Math.min(o,t.width-n-4))}px`,e.style.top=`${Math.max(4,Math.min(s,t.height-i-4))}px`;}base(e){let t=document.createElement("button");return t.type="button",t.dataset.tip=e,t.className="vela-dpop-btn",t.style.cssText=`width:${qn}px;height:${qn}px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:inherit;border:none;border-radius:5px;padding:0;`,t}iconBtn(e,t,n){let i=this.base(e);return i.innerHTML=kn(t),i.addEventListener("click",n),i}dragHandle(){let e=document.createElement("button");return e.type="button",e.className="vela-dpop-grip",e.style.cssText=`width:${qn}px;height:${qn}px;display:flex;align-items:center;justify-content:center;background:transparent;border:none;padding:0;cursor:grab;touch-action:none;color:var(--vela-fg-faint);`,e.innerHTML=kn($L),e.addEventListener("pointerdown",t=>{let n=this.el;if(!n||t.button!==0)return;t.preventDefault(),t.stopPropagation(),this.hideTip(),this.closeColorPopover(),this.closeMenu();let i=this.host.getBoundingClientRect(),o=t.clientX,s=t.clientY,a=parseFloat(n.style.left)||0,l=parseFloat(n.style.top)||0;e.style.cursor="grabbing";try{e.setPointerCapture(t.pointerId);}catch{}let c=d=>{let h=n.offsetWidth,p=n.offsetHeight,m=a+(d.clientX-o),f=l+(d.clientY-s);n.style.left=`${Math.max(4,Math.min(m,i.width-h-4))}px`,n.style.top=`${Math.max(4,Math.min(f,i.height-p-4))}px`;},u=()=>{e.style.cursor="grab",window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u);};window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u);}),e}kebabButton(e){let t=this.base("More");return t.innerHTML=kn(WL),t.addEventListener("pointerdown",n=>n.stopPropagation()),t.addEventListener("click",n=>{if(n.stopPropagation(),this.menuOwner===t){this.closeMenu();return}this.openActionMenu(t,[{icon:GL,label:"Duplicate",onClick:()=>e.duplicate()},{icon:BL,label:"Bring to front",onClick:()=>e.reorder("front")},{icon:HL,label:"Send to back",onClick:()=>e.reorder("back")},{icon:UL,label:"Reset settings",onClick:()=>e.resetSettings()}]);}),t}hostFloat(e,t){let n=this.theme,i=new $e({trigger:e,host:this.host,theme:n,position:"absolute",boundary:this.host,boundaryInset:4,viewportInset:0,gap:6,align:t.align??"start",zIndex:t.zIndex,onClose:()=>{this.menuPop===i&&(this.menuPop=null,this.menuOwner=null),this.colorPop===i&&(this.colorPop=null,this.colorOwner=null),t.onClose?.();}}),o=i.el;return o.style.background=n.background,o.style.border="1px solid var(--vela-border)",o.style.borderRadius="var(--vela-radius-lg)",o.style.boxShadow="var(--vela-shadow)",o.style.padding=t.padding,o.style.display="flex",o.style.flexDirection="column",o.style.gap="1px",o.style.color=n.textColor,o.style.font=`var(--vela-font-size-md) ${n.fontFamily}`,o.style.pointerEvents="auto",t.fill(o,i),i.show(),i}openMagnifierTimeframeMenu(e,t,n){Aw(),Te();let i=this.lowerTimeframeOptions(),o=document.createElement("div");o.style.cssText=`position:absolute;left:${e.x}px;top:${e.y}px;width:${e.w}px;height:${e.h}px;pointer-events:none;`,this.host.appendChild(o),this.menuPop=this.hostFloat(o,{zIndex:26,padding:"4px",onClose:()=>o.remove(),fill:(s,a)=>{if(i.length===0){let l=document.createElement("div");l.style.cssText="padding:6px 10px;opacity:0.65;white-space:nowrap;",l.textContent="No lower timeframe available",s.appendChild(l);return}for(let l of i){let c=document.createElement("button");c.type="button",c.className="vela-dpop-item",c.dataset.active=l.value===t?"1":"0",c.style.cssText="display:flex;align-items:center;min-width:88px;padding:5px 10px;border:none;border-radius:5px;color:inherit;cursor:pointer;text-align:left;font:inherit;font-variant-numeric:tabular-nums;",c.textContent=l.label,c.addEventListener("click",u=>{u.stopPropagation(),a.hide(),n(l.value);}),s.appendChild(c);}}}),this.menuOwner=o;}openActionMenu(e,t){this.menuPop=this.hostFloat(e,{align:"end",zIndex:26,padding:"4px",fill:(n,i)=>{for(let o of t){let s=document.createElement("button");s.type="button",s.className="vela-dpop-item",s.style.cssText="display:flex;align-items:center;gap:9px;min-width:150px;padding:6px 9px;border:none;border-radius:5px;color:inherit;cursor:pointer;text-align:left;font:inherit;";let a=document.createElement("span");a.style.cssText="display:flex;flex:none;width:20px;justify-content:center;",a.innerHTML=kn(o.icon,18);let l=document.createElement("span");l.textContent=o.label,l.style.cssText="flex:1;",s.append(a,l),s.addEventListener("click",c=>{c.stopPropagation(),i.hide(),o.onClick();}),n.appendChild(s);}}}),this.menuOwner=e;}showTip(e){let t=e.dataset.tip;if(!t){this.hideTip();return}let n=this.theme;if(!this.tipEl){let p=document.createElement("div");p.style.cssText=`position:absolute;z-index:27;pointer-events:none;white-space:nowrap;background:${n.textColor};color:${n.background};padding:3px 7px;border-radius:5px;font:var(--vela-font-size-sm) ${n.fontFamily};box-shadow:var(--vela-shadow);`,this.host.appendChild(p),this.tipEl=p;}let i=this.tipEl;i.textContent=t;let o=this.host.getBoundingClientRect(),s=e.getBoundingClientRect(),a=i.offsetWidth,l=i.offsetHeight,c=6,u=s.left-o.left+s.width/2-a/2;u=Math.max(4,Math.min(u,o.width-a-4));let d=s.top-o.top-l-c,h=d>=4?d:s.bottom-o.top+c;i.style.left=`${Math.round(u)}px`,i.style.top=`${Math.round(h)}px`;}hideTip(){this.tipEl?.remove(),this.tipEl=null;}toggle(e,t,n,i,o){let s=this.base(e),a=c=>{s.dataset.active=c===Nt?"mixed":c?"1":"0",s.innerHTML=kn(o&&c===false?o:t);};a(n);let l=n;return s.addEventListener("click",()=>{l=l===Nt?true:!l,a(l),i(l);}),s}widthInput(e,t,n,i,o,s){let a=new Ar({value:t===Nt?n:t,min:n,max:i,step:o,integer:o>=1,size:"sm",fill:false,compact:true,commit:"blur",title:e,onChange:s});return t===Nt&&(a.input.value="",a.input.placeholder="\u2014"),a.el.dataset.tip=e,QL(a.el),a.el}dropdown(e,t,n,i,o,s={}){let a=this.base(e);a.style.width="auto",a.style.minWidth=`${qn}px`,a.style.padding="0 4px",a.style.gap="2px";let l=n,c=u=>{if(a.replaceChildren(),u===Nt){let p=document.createElement("span");p.textContent="\u2014",p.style.cssText="min-width:18px;text-align:center;opacity:0.85;",a.appendChild(p);}let d=u===Nt?"":i(u);if(d){let p=document.createElement("span");p.style.cssText="display:flex;",p.innerHTML=kn(d),a.appendChild(p);}if(s.label&&s.labelInTrigger&&u!==Nt){let p=document.createElement("span");p.textContent=s.label(u),p.style.cssText="font-size:11px;opacity:0.85;font-variant-numeric:tabular-nums;",a.appendChild(p);}let h=document.createElement("span");h.style.cssText="display:flex;opacity:0.55;",h.innerHTML=kn(YL,12),a.appendChild(h);};return c(l),a.addEventListener("pointerdown",u=>u.stopPropagation()),a.addEventListener("click",u=>{if(u.stopPropagation(),this.menuOwner===a){this.closeMenu();return}this.openMenu(a,t,l,i,s.label,d=>{l=d,c(d),o(d);});}),a}openMenu(e,t,n,i,o,s){this.menuPop=this.hostFloat(e,{zIndex:26,padding:"4px",fill:(a,l)=>{for(let c of t){let u=c===n,d=document.createElement("button");d.type="button",d.className="vela-dpop-item",d.dataset.active=u?"1":"0",d.style.cssText=`display:flex;align-items:center;gap:8px;${o?"min-width:118px;":""}padding:5px 8px;border:none;border-radius:5px;color:inherit;cursor:pointer;text-align:left;font:inherit;`;let h=i(c);if(h){let p=document.createElement("span");p.style.cssText="display:flex;flex:none;width:22px;justify-content:center;",p.innerHTML=kn(h,18),d.appendChild(p);}if(o){let p=document.createElement("span");p.textContent=o(c),p.style.cssText="flex:1;font-variant-numeric:tabular-nums;",d.appendChild(p);}d.addEventListener("click",p=>{p.stopPropagation(),l.hide(),s(c);}),a.appendChild(d);}}}),this.menuOwner=e;}closeMenu(){this.menuPop?.hide();}colorButton(e,t,n,i,o=17,s=[]){let a=document.createElement("button");a.type="button",a.dataset.tip=e,a.className="vela-dpop-btn",a.style.cssText=`position:relative;width:${qn}px;height:${qn}px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;cursor:pointer;border-radius:5px;border:none;color:inherit;padding:0;`;let l=document.createElement("span");l.style.cssText="display:flex;",l.innerHTML=kn(t,o);let c=document.createElement("span");c.style.cssText=`display:block;height:3px;width:${Math.round(o*.85)}px;border-radius:2px;background:${n===Nt?JL(s):n};`,a.append(l,c);let u=n;return a.addEventListener("pointerdown",d=>d.stopPropagation()),a.addEventListener("click",d=>{d.stopPropagation();let h=u===Nt?s[0]??O:u;this.toggleColorPopover(a,h,u===Nt?s:[],p=>{u=p,c.style.background=p,i(p);});}),a}toggleColorPopover(e,t,n,i){if(this.colorOwner===e){this.closeColorPopover();return}this.openColorPopover(e,t,n,i);}openColorPopover(e,t,n,i){let o=this.theme;this.colorPop=this.hostFloat(e,{zIndex:25,padding:"10px",fill:(s,a)=>{if(n.length>1){let l=document.createElement("div");l.style.cssText="display:flex;align-items:center;gap:6px;padding-bottom:9px;border-bottom:1px solid var(--vela-border);";let c=document.createElement("span");c.textContent="In use",c.style.cssText="font:var(--vela-font-size-sm) inherit;opacity:0.7;margin-right:2px;",l.appendChild(c);for(let u of n){let d=document.createElement("button");d.type="button",d.dataset.tip=u,d.style.cssText=`width:18px;height:18px;border-radius:4px;border:1px solid var(--vela-border-strong);cursor:pointer;background:${u};padding:0;`,d.addEventListener("click",h=>{h.stopPropagation(),a.hide(),i(u);}),l.appendChild(d);}s.appendChild(l);}s.appendChild(Jo(t,o,i));}}),this.colorOwner=e;}closeColorPopover(){this.colorPop?.hide();}divider(){let e=document.createElement("div");return e.style.cssText="width:1px;height:18px;margin:0 3px;background:var(--vela-border);",e}},_r=Z("brush"),jn=Z("bucket"),Fh=Z("type"),NL=Z("price-delta"),FL=Z("date-delta"),VL=Z("lock"),_L=Z("unlock"),BL=Z("bring-front"),HL=Z("send-back"),zL=Z("trash"),Rw=Z("bold"),Dw=Z("italic"),$L=Z("grip"),WL=Z("kebab"),GL=Z("clone"),UL=Z("reset"),Vh=Z("gear"),YL=Z("chevron-down"),KL=Z("r-squared"),XL=Z("bands"),jL=Z("dedekind"),qL=Z("sonic"),ZL=Z("supersonic");function JL(r){let e=r.length>1?r:["var(--vela-fg-faint)","var(--vela-fg-muted)"],t=100/e.length;return `linear-gradient(90deg,${e.map((i,o)=>`${i} ${o*t}% ${(o+1)*t}%`).join(",")})`}function _i(r,e){let t=e==="dashed"?"5,3":e==="dotted"?"1.5,3":"";return R(`<line x1="3.5" y1="12" x2="20.5" y2="12" stroke-width="${Number(r)||2}" stroke-dasharray="${t}"/>`)}function QL(r){r.addEventListener("keydown",e=>e.stopPropagation());}function Ss(r,e,t=17,n=""){return Tu(`<text x="12" y="${t}" font-size="${e}" text-anchor="middle"${n?" "+n:""}>${r}</text>`)}function eP(r){return Ss(String(r),15)}function tP(r){return Ss("\u25CF",(_h[String(r)]??13)+4)}function nP(r){return Ss(String(r).charAt(0).toUpperCase(),15)}var _h={small:10,normal:13,large:16,huge:20};function rP(r){return Ss("12",(_h[String(r)]??13)-1,16.5,'font-weight="600"')}function Ow(r){return Ss("T",(_h[String(r)]??13)+2)}function Nw(r){return r.charAt(0).toUpperCase()+r.slice(1)}function ws(r){return Ct.find(e=>e.value===r)?.label??Nw(String(r))}function xs(r){return Xe.find(e=>e.value===r)?.label??Nw(String(r))}function kn(r,e=OL){return r.replace("<svg ",`<svg width="${e}" height="${e}" `)}var Bh=44,Hh=16,Cs=class{constructor(e,t,n,i=()=>{},o=()=>{},s=()=>{},a=()=>{},l=()=>{},c={}){this.host=e;this.theme=t;this.onArm=n;this.onMagnet=i;this.onMeasure=o;this.onEraser=s;this.onToggleFavorite=a;this.onStayMode=l;this.def={groups:[]};this.active=null;this.lastUsed=new Map;this.favorites=new Set;this.shortcuts=new Map;this.starEls=new Map;this.flyout=null;this.flyoutOwnerId=null;this.flyoutCell=null;this.groupCells=new Map;this.groupIcons=new Map;this.cursorBtn=null;this.magnetCell=null;this.magnetIcon=null;this.magnetMode="off";this.lastMagnetOn="weak";this.measureBtn=null;this.measureActive=false;this.eraserBtn=null;this.eraserActive=false;this.stayBtn=null;this.stayActive=false;this.syncBtn=null;this.syncActive=false;this.collapseBtn=null;this.collapsed=false;this.visible=false;this.tipText=new WeakMap;this.tipDisposers=[];this.onOutside=e=>{let t=e.target;this.flyout&&!this.flyout.contains(t)&&!this.root.contains(t)&&this.closeFlyout();};this.borderOverride=c.borderColor??null,this.width=c.width??Bh,this.dock=c.dock??"absolute",this.onCollapse=c.onCollapse??(()=>{}),this.onDrawingsSync=c.onDrawingsSync??null,iP(),this.root=document.createElement("div"),this.root.className="vela-dtb",this.styleRoot(),e.appendChild(this.root);}get borderColor(){return this.borderOverride??this.theme.borderColor}styleRoot(){let e=this.theme;Re(this.root,e);let t=this.collapsed?Hh:this.width;this.root.dataset.collapsed=this.collapsed?"1":"";let n=this.dock==="absolute"?`position:absolute;left:0;top:0;height:100%;width:${t}px;z-index:21;`:`position:relative;height:100%;width:${t}px;flex:none;`;this.root.style.cssText=n+`display:${this.visible?"flex":"none"};flex-direction:column;gap:4px;padding:6px 0;box-sizing:border-box;background:${e.background};border-right:1px solid ${this.borderColor};color:var(--vela-fg-muted);pointer-events:auto;overflow-y:auto;overflow-x:hidden;`;}setDefinition(e){this.def=e;for(let t of e.groups){let n=t.tools[0];n&&!this.lastUsed.has(t.id)&&this.lastUsed.set(t.id,n.type);}this.rebuild();}setFavorites(e){this.favorites=new Set(e);for(let[t,n]of this.starEls)this.paintStar(n,t);}setShortcuts(e){this.shortcuts=new Map(Object.entries(e));}paintStar(e,t){let n=this.favorites.has(t);e.classList.toggle("vela-fav",n),e.setAttribute("aria-label",n?"Remove from favorites":"Add to favorites"),e.setAttribute("aria-pressed",n?"true":"false"),e.innerHTML=Yc(n?fP:mP);}setVisible(e){this.visible=e,this.root.style.display=e?"flex":"none";}setActiveTool(e){if(this.active=e,e){let t=this.def.groups.find(n=>n.tools.some(i=>i.type===e));t&&(this.lastUsed.set(t.id,e),this.paintGroupIcon(t));}this.closeFlyout(),this.highlight();}setTheme(e){this.theme=e,this.styleRoot(),this.rebuild();}destroy(){this.closeFlyout();for(let e of this.tipDisposers.splice(0))e();this.root.remove();}rebuild(){for(let e of this.tipDisposers.splice(0))e();this.root.replaceChildren(),this.groupCells.clear(),this.groupIcons.clear(),this.cursorBtn=this.makeButton(oP,"Cursor",()=>this.onCursorClick()),this.root.appendChild(this.cursorBtn),this.def.groups.length>0&&this.root.appendChild(this.divider());for(let e of this.def.groups){let t=this.makeGroupCell(e);this.root.appendChild(t),this.paintGroupIcon(e);}this.root.appendChild(this.divider()),this.measureBtn=this.makeButton(sP,"Measure",()=>this.onMeasure()),this.root.appendChild(this.measureBtn),this.eraserBtn=this.makeButton(dP,"Eraser (click/drag to delete)",()=>this.onEraser()),this.root.appendChild(this.eraserBtn),this.root.appendChild(this.makeMagnetCell()),this.stayBtn=this.makeButton(cP,"Stay in drawing mode",()=>this.toggleStay()),this.root.appendChild(this.stayBtn),this.onDrawingsSync&&(this.syncBtn=this.makeButton(uP,"Sync drawings on all charts",()=>this.toggleDrawingsSync()),this.root.appendChild(this.syncBtn)),this.collapseBtn=this.makeButton(_w,"Collapse toolbar",()=>this.toggleCollapsed()),this.collapseBtn.classList.add("vela-dtb-collapse"),this.root.appendChild(this.collapseBtn),this.paintMeasure(),this.paintEraser(),this.paintMagnet(),this.paintStay(),this.paintDrawingsSync(),this.paintCollapse(),this.highlight();}toggleCollapsed(){this.collapsed=!this.collapsed,this.closeFlyout(),this.styleRoot(),this.paintCollapse(),this.onCollapse(this.collapsed);}paintCollapse(){let e=this.collapseBtn;if(!e)return;let t=this.collapsed?"Expand toolbar":"Collapse toolbar";e.innerHTML=Uc(this.collapsed?aP:_w,12),e.setAttribute("aria-label",t),this.tipText.set(e,t);}makeCell(e,t){let n=document.createElement("div");n.className="vela-dtb-cell";let i=document.createElement("button");i.type="button",i.className="vela-dtb-icon",i.setAttribute("aria-label",e),t.iconSvg&&(i.innerHTML=Uc(t.iconSvg)),i.addEventListener("click",t.onIcon),n.appendChild(i);let o=null;if(t.multi&&t.onArrow){let s=t.onArrow;o=document.createElement("button"),o.type="button",o.className="vela-dtb-arrow",o.setAttribute("aria-label",`${e} \u2014 more`),o.innerHTML=gP(hP),o.addEventListener("click",a=>{a.stopPropagation(),s();}),n.appendChild(o);}return this.tipDisposers.push(Yt(n,{host:this.host,theme:()=>this.theme,text:()=>this.tipText.get(n)??e,placement:"right"})),{cell:n,icon:i,arrow:o}}makeGroupCell(e){let t=e.tools.length>1,{cell:n,icon:i}=this.makeCell(e.label,{multi:t,onIcon:()=>this.onGroupIconClick(e),onArrow:t?()=>this.onArrowClick(e):void 0});return this.groupCells.set(e.id,n),this.groupIcons.set(e.id,i),n}makeMagnetCell(){let{cell:e,icon:t}=this.makeCell("Magnet snap",{iconSvg:lP,multi:true,onIcon:()=>this.toggleMagnet(),onArrow:()=>this.onMagnetArrowClick()});return this.magnetCell=e,this.magnetIcon=t,e}onCursorClick(){this.measureActive&&this.onMeasure(),this.eraserActive&&this.onEraser(),this.onArm(null);}onGroupIconClick(e){let t=this.lastUsed.get(e.id)??e.tools[0]?.type;t&&this.onArm(t);}onArrowClick(e){let t=this.flyoutOwnerId===e.id;this.closeFlyout(),t||this.openGroupFlyout(e);}toggleMagnet(){this.applyMagnet(this.magnetMode==="off"?this.lastMagnetOn:"off");}onMagnetArrowClick(){let e=this.flyoutOwnerId===Fw;this.closeFlyout(),e||this.openMagnetFlyout();}applyMagnet(e){this.magnetMode=e,e!=="off"&&(this.lastMagnetOn=e),this.onMagnet(e),this.paintMagnet(),this.highlight();}setMagnetMode(e){this.magnetMode=e,e!=="off"&&(this.lastMagnetOn=e),this.paintMagnet(),this.highlight();}setMeasureActive(e){this.measureActive=e,this.paintMeasure(),this.highlight();}paintMeasure(){let e=this.measureBtn;e&&(e.dataset.active=this.measureActive?"1":"");}setEraserActive(e){this.eraserActive=e,this.paintEraser(),this.highlight();}paintEraser(){let e=this.eraserBtn;e&&(e.dataset.active=this.eraserActive?"1":"");}paintMagnet(){let e=this.magnetCell,t=this.magnetIcon;if(!e||!t)return;let n=this.magnetMode==="off"?"Off":this.magnetMode==="weak"?"Weak":"Strong";this.tipText.set(e,`Magnet snap: ${n}`);let i=this.magnetMode!=="off";e.dataset.active=i?"1":"",t.style.opacity=i?"1":"0.5";}toggleStay(){this.stayActive=!this.stayActive,this.onStayMode(this.stayActive),this.paintStay();}setStayMode(e){this.stayActive=e,this.paintStay();}paintStay(){let e=this.stayBtn;e&&(e.dataset.active=this.stayActive?"1":"",e.style.opacity=this.stayActive?"1":"0.5");}toggleDrawingsSync(){this.syncActive=!this.syncActive,this.onDrawingsSync?.(this.syncActive),this.paintDrawingsSync();}setDrawingsSyncMode(e){this.syncActive=e,this.paintDrawingsSync();}paintDrawingsSync(){let e=this.syncBtn;e&&(e.dataset.active=this.syncActive?"1":"",e.style.opacity=this.syncActive?"1":"0.5");}beginFlyout(e,t){let n=this.theme,i=document.createElement("div");i.className="vela-dtb-flyout",i.style.cssText=`position:absolute;z-index:23;display:flex;flex-direction:column;gap:2px;padding:4px;border-radius:0 8px 8px 0;background:var(--vela-surface-elev);border:1px solid ${this.borderColor};border-left:none;box-shadow:var(--vela-shadow);pointer-events:auto;overflow-y:auto;overscroll-behavior:contain;`,Re(i,n),this.host.appendChild(i);let o=t.getBoundingClientRect(),s=this.root.getBoundingClientRect(),a=this.host.getBoundingClientRect(),l=o.top-a.top;return i.style.left=`${s.right-a.left-1}px`,i.style.top=`${l}px`,i.style.maxHeight=`${Math.max(120,a.height-l-8)}px`,this.flyout=i,this.flyoutOwnerId=e,this.flyoutCell=t,t.classList.add("vela-open"),this.highlight(),document.addEventListener("pointerdown",this.onOutside),i}openGroupFlyout(e){let t=this.groupCells.get(e.id);if(!t)return;let n=this.beginFlyout(e.id,t),i=e.sections??[{label:"",tools:e.tools}];for(let o=0;o<i.length;o++){let s=i[o];s.label&&(o>0&&n.appendChild(this.flyoutSeparator()),n.appendChild(this.flyoutHeader(s.label)));for(let a of s.tools)n.appendChild(this.makeFlyoutItem({icon:a.icon,label:a.label,selected:a.type===this.active,shortcut:this.shortcuts.get(a.type),onSelect:()=>this.onArm(a.type),favorite:{type:a.type,toggle:()=>this.onToggleFavorite(a.type,!this.favorites.has(a.type))}}));}}openMagnetFlyout(){let e=this.magnetCell;if(!e)return;let t=this.beginFlyout(Fw,e);t.appendChild(this.flyoutHeader("Magnet"));let n=[["off","Off"],["weak","Weak"],["strong","Strong"]];for(let[i,o]of n)t.appendChild(this.makeFlyoutItem({label:o,selected:i===this.magnetMode,onSelect:()=>{this.applyMagnet(i),this.closeFlyout();}}));}flyoutHeader(e){let t=this.theme,n=document.createElement("div");return n.textContent=e.toUpperCase(),n.style.cssText=`padding:6px 12px 2px 8px;font:var(--vela-font-size-sm) ${t.fontFamily};font-weight:600;letter-spacing:0.04em;color:var(--vela-fg-muted);user-select:none;`,n}flyoutSeparator(){let e=document.createElement("div");return e.style.cssText=`height:1px;margin:4px 8px;background:${this.borderColor};`,e}makeFlyoutItem(e){let t=this.theme,n=document.createElement("button");if(n.type="button",n.className="vela-dtb-item",n.setAttribute("aria-label",e.label),n.style.cssText=`display:flex;align-items:center;gap:8px;padding:5px 10px 5px 8px;cursor:pointer;color:${t.textColor};border-radius:var(--vela-radius-sm);font:13px ${t.fontFamily};white-space:nowrap;min-width:148px;`,e.icon){let s=document.createElement("span");s.style.cssText="width:18px;height:18px;display:flex;align-items:center;justify-content:center;flex:none;",s.innerHTML=Yc(e.icon),n.appendChild(s);}let i=document.createElement("span");i.textContent=e.label,i.style.cssText="flex:1 1 auto;text-align:left;",n.appendChild(i);let o=document.createElement("span");if(o.style.cssText="width:14px;height:14px;display:flex;align-items:center;justify-content:center;flex:none;",e.selected&&(o.innerHTML=Yc(pP)),n.appendChild(o),e.shortcut){let s=document.createElement("span");s.className="vela-dtb-hint",s.textContent=e.shortcut,s.style.cssText=`flex:none;font:var(--vela-font-size-md) ${t.fontFamily};color:var(--vela-fg-muted);`,n.appendChild(s);}if(e.favorite){let s=document.createElement("span");s.className="vela-dtb-star",s.setAttribute("role","button"),this.paintStar(s,e.favorite.type),this.starEls.set(e.favorite.type,s);for(let a of ["pointerdown","pointerup","mousedown","mouseup"])s.addEventListener(a,l=>l.stopPropagation());s.addEventListener("click",a=>{a.stopPropagation(),a.preventDefault(),e.favorite.toggle();}),n.appendChild(s);}return n.addEventListener("click",s=>{s.stopPropagation(),e.onSelect();}),n}closeFlyout(){this.starEls.clear(),this.flyout&&(this.flyout.remove(),this.flyout=null,this.flyoutCell?.classList.remove("vela-open"),this.flyoutCell=null,this.flyoutOwnerId=null,document.removeEventListener("pointerdown",this.onOutside),this.highlight());}paintGroupIcon(e){let t=this.groupIcons.get(e.id);if(!t)return;let n=this.lastUsed.get(e.id)??e.tools[0]?.type,i=e.tools.find(s=>s.type===n)??e.tools[0];t.innerHTML=Uc(i?.icon??"");let o=this.groupCells.get(e.id);o&&this.tipText.set(o,i?.label??e.label);}highlight(){let e=this.active?this.def.groups.find(t=>t.tools.some(n=>n.type===this.active)):null;for(let[t,n]of this.groupCells){let i=t===e?.id;n.dataset.active=i?"1":"";}this.cursorBtn&&(this.cursorBtn.dataset.active=this.active==null&&!this.measureActive&&!this.eraserActive?"1":""),this.paintMeasure(),this.paintEraser(),this.paintMagnet(),this.paintStay();}makeButton(e,t,n){let i=document.createElement("button");return i.type="button",i.className="vela-dtb-btn",i.setAttribute("aria-label",t),this.tipText.set(i,t),e&&(i.innerHTML=Uc(e)),this.tipDisposers.push(Yt(i,{host:this.host,theme:()=>this.theme,text:()=>this.tipText.get(i)??t,placement:"right"})),i.addEventListener("click",n),i}divider(){let e=document.createElement("div");return e.style.cssText=`width:24px;height:1px;margin:2px auto;flex:none;background:${this.borderColor};`,e}},Fw="__magnet__",Vw="vela-drawing-toolbar-styles";function iP(){if(typeof document>"u")return;let r=document.getElementById(Vw);r||(r=document.createElement("style"),r.id=Vw,document.head.appendChild(r)),r.textContent=`
|
|
913
|
+
@media (pointer: coarse){.vela-dpop-grip{width:${Zn+14}px !important;}}`,r||document.head.appendChild(e);}var Kc=class{constructor(e,t,n=()=>0){this.host=e;this.chartBarMs=n;this.el=null;this.tipEl=null;this.textPanel=null;this.colorPop=null;this.colorOwner=null;this.menuPop=null;this.menuOwner=null;this.onClose=null;this.onOutside=e=>{let t=e.target;if(this.settingsDialog.isOpen()){if(this.settingsDialog.contains(t)||this.isOwnChrome(t))return;this.settingsDialog.close();return}if(this.isOwnChrome(t))return;let n=this.onClose;this.close(),n?.(e);};this.theme=t,this.settingsDialog=new Yc(e,t);}lowerTimeframeOptions(){let e=this.chartBarMs();if(!(e>0))return [...gr];let t=gr.filter(n=>n.ms>0&&n.ms<e);return t.length>0?[gr[0],...t]:[]}setTheme(e){this.theme=e,this.settingsDialog.setTheme(e);}isOpen(){return this.el!=null}contains(e){return e!=null&&(this.isOwnChrome(e)||this.settingsDialog.contains(e))}open(e,t,n,i){this.close();let o=e[0];if(!o)return;Fw(),this.onClose=i??null;let s=this.theme,a=e.length>1,l=o.schema(),c=VM(e),u=x=>_M(e,x),d=x=>e.every(x),h=(x,L,w,M)=>this.colorButton(x,L,u(w),P=>n.patch({[M]:P}),void 0,BM(e,w)),p=a||l.textIsContent===true||!c.has("text.value"),m=document.createElement("div");m.className="vela-dpop",m.style.cssText=`position:absolute;z-index:22;background:${s.background};border:1px solid var(--vela-border);border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow);color:${s.textColor};font:var(--vela-font-size-md) ${s.fontFamily};display:flex;flex-direction:column;pointer-events:auto;overflow:hidden;`,Re(m,s),m.addEventListener("pointerdown",x=>{x.target?.closest(".vela-select-trigger, .vela-color-field")||Te();});let f=document.createElement("div");if(f.style.cssText="display:flex;align-items:center;gap:2px;padding:4px;",f.appendChild(this.dragHandle()),c.has("glyph")){let x=u(L=>L.glyph??Zi[0]);f.appendChild(this.dropdown("Icon",Zi,x,L=>sP(L),L=>n.patch({glyph:L})));}if(c.has("size")){let x=u(L=>L.size??"normal");f.appendChild(this.dropdown("Icon size",ba,x,L=>aP(L),L=>n.patch({size:L}),{label:xs}));}if(c.has("magnifier.timeframe")&&d(x=>x instanceof tt)){let x=w=>w,L=this.lowerTimeframeOptions();L.length>0&&f.appendChild(this.dropdown("Lower timeframe",L.map(w=>w.value),u(w=>x(w).magnifier.timeframe),()=>"",w=>n.patch({"magnifier.timeframe":w}),{label:w=>to(String(w)),labelInTrigger:true})),f.appendChild(h("Up candles",qn,w=>x(w).magnifier.upColor||s.upColor,"magnifier.upColor")),f.appendChild(h("Down candles",qn,w=>x(w).magnifier.downColor||s.downColor,"magnifier.downColor"));}if(c.has("style.lineColor")&&f.appendChild(h("Line color",Br,x=>x.style.lineColor||(x instanceof tt?_e(this.theme.background):O),"style.lineColor")),c.has("style.lineWidth")){let x=P=>P.schema().fields.find(C=>C.path==="style.lineWidth"),L=x(o),w=u(P=>P.style.lineWidth);d(P=>{let C=x(P);return C?.kind==="number"&&(C.min??1)>1})&&L?.kind==="number"?f.appendChild(this.widthInput("Line width",w,L.min??1,L.max??60,L.step??1,P=>n.patch({"style.lineWidth":P}))):f.appendChild(this.dropdown("Line width",[1,2,3,4],w,P=>Bi(P,"solid"),P=>n.patch({"style.lineWidth":P}),{label:P=>`${P}px`,labelInTrigger:true}));}c.has("style.lineStyle")&&f.appendChild(this.dropdown("Line style",Xe.map(x=>x.value),u(x=>x.style.lineStyle),x=>Bi(2,x),x=>n.patch({"style.lineStyle":x}),{label:Ss})),c.has("style.fillColor")&&f.appendChild(h("Fill",qn,x=>wt(x,this.theme)??x.style.fillColor??O,"style.fillColor"));let g=c.has("frvp.rows")&&o instanceof at,b=c.has("riskPercent")&&d(x=>x instanceof ht);if(b){let x=L=>L;f.appendChild(h("Profit zone",qn,L=>x(L).profitColor,"profitColor")),f.appendChild(h("Loss zone",qn,L=>x(L).lossColor,"lossColor"));}let y=x=>x.reg;if(c.has("reg.midColor")&&d(x=>y(x)!=null)){let x=w=>y(w),L=Xe.map(w=>w.value);f.appendChild(h("Midline color",Br,w=>x(w).midColor,"reg.midColor")),f.appendChild(this.dropdown("Midline style",L,u(w=>x(w).midStyle),w=>Bi(2,w),w=>n.patch({"reg.midStyle":w}),{label:Ss})),f.appendChild(h("Upper line color",Br,w=>x(w).upperColor,"reg.upperColor")),f.appendChild(this.dropdown("Upper line style",L,u(w=>x(w).upperStyle),w=>Bi(2,w),w=>n.patch({"reg.upperStyle":w}),{label:Ss})),f.appendChild(h("Lower line color",Br,w=>x(w).lowerColor,"reg.lowerColor")),f.appendChild(this.dropdown("Lower line style",L,u(w=>x(w).lowerStyle),w=>Bi(2,w),w=>n.patch({"reg.lowerStyle":w}),{label:Ss})),f.appendChild(h("Upper fill",qn,w=>x(w).upperFill,"reg.upperFill")),f.appendChild(h("Lower fill",qn,w=>x(w).lowerFill,"reg.lowerFill")),f.appendChild(this.toggle("Show R\xB2",QM,u(w=>x(w).showR2),w=>n.patch({"reg.showR2":w})));}let v=x=>x.vwap;if(c.has("vwap.midColor")&&d(x=>v(x)!=null)){let x=M=>v(M),L=Xe.map(M=>M.value),w=[.5,1,1.5,2,2.5,3,4,5];f.appendChild(h("VWAP color",Br,M=>x(M).midColor,"vwap.midColor")),f.appendChild(this.dropdown("VWAP style",L,u(M=>x(M).midStyle),M=>Bi(2,M),M=>n.patch({"vwap.midStyle":M}),{label:Ss})),f.appendChild(this.dropdown("Band multiplier",w,u(M=>x(M).multiplier),()=>eP,M=>n.patch({"vwap.multiplier":M}),{label:M=>`${M}\u03C3`,labelInTrigger:true})),f.appendChild(h("Upper band color",Br,M=>x(M).upperColor,"vwap.upperColor")),f.appendChild(h("Lower band color",Br,M=>x(M).lowerColor,"vwap.lowerColor")),f.appendChild(h("Band fill",qn,M=>x(M).bandFill,"vwap.bandFill"));}if(c.has("maxCurvature")){let x=u(L=>L.maxCurvature??24);f.appendChild(this.dropdown("Max curvature",Ru,x,()=>tP,L=>n.patch({maxCurvature:L}),{label:L=>`n=${L}`,labelInTrigger:true}));}if(c.has("mach")){let x=u(L=>L.mach??2);f.appendChild(this.dropdown("Mach number",Ou,x,()=>rP,L=>n.patch({mach:L}),{label:L=>`M=${L}`,labelInTrigger:true}));}if(c.has("waveCount")){let x=u(L=>L.waveCount??6);f.appendChild(this.dropdown("Waves",Du,x,()=>nP,L=>n.patch({waveCount:L}),{label:L=>`${L}`,labelInTrigger:true}));}let S=x=>x;c.has("showPrice")&&f.appendChild(this.toggle("Show price",zM,u(x=>S(x).showPrice!==false),x=>n.patch({showPrice:x}))),c.has("showDate")&&f.appendChild(this.toggle("Show date",$M,u(x=>S(x).showDate!==false),x=>n.patch({showDate:x}))),c.has("text.color")&&p&&f.appendChild(h("Text color",Bh,x=>x.text?.color||s.textColor,"text.color")),c.has("text.size")&&p&&f.appendChild(this.dropdown("Text size",Tt.map(x=>x.value),u(x=>x.text?.size??"normal"),x=>Bw(x),x=>n.patch({"text.size":x}),{label:xs}));let E=!a&&c.has("text.value");c.has("text.bold")&&!E&&f.appendChild(this.toggle("Bold",Vw,u(x=>!!x.text?.bold),x=>n.patch({"text.bold":x}))),c.has("text.italic")&&!E&&f.appendChild(this.toggle("Italic",_w,u(x=>!!x.text?.italic),x=>n.patch({"text.italic":x}))),E&&f.appendChild(this.iconBtn("Text",Bh,()=>this.toggleTextPanel(o,n,!p)));let T=o.editableLevels();if(T&&d(x=>x.editableLevels()!=null&&!(x instanceof Qe))){let x=w=>w,L=Tt.map(w=>w.value);f.appendChild(this.dropdown("Numbers size",L,u(w=>x(w).numbersSize??"small"),w=>cP(w),w=>n.patch({numbersSize:w}),{label:xs})),f.appendChild(this.dropdown("Label size",L,u(w=>x(w).labelsSize??"normal"),w=>Bw(w),w=>n.patch({labelsSize:w}),{label:xs}));}f.appendChild(this.divider()),!a&&g&&f.appendChild(this.iconBtn("Settings",Hh,()=>this.settingsDialog.open(o,n,"frvp"))),!a&&b&&f.appendChild(this.iconBtn("Position size",Hh,()=>this.settingsDialog.open(o,n,"position"))),!a&&T&&f.appendChild(this.iconBtn("Levels",Hh,()=>this.settingsDialog.open(o,n,"levels"))),f.appendChild(this.toggle("Lock",WM,u(x=>x.locked),x=>n.setLocked(x),GM));let k=this.iconBtn("Delete",KM,()=>n.remove());k.style.color="var(--vela-danger)",f.appendChild(k),f.appendChild(this.kebabButton(n)),m.append(f),this.host.appendChild(m),this.el=m,m.addEventListener("mouseover",x=>{let L=x.target.closest("[data-tip]");L?this.showTip(L):this.hideTip();}),m.addEventListener("mouseleave",()=>this.hideTip()),this.position(t),setTimeout(()=>document.addEventListener("pointerdown",this.onOutside),0);}close(){document.removeEventListener("pointerdown",this.onOutside),this.closeColorPopover(),this.closeMenu(),this.hideTip(),this.settingsDialog.close(),this.el?.remove(),this.el=null,this.textPanel=null,this.onClose=null;}destroy(){this.close();}isOwnChrome(e){if(this.el?.contains(e)||this.colorPop?.el.contains(e)||this.menuPop?.el.contains(e))return true;let t=e instanceof Element?e:e.parentElement;if(!t)return false;let n=t.closest(".vela-popover");return n!=null&&this.host.contains(n)}toggleTextPanel(e,t,n){if(this.textPanel){this.textPanel.remove(),this.textPanel=null,this.reposition();return}let i=e.text,o=document.createElement("div");o.style.cssText="padding:6px;border-top:1px solid var(--vela-border);display:flex;flex-direction:column;gap:4px;";let s=new Dr({value:i?.value??"",rows:1,size:"sm",autoGrow:true,maxLines:4,placeholder:"Label\u2026",onChange:l=>{t.patch({"text.value":l}),this.reposition();}});s.el.style.minWidth="220px",s.input.addEventListener("input",()=>{t.patch({"text.value":s.input.value}),this.reposition();}),s.input.addEventListener("keydown",l=>{if(l.stopPropagation(),l.key==="Escape"){l.preventDefault();let c=this.onClose;this.close(),c?.();}});let a=document.createElement("div");a.style.cssText="display:flex;align-items:center;justify-content:flex-start;gap:0;transform:scale(0.8);transform-origin:left center;",n&&a.append(this.colorButton("Text color",Bh,i?.color||this.theme.textColor,l=>t.patch({"text.color":l}),14),this.dropdown("Text size",Tt.map(l=>l.value),i?.size??"normal",l=>lP(l),l=>t.patch({"text.size":l}),{label:xs})),a.append(this.toggle("Bold",Vw,!!i?.bold,l=>t.patch({"text.bold":l})),this.toggle("Italic",_w,!!i?.italic,l=>t.patch({"text.italic":l}))),o.append(s.el,a),this.el?.appendChild(o),this.textPanel=o,this.reposition(),s.input.focus();}position(e){let t=this.el;if(!t)return;let n=this.host.getBoundingClientRect(),i=t.offsetWidth,o=t.offsetHeight,s=10,a=n.width/2-i/2,l=12;e&&(a=e.x+e.w/2-i/2,l=e.y-o-s,l<4&&(l=e.y+e.h+s)),t.style.left=`${Math.max(4,Math.min(a,n.width-i-4))}px`,t.style.top=`${Math.max(4,Math.min(l,n.height-o-4))}px`;}reposition(){let e=this.el;if(!e)return;let t=this.host.getBoundingClientRect(),n=e.offsetWidth,i=e.offsetHeight,o=parseFloat(e.style.left)||0,s=parseFloat(e.style.top)||0;e.style.left=`${Math.max(4,Math.min(o,t.width-n-4))}px`,e.style.top=`${Math.max(4,Math.min(s,t.height-i-4))}px`;}base(e){let t=document.createElement("button");return t.type="button",t.dataset.tip=e,t.className="vela-dpop-btn",t.style.cssText=`width:${Zn}px;height:${Zn}px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:inherit;border:none;border-radius:5px;padding:0;`,t}iconBtn(e,t,n){let i=this.base(e);return i.innerHTML=En(t),i.addEventListener("click",n),i}dragHandle(){let e=document.createElement("button");return e.type="button",e.className="vela-dpop-grip",e.style.cssText=`width:${Zn}px;height:${Zn}px;display:flex;align-items:center;justify-content:center;background:transparent;border:none;padding:0;cursor:grab;touch-action:none;color:var(--vela-fg-faint);`,e.innerHTML=En(XM),e.addEventListener("pointerdown",t=>{let n=this.el;if(!n||t.button!==0)return;t.preventDefault(),t.stopPropagation(),this.hideTip(),this.closeColorPopover(),this.closeMenu();let i=this.host.getBoundingClientRect(),o=t.clientX,s=t.clientY,a=parseFloat(n.style.left)||0,l=parseFloat(n.style.top)||0;e.style.cursor="grabbing";try{e.setPointerCapture(t.pointerId);}catch{}let c=d=>{let h=n.offsetWidth,p=n.offsetHeight,m=a+(d.clientX-o),f=l+(d.clientY-s);n.style.left=`${Math.max(4,Math.min(m,i.width-h-4))}px`,n.style.top=`${Math.max(4,Math.min(f,i.height-p-4))}px`;},u=()=>{e.style.cursor="grab",window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u);};window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u);}),e}kebabButton(e){let t=this.base("More");return t.innerHTML=En(jM),t.addEventListener("pointerdown",n=>n.stopPropagation()),t.addEventListener("click",n=>{if(n.stopPropagation(),this.menuOwner===t){this.closeMenu();return}this.openActionMenu(t,[{icon:qM,label:"Duplicate",onClick:()=>e.duplicate()},{icon:UM,label:"Bring to front",onClick:()=>e.reorder("front")},{icon:YM,label:"Send to back",onClick:()=>e.reorder("back")},{icon:ZM,label:"Reset settings",onClick:()=>e.resetSettings()}]);}),t}hostFloat(e,t){let n=this.theme,i=new $e({trigger:e,host:this.host,theme:n,position:"absolute",boundary:this.host,boundaryInset:4,viewportInset:0,gap:6,align:t.align??"start",zIndex:t.zIndex,onClose:()=>{this.menuPop===i&&(this.menuPop=null,this.menuOwner=null),this.colorPop===i&&(this.colorPop=null,this.colorOwner=null),t.onClose?.();}}),o=i.el;return o.style.background=n.background,o.style.border="1px solid var(--vela-border)",o.style.borderRadius="var(--vela-radius-lg)",o.style.boxShadow="var(--vela-shadow)",o.style.padding=t.padding,o.style.display="flex",o.style.flexDirection="column",o.style.gap="1px",o.style.color=n.textColor,o.style.font=`var(--vela-font-size-md) ${n.fontFamily}`,o.style.pointerEvents="auto",t.fill(o,i),i.show(),i}openMagnifierTimeframeMenu(e,t,n){Fw(),Te();let i=this.lowerTimeframeOptions(),o=document.createElement("div");o.style.cssText=`position:absolute;left:${e.x}px;top:${e.y}px;width:${e.w}px;height:${e.h}px;pointer-events:none;`,this.host.appendChild(o),this.menuPop=this.hostFloat(o,{zIndex:26,padding:"4px",onClose:()=>o.remove(),fill:(s,a)=>{if(i.length===0){let l=document.createElement("div");l.style.cssText="padding:6px 10px;opacity:0.65;white-space:nowrap;",l.textContent="No lower timeframe available",s.appendChild(l);return}for(let l of i){let c=document.createElement("button");c.type="button",c.className="vela-dpop-item",c.dataset.active=l.value===t?"1":"0",c.style.cssText="display:flex;align-items:center;min-width:88px;padding:5px 10px;border:none;border-radius:5px;color:inherit;cursor:pointer;text-align:left;font:inherit;font-variant-numeric:tabular-nums;",c.textContent=l.label,c.addEventListener("click",u=>{u.stopPropagation(),a.hide(),n(l.value);}),s.appendChild(c);}}}),this.menuOwner=o;}openActionMenu(e,t){this.menuPop=this.hostFloat(e,{align:"end",zIndex:26,padding:"4px",fill:(n,i)=>{for(let o of t){let s=document.createElement("button");s.type="button",s.className="vela-dpop-item",s.style.cssText="display:flex;align-items:center;gap:9px;min-width:150px;padding:6px 9px;border:none;border-radius:5px;color:inherit;cursor:pointer;text-align:left;font:inherit;";let a=document.createElement("span");a.style.cssText="display:flex;flex:none;width:20px;justify-content:center;",a.innerHTML=En(o.icon,18);let l=document.createElement("span");l.textContent=o.label,l.style.cssText="flex:1;",s.append(a,l),s.addEventListener("click",c=>{c.stopPropagation(),i.hide(),o.onClick();}),n.appendChild(s);}}}),this.menuOwner=e;}showTip(e){let t=e.dataset.tip;if(!t){this.hideTip();return}let n=this.theme;if(!this.tipEl){let p=document.createElement("div");p.style.cssText=`position:absolute;z-index:27;pointer-events:none;white-space:nowrap;background:${n.textColor};color:${n.background};padding:3px 7px;border-radius:5px;font:var(--vela-font-size-sm) ${n.fontFamily};box-shadow:var(--vela-shadow);`,this.host.appendChild(p),this.tipEl=p;}let i=this.tipEl;i.textContent=t;let o=this.host.getBoundingClientRect(),s=e.getBoundingClientRect(),a=i.offsetWidth,l=i.offsetHeight,c=6,u=s.left-o.left+s.width/2-a/2;u=Math.max(4,Math.min(u,o.width-a-4));let d=s.top-o.top-l-c,h=d>=4?d:s.bottom-o.top+c;i.style.left=`${Math.round(u)}px`,i.style.top=`${Math.round(h)}px`;}hideTip(){this.tipEl?.remove(),this.tipEl=null;}toggle(e,t,n,i,o){let s=this.base(e),a=c=>{s.dataset.active=c===Ft?"mixed":c?"1":"0",s.innerHTML=En(o&&c===false?o:t);};a(n);let l=n;return s.addEventListener("click",()=>{l=l===Ft?true:!l,a(l),i(l);}),s}widthInput(e,t,n,i,o,s){let a=new Rr({value:t===Ft?n:t,min:n,max:i,step:o,integer:o>=1,size:"sm",fill:false,compact:true,commit:"blur",title:e,onChange:s});return t===Ft&&(a.input.value="",a.input.placeholder="\u2014"),a.el.dataset.tip=e,oP(a.el),a.el}dropdown(e,t,n,i,o,s={}){let a=this.base(e);a.style.width="auto",a.style.minWidth=`${Zn}px`,a.style.padding="0 4px",a.style.gap="2px";let l=n,c=u=>{if(a.replaceChildren(),u===Ft){let p=document.createElement("span");p.textContent="\u2014",p.style.cssText="min-width:18px;text-align:center;opacity:0.85;",a.appendChild(p);}let d=u===Ft?"":i(u);if(d){let p=document.createElement("span");p.style.cssText="display:flex;",p.innerHTML=En(d),a.appendChild(p);}if(s.label&&s.labelInTrigger&&u!==Ft){let p=document.createElement("span");p.textContent=s.label(u),p.style.cssText="font-size:11px;opacity:0.85;font-variant-numeric:tabular-nums;",a.appendChild(p);}let h=document.createElement("span");h.style.cssText="display:flex;opacity:0.55;",h.innerHTML=En(JM,12),a.appendChild(h);};return c(l),a.addEventListener("pointerdown",u=>u.stopPropagation()),a.addEventListener("click",u=>{if(u.stopPropagation(),this.menuOwner===a){this.closeMenu();return}this.openMenu(a,t,l,i,s.label,d=>{l=d,c(d),o(d);});}),a}openMenu(e,t,n,i,o,s){this.menuPop=this.hostFloat(e,{zIndex:26,padding:"4px",fill:(a,l)=>{for(let c of t){let u=c===n,d=document.createElement("button");d.type="button",d.className="vela-dpop-item",d.dataset.active=u?"1":"0",d.style.cssText=`display:flex;align-items:center;gap:8px;${o?"min-width:118px;":""}padding:5px 8px;border:none;border-radius:5px;color:inherit;cursor:pointer;text-align:left;font:inherit;`;let h=i(c);if(h){let p=document.createElement("span");p.style.cssText="display:flex;flex:none;width:22px;justify-content:center;",p.innerHTML=En(h,18),d.appendChild(p);}if(o){let p=document.createElement("span");p.textContent=o(c),p.style.cssText="flex:1;font-variant-numeric:tabular-nums;",d.appendChild(p);}d.addEventListener("click",p=>{p.stopPropagation(),l.hide(),s(c);}),a.appendChild(d);}}}),this.menuOwner=e;}closeMenu(){this.menuPop?.hide();}colorButton(e,t,n,i,o=17,s=[]){let a=document.createElement("button");a.type="button",a.dataset.tip=e,a.className="vela-dpop-btn",a.style.cssText=`position:relative;width:${Zn}px;height:${Zn}px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;cursor:pointer;border-radius:5px;border:none;color:inherit;padding:0;`;let l=document.createElement("span");l.style.cssText="display:flex;",l.innerHTML=En(t,o);let c=document.createElement("span");c.style.cssText=`display:block;height:3px;width:${Math.round(o*.85)}px;border-radius:2px;background:${n===Ft?iP(s):n};`,a.append(l,c);let u=n;return a.addEventListener("pointerdown",d=>d.stopPropagation()),a.addEventListener("click",d=>{d.stopPropagation();let h=u===Ft?s[0]??O:u;this.toggleColorPopover(a,h,u===Ft?s:[],p=>{u=p,c.style.background=p,i(p);});}),a}toggleColorPopover(e,t,n,i){if(this.colorOwner===e){this.closeColorPopover();return}this.openColorPopover(e,t,n,i);}openColorPopover(e,t,n,i){let o=this.theme;this.colorPop=this.hostFloat(e,{zIndex:25,padding:"10px",fill:(s,a)=>{if(n.length>1){let l=document.createElement("div");l.style.cssText="display:flex;align-items:center;gap:6px;padding-bottom:9px;border-bottom:1px solid var(--vela-border);";let c=document.createElement("span");c.textContent="In use",c.style.cssText="font:var(--vela-font-size-sm) inherit;opacity:0.7;margin-right:2px;",l.appendChild(c);for(let u of n){let d=document.createElement("button");d.type="button",d.dataset.tip=u,d.style.cssText=`width:18px;height:18px;border-radius:4px;border:1px solid var(--vela-border-strong);cursor:pointer;background:${u};padding:0;`,d.addEventListener("click",h=>{h.stopPropagation(),a.hide(),i(u);}),l.appendChild(d);}s.appendChild(l);}s.appendChild(Qo(t,o,i));}}),this.colorOwner=e;}closeColorPopover(){this.colorPop?.hide();}divider(){let e=document.createElement("div");return e.style.cssText="width:1px;height:18px;margin:0 3px;background:var(--vela-border);",e}},Br=Z("brush"),qn=Z("bucket"),Bh=Z("type"),zM=Z("price-delta"),$M=Z("date-delta"),WM=Z("lock"),GM=Z("unlock"),UM=Z("bring-front"),YM=Z("send-back"),KM=Z("trash"),Vw=Z("bold"),_w=Z("italic"),XM=Z("grip"),jM=Z("kebab"),qM=Z("clone"),ZM=Z("reset"),Hh=Z("gear"),JM=Z("chevron-down"),QM=Z("r-squared"),eP=Z("bands"),tP=Z("dedekind"),nP=Z("sonic"),rP=Z("supersonic");function iP(r){let e=r.length>1?r:["var(--vela-fg-faint)","var(--vela-fg-muted)"],t=100/e.length;return `linear-gradient(90deg,${e.map((i,o)=>`${i} ${o*t}% ${(o+1)*t}%`).join(",")})`}function Bi(r,e){let t=e==="dashed"?"5,3":e==="dotted"?"1.5,3":"";return R(`<line x1="3.5" y1="12" x2="20.5" y2="12" stroke-width="${Number(r)||2}" stroke-dasharray="${t}"/>`)}function oP(r){r.addEventListener("keydown",e=>e.stopPropagation());}function Cs(r,e,t=17,n=""){return Lu(`<text x="12" y="${t}" font-size="${e}" text-anchor="middle"${n?" "+n:""}>${r}</text>`)}function sP(r){return Cs(String(r),15)}function aP(r){return Cs("\u25CF",(zh[String(r)]??13)+4)}function lP(r){return Cs(String(r).charAt(0).toUpperCase(),15)}var zh={small:10,normal:13,large:16,huge:20};function cP(r){return Cs("12",(zh[String(r)]??13)-1,16.5,'font-weight="600"')}function Bw(r){return Cs("T",(zh[String(r)]??13)+2)}function Hw(r){return r.charAt(0).toUpperCase()+r.slice(1)}function xs(r){return Tt.find(e=>e.value===r)?.label??Hw(String(r))}function Ss(r){return Xe.find(e=>e.value===r)?.label??Hw(String(r))}function En(r,e=HM){return r.replace("<svg ",`<svg width="${e}" height="${e}" `)}var $h=44,Wh=16,Ts=class{constructor(e,t,n,i=()=>{},o=()=>{},s=()=>{},a=()=>{},l=()=>{},c={}){this.host=e;this.theme=t;this.onArm=n;this.onMagnet=i;this.onMeasure=o;this.onEraser=s;this.onToggleFavorite=a;this.onStayMode=l;this.def={groups:[]};this.active=null;this.lastUsed=new Map;this.favorites=new Set;this.shortcuts=new Map;this.starEls=new Map;this.flyout=null;this.flyoutOwnerId=null;this.flyoutCell=null;this.groupCells=new Map;this.groupIcons=new Map;this.cursorBtn=null;this.magnetCell=null;this.magnetIcon=null;this.magnetMode="off";this.lastMagnetOn="weak";this.measureBtn=null;this.measureActive=false;this.eraserBtn=null;this.eraserActive=false;this.stayBtn=null;this.stayActive=false;this.syncBtn=null;this.syncActive=false;this.collapseBtn=null;this.collapsed=false;this.visible=false;this.tipText=new WeakMap;this.tipDisposers=[];this.onOutside=e=>{let t=e.target;this.flyout&&!this.flyout.contains(t)&&!this.root.contains(t)&&this.closeFlyout();};this.borderOverride=c.borderColor??null,this.width=c.width??$h,this.dock=c.dock??"absolute",this.onCollapse=c.onCollapse??(()=>{}),this.onDrawingsSync=c.onDrawingsSync??null,uP(),this.root=document.createElement("div"),this.root.className="vela-dtb",this.styleRoot(),e.appendChild(this.root);}get borderColor(){return this.borderOverride??this.theme.borderColor}styleRoot(){let e=this.theme;Re(this.root,e);let t=this.collapsed?Wh:this.width;this.root.dataset.collapsed=this.collapsed?"1":"";let n=this.dock==="absolute"?`position:absolute;left:0;top:0;height:100%;width:${t}px;z-index:21;`:`position:relative;height:100%;width:${t}px;flex:none;`;this.root.style.cssText=n+`display:${this.visible?"flex":"none"};flex-direction:column;gap:4px;padding:6px 0;box-sizing:border-box;background:${e.background};border-right:1px solid ${this.borderColor};color:var(--vela-fg-muted);pointer-events:auto;overflow-y:auto;overflow-x:hidden;`;}setDefinition(e){this.def=e;for(let t of e.groups){let n=t.tools[0];n&&!this.lastUsed.has(t.id)&&this.lastUsed.set(t.id,n.type);}this.rebuild();}setFavorites(e){this.favorites=new Set(e);for(let[t,n]of this.starEls)this.paintStar(n,t);}setShortcuts(e){this.shortcuts=new Map(Object.entries(e));}paintStar(e,t){let n=this.favorites.has(t);e.classList.toggle("vela-fav",n),e.setAttribute("aria-label",n?"Remove from favorites":"Add to favorites"),e.setAttribute("aria-pressed",n?"true":"false"),e.innerHTML=jc(n?xP:wP);}setVisible(e){this.visible=e,this.root.style.display=e?"flex":"none";}setActiveTool(e){if(this.active=e,e){let t=this.def.groups.find(n=>n.tools.some(i=>i.type===e));t&&(this.lastUsed.set(t.id,e),this.paintGroupIcon(t));}this.closeFlyout(),this.highlight();}setTheme(e){this.theme=e,this.styleRoot(),this.rebuild();}destroy(){this.closeFlyout();for(let e of this.tipDisposers.splice(0))e();this.root.remove();}rebuild(){for(let e of this.tipDisposers.splice(0))e();this.root.replaceChildren(),this.groupCells.clear(),this.groupIcons.clear(),this.cursorBtn=this.makeButton(dP,"Cursor",()=>this.onCursorClick()),this.root.appendChild(this.cursorBtn),this.def.groups.length>0&&this.root.appendChild(this.divider());for(let e of this.def.groups){let t=this.makeGroupCell(e);this.root.appendChild(t),this.paintGroupIcon(e);}this.root.appendChild(this.divider()),this.measureBtn=this.makeButton(hP,"Measure",()=>this.onMeasure()),this.root.appendChild(this.measureBtn),this.eraserBtn=this.makeButton(bP,"Eraser (click/drag to delete)",()=>this.onEraser()),this.root.appendChild(this.eraserBtn),this.root.appendChild(this.makeMagnetCell()),this.stayBtn=this.makeButton(fP,"Stay in drawing mode",()=>this.toggleStay()),this.root.appendChild(this.stayBtn),this.onDrawingsSync&&(this.syncBtn=this.makeButton(gP,"Sync drawings on all charts",()=>this.toggleDrawingsSync()),this.root.appendChild(this.syncBtn)),this.collapseBtn=this.makeButton(Ww,"Collapse toolbar",()=>this.toggleCollapsed()),this.collapseBtn.classList.add("vela-dtb-collapse"),this.root.appendChild(this.collapseBtn),this.paintMeasure(),this.paintEraser(),this.paintMagnet(),this.paintStay(),this.paintDrawingsSync(),this.paintCollapse(),this.highlight();}toggleCollapsed(){this.collapsed=!this.collapsed,this.closeFlyout(),this.styleRoot(),this.paintCollapse(),this.onCollapse(this.collapsed);}paintCollapse(){let e=this.collapseBtn;if(!e)return;let t=this.collapsed?"Expand toolbar":"Collapse toolbar";e.innerHTML=Xc(this.collapsed?pP:Ww,12),e.setAttribute("aria-label",t),this.tipText.set(e,t);}makeCell(e,t){let n=document.createElement("div");n.className="vela-dtb-cell";let i=document.createElement("button");i.type="button",i.className="vela-dtb-icon",i.setAttribute("aria-label",e),t.iconSvg&&(i.innerHTML=Xc(t.iconSvg)),i.addEventListener("click",t.onIcon),n.appendChild(i);let o=null;if(t.multi&&t.onArrow){let s=t.onArrow;o=document.createElement("button"),o.type="button",o.className="vela-dtb-arrow",o.setAttribute("aria-label",`${e} \u2014 more`),o.innerHTML=SP(vP),o.addEventListener("click",a=>{a.stopPropagation(),s();}),n.appendChild(o);}return this.tipDisposers.push(Kt(n,{host:this.host,theme:()=>this.theme,text:()=>this.tipText.get(n)??e,placement:"right"})),{cell:n,icon:i,arrow:o}}makeGroupCell(e){let t=e.tools.length>1,{cell:n,icon:i}=this.makeCell(e.label,{multi:t,onIcon:()=>this.onGroupIconClick(e),onArrow:t?()=>this.onArrowClick(e):void 0});return this.groupCells.set(e.id,n),this.groupIcons.set(e.id,i),n}makeMagnetCell(){let{cell:e,icon:t}=this.makeCell("Magnet snap",{iconSvg:mP,multi:true,onIcon:()=>this.toggleMagnet(),onArrow:()=>this.onMagnetArrowClick()});return this.magnetCell=e,this.magnetIcon=t,e}onCursorClick(){this.measureActive&&this.onMeasure(),this.eraserActive&&this.onEraser(),this.onArm(null);}onGroupIconClick(e){let t=this.lastUsed.get(e.id)??e.tools[0]?.type;t&&this.onArm(t);}onArrowClick(e){let t=this.flyoutOwnerId===e.id;this.closeFlyout(),t||this.openGroupFlyout(e);}toggleMagnet(){this.applyMagnet(this.magnetMode==="off"?this.lastMagnetOn:"off");}onMagnetArrowClick(){let e=this.flyoutOwnerId===zw;this.closeFlyout(),e||this.openMagnetFlyout();}applyMagnet(e){this.magnetMode=e,e!=="off"&&(this.lastMagnetOn=e),this.onMagnet(e),this.paintMagnet(),this.highlight();}setMagnetMode(e){this.magnetMode=e,e!=="off"&&(this.lastMagnetOn=e),this.paintMagnet(),this.highlight();}setMeasureActive(e){this.measureActive=e,this.paintMeasure(),this.highlight();}paintMeasure(){let e=this.measureBtn;e&&(e.dataset.active=this.measureActive?"1":"");}setEraserActive(e){this.eraserActive=e,this.paintEraser(),this.highlight();}paintEraser(){let e=this.eraserBtn;e&&(e.dataset.active=this.eraserActive?"1":"");}paintMagnet(){let e=this.magnetCell,t=this.magnetIcon;if(!e||!t)return;let n=this.magnetMode==="off"?"Off":this.magnetMode==="weak"?"Weak":"Strong";this.tipText.set(e,`Magnet snap: ${n}`);let i=this.magnetMode!=="off";e.dataset.active=i?"1":"",t.style.opacity=i?"1":"0.5";}toggleStay(){this.stayActive=!this.stayActive,this.onStayMode(this.stayActive),this.paintStay();}setStayMode(e){this.stayActive=e,this.paintStay();}paintStay(){let e=this.stayBtn;e&&(e.dataset.active=this.stayActive?"1":"",e.style.opacity=this.stayActive?"1":"0.5");}toggleDrawingsSync(){this.syncActive=!this.syncActive,this.onDrawingsSync?.(this.syncActive),this.paintDrawingsSync();}setDrawingsSyncMode(e){this.syncActive=e,this.paintDrawingsSync();}paintDrawingsSync(){let e=this.syncBtn;e&&(e.dataset.active=this.syncActive?"1":"",e.style.opacity=this.syncActive?"1":"0.5");}beginFlyout(e,t){let n=this.theme,i=document.createElement("div");i.className="vela-dtb-flyout",i.style.cssText=`position:absolute;z-index:23;display:flex;flex-direction:column;gap:2px;padding:4px;border-radius:0 8px 8px 0;background:var(--vela-surface-elev);border:1px solid ${this.borderColor};border-left:none;box-shadow:var(--vela-shadow);pointer-events:auto;overflow-y:auto;overscroll-behavior:contain;`,Re(i,n),this.host.appendChild(i);let o=t.getBoundingClientRect(),s=this.root.getBoundingClientRect(),a=this.host.getBoundingClientRect(),l=o.top-a.top;return i.style.left=`${s.right-a.left-1}px`,i.style.top=`${l}px`,i.style.maxHeight=`${Math.max(120,a.height-l-8)}px`,this.flyout=i,this.flyoutOwnerId=e,this.flyoutCell=t,t.classList.add("vela-open"),this.highlight(),document.addEventListener("pointerdown",this.onOutside),i}openGroupFlyout(e){let t=this.groupCells.get(e.id);if(!t)return;let n=this.beginFlyout(e.id,t),i=e.sections??[{label:"",tools:e.tools}];for(let o=0;o<i.length;o++){let s=i[o];s.label&&(o>0&&n.appendChild(this.flyoutSeparator()),n.appendChild(this.flyoutHeader(s.label)));for(let a of s.tools)n.appendChild(this.makeFlyoutItem({icon:a.icon,label:a.label,selected:a.type===this.active,shortcut:this.shortcuts.get(a.type),onSelect:()=>this.onArm(a.type),favorite:{type:a.type,toggle:()=>this.onToggleFavorite(a.type,!this.favorites.has(a.type))}}));}}openMagnetFlyout(){let e=this.magnetCell;if(!e)return;let t=this.beginFlyout(zw,e);t.appendChild(this.flyoutHeader("Magnet"));let n=[["off","Off"],["weak","Weak"],["strong","Strong"]];for(let[i,o]of n)t.appendChild(this.makeFlyoutItem({label:o,selected:i===this.magnetMode,onSelect:()=>{this.applyMagnet(i),this.closeFlyout();}}));}flyoutHeader(e){let t=this.theme,n=document.createElement("div");return n.textContent=e.toUpperCase(),n.style.cssText=`padding:6px 12px 2px 8px;font:var(--vela-font-size-sm) ${t.fontFamily};font-weight:600;letter-spacing:0.04em;color:var(--vela-fg-muted);user-select:none;`,n}flyoutSeparator(){let e=document.createElement("div");return e.style.cssText=`height:1px;margin:4px 8px;background:${this.borderColor};`,e}makeFlyoutItem(e){let t=this.theme,n=document.createElement("button");if(n.type="button",n.className="vela-dtb-item",n.setAttribute("aria-label",e.label),n.style.cssText=`display:flex;align-items:center;gap:8px;padding:5px 10px 5px 8px;cursor:pointer;color:${t.textColor};border-radius:var(--vela-radius-sm);font:13px ${t.fontFamily};white-space:nowrap;min-width:148px;`,e.icon){let s=document.createElement("span");s.style.cssText="width:18px;height:18px;display:flex;align-items:center;justify-content:center;flex:none;",s.innerHTML=jc(e.icon),n.appendChild(s);}let i=document.createElement("span");i.textContent=e.label,i.style.cssText="flex:1 1 auto;text-align:left;",n.appendChild(i);let o=document.createElement("span");if(o.style.cssText="width:14px;height:14px;display:flex;align-items:center;justify-content:center;flex:none;",e.selected&&(o.innerHTML=jc(yP)),n.appendChild(o),e.shortcut){let s=document.createElement("span");s.className="vela-dtb-hint",s.textContent=e.shortcut,s.style.cssText=`flex:none;font:var(--vela-font-size-md) ${t.fontFamily};color:var(--vela-fg-muted);`,n.appendChild(s);}if(e.favorite){let s=document.createElement("span");s.className="vela-dtb-star",s.setAttribute("role","button"),this.paintStar(s,e.favorite.type),this.starEls.set(e.favorite.type,s);for(let a of ["pointerdown","pointerup","mousedown","mouseup"])s.addEventListener(a,l=>l.stopPropagation());s.addEventListener("click",a=>{a.stopPropagation(),a.preventDefault(),e.favorite.toggle();}),n.appendChild(s);}return n.addEventListener("click",s=>{s.stopPropagation(),e.onSelect();}),n}closeFlyout(){this.starEls.clear(),this.flyout&&(this.flyout.remove(),this.flyout=null,this.flyoutCell?.classList.remove("vela-open"),this.flyoutCell=null,this.flyoutOwnerId=null,document.removeEventListener("pointerdown",this.onOutside),this.highlight());}paintGroupIcon(e){let t=this.groupIcons.get(e.id);if(!t)return;let n=this.lastUsed.get(e.id)??e.tools[0]?.type,i=e.tools.find(s=>s.type===n)??e.tools[0];t.innerHTML=Xc(i?.icon??"");let o=this.groupCells.get(e.id);o&&this.tipText.set(o,i?.label??e.label);}highlight(){let e=this.active?this.def.groups.find(t=>t.tools.some(n=>n.type===this.active)):null;for(let[t,n]of this.groupCells){let i=t===e?.id;n.dataset.active=i?"1":"";}this.cursorBtn&&(this.cursorBtn.dataset.active=this.active==null&&!this.measureActive&&!this.eraserActive?"1":""),this.paintMeasure(),this.paintEraser(),this.paintMagnet(),this.paintStay();}makeButton(e,t,n){let i=document.createElement("button");return i.type="button",i.className="vela-dtb-btn",i.setAttribute("aria-label",t),this.tipText.set(i,t),e&&(i.innerHTML=Xc(e)),this.tipDisposers.push(Kt(i,{host:this.host,theme:()=>this.theme,text:()=>this.tipText.get(i)??t,placement:"right"})),i.addEventListener("click",n),i}divider(){let e=document.createElement("div");return e.style.cssText=`width:24px;height:1px;margin:2px auto;flex:none;background:${this.borderColor};`,e}},zw="__magnet__",$w="vela-drawing-toolbar-styles";function uP(){if(typeof document>"u")return;let r=document.getElementById($w);r||(r=document.createElement("style"),r.id=$w,document.head.appendChild(r)),r.textContent=`
|
|
914
914
|
.vela-dtb-hit{width:22px;height:22px;display:flex;align-items:center;justify-content:center;border-radius:var(--vela-radius-md);transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease;}
|
|
915
915
|
.vela-dtb-hit--arrow{width:11px;height:22px;}
|
|
916
916
|
.vela-dtb-btn{position:relative;width:100%;height:30px;flex:none;display:flex;align-items:center;justify-content:center;cursor:pointer;color:inherit;background:transparent;border:none;padding:0;transition:color var(--vela-dur-fast) ease;}
|
|
@@ -947,11 +947,11 @@ ${xr(".vela-sd-pane")}
|
|
|
947
947
|
.vela-dtb-flyout::-webkit-scrollbar-button{display:none;width:0;height:0;}
|
|
948
948
|
.vela-dtb-flyout::-webkit-scrollbar-track,.vela-dtb-flyout::-webkit-scrollbar-track-piece,.vela-dtb-flyout::-webkit-scrollbar-corner{background:transparent;}
|
|
949
949
|
.vela-dtb-flyout::-webkit-scrollbar-thumb{background:var(--vela-scroll);border-radius:var(--vela-radius-sm);}
|
|
950
|
-
.vela-dtb-flyout::-webkit-scrollbar-thumb:hover{background:var(--vela-fg-muted);}`;}var oP=Z("cursor"),sP=Z("ruler"),_w=Z("chevrons-left"),aP=Z("chevrons-right"),lP=Z("magnet"),cP=Z("pen-lock"),uP=Z("pen-sync"),dP=Z("eraser"),hP=Z("chevron-right"),pP=Z("check"),mP=Z("star"),fP=Z("star-filled");function Yc(r){return r.replace("<svg ",'<svg width="100%" height="100%" ')}function Bw(r,e=18){return r?`<span style="width:${e}px;height:${e}px;display:flex;align-items:center;justify-content:center;">${Yc(r)}</span>`:""}function Uc(r,e=18){return `<span class="vela-dtb-hit">${Bw(r,e)}</span>`}function gP(r){return `<span class="vela-dtb-hit vela-dtb-hit--arrow">${Bw(r,11)}</span>`}function Hw(r){return `${r>=0?"+":""}${r.toFixed(2)}`}var bP=z,vP=W,yP=3,Kc=class{constructor(){this.state="idle";this.start=null;this.end=null;this.pressX=0;this.pressY=0;}isActive(){return this.state!=="idle"}isFinished(){return this.state==="finished"}down(e,t,n=e,i=t){if(this.state==="measuring"){this.end={x:n,y:i},this.state="finished";return}this.start={x:n,y:i},this.end={x:n,y:i},this.pressX=e,this.pressY=t,this.state="measuring";}move(e,t){this.state==="measuring"&&(this.end={x:e,y:t});}up(e,t,n=e,i=t){this.state==="measuring"&&Math.hypot(e-this.pressX,t-this.pressY)>yP&&(this.end={x:n,y:i},this.state="finished");}points(){return !this.start||!this.end?null:{start:this.start,end:this.end}}clear(){this.state="idle",this.start=null,this.end=null;}paint(e,t,n){if(!this.start||!this.end)return;let{x:i,y:o}=this.start,{x:s,y:a}=this.end,l=t.paneIdAtY(o)??t.paneIdAtY(a);if(!l)return;let c=t.pxToPoint(i,o,l),u=t.pxToPoint(s,a,l),d=u.price-c.price,h=c.price!==0?d/c.price*100:0,p=t.barsBetween?Math.round(t.barsBetween(c.time,u.time)):null,m=d>=0,f=m?bP:vP,g=Math.min(i,s),b=Math.max(i,s),y=Math.min(o,a),v=Math.max(o,a),S=(i+s)/2,E=(o+a)/2;e.save(),e.globalAlpha=.12,e.fillStyle=f,e.fillRect(g,y,b-g,v-y),e.globalAlpha=1,e.strokeStyle=f,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(S,o),e.lineTo(S,a),e.moveTo(i,E),e.lineTo(s,E),e.stroke(),e.setLineDash([]);let T=m?y:v,k=m?1:-1;e.fillStyle=f,e.beginPath(),e.moveTo(S,T),e.lineTo(S-5,T+k*7),e.lineTo(S+5,T+k*7),e.closePath(),e.fill(),e.restore(),this.paintLabel(e,t,n,S,y,v,f,[`${Hw(d)} (${Hw(h)}%)`,p!=null?`${p} bars \xB7 ${Qi(u.time-c.time)}`:Qi(u.time-c.time)]);}paintLabel(e,t,n,i,o,s,a,l){e.save(),e.font=`12px ${n.fontFamily}`;let c=Math.max(...l.map(f=>e.measureText(f).width))+16,u=16,d=l.length*u+8,h=s+8;h+d>t.height&&(h=o-d-8);let p=i-c/2;e.fillStyle=n.background,e.strokeStyle=a,e.lineWidth=1,e.beginPath(),e.roundRect(p,h,c,d,4),e.fill(),e.stroke(),e.fillStyle=n.textColor,e.textAlign="center",e.textBaseline="middle",l.forEach((f,g)=>e.fillText(f,i,h+8+u/2+g*u)),e.restore();}};function zw(r,e){if(e.editingText)return null;if(r.ctrlKey||r.metaKey)switch(r.key.toLowerCase()){case "z":return r.shiftKey?{kind:"redo"}:{kind:"undo"};case "y":return {kind:"redo"};case "c":return e.hasSelection?{kind:"copy"}:null;case "v":return {kind:"paste"};case "d":return e.hasSelection?{kind:"duplicate"}:null;default:return null}if(r.key==="Delete"||r.key==="Backspace")return e.hasTarget?{kind:"delete"}:null;if(e.hasSelection){let n=r.shiftKey?10:1;switch(r.key){case "ArrowLeft":return {kind:"nudge",dx:-n,dy:0};case "ArrowRight":return {kind:"nudge",dx:n,dy:0};case "ArrowUp":return {kind:"nudge",dx:0,dy:-n};case "ArrowDown":return {kind:"nudge",dx:0,dy:n}}}return null}function $w(r){let e=r;return !e||!e.tagName?false:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===true}var Ww="Enter Text",wP=8,zh=1;function $h(r){return r instanceof Bt||r instanceof ln}var xP={};function Gw(r,e){return e.length===0||r>e[e.length-1]?null:e.find(t=>t>=r)}var Xc=class{constructor(e,t,n,i){this.toolbarHost=e;this.overlayHost=t;this.canvas=n;this.deps=i;this.ctx=null;this.drawings=[];this.sliced=new Set;this.sliceCache=new Map;this.lastBounds=new Map;this.selectedIds=new Set;this.hoveredId=null;this.activeTool=null;this.intentCb=null;this.externalGhost=null;this.seriesGw=null;this.seriesGwUnsub=null;this.lastDraftKey=null;this.measure=new Kc;this.toolbarVisible=false;this.toolbarCollapsed=false;this.mobileLayout=false;this.historyChords=true;this.measureMode=false;this.eraserMode=false;this.erasing=false;this.textEditor=null;this.painter=new Hc;this.popupMulti=false;this.onPopupDismissed=e=>{if(e&&(e.shiftKey||e.ctrlKey||e.metaKey))return;let t=this.interaction.pressedId();t&&this.selectedIds.has(t)||this.clearSelection();};this.ctx=n.getContext("2d"),this.popup=new Gc(t,i.theme(),()=>i.chartBarMs()),this.toolbar=new Cs(e,i.theme(),o=>this.emit({kind:"arm",type:o}),o=>{this.deps.setSnapMode(o),this.emit({kind:"snap-mode",mode:o});},()=>this.withModeIntent(()=>this.toggleMeasure()),()=>this.withModeIntent(()=>this.toggleEraser()),(o,s)=>this.emit({kind:"favorite",type:o,on:s}),o=>this.emit({kind:"stay-mode",on:o}),{onCollapse:o=>{this.toolbarCollapsed=o,this.syncToolbarGutter();}}),this.interaction=new $c({projector:()=>this.deps.projector(),activeTool:()=>this.activeTool,drawings:()=>this.drawings,hoveredId:()=>this.hoveredId,selectedIds:()=>this.selectedIds,emit:o=>this.emit(o),changed:()=>{this.invalidateSlices(),this.render();},openSettings:(o,s,a)=>this.openSettingsById(o,s,a),snap:(o,s,a,l)=>this.deps.snap(o,s,a,l),lastStyle:()=>this.activeToolStyle});}setToolbar(e){this.toolbar.setDefinition(e);}showToolbar(e){this.toolbarVisible=e,this.toolbar.setVisible(e&&!this.mobileLayout),this.syncToolbarGutter();}setLayoutMode(e){this.mobileLayout=e==="mobile",this.toolbar.setVisible(this.toolbarVisible&&!this.mobileLayout),this.syncToolbarGutter();}syncToolbarGutter(){let e=this.toolbarVisible&&!this.mobileLayout;this.deps.setToolbarGutter(e?this.toolbarCollapsed?Hh:Bh:0);}setSeriesGateway(e){this.seriesGwUnsub?.(),this.seriesGw=e,this.seriesGwUnsub=e.onUpdate(()=>{this.invalidateSlices(),this.render(),this.deps.requestDataPaint();});}get seriesGateway(){return this.seriesGw}setExternalGhost(e){this.externalGhost=e?pt(e):null,this.render();}syncDrawings(e){this.drawings=e.map(t=>pt(t)).filter(t=>t!=null),this.textEditor&&!this.editedDrawing(this.textEditor.id)&&this.closeTextEditor(),this.invalidateSlices(),this.render(),this.deps.requestScaleUpdate();}stackRange(e){let t=this.deps.seriesBoundaries(e);return {front:Math.max(0,...t),back:Math.min(0,...t),price:this.deps.priceZ(e)??void 0}}priceRangeForPane(e,t,n){let i=1/0,o=-1/0;for(let s of this.drawings){if(!s.visible||s.paneId!==e)continue;let a=s.timeExtent();if(a&&(a.max<t||a.min>n))continue;let l=s.priceRange();l&&(l.min<i&&(i=l.min),l.max>o&&(o=l.max));}return i<=o?{min:i,max:o}:null}setActiveTool(e,t){e!=null&&(this.finishTextEditor(true),this.withModeIntent(()=>{this.measureMode&&this.exitMeasure(),this.eraserMode&&this.exitEraser();})),this.activeTool=e,this.activeToolStyle=t,this.toolbar.setActiveTool(e),e==null?this.interaction.onToolCleared():this.clearSelection(),this.render();}setFavorites(e){this.toolbar.setFavorites(e);}setToolShortcuts(e){this.toolbar.setShortcuts(e);}setSnapMode(e){this.deps.setSnapMode(e),this.toolbar.setMagnetMode(e);}setStayMode(e){this.toolbar.setStayMode(e);}setMode(e){this.withModeIntent(()=>{e==="measure"?this.measureMode||this.toggleMeasure():e==="eraser"?this.eraserMode||this.toggleEraser():(this.measureMode&&this.exitMeasure(),this.eraserMode&&this.exitEraser());});}modeOf(){return this.measureMode?"measure":this.eraserMode?"eraser":null}withModeIntent(e){let t=this.modeOf();e();let n=this.modeOf();n!==t&&this.emit({kind:"mode",mode:n});}setSelection(e){this.selectedIds=new Set(e),e.length>=2?this.openSettingsForSelection(e):this.popupMulti&&(this.popupMulti=false,this.popup.close(),e.length===1&&this.openSettingsById(e[0],0,0)),this.render();}openSettings(e){this.openSettingsById(e,0,0);}onDrawingIntent(e){return this.intentCb=e,()=>{this.intentCb===e&&(this.intentCb=null);}}claim(e,t){return this.measureMode||this.eraserMode||this.magnifierChipAt(e,t)?true:this.interaction.claim(e,t)}magnifierChipAt(e,t){for(let n=this.drawings.length-1;n>=0;n-=1){let i=this.drawings[n];if(!(i instanceof tt)||!i.visible||i.locked)continue;let o=i.chipRect;if(o&&e>=o.x&&e<=o.x+o.w&&t>=o.y&&t<=o.y+o.h)return i}return null}openMagnifierChipMenu(e){let t=e.chipRect;if(!t)return;let n=e.id;this.popup.openMagnifierTimeframeMenu(t,e.magnifier.timeframe,i=>{let o=this.drawings.find(s=>s.id===n);o instanceof tt&&(o.applySettings({"magnifier.timeframe":i}),this.render(),this.emit({kind:"edit",doc:o.serialize()}));});}deleteAt(e,t,n=false){let i=Vi(this.drawings,e,t,this.deps.projector(),6);if(!i)return false;let o=kw(i,this.selectedIds,this.drawings,n);return o.length===0?false:(this.popup.close(),this.emit({kind:"delete",ids:o}),true)}beginMeasureAt(e,t,n="off"){if(this.measureMode||this.eraserMode||this.activeTool!=null)return false;this.withModeIntent(()=>this.toggleMeasure());let i=this.interaction.snapCursor(e,t,n);return this.measure.down(e,t,i.x,i.y),this.render(),true}clearTransient(){this.textEditor&&this.finishTextEditor(true),this.measure.isFinished()&&(this.measure.clear(),this.render());}beginMarqueeAt(e,t){return this.measureMode||this.eraserMode||!this.interaction.beginMarquee(e,t)?false:(this.render(),true)}pointerDown(e,t,n="off",i=false,o=false){if(this.eraserMode){this.erasing=true,this.deleteAt(e,t);return}if(this.measureMode){let s=this.interaction.snapCursor(e,t,n);this.measure.down(e,t,s.x,s.y),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}if(this.activeTool==null){let s=this.magnifierChipAt(e,t);if(s){this.openMagnifierChipMenu(s);return}}this.interaction.down(e,t,n,i,o);}pointerMove(e,t,n="off",i=false,o=false){if(this.eraserMode){this.erasing&&this.deleteAt(e,t);return}if(this.measureMode){let s=this.interaction.snapCursor(e,t,n);this.measure.move(s.x,s.y),this.render();return}this.interaction.move(e,t,n,i),this.updateHover(e,t,o);}updateHover(e,t,n=false){let i=null;!n&&this.activeTool==null&&!this.interaction.isPlacing()&&!this.interaction.isDragging()&&(i=Vi(this.drawings,e,t,this.deps.projector(),6)?.id??null),i!==this.hoveredId&&(this.hoveredId=i,this.render());}pointerUp(e,t,n="off"){if(this.eraserMode){this.erasing=false;return}if(this.measureMode){let o=this.interaction.snapCursor(e,t,n);this.measure.up(e,t,o.x,o.y),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}let i=this.interaction.isDragging()?this.interaction.pressedId():null;this.interaction.up(e,t),i&&this.selectedIds.has(i)&&!this.popup.isOpen()&&(this.selectedIds.size>=2?this.openSettingsForSelection(this.selectionIds()):this.openSettingsById(i,e,t));}toggleMeasure(){if(this.measureMode){this.exitMeasure();return}this.eraserMode&&this.exitEraser(),this.measure.clear(),this.measureMode=true,this.emit({kind:"arm",type:null}),this.clearSelection(),this.toolbar.setMeasureActive(true),this.render();}toggleEraser(){if(this.eraserMode){this.exitEraser();return}this.measureMode&&this.exitMeasure(),this.eraserMode=true,this.erasing=false,this.emit({kind:"arm",type:null}),this.clearSelection(),this.toolbar.setEraserActive(true),this.render();}exitEraser(){this.eraserMode=false,this.erasing=false,this.toolbar.setEraserActive(false),this.render();}exitMeasure(e=true){this.measureMode=false,this.interaction.clearSnapMarker(),e&&this.measure.clear(),this.toolbar.setMeasureActive(false),this.render();}editTextInline(e){let t=this.editedDrawing(e);if(!t)return;this.closeTextEditor();let n=t.text?.value??"",i=this.inlineEditorCss(t,n);if(!i)return;let o=document.createElement("textarea");o.value=n,o.placeholder=Ww,o.spellcheck=false,o.style.cssText=i;let s=()=>{this.editedDrawing(e)?.applySettings({"text.value":o.value}),this.render();};o.addEventListener("input",s),o.addEventListener("pointerdown",a=>a.stopPropagation()),o.addEventListener("keydown",a=>{if(a.stopPropagation(),a.key==="Enter"&&!a.ctrlKey&&!a.metaKey){a.preventDefault();let l=o.selectionStart;o.setRangeText(`
|
|
951
|
-
`,l,o.selectionEnd,"end"),s();}else a.key==="Enter"?(a.preventDefault(),this.finishTextEditor(true)):a.key==="Escape"&&(a.preventDefault(),this.finishTextEditor(false));}),o.addEventListener("blur",a=>{this.popup.contains(a.relatedTarget)?this.storeText(o.value):this.finishTextEditor(true);}),this.overlayHost.appendChild(o),this.textEditor={el:o,id:e,initial:n,stored:n},o.focus(),o.setSelectionRange(o.value.length,o.value.length);}storeText(e){let t=this.textEditor,n=t&&this.editedDrawing(t.id);!t||!n||(n.applySettings({"text.value":e}),e!==t.stored&&(t.stored=e,this.emit({kind:"edit",doc:n.serialize()})));}editedDrawing(e){let t=this.drawings.find(n=>n.id===e);return
|
|
952
|
-
`),h=Math.ceil(this.measureTextWidth(d,a))+wP;return l+`left:${Math.round(c[0]+2)-Or}px;top:${Math.round(c[1]+2-(u-s)/2)-Nr}px;width:${h+Or*2}px;height:${d.length*u+Nr*2}px;padding:${Nr-zh}px ${Or-zh}px;border:${zh}px solid ${q(i.textColor,.3)};border-radius:4px;background:transparent;color:${o?.color??i.textColor};font:${a};line-height:${u}px;white-space:pre;`}measureTextWidth(e,t){let n=this.ctx;if(!n)return 120;let i=n.font;n.font=t;let o=Math.max(8,...e.map(s=>n.measureText(s).width));return n.font=i,o}layoutTextEditor(){let e=this.textEditor;if(!e)return;let t=this.editedDrawing(e.id),n=t&&this.inlineEditorCss(t,e.el.value);n&&(e.el.style.cssText=n);}closeTextEditor(){let e=this.textEditor;e&&(this.textEditor=null,e.el.remove(),this.render());}cursorAt(e,t){return this.eraserMode||this.activeTool==null&&this.magnifierChipAt(e,t)?"pointer":this.interaction.cursorAt(e,t)}cancelPlacement(){return this.measureMode||this.eraserMode?(this.withModeIntent(()=>this.measureMode?this.exitMeasure():this.exitEraser()),true):this.interaction.isPlacing()?(this.interaction.cancel(),this.activeTool!=null&&this.emit({kind:"arm",type:null}),true):this.activeTool!=null?(this.emit({kind:"arm",type:null}),true):false}dblClick(e,t){if(this.interaction.finishPlacing(true))return true;let n=Vi(this.drawings,e,t,this.deps.projector(),6);return $h(n)?(this.editTextInline(n.id),true):n!=null}handleKey(e){if(e.key==="Escape")return this.textEditor?(this.finishTextEditor(false),true):this.popup.isOpen()?(this.clearSelection(),true):this.interaction.cancel()?true:this.measureMode?(this.withModeIntent(()=>this.exitMeasure()),true):this.selectedIds.size?(this.clearSelection(),true):false;if(e.key==="Enter"&&this.interaction.finishPlacing(false))return true;let t=zw(e,{hasSelection:this.selectedIds.size>0,hasTarget:this.selectedIds.size>0||this.hoveredId!=null,editingText:$w(e.target)});if(!t)return false;switch(t.kind){case "undo":if(!this.historyChords)return false;this.emit({kind:"undo"});break;case "redo":if(!this.historyChords)return false;this.emit({kind:"redo"});break;case "copy":this.emit({kind:"copy",ids:this.selectionIds()});break;case "paste":this.emit({kind:"paste"});break;case "duplicate":this.emit({kind:"duplicate",ids:this.selectionIds()});break;case "delete":{let n=this.selectedIds.size?this.deletableSelection():this.hoveredId?[this.hoveredId]:[];n.length&&(this.popup.close(),this.emit({kind:"delete",ids:n}));break}case "nudge":this.nudgeSelection(t.dx,t.dy);break}return true}selectionIds(){return [...this.selectedIds]}deletableSelection(){return Oh(this.selectedIds,this.drawings)}nudgeSelection(e,t){let n=this.deps.projector(),i=[];for(let o of this.drawings){if(!this.selectedIds.has(o.id)||o.locked)continue;let s=o.anchors.map(l=>{let c=n.yOf(l.price,o.paneId);return c==null?{time:l.time,price:l.price}:n.pxToPoint(n.xOf(l.time)+e,c+t,o.paneId)}),a=o.serialize();a.anchors=s,i.push(a);}i.length===1?this.emit({kind:"edit",doc:i[0]}):i.length>1&&this.emit({kind:"edit-many",docs:i});}setTheme(e){this.popup.setTheme(e),this.toolbar.setTheme(e),this.render();}onResize(){this.finishTextEditor(true),this.popup.close(),this.render();}isInterleaved(e){return Gw(e.zIndex,this.lastBounds.get(e.paneId)??[])!==null}invalidateSlices(){(this.sliced.size>0||this.drawings.some(e=>this.isInterleaved(e)))&&this.deps.requestDataPaint();}prepareSlices(e){this.sliced.clear(),this.lastBounds=new Map(e.map(a=>[a,this.deps.seriesBoundaries(a)]));let t=new Map,n=this.deps.dpr(),i=this.deps.projector(),o=this.deps.theme(),s=new Map;for(let a of this.drawings){if(!a.visible)continue;let l=Gw(a.zIndex,this.lastBounds.get(a.paneId)??[]);if(l===null)continue;let c=`${a.paneId}|${l}`,u=s.get(c);u?u.drawings.push(a):s.set(c,{paneId:a.paneId,beforeZ:l,drawings:[a]}),this.sliced.add(a.id);}for(let[a,{paneId:l,beforeZ:c,drawings:u}]of s){let d=this.sliceCache.get(a);d||(d=document.createElement("canvas"),this.sliceCache.set(a,d)),(d.width!==this.canvas.width||d.height!==this.canvas.height)&&(d.width=this.canvas.width,d.height=this.canvas.height);let h=d.getContext("2d");if(!h)continue;h.setTransform(n,0,0,n,0,0),h.clearRect(0,0,d.width/n,d.height/n),this.painter.seriesLook=this.deps.seriesLook(),this.painter.paintAll(h,u,i,o,xP);let p=t.get(l)??[];p.push({beforeZ:c,canvas:d}),t.set(l,p);}for(let a of [...this.sliceCache.keys()])s.has(a)||this.sliceCache.delete(a);for(let a of t.values())a.sort((l,c)=>l.beforeZ-c.beforeZ);return t}render(){let e=this.ctx;if(!e)return;let t=this.deps.dpr();e.setTransform(t,0,0,t,0,0),e.clearRect(0,0,this.canvas.width/t,this.canvas.height/t);let n=this.deps.projector(),i=this.textEditor?this.editedDrawing(this.textEditor.id):null,o={selected:this.selectedIds,hovered:this.hoveredId,dragged:this.interaction.activeDragId(),mutedLabel:i instanceof ln?i.id:null};this.painter.seriesLook=this.deps.seriesLook(),this.painter.paintAll(e,this.drawings.filter(h=>!this.isInterleaved(h)),n,this.deps.theme(),o),this.painter.paintHighlights(e,this.drawings.filter(h=>this.isInterleaved(h)),n,Dh(o));let s=this.interaction.dragClones();s&&this.painter.paintAll(e,s,n,this.deps.theme(),{selected:new Set(s.map(h=>h.id))}),this.layoutTextEditor();let a=this.interaction.ghost();if(a&&this.painter.paintGhost(e,a,n,this.deps.theme()),this.externalGhost&&this.painter.paintGhost(e,this.externalGhost,n,this.deps.theme()),this.emitDraft(a),this.activeTool&&!a){let h=kt(this.activeTool)?.placementHint;h&&this.painter.paintPlacementHint(e,h,this.deps.theme(),n.width,n.height);}let l=this.interaction.placingMarkers(n);l&&this.painter.paintHandles(e,l);let c=this.interaction.snapMarker(),u=c?n.yOf(c.point.price,c.paneId):null;c&&u!=null&&this.painter.paintSnapRing(e,n.xOf(c.point.time),u,this.deps.theme()),this.measure.isActive()&&this.measure.paint(e,n,this.deps.theme());let d=this.interaction.marqueeRect();d&&this.painter.paintMarquee(e,d);}destroy(){this.closeTextEditor(),this.popup.destroy(),this.toolbar.destroy(),this.seriesGwUnsub?.(),this.seriesGwUnsub=null,this.seriesGw=null,this.intentCb=null,this.drawings=[];}clearSelection(){this.popup.close(),this.selectedIds.size&&this.emit({kind:"select",ids:[]}),this.render();}emitEdits(e){let t=e.map(n=>n.serialize());t.length===1?this.emit({kind:"edit",doc:t[0]}):t.length>1&&this.emit({kind:"edit-many",docs:t});}openSettingsForSelection(e){let t=()=>e.map(s=>this.drawings.find(a=>a.id===s)).filter(s=>s!=null),n=t();if(n.length<2)return;let i=this.deps.projector(),o=null;for(let s of n){let a=s.bounds(i);if(a)if(!o)o={...a};else {let l=Math.max(o.x+o.w,a.x+a.w),c=Math.max(o.y+o.h,a.y+a.h);o.x=Math.min(o.x,a.x),o.y=Math.min(o.y,a.y),o.w=l-o.x,o.h=c-o.y;}}this.popupMulti=true,this.emit({kind:"settings",id:n[0].id}),this.popup.open(n,o,{resolve:()=>t()[0]??null,patch:s=>{let a=t();for(let l of a)l.applySettings(s);this.render(),this.emitEdits(a);},setLocked:s=>{let a=t();for(let l of a)l.locked=s;this.emitEdits(a);},reorder:s=>{for(let a of t())this.emit({kind:"reorder",id:a.id,to:s});},duplicate:()=>{this.popup.close(),this.emit({kind:"duplicate",ids:t().map(s=>s.id)});},resetSettings:()=>{let s=t();for(let a of s)Ka(a);this.render(),this.emitEdits(s),this.openSettingsForSelection(e);},remove:()=>{let s=t().filter(a=>!a.locked).map(a=>a.id);s.length!==0&&(this.popup.close(),this.emit({kind:"delete",ids:s}));}},this.onPopupDismissed);}openSettingsById(e,t,n){let i=this.drawings.find(a=>a.id===e);if(!i)return;let o=()=>this.drawings.find(a=>a.id===e);this.popupMulti=false,this.emit({kind:"select",ids:[e]}),this.emit({kind:"settings",id:e});let s=i.bounds(this.deps.projector());this.popup.open([i],s,{resolve:()=>o()??null,patch:a=>{let l=o();l&&(l.applySettings(a),this.render(),this.emit({kind:"edit",doc:l.serialize()}));},setLocked:a=>{let l=o();l&&(l.locked=a,this.emit({kind:"edit",doc:l.serialize()}));},reorder:a=>this.emit({kind:"reorder",id:e,to:a}),duplicate:()=>{this.finishTextEditor(true),this.popup.close(),this.emit({kind:"duplicate",ids:[e]});},resetSettings:()=>{let a=o();a&&(Ka(a),this.render(),this.emit({kind:"edit",doc:a.serialize()}),this.openSettingsById(e,0,0));},restore:a=>{let l=o();l&&(a.style&&(l.style={...a.style}),a.text!==void 0&&(l.text=a.text?{...a.text}:void 0),a.props!==void 0&&l.applyProps(a.props),this.render(),this.emit({kind:"edit",doc:a}));},remove:()=>{this.closeTextEditor(),this.popup.close(),this.emit({kind:"delete",ids:[e]});}},this.onPopupDismissed);}deselect(){this.clearSelection();}emitDraft(e){let t=e?JSON.stringify({t:e.type,p:e.paneId,a:e.anchors,s:e.style,x:e.text}):null;t!==this.lastDraftKey&&(this.lastDraftKey=t,this.intentCb?.({kind:"draft",doc:e?e.serialize():null}));}emit(e){if(e.kind==="create"){e.doc.text&&e.doc.text.color===void 0&&(e.doc.text={...e.doc.text,color:_e(this.deps.theme().background)});let t=new Set(this.drawings.map(n=>n.id));this.intentCb?.(e),setTimeout(()=>{let n=this.drawings.find(i=>!t.has(i.id));n&&(this.openSettingsById(n.id,0,0),$h(n)&&this.editTextInline(n.id));},0);return}if(e.kind==="clone"){let t=new Set(this.drawings.map(i=>i.id));this.intentCb?.(e);let n=this.drawings.filter(i=>!t.has(i.id));n.length===1&&this.openSettingsById(n[0].id,0,0);return}this.intentCb?.(e);}};var Wh={auto:13,tiny:10,small:11,normal:13,large:16,huge:20};function Gh(r){return typeof r=="number"?r>0?r:Wh.auto:Wh[r]??Wh.auto}function Uw(r){return r.cells.some(e=>e?.some(t=>t!=null&&!t.merged))}function Yw(r){let e=new Map,t=new Set;for(let n of r.merges){e.set(`${n.startRow}:${n.startCol}`,{cs:n.endCol-n.startCol+1,rs:n.endRow-n.startRow+1});for(let i=n.startRow;i<=n.endRow;i+=1)for(let o=n.startCol;o<=n.endCol;o+=1)(i!==n.startRow||o!==n.startCol)&&t.add(`${i}:${o}`);}for(let n=0;n<r.rows;n+=1)for(let i=0;i<r.columns;i+=1)r.cells[n]?.[i]?.merged&&!e.has(`${n}:${i}`)&&t.add(`${n}:${i}`);for(let n of e.keys())t.delete(n);return {span:e,omit:t}}var Uh=6,Yh=2,jc=6,Kh=1.2;function Kw(r,e,t,n){if(!Uw(e))return;let i=SP(r,e,t);if(!i||i.w<=0||i.h<=0)return;let o=e.frameColor&&e.frameWidth>0?e.frameWidth:0,{x:s,y:a}=CP(e.position,i.w+2*o,i.h+2*o,t),l=s+o,c=a+o;e.bgColor&&(r.fillStyle=e.bgColor,r.fillRect(l,c,i.w,i.h)),o>0&&e.frameColor&&(r.strokeStyle=e.frameColor,r.lineWidth=o,r.strokeRect(s+o/2,a+o/2,i.w+o,i.h+o));let u=[0];for(let m of i.colW)u.push(u[u.length-1]+m);let d=[0];for(let m of i.rowH)d.push(d[d.length-1]+m);let h=r.textBaseline,p=r.textAlign;r.textBaseline="middle";for(let m of i.boxes){let f=l+u[m.c],g=c+d[m.r],b=u[m.c+m.cs]-u[m.c],y=d[m.r+m.rs]-d[m.r],v=m.cell;v.bgColor&&(r.fillStyle=v.bgColor,r.fillRect(f,g,b,y));let S=v.text??"";if(S.length>0){let E=Gh(v.textSize);r.font=Xw(v,E,t.theme),r.fillStyle=v.textColor??t.theme.textColor;let T=S.split(`
|
|
953
|
-
`),k=T.length*E*
|
|
954
|
-
`),f=0;for(let y of m)f=Math.max(f,r.measureText(y).width);let g=Math.ceil(f)+2*
|
|
950
|
+
.vela-dtb-flyout::-webkit-scrollbar-thumb:hover{background:var(--vela-fg-muted);}`;}var dP=Z("cursor"),hP=Z("ruler"),Ww=Z("chevrons-left"),pP=Z("chevrons-right"),mP=Z("magnet"),fP=Z("pen-lock"),gP=Z("pen-sync"),bP=Z("eraser"),vP=Z("chevron-right"),yP=Z("check"),wP=Z("star"),xP=Z("star-filled");function jc(r){return r.replace("<svg ",'<svg width="100%" height="100%" ')}function Gw(r,e=18){return r?`<span style="width:${e}px;height:${e}px;display:flex;align-items:center;justify-content:center;">${jc(r)}</span>`:""}function Xc(r,e=18){return `<span class="vela-dtb-hit">${Gw(r,e)}</span>`}function SP(r){return `<span class="vela-dtb-hit vela-dtb-hit--arrow">${Gw(r,11)}</span>`}function Uw(r){return `${r>=0?"+":""}${r.toFixed(2)}`}var CP=z,TP=W,kP=3,qc=class{constructor(){this.state="idle";this.start=null;this.end=null;this.pressX=0;this.pressY=0;}isActive(){return this.state!=="idle"}isFinished(){return this.state==="finished"}down(e,t,n=e,i=t){if(this.state==="measuring"){this.end={x:n,y:i},this.state="finished";return}this.start={x:n,y:i},this.end={x:n,y:i},this.pressX=e,this.pressY=t,this.state="measuring";}move(e,t){this.state==="measuring"&&(this.end={x:e,y:t});}up(e,t,n=e,i=t){this.state==="measuring"&&Math.hypot(e-this.pressX,t-this.pressY)>kP&&(this.end={x:n,y:i},this.state="finished");}points(){return !this.start||!this.end?null:{start:this.start,end:this.end}}clear(){this.state="idle",this.start=null,this.end=null;}paint(e,t,n){if(!this.start||!this.end)return;let{x:i,y:o}=this.start,{x:s,y:a}=this.end,l=t.paneIdAtY(o)??t.paneIdAtY(a);if(!l)return;let c=t.pxToPoint(i,o,l),u=t.pxToPoint(s,a,l),d=u.price-c.price,h=c.price!==0?d/c.price*100:0,p=t.barsBetween?Math.round(t.barsBetween(c.time,u.time)):null,m=d>=0,f=m?CP:TP,g=Math.min(i,s),b=Math.max(i,s),y=Math.min(o,a),v=Math.max(o,a),S=(i+s)/2,E=(o+a)/2;e.save(),e.globalAlpha=.12,e.fillStyle=f,e.fillRect(g,y,b-g,v-y),e.globalAlpha=1,e.strokeStyle=f,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(S,o),e.lineTo(S,a),e.moveTo(i,E),e.lineTo(s,E),e.stroke(),e.setLineDash([]);let T=m?y:v,k=m?1:-1;e.fillStyle=f,e.beginPath(),e.moveTo(S,T),e.lineTo(S-5,T+k*7),e.lineTo(S+5,T+k*7),e.closePath(),e.fill(),e.restore(),this.paintLabel(e,t,n,S,y,v,f,[`${Uw(d)} (${Uw(h)}%)`,p!=null?`${p} bars \xB7 ${eo(u.time-c.time)}`:eo(u.time-c.time)]);}paintLabel(e,t,n,i,o,s,a,l){e.save(),e.font=`12px ${n.fontFamily}`;let c=Math.max(...l.map(f=>e.measureText(f).width))+16,u=16,d=l.length*u+8,h=s+8;h+d>t.height&&(h=o-d-8);let p=i-c/2;e.fillStyle=n.background,e.strokeStyle=a,e.lineWidth=1,e.beginPath(),e.roundRect(p,h,c,d,4),e.fill(),e.stroke(),e.fillStyle=n.textColor,e.textAlign="center",e.textBaseline="middle",l.forEach((f,g)=>e.fillText(f,i,h+8+u/2+g*u)),e.restore();}};function Yw(r,e){if(e.editingText)return null;if(r.ctrlKey||r.metaKey)switch(r.key.toLowerCase()){case "z":return r.shiftKey?{kind:"redo"}:{kind:"undo"};case "y":return {kind:"redo"};case "c":return e.hasSelection?{kind:"copy"}:null;case "v":return {kind:"paste"};case "d":return e.hasSelection?{kind:"duplicate"}:null;default:return null}if(r.key==="Delete"||r.key==="Backspace")return e.hasTarget?{kind:"delete"}:null;if(e.hasSelection){let n=r.shiftKey?10:1;switch(r.key){case "ArrowLeft":return {kind:"nudge",dx:-n,dy:0};case "ArrowRight":return {kind:"nudge",dx:n,dy:0};case "ArrowUp":return {kind:"nudge",dx:0,dy:-n};case "ArrowDown":return {kind:"nudge",dx:0,dy:n}}}return null}function Kw(r){let e=r;return !e||!e.tagName?false:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===true}var Xw="Enter Text",EP=8,Gh=1;function Uh(r){return r instanceof Ht||r instanceof cn}var LP={};function jw(r,e){return e.length===0||r>e[e.length-1]?null:e.find(t=>t>=r)}var Zc=class{constructor(e,t,n,i){this.toolbarHost=e;this.overlayHost=t;this.canvas=n;this.deps=i;this.ctx=null;this.drawings=[];this.sliced=new Set;this.sliceCache=new Map;this.lastBounds=new Map;this.selectedIds=new Set;this.hoveredId=null;this.activeTool=null;this.intentCb=null;this.externalGhost=null;this.seriesGw=null;this.seriesGwUnsub=null;this.lastDraftKey=null;this.measure=new qc;this.toolbarVisible=false;this.toolbarCollapsed=false;this.mobileLayout=false;this.historyChords=true;this.measureMode=false;this.eraserMode=false;this.erasing=false;this.textEditor=null;this.painter=new Wc;this.popupMulti=false;this.onPopupDismissed=e=>{if(e&&(e.shiftKey||e.ctrlKey||e.metaKey))return;let t=this.interaction.pressedId();t&&this.selectedIds.has(t)||this.clearSelection();};this.ctx=n.getContext("2d"),this.popup=new Kc(t,i.theme(),()=>i.chartBarMs()),this.toolbar=new Ts(e,i.theme(),o=>this.emit({kind:"arm",type:o}),o=>{this.deps.setSnapMode(o),this.emit({kind:"snap-mode",mode:o});},()=>this.withModeIntent(()=>this.toggleMeasure()),()=>this.withModeIntent(()=>this.toggleEraser()),(o,s)=>this.emit({kind:"favorite",type:o,on:s}),o=>this.emit({kind:"stay-mode",on:o}),{onCollapse:o=>{this.toolbarCollapsed=o,this.syncToolbarGutter();}}),this.interaction=new Uc({projector:()=>this.deps.projector(),activeTool:()=>this.activeTool,drawings:()=>this.drawings,hoveredId:()=>this.hoveredId,selectedIds:()=>this.selectedIds,emit:o=>this.emit(o),changed:()=>{this.invalidateSlices(),this.render();},openSettings:(o,s,a)=>this.openSettingsById(o,s,a),snap:(o,s,a,l)=>this.deps.snap(o,s,a,l),lastStyle:()=>this.activeToolStyle});}setToolbar(e){this.toolbar.setDefinition(e);}showToolbar(e){this.toolbarVisible=e,this.toolbar.setVisible(e&&!this.mobileLayout),this.syncToolbarGutter();}setLayoutMode(e){this.mobileLayout=e==="mobile",this.toolbar.setVisible(this.toolbarVisible&&!this.mobileLayout),this.syncToolbarGutter();}syncToolbarGutter(){let e=this.toolbarVisible&&!this.mobileLayout;this.deps.setToolbarGutter(e?this.toolbarCollapsed?Wh:$h:0);}setSeriesGateway(e){this.seriesGwUnsub?.(),this.seriesGw=e,this.seriesGwUnsub=e.onUpdate(()=>{this.invalidateSlices(),this.render(),this.deps.requestDataPaint();});}get seriesGateway(){return this.seriesGw}setExternalGhost(e){this.externalGhost=e?pt(e):null,this.render();}syncDrawings(e){this.drawings=e.map(t=>pt(t)).filter(t=>t!=null),this.textEditor&&!this.editedDrawing(this.textEditor.id)&&this.closeTextEditor(),this.invalidateSlices(),this.render(),this.deps.requestScaleUpdate();}stackRange(e){let t=this.deps.seriesBoundaries(e);return {front:Math.max(0,...t),back:Math.min(0,...t),price:this.deps.priceZ(e)??void 0}}priceRangeForPane(e,t,n){let i=1/0,o=-1/0;for(let s of this.drawings){if(!s.visible||s.paneId!==e)continue;let a=s.timeExtent();if(a&&(a.max<t||a.min>n))continue;let l=s.priceRange();l&&(l.min<i&&(i=l.min),l.max>o&&(o=l.max));}return i<=o?{min:i,max:o}:null}setActiveTool(e,t){e!=null&&(this.finishTextEditor(true),this.withModeIntent(()=>{this.measureMode&&this.exitMeasure(),this.eraserMode&&this.exitEraser();})),this.activeTool=e,this.activeToolStyle=t,this.toolbar.setActiveTool(e),e==null?this.interaction.onToolCleared():this.clearSelection(),this.render();}setFavorites(e){this.toolbar.setFavorites(e);}setToolShortcuts(e){this.toolbar.setShortcuts(e);}setSnapMode(e){this.deps.setSnapMode(e),this.toolbar.setMagnetMode(e);}setStayMode(e){this.toolbar.setStayMode(e);}setMode(e){this.withModeIntent(()=>{e==="measure"?this.measureMode||this.toggleMeasure():e==="eraser"?this.eraserMode||this.toggleEraser():(this.measureMode&&this.exitMeasure(),this.eraserMode&&this.exitEraser());});}modeOf(){return this.measureMode?"measure":this.eraserMode?"eraser":null}withModeIntent(e){let t=this.modeOf();e();let n=this.modeOf();n!==t&&this.emit({kind:"mode",mode:n});}setSelection(e){this.selectedIds=new Set(e),e.length>=2?this.openSettingsForSelection(e):this.popupMulti&&(this.popupMulti=false,this.popup.close(),e.length===1&&this.openSettingsById(e[0],0,0)),this.render();}openSettings(e){this.openSettingsById(e,0,0);}onDrawingIntent(e){return this.intentCb=e,()=>{this.intentCb===e&&(this.intentCb=null);}}claim(e,t){return this.measureMode||this.eraserMode||this.magnifierChipAt(e,t)?true:this.interaction.claim(e,t)}magnifierChipAt(e,t){for(let n=this.drawings.length-1;n>=0;n-=1){let i=this.drawings[n];if(!(i instanceof tt)||!i.visible||i.locked)continue;let o=i.chipRect;if(o&&e>=o.x&&e<=o.x+o.w&&t>=o.y&&t<=o.y+o.h)return i}return null}openMagnifierChipMenu(e){let t=e.chipRect;if(!t)return;let n=e.id;this.popup.openMagnifierTimeframeMenu(t,e.magnifier.timeframe,i=>{let o=this.drawings.find(s=>s.id===n);o instanceof tt&&(o.applySettings({"magnifier.timeframe":i}),this.render(),this.emit({kind:"edit",doc:o.serialize()}));});}deleteAt(e,t,n=false){let i=_i(this.drawings,e,t,this.deps.projector(),6);if(!i)return false;let o=Iw(i,this.selectedIds,this.drawings,n);return o.length===0?false:(this.popup.close(),this.emit({kind:"delete",ids:o}),true)}beginMeasureAt(e,t,n="off"){if(this.measureMode||this.eraserMode||this.activeTool!=null)return false;this.withModeIntent(()=>this.toggleMeasure());let i=this.interaction.snapCursor(e,t,n);return this.measure.down(e,t,i.x,i.y),this.render(),true}clearTransient(){this.textEditor&&this.finishTextEditor(true),this.measure.isFinished()&&(this.measure.clear(),this.render());}beginMarqueeAt(e,t){return this.measureMode||this.eraserMode||!this.interaction.beginMarquee(e,t)?false:(this.render(),true)}pointerDown(e,t,n="off",i=false,o=false){if(this.eraserMode){this.erasing=true,this.deleteAt(e,t);return}if(this.measureMode){let s=this.interaction.snapCursor(e,t,n);this.measure.down(e,t,s.x,s.y),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}if(this.activeTool==null){let s=this.magnifierChipAt(e,t);if(s){this.openMagnifierChipMenu(s);return}}this.interaction.down(e,t,n,i,o);}pointerMove(e,t,n="off",i=false,o=false){if(this.eraserMode){this.erasing&&this.deleteAt(e,t);return}if(this.measureMode){let s=this.interaction.snapCursor(e,t,n);this.measure.move(s.x,s.y),this.render();return}this.interaction.move(e,t,n,i),this.updateHover(e,t,o);}updateHover(e,t,n=false){let i=null;!n&&this.activeTool==null&&!this.interaction.isPlacing()&&!this.interaction.isDragging()&&(i=_i(this.drawings,e,t,this.deps.projector(),6)?.id??null),i!==this.hoveredId&&(this.hoveredId=i,this.render());}pointerUp(e,t,n="off"){if(this.eraserMode){this.erasing=false;return}if(this.measureMode){let o=this.interaction.snapCursor(e,t,n);this.measure.up(e,t,o.x,o.y),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}let i=this.interaction.isDragging()?this.interaction.pressedId():null;this.interaction.up(e,t),i&&this.selectedIds.has(i)&&!this.popup.isOpen()&&(this.selectedIds.size>=2?this.openSettingsForSelection(this.selectionIds()):this.openSettingsById(i,e,t));}toggleMeasure(){if(this.measureMode){this.exitMeasure();return}this.eraserMode&&this.exitEraser(),this.measure.clear(),this.measureMode=true,this.emit({kind:"arm",type:null}),this.clearSelection(),this.toolbar.setMeasureActive(true),this.render();}toggleEraser(){if(this.eraserMode){this.exitEraser();return}this.measureMode&&this.exitMeasure(),this.eraserMode=true,this.erasing=false,this.emit({kind:"arm",type:null}),this.clearSelection(),this.toolbar.setEraserActive(true),this.render();}exitEraser(){this.eraserMode=false,this.erasing=false,this.toolbar.setEraserActive(false),this.render();}exitMeasure(e=true){this.measureMode=false,this.interaction.clearSnapMarker(),e&&this.measure.clear(),this.toolbar.setMeasureActive(false),this.render();}editTextInline(e){let t=this.editedDrawing(e);if(!t)return;this.closeTextEditor();let n=t.text?.value??"",i=this.inlineEditorCss(t,n);if(!i)return;let o=document.createElement("textarea");o.value=n,o.placeholder=Xw,o.spellcheck=false,o.style.cssText=i;let s=()=>{this.editedDrawing(e)?.applySettings({"text.value":o.value}),this.render();};o.addEventListener("input",s),o.addEventListener("pointerdown",a=>a.stopPropagation()),o.addEventListener("keydown",a=>{if(a.stopPropagation(),a.key==="Enter"&&!a.ctrlKey&&!a.metaKey){a.preventDefault();let l=o.selectionStart;o.setRangeText(`
|
|
951
|
+
`,l,o.selectionEnd,"end"),s();}else a.key==="Enter"?(a.preventDefault(),this.finishTextEditor(true)):a.key==="Escape"&&(a.preventDefault(),this.finishTextEditor(false));}),o.addEventListener("blur",a=>{this.popup.contains(a.relatedTarget)?this.storeText(o.value):this.finishTextEditor(true);}),this.overlayHost.appendChild(o),this.textEditor={el:o,id:e,initial:n,stored:n},o.focus(),o.setSelectionRange(o.value.length,o.value.length);}storeText(e){let t=this.textEditor,n=t&&this.editedDrawing(t.id);!t||!n||(n.applySettings({"text.value":e}),e!==t.stored&&(t.stored=e,this.emit({kind:"edit",doc:n.serialize()})));}editedDrawing(e){let t=this.drawings.find(n=>n.id===e);return Uh(t)?t:null}finishTextEditor(e){let t=this.textEditor;if(!t)return;let n=e?t.el.value:t.initial;this.closeTextEditor();let i=this.editedDrawing(t.id);i&&(i.applySettings({"text.value":n}),this.render(),i instanceof cn&&n.trim()===""?(this.clearSelection(),this.emit({kind:"delete",ids:[i.id]})):n!==t.stored&&this.emit({kind:"edit",doc:i.serialize()}));}inlineEditorCss(e,t){let n=this.deps.projector(),i=this.deps.theme(),o=e.text,s=Be(o?.size??"normal"),a=`${o?.italic?"italic ":""}${o?.bold?"bold ":""}${s}px ${i.fontFamily}`,l="position:absolute;z-index:24;box-sizing:border-box;resize:none;overflow:hidden;margin:0;outline:none;pointer-events:auto;text-align:left;";if(e instanceof Ht){let p=e.box(n);if(!p)return null;let m=e.style.fillColor??i.background;return l+`left:${Math.round(p.x)}px;top:${Math.round(p.y)}px;width:${Math.round(p.w)}px;height:${Math.round(p.h)}px;padding:5px 8px;border-radius:5px;border:1px solid ${e.style.lineColor??i.borderColor};background:${Qd(m,i.background,Gn(m).alpha)};color:${o?.color??i.textColor};font:${a};`}let c=e.handlePoints(n)[0];if(!c)return null;let u=on(s),d=(t||Xw).split(`
|
|
952
|
+
`),h=Math.ceil(this.measureTextWidth(d,a))+EP;return l+`left:${Math.round(c[0]+2)-Nr}px;top:${Math.round(c[1]+2-(u-s)/2)-Fr}px;width:${h+Nr*2}px;height:${d.length*u+Fr*2}px;padding:${Fr-Gh}px ${Nr-Gh}px;border:${Gh}px solid ${q(i.textColor,.3)};border-radius:4px;background:transparent;color:${o?.color??i.textColor};font:${a};line-height:${u}px;white-space:pre;`}measureTextWidth(e,t){let n=this.ctx;if(!n)return 120;let i=n.font;n.font=t;let o=Math.max(8,...e.map(s=>n.measureText(s).width));return n.font=i,o}layoutTextEditor(){let e=this.textEditor;if(!e)return;let t=this.editedDrawing(e.id),n=t&&this.inlineEditorCss(t,e.el.value);n&&(e.el.style.cssText=n);}closeTextEditor(){let e=this.textEditor;e&&(this.textEditor=null,e.el.remove(),this.render());}cursorAt(e,t){return this.eraserMode||this.activeTool==null&&this.magnifierChipAt(e,t)?"pointer":this.interaction.cursorAt(e,t)}cancelPlacement(){return this.measureMode||this.eraserMode?(this.withModeIntent(()=>this.measureMode?this.exitMeasure():this.exitEraser()),true):this.interaction.isPlacing()?(this.interaction.cancel(),this.activeTool!=null&&this.emit({kind:"arm",type:null}),true):this.activeTool!=null?(this.emit({kind:"arm",type:null}),true):false}dblClick(e,t){if(this.interaction.finishPlacing(true))return true;let n=_i(this.drawings,e,t,this.deps.projector(),6);return Uh(n)?(this.editTextInline(n.id),true):n!=null}handleKey(e){if(e.key==="Escape")return this.textEditor?(this.finishTextEditor(false),true):this.popup.isOpen()?(this.clearSelection(),true):this.interaction.cancel()?true:this.measureMode?(this.withModeIntent(()=>this.exitMeasure()),true):this.selectedIds.size?(this.clearSelection(),true):false;if(e.key==="Enter"&&this.interaction.finishPlacing(false))return true;let t=Yw(e,{hasSelection:this.selectedIds.size>0,hasTarget:this.selectedIds.size>0||this.hoveredId!=null,editingText:Kw(e.target)});if(!t)return false;switch(t.kind){case "undo":if(!this.historyChords)return false;this.emit({kind:"undo"});break;case "redo":if(!this.historyChords)return false;this.emit({kind:"redo"});break;case "copy":this.emit({kind:"copy",ids:this.selectionIds()});break;case "paste":this.emit({kind:"paste"});break;case "duplicate":this.emit({kind:"duplicate",ids:this.selectionIds()});break;case "delete":{let n=this.selectedIds.size?this.deletableSelection():this.hoveredId?[this.hoveredId]:[];n.length&&(this.popup.close(),this.emit({kind:"delete",ids:n}));break}case "nudge":this.nudgeSelection(t.dx,t.dy);break}return true}selectionIds(){return [...this.selectedIds]}deletableSelection(){return Vh(this.selectedIds,this.drawings)}nudgeSelection(e,t){let n=this.deps.projector(),i=[];for(let o of this.drawings){if(!this.selectedIds.has(o.id)||o.locked)continue;let s=o.anchors.map(l=>{let c=n.yOf(l.price,o.paneId);return c==null?{time:l.time,price:l.price}:n.pxToPoint(n.xOf(l.time)+e,c+t,o.paneId)}),a=o.serialize();a.anchors=s,i.push(a);}i.length===1?this.emit({kind:"edit",doc:i[0]}):i.length>1&&this.emit({kind:"edit-many",docs:i});}setTheme(e){this.popup.setTheme(e),this.toolbar.setTheme(e),this.render();}onResize(){this.finishTextEditor(true),this.popup.close(),this.render();}isInterleaved(e){return jw(e.zIndex,this.lastBounds.get(e.paneId)??[])!==null}invalidateSlices(){(this.sliced.size>0||this.drawings.some(e=>this.isInterleaved(e)))&&this.deps.requestDataPaint();}prepareSlices(e){this.sliced.clear(),this.lastBounds=new Map(e.map(a=>[a,this.deps.seriesBoundaries(a)]));let t=new Map,n=this.deps.dpr(),i=this.deps.projector(),o=this.deps.theme(),s=new Map;for(let a of this.drawings){if(!a.visible)continue;let l=jw(a.zIndex,this.lastBounds.get(a.paneId)??[]);if(l===null)continue;let c=`${a.paneId}|${l}`,u=s.get(c);u?u.drawings.push(a):s.set(c,{paneId:a.paneId,beforeZ:l,drawings:[a]}),this.sliced.add(a.id);}for(let[a,{paneId:l,beforeZ:c,drawings:u}]of s){let d=this.sliceCache.get(a);d||(d=document.createElement("canvas"),this.sliceCache.set(a,d)),(d.width!==this.canvas.width||d.height!==this.canvas.height)&&(d.width=this.canvas.width,d.height=this.canvas.height);let h=d.getContext("2d");if(!h)continue;h.setTransform(n,0,0,n,0,0),h.clearRect(0,0,d.width/n,d.height/n),this.painter.seriesLook=this.deps.seriesLook(),this.painter.paintAll(h,u,i,o,LP);let p=t.get(l)??[];p.push({beforeZ:c,canvas:d}),t.set(l,p);}for(let a of [...this.sliceCache.keys()])s.has(a)||this.sliceCache.delete(a);for(let a of t.values())a.sort((l,c)=>l.beforeZ-c.beforeZ);return t}render(){let e=this.ctx;if(!e)return;let t=this.deps.dpr();e.setTransform(t,0,0,t,0,0),e.clearRect(0,0,this.canvas.width/t,this.canvas.height/t);let n=this.deps.projector(),i=this.textEditor?this.editedDrawing(this.textEditor.id):null,o={selected:this.selectedIds,hovered:this.hoveredId,dragged:this.interaction.activeDragId(),mutedLabel:i instanceof cn?i.id:null};this.painter.seriesLook=this.deps.seriesLook(),this.painter.paintAll(e,this.drawings.filter(h=>!this.isInterleaved(h)),n,this.deps.theme(),o),this.painter.paintHighlights(e,this.drawings.filter(h=>this.isInterleaved(h)),n,Fh(o));let s=this.interaction.dragClones();s&&this.painter.paintAll(e,s,n,this.deps.theme(),{selected:new Set(s.map(h=>h.id))}),this.layoutTextEditor();let a=this.interaction.ghost();if(a&&this.painter.paintGhost(e,a,n,this.deps.theme()),this.externalGhost&&this.painter.paintGhost(e,this.externalGhost,n,this.deps.theme()),this.emitDraft(a),this.activeTool&&!a){let h=Et(this.activeTool)?.placementHint;h&&this.painter.paintPlacementHint(e,h,this.deps.theme(),n.width,n.height);}let l=this.interaction.placingMarkers(n);l&&this.painter.paintHandles(e,l);let c=this.interaction.snapMarker(),u=c?n.yOf(c.point.price,c.paneId):null;c&&u!=null&&this.painter.paintSnapRing(e,n.xOf(c.point.time),u,this.deps.theme()),this.measure.isActive()&&this.measure.paint(e,n,this.deps.theme());let d=this.interaction.marqueeRect();d&&this.painter.paintMarquee(e,d);}destroy(){this.closeTextEditor(),this.popup.destroy(),this.toolbar.destroy(),this.seriesGwUnsub?.(),this.seriesGwUnsub=null,this.seriesGw=null,this.intentCb=null,this.drawings=[];}clearSelection(){this.popup.close(),this.selectedIds.size&&this.emit({kind:"select",ids:[]}),this.render();}emitEdits(e){let t=e.map(n=>n.serialize());t.length===1?this.emit({kind:"edit",doc:t[0]}):t.length>1&&this.emit({kind:"edit-many",docs:t});}openSettingsForSelection(e){let t=()=>e.map(s=>this.drawings.find(a=>a.id===s)).filter(s=>s!=null),n=t();if(n.length<2)return;let i=this.deps.projector(),o=null;for(let s of n){let a=s.bounds(i);if(a)if(!o)o={...a};else {let l=Math.max(o.x+o.w,a.x+a.w),c=Math.max(o.y+o.h,a.y+a.h);o.x=Math.min(o.x,a.x),o.y=Math.min(o.y,a.y),o.w=l-o.x,o.h=c-o.y;}}this.popupMulti=true,this.emit({kind:"settings",id:n[0].id}),this.popup.open(n,o,{resolve:()=>t()[0]??null,patch:s=>{let a=t();for(let l of a)l.applySettings(s);this.render(),this.emitEdits(a);},setLocked:s=>{let a=t();for(let l of a)l.locked=s;this.emitEdits(a);},reorder:s=>{for(let a of t())this.emit({kind:"reorder",id:a.id,to:s});},duplicate:()=>{this.popup.close(),this.emit({kind:"duplicate",ids:t().map(s=>s.id)});},resetSettings:()=>{let s=t();for(let a of s)ja(a);this.render(),this.emitEdits(s),this.openSettingsForSelection(e);},remove:()=>{let s=t().filter(a=>!a.locked).map(a=>a.id);s.length!==0&&(this.popup.close(),this.emit({kind:"delete",ids:s}));}},this.onPopupDismissed);}openSettingsById(e,t,n){let i=this.drawings.find(a=>a.id===e);if(!i)return;let o=()=>this.drawings.find(a=>a.id===e);this.popupMulti=false,this.emit({kind:"select",ids:[e]}),this.emit({kind:"settings",id:e});let s=i.bounds(this.deps.projector());this.popup.open([i],s,{resolve:()=>o()??null,patch:a=>{let l=o();l&&(l.applySettings(a),this.render(),this.emit({kind:"edit",doc:l.serialize()}));},setLocked:a=>{let l=o();l&&(l.locked=a,this.emit({kind:"edit",doc:l.serialize()}));},reorder:a=>this.emit({kind:"reorder",id:e,to:a}),duplicate:()=>{this.finishTextEditor(true),this.popup.close(),this.emit({kind:"duplicate",ids:[e]});},resetSettings:()=>{let a=o();a&&(ja(a),this.render(),this.emit({kind:"edit",doc:a.serialize()}),this.openSettingsById(e,0,0));},restore:a=>{let l=o();l&&(a.style&&(l.style={...a.style}),a.text!==void 0&&(l.text=a.text?{...a.text}:void 0),a.props!==void 0&&l.applyProps(a.props),this.render(),this.emit({kind:"edit",doc:a}));},remove:()=>{this.closeTextEditor(),this.popup.close(),this.emit({kind:"delete",ids:[e]});}},this.onPopupDismissed);}deselect(){this.clearSelection();}emitDraft(e){let t=e?JSON.stringify({t:e.type,p:e.paneId,a:e.anchors,s:e.style,x:e.text}):null;t!==this.lastDraftKey&&(this.lastDraftKey=t,this.intentCb?.({kind:"draft",doc:e?e.serialize():null}));}emit(e){if(e.kind==="create"){e.doc.text&&e.doc.text.color===void 0&&(e.doc.text={...e.doc.text,color:_e(this.deps.theme().background)});let t=new Set(this.drawings.map(n=>n.id));this.intentCb?.(e),setTimeout(()=>{let n=this.drawings.find(i=>!t.has(i.id));n&&(this.openSettingsById(n.id,0,0),Uh(n)&&this.editTextInline(n.id));},0);return}if(e.kind==="clone"){let t=new Set(this.drawings.map(i=>i.id));this.intentCb?.(e);let n=this.drawings.filter(i=>!t.has(i.id));n.length===1&&this.openSettingsById(n[0].id,0,0);return}this.intentCb?.(e);}};var Yh={auto:13,tiny:10,small:11,normal:13,large:16,huge:20};function Kh(r){return typeof r=="number"?r>0?r:Yh.auto:Yh[r]??Yh.auto}function qw(r){return r.cells.some(e=>e?.some(t=>t!=null&&!t.merged))}function Zw(r){let e=new Map,t=new Set;for(let n of r.merges){e.set(`${n.startRow}:${n.startCol}`,{cs:n.endCol-n.startCol+1,rs:n.endRow-n.startRow+1});for(let i=n.startRow;i<=n.endRow;i+=1)for(let o=n.startCol;o<=n.endCol;o+=1)(i!==n.startRow||o!==n.startCol)&&t.add(`${i}:${o}`);}for(let n=0;n<r.rows;n+=1)for(let i=0;i<r.columns;i+=1)r.cells[n]?.[i]?.merged&&!e.has(`${n}:${i}`)&&t.add(`${n}:${i}`);for(let n of e.keys())t.delete(n);return {span:e,omit:t}}var Xh=6,jh=2,Jc=6,qh=1.2;function Jw(r,e,t,n){if(!qw(e))return;let i=MP(r,e,t);if(!i||i.w<=0||i.h<=0)return;let o=e.frameColor&&e.frameWidth>0?e.frameWidth:0,{x:s,y:a}=PP(e.position,i.w+2*o,i.h+2*o,t),l=s+o,c=a+o;e.bgColor&&(r.fillStyle=e.bgColor,r.fillRect(l,c,i.w,i.h)),o>0&&e.frameColor&&(r.strokeStyle=e.frameColor,r.lineWidth=o,r.strokeRect(s+o/2,a+o/2,i.w+o,i.h+o));let u=[0];for(let m of i.colW)u.push(u[u.length-1]+m);let d=[0];for(let m of i.rowH)d.push(d[d.length-1]+m);let h=r.textBaseline,p=r.textAlign;r.textBaseline="middle";for(let m of i.boxes){let f=l+u[m.c],g=c+d[m.r],b=u[m.c+m.cs]-u[m.c],y=d[m.r+m.rs]-d[m.r],v=m.cell;v.bgColor&&(r.fillStyle=v.bgColor,r.fillRect(f,g,b,y));let S=v.text??"";if(S.length>0){let E=Kh(v.textSize);r.font=Qw(v,E,t.theme),r.fillStyle=v.textColor??t.theme.textColor;let T=S.split(`
|
|
953
|
+
`),k=T.length*E*qh,x=v.vAlign==="top"?g+jh:v.vAlign==="bottom"?g+y-jh-k:g+(y-k)/2,L=v.hAlign==="left"?f+Xh:v.hAlign==="right"?f+b-Xh:f+b/2;r.textAlign=v.hAlign,T.forEach((w,M)=>r.fillText(w,L,x+(M+.5)*E*qh));}v.tooltip&&n.push({left:f,top:g,right:f+b,bottom:g+y,text:v.tooltip});}if(r.textBaseline=h,r.textAlign=p,e.borderColor&&e.borderWidth>0){r.strokeStyle=e.borderColor,r.lineWidth=e.borderWidth;let m=new Set;r.beginPath();let f=(g,b,y,v)=>{let S=`${g},${b},${y},${v}`;m.has(S)||(m.add(S),r.moveTo(g,b),r.lineTo(y,v));};for(let g of i.boxes){let b=Math.round(l+u[g.c]),y=Math.round(l+u[g.c+g.cs]),v=Math.round(c+d[g.r]),S=Math.round(c+d[g.r+g.rs]);f(b,v,y,v),f(b,S,y,S),f(b,v,b,S),f(y,v,y,S);}r.stroke();}}function MP(r,e,t){let{span:n,omit:i}=Zw(e),o=new Array(e.columns).fill(0),s=new Array(e.rows).fill(0),a=[];for(let h=0;h<e.rows;h+=1)for(let p=0;p<e.columns;p+=1){if(i.has(`${h}:${p}`))continue;let m=e.cells[h]?.[p];if(m==null)continue;let f=n.get(`${h}:${p}`);a.push({cell:m,r:h,c:p,cs:Math.min(f?.cs??1,e.columns-p),rs:Math.min(f?.rs??1,e.rows-h)});}if(a.length===0)return null;let l=h=>{let p=Kh(h.textSize);r.font=Qw(h,p,t.theme);let m=(h.text??"").split(`
|
|
954
|
+
`),f=0;for(let y of m)f=Math.max(f,r.measureText(y).width);let g=Math.ceil(f)+2*Xh,b=Math.ceil(m.length*p*qh)+2*jh;return h.width&&(g=Math.max(g,h.width/100*t.plotWidth)),h.height&&(b=Math.max(b,h.height/100*t.paneHeight)),{w:g,h:b}},c=[];for(let h of a){let{w:p,h:m}=l(h.cell);h.cs===1&&(o[h.c]=Math.max(o[h.c],p)),h.rs===1&&(s[h.r]=Math.max(s[h.r],m)),(h.cs>1||h.rs>1)&&c.push({box:h,w:p,h:m});}for(let{box:h,w:p,h:m}of c){if(h.cs>1){let f=0;for(let g=h.c;g<h.c+h.cs;g+=1)f+=o[g];if(p>f)for(let g=h.c;g<h.c+h.cs;g+=1)o[g]+=(p-f)/h.cs;}if(h.rs>1){let f=0;for(let g=h.r;g<h.r+h.rs;g+=1)f+=s[g];if(m>f)for(let g=h.r;g<h.r+h.rs;g+=1)s[g]+=(m-f)/h.rs;}}let u=0;for(let h of o)u+=h;let d=0;for(let h of s)d+=h;return {colW:o,rowH:s,w:u,h:d,boxes:a}}function PP(r,e,t,n){let i;r.startsWith("top")?i=Jc:r.startsWith("bottom")?i=n.paneHeight-Jc-t:i=n.paneHeight/2-t/2;let o;return r.endsWith("left")?o=Jc:r.endsWith("right")?o=n.plotWidth-Jc-e:o=n.plotWidth/2-e/2,{x:o,y:i}}function Qw(r,e,t){let n=r.fontFamily==="monospace"?"monospace":t.fontFamily||"sans-serif";return `${r.italic?"italic ":""}${r.bold?"bold ":""}${e}px ${n}`}function IP(r,e){return e.find(t=>t>r)??1/0}var Qc=class{constructor(){this.drawScene=new Ni({timeToLogical:()=>0,barAt:()=>null,theme:{}});this.sliceCache=new Map;this.tips=[];}prepare(e,t,n,i){this.tips=[];let o=new Map;if(i.width===0||i.height===0)return this.sliceCache.clear(),o;this.drawScene.setDeps({timeToLogical:u=>t.timeToLogical(u),barAt:u=>{let d=e.bars[Math.round(u)];return d?{high:d.high,low:d.low}:null},theme:n});let s=t.dpr,a=t.width,l=new Map,c=(u,d,h)=>{let p=`${u}|${d}`,m=l.get(p);m?m.entries.push(h):l.set(p,{paneId:u,beforeZ:d,entries:[h]});};for(let u of e.orderedPanes()){if(u.collapsed)continue;let d=e.seriesBoundaries(u.id);for(let h of e.orderedIndicatorsForPane(u.id)){let p=Fi(h,false),m=(h.tables??[]).filter(y=>!y.overlay);if(Th(p)&&m.length===0)continue;let f=e.scaleFor(h,u),g=f===u.scale?u:{...u,scale:f},b=IP(e.zOf(h.id),d);c(u.id,b,{set:p,tables:m,pane:g,indexOffset:e.offsetOf(h.id)});}if(u.kind==="price")for(let h of e.indicators.values()){let p=Fi(h,true),m=(h.tables??[]).filter(f=>f.overlay===true);Th(p)&&m.length===0||c(u.id,1/0,{set:p,tables:m,pane:u,indexOffset:e.offsetOf(h.id)});}}for(let[u,{paneId:d,beforeZ:h,entries:p}]of l){let m=this.sliceCache.get(u);m||(m=document.createElement("canvas"),this.sliceCache.set(u,m)),(m.width!==i.width||m.height!==i.height)&&(m.width=i.width,m.height=i.height);let f=m.getContext("2d");if(!f)continue;f.setTransform(s,0,0,s,0,0),f.clearRect(0,0,m.width/s,m.height/s);for(let b of p)this.paintEntry(f,b,t,a,n);let g=o.get(d)??[];g.push({beforeZ:h,canvas:m}),o.set(d,g);}for(let u of [...this.sliceCache.keys()])l.has(u)||this.sliceCache.delete(u);for(let u of o.values())u.sort((d,h)=>d.beforeZ-h.beforeZ);return o}paintEntry(e,t,n,i,o){let{pane:s}=t,a=[];e.save(),e.translate(0,s.bounds.top),e.beginPath(),e.rect(0,0,i,s.bounds.height),e.clip(),this.drawScene.setSet(t.set,t.indexOffset),this.drawScene.render(e,i,s.bounds.height,l=>n.logicalToX(l),l=>n.priceToY(l,s.scale,s.bounds)-s.bounds.top),a.push(...this.drawScene.labelTipRegions());for(let l of t.tables)Jw(e,l,{paneHeight:s.bounds.height,plotWidth:i,theme:o},a);e.restore();for(let l of a)this.tips.push({...l,top:l.top+s.bounds.top,bottom:l.bottom+s.bounds.top});}labelTooltipAt(e,t){for(let n=this.tips.length-1;n>=0;n-=1){let i=this.tips[n];if(e>=i.left&&e<=i.right&&t>=i.top&&t<=i.bottom)return i.text}return null}};function ex(r,e){let t=new Map;for(let[n,i]of r)t.set(n,[...i]);for(let[n,i]of e)t.set(n,[...t.get(n)??[],...i]);for(let n of t.values())n.sort((i,o)=>i.beforeZ-o.beforeZ);return t}function tx(r,e,t,n,i){return {xOf:o=>r.timeToX(o),yOf:(o,s)=>{let a=e(s);return a?r.priceToY(o,a.scale,a.bounds):null},pxToPoint:(o,s,a)=>{let l=e(a),c=r.logicalToTime(r.xToLogical(o)),u=l?r.yToPrice(s,l.scale,l.bounds):0;return {time:c,price:u}},paneIdAtY:t,paneRect:o=>{let s=e(o);return s?{top:s.bounds.top,height:s.collapsed?0:s.bounds.height}:null},barsBetween:(o,s)=>Math.abs(r.timeToLogical(s)-r.timeToLogical(o)),barsInRange:n?(o,s)=>n(o,s):void 0,seriesInRange:i,width:r.width,height:r.height}}var nx=2/7,rx=1/7;function eu(r,e,t,n,i,o,s=false,a=()=>0){let l=1/0,c=-1/0,u=h=>{h!=null&&Number.isFinite(h)&&(h<l&&(l=h),h>c&&(c=h));};if(t)for(let h=n;h<=i;h+=1){let p=e[h];p&&(u(p.high),u(p.low));}for(let h of r){let p=a(h.id);for(let m of h.series)m.overlay!==true&&ix(m,n,i,p,u);for(let m of h.priceLines)u(m.price);}if(o&&(u(o.min),u(o.max)),l===1/0||c===-1/0)return {min:0,max:1};if(l===c){let h=Math.abs(l)*.1||1;return {min:l-h,max:c+h,log:s&&l-h>0}}if(s&&l>0){let h=Math.log(l),p=Math.log(c),m=p-h;return {min:Math.exp(h-m*rx),max:Math.exp(p+m*nx),log:true}}let d=c-l;return {min:l-d*rx,max:c+d*nx}}function ix(r,e,t,n,i){if(Ns(r)){if(r.kind==="candle"||r.kind==="bar")for(let o=e;o<=t;o+=1){let s=r.bars[o-n];s&&(i(s.high),i(s.low));}else if(Fe(r)){for(let o=e;o<=t;o+=1)i(r.points[o-n]?.value);r.kind==="histogram"||r.kind==="columns"?i(r.style?.base??0):r.style?.base!=null&&i(r.style.base);}}}function ox(r,e,t,n=()=>0){let i=1/0,o=-1/0,s=a=>{a!=null&&Number.isFinite(a)&&(a<i&&(i=a),a>o&&(o=a));};for(let a of r){let l=n(a.id);for(let c of a.series)c.overlay===true&&ix(c,e,t,l,s);}return i===1/0?null:{min:i,max:o}}function sx(r,e,t,n){if(t<=0&&n<=0)return r;let i=e-t-n;if(!(i>=8))return r;if(r.log&&r.min>0&&r.max>r.min){let s=Math.log(r.min),a=Math.log(r.max),l=(a-s)/i;return {...r,min:Math.exp(s-n*l),max:Math.exp(a+t*l)}}if(r.max<=r.min)return r;let o=(r.max-r.min)/i;return {...r,min:r.min-n*o,max:r.max+t*o}}var AP=new Set(["a","abbr","b","blockquote","br","code","dd","del","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","ins","kbd","li","mark","ol","p","pre","q","s","small","span","strong","sub","sup","table","tbody","td","tfoot","th","thead","tr","u","ul"]),RP=new Set(["script","style","iframe","frame","frameset","object","embed","applet","form","input","textarea","button","select","option","link","meta","base","svg","math","template","noscript","audio","video","canvas","dialog","head","title"]),DP={a:new Set(["href"]),img:new Set(["src","alt","width","height"]),td:new Set(["colspan","rowspan"]),th:new Set(["colspan","rowspan"]),ol:new Set(["start"])},OP=new Set(["javascript","vbscript","data","file","blob"]);function NP(r){let e=r.toLowerCase();return RP.has(e)?"drop":AP.has(e)?"keep":"unwrap"}function FP(r,e){let t=e.toLowerCase();return t.startsWith("on")||t==="style"?false:t==="title"?true:DP[r.toLowerCase()]?.has(t)??false}function VP(r,e=false){let t="";for(let o of r)o.charCodeAt(0)>32&&(t+=o);let n=/^([a-z][a-z0-9+.-]*):/i.exec(t),i=n?n[1].toLowerCase():null;return i!==null&&OP.has(i)||e&&i!=="http"&&i!=="https"?null:t}var _P=1,BP=3;function ax(r,e){let t=e.createElement("template");t.innerHTML=r;let n=e.createDocumentFragment();return Zh(t.content,n,e),n}function Zh(r,e,t){for(let n of Array.from(r.childNodes)){if(n.nodeType===BP){e.appendChild(t.createTextNode(n.textContent??""));continue}if(n.nodeType!==_P)continue;let i=n,o=i.tagName.toLowerCase(),s=NP(o);if(s==="drop")continue;if(s==="unwrap"){Zh(i,e,t);continue}let a=t.createElement(o);for(let l of Array.from(i.attributes)){let c=l.name.toLowerCase();if(!FP(o,c))continue;let u=l.value;if(c==="href"||c==="src"){let d=VP(u,c==="src");if(d===null)continue;u=d;}a.setAttribute(c,u);}o==="a"&&(a.setAttribute("target","_blank"),a.setAttribute("rel","noopener noreferrer")),Zh(i,a,t),e.appendChild(a);}}var HP="vela-marks-popover",zP=`
|
|
955
955
|
.vela-marks-panel { padding: 0; gap: 0; min-width: 220px; max-width: 320px; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }
|
|
956
956
|
.vela-marks-section { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; }
|
|
957
957
|
.vela-marks-section + .vela-marks-section { border-top: 1px solid var(--vela-border); }
|
|
@@ -967,7 +967,7 @@ ${xr(".vela-sd-pane")}
|
|
|
967
967
|
.vela-marks-html td, .vela-marks-html th { padding: 2px 6px; border: 1px solid var(--vela-border); }
|
|
968
968
|
.vela-marks-html pre, .vela-marks-html code { font-family: var(--vela-font-mono, monospace); font-size: 0.92em; }
|
|
969
969
|
.vela-marks-loading, .vela-marks-error { color: var(--vela-fg-muted); font-style: italic; }
|
|
970
|
-
`,Jc=class{constructor(e){this.deps=e;this.pop=null;this.openKey=null;this.generation=0;let t=e.plot.ownerDocument;he(Go,Uo,t),he(OP,NP,t),this.anchor=t.createElement("div"),this.anchor.className="vela-marks-anchor",Object.assign(this.anchor.style,{position:"absolute",pointerEvents:"none",left:"0",top:"0",width:"0",height:"0"}),e.plot.appendChild(this.anchor);}get key(){return this.openKey}open(e,t){this.close(),this.place(t);let n=++this.generation;this.openKey=e.key,this.pop=new $e({trigger:this.anchor,host:this.deps.host(),theme:this.deps.theme(),gap:8,align:"center",fadeMs:120,className:"vela-marks-pop",content:i=>this.build(i,e,n),onClose:()=>{this.generation===n&&(this.openKey=null,this.pop=null,this.deps.onOpenChange?.(null));}}),this.pop.show(),this.deps.onOpenChange?.(e.key);}track(e){if(this.pop){if(!e){this.close();return}this.place(e),this.pop.reposition();}}close(){let e=this.pop,t=this.openKey!==null;this.pop=null,this.openKey=null,this.generation++,e?.destroy(),t&&this.deps.onOpenChange?.(null);}destroy(){this.close(),this.anchor.remove();}place(e){Object.assign(this.anchor.style,{left:`${e.x-e.size/2}px`,top:`${e.y-e.size/2}px`,width:`${e.size}px`,height:`${e.size}px`});}build(e,t,n){let i=e.ownerDocument,o=i.createElement("div");o.className="vela-callout-panel vela-marks-panel";let s=[];for(let a of t.marks){let l=i.createElement("section");if(l.className="vela-marks-section",a.title){let u=i.createElement("div");u.className="vela-callout-title",u.textContent=a.title,l.appendChild(u);}let c=a.content;if(typeof c=="function"){let u=i.createElement("div");u.className="vela-marks-loading",u.textContent="Loading\u2026",l.appendChild(u),s.push({el:l,resolve:()=>this.resolveLazy(c,u,n)});}else c!==void 0&&this.renderContent(l,c);l.childElementCount>0&&o.appendChild(l);}e.appendChild(o),s.length>0&&FP(o,s);}resolveLazy(e,t,n){let i;try{i=Promise.resolve(e());}catch(o){i=Promise.reject(o instanceof Error?o:new Error(String(o)));}i.then(o=>{if(n!==this.generation)return;let s=t.parentElement;s&&(t.remove(),this.renderContent(s,o),this.pop?.reposition());},()=>{n===this.generation&&(t.className="vela-marks-error",t.textContent="Couldn\u2019t load this entry.");});}renderContent(e,t){let n=e.ownerDocument;if(!(!t||typeof t!="object")){if("text"in t){let i=n.createElement("div");i.className="vela-callout-text",i.textContent=String(t.text),e.appendChild(i);return}if("html"in t){let i=n.createElement("div");i.className="vela-marks-html",i.appendChild(nx(String(t.html),n)),e.appendChild(i);return}if("panel"in t&&t.panel&&Array.isArray(t.panel.items)){let i=null;for(let o of t.panel.items)if(!(!o||typeof o!="object")){if(o.type==="button"){i||(i=n.createElement("div"),i.className="vela-callout-actions",e.appendChild(i));let s=n.createElement("button");s.type="button",s.className="vela-callout-btn"+(o.primary?" vela-callout-btn-primary":""),s.textContent=o.label,s.addEventListener("click",()=>{o.run(),o.close!==false&&this.close();}),i.appendChild(s);continue}if(i=null,o.type==="text"){let s=n.createElement("div");s.className="vela-callout-text",s.textContent=o.text,e.appendChild(s);}else if(o.type==="field"){let s=n.createElement("div");s.className="vela-marks-field";let a=n.createElement("span");a.className="vela-marks-field-label",a.textContent=o.label;let l=n.createElement("span");l.className="vela-marks-field-value",l.textContent=o.value,s.append(a,l),e.appendChild(s);}}}}}};function FP(r,e){if(typeof IntersectionObserver>"u"){for(let n of e)n.resolve();return}let t=new IntersectionObserver(n=>{for(let i of n){if(!i.isIntersecting)continue;let o=e.find(s=>s.el===i.target);o&&(t.unobserve(i.target),o.resolve());}},{root:r});for(let n of e)t.observe(n.el);}function rx(r,e){if(r.log&&r.min>0&&r.max>r.min){let i=Math.log(r.min),o=Math.log(r.max),s=(i+o)/2,a=(o-i)/2*e;return {min:Math.exp(s-a),max:Math.exp(s+a),log:true}}let t=(r.min+r.max)/2,n=(r.max-r.min)/2*e;return {min:t-n,max:t+n,log:r.log}}function ix(r,e,t){if(t<=0)return {...r};if(r.log&&r.min>0&&r.max>r.min){let i=Math.log(r.min),o=Math.log(r.max),s=(o-i)*e/t;return {min:Math.exp(i+s),max:Math.exp(o+s),log:true}}let n=(r.max-r.min)*e/t;return {min:r.min+n,max:r.max+n,log:r.log}}function ox(r,e,t=24){let{combinedTop:n,combinedHeight:i,combinedWeight:o,startBoundaryY:s}=r,a=Math.min(t,i/2),l=n+a,c=n+i-a,d=Math.max(l,Math.min(c,s+e))-n,h=i>0?o*(d/i):o/2;return {above:h,below:o-h}}function VP(r,e,t,n){let i=Math.max(t,r),o=Math.min(n,e);return o>i?{x:i,width:o-i}:null}function _P(r){return Math.ceil(r)-.5}var Qc=class{constructor(){this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}destroy(){this.canvas=null,this.ctx=null;}render(e,t,n,i){let o=this.ctx,s=this.canvas;if(!o||!s)return;let a=t.dpr;o.setTransform(a,0,0,a,0,0),o.clearRect(0,0,s.width/a,s.height/a);let l=t.barCount;if(l===0)return;let c=t.visibleLogicalRange();Math.min(l-1,Math.ceil(c.to))<Math.max(0,Math.floor(c.from))||(this.drawHighlights(o,e,t),this.drawGrid(o,e,t,n,t.width,i));}drawHighlights(e,t,n){let i=t.sessionHighlightBands();if(i.length>0){let o=Math.max(0,n.logicalToX(-0.5)),s=Math.min(n.width,n.logicalToX(n.barCount-.5));this.drawHighlightSet(e,i,n,o,s,true);}this.drawHighlightSet(e,t.highlights,n,0,n.width,false);}drawHighlightSet(e,t,n,i,o,s){let a=l=>s?n.logicalToX(_P(n.timeToLogical(l))):n.timeToX(l);for(let l of t){let c=VP(a(l.from),a(l.to),i,o);c&&(e.fillStyle=l.color,e.fillRect(c.x,0,c.width,n.height));}}drawGrid(e,t,n,i,o,s){let a=t.orderedPanes(),{gridVert:l,gridHorz:c}=t.style,u=l.color??i.gridColor,d=c.color??i.gridColor;if(e.lineWidth=1,t.showGrid&&l.visible){e.globalAlpha=s,e.strokeStyle=u;let h=n.visibleTimeRange(),p=us((h.from+h.to)/2,t.timezone);e.beginPath();for(let m of Ac(h.from,h.to,8,p)){let f=Math.round(n.timeToX(m.time))+.5;f<0||f>o||(e.moveTo(f,0),e.lineTo(f,n.height));}e.stroke();}for(let h of a)if(t.showGrid&&c.visible&&!h.collapsed){e.globalAlpha=s,e.strokeStyle=d;let p=Tn(t,h);e.beginPath();for(let m of fs(h.scale,h.bounds.height,p,void 0,h.axisFormat)){let f=Math.round(n.priceToY(m.price,h.scale,h.bounds))+.5;f<h.bounds.top||f>h.bounds.top+h.bounds.height||(e.moveTo(0,f),e.lineTo(o,f));}e.stroke();}e.globalAlpha=1;}};function sx(r,e,t,n){let{i0:i,i1:o,xOf:s,halfW:a,bottomY:l,maxH:c,maxVol:u}=t;if(!(u<=0||c<=0)){r.globalAlpha=.5;for(let d=i;d<=o;d+=1){let h=e[d],p=h?.volume;if(h==null||p==null||!(p>0))continue;let m=Math.max(1,p/u*c);r.fillStyle=h.close>=h.open?n.up:n.down,r.fillRect(s(d)-a,l-m,a*2,m);}r.globalAlpha=1;}}var jh=.96;function BP(r){return Math.max(.5,Math.floor(r*.7)/2)}var eu=class{constructor(){this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}destroy(){this.canvas=null,this.ctx=null;}render(e){let t=this.ctx,n=this.canvas;if(!t||!n)return;let{bars:i,data:o,visible:s,coords:a,bounds:l,fillPane:c}=e,u=a.dpr;if(t.setTransform(u,0,0,u,0,0),t.clearRect(0,0,n.width/u,n.height/u),!o||!s||i.length===0||l.height<=0)return;let d=a.visibleLogicalRange(),h=Math.max(0,Math.floor(d.from)),p=Math.min(i.length-1,Math.ceil(d.to));if(h>p)return;let m=0;for(let f=h;f<=p;f+=1){let g=i[f]?.volume;g!=null&&g>m&&(m=g);}m<=0||(t.save(),t.beginPath(),t.rect(0,l.top,a.width,l.height),t.clip(),sx(t,i,{i0:h,i1:p,xOf:f=>a.logicalToX(f),halfW:BP(a.bodySpacing()),bottomY:l.top+l.height,maxH:l.height*(c?jh:o.heightFrac),maxVol:m},{up:o.upColor,down:o.downColor}),t.restore());}};function ax(r,e){return e==null?r:r==null?{...e}:{candleBodyScale:qh(r.candleBodyScale,e.candleBodyScale),candleBodyAlpha:qh(r.candleBodyAlpha,e.candleBodyAlpha),gridAlpha:qh(r.gridAlpha,e.gridAlpha)}}function qh(r,e){return r==null?e:e==null?r:Math.min(r,e)}var Zh=new Map;function HP(r){Zh.set(r.id,r);}function zP(r){Zh.delete(r);}function Jh(){return [...Zh.values()]}function lx(r,e){let t=r.map(o=>({id:o.id,key:o.ownerZ??(o.placement==="below-data"?-1/0:e)}));t.sort((o,s)=>o.key-s.key);let n=[],i=[];for(let o of t)(o.key<e?n:i).push(o.id);return {below:n,above:i}}var cx='<svg viewBox="0 0 45 40" aria-hidden="true"><g fill="currentColor"><path d="m40.25 38 4.58-7.998L28.802 2l-16.03 28 9.16-.001 6.87-12z"/><path d="M34.525 32.002 9.33 31.997 27.655 0h-9.158L.18 31.993 4.759 40h34.347z"/></g></svg>',ux='<svg viewBox="0 0 964 252" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M 614 94.500 L 614 189 633.500 189 L 653 189 653 94.500 L 653 0 633.500 0 L 614 0 614 94.500 M 0 97.500 L 0 189 63.023 189 L 126.045 189 125.773 170.750 L 125.500 152.500 84.250 152.239 L 43 151.978 43 78.989 L 43 6 21.500 6 L 0 6 0 97.500 M 450.387 96.451 C 421.871 146.253, 398.306 186.994, 398.020 186.987 C 397.423 186.972, 362 124.724, 362 123.691 C 362 123.316, 370.100 108.818, 380 91.472 C 389.900 74.127, 398 59.500, 398 58.968 C 398 58.380, 391.007 58, 380.210 58 L 362.420 58 348.060 83.138 C 334.400 107.052, 333.637 108.160, 332.399 105.888 C 331.682 104.575, 325.287 93.375, 318.187 81 L 305.277 58.500 287.139 58.227 C 277.162 58.078, 269 58.186, 269 58.469 C 269 58.751, 277.154 73.274, 287.120 90.741 C 297.086 108.209, 305.261 122.983, 305.287 123.574 C 305.312 124.164, 297.318 138.789, 287.522 156.074 C 277.725 173.358, 269.524 187.838, 269.296 188.250 C 269.068 188.662, 276.977 189, 286.870 189 L 304.859 189 319.163 163.959 C 331.321 142.674, 333.647 139.165, 334.670 140.563 C 335.331 141.468, 341.864 152.737, 349.186 165.606 L 362.500 189.003 402.442 188.752 L 442.384 188.500 472.080 136.695 C 488.413 108.203, 501.939 84.729, 502.138 84.531 C 502.337 84.333, 516 107.757, 532.500 136.583 L 562.500 188.994 584.750 188.997 C 596.987 188.999, 607 188.854, 607 188.675 C 607 188.319, 503.014 6.686, 502.532 6.201 C 502.369 6.037, 478.904 46.649, 450.387 96.451 M 717.500 55.017 C 697.175 57.389, 680.641 68.752, 672.036 86.264 C 665.866 98.818, 663.840 108.024, 663.840 123.500 C 663.840 133.409, 664.328 138.355, 665.892 144.300 C 672.076 167.810, 689.191 184.757, 711.529 189.489 C 730.549 193.518, 747.264 189.540, 761.282 177.648 C 764.944 174.542, 768.178 172, 768.470 172 C 769.345 172, 769.030 185.018, 767.979 192.285 C 765.618 208.613, 755.148 218.672, 738.473 220.632 C 732.586 221.324, 723.136 219.599, 717.709 216.843 C 712.693 214.295, 706.636 207.946, 703.972 202.443 C 702.789 199.999, 701.749 198, 701.661 198.001 C 700.201 198.007, 665.596 205.071, 665.230 205.437 C 664.326 206.341, 669.156 218.313, 672.607 223.721 C 682.146 238.672, 700.008 248.257, 723.500 251.033 C 758.132 255.124, 788.930 241.875, 800.287 218 C 806.923 204.047, 807 203.001, 807 126.542 L 807 58 788.500 58 L 770 58 770 66.500 C 770 71.175, 769.641 75, 769.203 75 C 768.765 75, 766.627 73.142, 764.453 70.872 C 752.805 58.708, 735.614 52.903, 717.500 55.017 M 878.500 55.031 C 850.107 59.412, 830.755 75.064, 822.285 100.500 C 819.905 107.644, 819.614 110.051, 819.565 123 C 819.501 139.581, 820.786 145.825, 826.763 158 C 832.104 168.880, 842.842 179.424, 854.077 184.822 C 867.651 191.343, 873.132 192.462, 891.500 192.462 C 909.868 192.462, 915.349 191.343, 928.923 184.822 C 944.653 177.265, 956.667 162.306, 961.710 144 C 963.074 139.048, 963.481 134.047, 963.418 123 C 963.346 110.140, 963.038 107.595, 960.694 100.500 C 953.325 78.193, 936.695 62.854, 913.500 56.969 C 904.262 54.625, 887.240 53.682, 878.500 55.031 M 134.015 102.750 C 134.027 139.250, 134.310 148.689, 135.549 153.947 C 141.139 177.663, 159.815 193, 183.105 193 C 196.453 193, 210.163 186.171, 217.936 175.650 C 219.826 173.093, 221.738 171, 222.186 171 C 222.634 171, 223 175.050, 223 180 L 223 189 242.507 189 L 262.014 189 261.757 123.750 L 261.500 58.500 242.500 58.500 L 223.500 58.500 223 99.500 C 222.513 139.406, 222.441 140.610, 220.289 144.634 C 209.729 164.377, 183.014 164.880, 174.299 145.500 C 172.677 141.895, 172.469 137.382, 172.190 99.750 L 171.880 58 152.940 58 L 134 58 134.015 102.750 M 729.932 87.998 C 719.311 89.821, 710.155 97.164, 705.141 107.880 C 702.851 112.772, 702.510 114.798, 702.505 123.521 C 702.500 132.834, 702.732 134.014, 705.787 140.218 C 709.761 148.290, 715.989 154.097, 723.853 157.063 C 731.409 159.912, 744.359 159.466, 750.795 156.136 C 767.289 147.601, 774.103 127.713, 767.019 108.780 C 761.433 93.851, 746.051 85.232, 729.932 87.998 M 883.972 88.348 C 865.749 92.310, 854.873 109.966, 858.119 130.316 C 860.933 147.963, 872.346 158.830, 889.084 159.799 C 900.714 160.472, 906.867 158.234, 914.650 150.497 C 919.856 145.323, 921.123 143.340, 922.900 137.587 C 925.412 129.456, 925.655 118.570, 923.489 111.275 C 918.479 94.405, 901.478 84.541, 883.972 88.348"/></svg>';var $P="https://luxalgo.com/vela",dx="vela-attribution-styles",WP=`
|
|
970
|
+
`,tu=class{constructor(e){this.deps=e;this.pop=null;this.openKey=null;this.generation=0;this.pressKey=null;this.onPress=()=>{if(this.openKey===null)return;this.pressKey=this.openKey;let e=this.deps.plot.ownerDocument,t=()=>{setTimeout(()=>this.pressKey=null,0);};e.addEventListener("pointerup",t,{capture:true,once:true}),e.addEventListener("pointercancel",t,{capture:true,once:true});};let t=e.plot.ownerDocument;he(Uo,Yo,t),he(HP,zP,t),this.anchor=t.createElement("div"),this.anchor.className="vela-marks-anchor",Object.assign(this.anchor.style,{position:"absolute",pointerEvents:"none",left:"0",top:"0",width:"0",height:"0"}),e.plot.appendChild(this.anchor),t.addEventListener("pointerdown",this.onPress,true);}get key(){return this.openKey}open(e,t){if(this.pressKey===e.key)return;this.close(),this.place(t);let n=++this.generation;this.openKey=e.key,this.pop=new $e({trigger:this.anchor,host:this.deps.host(),theme:this.deps.theme(),gap:8,align:"center",fadeMs:120,className:"vela-marks-pop",content:i=>this.build(i,e,n),onClose:()=>{this.generation===n&&(this.openKey=null,this.pop=null,this.deps.onOpenChange?.(null));}}),this.pop.show(),this.deps.onOpenChange?.(e.key);}track(e){if(this.pop){if(!e){this.close();return}this.place(e),this.pop.reposition();}}close(){let e=this.pop,t=this.openKey!==null;this.pop=null,this.openKey=null,this.generation++,e?.destroy(),t&&this.deps.onOpenChange?.(null);}destroy(){this.close(),this.deps.plot.ownerDocument.removeEventListener("pointerdown",this.onPress,true),this.anchor.remove();}place(e){Object.assign(this.anchor.style,{left:`${e.x-e.size/2}px`,top:`${e.y-e.size/2}px`,width:`${e.size}px`,height:`${e.size}px`});}build(e,t,n){let i=e.ownerDocument,o=i.createElement("div");o.className="vela-callout-panel vela-marks-panel";let s=[];for(let a of t.marks){let l=i.createElement("section");if(l.className="vela-marks-section",a.title){let u=i.createElement("div");u.className="vela-callout-title",u.textContent=a.title,l.appendChild(u);}let c=a.content;if(typeof c=="function"){let u=i.createElement("div");u.className="vela-marks-loading",u.textContent="Loading\u2026",l.appendChild(u),s.push({el:l,resolve:()=>this.resolveLazy(c,u,n)});}else c!==void 0&&this.renderContent(l,c);l.childElementCount>0&&o.appendChild(l);}e.appendChild(o),s.length>0&&$P(o,s);}resolveLazy(e,t,n){let i;try{i=Promise.resolve(e());}catch(o){i=Promise.reject(o instanceof Error?o:new Error(String(o)));}i.then(o=>{if(n!==this.generation)return;let s=t.parentElement;s&&(t.remove(),this.renderContent(s,o),this.pop?.reposition());},()=>{n===this.generation&&(t.className="vela-marks-error",t.textContent="Couldn\u2019t load this entry.");});}renderContent(e,t){let n=e.ownerDocument;if(!(!t||typeof t!="object")){if("text"in t){let i=n.createElement("div");i.className="vela-callout-text",i.textContent=String(t.text),e.appendChild(i);return}if("html"in t){let i=n.createElement("div");i.className="vela-marks-html",i.appendChild(ax(String(t.html),n)),e.appendChild(i);return}if("panel"in t&&t.panel&&Array.isArray(t.panel.items)){let i=null;for(let o of t.panel.items)if(!(!o||typeof o!="object")){if(o.type==="button"){i||(i=n.createElement("div"),i.className="vela-callout-actions",e.appendChild(i));let s=n.createElement("button");s.type="button",s.className="vela-callout-btn"+(o.primary?" vela-callout-btn-primary":""),s.textContent=o.label,s.addEventListener("click",()=>{o.run(),o.close!==false&&this.close();}),i.appendChild(s);continue}if(i=null,o.type==="text"){let s=n.createElement("div");s.className="vela-callout-text",s.textContent=o.text,e.appendChild(s);}else if(o.type==="field"){let s=n.createElement("div");s.className="vela-marks-field";let a=n.createElement("span");a.className="vela-marks-field-label",a.textContent=o.label;let l=n.createElement("span");l.className="vela-marks-field-value",l.textContent=o.value,s.append(a,l),e.appendChild(s);}}}}}};function $P(r,e){if(typeof IntersectionObserver>"u"){for(let n of e)n.resolve();return}let t=new IntersectionObserver(n=>{for(let i of n){if(!i.isIntersecting)continue;let o=e.find(s=>s.el===i.target);o&&(t.unobserve(i.target),o.resolve());}},{root:r});for(let n of e)t.observe(n.el);}function lx(r,e){if(r.log&&r.min>0&&r.max>r.min){let i=Math.log(r.min),o=Math.log(r.max),s=(i+o)/2,a=(o-i)/2*e;return {min:Math.exp(s-a),max:Math.exp(s+a),log:true}}let t=(r.min+r.max)/2,n=(r.max-r.min)/2*e;return {min:t-n,max:t+n,log:r.log}}function cx(r,e,t){if(t<=0)return {...r};if(r.log&&r.min>0&&r.max>r.min){let i=Math.log(r.min),o=Math.log(r.max),s=(o-i)*e/t;return {min:Math.exp(i+s),max:Math.exp(o+s),log:true}}let n=(r.max-r.min)*e/t;return {min:r.min+n,max:r.max+n,log:r.log}}function ux(r,e,t=24){let{combinedTop:n,combinedHeight:i,combinedWeight:o,startBoundaryY:s}=r,a=Math.min(t,i/2),l=n+a,c=n+i-a,d=Math.max(l,Math.min(c,s+e))-n,h=i>0?o*(d/i):o/2;return {above:h,below:o-h}}function WP(r,e,t,n){let i=Math.max(t,r),o=Math.min(n,e);return o>i?{x:i,width:o-i}:null}function GP(r){return Math.ceil(r)-.5}var nu=class{constructor(){this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}destroy(){this.canvas=null,this.ctx=null;}render(e,t,n,i){let o=this.ctx,s=this.canvas;if(!o||!s)return;let a=t.dpr;o.setTransform(a,0,0,a,0,0),o.clearRect(0,0,s.width/a,s.height/a);let l=t.barCount;if(l===0)return;let c=t.visibleLogicalRange();Math.min(l-1,Math.ceil(c.to))<Math.max(0,Math.floor(c.from))||(this.drawHighlights(o,e,t),this.drawGrid(o,e,t,n,t.width,i));}drawHighlights(e,t,n){let i=t.sessionHighlightBands();if(i.length>0){let o=Math.max(0,n.logicalToX(-0.5)),s=Math.min(n.width,n.logicalToX(n.barCount-.5));this.drawHighlightSet(e,i,n,o,s,true);}this.drawHighlightSet(e,t.highlights,n,0,n.width,false);}drawHighlightSet(e,t,n,i,o,s){let a=l=>s?n.logicalToX(GP(n.timeToLogical(l))):n.timeToX(l);for(let l of t){let c=WP(a(l.from),a(l.to),i,o);c&&(e.fillStyle=l.color,e.fillRect(c.x,0,c.width,n.height));}}drawGrid(e,t,n,i,o,s){let a=t.orderedPanes(),{gridVert:l,gridHorz:c}=t.style,u=l.color??i.gridColor,d=c.color??i.gridColor;if(e.lineWidth=1,t.showGrid&&l.visible){e.globalAlpha=s,e.strokeStyle=u;let h=n.visibleTimeRange(),p=ds((h.from+h.to)/2,t.timezone);e.beginPath();for(let m of Oc(h.from,h.to,8,p)){let f=Math.round(n.timeToX(m.time))+.5;f<0||f>o||(e.moveTo(f,0),e.lineTo(f,n.height));}e.stroke();}for(let h of a)if(t.showGrid&&c.visible&&!h.collapsed){e.globalAlpha=s,e.strokeStyle=d;let p=kn(t,h);e.beginPath();for(let m of gs(h.scale,h.bounds.height,p,void 0,h.axisFormat)){let f=Math.round(n.priceToY(m.price,h.scale,h.bounds))+.5;f<h.bounds.top||f>h.bounds.top+h.bounds.height||(e.moveTo(0,f),e.lineTo(o,f));}e.stroke();}e.globalAlpha=1;}};function dx(r,e,t,n){let{i0:i,i1:o,xOf:s,halfW:a,bottomY:l,maxH:c,maxVol:u}=t;if(!(u<=0||c<=0)){r.globalAlpha=.5;for(let d=i;d<=o;d+=1){let h=e[d],p=h?.volume;if(h==null||p==null||!(p>0))continue;let m=Math.max(1,p/u*c);r.fillStyle=h.close>=h.open?n.up:n.down,r.fillRect(s(d)-a,l-m,a*2,m);}r.globalAlpha=1;}}var Jh=.96;function UP(r){return Math.max(.5,Math.floor(r*.7)/2)}var ru=class{constructor(){this.canvas=null;this.ctx=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}destroy(){this.canvas=null,this.ctx=null;}render(e){let t=this.ctx,n=this.canvas;if(!t||!n)return;let{bars:i,data:o,visible:s,coords:a,bounds:l,fillPane:c}=e,u=a.dpr;if(t.setTransform(u,0,0,u,0,0),t.clearRect(0,0,n.width/u,n.height/u),!o||!s||i.length===0||l.height<=0)return;let d=a.visibleLogicalRange(),h=Math.max(0,Math.floor(d.from)),p=Math.min(i.length-1,Math.ceil(d.to));if(h>p)return;let m=0;for(let f=h;f<=p;f+=1){let g=i[f]?.volume;g!=null&&g>m&&(m=g);}m<=0||(t.save(),t.beginPath(),t.rect(0,l.top,a.width,l.height),t.clip(),dx(t,i,{i0:h,i1:p,xOf:f=>a.logicalToX(f),halfW:UP(a.bodySpacing()),bottomY:l.top+l.height,maxH:l.height*(c?Jh:o.heightFrac),maxVol:m},{up:o.upColor,down:o.downColor}),t.restore());}};function hx(r,e){return e==null?r:r==null?{...e}:{candleBodyScale:Qh(r.candleBodyScale,e.candleBodyScale),candleBodyAlpha:Qh(r.candleBodyAlpha,e.candleBodyAlpha),gridAlpha:Qh(r.gridAlpha,e.gridAlpha)}}function Qh(r,e){return r==null?e:e==null?r:Math.min(r,e)}var ep=new Map;function YP(r){ep.set(r.id,r);}function KP(r){ep.delete(r);}function tp(){return [...ep.values()]}function px(r,e){let t=r.map(o=>({id:o.id,key:o.ownerZ??(o.placement==="below-data"?-1/0:e)}));t.sort((o,s)=>o.key-s.key);let n=[],i=[];for(let o of t)(o.key<e?n:i).push(o.id);return {below:n,above:i}}var mx='<svg viewBox="0 0 45 40" aria-hidden="true"><g fill="currentColor"><path d="m40.25 38 4.58-7.998L28.802 2l-16.03 28 9.16-.001 6.87-12z"/><path d="M34.525 32.002 9.33 31.997 27.655 0h-9.158L.18 31.993 4.759 40h34.347z"/></g></svg>',fx='<svg viewBox="0 0 964 252" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M 614 94.500 L 614 189 633.500 189 L 653 189 653 94.500 L 653 0 633.500 0 L 614 0 614 94.500 M 0 97.500 L 0 189 63.023 189 L 126.045 189 125.773 170.750 L 125.500 152.500 84.250 152.239 L 43 151.978 43 78.989 L 43 6 21.500 6 L 0 6 0 97.500 M 450.387 96.451 C 421.871 146.253, 398.306 186.994, 398.020 186.987 C 397.423 186.972, 362 124.724, 362 123.691 C 362 123.316, 370.100 108.818, 380 91.472 C 389.900 74.127, 398 59.500, 398 58.968 C 398 58.380, 391.007 58, 380.210 58 L 362.420 58 348.060 83.138 C 334.400 107.052, 333.637 108.160, 332.399 105.888 C 331.682 104.575, 325.287 93.375, 318.187 81 L 305.277 58.500 287.139 58.227 C 277.162 58.078, 269 58.186, 269 58.469 C 269 58.751, 277.154 73.274, 287.120 90.741 C 297.086 108.209, 305.261 122.983, 305.287 123.574 C 305.312 124.164, 297.318 138.789, 287.522 156.074 C 277.725 173.358, 269.524 187.838, 269.296 188.250 C 269.068 188.662, 276.977 189, 286.870 189 L 304.859 189 319.163 163.959 C 331.321 142.674, 333.647 139.165, 334.670 140.563 C 335.331 141.468, 341.864 152.737, 349.186 165.606 L 362.500 189.003 402.442 188.752 L 442.384 188.500 472.080 136.695 C 488.413 108.203, 501.939 84.729, 502.138 84.531 C 502.337 84.333, 516 107.757, 532.500 136.583 L 562.500 188.994 584.750 188.997 C 596.987 188.999, 607 188.854, 607 188.675 C 607 188.319, 503.014 6.686, 502.532 6.201 C 502.369 6.037, 478.904 46.649, 450.387 96.451 M 717.500 55.017 C 697.175 57.389, 680.641 68.752, 672.036 86.264 C 665.866 98.818, 663.840 108.024, 663.840 123.500 C 663.840 133.409, 664.328 138.355, 665.892 144.300 C 672.076 167.810, 689.191 184.757, 711.529 189.489 C 730.549 193.518, 747.264 189.540, 761.282 177.648 C 764.944 174.542, 768.178 172, 768.470 172 C 769.345 172, 769.030 185.018, 767.979 192.285 C 765.618 208.613, 755.148 218.672, 738.473 220.632 C 732.586 221.324, 723.136 219.599, 717.709 216.843 C 712.693 214.295, 706.636 207.946, 703.972 202.443 C 702.789 199.999, 701.749 198, 701.661 198.001 C 700.201 198.007, 665.596 205.071, 665.230 205.437 C 664.326 206.341, 669.156 218.313, 672.607 223.721 C 682.146 238.672, 700.008 248.257, 723.500 251.033 C 758.132 255.124, 788.930 241.875, 800.287 218 C 806.923 204.047, 807 203.001, 807 126.542 L 807 58 788.500 58 L 770 58 770 66.500 C 770 71.175, 769.641 75, 769.203 75 C 768.765 75, 766.627 73.142, 764.453 70.872 C 752.805 58.708, 735.614 52.903, 717.500 55.017 M 878.500 55.031 C 850.107 59.412, 830.755 75.064, 822.285 100.500 C 819.905 107.644, 819.614 110.051, 819.565 123 C 819.501 139.581, 820.786 145.825, 826.763 158 C 832.104 168.880, 842.842 179.424, 854.077 184.822 C 867.651 191.343, 873.132 192.462, 891.500 192.462 C 909.868 192.462, 915.349 191.343, 928.923 184.822 C 944.653 177.265, 956.667 162.306, 961.710 144 C 963.074 139.048, 963.481 134.047, 963.418 123 C 963.346 110.140, 963.038 107.595, 960.694 100.500 C 953.325 78.193, 936.695 62.854, 913.500 56.969 C 904.262 54.625, 887.240 53.682, 878.500 55.031 M 134.015 102.750 C 134.027 139.250, 134.310 148.689, 135.549 153.947 C 141.139 177.663, 159.815 193, 183.105 193 C 196.453 193, 210.163 186.171, 217.936 175.650 C 219.826 173.093, 221.738 171, 222.186 171 C 222.634 171, 223 175.050, 223 180 L 223 189 242.507 189 L 262.014 189 261.757 123.750 L 261.500 58.500 242.500 58.500 L 223.500 58.500 223 99.500 C 222.513 139.406, 222.441 140.610, 220.289 144.634 C 209.729 164.377, 183.014 164.880, 174.299 145.500 C 172.677 141.895, 172.469 137.382, 172.190 99.750 L 171.880 58 152.940 58 L 134 58 134.015 102.750 M 729.932 87.998 C 719.311 89.821, 710.155 97.164, 705.141 107.880 C 702.851 112.772, 702.510 114.798, 702.505 123.521 C 702.500 132.834, 702.732 134.014, 705.787 140.218 C 709.761 148.290, 715.989 154.097, 723.853 157.063 C 731.409 159.912, 744.359 159.466, 750.795 156.136 C 767.289 147.601, 774.103 127.713, 767.019 108.780 C 761.433 93.851, 746.051 85.232, 729.932 87.998 M 883.972 88.348 C 865.749 92.310, 854.873 109.966, 858.119 130.316 C 860.933 147.963, 872.346 158.830, 889.084 159.799 C 900.714 160.472, 906.867 158.234, 914.650 150.497 C 919.856 145.323, 921.123 143.340, 922.900 137.587 C 925.412 129.456, 925.655 118.570, 923.489 111.275 C 918.479 94.405, 901.478 84.541, 883.972 88.348"/></svg>';var XP="https://luxalgo.com/vela",gx="vela-attribution-styles",jP=`
|
|
971
971
|
.vela-attribution {
|
|
972
972
|
text-decoration: none;
|
|
973
973
|
display: flex;
|
|
@@ -1028,5 +1028,5 @@ ${xr(".vela-sd-pane")}
|
|
|
1028
1028
|
[data-layout='mobile'] .vela-attribution .vela-attr-wordmark svg { height: 21px; }
|
|
1029
1029
|
[data-vela-layout='mobile'] .vela-attribution:hover .vela-attr-wordmark,
|
|
1030
1030
|
[data-layout='mobile'] .vela-attribution:hover .vela-attr-wordmark { transform: translateX(0); }
|
|
1031
|
-
`;function GP(r){let e=r.getElementById(dx);e||(e=r.createElement("style"),e.id=dx,r.head.appendChild(e)),e.textContent=WP;}function Qh(r){return lt(r)?"#ffffff":"#000000"}function ep(r,e){let t=lt(e);r.style.color=t?"#ffffff":"#000000",r.style.setProperty("--vela-attr-shadow",t?"rgba(0,0,0,0.45)":"rgba(255,255,255,0.55)");}function hx(r,e,t){let n=r.createElement("div");return n.className="vela-attribution-custom",Object.assign(n.style,{position:"absolute",zIndex:"6",pointerEvents:"auto",display:"flex",alignItems:"center",lineHeight:"1"}),n.style.color=Qh(t),n.innerHTML=e,n.dataset.velaScreenshot="1",n}function px(r,e){GP(r);let t=r.createElement("a");t.className="vela-attribution",t.href=$P,t.target="_blank",t.rel="noopener",t.title="Charting by Vela",t.setAttribute("aria-label","Charting by Vela"),Object.assign(t.style,{position:"absolute",zIndex:"6",pointerEvents:"auto",cursor:"pointer"}),ep(t,e),t.dataset.velaScreenshot="1";let n=r.createElement("span");n.className="vela-attr-symbol",n.setAttribute("aria-hidden","true"),n.innerHTML=cx;let i=r.createElement("span");return i.className="vela-attr-wordmark",i.innerHTML=ux,t.append(n,i),t}function tu(r){if(!r||r==="transparent")return false;let e=/rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*([\d.]+)\s*\)/.exec(r);return e?parseFloat(e[1])>.001:true}function mx(r,e,t){let n=r.borderTopLeftRadius,i=parseFloat(n)||0,o=n.endsWith("%")?i/100*Math.min(e,t):i;return Math.max(0,Math.min(o,Math.min(e,t)/2))}function tp(r,e,t,n,i,o){r.beginPath(),o>0&&typeof r.roundRect=="function"?r.roundRect(e,t,n,i,o):r.rect(e,t,n,i);}function UP(r){try{let e=r.ownerDocument.createElement("canvas");e.width=1,e.height=1;let t=e.getContext("2d");return t?(t.drawImage(r,0,0,1,1),e.toDataURL(),!0):!1}catch{return false}}function nu(r,e,t){let n=e.ownerDocument.defaultView;if(!n)return;r.save(),r.scale(t.dpr,t.dpr);let i=(c,u,d)=>{let h=c.textContent?.replace(/\s+/g," ").trim();if(!h)return;let p=c.ownerDocument.createRange();p.selectNodeContents(c);let m=p.getBoundingClientRect();m.width<=0||m.height<=0||(r.globalAlpha=d,r.fillStyle=u.color,r.font=`${u.fontStyle} ${u.fontWeight} ${u.fontSize} ${u.fontFamily}`,r.textBaseline="middle",r.textAlign="left",r.fillText(h,m.left-t.left,m.top-t.top+m.height/2));},o=(c,u,d)=>{if(!c.complete||c.naturalWidth<=0||!UP(c))return;let h=c.getBoundingClientRect();if(h.width<=0||h.height<=0)return;let p=h.left-t.left,m=h.top-t.top;r.save(),r.globalAlpha=d,tp(r,p,m,h.width,h.height,mx(u,h.width,h.height)),r.clip(),r.drawImage(c,p,m,h.width,h.height),r.restore();},s=(c,u)=>{for(let d of c.children){if(d.hasAttribute("transform"))continue;let h=d.tagName.toLowerCase();if(h==="g"){s(d,u);continue}let p=b=>parseFloat(d.getAttribute(b)??"0")||0,m=null;if(h==="path"){let b=d.getAttribute("d");b&&(m=new Path2D(b));}else if(h==="circle")m=new Path2D,m.arc(p("cx"),p("cy"),p("r"),0,Math.PI*2);else if(h==="ellipse")m=new Path2D,m.ellipse(p("cx"),p("cy"),p("rx"),p("ry"),0,0,Math.PI*2);else if(h==="rect")m=new Path2D,m.rect(p("x"),p("y"),p("width"),p("height"));else if(h==="line")m=new Path2D,m.moveTo(p("x1"),p("y1")),m.lineTo(p("x2"),p("y2"));else if(h==="polyline"||h==="polygon"){let b=(d.getAttribute("points")??"").trim().split(/[\s,]+/).map(Number);if(b.length<4||b.some(Number.isNaN))continue;m=new Path2D,m.moveTo(b[0],b[1]);for(let y=2;y+1<b.length;y+=2)m.lineTo(b[y],b[y+1]);h==="polygon"&&m.closePath();}if(!m)continue;let f=n.getComputedStyle(d);f.fill&&f.fill!=="none"&&tu(f.fill)&&(r.globalAlpha=u*(parseFloat(f.fillOpacity)||1),r.fillStyle=f.fill,r.fill(m));let g=parseFloat(f.strokeWidth)||0;f.stroke&&f.stroke!=="none"&&tu(f.stroke)&&g>0&&(r.globalAlpha=u*(parseFloat(f.strokeOpacity)||1),r.strokeStyle=f.stroke,r.lineWidth=g,(f.strokeLinecap==="round"||f.strokeLinecap==="square"||f.strokeLinecap==="butt")&&(r.lineCap=f.strokeLinecap),(f.strokeLinejoin==="round"||f.strokeLinejoin==="bevel"||f.strokeLinejoin==="miter")&&(r.lineJoin=f.strokeLinejoin),r.stroke(m));}},a=(c,u)=>{let d=c.getBoundingClientRect();if(d.width<=0||d.height<=0)return;let h=n.getComputedStyle(c);if(h.display==="none"||h.visibility==="hidden")return;let p=u*(parseFloat(h.opacity)||1);if(p<=.001)return;let m=c.viewBox.baseVal,f=m&&m.width>0?m.width:d.width,g=m&&m.height>0?m.height:d.height;r.save(),r.translate(d.left-t.left,d.top-t.top),r.scale(d.width/f,d.height/g),m&&r.translate(-m.x,-m.y),s(c,p),r.restore();},l=(c,u)=>{let d=n.getComputedStyle(c);if(d.display==="none"||d.visibility==="hidden")return;let h=u*(parseFloat(d.opacity)||1);if(h<=.001)return;let p=c.getBoundingClientRect();if(p.width>0&&p.height>0){let m=p.left-t.left,f=p.top-t.top,g=mx(d,p.width,p.height);tu(d.backgroundColor)&&(r.globalAlpha=h,r.fillStyle=d.backgroundColor,tp(r,m,f,p.width,p.height,g),r.fill());let b=parseFloat(d.borderTopWidth)||0;b>0&&d.borderTopStyle!=="none"&&tu(d.borderTopColor)&&(r.globalAlpha=h,r.strokeStyle=d.borderTopColor,r.lineWidth=b,tp(r,m+b/2,f+b/2,p.width-b,p.height-b,Math.max(0,g-b/2)),r.stroke());}for(let m of c.childNodes)m.nodeType===3?i(m,d,h):m instanceof n.HTMLImageElement?o(m,n.getComputedStyle(m),h):m instanceof n.SVGSVGElement?a(m,h):m instanceof n.HTMLElement&&l(m,h);};e instanceof n.HTMLElement&&l(e,1),r.restore();}function fx(r,e,t,n,i){let o=Math.max(0,e),s=Math.min(r.length-1,t);if(o>s)return null;let a=1/0,l=-1/0;for(let v=o;v<=s;v+=1){let S=r[v];S.volume!=null&&S.volume>0&&(S.low<a&&(a=S.low),S.high>l&&(l=S.high));}if(!Number.isFinite(a))return null;let c=l>a?Math.max(1,Math.round(n)):1,u=l>a?(l-a)/c:1,d=Array.from({length:c},(v,S)=>({price:a+S*u,up:0,down:0}));for(let v=o;v<=s;v+=1){let S=r[v],E=S.volume;if(!(E!=null&&E>0))continue;let T=S.close>=S.open?"up":"down",k=S.high-S.low;if(k<=0){let w=np(Math.floor((S.low-a)/u),c);d[w][T]+=E;continue}let x=np(Math.floor((S.low-a)/u),c),M=np(Math.floor((S.high-a)/u-1e-9),c);for(let w=x;w<=M;w+=1){let L=a+w*u,P=Math.min(S.high,L+u)-Math.max(S.low,L);P>0&&(d[w][T]+=E*P/k);}}let h=0,p=0,m=0;for(let v=0;v<c;v+=1){let S=d[v].up+d[v].down;h+=S,S>p&&(p=S,m=v);}if(p<=0)return null;let f=h*Math.min(1,Math.max(0,i)),g=m,b=m,y=p;for(;y<f&&(g>0||b<c-1);){let v=g>0?d[g-1].up+d[g-1].down:-1,S=b<c-1?d[b+1].up+d[b+1].down:-1;S>v?(b+=1,y+=S):(g-=1,y+=v);}return {rows:d,rowH:u,min:a,maxTotal:p,poc:m,vaFrom:g,vaTo:b}}function np(r,e){return r<0?0:r>=e?e-1:r}function gx(r,e,t,n){let{rows:i,rowH:o,maxTotal:s,poc:a,vaFrom:l,vaTo:c}=e,{rightX:u,maxW:d,yOf:h}=t;if(!(s<=0||d<=0)){for(let p=0;p<i.length;p+=1){let m=i[p],f=m.up+m.down;if(f<=0)continue;let g=h(m.price+o),b=Math.max(1,h(m.price)-g-1),y=f/s*d,v=m.up/f*y;r.globalAlpha=p>=l&&p<=c?.62:.28,v>0&&(r.fillStyle=n.upColor,r.fillRect(u-y,g,v,b)),y-v>0&&(r.fillStyle=n.downColor,r.fillRect(u-y+v,g,y-v,b));}if(n.showPoc){let p=i[a],m=h(p.price+o),f=Math.max(1,h(p.price)-m-1);r.globalAlpha=.9,r.strokeStyle=n.pocColor,r.lineWidth=1,r.strokeRect(u-d+.5,m+.5,d-1,f);}r.globalAlpha=1;}}var ru=class{constructor(){this.canvas=null;this.ctx=null;this.memoKey="";this.memo=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}destroy(){this.canvas=null,this.ctx=null,this.memoKey="",this.memo=null;}render(e){let t=this.ctx,n=this.canvas;if(!t||!n)return;let{bars:i,data:o,visible:s,coords:a,scale:l,bounds:c,theme:u}=e,d=a.dpr;if(t.setTransform(d,0,0,d,0,0),t.clearRect(0,0,n.width/d,n.height/d),!o||!s||i.length===0||c.height<=0)return;let h=a.visibleLogicalRange(),p=Math.max(0,Math.floor(h.from)),m=Math.min(i.length-1,Math.ceil(h.to));if(p>m)return;let f=i[m],g=`${p}:${m}:${i.length}:${f.high}:${f.low}:${f.close}:${f.volume??0}:${o.rows}:${o.valueAreaFrac}`;g!==this.memoKey&&(this.memoKey=g,this.memo=fx(i,p,m,o.rows,o.valueAreaFrac));let b=this.memo;b&&(t.save(),t.beginPath(),t.rect(0,c.top,a.width,c.height),t.clip(),gx(t,b,{rightX:a.width,maxW:a.width*o.widthFrac,yOf:y=>a.priceToY(y,l,c)},{upColor:o.upColor,downColor:o.downColor,showPoc:o.showPoc,pocColor:u.textColor}),t.restore());}};var He="price",qP=8,ZP="rgba(0,0,0,0)",iu=64,JP=56,Sx=26,Bi=22,Ts=26,rp=24,QP=5,eI="0 2px 8px rgba(0,0,0,0.4)",tI=12,Lx=12,Cx=iu+Lx,ip=Bi+14,nI=120,rI=2,Tx=6,kx=350,iI=.02,oI=220;function op(){return typeof performance<"u"?performance.now():Date.now()}var sI=.004,aI=.2,lI=4,ks=class{constructor(e){this.capabilities=my;this.surfaceBackground=Ut.background;this.surfaceTextColor=Ut.textColor;this.toolbarGutter=0;this.mountContainer=null;this.userDrawings=null;this.backdropRenderer=new Qc;this.volumeRenderer=new eu;this.extLayers=[];this.layerOrderSig="";this.attributionEl=null;this.attributionEnabled=true;this.attributionHtml=null;this.vpvrRenderer=new ru;this.resizeObserver=null;this.dprMedia=null;this.plotDeviceSize=null;this.coords=new vc;this.scene=new kc;this.backendMode="auto";this.glowAmount=0;this.chrome=new Oc;this.indicatorSlices=new qc;this.labelTooltip=null;this.markPopover=null;this.marksExpandedBy="hover";this.markPulseRaf=null;this.markClickCbs=new Set;this.crosshairLayer=new Fc;this.hostClock=null;this.ownClock=null;this.countdownUnsub=null;this.symbolPicker=null;this.indicatorTitlesOn=true;this.indicatorValuesOn=true;this.legendActionsProvider=null;this.legendCalloutsProvider=null;this.legendOverviewAction=null;this.keyboard=null;this.keyboardEnabled=true;this.historyChordsEnabled=true;this.liveRegion=null;this.animZoom=new Un(70);this.animPan=new Un(110);this.animScroll=new Un(130);this.animAutoscale=new Un(80);this.animLiveBar=new Un(90,0);this.candleUp=z;this.candleDown=W;this.intro={style:"settle",duration:650};this.introOnStyle="settle";this.introPlayed=false;this.introRaf=null;this.loadingEl=null;this.modelAlpha=1;this.targetBarSpacing=0;this.zoomAnchorLogical=0;this.zoomAnchorX=0;this.zoomAnchorMode="right";this.panVelocity=0;this.bars=[];this.didInitialFit=false;this.paintedData=false;this.skeletonClockMs=0;this.candleBodyAlpha=1;this.candleStructureAlpha=1;this.lastPointer=null;this.volumeActive=false;this.volumeHidden=false;this.vpvrActive=false;this.vpvrHidden=false;this.liveEaseTime=0;this.liveEaseHigh=0;this.liveEaseLow=0;this.liveEaseClose=0;this.axisDragEnabled=true;this.scaleDragHolder=null;this.scaleDragHeight=0;this.scaleDragStart=null;this.paneResizeEnabled=true;this.resizeAbove=null;this.resizeBelow=null;this.resizeSplitStart=null;this.hoverSeparatorY=null;this.maximizedPaneId=null;this.rightAxisW=iu;this.paneControls=null;this.axisScaleButtons=null;this.paneActionCbs=new Set;this.hoverLogical=null;this.settingsDialog=null;this.hiddenSettings=[];this.dialogHost=null;this.settingsButton=null;this.settingsEnabled=false;this.scrollButton=null;this.pointerNearScrollBtn=false;this.scrollTargetRO=null;this.scrollBtnBottomPx=ip;this.scrollBtnRightPx=Cx;this.layoutMode="desktop";this.viewportCbs=new Set;this.crosshairCbs=new Set;this.chartTypeSettingsCbs=new Set;this.configChangedCbs=new Set;this.themeSelectCbs=new Set;this.factoryConfig=null;this.hostSettingsSections=[];this.clickCbs=new Set;this.axisLongPressCbs=new Set;this.inputChangeCbs=new Set;this.removeIndicatorCbs=new Set;this.toggleVisibleCbs=new Set;this.moveIndicatorCbs=new Set;this.priceStyleCbs=new Set;this.name="native";this.features=["logScale","currentPriceLine","priceLabel","countdown","upColor","downColor","glow","animZoom","animPan","animScroll","animAutoscale","animLiveBar","intro","zoomAnchor","axisDrag","paneResize","candleZOrder","candleVisible","seriesOrder","highlights","sessionZones","gridlines","axisLabels","scaleMode","invertScale","paneScales","autoScale","timezone","keyboard","historyChords","priceStyle","priceBaseline","baselinePrice","settings","attribution","dialogHost","tradeMarkers","marks","indicatorTitles","indicatorValues"];this.onScrollProximityMove=e=>{if(!this.scrollButton||!this.plot)return;let t=this.plot.getBoundingClientRect(),n=t.width-this.scrollBtnRightPx-Ts/2,i=t.height-this.scrollBtnBottomPx-Ts/2,o=Math.hypot(e.clientX-t.left-n,e.clientY-t.top-i)<=nI;o!==this.pointerNearScrollBtn&&(this.pointerNearScrollBtn=o,this.updateScrollToRealtimeButton());};this.onScrollProximityLeave=()=>{this.pointerNearScrollBtn&&(this.pointerNearScrollBtn=false,this.updateScrollToRealtimeButton());};this.onDprChange=()=>{this.watchDpr(),this.resize();};this.externalCross=null;this.snapMode="off";e&&(this.scene.showPriceLine=e.currentPriceLine,this.scene.logScale=e.logScale,this.backendMode=e.nativeBackend,this.animZoom.set(e.animZoom),this.animPan.set(e.animPan),this.animScroll.set(e.animScroll),this.animAutoscale.set(e.animAutoscale),this.animLiveBar.set(e.animLiveBar),this.setIntro(e.animIntro),this.glowAmount=e.glow,this.candleUp=e.upColor,this.candleDown=e.downColor,this.scene.priceStyle=e.priceStyle,this.scene.basePainting=ch(e.priceStyle),this.scene.candleOverride=mc(e.priceStyle,this.scene.style.chartTypes)),this.theme=this.deriveTheme(Ut);}applyFeature(e,t){switch(e){case "logScale":if(t&&typeof t=="object"){let n=t;this.setPaneLog(n.pane??He,!!n.value);return}this.scene.logScale=!!t;break;case "currentPriceLine":this.scene.showPriceLine=!!t;break;case "priceLabel":this.scene.showPriceLabel=!!t;break;case "countdown":this.scene.showCountdown=!!t,this.syncCountdownTimer();break;case "upColor":this.candleUp=String(t),this.theme&&(this.theme=this.deriveTheme(this.theme));break;case "downColor":this.candleDown=String(t),this.theme&&(this.theme=this.deriveTheme(this.theme));break;case "glow":this.glowAmount=Number(t)||0,this.backend&&"glow"in this.backend&&(this.backend.glow=this.glowAmount);break;case "animZoom":this.animZoom.set(Vt(t,70));return;case "animPan":{let n=Vt(t,110);this.animPan.set(n),this.animScroll.toggle(n>0);return}case "animScroll":this.animScroll.set(Vt(t,130));return;case "animAutoscale":this.animAutoscale.set(Vt(t,80));return;case "animLiveBar":this.animLiveBar.set(wu(t));return;case "intro":{this.setIntro(xu(t)),this.intro.style&&this.playIntro();return}case "zoomAnchor":this.zoomAnchorMode=t==="right"?"right":"cursor",this.input&&(this.input.rightEdgeZoom=this.zoomAnchorMode==="right");return;case "axisDrag":this.axisDragEnabled=!!t,this.input&&(this.input.axisDrag=this.axisDragEnabled);return;case "paneResize":this.paneResizeEnabled=!!t,this.input&&(this.input.paneResize=this.paneResizeEnabled);return;case "candleZOrder":this.scene.candleZ=Number(t)||0;break;case "candleVisible":this.scene.candlesHidden=t===false;break;case "seriesOrder":this.applySeriesOrder(t);break;case "highlights":this.scene.highlights=hI(t);break;case "sessionZones":this.scene.sessionZones=pI(t);break;case "gridlines":this.scene.showGrid=!!t;break;case "axisLabels":this.scene.showAxisLabels=!!t;break;case "scaleMode":if(t&&typeof t=="object"){let n=t;this.setPaneScaleMode(n.pane??He,Ex(n.mode));return}this.scene.scaleMode=Ex(t);break;case "invertScale":if(t&&typeof t=="object"){let n=t;this.setPaneInvert(n.pane??He,!!n.value);return}this.scene.invertScale=!!t;break;case "autoScale":for(let n of this.scene.panes.values())n.manualScale=t?null:{...n.scale};break;case "timezone":this.scene.timezone=typeof t=="string"&&t?t:"UTC";break;case "priceStyle":this.setPriceStyle(mI(t)?t:"candles");break;case "priceBaseline":this.scene.baselineValue=t==null?null:Number(t);break;case "tradeMarkers":this.scene.tradeMarkers=_y(this.scene.tradeMarkers,t);break;case "marks":this.scene.marks=Uy(this.scene.marks,t),this.markPopover?.close();break;case "keyboard":this.setKeyboardEnabled(!!t);return;case "historyChords":this.historyChordsEnabled=!!t,this.userDrawings&&(this.userDrawings.historyChords=this.historyChordsEnabled);return;case "settings":this.setSettingsEnabled(!!t);return;case "indicatorTitles":this.indicatorTitlesOn=t!==false,this.inputsUI?.setTitlesVisible(this.indicatorTitlesOn);return;case "indicatorValues":this.indicatorValuesOn=t!==false,this.inputsUI?.setValuesVisible(this.indicatorValuesOn);return;case "attribution":this.attributionHtml=typeof t=="string"&&t.trim()?t:null,this.attributionEnabled=this.attributionHtml!==null||!!t,this.rebuildAttribution();return;case "dialogHost":this.dialogHost=t instanceof HTMLElement?t:null,this.settingsDialog?.close(),this.settingsDialog=null,this.inputsUI?.setDialogHost(this.dialogHost);return;default:return}this.scheduler?.invalidate(4);}readFeature(e){switch(e){case "logScale":return this.scene.logScale;case "currentPriceLine":return this.scene.showPriceLine;case "priceLabel":return this.scene.showPriceLabel;case "countdown":return this.scene.showCountdown;case "upColor":return this.candleUp;case "downColor":return this.candleDown;case "glow":return this.glowAmount;case "animZoom":return this.animZoom.tau;case "animPan":return this.animPan.tau;case "animScroll":return this.animScroll.tau;case "animAutoscale":return this.animAutoscale.tau;case "animLiveBar":return this.animLiveBar.tau;case "intro":return this.intro.style;case "zoomAnchor":return this.zoomAnchorMode;case "axisDrag":return this.input?this.input.axisDrag:this.axisDragEnabled;case "paneResize":return this.input?this.input.paneResize:this.paneResizeEnabled;case "candleZOrder":return this.scene.candleZ;case "candleVisible":return !this.scene.candlesHidden;case "seriesOrder":return this.scene.indicatorZOrder();case "highlights":return this.scene.highlights;case "sessionZones":return this.scene.sessionZones;case "gridlines":return this.scene.showGrid;case "axisLabels":return this.scene.showAxisLabels;case "scaleMode":return this.scene.scaleMode;case "invertScale":return this.scene.invertScale;case "paneScales":return this.paneScaleInfos();case "autoScale":{let t=this.scene.orderedPanes().find(n=>n.kind==="price");return t?t.manualScale==null:true}case "timezone":return this.scene.timezone;case "priceStyle":return this.scene.priceStyle;case "priceBaseline":return this.scene.baselineValue;case "baselinePrice":{let t=this.scene.panes.get(He);return t?this.scene.baselinePriceFor(t.scale):this.scene.baselineValue}case "tradeMarkers":return {...this.scene.tradeMarkers,colors:{...this.scene.tradeMarkers.colors}};case "marks":return {visible:this.scene.marks.visible,groups:{...this.scene.marks.groups}};case "keyboard":return this.keyboardEnabled;case "historyChords":return this.historyChordsEnabled;case "settings":return this.settingsEnabled;case "indicatorTitles":return this.indicatorTitlesOn;case "indicatorValues":return this.indicatorValuesOn;case "attribution":return this.attributionHtml??this.attributionEnabled;case "dialogHost":return this.dialogHost??void 0;default:return}}setNativeData(e,t){e==="volume"?(this.scene.volumeLayer=t??null,this.scheduler?.invalidate(3)):e==="vpvr"?(this.scene.vpvrLayer=t??null,this.scheduler?.invalidate(3)):e.endsWith("-pending")?(this.scene.nativePending.set(e.slice(0,-8),t??[]),this.scheduler?.invalidate(3)):(this.scene.nativeData.set(e,t),this.scheduler?.invalidate(3));}setIndicatorStatus(e,t){this.inputsUI.setStatus(e.id,t);}setLoading(e){if(!e||!this.wrapper){this.loadingEl?.remove(),this.loadingEl=null;return}if(this.loadingEl)return;let t=this.wrapper.ownerDocument,n=t.createElement("div");n.className="vela-loading",Object.assign(n.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",gap:"7px",pointerEvents:"none"});for(let i=0;i<3;i+=1){let o=t.createElement("span");Object.assign(o.style,{width:"7px",height:"7px",borderRadius:"50%",background:this.chromeTheme().textColor,opacity:"0.15"}),o.animate([{opacity:.12},{opacity:.55}],{duration:800,iterations:1/0,direction:"alternate",easing:"ease-in-out",delay:-i*260}),n.appendChild(o);}this.wrapper.appendChild(n),this.loadingEl=n;}setPricePrecision(e){let t=typeof e=="number"&&e>0?e:void 0;t!==this.scene.priceMintick&&(this.scene.priceMintick=t,this.scheduler?.invalidate(4));}getConfig(){let e=this.scene.style,t=Object.fromEntries(Object.entries(e.chartTypes).map(([i,o])=>[i,{...o}])),n=this.theme;return {version:lh,chartTypes:t,layout:{background:n.background,textColor:n.textColor,fontFamily:n.fontFamily,fontSize:e.fontSize},grid:{vertLines:{visible:e.gridVert.visible,color:e.gridVert.color??n.gridColor},horzLines:{visible:e.gridHorz.visible,color:e.gridHorz.color??n.gridColor}},crosshair:{color:e.crosshair.color??n.textColor,width:e.crosshair.width,style:e.crosshair.style,opacity:e.crosshair.opacity,labelBackground:e.crosshair.labelBackground??n.textColor},priceScale:{mode:this.scene.scaleMode,log:this.scene.logScale,invert:this.scene.invertScale,borderColor:e.borderColor??n.borderColor,labelsVisible:this.scene.showAxisLabels,currentPriceLine:this.scene.showPriceLine,priceLabel:this.scene.showPriceLabel,countdown:this.scene.showCountdown,animateLastPrice:this.animLiveBar.on},animations:{zoom:this.animZoom.on,pan:this.animPan.on,autoscale:this.animAutoscale.on,intro:this.intro.style!==false},panes:{separatorColor:e.separatorColor??n.borderColor},trades:{visible:this.scene.tradeMarkers.visible,labels:this.scene.tradeMarkers.labels,qty:this.scene.tradeMarkers.qty,longColor:this.scene.tradeMarkers.colors.long,shortColor:this.scene.tradeMarkers.colors.short,exitColor:this.scene.tradeMarkers.colors.exit},timeScale:{timezone:this.scene.timezone},marks:{visible:this.scene.marks.visible,groups:{...this.scene.marks.groups}},candles:{upColor:this.candleUp,downColor:this.candleDown,bodyVisible:e.candle.bodyVisible,borderVisible:e.candle.borderVisible,borderUpColor:e.candle.borderUpColor??this.candleUp,borderDownColor:e.candle.borderDownColor??this.candleDown,wickVisible:e.candle.wickVisible,wickUpColor:e.candle.wickUpColor??this.candleUp,wickDownColor:e.candle.wickDownColor??this.candleDown},bars:{upColor:e.bars.upColor??this.candleUp,downColor:e.bars.downColor??this.candleDown},line:{color:e.line.color??this.candleUp,width:e.line.width},stacking:{candles:this.scene.candleZ,series:Object.fromEntries(this.scene.indicatorZOrder().map(({id:i,z:o})=>[i,o]))},area:(()=>{let i=e.area.lineColor??this.candleUp;return {lineColor:i,width:e.area.width,topColor:e.area.topColor??i,bottomColor:e.area.bottomColor??ZP}})(),baseline:(()=>{let i=e.baseline.topLineColor??ki,o=e.baseline.bottomLineColor??Ei;return {topLineColor:i,bottomLineColor:o,topFillColor:e.baseline.topFillColor??q(i,Sn),topFillColor2:e.baseline.topFillColor2??q(i,Cn),bottomFillColor:e.baseline.bottomFillColor??q(o,Sn),bottomFillColor2:e.baseline.bottomFillColor2??q(o,Cn),width:e.baseline.width,baselineLevel:e.baseline.baselineLevel}})(),series:{style:this.scene.priceStyle,baseline:this.scene.baselineValue,spacing:this.coords.spacingScale},sessions:{premarketColor:e.sessions.premarketColor,postmarketColor:e.sessions.postmarketColor,extendedColor:e.sessions.extendedColor}}}applyConfig(e){let t=wy(this.getConfig(),e),n=this.scene.style;for(let[u,d]of Object.entries(t.chartTypes))if(JSON.stringify(n.chartTypes[u])!==JSON.stringify(d)){this.scene.nativeData.set(`${u}-settings`,{...d});for(let h of this.chartTypeSettingsCbs)h(u,{...d});}n.chartTypes=Object.fromEntries(Object.entries(t.chartTypes).map(([u,d])=>[u,{...d}]));let i=e&&typeof e=="object"?e.layout:void 0,o=i&&typeof i=="object"?i.textColor:void 0,s=typeof o=="string"&&o.trim().length>0,a=this.theme,l={textColor:t.layout.textColor,gridColor:a.gridColor,borderColor:a.borderColor};if(!s&<(t.layout.textColor)===lt(t.layout.background)){let u=lt(t.layout.background)?Ut:ao;l={textColor:u.textColor,gridColor:u.gridColor,borderColor:u.borderColor};}this.theme={...this.theme,background:t.layout.background,textColor:l.textColor,gridColor:l.gridColor,borderColor:l.borderColor,fontFamily:t.layout.fontFamily},n.fontSize=t.layout.fontSize;let c=(u,d,h)=>u===null&&d===h?null:d;n.gridVert={visible:t.grid.vertLines.visible,color:c(n.gridVert.color,t.grid.vertLines.color,a.gridColor)},n.gridHorz={visible:t.grid.horzLines.visible,color:c(n.gridHorz.color,t.grid.horzLines.color,a.gridColor)},n.crosshair={color:t.crosshair.color,width:t.crosshair.width,style:t.crosshair.style,opacity:t.crosshair.opacity,labelBackground:t.crosshair.labelBackground},this.scene.scaleMode=t.priceScale.mode,this.scene.logScale=t.priceScale.log,this.scene.invertScale=t.priceScale.invert,n.borderColor=c(n.borderColor,t.priceScale.borderColor,a.borderColor),this.scene.showAxisLabels=t.priceScale.labelsVisible,this.scene.showPriceLine=t.priceScale.currentPriceLine,this.scene.showPriceLabel=t.priceScale.priceLabel,this.scene.showCountdown=t.priceScale.countdown,this.syncCountdownTimer(),this.animLiveBar.toggle(t.priceScale.animateLastPrice),this.animZoom.toggle(t.animations.zoom),this.animPan.toggle(t.animations.pan),this.animScroll.toggle(t.animations.pan),this.animAutoscale.toggle(t.animations.autoscale),this.intro={style:t.animations.intro?this.introOnStyle:false,duration:this.intro.duration||650},n.separatorColor=c(n.separatorColor,t.panes.separatorColor,a.borderColor),this.scene.tradeMarkers={visible:t.trades.visible,labels:t.trades.labels,qty:t.trades.qty,colors:{long:t.trades.longColor,short:t.trades.shortColor,exit:t.trades.exitColor}},this.scene.timezone=t.timeScale.timezone,this.scene.marks={visible:t.marks.visible,groups:{...t.marks.groups}},this.candleUp=t.candles.upColor,this.candleDown=t.candles.downColor,n.candle={bodyVisible:t.candles.bodyVisible,borderVisible:t.candles.borderVisible,borderUpColor:t.candles.borderUpColor,borderDownColor:t.candles.borderDownColor,wickVisible:t.candles.wickVisible,wickUpColor:t.candles.wickUpColor,wickDownColor:t.candles.wickDownColor},this.scene.candleZ=t.stacking.candles;for(let[u,d]of Object.entries(t.stacking.series))this.scene.setIndicatorZ(u,d);n.bars={upColor:t.bars.upColor,downColor:t.bars.downColor},n.line={color:t.line.color,width:t.line.width},n.area={lineColor:t.area.lineColor,width:t.area.width,topColor:t.area.topColor,bottomColor:t.area.bottomColor},n.baseline={topLineColor:t.baseline.topLineColor,bottomLineColor:t.baseline.bottomLineColor,topFillColor:t.baseline.topFillColor,topFillColor2:t.baseline.topFillColor2,bottomFillColor:t.baseline.bottomFillColor,bottomFillColor2:t.baseline.bottomFillColor2,width:t.baseline.width,baselineLevel:t.baseline.baselineLevel},n.sessions={premarketColor:t.sessions.premarketColor,postmarketColor:t.sessions.postmarketColor,extendedColor:t.sessions.extendedColor},this.setPriceStyle(t.series.style),this.scene.candleOverride=mc(this.scene.priceStyle,n.chartTypes),this.scene.baselineValue=t.series.baseline,this.coords.setPitchScale(t.series.spacing),this.coords.setViewport(this.clampViewport(this.coords.getViewport().barSpacing,this.coords.getViewport().rightOffset)),this.targetBarSpacing=this.coords.getViewport().barSpacing,this.theme=this.deriveTheme(this.theme),this.wrapper&&(Re(this.wrapper,this.chromeTheme()),this.applyBackground()),this.inputsUI?.setTheme(this.theme),this.paneControls?.setTheme(this.theme),this.axisScaleButtons?.setTheme(this.theme),this.userDrawings?.setTheme(this.chromeTheme()),this.refreshScrollButtonTheme(),this.refreshAttributionColor(),this.scheduler?.invalidate(4);for(let u of this.configChangedCbs)u();}applySeriesOrder(e){if(!e||typeof e!="object")return;let t=e;typeof t.id=="string"&&(typeof t.z=="number"?this.scene.setIndicatorZ(t.id,t.z):t.to==="front"?this.scene.bringIndicatorToFront(t.id):t.to==="back"&&this.scene.sendIndicatorToBack(t.id));}setSettingsEnabled(e){this.settingsEnabled=e,e?(this.plot&&!this.settingsButton&&(this.settingsButton=this.makeSettingsButton(),this.plot.appendChild(this.settingsButton)),this.settingsButton&&(this.settingsButton.style.display="flex"),this.plot&&!this.settingsDialog&&(this.settingsDialog=new bs(this.dialogHost??this.plot,this.theme))):(this.settingsButton?.style.setProperty("display","none"),this.settingsDialog?.close());}makeSettingsButton(){let e=document.createElement("button");return e.type="button",e.title="Chart settings",e.innerHTML=ye("gear",14),Object.assign(e.style,{position:"absolute",bottom:`${Bi+10}px`,right:`${iu+10}px`,zIndex:"6",width:"26px",height:"26px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:"50%",border:`1px solid ${this.theme.borderColor}`,background:this.theme.background,color:this.theme.textColor,fontSize:"14px",lineHeight:"1",opacity:"0.75",pointerEvents:"auto",padding:"0"}),e.addEventListener("mouseenter",()=>e.style.opacity="1"),e.addEventListener("mouseleave",()=>e.style.opacity="0.75"),e.addEventListener("click",()=>this.toggleSettingsDialog()),e}openSettingsDialog(e){!this.settingsDialog&&this.plot&&(this.settingsDialog=new bs(this.dialogHost??this.plot,this.theme),this.settingsDialog.setLayoutMode(this.layoutMode)),this.toggleSettingsDialog(e);}syncThemeControl(){this.settingsDialog?.setThemeControl(lt(this.surfaceBackground)?"dark":"light",e=>{for(let t of this.themeSelectCbs)t(e);});}toggleSettingsDialog(e){if(this.settingsDialog){if(e!==void 0&&this.settingsDialog.isOpen()){this.settingsDialog.showSection(e);return}this.settingsDialog.setTheme(this.theme),this.settingsDialog.setHostSections(this.hostSettingsSections),this.settingsDialog.setMarkGroups(this.markGroupsInUse(),t=>Tc(this.scene.marks,t,this.scene.markGroups)),this.settingsDialog.setHiddenSettings(this.hiddenSettings),this.syncThemeControl(),this.settingsDialog.toggle(this.getConfig(),t=>this.applyConfig(t),t=>this.applyConfig(t),()=>{this.factoryConfig&&this.applyConfig(yy(this.factoryConfig)),this.settingsDialog?.close(),this.openSettingsDialog();},e);}}closeDialogs(){this.inputsUI?.closeOpenDialog(),this.settingsDialog?.close();}makeScrollToRealtimeButton(){let e=document.createElement("button");return e.type="button",e.title="Scroll to most recent bar (Alt+Shift+\u2192)",e.setAttribute("aria-label","Scroll to most recent bar"),e.innerHTML=this.scrollButtonIcon(),Object.assign(e.style,{position:"absolute",bottom:`${ip}px`,right:`${Cx}px`,zIndex:"6",width:`${Ts}px`,height:`${Ts}px`,boxSizing:"border-box",display:"none",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:`${QP}px`,border:`1px solid ${this.theme.borderColor}`,boxShadow:eI,background:this.scrollButtonSurface(),color:this.theme.textColor,lineHeight:"0",opacity:"0.85",pointerEvents:"auto",padding:"0"}),e.addEventListener("mouseenter",()=>e.style.opacity="1"),e.addEventListener("mouseleave",()=>e.style.opacity="0.85"),e.addEventListener("click",()=>this.scrollToRealtime()),e}scrollButtonIcon(){return ye("chevrons-right",tI)}scrollButtonSurface(){return q(this.theme.background,.5)}refreshScrollButtonTheme(){this.scrollButton&&(this.scrollButton.style.background=this.scrollButtonSurface(),this.scrollButton.style.color=this.theme.textColor,this.scrollButton.style.borderColor=this.theme.borderColor);}updateScrollToRealtimeButton(){let e=this.scrollButton;if(!e)return;let t=this.coords.barCount>0&&this.coords.getViewport().rightOffset<0;if(this.layoutMode==="mobile"){e.style.display=t?"flex":"none";return}e.style.display=t&&this.pointerNearScrollBtn?"flex":"none";}scrollToRealtime(){this.coords.barCount!==0&&this.glideRightOffset(Tx);}glideRightOffset(e){let t=this.coords.getViewport();if(!this.animScroll.on){this.applyViewport({barSpacing:t.barSpacing,rightOffset:e});return}this.panVelocity=0,this.targetBarSpacing=t.barSpacing,this.scrollTargetRO=e,this.animator.start();}screenshotCanvas(){if(!this.dataCanvas)return null;this.computeScales(),this.paintData();let e=document.createElement("canvas");e.width=this.dataCanvas.width,e.height=this.dataCanvas.height;let t=e.getContext("2d");if(!t)return null;t.fillStyle=this.theme.background,t.fillRect(0,0,e.width,e.height);let n=this.plot?.getBoundingClientRect(),i=n&&n.width>0?{left:n.left,top:n.top,dpr:e.width/n.width}:null,o=[...this.mountContainer?.querySelectorAll("[data-vela-screenshot]")??[]];if(i)for(let s of o)s.getAttribute("data-vela-screenshot")==="under"&&nu(t,s,i);for(let s of [...this.canvasPile(),this.chromeCanvas,this.drawingsCanvas])s&&s.width>0&&s.height>0&&t.drawImage(s,0,0);if(i){for(let s of this.plot?.querySelectorAll("[data-vela-pane]")??[])nu(t,s,i);for(let s of o)s.getAttribute("data-vela-screenshot")!=="under"&&nu(t,s,i);}return e}screenshot(){return this.screenshotCanvas()?.toDataURL("image/png")??null}playIntro(){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.introRaf=null;let{style:e,duration:t}=this.intro,n=this.bars,i=n.length;if(i===0||!e)return;this.computeScales();for(let a of this.scene.panes.values())a.scale={...a.scaleTarget};this.modelAlpha=0;let o=performance.now(),s=a=>{let l=Math.min(1,(a-o)/t);this.scene.bars=l>=1?n:n.map((c,u)=>this.revealCandle(c,u,l,i,e)),this.paintData(),l<1?this.introRaf=requestAnimationFrame(s):(this.scene.bars=n,this.fadeInModels());};this.introRaf=requestAnimationFrame(s);}fadeInModels(){let e=Math.min(kx,this.intro.duration||kx),t=performance.now(),n=i=>{this.modelAlpha=Math.min(1,(i-t)/e),this.paintData(),this.modelAlpha<1?this.introRaf=requestAnimationFrame(n):(this.modelAlpha=1,this.introRaf=null);};this.introRaf=requestAnimationFrame(n);}revealCandle(e,t,n,i,o){let a=Math.max(0,Math.min(1,(n-t/Math.max(1,i-1)*.55)/.44999999999999996)),l;if(o==="settle"){let d=a-1;l=1+(1.70158+1)*d*d*d+1.70158*d*d;}else {let u=1-a;l=1-u*u*u;}let c=e.open;return {...e,high:c+(e.high-c)*l,low:c+(e.low-c)*l,close:c+(e.close-c)*l}}deriveTheme(e){return {...e,upColor:this.candleUp,downColor:this.candleDown}}chromeTheme(){return {...this.theme,background:this.surfaceBackground,textColor:this.surfaceTextColor,borderColor:lt(this.surfaceBackground)?Ut.borderColor:ao.borderColor}}axisSurface(){return {background:this.theme.background,textColor:this.theme.textColor}}mount(e,t){this.mountContainer=e,this.publishGutters(),this.theme=this.deriveTheme(t),this.surfaceBackground=t.background,this.surfaceTextColor=t.textColor,this.wrapper=document.createElement("div"),Object.assign(this.wrapper.style,{position:"relative",width:"100%",height:"100%",overflow:"hidden",cursor:"crosshair",userSelect:"none",webkitUserSelect:"none"}),Re(this.wrapper,this.chromeTheme()),this.backdropCanvas=document.createElement("canvas"),Object.assign(this.backdropCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.volumeCanvas=document.createElement("canvas"),Object.assign(this.volumeCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.dataCanvas=this.createGeometryBackend(),this.vpvrCanvas=document.createElement("canvas"),Object.assign(this.vpvrCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.chromeCanvas=document.createElement("canvas"),Object.assign(this.chromeCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.drawingsCanvas=document.createElement("canvas"),Object.assign(this.drawingsCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.cursorCanvas=document.createElement("canvas"),Object.assign(this.cursorCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.overlayRoot=document.createElement("div"),Object.assign(this.overlayRoot.style,{position:"absolute",inset:"0",pointerEvents:"none"}),this.plot=document.createElement("div"),Object.assign(this.plot.style,{position:"absolute",top:"0",right:"0",bottom:"0",left:"0"}),this.extLayers=Jh().map(o=>{let s=document.createElement("canvas");return Object.assign(s.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),{def:o,instance:o.create(),canvas:s}});let n=this.extLayers.filter(o=>o.def.placement==="below-data").map(o=>o.canvas),i=this.extLayers.filter(o=>o.def.placement!=="below-data").map(o=>o.canvas);this.plot.append(this.backdropCanvas,...n,this.dataCanvas,this.volumeCanvas,this.vpvrCanvas,...i,this.chromeCanvas,this.drawingsCanvas,this.cursorCanvas,this.overlayRoot),this.layerOrderSig="",this.wrapper.appendChild(this.plot),this.factoryConfig=this.getConfig(),this.attributionEl=this.buildAttributionEl(),this.attributionEnabled||(this.attributionEl.style.display="none"),this.positionAttribution(),this.wrapper.appendChild(this.attributionEl),e.appendChild(this.wrapper),this.applyBackground(),this.backdropRenderer.mount(this.backdropCanvas),this.volumeRenderer.mount(this.volumeCanvas),this.vpvrRenderer.mount(this.vpvrCanvas);for(let o of this.extLayers)o.instance.mount(o.canvas);this.chrome.mount(this.chromeCanvas),this.crosshairLayer.mount(this.cursorCanvas),this.coords.setViewport(ls()),this.scene.ensurePane(He,"price",0,3),this.scheduler=new yc(o=>this.renderFrame(o)),this.animator=new wc(o=>this.animTick(o)),this.targetBarSpacing=this.coords.getViewport().barSpacing,this.input=new xc({getCoords:()=>this.coords,apply:o=>this.applyViewport(o),zoomTo:(o,s,a)=>this.zoomTo(o,s,a),fling:o=>this.fling(o),onPointerMove:(o,s)=>this.handlePointerMove(o,s),onClick:(o,s)=>{this.handleMarkClick(o,s)||(this.userDrawings?.deselect(),this.handleClick(o));},onAxisLongPress:(o,s,a)=>{for(let l of this.axisLongPressCbs)l({axis:o,x:s,y:a});},beginPriceScale:(o,s)=>this.beginPriceScale(o,s),priceScaleBy:o=>this.priceScaleBy(o),beginPricePan:o=>this.beginPricePan(o),pricePanBy:o=>this.pricePanBy(o),resetPriceScale:(o,s)=>this.resetPriceScale(o,s),dataDblClick:(o,s)=>this.dataDblClick(o,s),paneSeparatorAt:o=>this.paneSeparatorAt(o),beginPaneResize:o=>this.beginPaneResize(o),paneResizeBy:o=>this.paneResizeBy(o),resetPaneSize:o=>this.resetPaneSize(o),resetView:()=>this.resetView(),drawingsClaim:(o,s)=>this.userDrawings?.claim(o,s)??false,drawingsMeasureStart:(o,s,a)=>this.userDrawings?.beginMeasureAt(o,s,a)??false,drawingsMarqueeStart:(o,s)=>this.userDrawings?.beginMarqueeAt(o,s)??false,drawingsDeleteAt:(o,s)=>this.userDrawings?.deleteAt(o,s,true)??false,drawingsCancelPlacement:()=>this.userDrawings?.cancelPlacement()??false,drawingsSnapMode:()=>this.snapMode,drawingsPointerDown:(o,s,a,l,c)=>this.userDrawings?.pointerDown(o,s,a,l,c),drawingsPointerMove:(o,s,a,l,c)=>this.userDrawings?.pointerMove(o,s,a,l,c),drawingsPointerUp:(o,s,a)=>this.userDrawings?.pointerUp(o,s,a),drawingsCursor:(o,s)=>this.userDrawings?.cursorAt(o,s)??(this.chrome.markGlyphAt(o,s)?"pointer":null),drawingsDblClick:(o,s)=>this.userDrawings?.dblClick(o,s)??false,drawingsClearTransient:()=>this.userDrawings?.clearTransient()}),this.input.rightEdgeZoom=this.zoomAnchorMode==="right",this.input.axisDrag=this.axisDragEnabled,this.input.paneResize=this.paneResizeEnabled,this.input.attach(this.dataCanvas),this.settingsEnabled&&this.setSettingsEnabled(true),this.syncCountdownTimer(),this.scrollButton=this.makeScrollToRealtimeButton(),this.plot.appendChild(this.scrollButton),this.plot.addEventListener("pointermove",this.onScrollProximityMove),this.plot.addEventListener("pointerleave",this.onScrollProximityLeave),this.labelTooltip=new Nc(this.plot,{theme:()=>this.chromeTheme(),lookup:(o,s)=>this.indicatorSlices.labelTooltipAt(o,s)??this.chrome.markTooltipAt(o,s,this.markGroupsInUse())}),this.markPopover=new Jc({plot:this.plot,host:()=>this.dialogHost??this.plot,theme:()=>this.chromeTheme(),onOpenChange:o=>{this.scene.marksActiveKey=o,this.scheduler?.invalidate(2);}}),this.chrome.setMarkIconReady(()=>this.scheduler?.invalidate(2)),this.userDrawings=new Xc(this.wrapper,this.plot,this.drawingsCanvas,{projector:()=>this.drawingProjector(),dpr:()=>this.coords.dpr,theme:()=>this.theme,requestScaleUpdate:()=>this.scheduler.invalidate(3),seriesBoundaries:o=>this.scene.seriesBoundaries(o),priceZ:o=>o===He?this.scene.candleZ:null,requestDataPaint:()=>this.scheduler.invalidate(3),seriesLook:()=>{let o=this.scene.style,s=Mi(o.candle,this.scene.candleOverride,this.theme.upColor,this.theme.downColor),a=o.bars.upColor??this.theme.upColor,l=o.bars.downColor??this.theme.downColor,c=this.scene.priceStyle;return {style:c,upColor:c==="bars"?a:s.up,downColor:c==="bars"?l:s.down,lineColor:c==="area"?o.area.lineColor??this.theme.upColor:o.line.color??this.theme.upColor}},chartBarMs:()=>this.coords.barInterval,snap:(o,s,a,l)=>this.snapToCandle(o,s,a,l),setSnapMode:o=>this.setSnapMode(o),setToolbarGutter:o=>this.setToolbarGutter(o)}),this.userDrawings.historyChords=this.historyChordsEnabled,this.layoutMode==="mobile"&&(this.mountContainer?.setAttribute("data-vela-layout",this.layoutMode),this.userDrawings.setLayoutMode(this.layoutMode),this.scrollButton&&(this.scrollButton.style.width=`${rp}px`,this.scrollButton.style.height=`${rp}px`)),this.keyboard=new Sc({panByBars:o=>this.panByBars(o),zoomByStep:o=>this.zoomByStep(o),stepCrosshair:o=>this.stepCrosshair(o),jumpToEdge:o=>this.focusBar(o==="first"?0:this.coords.barCount-1),resetView:()=>this.resetView(),scrollToRealtime:()=>this.scrollToRealtime(),clearCrosshair:()=>this.handlePointerMove(null,null),preempt:o=>this.userDrawings?.handleKey(o)??false}),this.setKeyboardEnabled(this.keyboardEnabled),this.inputsUI=new cc(this.plot,t,o=>this.paneBoundsFor(o)),this.inputsUI.setLayoutMode(this.layoutMode),this.inputsUI.setTitlesVisible(this.indicatorTitlesOn),this.inputsUI.setValuesVisible(this.indicatorValuesOn),this.inputsUI.setDialogHost(this.dialogHost),this.inputsUI.setSymbolPicker(this.symbolPicker),this.inputsUI.setLegendActions(this.legendActionsProvider),this.inputsUI.setLegendCallouts(this.legendCalloutsProvider),this.inputsUI.setLegendOverviewAction(this.legendOverviewAction),this.inputsUI.setOnChange(o=>{for(let s of this.inputChangeCbs)s({indicatorId:o.indicatorId,key:o.key,value:o.value,...o.kind?{kind:o.kind}:{}});}),this.inputsUI.setOnRemove(o=>{for(let s of this.removeIndicatorCbs)s(o);}),this.inputsUI.setOnToggleVisible((o,s)=>{for(let a of this.toggleVisibleCbs)a(o,s);}),this.inputsUI.setMoveApi({panes:()=>this.scene.orderedPanes().map((o,s)=>({id:o.id,kind:o.kind,label:o.kind==="price"?"Main chart":this.paneMasterTitle(o.id)??`Pane ${s}`,top:o.bounds.top,height:o.bounds.height})),move:(o,s)=>{for(let a of this.moveIndicatorCbs)a(o,s);}}),this.paneControls=new uc(this.plot,t,{panes:()=>this.paneControlViews(),rightAxis:()=>this.rightAxisW,onMove:(o,s)=>this.movePaneLocal(o,s),onToggleCollapse:o=>{let s=this.scene.panes.get(o);if(!s)return;let a=!s.collapsed;s.collapsed=a,this.afterPaneLayoutChange(),this.emitPaneAction({type:"collapse",paneId:o,collapsed:a});},onToggleMaximize:o=>{let s=this.maximizedPaneId!==o;this.maximizedPaneId=s?o:null,this.afterPaneLayoutChange(),this.emitPaneAction({type:"maximize",paneId:o,maximized:s});}}),this.paneControls.setSuspended(this.layoutMode==="mobile"),this.axisScaleButtons=new dc(this.plot,t,{panes:()=>this.axisScaleViews(),rightAxis:()=>this.rightAxisW,onToggleAuto:o=>this.togglePaneAuto(o),onToggleLog:o=>{let s=this.scene.panes.get(o);s&&this.setPaneLog(o,!Ai(this.scene,s));}}),this.resizeObserver=new ResizeObserver(o=>{for(let s of o){if(s.target!==this.plot)continue;let a=s.devicePixelContentBoxSize?.[0];a&&(this.plotDeviceSize={width:a.inlineSize,height:a.blockSize});}this.resize();}),this.resizeObserver.observe(this.wrapper);try{this.resizeObserver.observe(this.plot,{box:"device-pixel-content-box"});}catch{}this.watchDpr(),this.syncSize();}makeDataCanvas(){let e=document.createElement("canvas");return Object.assign(e.style,{position:"absolute",inset:"0",width:"100%",height:"100%"}),e}createGeometryBackend(){if((this.backendMode==="auto"||this.backendMode==="webgl2")&&fy()){let n=this.makeDataCanvas(),i=new bc;if(i.glow=this.glowAmount,i.onNeedsRedraw=()=>this.scheduler?.invalidate(4),i.onContextFailed=()=>this.swapToCanvas2dFallback(),i.mount(n),i.ok)return this.backend=i,n;i.destroy();}let e=this.makeDataCanvas(),t=new cs;return t.mount(e),this.backend=t,e}swapToCanvas2dFallback(){if(this.backend.kind==="canvas2d")return;let e=this.dataCanvas;this.input?.detach(),this.backend.destroy();let t=this.makeDataCanvas(),n=new cs;n.mount(t),this.backend=n,e.replaceWith(t),this.dataCanvas=t,this.input?.attach(t),this.syncSize();}watchDpr(){typeof window.matchMedia=="function"&&(this.dprMedia?.removeEventListener("change",this.onDprChange),this.dprMedia=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.dprMedia.addEventListener("change",this.onDprChange,{once:true}));}setTheme(e){this.theme=this.deriveTheme(e),this.surfaceBackground=e.background,this.surfaceTextColor=e.textColor,this.wrapper&&Re(this.wrapper,this.chromeTheme()),this.applyBackground(),this.inputsUI.setTheme(e),this.paneControls?.setTheme(this.theme),this.axisScaleButtons?.setTheme(this.theme),this.settingsDialog?.refreshConfig(this.getConfig()),this.syncThemeControl(),this.settingsDialog?.setTheme(this.theme),this.settingsButton&&(this.settingsButton.style.background=this.theme.background,this.settingsButton.style.color=this.theme.textColor,this.settingsButton.style.borderColor=this.theme.borderColor),this.refreshScrollButtonTheme(),this.userDrawings?.setTheme(this.chromeTheme()),this.refreshAttributionColor(),this.scheduler.invalidate(4);}resize(){this.syncSize();}setWallClock(e){e!==this.hostClock&&(this.hostClock=e,this.countdownUnsub!=null&&(this.countdownUnsub(),this.countdownUnsub=null),this.syncCountdownTimer());}syncCountdownTimer(){if(this.scene.showCountdown){if(this.countdownUnsub==null){let e=this.hostClock??this.ownClock??(this.ownClock=new vo);this.countdownUnsub=e.onTick(()=>{this.scene.showCountdown&&this.scene.bars.length>0&&this.scheduler?.invalidate(2);});}}else this.countdownUnsub!=null&&(this.countdownUnsub(),this.countdownUnsub=null);}destroy(){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.loadingEl?.remove(),this.loadingEl=null,this.countdownUnsub!=null&&(this.countdownUnsub(),this.countdownUnsub=null),this.scheduler?.destroy(),this.animator?.stop(),this.input?.detach(),this.keyboard?.detach(),this.keyboard=null,this.liveRegion=null,this.inputsUI?.destroy(),this.paneControls?.destroy(),this.axisScaleButtons?.destroy(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.dprMedia?.removeEventListener("change",this.onDprChange),this.dprMedia=null,this.userDrawings?.destroy(),this.userDrawings=null,this.settingsDialog?.destroy(),this.settingsDialog=null,this.settingsButton?.remove(),this.settingsButton=null,this.plot?.removeEventListener("pointermove",this.onScrollProximityMove),this.plot?.removeEventListener("pointerleave",this.onScrollProximityLeave),this.labelTooltip?.destroy(),this.labelTooltip=null,this.markPopover?.destroy(),this.markPopover=null,this.chrome.setMarkIconReady(null),this.markPulseRaf!==null&&cancelAnimationFrame(this.markPulseRaf),this.markPulseRaf=null,this.scrollButton?.remove(),this.scrollButton=null;for(let e of this.extLayers)e.instance.destroy?.();this.extLayers=[],this.backdropRenderer.destroy(),this.volumeRenderer.destroy(),this.vpvrRenderer.destroy(),this.backend.destroy(),this.chrome.destroy(),this.crosshairLayer.destroy(),this.attributionEl?.remove(),this.attributionEl=null,this.mountContainer?.style.removeProperty("--vela-toolbar-gutter"),this.mountContainer?.style.removeProperty("--vela-scale-gutter"),this.mountContainer?.style.removeProperty("--vela-bottom-gutter"),this.mountContainer?.style.removeProperty("--vela-price-pane-top"),this.mountContainer?.style.removeProperty("--vela-price-pane-bottom"),this.mountContainer=null,this.wrapper?.remove();}setBars(e,t){this.introRaf!=null&&(cancelAnimationFrame(this.introRaf),this.introRaf=null,this.modelAlpha=1),this.liveEaseTime=0;let n=this.bars,i=n[0]?.time;this.bars=fI(e),this.scene.bars=this.bars,this.coords.setBars(this.bars.map(s=>s.time));for(let s of this.scene.indicators.values())this.refreshAnchorOffset(s);if(t?.preserveView===true&&i!=null&&this.bars.length>0){let s=this.bars[0].time,a=0;if(s!==i){let l=this.bars.findIndex(c=>c.time===i);if(l>0)a=l;else {let c=n.findIndex(u=>u.time===s);c>0&&(a=-c);}}a!==0&&(this.zoomAnchorLogical+=a,this.hoverLogical!=null&&(this.hoverLogical+=a));}let o=t?.preserveView===true&&this.didInitialFit;if(this.coords.width>0&&!o&&(this.didInitialFit?this.reframeKeepZoom():this.fitContent(),this.didInitialFit=true),!this.introPlayed&&this.bars.length>0&&(this.introPlayed=true,this.intro.style)){this.playIntro();return}this.scheduler.invalidate(4);}updateBar(e){let t=this.bars.length,n=this.bars[t-1];if(n&&e.time===n.time)this.bars[t-1]=e,!this.animLiveBar.on||this.liveEaseTime!==e.time?this.syncLiveEase(e):this.animator.start();else if(!n||e.time>n.time)this.bars.push(e),this.syncLiveEase(e),this.coords.barInterval>0?this.coords.appendBar(e.time):this.coords.setBars(this.bars.map(i=>i.time));else return;this.scene.bars=this.bars,this.scheduler.invalidate(4);}setIntro(e){this.intro=e,e.style&&(this.introOnStyle=e.style);}syncLiveEase(e){this.liveEaseTime=e.time,this.liveEaseHigh=e.high,this.liveEaseLow=e.low,this.liveEaseClose=e.close;}easeLiveBar(e){let t=this.bars[this.bars.length-1];if(!t||this.liveEaseTime!==t.time)return false;let n=Math.max(1e-9,Math.abs(t.close)*1e-6),i=this.animLiveBar.tau,o=vt(this.liveEaseHigh,t.high,e,i),s=vt(this.liveEaseLow,t.low,e,i),a=vt(this.liveEaseClose,t.close,e,i),l=Math.abs(o-t.high)>n||Math.abs(s-t.low)>n||Math.abs(a-t.close)>n;return this.liveEaseHigh=l?o:t.high,this.liveEaseLow=l?s:t.low,this.liveEaseClose=l?a:t.close,l}ensurePane(e){this.scene.ensurePane(e.id,e.kind,e.order,e.heightWeight??(e.kind==="price"?3:1)),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}removePane(e){e!==He&&(this.scene.removePane(e),this.maximizedPaneId===e&&(this.maximizedPaneId=null),this.refreshAxisWidth(),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}setIndicatorPane(e,t,n){let i=this.scene.indicators.get(e.id);i&&(i.paneId=t,i.ownScale=n?.ownScale===true,i.ownScale||this.scene.dropIndicatorScale(e.id),this.inputsUI.setPane(e.id,t),this.refreshAnchorOffset(i),this.refreshAxisWidth(),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}orderPanes(e){this.scene.orderPanes(e),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}setPaneCollapsed(e,t){let n=this.scene.panes.get(e);!n||n.collapsed===t||(n.collapsed=t,this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}setPaneMaximized(e){e!==null&&!this.scene.panes.has(e)&&(e=null),this.maximizedPaneId=e,this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}onPaneAction(e){return this.paneActionCbs.add(e),()=>this.paneActionCbs.delete(e)}emitPaneAction(e){for(let t of this.paneActionCbs)t(e);}onMoveIndicator(e){return this.moveIndicatorCbs.add(e),()=>this.moveIndicatorCbs.delete(e)}maxOwnScaleColumns(){let e=0;for(let t of this.scene.panes.values()){let n=this.scene.ownScaleIndicatorsForPane(t.id).length;n>e&&(e=n);}return e}refreshAxisWidth(){let e=iu+JP*this.maxOwnScaleColumns();return e===this.rightAxisW?false:(this.rightAxisW=e,this.publishGutters(),this.coords.width>0&&this.syncSize(),true)}refreshAnchorOffset(e){let t=e.anchorTime;if(t==null||this.bars.length===0){this.scene.setAnchorOffset(e.id,0);return}let n=this.bars[0].time;if(t===n){this.scene.setAnchorOffset(e.id,0);return}if(t<n){let a=cI(e,n);if(a==null){console.warn(`[vela] indicator "${e.id}" starts before the first bar with no series to align on \u2014 rendering unanchored`),this.scene.setAnchorOffset(e.id,0);return}this.scene.setAnchorOffset(e.id,-a);return}let i=0,o=this.bars.length-1,s=this.bars.length;for(;i<=o;){let a=i+o>>1;this.bars[a].time>=t?(s=a,o=a-1):i=a+1;}if(s>=this.bars.length||this.bars[s].time!==t){console.warn(`[vela] indicator "${e.id}" anchorTime matches no chart bar \u2014 rendering unanchored`),this.scene.setAnchorOffset(e.id,0);return}this.scene.setAnchorOffset(e.id,s);}mountIndicator(e){return this.scene.indicators.set(e.id,e),this.refreshAnchorOffset(e),e.native&&this.extLayers.some(t=>t.def.id===e.native.type)?this.scene.assignIndicatorZTop(e.id):this.scene.assignIndicatorZ(e.id),e.legend!==false&&this.inputsUI.upsert(e.id,e.shorttitle??e.title,e.inputs,e.inputValues,e.paneId,{native:!!e.native,...e.props?{props:e.props,propValues:e.propValues??{}}:{}}),e.native?.type==="volume"?(this.volumeActive=true,this.volumeHidden=false):e.native?.type==="vpvr"&&(this.vpvrActive=true,this.vpvrHidden=false),e.ownScale&&this.refreshAxisWidth(),this.paneControls?.refresh(),this.scheduler.invalidate(4),{id:e.id}}updateIndicator(e,t){let n=this.scene.indicators.get(e.id);if(n){if(t.kind==="value"&&t.anchorTime!==void 0){let i=t.anchorTime??void 0;i!==n.anchorTime&&(n.anchorTime=i,this.refreshAnchorOffset(n));}uI(n,t),this.scheduler.invalidate(3);}}removeIndicator(e){let t=this.scene.indicators.get(e.id)?.native?.type;t==="volume"?(this.volumeActive=false,this.volumeHidden=false,this.scene.volumeLayer=null):t==="vpvr"&&(this.vpvrActive=false,this.vpvrHidden=false,this.scene.vpvrLayer=null),this.scene.indicators.delete(e.id),this.scene.forgetIndicatorZ(e.id),this.scene.forgetAnchorOffset(e.id),this.scene.dropIndicatorScale(e.id),this.inputsUI.remove(e.id),this.refreshAxisWidth(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}setIndicatorInputs(e,t,n){this.inputsUI.setValues(e.id,t,n);}setSymbolPicker(e){this.symbolPicker=e,this.inputsUI?.setSymbolPicker(e);}setLegendActions(e){this.legendActionsProvider=e,this.inputsUI?.setLegendActions(e);}setLegendCallouts(e){this.legendCalloutsProvider=e,this.inputsUI?.setLegendCallouts(e);}setLegendOverviewAction(e){this.legendOverviewAction=e,this.inputsUI?.setLegendOverviewAction(e);}openIndicatorSettings(e){this.inputsUI?.openSettingsFor(e);}setIndicatorVisible(e,t){let n=this.scene.indicators.get(e.id)?.native?.type;if(n==="volume"||n==="vpvr"){n==="volume"?this.volumeHidden=!t:this.vpvrHidden=!t,this.inputsUI.setVisible(e.id,t),this.scheduler.invalidate(4);return}t||this.scene.indicators.delete(e.id),this.inputsUI.setVisible(e.id,t),this.scheduler.invalidate(4);}onInputChange(e){return this.inputChangeCbs.add(e),()=>this.inputChangeCbs.delete(e)}onToggleIndicatorVisible(e){return this.toggleVisibleCbs.add(e),()=>this.toggleVisibleCbs.delete(e)}onPriceStyleChange(e){return this.priceStyleCbs.add(e),()=>this.priceStyleCbs.delete(e)}setPriceStyle(e){if(e!==this.scene.priceStyle){this.scene.priceStyle=e,this.scene.basePainting=ch(e),this.scene.candleOverride=mc(e,this.scene.style.chartTypes);for(let t of this.priceStyleCbs)t(e);}}onRemoveIndicator(e){return this.removeIndicatorCbs.add(e),()=>this.removeIndicatorCbs.delete(e)}setLayoutMode(e){if(e!==this.layoutMode){if(this.layoutMode=e,this.mountContainer?.setAttribute("data-vela-layout",e),this.userDrawings?.setLayoutMode(e),this.settingsDialog?.setLayoutMode(e),this.inputsUI?.setLayoutMode(e),this.paneControls?.setSuspended(e==="mobile"),this.scrollButton){let t=e==="mobile"?rp:Ts;this.scrollButton.style.width=`${t}px`,this.scrollButton.style.height=`${t}px`;}this.updateScrollToRealtimeButton();}}setSettingsSections(e){this.hostSettingsSections=e,this.settingsDialog?.setHostSections(e);}setSettingsVisibility(e){this.hiddenSettings=[...e.hidden??[]],this.settingsDialog?.setHiddenSettings(this.hiddenSettings);}listSettingsIds(){return bw(this.hostSettingsSections,this.markGroupsInUse())}onChartTypeSettingsChange(e){return this.chartTypeSettingsCbs.add(e),()=>this.chartTypeSettingsCbs.delete(e)}onConfigChanged(e){return this.configChangedCbs.add(e),()=>this.configChangedCbs.delete(e)}onThemeSelect(e){return this.themeSelectCbs.add(e),()=>this.themeSelectCbs.delete(e)}onCrosshairMove(e){return this.crosshairCbs.add(e),()=>this.crosshairCbs.delete(e)}onClick(e){return this.clickCbs.add(e),()=>this.clickCbs.delete(e)}onAxisLongPress(e){return this.axisLongPressCbs.add(e),()=>this.axisLongPressCbs.delete(e)}setTimelineMarks(e,t){this.scene.timelineMarks=e,this.scene.markGroups=t,this.scene.marksExpandedStack=null,this.markPopover?.close(),this.scheduler?.invalidate(2);}onMarkClick(e){return this.markClickCbs.add(e),()=>this.markClickCbs.delete(e)}markGroupsInUse(){return cw(this.scene.timelineMarks,this.scene.markGroups)}onViewportChange(e){return this.viewportCbs.add(e),()=>this.viewportCbs.delete(e)}getVisibleRange(){let e=this.coords.barCount;if(e===0||this.coords.width===0)return null;let t=this.coords.visibleLogicalRange(),n=Math.max(0,Math.ceil(t.from)),i=Math.min(e-1,Math.floor(t.to));return i<n?null:{from:this.coords.logicalToTime(n),to:this.coords.logicalToTime(i)}}setVisibleRange(e){let t=this.coords.timeToLogical(e.from),n=this.coords.timeToLogical(e.to),i=Math.max(1e-6,n-t),o=nn(this.coords.width/(i*this.coords.spacingScale)),s=n-(this.coords.barCount-1);this.applyViewport({barSpacing:o,rightOffset:s});}panBy(e){if(this.coords.barCount===0||this.coords.width===0)return;let t=this.coords.getViewport(),n=this.coords.width/this.coords.pxPerBar(),i=this.scrollTargetRO??t.rightOffset;this.glideRightOffset(this.clampViewport(t.barSpacing,i+e*n).rightOffset);}applyViewport(e){this.animator.stop(),this.panVelocity=0,this.scrollTargetRO=null;let t=this.clampViewport(e.barSpacing,e.rightOffset);this.coords.setViewport(t),this.targetBarSpacing=t.barSpacing,this.scheduler.invalidate(4),this.emitViewportChange();}zoomTo(e,t,n){let i=this.clampViewport(e,this.coords.getViewport().rightOffset).barSpacing;if(this.zoomAnchorLogical=t,this.zoomAnchorX=n,this.panVelocity=0,this.scrollTargetRO=null,!this.animZoom.on){let o=this.clampViewport(i,this.anchoredRightOffset(i));this.coords.setViewport(o),this.targetBarSpacing=o.barSpacing,this.scheduler.invalidate(4),this.emitViewportChange();return}this.targetBarSpacing=i,this.animator.start();}fling(e){this.animPan.on&&(this.scrollTargetRO=null,this.panVelocity=e,this.animator.start());}anchoredRightOffset(e){let t=e*this.coords.spacingScale;return this.zoomAnchorLogical+(this.coords.width-this.zoomAnchorX)/t-(this.coords.barCount-1)}clampViewport(e,t){let n=this.coords.barCount,i=this.coords.width;if(n<=1||i<=0)return {barSpacing:nn(e),rightOffset:t};let o=Math.min(rI,n),s=this.coords.spacingScale,a=Math.min(1e3,i/(o*s)),l=Math.max(.5,Math.min(a,i/((n+Tx)*s))),c=Math.max(l,Math.min(a,e)),d=i/(c*s)-(o-1),h=o-n,p=Math.max(h,Math.min(d,t));return {barSpacing:c,rightOffset:p}}animTick(e){let t=this.coords.getViewport(),n=t.barSpacing,i=t.rightOffset,o=false,s=this.targetBarSpacing;Math.abs(n-s)>s*.001?(n=nn(vt(n,s,e,this.animZoom.tau)),i=this.anchoredRightOffset(n),o=true):n!==s&&(n=s,i=this.anchoredRightOffset(n));let a=iI/Math.max(1e-6,n*this.coords.spacingScale);if(Math.abs(this.panVelocity)>a){i+=this.panVelocity*e;let c=this.animPan.tau;this.panVelocity=c>0?this.panVelocity*Math.exp(-e/c):0,Math.abs(this.panVelocity)<=a?this.panVelocity=0:o=true;}if(this.scrollTargetRO!=null){let c=this.scrollTargetRO,u=vt(i,c,e,this.animScroll.tau);Math.abs(u-c)<.001?(i=c,this.scrollTargetRO=null):(i=u,o=true);}let l=this.clampViewport(n,i);return l.barSpacing!==n&&(this.targetBarSpacing=l.barSpacing),this.scrollTargetRO!=null&&l.rightOffset!==i&&(this.scrollTargetRO=l.rightOffset),this.coords.setViewport(l),this.computeScales(),this.easeScales(e)&&(o=true),this.easeLiveBar(e)&&(o=true),this.skeletonClockMs+=e,this.paintData(),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx()),this.updateLegendValues(),this.emitViewportChange(),o}easeScales(e){let t=false,n=this.animAutoscale.tau;for(let i of this.scene.panes.values()){let o=i.scaleTarget,s=i.scale;if(o.log&&s.min>0&&o.min>0){let u=Math.log(o.min),d=Math.log(o.max),h=Math.max(1e-9,Math.abs(d-u)),p=vt(Math.log(s.min),u,e,n),m=vt(Math.log(s.max),d,e,n);Math.abs(p-u)<=h*.001&&Math.abs(m-d)<=h*.001?i.scale={min:o.min,max:o.max,log:true}:(t=true,i.scale={min:Math.exp(p),max:Math.exp(m),log:true});continue}let a=Math.max(1e-9,Math.abs(o.max-o.min)),l=vt(s.min,o.min,e,n),c=vt(s.max,o.max,e,n);Math.abs(l-o.min)<=a*.001&&Math.abs(c-o.max)<=a*.001?(l=o.min,c=o.max):t=true,i.scale={min:l,max:c,log:o.log};}for(let i of this.scene.indicatorScales.values()){let o=i.scaleTarget,s=i.scale,a=Math.max(1e-9,Math.abs(o.max-o.min)),l=vt(s.min,o.min,e,n),c=vt(s.max,o.max,e,n);Math.abs(l-o.min)<=a*.001&&Math.abs(c-o.max)<=a*.001?(l=o.min,c=o.max):t=true,i.scale={min:l,max:c};}return t}emitViewportChange(){this.updateScrollToRealtimeButton();let e=this.getVisibleRange();if(e)for(let t of this.viewportCbs)t(e);}handlePointerMove(e,t){if(e===null||t===null||this.coords.barCount===0){this.scene.crosshair=null,this.hoverSeparatorY=null,this.lastPointer=null,this.marksExpandedBy==="hover"&&this.setMarksExpanded(null),this.setMarkHover(null),this.scheduler.invalidate(1),this.hoverLogical=null;let p={time:null,price:null,paneKind:null,values:new Map,ohlc:null};for(let m of this.crosshairCbs)m(p);return}let n=e>=0&&t>=0&&e<=this.coords.width&&t<=this.coords.height;this.scene.crosshair=n?{x:e,y:t}:null,this.lastPointer=n?{x:e,y:t}:null,this.hoverSeparatorY=e>=0&&t>=0&&t<=this.coords.height?this.separatorHoverY(t):null,this.scheduler.invalidate(1),this.setMarksExpanded(n?this.chrome.markStackAt(e,t):null),this.setMarkHover(n?this.chrome.markGlyphAt(e,t)?.cluster.key??null:null);let i=Math.round(this.coords.xToLogical(e)),o=i>=0&&i<this.coords.barCount,s=o?this.coords.logicalToTime(i):null,a=this.paneNodeAtY(t),l=n&&a?this.coords.yToPrice(t,a.scale,a.bounds):null,c=new Map;if(o)for(let p of this.scene.indicators.values()){let m=this.scene.offsetOf(p.id);for(let f of p.series)if(Fe(f)){let g=f.points[i-m]?.value;g!=null&&c.set(f.id,g);}}let u=o?this.bars[i]:void 0,d=u?{time:u.time,open:u.open,high:u.high,low:u.low,close:u.close,volume:u.volume}:null;this.hoverLogical=o?i:null;let h={time:s,price:l,paneKind:n&&a?a.kind:null,values:c,ohlc:d};for(let p of this.crosshairCbs)p(h);}handleClick(e){if(this.coords.barCount===0)return;let t=Math.round(this.coords.xToLogical(e)),n=t>=0&&t<this.coords.barCount;for(let i of this.clickCbs)i({time:n?this.coords.logicalToTime(t):null,price:null});}setMarksExpanded(e,t="hover"){if(this.scene.marksExpandedStack!==e){if(e===null&&this.markPopover?.key){let n=this.chrome.markGlyphByKey(this.markPopover.key);if(n&&n.stack===this.scene.marksExpandedStack)return}this.scene.marksExpandedStack=e,this.marksExpandedBy=t,this.scheduler?.invalidate(2);}}handleMarkClick(e,t){let n=this.chrome.markGlyphAt(e,t);if(!n)return this.scene.marksExpandedStack!==null&&this.chrome.markStackAt(e,t)===null&&this.setMarksExpanded(null),false;if(n.decked)return this.setMarksExpanded(n.stack,"tap"),true;let i=n.cluster.marks,o=i[0],s={id:o.id,ids:i.map(a=>a.id),time:o.time,...n.cluster.group!==void 0?{group:n.cluster.group}:{}};for(let a of this.markClickCbs)a(s);return i.some(a=>a.content!==void 0)?this.markPopover?.open(n.cluster,{x:n.x,y:n.y,size:n.size}):(this.scene.marksFlash={key:n.cluster.key,until:op()+oI},this.syncMarkPulse()),true}trackMarkPopover(){let e=this.markPopover?.key;if(!e)return;let t=this.chrome.markGlyphByKey(e);this.markPopover.track(t&&!(t.decked&&t.depth!==0)?{x:t.x,y:t.y,size:t.size}:null);}setMarkHover(e){this.scene.marksHoverKey!==e&&(this.scene.marksHoverKey=e,this.scene.marksHoverSince=op(),this.scheduler?.invalidate(2),this.syncMarkPulse());}syncMarkPulse(){if(this.markPulseRaf!==null||typeof requestAnimationFrame!="function")return;let e=()=>{this.markPulseRaf=null;let t=op();this.scene.marksFlash&&this.scene.marksFlash.until<=t&&(this.scene.marksFlash=null),this.scheduler?.invalidate(2),(this.scene.marksHoverKey!==null&&t-this.scene.marksHoverSince<Rc||this.scene.marksFlash!==null)&&(this.markPulseRaf=requestAnimationFrame(e));};this.markPulseRaf=requestAnimationFrame(e);}paneAtY(e){return this.paneNodeAtY(e)}paneNodeAtY(e){for(let t of this.scene.panes.values())if(e>=t.bounds.top&&e<=t.bounds.top+t.bounds.height)return t;return null}nearestPaneToY(e){let t=null,n=1/0;for(let i of this.scene.panes.values()){let o=e<i.bounds.top?i.bounds.top-e:e-(i.bounds.top+i.bounds.height);o<n&&(n=o,t=i);}return t}resolveScaleHolder(e,t){let n=this.paneNodeAtY(t);if(!n)return null;let i=this.coords.width,o=this.scene.ownScaleIndicatorsForPane(n.id);if(e>=i+64&&o.length>0){let s=Math.floor((e-i-64)/56),a=o[s];if(a)return {holder:this.scene.ensureIndicatorScale(a.id,n.scaleTarget),height:n.bounds.height}}return {holder:n,height:n.bounds.height}}beginPriceScale(e,t){let n=this.resolveScaleHolder(e,t);n&&(this.scaleDragHolder=n.holder,this.scaleDragHeight=n.height,this.scaleDragStart={...n.holder.scale},n.holder.manualScale={...n.holder.scale},this.axisScaleButtons?.reposition(),this.scheduler.invalidate(4));}priceScaleBy(e){let t=this.scaleDragHolder,n=this.scaleDragStart;!t||!n||this.setManualScale(t,rx(n,Math.exp(e*sI)));}beginPricePan(e){let t=this.paneNodeAtY(e);return !t||!t.manualScale?false:(this.scaleDragHolder=t,this.scaleDragHeight=t.bounds.height,this.scaleDragStart={...t.scale},true)}pricePanBy(e){let t=this.scaleDragHolder,n=this.scaleDragStart;!t||!n||this.setManualScale(t,ix(n,e,this.scaleDragHeight));}resetPriceScale(e,t){let n=this.resolveScaleHolder(e,t);n&&(n.holder.manualScale=null,this.axisScaleButtons?.reposition(),this.scheduler.invalidate(4));}dataDblClick(e,t){let n=this.paneNodeAtY(t)??this.nearestPaneToY(t);if(!n)return;let i=this.maximizedPaneId!==n.id;this.maximizedPaneId=i?n.id:null,this.afterPaneLayoutChange(),this.emitPaneAction({type:"maximize",paneId:n.id,maximized:i});}resetView(){this.fitContent(),this.scheduler.invalidate(4),this.emitViewportChange();}setManualScale(e,t){e.manualScale=t,e.scale={...t},e.scaleTarget={...t},e.initialized=true,this.scheduler.invalidate(4);}afterPaneLayoutChange(){this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}paneControlViews(){let e=this.scene.orderedPanes();return e.map((t,n)=>({id:t.id,kind:t.kind,collapsed:t.collapsed,maximized:this.maximizedPaneId===t.id,top:t.bounds.top,height:t.bounds.height,index:n,count:e.length}))}movePaneLocal(e,t){let n=this.scene.orderedPanes(),i=n.findIndex(l=>l.id===e);if(i<0)return;let o=t==="up"?i-1:i+1;if(o<1||o>=n.length)return;let s=n.map(l=>l.id),a=s[i];s[i]=s[o],s[o]=a,this.scene.orderPanes(s),this.afterPaneLayoutChange(),this.emitPaneAction({type:"move",paneId:e,dir:t});}paneSeparatorAt(e){return this.separatorPaneIndexAt(e)!==null}separatorHoverY(e){if(!this.paneResizeEnabled)return null;let t=this.separatorPaneIndexAt(e);return t===null?null:this.scene.orderedPanes()[t].bounds.top}separatorPaneIndexAt(e){let t=this.scene.orderedPanes();for(let n=1;n<t.length;n++)if(Math.abs(e-t[n].bounds.top)<=lI)return n;return null}beginPaneResize(e){let t=this.separatorPaneIndexAt(e);if(t===null)return;let n=this.scene.orderedPanes(),i=n[t-1],o=n[t];this.resizeAbove=i,this.resizeBelow=o,this.resizeSplitStart={combinedTop:i.bounds.top,combinedHeight:i.bounds.height+o.bounds.height,combinedWeight:i.heightWeight+o.heightWeight,startBoundaryY:o.bounds.top};}paneResizeBy(e){let t=this.resizeAbove,n=this.resizeBelow,i=this.resizeSplitStart;if(!t||!n||!i)return;let o=ox(i,e);t.heightWeight=o.above,n.heightWeight=o.below,this.layoutPanes(),this.scheduler.invalidate(4);}resetPaneSize(e){let t=this.separatorPaneIndexAt(e);if(t===null)return;let n=this.scene.orderedPanes(),i=n[t-1],o=n[t],s=(i.heightWeight+o.heightWeight)/2;i.heightWeight=s,o.heightWeight=s,this.layoutPanes(),this.scheduler.invalidate(4);}setKeyboardEnabled(e){this.keyboardEnabled=e,!(!this.dataCanvas||!this.keyboard)&&(e?(this.dataCanvas.tabIndex=0,this.dataCanvas.setAttribute("role","application"),this.dataCanvas.setAttribute("aria-label","Interactive price chart. Use Left/Right arrows to move between bars, Shift+Arrow to pan, plus/minus to zoom, Home/End to jump, 0 to reset."),!this.liveRegion&&this.wrapper&&(this.liveRegion=document.createElement("div"),this.liveRegion.setAttribute("aria-live","polite"),this.liveRegion.setAttribute("role","status"),Object.assign(this.liveRegion.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:"0"}),this.wrapper.appendChild(this.liveRegion)),this.keyboard.attach(this.dataCanvas)):(this.keyboard.detach(),this.dataCanvas.removeAttribute("tabindex"),this.dataCanvas.removeAttribute("role"),this.dataCanvas.removeAttribute("aria-label")));}panByBars(e){let t=this.coords.getViewport();this.applyViewport({barSpacing:t.barSpacing,rightOffset:t.rightOffset+e});}zoomByStep(e){let t=this.coords.getViewport(),n=nn(t.barSpacing*Math.exp(e*aI));this.zoomTo(n,this.coords.rightEdgeLogical,this.coords.width);}stepCrosshair(e){let t=this.coords.barCount;if(t===0)return;let n=this.hoverLogical??Math.min(t-1,Math.round(this.coords.xToLogical(this.coords.width)));this.focusBar(n+e);}focusBar(e){let t=this.coords.barCount;if(t===0)return;let n=Math.max(0,Math.min(t-1,e)),i=this.coords.getViewport(),o=2,s=this.coords.xToLogical(0),a=this.coords.xToLogical(this.coords.width),l=i.rightOffset;n<s+o?l-=s+o-n:n>a-o&&(l+=n-(a-o)),l!==i.rightOffset&&this.applyViewport({barSpacing:i.barSpacing,rightOffset:l});let c=this.scene.orderedPanes().find(d=>d.kind==="price")??this.scene.orderedPanes()[0]??null,u=this.scene.crosshair?.y??(c?c.bounds.top+c.bounds.height/2:this.coords.height/2);this.handlePointerMove(this.coords.logicalToX(n),u),this.announceBar(n);}announceBar(e){if(!this.liveRegion)return;let t=this.bars[e],n=this.dataWindowPricePane(),i=this.dataWindowOHLC(t,n),o=[];t&&o.push(dI(t.time,this.scene.timezone)),i&&o.push(`Open ${i.o}, High ${i.h}, Low ${i.l}, Close ${i.c}`);for(let s of this.dataWindowGroups(e,n))for(let a of s.rows)o.push(`${a.label} ${a.value}`);this.liveRegion.textContent=o.join(". ");}getDataWindowReadout(){let e=this.bars.length;if(e===0)return {date:"",time:"",ohlc:null,groups:[]};let t=this.hoverLogical!=null?this.hoverLogical:e-1,n=this.bars[t],i=this.dataWindowPricePane(),o=n?Px(n.time,this.scene.timezone):{date:"",time:""};return {date:o.date,time:o.time,ohlc:this.dataWindowOHLC(n,i),groups:this.dataWindowGroups(t,i)}}dataWindowPricePane(){return this.scene.orderedPanes().find(e=>e.kind==="price")??null}dataWindowFmt(e,t){return t?Ic(t.scale,t.bounds.height,e,this.scene.priceMintick):String(e)}dataWindowOHLC(e,t){return e?{o:this.dataWindowFmt(e.open,t),h:this.dataWindowFmt(e.high,t),l:this.dataWindowFmt(e.low,t),c:this.dataWindowFmt(e.close,t),vol:e.volume!=null?Mx(e.volume):void 0,up:e.close>=e.open}:null}dataWindowGroups(e,t){let n=[];for(let i of this.scene.indicators.values()){let o=this.dataWindowRowsFor(i,e,t);o.length&&n.push({name:i.title,rows:o});}return n}dataWindowRowsFor(e,t,n){if(e.native?.type==="volume")return this.volumeReadoutRows(e,t);let i=(e.paneId?this.scene.panes.get(e.paneId):null)??n,o=this.scene.offsetOf(e.id),s=[];for(let a of e.series){let l,c;if(a.kind==="candle"||a.kind==="bar")l=a.bars[t-o]?.close,c=a.style?.up??this.theme.upColor;else if(Fe(a)){if(a.visible===false)continue;l=a.points[t-o]?.value,c=a.points[t-o]?.color??a.style.color;}else continue;l==null||!Number.isFinite(l)||s.push({label:a.title||e.title,value:this.dataWindowFmt(l,i),color:c});}return s}volumeReadoutRows(e,t){if(this.volumeHidden)return [];let n=this.bars[t],i=n?.volume;if(n==null||i==null||!Number.isFinite(i))return [];let o=this.scene.volumeLayer,s=n.close>=n.open?o?.upColor??this.theme.upColor:o?.downColor??this.theme.downColor;return [{label:e.title,value:Mx(i),color:s}]}updateLegendValues(){if(!this.inputsUI)return;let e=this.bars.length,t=new Map;if(e>0){let n=this.hoverLogical!=null?this.hoverLogical:e-1,i=this.dataWindowPricePane();for(let o of this.scene.indicators.values())t.set(o.id,this.dataWindowRowsFor(o,n,i).map(s=>({value:s.value,color:s.color})));}this.inputsUI.setPlotValues(t);}renderFrame(e){this.animator.active||(mh(e)?(this.computeScales(),this.paintData()):Py(e)&&this.paintedData&&(this.chrome.prepare(this.scene,this.coords,this.theme),this.chrome.render(this.scene,this.coords,this.theme,this.axisSurface()),this.trackMarkPopover()),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx()),!mh(e)&&this.paintedData&&this.repaintCursorLayers(),this.updateLegendValues());}repaintCursorLayers(){let e=this.scene.panes.get(He);if(!e)return;let t=typeof performance<"u"?performance.now():Date.now();for(let n of this.extLayers){if(!n.def.repaintOnCursor)continue;let i=this.layerPane(n.def.id)??e;i.collapsed||(n.instance.render(this.extLayerArgs(n.def.id,i.scale,i.bounds,t)),this.animZoom.on&&n.instance.animating?.()&&this.animator.start());}}clearLayerCanvas(e){e.width===0||e.height===0||e.getContext("2d")?.clearRect(0,0,e.width,e.height);}extLayerArgs(e,t,n,i){return {bars:this.scene.bars,data:this.scene.nativeData.get(e),settings:this.scene.nativeData.get(`${e}-settings`)??{},pending:this.scene.nativePending.get(e)??[],coords:this.coords,scale:t,bounds:n,theme:this.theme,priceStyle:this.scene.priceStyle,nowMs:i,cursor:this.lastPointer}}paintData(){this.syncLayerCanvasOrder(),this.stampScaleInvert(),this.backend.modelAlpha=this.modelAlpha,this.backend.candleBodyAlpha=this.candleBodyAlpha,this.backend.candleStructureAlpha=this.candleStructureAlpha;let e=1,t=1;this.backend.candleBodyScale=t;let n=this.scene.panes.get(He);if(n){let a=this.nativeLayerPane("volume")??n;this.volumeRenderer.render({bars:this.scene.bars,data:this.scene.volumeLayer,visible:this.volumeActive&&!this.volumeHidden&&!a.collapsed,coords:this.coords,bounds:a.bounds,fillPane:a.kind!=="price"}),this.vpvrRenderer.render({bars:this.scene.bars,data:this.scene.vpvrLayer,visible:this.vpvrActive&&!this.vpvrHidden,coords:this.coords,scale:n.scale,bounds:n.bounds,theme:this.theme});let l=typeof performance<"u"?performance.now():Date.now(),c=null;for(let u of this.extLayers){let d=this.layerPane(u.def.id)??n;if(d.collapsed){this.clearLayerCanvas(u.canvas);continue}let h=this.extLayerArgs(u.def.id,d.scale,d.bounds,l);u.instance.render(h),d===n&&(c=ax(c,u.instance.modulateBase?.(h)??null)),this.animZoom.on&&u.instance.animating?.()&&this.animator.start();}c&&(c.candleBodyScale!=null&&(this.backend.candleBodyScale=sp(c.candleBodyScale)||.01),c.candleBodyAlpha!=null&&(this.backend.candleBodyAlpha=sp(c.candleBodyAlpha)*this.candleBodyAlpha),c.gridAlpha!=null&&(e=sp(c.gridAlpha)));}let i=this.bars.length-1,o=i>=0?this.bars[i]:void 0,s=!!o&&this.liveEaseTime===o.time&&(o.high!==this.liveEaseHigh||o.low!==this.liveEaseLow||o.close!==this.liveEaseClose);s&&o&&(this.bars[i]={...o,high:this.liveEaseHigh,low:this.liveEaseLow,close:this.liveEaseClose}),this.scene.drawingSlices=jw(this.indicatorSlices.prepare(this.scene,this.coords,this.theme,this.dataCanvas),this.userDrawings?.prepareSlices(this.scene.orderedPanes().map(a=>a.id))??new Map),this.backdropRenderer.render(this.scene,this.coords,this.theme,e),this.backend.render(this.scene,this.coords,this.theme),this.chrome.render(this.scene,this.coords,this.theme,this.axisSurface()),this.trackMarkPopover(),this.userDrawings?.render(),s&&o&&(this.bars[i]=o),this.paintedData=true;}drawingProjector(){return qw(this.coords,e=>{let t=this.scene.panes.get(e);return t?{scale:t.scale,bounds:t.bounds,collapsed:t.collapsed}:null},e=>this.paneNodeAtY(e)?.id??null,(e,t)=>this.barsInTimeRange(e,t),this.userDrawings?.seriesGateway?(e,t,n)=>this.userDrawings.seriesGateway.seriesInRange(e,t,n):void 0)}barsInTimeRange(e,t){let n=Math.min(e,t),i=Math.max(e,t),o=[];for(let s of this.bars)if(!(s.time<n)){if(s.time>i)break;o.push(s);}return o}get userDrawingsPort(){return this.userDrawings??void 0}focus(){this.dataCanvas?.focus({preventScroll:true});}setExternalCrosshair(e,t=null){let n=e==null?null:{time:e,price:t},i=this.externalCross;!n&&!i||n&&i&&i.time===n.time&&i.price===n.price||(this.externalCross=n,this.scheduler.invalidate(1));}externalCrossPx(){let e=this.externalCross;if(!e||this.coords.barCount===0)return null;let t=Math.floor(this.coords.timeToLogical(e.time));if(t<0||t>=this.coords.barCount)return null;let n=this.coords.logicalToX(t);if(!Number.isFinite(n)||n<0||n>this.coords.width)return null;let i=null;if(e.price!=null){let o=this.scene.orderedPanes().find(s=>s.kind==="price");o&&(i=this.coords.priceToY(e.price,o.scale,o.bounds),(!Number.isFinite(i)||i<o.bounds.top||i>o.bounds.top+o.bounds.height)&&(i=null));}return {x:n,y:i,time:this.coords.logicalToTime(t),price:i!=null?e.price:null}}setSnapMode(e){this.snapMode=e;}snapToCandle(e,t,n="strong",i){if(n==="off")return e;let o=this.bars.length;if(o===0)return e;let s=Math.max(0,Math.min(o-1,Math.round(this.coords.timeToLogical(e.time)))),a=this.bars[s];if(!a)return e;let l;if(t!==He)l={time:a.time,price:e.price};else {let c=a.open;for(let u of [a.high,a.low,a.close])Math.abs(u-e.price)<Math.abs(c-e.price)&&(c=u);l={time:a.time,price:c};}if(n==="weak"&&i){let c=this.drawingProjector(),u=c.yOf(l.price,t);if(Math.hypot(c.xOf(l.time)-i.x,(u??i.y)-i.y)>qP)return e}return l}computeScales(){let e=this.coords.barCount;if(e===0)return;let t=this.coords.visibleLogicalRange(),n=Math.max(0,Math.floor(t.from)),i=Math.min(e-1,Math.ceil(t.to));if(i<n)return;this.scene.percentBaseline=this.bars[n]?.close??0;let o=this.scene.orderedPanes(),s=o.find(l=>l.kind==="price")??null;this.chrome.prepare(this.scene,this.coords,this.theme);let a=this.animator.active;for(let l of o){if(l.manualScale){l.scaleTarget=l.manualScale,l.scale={...l.manualScale},l.initialized=true;continue}let u=this.scene.indicatorsForPane(l.id).filter(p=>p.ownScale!==true),d=this.chrome.paneDrawingsRange(u,this.scene,l===s,t);if(l===s){let p=ex(this.scene.indicators.values(),n,i,m=>this.scene.offsetOf(m));p&&(d=d?{min:Math.min(d.min,p.min),max:Math.max(d.max,p.max)}:p);}let h=l.kind==="price"&&!this.scene.candlesHidden;if(l.scaleTarget=Zc(u,this.bars,h,n,i,d,Ai(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=l.kind==="price"?this.bars[n]?.close??0:this.firstVisibleValue(u,n),l.axisFormat=void 0,l.axisBands=void 0,this.volumeOwnsPane(l,u)){let p=this.maxVisibleVolume(n,i);p>0&&(l.scaleTarget={min:0,max:p/jh},l.axisFormat="volume");}else if(this.layerNativesOwnPane(l,u)&&(l.scaleTarget=Zc([],this.bars,true,n,i,d,Ai(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=this.bars[n]?.close??0,u.every(p=>p.paneAxis!=null))){l.axisFormat="none";let p=u.find(m=>typeof m.paneAxis=="object");l.axisBands=p?p.paneAxis.bands:void 0;}if(l===s&&this.scene.tradeMarkers.visible&&l.bounds.height>0){let p=this.tradesScaleHints(t);if(p){let m=l.scaleTarget,f={...m,min:Math.min(m.min,p.min),max:Math.max(m.max,p.max)};l.scaleTarget=tx(f,l.bounds.height,p.abovePx,p.belowPx);}}(!a||!l.initialized)&&(l.scale={...l.scaleTarget},l.initialized=true);for(let p of this.scene.ownScaleIndicatorsForPane(l.id)){let m=this.scene.ensureIndicatorScale(p.id,l.scaleTarget);if(m.manualScale){m.scaleTarget=m.manualScale,m.scale={...m.manualScale},m.initialized=true;continue}let f=this.chrome.paneDrawingsRange([p],this.scene,false,t);m.scaleTarget=Zc([p],this.bars,false,n,i,f,false,g=>this.scene.offsetOf(g)),(!a||!m.initialized)&&(m.scale={...m.scaleTarget},m.initialized=true);}}}tradesScaleHints(e){let t=null,n={timeToLogical:i=>this.coords.timeToLogical(i),barAt:i=>{let o=this.bars[Math.round(i)];return o?{high:o.high,low:o.low}:null}};for(let i of this.scene.indicators.values()){if(!i.trades?.length)continue;let o=$y(i.trades,this.scene.tradeMarkers,n,e.from,e.to,this.scene.style.fontSize);o&&(t=t?{min:Math.min(t.min,o.min),max:Math.max(t.max,o.max),abovePx:Math.max(t.abovePx,o.abovePx),belowPx:Math.max(t.belowPx,o.belowPx)}:o);}return t}fitContent(){let e=this.coords.barCount,t=this.coords.width;if(e<=0||t<=0)return;this.animator?.stop(),this.panVelocity=0;for(let s of this.scene.panes.values())s.manualScale=null;for(let s of this.scene.indicatorScales.values())s.manualScale=null;let n=Math.min(e,200),i=6,o=this.clampViewport(t/((n+i)*this.coords.spacingScale),i);this.coords.setViewport(o),this.targetBarSpacing=o.barSpacing;}reframeKeepZoom(){this.animator?.stop(),this.panVelocity=0;for(let t of this.scene.panes.values())t.manualScale=null;for(let t of this.scene.indicatorScales.values())t.manualScale=null;let e={barSpacing:nn(this.coords.getViewport().barSpacing),rightOffset:ls().rightOffset};this.coords.setViewport(e),this.targetBarSpacing=e.barSpacing;}paneBoundsFor(e){let t=this.scene.panes.get(e);return {top:t?.bounds.top??0,height:t?.bounds.height??0,rightAxis:this.rightAxisW}}paneMasterTitle(e){let t=this.scene.orderedIndicatorsForPane(e);return (t.find(i=>i.ownScale!==true)??t[0])?.title||null}nativeLayerPane(e){for(let t of this.scene.indicators.values())if(t.native?.type===e)return this.scene.panes.get(t.paneId??He)??null;return null}layerOwner(e){for(let t of this.scene.indicators.values())if(t.native?.type===e)return t;return null}layerPane(e){let t=this.layerOwner(e),n=t?t.paneId??He:He;return this.scene.panes.get(n)??null}orderedLayerCanvases(){let e=new Map(this.extLayers.map(i=>[i.def.id,i.canvas])),{below:t,above:n}=lx(this.extLayers.map(i=>{let o=this.layerOwner(i.def.id);return {id:i.def.id,placement:i.def.placement==="below-data"?"below-data":"above-data",ownerZ:o?this.scene.zOf(o.id):null}}),this.scene.candleZ);return {below:t.map(i=>e.get(i)),above:n.map(i=>e.get(i))}}canvasPile(){let{below:e,above:t}=this.orderedLayerCanvases();return [this.backdropCanvas,...e,this.dataCanvas,this.volumeCanvas,this.vpvrCanvas,...t]}syncLayerCanvasOrder(){if(this.extLayers.length===0||!this.plot)return;let{below:e,above:t}=this.orderedLayerCanvases(),n=[...e.map(i=>this.extLayers.find(o=>o.canvas===i).def.id),"|",...t.map(i=>this.extLayers.find(o=>o.canvas===i).def.id)].join(",");if(n!==this.layerOrderSig){this.layerOrderSig=n;for(let i of e)this.plot.insertBefore(i,this.dataCanvas);for(let i of t)this.plot.insertBefore(i,this.chromeCanvas);}}volumeOwnsPane(e,t){return e.kind==="price"||!this.volumeActive||this.volumeHidden||!this.scene.volumeLayer||this.nativeLayerPane("volume")!==e?false:t.every(n=>n.native?.type==="volume")}layerNativesOwnPane(e,t){return e.kind==="price"||t.length===0?false:t.every(n=>n.series.length===0&&!!n.native&&this.extLayers.some(i=>i.def.id===n.native.type))}paneScaleInfos(){return this.scene.orderedPanes().map(e=>({id:e.id,kind:e.kind,top:e.bounds.top,height:e.bounds.height,mode:yh(this.scene,e),log:Ai(this.scene,e),invert:wh(this.scene,e)}))}axisScaleViews(){return this.scene.orderedPanes().map(e=>({id:e.id,top:e.bounds.top,height:e.bounds.height,collapsed:e.collapsed,auto:e.manualScale==null,log:Ai(this.scene,e)}))}togglePaneAuto(e){let t=this.scene.panes.get(e);t&&(t.manualScale=t.manualScale==null?{...t.scale}:null,this.scheduler?.invalidate(4));}setPaneScaleMode(e,t){if(e===He)this.scene.scaleMode=t;else {let n=this.scene.panes.get(e);if(!n)return;n.scaleMode=t;}this.scheduler?.invalidate(4);}setPaneLog(e,t){let n=e===He?this.scene.orderedPanes().find(i=>i.kind==="price"):this.scene.panes.get(e);if(e===He)this.scene.logScale=t;else {if(!n)return;n.logScale=t;}n?.manualScale&&(n.manualScale.log=t),this.scheduler?.invalidate(4);}setPaneInvert(e,t){if(e===He)this.scene.invertScale=t;else {let n=this.scene.panes.get(e);if(!n)return;n.invert=t;}this.scheduler?.invalidate(4);}stampScaleInvert(){for(let e of this.scene.panes.values()){let t=wh(this.scene,e);e.scale.invert=t,e.scaleTarget.invert=t,e.manualScale&&(e.manualScale.invert=t);for(let n of this.scene.ownScaleIndicatorsForPane(e.id)){let i=this.scene.indicatorScales.get(n.id);i&&(i.scale.invert=t,i.scaleTarget.invert=t,i.manualScale&&(i.manualScale.invert=t));}}}firstVisibleValue(e,t){for(let n of e){let i=this.scene.offsetOf(n.id);for(let o of n.series)if(o.overlay!==true){if(Fe(o)){let s=o.points[t-i]?.value;if(s!=null&&Number.isFinite(s))return s}else if(o.kind==="candle"||o.kind==="bar"){let s=o.bars[t-i];if(s&&Number.isFinite(s.close))return s.close}}}return 0}maxVisibleVolume(e,t){let n=0;for(let i=e;i<=t;i+=1){let o=this.bars[i]?.volume;o!=null&&o>n&&(n=o);}return n}layoutPanes(){let e=this.scene.orderedPanes(),t=this.coords.height;this.inputsUI?.setCollapsedPanes(this.collapsedMasterMap());let n=this.maximizedPaneId?this.scene.panes.get(this.maximizedPaneId):null;if(n){let u=0;for(let d of e)d===n?d.bounds={top:0,height:t}:d.bounds={top:t,height:0},u+=d.bounds.height;this.inputsUI?.reposition(),this.paneControls?.reposition(),this.axisScaleButtons?.reposition(),this.repositionScrollButton(),this.positionAttribution(),this.publishPricePaneBounds();return}let i=e.filter(u=>u.collapsed),o=e.filter(u=>!u.collapsed),s=i.length*Sx,a=Math.max(0,t-s),l=o.reduce((u,d)=>u+(d.heightWeight||1),0)||1,c=0;for(let u of e){let d=u.collapsed?Sx:a*(u.heightWeight||1)/l;u.bounds={top:c,height:d},c+=d;}this.inputsUI?.reposition(),this.paneControls?.reposition(),this.axisScaleButtons?.reposition(),this.repositionScrollButton(),this.positionAttribution(),this.publishPricePaneBounds();}repositionScrollButton(){let e=this.coords.height;if(e<=0)return;let t=this.maximizedPaneId?this.scene.panes.get(this.maximizedPaneId):null,n=t?[t]:this.scene.orderedPanes().filter(o=>!o.collapsed),i=n.length?Math.max(...n.map(o=>o.bounds.top+o.bounds.height)):e;this.scrollBtnBottomPx=ip+Math.max(0,e-i),this.mountContainer?.style.setProperty("--vela-bottom-gutter",`${Bi+Math.max(0,e-i)}px`),this.scrollBtnRightPx=this.rightAxisW+Lx,this.scrollButton&&(this.scrollButton.style.bottom=`${this.scrollBtnBottomPx}px`,this.scrollButton.style.right=`${this.scrollBtnRightPx}px`);}collapsedMasterMap(){let e=new Map;for(let t of this.scene.panes.values()){if(!t.collapsed)continue;let n=this.scene.orderedIndicatorsForPane(t.id).filter(s=>s.legend!==false),i=new Set(this.scene.ownScaleIndicatorsForPane(t.id).map(s=>s.id)),o=n.find(s=>!i.has(s.id))??n[0];e.set(t.id,o?.id??null);}return e}setToolbarGutter(e){e!==this.toolbarGutter&&(this.toolbarGutter=e,this.publishGutters(),this.positionAttribution(),this.syncSize());}publishGutters(){this.mountContainer?.style.setProperty("--vela-toolbar-gutter",`${this.toolbarGutter}px`),this.mountContainer?.style.setProperty("--vela-scale-gutter",`${this.rightAxisW}px`);}publishPricePaneBounds(){if(!this.mountContainer)return;let e=this.coords.height+Bi,t=this.scene.panes.get(He),n=t?t.bounds.top:0,i=t?t.bounds.height:this.coords.height,o=Math.max(0,e-(n+i));this.mountContainer.style.setProperty("--vela-price-pane-top",`${n}px`),this.mountContainer.style.setProperty("--vela-price-pane-bottom",`${o}px`);}buildAttributionEl(){return this.attributionHtml!==null?hx(document,this.attributionHtml,this.theme.background):px(document,this.theme.background)}rebuildAttribution(){this.attributionEl&&(this.attributionEl.remove(),this.attributionEl=this.buildAttributionEl(),this.attributionEnabled||(this.attributionEl.style.display="none"),this.positionAttribution(),this.wrapper.appendChild(this.attributionEl));}positionAttribution(){if(!this.attributionEl)return;let e=this.coords?.height??0,t=this.maximizedPaneId?this.scene.panes.get(this.maximizedPaneId):null,n=t?[t]:this.scene.orderedPanes().filter(o=>!o.collapsed),i=e>0&&n.length?Math.max(...n.map(o=>o.bounds.top+o.bounds.height)):e;Object.assign(this.attributionEl.style,{left:`${(this.toolbarGutter||0)+12}px`,bottom:`${Bi+10+Math.max(0,e-i)}px`});}refreshAttributionColor(){this.attributionEl&&(this.attributionHtml!==null?this.attributionEl.style.color=Qh(this.theme.background):ep(this.attributionEl,this.theme.background));}syncSize(){let e=this.wrapper.clientWidth,t=this.wrapper.clientHeight;if(e<=0||t<=0)return;let n=window.devicePixelRatio||1;this.plot.style.left=`${this.toolbarGutter}px`;let i=this.plot.getBoundingClientRect(),o=Math.max(1,Math.round(i.width*n)),s=Math.max(1,Math.round(i.height*n)),a=this.plotDeviceSize;a&&Math.abs(a.width-i.width*n)<=1&&Math.abs(a.height-i.height*n)<=1&&(o=Math.max(1,a.width),s=Math.max(1,a.height));let l=o/n,c=s/n,u=d=>{d.width=o,d.height=s,d.style.width=`${l}px`,d.style.height=`${c}px`;};u(this.dataCanvas),u(this.backdropCanvas),u(this.volumeCanvas);for(let d of this.extLayers)u(d.canvas);u(this.vpvrCanvas),u(this.chromeCanvas),u(this.drawingsCanvas),u(this.cursorCanvas),this.coords.setSize(Math.max(1,l-this.rightAxisW),Math.max(1,c-Bi),n),this.scene.crosshair=null,this.layoutPanes(),this.userDrawings?.onResize(),!this.didInitialFit&&this.coords.barCount>0&&(this.fitContent(),this.didInitialFit=true),this.animator.active?(this.computeScales(),this.paintData(),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx())):this.scheduler.flushNow(4);}applyBackground(){this.wrapper.style.background=this.theme.background;}};function cI(r,e){for(let t of r.series){let n=t.kind==="candle"||t.kind==="bar"?t.bars:Fe(t)?t.points:null;if(!n||n.length===0)continue;let i=0,o=n.length;for(;i<o;){let s=i+o>>1;n[s].time<e?i=s+1:o=s;}return i}return null}function uI(r,e){if(e.kind==="value"){for(let t of e.series){let n=r.series.find(i=>i.id===t.seriesId);n&&(t.kind==="points"&&Fe(n)?n.points=t.points:t.kind==="bars"&&(n.kind==="candle"||n.kind==="bar")&&(n.bars=t.bars));}e.lines&&(r.lines=e.lines),e.boxes&&(r.boxes=e.boxes),e.labels&&(r.labels=e.labels),e.polylines&&(r.polylines=e.polylines),e.linefills&&(r.linefills=e.linefills),e.tables&&(r.tables=e.tables),e.trades&&(r.trades=e.trades);return}for(let t of e.removed){let n=r.series.findIndex(i=>i.id===t);n>=0&&r.series.splice(n,1);}for(let t of e.added)r.series.push(t);}function Px(r,e){let t=Ec(r,e),n=i=>i<10?`0${i}`:String(i);return {date:`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())}`,time:`${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}}function dI(r,e){let{date:t,time:n}=Px(r,e);return `${t} ${n}`}function hI(r){if(!Array.isArray(r))return [];let e=[];for(let t of r){if(!t||typeof t!="object")continue;let n=t,i=Number(n.from),o=Number(n.to);!Number.isFinite(i)||!Number.isFinite(o)||o<=i||e.push({from:i,to:o,color:typeof n.color=="string"?n.color:"rgba(120,130,160,0.10)"});}return e.sort((t,n)=>t.from-n.from)}function pI(r){if(r==null||typeof r!="object")return null;let e=r,t=n=>{if(!Array.isArray(n))return [];let i=[];for(let o of n){if(!Array.isArray(o))continue;let s=Number(o[0]),a=Number(o[1]);Number.isFinite(s)&&Number.isFinite(a)&&a>s&&i.push([s,a]);}return i.sort((o,s)=>o[0]-s[0])};return {pre:t(e.pre),post:t(e.post),extended:t(e.extended)}}function sp(r){return Math.max(0,Math.min(1,r))}function mI(r){return typeof r=="string"&&Li().includes(r)}function Ex(r){return r==="percent"||r==="indexed"?r:"price"}function Mx(r){let e=Math.abs(r);return e>=1e9?`${(r/1e9).toFixed(2)}B`:e>=1e6?`${(r/1e6).toFixed(2)}M`:e>=1e3?`${(r/1e3).toFixed(2)}K`:r.toFixed(2)}function fI(r){let e=[...r].sort((n,i)=>n.time-i.time),t=[];for(let n of e){let i=t[t.length-1];i&&i.time===n.time?t[t.length-1]=n:t.push(n);}return t}function ap(r,e){let t=(r.open+r.high+r.low+r.close)/4,n=e?(e.open+e.close)/2:(r.open+r.close)/2;return {time:r.time,open:n,high:Math.max(r.high,n,t),low:Math.min(r.low,n,t),close:t,...r.volume!=null?{volume:r.volume}:{}}}function Ix(r){let e=new Array(r.length),t;for(let n=0;n<r.length;n+=1)t=ap(r[n],t),e[n]=t;return e}var gI={full:Ix,next:ap};function Ax(){Nu({id:"heikinashi",label:"Heikin Ashi",barTransform:gI});}var lp=z,cp=W,up=20;function bI(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function Rx(r,e){return typeof r=="string"&&r!==""?r:e}function ou(r){return {upColor:Rx(r.upColor,lp),downColor:Rx(r.downColor,cp),heightFrac:Math.min(.5,Math.max(.05,bI(r.heightPct,up)/100))}}var dp=class{constructor(){this.ctx=null;this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(ou(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx?.pushData(ou(e));}suspend(){}resume(){this.ctx?.pushData(ou(this.inputs));}stop(){}},Dx={type:"volume",title:"Volume",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"upColor",title:"Up color",type:"color",defval:lp},{key:"downColor",title:"Down color",type:"color",defval:cp},{key:"heightPct",title:"Height %",type:"int",defval:up,min:5,max:50,step:1,tooltip:"Pane height the tallest visible bar occupies"}],defaultInputs:()=>({upColor:lp,downColor:cp,heightPct:up}),create:()=>new dp};function hp(){Ln(Dx);}var mp=24,fp=30,gp=Ke,bp=W,vp=70;function pp(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function Ox(r,e){return typeof r=="string"&&r!==""?r:e}function su(r){return {rows:Math.round(Math.min(400,Math.max(2,pp(r.rows,mp)))),widthFrac:Math.min(.9,Math.max(.05,pp(r.widthPct,fp)/100)),upColor:Ox(r.upColor,gp),downColor:Ox(r.downColor,bp),showPoc:r.showPoc!==false,valueAreaFrac:Math.min(1,Math.max(0,pp(r.valueAreaPct,vp)/100))}}var yp=class{constructor(){this.ctx=null;this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(su(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx?.pushData(su(e));}suspend(){}resume(){this.ctx?.pushData(su(this.inputs));}stop(){}},Nx={type:"vpvr",title:"Visible Range Volume Profile",shortTitle:"VRVP",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"rows",title:"Rows",type:"int",defval:mp,min:2,max:400,step:1},{key:"widthPct",title:"Width %",type:"int",defval:fp,min:5,max:90,step:1,tooltip:"Pane width the largest row occupies"},{key:"upColor",title:"Up color",type:"color",defval:gp},{key:"downColor",title:"Down color",type:"color",defval:bp},{key:"showPoc",title:"Point of control",type:"bool",defval:true},{key:"valueAreaPct",title:"Value area %",type:"int",defval:vp,min:0,max:100,step:1}],defaultInputs:()=>({rows:mp,widthPct:fp,upColor:gp,downColor:bp,showPoc:true,valueAreaPct:vp}),create:()=>new yp};function wp(){Ln(Nx);}function Zn(r){let e=r.title.trim().toLowerCase().replace(/\s+/g,"-");return `${r.instanceId}:${r.kind}:${e}#${r.ordinal}`}function I(r,e,t){let n=r[e];return typeof n=="number"&&Number.isFinite(n)?n:t}function F(r,e,t){let n=r[e];return typeof n=="string"&&n!==""?n:t}function Sp(r,e,t){let n=r[e];return typeof n=="boolean"?n:t}function vI(r,e,t){let n=new Array(r.length);for(let i=0;i<r.length;i++){let o=e[i],s={time:r[i].time,value:o!=null&&Number.isFinite(o)?o:null},a=t?.[i];a!=null&&(s.color=a),n[i]=s;}return n}var xp=class{constructor(e){this.spec=e;this.ctx=null;this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,this.recompute();}onBars(){this.recompute();}onViewport(){}setInputs(e){this.inputs=e,this.ctx&&this.recompute();}suspend(){}resume(){this.recompute();}stop(){}recompute(){if(!this.ctx)return;let e=this.ctx.bars(),t=this.spec.compute(e,this.inputs),n=this.spec.type,i=[],o=new Map;t.plots.forEach((c,u)=>{let d=c.kind??"line",h=Zn({instanceId:n,kind:d,title:c.title,ordinal:u});o.set(c.key,h),i.push({id:h,title:c.title,paneId:"",kind:d,points:vI(e,c.values,c.colors),style:{color:c.color,width:c.width??1,lineStyle:c.lineStyle??"solid",...c.base!=null?{base:c.base}:{}},...c.overlay?{overlay:true}:{}});}),t.markers&&t.markers.length>0&&i.push({id:Zn({instanceId:n,kind:"markers",title:"markers",ordinal:0}),title:this.spec.shortTitle??this.spec.title,paneId:"",kind:"markers",markers:t.markers});let s=(t.bands??[]).flatMap((c,u)=>{let d=o.get(c.from),h=o.get(c.to);return !d||!h?[]:[{id:Zn({instanceId:n,kind:"fill",title:c.key,ordinal:u}),paneId:"",fromSeriesId:d,toSeriesId:h,color:c.color}]}),a=(t.levels??[]).map((c,u)=>({id:Zn({instanceId:n,kind:"hline",title:c.key,ordinal:u}),paneId:"",price:c.price,...c.color!=null?{color:c.color}:{},lineStyle:c.lineStyle??"dashed",width:1,...c.title!=null?{title:c.title}:{}})),l=(t.polylines??[]).map((c,u)=>{let{key:d,...h}=c;return {id:Zn({instanceId:n,kind:"polyline",title:d,ordinal:u}),paneId:"",...h}});this.ctx.emit({series:i,fills:s,priceLines:a,polylines:l}),this.ctx.setStatus("idle");}};function Fx(r){return {type:r.type,title:r.title,...r.shortTitle!=null?{shortTitle:r.shortTitle}:{},paneHint:r.overlay?"price":"new",overlay:r.overlay,multiInstance:true,inputsSchema:()=>r.inputs,defaultInputs:()=>Object.fromEntries(r.inputs.map(e=>[e.key,e.defval])),create:()=>new xp(r)}}var Vx=["Close","Open","High","Low","HL2","HLC3","OHLC4","HLCC4"];function ee(r,e){let t=new Array(r.length);for(let n=0;n<r.length;n++){let i=r[n];switch(e){case "Open":t[n]=i.open;break;case "High":t[n]=i.high;break;case "Low":t[n]=i.low;break;case "HL2":t[n]=(i.high+i.low)/2;break;case "HLC3":t[n]=(i.high+i.low+i.close)/3;break;case "OHLC4":t[n]=(i.open+i.high+i.low+i.close)/4;break;case "HLCC4":t[n]=(i.high+i.low+i.close+i.close)/4;break;default:t[n]=i.close;}}return t}function xt(r){return r.map(e=>e.volume!=null&&Number.isFinite(e.volume)?e.volume:Number.NaN)}function Ue(r){return r.map(e=>e.high)}function Ye(r){return r.map(e=>e.low)}function Oe(r){return r.map(e=>e.close)}function _x(r){return r.map(e=>e.open)}function K(r,e,t){let n=new Array(r.length);for(let i=0;i<r.length;i++){let o=r[i],s=e[i];n[i]=Number.isFinite(o)&&Number.isFinite(s)?t(o,s):Number.NaN;}return n}function ae(r,e){let t=new Array(r.length);for(let n=0;n<r.length;n++){let i=r[n];t[n]=Number.isFinite(i)?e(i):Number.NaN;}return t}function ke(r,e){return K(r,e,(t,n)=>t-n)}function En(r,e,t){let n=new Array(r.length).fill(Number.NaN);if(e<=0)return n;let i=0;for(let o=0;o<r.length;o++)i=Number.isFinite(r[o])?i+1:0,i>=e&&(n[o]=t(r,o-e+1,o));return n}function xe(r,e){return En(r,e,(t,n,i)=>{let o=0;for(let s=n;s<=i;s++)o+=t[s];return o})}function ge(r,e){return En(r,e,(t,n,i)=>{let o=0;for(let s=n;s<=i;s++)o+=t[s];return o/e})}function au(r,e){let t=e*(e+1)/2;return En(r,e,(n,i,o)=>{let s=0;for(let a=i;a<=o;a++)s+=n[a]*(a-i+1);return s/t})}function Bx(r,e,t){let n=K(r,e,(i,o)=>i*o);return K(xe(n,t),xe(e,t),(i,o)=>o>0?i/o:Number.NaN)}function on(r,e){return En(r,e,(t,n,i)=>{let o=0;for(let l=n;l<=i;l++)o+=t[l];let s=o/e,a=0;for(let l=n;l<=i;l++){let c=t[l]-s;a+=c*c;}return Math.sqrt(a/e)})}function ct(r,e){return En(r,e,(t,n,i)=>{let o=-1/0;for(let s=n;s<=i;s++)t[s]>o&&(o=t[s]);return o})}function St(r,e){return En(r,e,(t,n,i)=>{let o=1/0;for(let s=n;s<=i;s++)t[s]<o&&(o=t[s]);return o})}function Hx(r,e){return En(r,e,(t,n,i)=>{let o=-1/0,s=i;for(let a=n;a<=i;a++)t[a]>=o&&(o=t[a],s=a);return i-s})}function zx(r,e){return En(r,e,(t,n,i)=>{let o=1/0,s=i;for(let a=n;a<=i;a++)t[a]<=o&&(o=t[a],s=a);return i-s})}function $x(r,e,t){let n=new Array(r.length).fill(Number.NaN),i=0,o=Number.NaN;for(let s=0;s<r.length;s++){let a=r[s];if(!Number.isFinite(a)){i=0,o=Number.NaN;continue}if(i+=1,Number.isFinite(o))o=t*a+(1-t)*o,n[s]=o;else if(i>=e){let l=0;for(let c=s-e+1;c<=s;c++)l+=r[c];o=l/e,n[s]=o;}}return n}function Q(r,e){return $x(r,e,2/(e+1))}function Pe(r,e){return $x(r,e,1/e)}function ze(r,e=1){let t=new Array(r.length).fill(Number.NaN);for(let n=e;n<r.length;n++){let i=r[n],o=r[n-e];Number.isFinite(i)&&Number.isFinite(o)&&(t[n]=i-o);}return t}function Ft(r,e){let t=new Array(r.length).fill(Number.NaN);for(let n=e;n<r.length;n++){let i=r[n],o=r[n-e];Number.isFinite(i)&&Number.isFinite(o)&&o!==0&&(t[n]=100*(i-o)/o);}return t}function ot(r,e){let t=new Array(r.length).fill(Number.NaN);for(let n=0;n<r.length;n++){let i=n-e;i>=0&&i<r.length&&(t[n]=r[i]);}return t}function Jn(r){let e=new Array(r.length).fill(Number.NaN);for(let t=0;t<r.length;t++){let n=r[t];if(t===0){e[t]=n.high-n.low;continue}let i=r[t-1].close;e[t]=Math.max(n.high-n.low,Math.abs(n.high-i),Math.abs(n.low-i));}return e}function Br(r,e){return Pe(Jn(r),e)}function Es(r,e){let t=ze(r),n=ae(t,o=>Math.max(o,0)),i=ae(t,o=>Math.max(-o,0));return K(Pe(n,e),Pe(i,e),(o,s)=>s===0?100:100-100/(1+o/s))}function lu(r,e,t,n){let i=ct(e,n),o=St(t,n),s=new Array(r.length).fill(Number.NaN);for(let a=0;a<r.length;a++){let l=r[a],c=i[a],u=o[a];!Number.isFinite(l)||!Number.isFinite(c)||!Number.isFinite(u)||(s[a]=c===u?50:100*(l-u)/(c-u));}return s}function cu(r,e){let t=(e-1)*e/2,n=(e-1)*e*(2*e-1)/6,i=e*n-t*t;return En(r,e,(o,s,a)=>{let l=0,c=0;for(let h=s;h<=a;h++){let p=h-s;l+=o[h],c+=p*o[h];}let u=i===0?0:(e*c-t*l)/i;return (l-u*t)/e+u*(e-1)})}function uu(r){let e=new Array(r.length).fill(Number.NaN);for(let t=3;t<r.length;t++){let n=r[t-3],i=r[t-2],o=r[t-1],s=r[t];Number.isFinite(n)&&Number.isFinite(i)&&Number.isFinite(o)&&Number.isFinite(s)&&(e[t]=(n+2*i+2*o+s)/6);}return e}function Wx(r,e){let t=new Array(r.length).fill(Number.NaN);for(let n=e;n<r.length;n++){let i=r[n];if(!Number.isFinite(i))continue;let o=0,s=0;for(let a=n-e;a<n;a++){let l=r[a];if(!Number.isFinite(l)){s=-1;break}s+=1,l<=i&&(o+=1);}s===e&&(t[n]=100*o/e);}return t}function Ms(r){let e=new Array(r.length).fill(Number.NaN),t=0,n=false;for(let i=0;i<r.length;i++){let o=r[i];Number.isFinite(o)&&(t+=o,n=true),n&&(e[i]=t);}return e}function D(r,e="length",t="Length",n=5e3){return {key:e,title:t,type:"int",defval:r,min:1,max:n,step:1}}function be(r="Close"){return {key:"source",title:"Source",type:"string",defval:r,options:Vx}}function X(r=_,e="Color",t="color"){return {key:t,title:e,type:"color",defval:r}}function Mn(r,e=.08){let t=/^#([0-9a-f]{6})$/i.exec(r.trim());if(!t)return r;let n=Math.round(e*255).toString(16).padStart(2,"0");return `#${t[1]}${n}`}var yI=["SMA","EMA","WMA","RMA","VWMA"],Gx={key:"offset",title:"Offset",type:"int",defval:0,min:-500,max:500,step:1};function Ux(r,e,t,n){return {type:r,title:e,shortTitle:t,overlay:true,inputs:[D(20),be(),Gx,X()],compute:(i,o)=>{let s=I(o,"length",20),a=n(ee(i,F(o,"source","Close")),s),l=Math.trunc(I(o,"offset",0));return l!==0&&(a=ot(a,l)),{plots:[{key:t.toLowerCase(),title:t,values:a,color:F(o,"color",_),width:2}]}}}}var wI=Ux("sma","Simple Moving Average","SMA",ge),xI=Ux("ema","Exponential Moving Average","EMA",Q),SI={type:"moving-average",title:"Moving Average",shortTitle:"MA",overlay:true,inputs:[{key:"maType",title:"Type",type:"string",defval:"SMA",options:yI},D(20),be(),Gx,X()],compute:(r,e)=>{let t=I(e,"length",20),n=ee(r,F(e,"source","Close")),i=F(e,"maType","SMA"),o;switch(i){case "EMA":o=Q(n,t);break;case "WMA":o=au(n,t);break;case "RMA":o=Pe(n,t);break;case "VWMA":o=Bx(n,xt(r),t);break;default:o=ge(n,t);}let s=Math.trunc(I(e,"offset",0));return s!==0&&(o=ot(o,s)),{plots:[{key:"ma",title:i,values:o,color:F(e,"color",_),width:2}]}}},CI={type:"rma",title:"Smoothed Moving Average",shortTitle:"RMA",overlay:true,inputs:[D(14),be(),X()],compute:(r,e)=>({plots:[{key:"rma",title:"RMA",values:Pe(ee(r,F(e,"source","Close")),I(e,"length",14)),color:F(e,"color",_),width:2}]})},TI={type:"zlema",title:"Zero-Lag Exponential Moving Average",shortTitle:"ZLEMA",overlay:true,inputs:[D(14),be(),X()],compute:(r,e)=>{let t=I(e,"length",14),n=ee(r,F(e,"source","Close")),i=Math.floor((t-1)/2),o=ot(n,i),s=K(n,o,(a,l)=>2*a-l);return {plots:[{key:"zlema",title:"ZLEMA",values:Q(s,t),color:F(e,"color",_),width:2}]}}},kI={type:"vidya",title:"Variable Index Dynamic Average",shortTitle:"VIDYA",overlay:true,inputs:[D(14),{key:"cmoLength",title:"Momentum length",type:"int",defval:9,min:1,max:500,step:1},be(),X()],compute:(r,e)=>{let t=I(e,"length",14),n=I(e,"cmoLength",9),i=ee(r,F(e,"source","Close")),o=ze(i),s=new Array(i.length).fill(Number.NaN),a=new Array(i.length).fill(Number.NaN);for(let d=n;d<i.length;d++){let h=0,p=0,m=true;for(let f=d-n+1;f<=d;f++){let g=o[f];if(!Number.isFinite(g)){m=false;break}g>0?h+=g:p-=g;}m&&(s[d]=h,a[d]=p);}let l=2/(t+1),c=new Array(i.length).fill(Number.NaN),u=Number.NaN;for(let d=0;d<i.length;d++){let h=i[d],p=s[d],m=a[d];if(!Number.isFinite(h)||!Number.isFinite(p)||!Number.isFinite(m))continue;let f=p+m,g=f===0?0:Math.abs((p-m)/f);u=Number.isFinite(u)?l*g*h+(1-l*g)*u:h,c[d]=u;}return {plots:[{key:"vidya",title:"VIDYA",values:c,color:F(e,"color",_),width:2}]}}},EI={type:"ma-envelope",title:"Moving Average Envelope",shortTitle:"MA Env",overlay:true,inputs:[{key:"maType",title:"Type",type:"string",defval:"SMA",options:["SMA","EMA"]},D(20),be(),{key:"percent",title:"Percent",type:"float",defval:2.5,min:.01,max:50,step:.1},X()],compute:(r,e)=>{let t=I(e,"length",20),n=ee(r,F(e,"source","Close")),i=F(e,"maType","SMA")==="EMA"?Q(n,t):ge(n,t),o=I(e,"percent",2.5)/100,s=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:i,color:s,width:2},{key:"upper",title:"Upper",values:ae(i,a=>a*(1+o)),color:s},{key:"lower",title:"Lower",values:ae(i,a=>a*(1-o)),color:s}],bands:[{key:"envelope",from:"upper",to:"lower",color:Mn(s)}]}}},MI={type:"linear-regression",title:"Linear Regression Curve",shortTitle:"LinReg",overlay:true,inputs:[D(14),be(),X()],compute:(r,e)=>({plots:[{key:"linreg",title:"LinReg",values:cu(ee(r,F(e,"source","Close")),I(e,"length",14)),color:F(e,"color",_),width:2}]})},Yx=[wI,xI,SI,CI,TI,kI,EI,MI];function Cp(r,e){let t=I(e,"length",20),n=I(e,"mult",2),i=ee(r,F(e,"source","Close")),o=ge(i,t),s=ae(on(i,t),a=>a*n);return {basis:o,upper:K(o,s,(a,l)=>a+l),lower:K(o,s,(a,l)=>a-l)}}var Tp=[D(20),be(),{key:"mult",title:"StdDev",type:"float",defval:2,min:.1,max:50,step:.1}],LI={type:"bollinger-bands",title:"Bollinger Bands",shortTitle:"BB",overlay:true,inputs:[...Tp,X()],compute:(r,e)=>{let{basis:t,upper:n,lower:i}=Cp(r,e),o=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:t,color:ue},{key:"upper",title:"Upper",values:n,color:o},{key:"lower",title:"Lower",values:i,color:o}],bands:[{key:"bb",from:"upper",to:"lower",color:Mn(o)}]}}},PI={type:"percent-b",title:"Bollinger Bands %B",shortTitle:"%B",overlay:false,inputs:[...Tp,X()],compute:(r,e)=>{let{upper:t,lower:n}=Cp(r,e);return {plots:[{key:"pb",title:"%B",values:ee(r,F(e,"source","Close")).map((s,a)=>{let l=t[a],c=n[a];return Number.isFinite(l)&&Number.isFinite(c)&&l!==c?(s-c)/(l-c):Number.NaN}),color:F(e,"color",_),width:2}],levels:[{key:"upper",price:1,color:J},{key:"middle",price:.5,color:J,lineStyle:"dotted"},{key:"lower",price:0,color:J}]}}},II={type:"bandwidth",title:"Bollinger Bands Width",shortTitle:"BandWidth",overlay:false,inputs:[...Tp,X()],compute:(r,e)=>{let{basis:t,upper:n,lower:i}=Cp(r,e);return {plots:[{key:"bbw",title:"BBW",values:t.map((s,a)=>{let l=n[a],c=i[a];return Number.isFinite(s)&&s!==0&&Number.isFinite(l)&&Number.isFinite(c)?(l-c)/s*100:Number.NaN}),color:F(e,"color",_),width:2}]}}},AI={type:"keltner-channels",title:"Keltner Channels",shortTitle:"KC",overlay:true,inputs:[D(20),{key:"mult",title:"Multiplier",type:"float",defval:2,min:.1,max:50,step:.1},{key:"atrLength",title:"ATR length",type:"int",defval:10,min:1,max:500,step:1},be(),X()],compute:(r,e)=>{let t=I(e,"length",20),n=I(e,"mult",2),i=Q(ee(r,F(e,"source","Close")),t),o=ae(Br(r,I(e,"atrLength",10)),a=>a*n),s=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:i,color:ue},{key:"upper",title:"Upper",values:K(i,o,(a,l)=>a+l),color:s},{key:"lower",title:"Lower",values:K(i,o,(a,l)=>a-l),color:s}],bands:[{key:"kc",from:"upper",to:"lower",color:Mn(s)}]}}},RI={type:"donchian-channels",title:"Donchian Channels",shortTitle:"DC",overlay:true,inputs:[D(20),X()],compute:(r,e)=>{let t=I(e,"length",20),n=ct(Ue(r),t),i=St(Ye(r),t),o=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:K(n,i,(s,a)=>(s+a)/2),color:ue},{key:"upper",title:"Upper",values:n,color:o},{key:"lower",title:"Lower",values:i,color:o}],bands:[{key:"dc",from:"upper",to:"lower",color:Mn(o)}]}}},DI={type:"chandelier-exit",title:"Chandelier Exit",shortTitle:"CE",overlay:true,inputs:[D(22),{key:"mult",title:"ATR multiplier",type:"float",defval:3,min:.1,max:50,step:.1}],compute:(r,e)=>{let t=I(e,"length",22),n=ae(Br(r,t),s=>s*I(e,"mult",3)),i=K(ct(Ue(r),t),n,(s,a)=>s-a),o=K(St(Ye(r),t),n,(s,a)=>s+a);return {plots:[{key:"long",title:"Long stop",values:i,color:z},{key:"short",title:"Short stop",values:o,color:W}]}}},OI={type:"chande-kroll-stop",title:"Chande Kroll Stop",shortTitle:"CKS",overlay:true,inputs:[{key:"p",title:"ATR length",type:"int",defval:10,min:1,max:500,step:1},{key:"x",title:"ATR multiplier",type:"float",defval:1,min:.1,max:50,step:.1},{key:"q",title:"Stop length",type:"int",defval:9,min:1,max:500,step:1}],compute:(r,e)=>{let t=I(e,"p",10),n=I(e,"x",1),i=I(e,"q",9),o=ae(Br(r,t),l=>l*n),s=K(ct(Ue(r),t),o,(l,c)=>l-c),a=K(St(Ye(r),t),o,(l,c)=>l+c);return {plots:[{key:"stopShort",title:"Stop short",values:ct(s,i),color:W},{key:"stopLong",title:"Stop long",values:St(a,i),color:z}]}}},NI={type:"supertrend",title:"SuperTrend",shortTitle:"SuperTrend",overlay:true,inputs:[{key:"atrLength",title:"ATR length",type:"int",defval:10,min:1,max:500,step:1},{key:"mult",title:"Factor",type:"float",defval:3,min:.1,max:50,step:.1}],compute:(r,e)=>{let t=I(e,"atrLength",10),n=I(e,"mult",3),i=Br(r,t),o=r.length,s=new Array(o).fill(Number.NaN),a=new Array(o).fill(1),l=Number.NaN,c=Number.NaN,u=1;for(let h=0;h<o;h++){let p=i[h];if(!Number.isFinite(p))continue;let m=r[h],f=(m.high+m.low)/2,g=f-n*p,b=f+n*p,y=h>0?r[h-1].close:m.close;l=Number.isFinite(l)&&y>l?Math.max(g,l):g,c=Number.isFinite(c)&&y<c?Math.min(b,c):b,u===1&&m.close<l?u=-1:u===-1&&m.close>c&&(u=1),a[h]=u,s[h]=u===1?l:c;}let d=a.map((h,p)=>Number.isFinite(s[p])?h===1?z:W:null);return {plots:[{key:"st",title:"SuperTrend",values:s,color:z,width:2,colors:d}]}}},FI={type:"williams-alligator",title:"Williams Alligator",shortTitle:"Alligator",overlay:true,inputs:[{key:"jawLength",title:"Jaw length",type:"int",defval:13,min:1,max:500,step:1},{key:"teethLength",title:"Teeth length",type:"int",defval:8,min:1,max:500,step:1},{key:"lipsLength",title:"Lips length",type:"int",defval:5,min:1,max:500,step:1},{key:"jawOffset",title:"Jaw offset",type:"int",defval:8,min:0,max:100,step:1},{key:"teethOffset",title:"Teeth offset",type:"int",defval:5,min:0,max:100,step:1},{key:"lipsOffset",title:"Lips offset",type:"int",defval:3,min:0,max:100,step:1}],compute:(r,e)=>{let t=ee(r,"HL2"),n=ot(Pe(t,I(e,"jawLength",13)),I(e,"jawOffset",8)),i=ot(Pe(t,I(e,"teethLength",8)),I(e,"teethOffset",5)),o=ot(Pe(t,I(e,"lipsLength",5)),I(e,"lipsOffset",3));return {plots:[{key:"jaw",title:"Jaw",values:n,color:_},{key:"teeth",title:"Teeth",values:i,color:W},{key:"lips",title:"Lips",values:o,color:z}]}}},VI={type:"gator-oscillator",title:"Gator Oscillator",shortTitle:"Gator Oscillator",overlay:false,inputs:[],compute:r=>{let e=ee(r,"HL2"),t=ot(Pe(e,13),8),n=ot(Pe(e,8),5),i=ot(Pe(e,5),3),o=ae(ke(t,n),Math.abs),s=ae(ke(n,i),l=>-Math.abs(l)),a=l=>l.map((c,u)=>{if(!Number.isFinite(c))return null;let d=u>0?l[u-1]:Number.NaN;return Number.isFinite(d)&&Math.abs(c)>Math.abs(d)?z:W});return {plots:[{key:"upper",title:"Upper",values:o,kind:"histogram",color:z,colors:a(o),base:0},{key:"lower",title:"Lower",values:s,kind:"histogram",color:W,colors:a(s),base:0}]}}},Kx=[LI,PI,II,AI,RI,DI,OI,NI,FI,VI];function sn(r,e,t){let n=[{key:"upper",price:e,color:J},{key:"lower",price:r,color:J}];return t!=null&&n.splice(1,0,{key:"middle",price:t,color:J,lineStyle:"dotted"}),n}var st=[{key:"zero",price:0,color:J}];function du(r){return r.map((e,t)=>{if(!Number.isFinite(e))return null;let n=t>0?r[t-1]:Number.NaN,i=Number.isFinite(n)?e>=n:true;return e>=0?i?z:`${z}80`:i?`${W}80`:W})}var _I={type:"rsi",title:"Relative Strength Index",shortTitle:"RSI",overlay:false,inputs:[D(14),be(),X()],compute:(r,e)=>({plots:[{key:"rsi",title:"RSI",values:Es(ee(r,F(e,"source","Close")),I(e,"length",14)),color:F(e,"color",_),width:2}],levels:sn(30,70,50)})},BI={type:"stochastic",title:"Stochastic",shortTitle:"Stoch",overlay:false,inputs:[D(14,"kLength","%K length"),D(1,"kSmoothing","%K smoothing",500),D(3,"dLength","%D smoothing",500)],compute:(r,e)=>{let t=ge(lu(Oe(r),Ue(r),Ye(r),I(e,"kLength",14)),I(e,"kSmoothing",1)),n=ge(t,I(e,"dLength",3));return {plots:[{key:"k",title:"%K",values:t,color:_,width:2},{key:"d",title:"%D",values:n,color:ue}],levels:sn(20,80)}}},HI={type:"stochastic-rsi",title:"Stochastic RSI",shortTitle:"Stoch RSI",overlay:false,inputs:[D(14,"rsiLength","RSI length"),D(14,"stochLength","Stochastic length"),D(3,"kSmoothing","%K smoothing",500),D(3,"dLength","%D smoothing",500),be()],compute:(r,e)=>{let t=Es(ee(r,F(e,"source","Close")),I(e,"rsiLength",14)),n=ge(lu(t,t,t,I(e,"stochLength",14)),I(e,"kSmoothing",3)),i=ge(n,I(e,"dLength",3));return {plots:[{key:"k",title:"%K",values:n,color:_,width:2},{key:"d",title:"%D",values:i,color:ue}],levels:sn(20,80)}}},zI={type:"macd",title:"MACD",overlay:false,inputs:[D(12,"fastLength","Fast length"),D(26,"slowLength","Slow length"),D(9,"signalLength","Signal smoothing",500),be()],compute:(r,e)=>{let t=ee(r,F(e,"source","Close")),n=ke(Q(t,I(e,"fastLength",12)),Q(t,I(e,"slowLength",26))),i=Q(n,I(e,"signalLength",9)),o=ke(n,i);return {plots:[{key:"hist",title:"Histogram",values:o,kind:"histogram",color:z,colors:du(o),base:0},{key:"macd",title:"MACD",values:n,color:_,width:2},{key:"signal",title:"Signal",values:i,color:ue}],levels:st}}},$I={type:"ppo",title:"Percentage Price Oscillator",shortTitle:"PPO",overlay:false,inputs:[D(12,"fastLength","Fast length"),D(26,"slowLength","Slow length"),D(9,"signalLength","Signal smoothing",500),be()],compute:(r,e)=>{let t=ee(r,F(e,"source","Close")),n=Q(t,I(e,"fastLength",12)),i=Q(t,I(e,"slowLength",26)),o=K(n,i,(l,c)=>c===0?Number.NaN:(l-c)/c*100),s=Q(o,I(e,"signalLength",9)),a=ke(o,s);return {plots:[{key:"hist",title:"Histogram",values:a,kind:"histogram",color:z,colors:du(a),base:0},{key:"ppo",title:"PPO",values:o,color:_,width:2},{key:"signal",title:"Signal",values:s,color:ue}],levels:st}}},WI={type:"awesome-oscillator",title:"Awesome Oscillator",shortTitle:"AO",overlay:false,inputs:[],compute:r=>{let e=ee(r,"HL2"),t=ke(ge(e,5),ge(e,34)),n=t.map((i,o)=>{if(!Number.isFinite(i))return null;let s=o>0?t[o-1]:Number.NaN;return Number.isFinite(s)&&i<s?W:z});return {plots:[{key:"ao",title:"AO",values:t,kind:"histogram",color:z,colors:n,base:0}],levels:st}}},GI={type:"commodity-channel-index",title:"Commodity Channel Index",shortTitle:"CCI",overlay:false,inputs:[D(20),be("HLC3"),X()],compute:(r,e)=>{let t=I(e,"length",20),n=ee(r,F(e,"source","HLC3")),i=ge(n,t),o=new Array(n.length).fill(Number.NaN);for(let a=t-1;a<n.length;a++){let l=i[a];if(!Number.isFinite(l))continue;let c=0;for(let u=a-t+1;u<=a;u++)c+=Math.abs(n[u]-l);o[a]=c/t;}return {plots:[{key:"cci",title:"CCI",values:n.map((a,l)=>{let c=i[l],u=o[l];return Number.isFinite(c)&&Number.isFinite(u)&&u!==0?(a-c)/(.015*u):Number.NaN}),color:F(e,"color",_),width:2}],levels:sn(-100,100,0)}}},UI={type:"williams-percent-r",title:"Williams %R",shortTitle:"%R",overlay:false,inputs:[D(14),X()],compute:(r,e)=>({plots:[{key:"wr",title:"%R",values:ae(lu(Oe(r),Ue(r),Ye(r),I(e,"length",14)),n=>n-100),color:F(e,"color",_),width:2}],levels:sn(-80,-20)})},YI={type:"chande-momentum-oscillator",title:"Chande Momentum Oscillator",shortTitle:"CMO",overlay:false,inputs:[D(9),be(),X()],compute:(r,e)=>{let t=I(e,"length",9),n=ze(ee(r,F(e,"source","Close"))),i=xe(ae(n,a=>Math.max(a,0)),t),o=xe(ae(n,a=>Math.max(-a,0)),t);return {plots:[{key:"cmo",title:"CMO",values:K(i,o,(a,l)=>a+l===0?0:100*(a-l)/(a+l)),color:F(e,"color",_),width:2}],levels:sn(-50,50,0)}}},KI={type:"connors-rsi",title:"Connors RSI",shortTitle:"CRSI",overlay:false,inputs:[D(3,"rsiLength","RSI length"),D(2,"streakLength","Streak RSI length"),D(100,"rankLength","Percent-rank length"),X()],compute:(r,e)=>{let t=Oe(r),n=new Array(t.length).fill(0);for(let l=1;l<t.length;l++){let c=t[l]-t[l-1];n[l]=c>0?Math.max(n[l-1],0)+1:c<0?Math.min(n[l-1],0)-1:0;}let i=Es(t,I(e,"rsiLength",3)),o=Es(n,I(e,"streakLength",2)),s=Wx(Ft(t,1),I(e,"rankLength",100));return {plots:[{key:"crsi",title:"CRSI",values:t.map((l,c)=>{let u=i[c],d=o[c],h=s[c];return Number.isFinite(u)&&Number.isFinite(d)&&Number.isFinite(h)?(u+d+h)/3:Number.NaN}),color:F(e,"color",_),width:2}],levels:sn(20,80,50)}}},XI={type:"fisher-transform",title:"Fisher Transform",shortTitle:"Fisher",overlay:false,inputs:[D(9)],compute:(r,e)=>{let t=I(e,"length",9),n=ee(r,"HL2"),i=ct(n,t),o=St(n,t),s=r.length,a=new Array(s).fill(Number.NaN),l=0,c=0;for(let u=0;u<s;u++){let d=i[u],h=o[u];if(!Number.isFinite(d)||!Number.isFinite(h))continue;let p=d===h?0:(n[u]-h)/(d-h)-.5;l=Math.max(-0.999,Math.min(.999,.66*p+.67*l)),c=.5*Math.log((1+l)/(1-l))+.5*c,a[u]=c;}return {plots:[{key:"fisher",title:"Fisher",values:a,color:_,width:2},{key:"trigger",title:"Trigger",values:ot(a,1),color:ue}],levels:st}}},jI={type:"trix",title:"TRIX",overlay:false,inputs:[D(18),X()],compute:(r,e)=>{let t=I(e,"length",18),n=ae(Oe(r),Math.log),i=Q(Q(Q(n,t),t),t);return {plots:[{key:"trix",title:"TRIX",values:ae(ze(i),s=>s*1e4),color:F(e,"color",_),width:2}],levels:st}}};function Xx(r,e,t){let n=ze(r),i=Q(Q(n,e),t),o=Q(Q(ae(n,Math.abs),e),t);return K(i,o,(s,a)=>a===0?0:100*s/a)}var qI={type:"true-strength-index",title:"True Strength Index",shortTitle:"TSI",overlay:false,inputs:[D(25,"longLength","Long length"),D(13,"shortLength","Short length"),D(13,"signalLength","Signal length")],compute:(r,e)=>{let t=Xx(Oe(r),I(e,"longLength",25),I(e,"shortLength",13));return {plots:[{key:"tsi",title:"TSI",values:t,color:_,width:2},{key:"signal",title:"Signal",values:Q(t,I(e,"signalLength",13)),color:ue}],levels:st}}},ZI={type:"smi-ergodic",title:"SMI Ergodic Oscillator",shortTitle:"SMIE",overlay:false,inputs:[D(5,"shortLength","Short length"),D(20,"longLength","Long length"),D(5,"signalLength","Signal length")],compute:(r,e)=>{let t=Xx(Oe(r),I(e,"longLength",20),I(e,"shortLength",5)),n=Q(t,I(e,"signalLength",5)),i=ke(t,n);return {plots:[{key:"osc",title:"Oscillator",values:i,kind:"histogram",color:z,colors:du(i),base:0},{key:"smi",title:"SMI",values:t,color:_,width:2},{key:"signal",title:"Signal",values:n,color:ue}],levels:st}}},JI={type:"schaff-trend-cycle",title:"Schaff Trend Cycle",shortTitle:"Schaff Trend Cycle",overlay:false,inputs:[D(10,"cycleLength","Cycle length"),D(23,"fastLength","Fast length"),D(50,"slowLength","Slow length")],compute:(r,e)=>{let t=I(e,"cycleLength",10),n=Oe(r),i=ke(Q(n,I(e,"fastLength",23)),Q(n,I(e,"slowLength",50))),o=a=>{let l=St(a,t),c=ct(a,t),u=new Array(a.length).fill(Number.NaN),d=Number.NaN,h=Number.NaN;for(let p=0;p<a.length;p++){let m=a[p],f=l[p],g=c[p];if(!Number.isFinite(m)||!Number.isFinite(f)||!Number.isFinite(g))continue;let b=g>f?(m-f)/(g-f)*100:Number.isFinite(d)?d:50;d=b,h=Number.isFinite(h)?h+.5*(b-h):b,u[p]=h;}return u};return {plots:[{key:"stc",title:"STC",values:o(o(i)),color:_,width:2}],levels:sn(25,75)}}},QI={type:"know-sure-thing",title:"Know Sure Thing",shortTitle:"KST",overlay:false,inputs:[be(),D(9,"signalLength","Signal length")],compute:(r,e)=>{let t=ee(r,F(e,"source","Close")),n=[ge(Ft(t,10),10),ge(Ft(t,15),10),ge(Ft(t,20),10),ge(Ft(t,30),15)].reduce((i,o,s)=>K(i,o,(a,l)=>a+l*(s+1)),new Array(t.length).fill(0));return {plots:[{key:"kst",title:"KST",values:n,color:_,width:2},{key:"signal",title:"Signal",values:ge(n,I(e,"signalLength",9)),color:ue}],levels:st}}},eA={type:"coppock-curve",title:"Coppock Curve",shortTitle:"Coppock",overlay:false,inputs:[D(10,"wmaLength","WMA length"),D(14,"longRoc","Long RoC length"),D(11,"shortRoc","Short RoC length"),be(),X()],compute:(r,e)=>{let t=ee(r,F(e,"source","Close"));return {plots:[{key:"coppock",title:"Coppock",values:au(K(Ft(t,I(e,"longRoc",14)),Ft(t,I(e,"shortRoc",11)),(i,o)=>i+o),I(e,"wmaLength",10)),color:F(e,"color",_),width:2}],levels:st}}},tA={type:"detrended-price-oscillator",title:"Detrended Price Oscillator",shortTitle:"DPO",overlay:false,inputs:[D(21),X()],compute:(r,e)=>{let t=I(e,"length",21),n=Math.floor(t/2)+1;return {plots:[{key:"dpo",title:"DPO",values:ke(Oe(r),ot(ge(Oe(r),t),n)),color:F(e,"color",_),width:2}],levels:st}}},nA={type:"rate-of-change",title:"Rate of Change",shortTitle:"ROC",overlay:false,inputs:[D(9),be(),X()],compute:(r,e)=>({plots:[{key:"roc",title:"RoC",values:Ft(ee(r,F(e,"source","Close")),I(e,"length",9)),color:F(e,"color",_),width:2}],levels:st})},rA={type:"ultimate-oscillator",title:"Ultimate Oscillator",shortTitle:"UO",overlay:false,inputs:[D(7,"fastLength","Fast length"),D(14,"middleLength","Middle length"),D(28,"slowLength","Slow length"),X()],compute:(r,e)=>{let t=r.length,n=new Array(t).fill(Number.NaN),i=new Array(t).fill(Number.NaN);for(let u=0;u<t;u++){let d=r[u],h=u>0?r[u-1].close:d.close,p=Math.min(d.low,h),m=Math.max(d.high,h);n[u]=d.close-p,i[u]=m-p;}let o=u=>K(xe(n,u),xe(i,u),(d,h)=>h===0?Number.NaN:d/h),s=o(I(e,"fastLength",7)),a=o(I(e,"middleLength",14)),l=o(I(e,"slowLength",28));return {plots:[{key:"uo",title:"UO",values:s.map((u,d)=>{let h=a[d],p=l[d];return Number.isFinite(u)&&Number.isFinite(h)&&Number.isFinite(p)?100*(4*u+2*h+p)/7:Number.NaN}),color:F(e,"color",_),width:2}],levels:sn(30,70,50)}}},iA={type:"relative-vigor-index",title:"Relative Vigor Index",shortTitle:"RVGI",overlay:false,inputs:[D(10)],compute:(r,e)=>{let t=I(e,"length",10),n=uu(ke(Oe(r),_x(r))),i=uu(ke(Ue(r),Ye(r))),o=K(xe(n,t),xe(i,t),(s,a)=>a===0?0:s/a);return {plots:[{key:"rvgi",title:"RVGI",values:o,color:_,width:2},{key:"signal",title:"Signal",values:uu(o),color:ue}],levels:st}}},oA={type:"relative-volatility-index",title:"Relative Volatility Index",shortTitle:"RVI",overlay:false,inputs:[D(10,"stdevLength","StdDev length"),D(14,"smoothLength","Smoothing length"),be(),X()],compute:(r,e)=>{let t=I(e,"smoothLength",14),n=ee(r,F(e,"source","Close")),i=on(n,I(e,"stdevLength",10)),o=ze(n),s=Pe(K(i,o,(c,u)=>u>0?c:0),t),a=Pe(K(i,o,(c,u)=>u<=0?c:0),t);return {plots:[{key:"rvi",title:"RVI",values:K(s,a,(c,u)=>c+u===0?50:100*c/(c+u)),color:F(e,"color",_),width:2}],levels:sn(20,80,50)}}},sA={type:"balance-of-power",title:"Balance of Power",shortTitle:"BOP",overlay:false,inputs:[X()],compute:(r,e)=>({plots:[{key:"bop",title:"BOP",values:r.map(n=>n.high===n.low?0:(n.close-n.open)/(n.high-n.low)),color:F(e,"color",_),width:2}],levels:st})},aA={type:"elder-ray",title:"Elder Ray",overlay:false,inputs:[D(13)],compute:(r,e)=>{let t=Q(Oe(r),I(e,"length",13));return {plots:[{key:"bull",title:"Bull power",values:ke(Ue(r),t),kind:"histogram",color:z,base:0},{key:"bear",title:"Bear power",values:ke(Ye(r),t),kind:"histogram",color:W,base:0}],levels:st}}},lA={type:"ttm-squeeze",title:"TTM Squeeze",overlay:false,inputs:[D(20),{key:"bbMult",title:"Bollinger multiplier",type:"float",defval:2,min:.1,max:50,step:.1},{key:"kcMult",title:"Keltner multiplier",type:"float",defval:1.5,min:.1,max:50,step:.1}],compute:(r,e)=>{let t=I(e,"length",20),n=Oe(r),i=ge(n,t),o=ae(on(n,t),h=>h*I(e,"bbMult",2)),s=ae(Pe(Jn(r),t),h=>h*I(e,"kcMult",1.5)),a=K(ct(Ue(r),t),St(Ye(r),t),(h,p)=>(h+p)/2),l=K(a,i,(h,p)=>(h+p)/2),c=cu(ke(n,l),t),d=n.map((h,p)=>{let m=o[p],f=s[p];return Number.isFinite(m)&&Number.isFinite(f)?m<f:false}).map((h,p)=>Number.isFinite(c[p])?h?W:z:null);return {plots:[{key:"mom",title:"Momentum",values:c,kind:"histogram",color:z,colors:du(c),base:0},{key:"squeeze",title:"Squeeze",values:c.map(h=>Number.isFinite(h)?0:Number.NaN),kind:"cross",color:Je,colors:d}]}}},jx=[_I,BI,HI,zI,$I,WI,GI,UI,YI,KI,XI,jI,qI,ZI,JI,QI,eA,tA,nA,rA,iA,oA,sA,aA,lA];var cA={type:"aroon",title:"Aroon",overlay:false,inputs:[D(14)],compute:(r,e)=>{let t=I(e,"length",14),n=ae(Hx(Ue(r),t+1),o=>100*(t-o)/t),i=ae(zx(Ye(r),t+1),o=>100*(t-o)/t);return {plots:[{key:"up",title:"Aroon up",values:n,color:z,width:2},{key:"down",title:"Aroon down",values:i,color:W,width:2}]}}},uA={type:"average-directional-index",title:"Average Directional Index",shortTitle:"ADX",overlay:false,inputs:[D(14,"diLength","DI length"),D(14,"adxLength","ADX smoothing")],compute:(r,e)=>{let t=I(e,"diLength",14),n=I(e,"adxLength",14),i=r.length,o=new Array(i).fill(Number.NaN),s=new Array(i).fill(Number.NaN);for(let d=1;d<i;d++){let h=r[d].high-r[d-1].high,p=r[d-1].low-r[d].low;o[d]=h>p&&h>0?h:0,s[d]=p>h&&p>0?p:0;}let a=Pe(Jn(r),t),l=K(Pe(o,t),a,(d,h)=>h===0?0:100*d/h),c=K(Pe(s,t),a,(d,h)=>h===0?0:100*d/h),u=K(l,c,(d,h)=>d+h===0?0:100*Math.abs(d-h)/(d+h));return {plots:[{key:"adx",title:"ADX",values:Pe(u,n),color:_,width:2},{key:"plusDi",title:"+DI",values:l,color:z},{key:"minusDi",title:"-DI",values:c,color:W}],levels:[{key:"threshold",price:25,color:J,lineStyle:"dotted"}]}}},dA={type:"vortex-indicator",title:"Vortex Indicator",shortTitle:"VI",overlay:false,inputs:[D(14)],compute:(r,e)=>{let t=I(e,"length",14),n=r.length,i=new Array(n).fill(Number.NaN),o=new Array(n).fill(Number.NaN);for(let a=1;a<n;a++)i[a]=Math.abs(r[a].high-r[a-1].low),o[a]=Math.abs(r[a].low-r[a-1].high);let s=xe(Jn(r),t);return {plots:[{key:"viPlus",title:"VI+",values:K(xe(i,t),s,(a,l)=>l===0?Number.NaN:a/l),color:z,width:2},{key:"viMinus",title:"VI-",values:K(xe(o,t),s,(a,l)=>l===0?Number.NaN:a/l),color:W,width:2}],levels:[{key:"one",price:1,color:J,lineStyle:"dotted"}]}}},qx=[cA,uA,dA];var hA={type:"average-true-range",title:"Average True Range",shortTitle:"ATR",overlay:false,inputs:[D(14),X()],compute:(r,e)=>({plots:[{key:"atr",title:"ATR",values:Br(r,I(e,"length",14)),color:F(e,"color",_),width:2}]})},pA={type:"historical-volatility",title:"Historical Volatility",shortTitle:"HV",overlay:false,inputs:[D(10),{key:"annual",title:"Periods per year",type:"int",defval:365,min:1,max:1e5,step:1,tooltip:"Annualization factor (365 for daily crypto bars, 252 for stock sessions)"},X()],compute:(r,e)=>{let t=ae(ze(ae(Oe(r),Math.log)),i=>i);return {plots:[{key:"hv",title:"HV",values:ae(on(t,I(e,"length",10)),i=>i*Math.sqrt(I(e,"annual",365))*100),color:F(e,"color",_),width:2}]}}},mA={type:"chaikin-volatility",title:"Chaikin Volatility",shortTitle:"CHV",overlay:false,inputs:[D(10,"emaLength","EMA length"),D(10,"rocLength","RoC length"),X()],compute:(r,e)=>{let t=Q(ke(Ue(r),Ye(r)),I(e,"emaLength",10));return {plots:[{key:"cv",title:"Chaikin Vol",values:Ft(t,I(e,"rocLength",10)),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},fA={type:"mass-index",title:"Mass Index",shortTitle:"MI",overlay:false,inputs:[D(25),X()],compute:(r,e)=>{let t=ke(Ue(r),Ye(r)),n=Q(t,9),i=K(n,Q(n,9),(o,s)=>s===0?Number.NaN:o/s);return {plots:[{key:"mi",title:"Mass Index",values:xe(i,I(e,"length",25)),color:F(e,"color",_),width:2}],levels:[{key:"reversal",price:27,color:J,lineStyle:"dotted"}]}}},gA={type:"standard-deviation",title:"Standard Deviation",shortTitle:"StdDev",overlay:false,inputs:[D(20),be(),X()],compute:(r,e)=>({plots:[{key:"stdev",title:"StdDev",values:on(ee(r,F(e,"source","Close")),I(e,"length",20)),color:F(e,"color",_),width:2}]})},bA={type:"ulcer-index",title:"Ulcer Index",overlay:false,inputs:[D(14),X()],compute:(r,e)=>{let t=I(e,"length",14),n=Oe(r),i=K(n,ct(n,t),(s,a)=>a===0?0:100*(s-a)/a);return {plots:[{key:"ui",title:"Ulcer",values:ae(ge(ae(i,s=>s*s),t),Math.sqrt),color:F(e,"color",_),width:2}]}}},vA={type:"choppiness-index",title:"Choppiness Index",shortTitle:"CHOP",overlay:false,inputs:[D(14),X()],compute:(r,e)=>{let t=I(e,"length",14),n=xe(Jn(r),t),i=K(ct(Ue(r),t),St(Ye(r),t),(s,a)=>s-a);return {plots:[{key:"chop",title:"CHOP",values:K(n,i,(s,a)=>a>0&&s>0?100*Math.log10(s/a)/Math.log10(t):Number.NaN),color:F(e,"color",_),width:2}],levels:[{key:"upper",price:61.8,color:J},{key:"lower",price:38.2,color:J}]}}},Zx=[hA,pA,mA,fA,gA,bA,vA];function hu(r){return r.map(e=>e.volume==null||!Number.isFinite(e.volume)?Number.NaN:e.high===e.low?0:(2*e.close-e.high-e.low)/(e.high-e.low)*e.volume)}var yA={type:"on-balance-volume",title:"On Balance Volume",shortTitle:"OBV",overlay:false,inputs:[X()],compute:(r,e)=>{let t=xt(r),n=ze(Oe(r)),i=K(t,n,(o,s)=>s>0?o:s<0?-o:0);return {plots:[{key:"obv",title:"OBV",values:Ms(i),color:F(e,"color",_),width:2}]}}},wA={type:"accumulation-distribution",title:"Accumulation / Distribution",shortTitle:"A/D",overlay:false,inputs:[X()],compute:(r,e)=>({plots:[{key:"ad",title:"A/D",values:Ms(hu(r)),color:F(e,"color",_),width:2}]})},xA={type:"chaikin-money-flow",title:"Chaikin Money Flow",shortTitle:"CMF",overlay:false,inputs:[D(20),X()],compute:(r,e)=>{let t=I(e,"length",20);return {plots:[{key:"cmf",title:"CMF",values:K(xe(hu(r),t),xe(xt(r),t),(i,o)=>o===0?0:i/o),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},SA={type:"chaikin-oscillator",title:"Chaikin Oscillator",shortTitle:"Chaikin Osc",overlay:false,inputs:[D(3,"fastLength","Fast length"),D(10,"slowLength","Slow length"),X()],compute:(r,e)=>{let t=Ms(hu(r));return {plots:[{key:"co",title:"Chaikin Osc",values:ke(Q(t,I(e,"fastLength",3)),Q(t,I(e,"slowLength",10))),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},CA={type:"ease-of-movement",title:"Ease of Movement",shortTitle:"EOM",overlay:false,inputs:[D(14),{key:"divisor",title:"Divisor",type:"int",defval:1e4,min:1,max:1e9,step:1},X()],compute:(r,e)=>{let t=I(e,"divisor",1e4),n=ee(r,"HL2"),i=ze(n),o=r.map((s,a)=>{let l=i[a];return s.volume==null||!Number.isFinite(s.volume)||s.volume===0||!Number.isFinite(l)?Number.NaN:t*l*(s.high-s.low)/s.volume});return {plots:[{key:"eom",title:"EOM",values:ge(o,I(e,"length",14)),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},TA={type:"force-index",title:"Force Index",shortTitle:"FI",overlay:false,inputs:[D(13),X()],compute:(r,e)=>{let t=K(ze(Oe(r)),xt(r),(n,i)=>n*i);return {plots:[{key:"force",title:"Force",values:Q(t,I(e,"length",13)),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},kA={type:"klinger-oscillator",title:"Klinger Oscillator",shortTitle:"KVO",overlay:false,inputs:[D(34,"fastLength","Fast length"),D(55,"slowLength","Slow length"),D(13,"signalLength","Signal length")],compute:(r,e)=>{let t=ee(r,"HLC3"),n=ze(t),i=K(xt(r),n,(s,a)=>a>=0?s:-s),o=ke(Q(i,I(e,"fastLength",34)),Q(i,I(e,"slowLength",55)));return {plots:[{key:"kvo",title:"KVO",values:o,color:_,width:2},{key:"signal",title:"Signal",values:Q(o,I(e,"signalLength",13)),color:ue}],levels:[{key:"zero",price:0,color:J}]}}},EA={type:"money-flow-index",title:"Money Flow Index",shortTitle:"MFI",overlay:false,inputs:[D(14),X()],compute:(r,e)=>{let t=I(e,"length",14),n=ee(r,"HLC3"),i=K(n,xt(r),(c,u)=>c*u),o=ze(n),s=xe(K(i,o,(c,u)=>u>0?c:0),t),a=xe(K(i,o,(c,u)=>u<0?c:0),t);return {plots:[{key:"mfi",title:"MFI",values:K(s,a,(c,u)=>u===0?100:100-100/(1+c/u)),color:F(e,"color",_),width:2}],levels:[{key:"upper",price:80,color:J},{key:"lower",price:20,color:J}]}}};function Jx(r,e){let t=new Array(r.length).fill(Number.NaN),n=1e3,i=false;for(let o=1;o<r.length;o++){let s=r[o].volume,a=r[o-1].volume,l=r[o-1].close;if(s==null||a==null||!Number.isFinite(s)||!Number.isFinite(a)||l===0){i&&(t[o]=n);continue}i=true,e(s,a)&&(n+=(r[o].close-l)/l*n),t[o]=n;}return t}var MA={type:"negative-volume-index",title:"Negative Volume Index",shortTitle:"Negative Volume Index",overlay:false,inputs:[D(255,"signalLength","Signal length"),X()],compute:(r,e)=>{let t=Jx(r,(n,i)=>n<i);return {plots:[{key:"nvi",title:"NVI",values:t,color:F(e,"color",_),width:2},{key:"signal",title:"Signal",values:Q(t,I(e,"signalLength",255)),color:ue}]}}},LA={type:"positive-volume-index",title:"Positive Volume Index",shortTitle:"Positive Volume Index",overlay:false,inputs:[D(255,"signalLength","Signal length"),X()],compute:(r,e)=>{let t=Jx(r,(n,i)=>n>i);return {plots:[{key:"pvi",title:"PVI",values:t,color:F(e,"color",_),width:2},{key:"signal",title:"Signal",values:Q(t,I(e,"signalLength",255)),color:ue}]}}},PA={type:"price-volume-trend",title:"Price Volume Trend",shortTitle:"PVT",overlay:false,inputs:[X()],compute:(r,e)=>{let t=Oe(r),n=r.map((i,o)=>{if(o===0||i.volume==null||!Number.isFinite(i.volume))return Number.NaN;let s=t[o-1];return s===0?0:(t[o]-s)/s*i.volume});return {plots:[{key:"pvt",title:"PVT",values:Ms(n),color:F(e,"color",_),width:2}]}}},IA={type:"volume-oscillator",title:"Volume Oscillator",shortTitle:"Vol Osc",overlay:false,inputs:[D(5,"fastLength","Fast length"),D(10,"slowLength","Slow length"),X()],compute:(r,e)=>{let t=xt(r),n=Q(t,I(e,"fastLength",5)),i=Q(t,I(e,"slowLength",10));return {plots:[{key:"vo",title:"Volume Osc",values:K(n,i,(s,a)=>a===0?Number.NaN:100*(s-a)/a),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},AA={type:"pvo",title:"Percentage Volume Oscillator",shortTitle:"PVO",overlay:false,inputs:[D(12,"fastLength","Fast length"),D(26,"slowLength","Slow length"),D(9,"signalLength","Signal length")],compute:(r,e)=>{let t=xt(r),n=Q(t,I(e,"fastLength",12)),i=Q(t,I(e,"slowLength",26)),o=K(n,i,(l,c)=>c===0?Number.NaN:100*(l-c)/c),s=Q(o,I(e,"signalLength",9)),a=ke(o,s);return {plots:[{key:"hist",title:"Histogram",values:a,kind:"histogram",color:z,colors:a.map(l=>Number.isFinite(l)?l>=0?z:W:null),base:0},{key:"pvo",title:"PVO",values:o,color:_,width:2},{key:"signal",title:"Signal",values:s,color:ue}],levels:[{key:"zero",price:0,color:J}]}}},RA={type:"volume-flow-indicator",title:"Volume Flow Indicator",shortTitle:"Volume Flow Indicator",overlay:false,inputs:[D(130),{key:"coef",title:"Cutoff coefficient",type:"float",defval:.2,min:.01,max:10,step:.01},{key:"volCoef",title:"Volume cap",type:"float",defval:2.5,min:.1,max:50,step:.1},D(3,"smoothLength","Smoothing length")],compute:(r,e)=>{let t=I(e,"length",130),n=I(e,"coef",.2),i=I(e,"volCoef",2.5),o=ae(ee(r,"HLC3"),Math.log),s=ze(o),a=on(s,30),l=xt(r),c=ge(l,t),u=ze(ee(r,"HLC3")),d=r.map((f,g)=>{let b=Number.isFinite(a[g])?n*a[g]*f.close:Number.NaN,y=l[g],v=g>0?c[g-1]:Number.NaN,S=u[g];if(!Number.isFinite(b)||!Number.isFinite(y)||!Number.isFinite(v)||!Number.isFinite(S))return Number.NaN;let E=Math.min(y,v*i);return S>b?E:S<-b?-E:0}),h=r.map((f,g)=>{let b=g>0?c[g-1]:Number.NaN;return Number.isFinite(b)&&b!==0?b:Number.NaN}),p=xe(d,t),m=K(p,h,(f,g)=>f/g);return {plots:[{key:"vfi",title:"VFI",values:ge(m,I(e,"smoothLength",3)),color:_,width:2}],levels:[{key:"zero",price:0,color:J}]}}},DA={type:"intraday-intensity",title:"Intraday Intensity",shortTitle:"Intraday Intensity",overlay:false,inputs:[D(21),X()],compute:(r,e)=>{let t=I(e,"length",21);return {plots:[{key:"ii",title:"II%",values:K(xe(hu(r),t),xe(xt(r),t),(i,o)=>o===0?0:100*i/o),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},Qx=[yA,wA,xA,SA,CA,TA,kA,EA,MA,LA,PA,IA,AA,RA,DA];var Ep=864e5;function Mp(r,e){if(r==="Week")return Math.floor((Math.floor(e/Ep)+3)/7);if(r==="Month"||r==="Quarter"||r==="Year"){let t=new Date(e);return r==="Year"?t.getUTCFullYear():r==="Quarter"?t.getUTCFullYear()*4+Math.floor(t.getUTCMonth()/3):t.getUTCFullYear()*12+t.getUTCMonth()}return Math.floor(e/Ep)}var OA={type:"parabolic-sar",title:"Parabolic SAR",shortTitle:"SAR",overlay:true,inputs:[{key:"start",title:"Start",type:"float",defval:.02,min:.001,max:1,step:.001},{key:"increment",title:"Increment",type:"float",defval:.02,min:.001,max:1,step:.001},{key:"maximum",title:"Max value",type:"float",defval:.2,min:.01,max:1,step:.01}],compute:(r,e)=>{let t=I(e,"start",.02),n=I(e,"increment",.02),i=I(e,"maximum",.2),o=r.length,s=new Array(o).fill(Number.NaN),a=new Array(o).fill(null);if(o>=2){let l=r[1].close>=r[0].close,c=l?r[0].low:r[0].high,u=l?r[0].high:r[0].low,d=t;for(let h=1;h<o;h++){let p=r[h];c+=d*(u-c),l?c=Math.min(c,r[h-1].low,h>=2?r[h-2].low:r[h-1].low):c=Math.max(c,r[h-1].high,h>=2?r[h-2].high:r[h-1].high),(l?p.low<c:p.high>c)?(l=!l,c=u,u=l?p.high:p.low,d=t):l&&p.high>u?(u=p.high,d=Math.min(i,d+n)):!l&&p.low<u&&(u=p.low,d=Math.min(i,d+n)),s[h]=c,a[h]=l?z:W;}}return {plots:[{key:"sar",title:"PSAR",values:s,kind:"circles",color:_,colors:a}]}}},e0="Bands",pu="Style",kp=[{on:"band1",mult:"band1Mult",color:"band1Color",fill:"band1Fill",fillColor:"band1FillColor",defMult:1,defOn:true,defColor:z},{on:"band2",mult:"band2Mult",color:"band2Color",fill:"band2Fill",fillColor:"band2FillColor",defMult:2,defOn:false,defColor:ue},{on:"band3",mult:"band3Mult",color:"band3Color",fill:"band3Fill",fillColor:"band3FillColor",defMult:3,defOn:false,defColor:Vs[4]}],NA={type:"vwap",title:"Volume Weighted Average Price",shortTitle:"VWAP",overlay:true,inputs:[{key:"anchor",title:"Period",type:"string",defval:"Day",options:["Day","Week","Month","Quarter","Year"],tooltip:"Where the accumulation resets (UTC periods)"},be("HLC3"),...kp.flatMap((r,e)=>[{key:r.on,title:`Band ${e+1} multiplier`,type:"bool",defval:r.defOn,inline:r.on,group:e0},{key:r.mult,title:"",type:"float",defval:r.defMult,min:.1,max:10,step:.1,inline:r.on,group:e0}]),{...X(Je,"VWAP color"),group:pu},...kp.flatMap((r,e)=>[{...X(r.defColor,`Band ${e+1} color`,r.color),inline:r.color,group:pu},{key:r.fill,title:"Fill",type:"bool",defval:true,inline:r.color,group:pu},{...X(Mn(r.defColor),"",r.fillColor),inline:r.color,group:pu}])],compute:(r,e)=>{let t=F(e,"anchor","Day"),n=ee(r,F(e,"source","HLC3")),i=r.length,o=new Array(i).fill(Number.NaN),s=kp.filter(p=>Sp(e,p.on,p.defOn)).map(p=>({mult:Math.max(0,I(e,p.mult,p.defMult)),color:F(e,p.color,p.defColor),fill:Sp(e,p.fill,true),fillColor:F(e,p.fillColor,Mn(p.defColor)),up:new Array(i).fill(Number.NaN),down:new Array(i).fill(Number.NaN)})),a=Number.NaN,l=0,c=0,u=0;for(let p=0;p<i;p++){let m=r[p],f=Mp(t,m.time);f!==a&&(a=f,l=0,c=0,u=0);let g=m.volume;if(g!=null&&Number.isFinite(g)&&g>0){let v=n[p];l+=v*g,c+=v*v*g,u+=g;}if(u<=0)continue;let b=l/u,y=Math.sqrt(Math.max(0,c/u-b*b));o[p]=b;for(let v of s)v.up[p]=b+v.mult*y,v.down[p]=b-v.mult*y;}let d=[{key:"vwap",title:"VWAP",values:o,color:F(e,"color",Je),width:2}],h=[];return s.forEach((p,m)=>{d.push({key:`up${m}`,title:`Upper ${p.mult}\u03C3`,values:p.up,color:p.color},{key:`down${m}`,title:`Lower ${p.mult}\u03C3`,values:p.down,color:p.color}),p.fill&&h.push({key:`band${m}`,from:`up${m}`,to:`down${m}`,color:p.fillColor});}),{plots:d,bands:h}}},FA={type:"pivot-points",title:"Pivot Points",shortTitle:"Pivots",overlay:true,inputs:[{key:"anchor",title:"Period",type:"string",defval:"Day",options:["Day","Week","Month"]}],compute:(r,e)=>{let t=F(e,"anchor","Day"),n=new Map;for(let l of r){let c=Mp(t,l.time),u=n.get(c);u?(u.high=Math.max(u.high,l.high),u.low=Math.min(u.low,l.low),u.close=l.close):n.set(c,{high:l.high,low:l.low,close:l.close});}let i=r.length,o=()=>new Array(i).fill(Number.NaN),s={p:o(),r1:o(),s1:o(),r2:o(),s2:o(),r3:o(),s3:o()};for(let l=0;l<i;l++){let c=n.get(Mp(t,r[l].time)-1);if(!c)continue;let u=(c.high+c.low+c.close)/3;s.p[l]=u,s.r1[l]=2*u-c.low,s.s1[l]=2*u-c.high,s.r2[l]=u+(c.high-c.low),s.s2[l]=u-(c.high-c.low),s.r3[l]=c.high+2*(u-c.low),s.s3[l]=c.low-2*(c.high-u);}let a=(l,c,u)=>({key:l,title:c,kind:"step",values:s[l],color:u});return {plots:[a("p","P",ue),a("r1","R1",W),a("s1","S1",z),a("r2","R2",W),a("s2","S2",z),a("r3","R3",W),a("s3","S3",z)]}}},VA={type:"52-week-high-low",title:"52 Week High/Low",shortTitle:"52W H/L",overlay:true,inputs:[{key:"weeks",title:"Weeks",type:"int",defval:52,min:1,max:520,step:1}],compute:(r,e)=>{let t=I(e,"weeks",52)*7*Ep,n=r.length,i=new Array(n).fill(Number.NaN),o=new Array(n).fill(Number.NaN),s=[],a=[],l=0;for(let c=0;c<n;c++){let u=r[c];for(;s.length>0&&r[s[s.length-1]].high<=u.high;)s.pop();for(s.push(c);a.length>0&&r[a[a.length-1]].low>=u.low;)a.pop();for(a.push(c);r[l].time<u.time-t;)l+=1;for(;s[0]<l;)s.shift();for(;a[0]<l;)a.shift();i[c]=r[s[0]].high,o[c]=r[a[0]].low;}return {plots:[{key:"high",title:"52W high",values:i,kind:"step",color:z},{key:"low",title:"52W low",values:o,kind:"step",color:W}]}}},_A={type:"zigzag",title:"ZigZag",overlay:true,inputs:[{key:"deviation",title:"Deviation %",type:"float",defval:5,min:.01,max:100,step:.1},{key:"depth",title:"Depth",type:"int",defval:10,min:1,max:500,step:1},X()],compute:(r,e)=>{let t=I(e,"deviation",5)/100,n=I(e,"depth",10),i=[];if(r.length>1){let o=r[1].close>=r[0].close,s=o?{i:0,price:r[0].high}:{i:0,price:r[0].low};for(let a=1;a<r.length;a++){let l=r[a];o?l.high>=s.price?s={i:a,price:l.high}:l.low<=s.price*(1-t)&&a-(i[i.length-1]?.i??-n)>=n&&(i.push(s),o=false,s={i:a,price:l.low}):l.low<=s.price?s={i:a,price:l.low}:l.high>=s.price*(1+t)&&a-(i[i.length-1]?.i??-n)>=n&&(i.push(s),o=true,s={i:a,price:l.high});}i.push(s);}return {plots:[],polylines:[{key:"zigzag",points:i.map(o=>({xloc:"bar_time",x:r[o.i].time,price:o.price})),curved:false,closed:false,lineColor:F(e,"color",_),lineWidth:2,lineStyle:"solid",arrowLeft:false,arrowRight:false}]}}},BA={type:"williams-fractal",title:"Williams Fractal",shortTitle:"Fractals",overlay:true,inputs:[{key:"periods",title:"Periods",type:"int",defval:2,min:1,max:50,step:1}],compute:(r,e)=>{let t=I(e,"periods",2),n=[],i=(o,s,a)=>{let l=s(r[o]);for(let c=o-t;c<=o+t;c++)if(c!==o&&!a(l,s(r[c])))return false;return true};for(let o=t;o<r.length-t;o++)i(o,s=>s.high,(s,a)=>s>=a)&&n.push({time:r[o].time,position:"aboveBar",shape:"triangleup",color:z}),i(o,s=>s.low,(s,a)=>s<=a)&&n.push({time:r[o].time,position:"belowBar",shape:"triangledown",color:W});return {plots:[],markers:n}}},t0=[OA,NA,FA,VA,_A,BA];var HA=[...Yx,...Kx,...jx,...qx,...Zx,...Qx,...t0];function n0(){for(let r of HA)Ln(Fx(r));}var Lp=class{constructor(e,t={},n={}){Ax(),hp(),wp(),n0();let i=zA(e),o=Jr(t.theme),s={currentPriceLine:t.currentPriceLine??true,logScale:t.logScale??false,nativeBackend:t.nativeBackend??"auto",...Hp(t.animations),glow:t.glow??0,upColor:t.upColor??z,downColor:t.downColor??W,priceStyle:t.priceStyle??"candles"},a=t.renderer??ks;if(typeof a!="function")throw new Error("[vela] options.renderer must be a renderer class, e.g. import { LwcRenderer } from 'vela/renderers/lwc'. The 'lwc'/'native' string options were removed.");let l=n.renderer??new a(s),c=n.engines??[],u=n.dataFeed??new br,d={market:{symbol:t.symbol,timeframe:t.timeframe,bars:t.bars,session:t.session,visibleRange:t.visibleRange,data:t.data},live:t.live??false,theme:o,defaultLanguage:t.defaultLanguage??c[0]?.language??"pine",drawings:t.drawings,volume:t.volume??true};this.rendererControl=new lo(l),t.settings&&this.rendererControl.setSettingsVisibility(t.settings),this.dataControl=new fo(u),this.orchestrator=new Qa(i,l,u,c,d,this.dataControl);let h=Vu();Object.keys(h).length>0&&this.rendererControl.set(h),this.panesControl=new el(this.orchestrator),this.drawingsControl=new go(this.orchestrator.drawings),this.marksControl=new bo(this.orchestrator.marks);}registerEngine(e,t){return this.orchestrator.registerEngine(e,t),this}addIndicator(e,t){return this.orchestrator.addIndicator(e,t)}addNativeIndicator(e,t){return this.orchestrator.addNativeIndicator(e,t)}availableNativeIndicators(){return this.orchestrator.availableNativeIndicators()}presentNativeIndicators(){return this.orchestrator.presentNativeIndicators()}indicators(){return this.orchestrator.listIndicators()}runScript(e,t){let n=this.addIndicator(e,t),i=new Set,o=()=>{try{n.remove();}catch{}};return new Promise(s=>{let a=false,l=this.on("script:run",u=>{if(u.id===n.id){if(a){for(let d of i)d(u);return}a=true,c(),s({ok:true,run:u,error:null,onUpdate:d=>(i.add(d),()=>i.delete(d)),remove:()=>{l(),i.clear(),o();}});}}),c=n.on("error",({error:u})=>{a||(a=true,l(),c(),o(),s({ok:false,run:null,error:u,onUpdate:()=>()=>{},remove:()=>{}}));});})}runIndicator(e,t){let n=this.addIndicator(e,t);return new Promise(i=>{let o=n.on("ready",()=>{o(),s(),i({ok:true,handle:n,error:null,context:null});}),s=n.on("error",({error:a})=>{o(),s(),n.context().catch(()=>null).then(l=>{try{n.remove();}catch{}i({ok:false,handle:null,error:a,context:l});});});})}setMarket(e){return this.orchestrator.setMarket(e)}get market(){return this.orchestrator.marketSnapshot()}ready(){return this.orchestrator.ready()}historyComplete(){return this.orchestrator.historyComplete()}inspect(){return this.orchestrator.inspect()}get renderer(){return this.rendererControl}get panes(){return this.panesControl}get data(){return this.dataControl}get drawings(){return this.drawingsControl}get marks(){return this.marksControl}on(e,t){return this.orchestrator.events.on(e,t)}getVisibleRange(){return this.orchestrator.getVisibleRange()}setVisibleRange(e){return this.orchestrator.setVisibleRange(e),this}panBy(e){return this.orchestrator.panBy(e),this}setVisibleRangePreset(e){return this.orchestrator.setVisibleRangePreset(e),this}resize(){this.orchestrator.resize();}setTheme(e){return this.orchestrator.setTheme(Jr(e)),this}destroy(){this.orchestrator.destroy();}};function zA(r){if(typeof r!="string")return r;let e=document.querySelector(r);if(!e)throw new Error(`[vela] container not found for selector "${r}"`);return e}var r0=["symbol","timeframes","style","layout","indicators","actions","undo-redo","alerts","panels","screenshot"];var Hi=new Map,Ls=new Map,Ps=new Map;function $A(r){return Ls.set(r.id,r),()=>{Ls.get(r.id)===r&&Ls.delete(r.id);}}function WA(r){Ls.delete(r);}function GA(){return [...Ls.values()]}var i0=100;function UA(r){return Ps.set(r.id,r),()=>{Ps.get(r.id)===r&&Ps.delete(r.id);}}function YA(r){Ps.delete(r);}function KA(){return [...Ps.values()].sort((r,e)=>(r.order??i0)-(e.order??i0))}var Pp=["indicators","screenshot"],o0=new Set(Pp),XA=new Set(r0);function jA(r){if(o0.has(r))return Hi.get(r)}function qA(r){return XA.has(r.id)&&!o0.has(r.id)?(console.warn(`[vela] widget action "${r.id}": this built-in topbar slot is a stateful control and cannot be overridden \u2014 ignored. Overridable slots: ${Pp.join(", ")}.`),()=>{}):(Hi.set(r.id,r),()=>{Hi.get(r.id)===r&&Hi.delete(r.id);})}function ZA(r){Hi.delete(r);}function JA(r,e){let t=[...Hi.values()].filter(n=>n.target===r);return t.sort((n,i)=>(n.order??0)-(i.order??0)),e?t.filter(n=>!n.when||n.when(e)):t}var Is=new Map;function QA(r){return Is.set(r.id,r),()=>{Is.get(r.id)===r&&Is.delete(r.id);}}function eR(r){Is.delete(r);}function tR(){return [...Is.values()].sort((r,e)=>(r.order??0)-(e.order??0))}var As=new Map;function nR(r){return As.set(r.id,r),()=>{As.get(r.id)===r&&As.delete(r.id);}}function rR(r){As.delete(r);}function iR(){return [...As.values()].sort((r,e)=>(r.order??0)-(e.order??0))}var Rs=new Map;function oR(r){return Rs.set(r.key,r),()=>{Rs.get(r.key)===r&&Rs.delete(r.key);}}function sR(r){Rs.delete(r);}function aR(r){return [...Rs.values()].filter(e=>e.scope===r)}var mu;function lR(r){return mu=r,()=>{mu===r&&(mu=void 0);}}function cR(){return mu}var Ds=new Map;function uR(r,e){return Ds.set(r,e),()=>{Ds.get(r)===e&&Ds.delete(r);}}function dR(r){Ds.delete(r);}function hR(r){return {...Object.fromEntries(Ds),...r}}var s0=280,Ip=200,a0=640;function pR(r,e=Ip,t=a0){let n=Number.isFinite(e)&&e>0?e:Ip,i=Number.isFinite(t)?Math.max(t,n):Number.POSITIVE_INFINITY;return Number.isFinite(r)?Math.round(Math.min(Math.max(r,n),i)):n}function zi(r){let e=r.description?.split("/")[0]?.trim();return e?e.replace(/\s+Perpetual$/i,""):r.ticker.replace(/[-_/]?(USDT|USDC|USD1|USDS|BUSD|USD|EUR|PERP)$/i,"")||r.ticker}function $i(r){let e=r.trim().toUpperCase();return e?`https://crypto-icons.ledger.com/${encodeURIComponent(e)}.png`:void 0}var l0="https://api.binance.com/api/v3",mR="https://api.binance.us/api/v3",Ap="https://fapi.binance.com/fapi/v1",fR="wss://stream.binance.com:9443",gR="wss://stream.binance.us:9443",bR="wss://fstream.binance.com",vR=15e3,yR=2e3,c0={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h",720:"12h",D:"1d",W:"1w",M:"1M"},u0={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"D","1w":"W","1mo":"M","1D":"D","1W":"W","4H":"240",D:"D",W:"W",M:"M"},wR=[1,3,5,15,30,60,120,240,360,480,720],xR={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h",720:"12h"},SR=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function d0(r){return u0[r]??u0[r.toLowerCase()]??r}function Rp(r){let e=r.trim().toUpperCase();return e.endsWith(".P")?{apiSymbol:e.slice(0,-2),isFutures:true}:{apiSymbol:e,isFutures:false}}function h0(r){return r.map(e=>({time:Number(e[0]),open:Number(e[1]),high:Number(e[2]),low:Number(e[3]),close:Number(e[4]),volume:Number(e[5])}))}function CR(r){return {time:Number(r.t),open:Number(r.o),high:Number(r.h),low:Number(r.l),close:Number(r.c),volume:Number(r.v)}}function TR(r){let e=new Map;for(let t of r)e.set(t.time,t);return [...e.values()].sort((t,n)=>t.time-n.time)}function kR(r,e){let t=new Map;for(let n of r){let i=Math.floor(n.time/e)*e,o=t.get(i);o?(o.high=Math.max(o.high,n.high),o.low=Math.min(o.low,n.low),o.close=n.close,o.volume=(o.volume??0)+(n.volume??0)):t.set(i,{time:i,open:n.open,high:n.high,low:n.low,close:n.close,volume:n.volume??0});}return [...t.values()].sort((n,i)=>n.time-i.time)}function ER(r){return wR.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var fu=class{constructor(){this.spotBaseUrl=null;this.spotBaseProbe=null;this.symbolsPromise=null;}info(){return {name:"binance",displayName:"Binance",requiresApiKey:false,supportedTimeframes:SR,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let{apiSymbol:i,isFutures:o}=Rp(e),s=o?Ap:await this.spotBase(),a=d0(t),l=c0[a];if(l)return TR(h0(await this.fetchKlines(s,i,l,n)));let c=/^\d+$/.test(a)?parseInt(a,10):null,u=c!=null?ER(c):null;if(c==null||u==null)return console.warn(`[vela] Binance: timeframe "${t}" is not supported and cannot be aggregated.`),[];let d=c/u,h={...n,limit:n.limit!=null?n.limit*d+d:void 0},p=h0(await this.fetchKlines(s,i,xR[u],h)),m=kR(p,c*6e4);return n.limit!=null&&m.length>n.limit?m.slice(-n.limit):m}catch(i){return console.warn(`[vela] Binance: failed to fetch ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}async getSymbolInfo(e){let{apiSymbol:t,isFutures:n}=Rp(e),i=n?Ap:await this.spotBase(),o=n?`${i}/exchangeInfo`:`${i}/exchangeInfo?symbol=${t}`,a=(await this.json(o).catch(()=>null))?.symbols??[],l=n?a.find(d=>d.symbol===t):a[0];if(!l)return;let c=l.filters?.find(d=>d.filterType==="PRICE_FILTER"),u=c?parseFloat(c.tickSize??"0.01"):.01;return {ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",description:`${l.baseAsset} / ${l.quoteAsset}${n?" Perpetual":""}`,type:n?"futures":"crypto",basecurrency:l.baseAsset,currency:l.quoteAsset,mintick:u,pricescale:Math.round(1/u),timezone:"Etc/UTC",session:"24x7"}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=Promise.all([this.listSpot().catch(()=>[]),this.listFutures().catch(()=>[])]).then(([e,t])=>[...e,...t])),this.symbolsPromise}resolveSymbolIcon(e){return $i(zi(e))}subscribe(e,t,n){let{apiSymbol:i,isFutures:o}=Rp(e),s=c0[d0(t)];return s&&typeof WebSocket<"u"?this.streamKlines(e,t,i,o,s,n):this.pollBars(e,t,n)}streamKlines(e,t,n,i,o,s){let a=false,l=null,c=null,u=null,d=null,h=`${n.toLowerCase()}@kline_${o}`,p=()=>{u&&(clearTimeout(u),u=null);},m=()=>{if(!(a||d)){p(),c&&(clearTimeout(c),c=null);try{l?.close();}catch{}l=null,console.warn(`[vela] Binance: ${e} ${t} stream delivered no data; falling back to polling.`),d=this.pollBars(e,t,s);}},f=async()=>{if(a)return;let g=i?bR:await this.spotWsBase();a||(l=new WebSocket(`${g}/ws/${h}`),u=setTimeout(m,vR),l.onmessage=b=>{if(!(a||d))try{let y=JSON.parse(typeof b.data=="string"?b.data:"");y.k&&(p(),s(CR(y.k)));}catch{}},l.onclose=()=>{!a&&!d&&(c=setTimeout(()=>{f();},yR));},l.onerror=()=>{try{l?.close();}catch{}});};return f(),()=>{a=true,p(),c&&clearTimeout(c),d?.();try{l?.close();}catch{}}}async spotWsBase(){return (await this.spotBase()).includes("binance.us")?gR:fR}pollBars(e,t,n){let i=false,o=null,s=async()=>{if(!i){try{let a=await this.getBars(e,t,{limit:2});for(let l of a)n(l);}catch{}i||(o=setTimeout(()=>{s();},3e3));}};return o=setTimeout(()=>{s();},3e3),()=>{i=true,o&&clearTimeout(o);}}async listSpot(){let e=await this.spotBase();return ((await this.json(`${e}/exchangeInfo`)).symbols??[]).filter(n=>n.status==="TRADING").map(n=>({ticker:n.symbol,description:`${n.baseAsset} / ${n.quoteAsset}`,type:"crypto"}))}async listFutures(){return ((await this.json(`${Ap}/exchangeInfo`)).symbols??[]).filter(t=>t.contractType==="PERPETUAL"&&t.status==="TRADING").map(t=>({ticker:`${t.symbol}.P`,description:`${t.baseAsset} / ${t.quoteAsset} Perpetual`,type:"futures"}))}async fetchKlines(e,t,n,i){if(i.from!=null)return this.paginateForward(e,t,n,i.from,i.to??Date.now(),i.limit);let o=i.limit??500;return o>1e3?this.paginateBackward(e,t,n,o,i.to):this.klinesChunk(e,{symbol:t,interval:n,limit:o,endTime:i.to})}async paginateForward(e,t,n,i,o,s){let a=[],l=i;for(;l<o;){let c=await this.klinesChunk(e,{symbol:t,interval:n,limit:1e3,startTime:l,endTime:o});if(c.length===0||(a.push(...c),l=Number(c[c.length-1][6])+1,c.length<1e3)||s&&a.length>=s)break}return s?a.slice(0,s):a}async paginateBackward(e,t,n,i,o){let s=[],a=i,l=o,c=Math.ceil(i/1e3)+5;for(;a>0&&c-- >0;){let u=Math.min(a,1e3),d=await this.klinesChunk(e,{symbol:t,interval:n,limit:u,endTime:l});if(d.length===0||(s=d.concat(s),a-=d.length,l=Number(d[0][0])-1,d.length<u))break}return s}async klinesChunk(e,t){let n=new URL(`${e}/klines`);n.searchParams.set("symbol",t.symbol),n.searchParams.set("interval",t.interval),t.limit&&n.searchParams.set("limit",String(Math.min(t.limit,1e3))),t.startTime!=null&&n.searchParams.set("startTime",String(t.startTime)),t.endTime!=null&&n.searchParams.set("endTime",String(t.endTime));let i=await this.json(n.toString());return Array.isArray(i)?i.length>0&&!Array.isArray(i[0])?[]:i:[]}spotBase(){return this.spotBaseUrl?Promise.resolve(this.spotBaseUrl):(this.spotBaseProbe||(this.spotBaseProbe=(async()=>{try{for(let e of [l0,mR])try{if((await fetch(`${e}/ping`,{signal:AbortSignal.timeout(5e3)})).ok)return this.spotBaseUrl=e}catch{}return l0}finally{this.spotBaseProbe=null;}})()),this.spotBaseProbe)}async json(e){let t=await fetch(e);if(!t.ok)throw new Error(`Binance HTTP ${t.status} for ${e}`);return t.json()}};var MR="https://api.hyperliquid.xyz/info",LR="wss://api.hyperliquid.xyz/ws",PR=15e3,IR=2e3,p0={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",480:"8h",720:"12h",D:"1d",W:"1w",M:"1M"},m0={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"D","1w":"W","1mo":"M","1D":"D","1W":"W","4H":"240",D:"D",W:"W",M:"M"},AR=[1,3,5,15,30,60,120,240,480,720],RR={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",480:"8h",720:"12h"},DR=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],f0={D:864e5,W:6048e5,M:2592e6};function OR(r){if(f0[r])return f0[r];let e=parseInt(r,10);return Number.isFinite(e)&&e>0?e*6e4:36e5}function g0(r){return m0[r]??m0[r.toLowerCase()]??r}function Dp(r){let e=r.trim();return e.includes("/")?e:e.toUpperCase()}function Op(r){return {time:Number(r.t),open:Number(r.o),high:Number(r.h),low:Number(r.l),close:Number(r.c),volume:Number(r.v)}}function NR(r){let e=new Map;for(let t of r)e.set(t.time,t);return [...e.values()].sort((t,n)=>t.time-n.time)}function FR(r,e){let t=new Map;for(let n of r){let i=Math.floor(n.time/e)*e,o=t.get(i);o?(o.high=Math.max(o.high,n.high),o.low=Math.min(o.low,n.low),o.close=n.close,o.volume=(o.volume??0)+(n.volume??0)):t.set(i,{time:i,open:n.open,high:n.high,low:n.low,close:n.close,volume:n.volume??0});}return [...t.values()].sort((n,i)=>n.time-i.time)}function VR(r){return AR.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var gu=class{constructor(){this.metaPromise=null;this.spotMetaPromise=null;this.symbolsPromise=null;}info(){return {name:"hyperliquid",displayName:"Hyperliquid",requiresApiKey:false,supportedTimeframes:DR,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=Dp(e),o=g0(t),s=p0[o];if(s)return NR((await this.fetchCandles(i,s,OR(o),n)).map(Op));let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?VR(a):null;if(a==null||l==null)return console.warn(`[vela] Hyperliquid: timeframe "${t}" is not supported and cannot be aggregated.`),[];let c=a/l,u={...n,limit:n.limit!=null?n.limit*c+c:void 0},d=(await this.fetchCandles(i,RR[l],l*6e4,u)).map(Op),h=FR(d,a*6e4);return n.limit!=null&&h.length>n.limit?h.slice(-n.limit):h}catch(i){return console.warn(`[vela] Hyperliquid: failed to fetch ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}async getSymbolInfo(e){let t=Dp(e),i=(await this.fetchMeta().catch(()=>null))?.universe?.find(o=>o.name===t);if(i){let o=v0(Math.max(0,6-(i.szDecimals??2)));return b0(e,t,"USD","futures",`${t} / USD Perpetual`,o)}if(t.includes("/")){let o=await this.fetchSpotMeta().catch(()=>null),s=o?.universe?.find(d=>d.name===t),a=s&&o?.tokens?o.tokens[s.tokens?.[0]??-1]:void 0,[l=t,c="USDC"]=t.split("/"),u=v0(Math.max(0,8-(a?.szDecimals??2)));return b0(e,l,c,"crypto",`${l} / ${c}`,u)}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=Promise.all([this.listPerps().catch(()=>[]),this.listSpot().catch(()=>[])]).then(([e,t])=>[...e,...t])),this.symbolsPromise}resolveSymbolIcon(e){return $i(zi(e))}subscribe(e,t,n){let i=Dp(e),o=p0[g0(t)];return o&&typeof WebSocket<"u"?this.streamCandles(e,t,i,o,n):this.pollBars(e,t,n)}async listPerps(){return ((await this.fetchMeta()).universe??[]).filter(t=>!t.isDelisted).map(t=>({ticker:t.name,description:`${t.name} / USD Perpetual`,type:"futures"}))}async listSpot(){let e=await this.fetchSpotMeta(),t=e.tokens??[],n=i=>i!=null?t[i]?.name??null:null;return (e.universe??[]).map(i=>{let o=n(i.tokens?.[0]),s=n(i.tokens?.[1]),a=o&&s?`${o} / ${s}`:i.name;return {ticker:i.name,description:a,type:"crypto"}})}async fetchCandles(e,t,n,i){let o=i.to??Date.now(),s=i.from!=null?i.from:o-((i.limit??500)+2)*n,a=await this.candleSnapshot(e,t,s,o);return i.from==null&&i.limit!=null&&a.length>i.limit?a.slice(-i.limit):a}async candleSnapshot(e,t,n,i){let o=await this.post({type:"candleSnapshot",req:{coin:e,interval:t,startTime:Math.floor(n),endTime:Math.floor(i)}});return Array.isArray(o)?o:[]}streamCandles(e,t,n,i,o){let s=false,a=null,l=null,c=null,u=null,d=null,h=()=>{u&&(clearTimeout(u),u=null);},p=()=>{l&&(clearInterval(l),l=null);},m=()=>{if(!(s||d)){h(),p(),c&&(clearTimeout(c),c=null);try{a?.close();}catch{}a=null,console.warn(`[vela] Hyperliquid: ${e} ${t} stream delivered no data; falling back to polling.`),d=this.pollBars(e,t,o);}},f=()=>{s||d||(a=new WebSocket(LR),u=setTimeout(m,PR),a.onopen=()=>{try{a?.send(JSON.stringify({method:"subscribe",subscription:{type:"candle",coin:n,interval:i}}));}catch{}l=setInterval(()=>{try{a?.send(JSON.stringify({method:"ping"}));}catch{}},3e4);},a.onmessage=g=>{if(!(s||d))try{let b=JSON.parse(typeof g.data=="string"?g.data:"");b.channel==="candle"&&b.data&&b.data.s===n&&(h(),o(Op(b.data)));}catch{}},a.onclose=()=>{p(),!s&&!d&&(c=setTimeout(f,IR));},a.onerror=()=>{try{a?.close();}catch{}});};return f(),()=>{s=true,h(),p(),c&&clearTimeout(c),d?.();try{a?.close();}catch{}}}pollBars(e,t,n){let i=false,o=null,s=async()=>{if(!i){try{let a=await this.getBars(e,t,{limit:2});for(let l of a)n(l);}catch{}i||(o=setTimeout(()=>{s();},3e3));}};return o=setTimeout(()=>{s();},3e3),()=>{i=true,o&&clearTimeout(o);}}fetchMeta(){return this.metaPromise??(this.metaPromise=this.post({type:"meta"}).then(e=>e))}fetchSpotMeta(){return this.spotMetaPromise??(this.spotMetaPromise=this.post({type:"spotMeta"}).then(e=>e))}async post(e){let t=await fetch(MR,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Hyperliquid HTTP ${t.status}`);return t.json()}};function b0(r,e,t,n,i,o){return {ticker:r,tickerid:`HYPERLIQUID:${r}`,prefix:"HYPERLIQUID",description:i,type:n,basecurrency:e,currency:t,mintick:o,pricescale:Math.round(1/o),timezone:"Etc/UTC",session:"24x7"}}function v0(r){return Math.pow(10,-r)}var _R={now:()=>Date.now(),delay:r=>new Promise(e=>setTimeout(e,r))},bu=class{constructor(e,t,n=_R){this.maxConcurrent=e;this.minIntervalMs=t;this.clock=n;this.active=0;this.waiters=[];this.nextStartAt=0;this.pausedUntil=0;}async run(e){await this.acquire();try{return await this.waitForTurn(),await e()}finally{this.release();}}pauseFor(e){e>0&&(this.pausedUntil=Math.max(this.pausedUntil,this.clock.now()+e));}async waitForTurn(){for(;;){let e=this.clock.now(),t=Math.max(this.pausedUntil-e,this.nextStartAt-e);if(t<=0)break;await this.clock.delay(t);}this.nextStartAt=Math.max(this.clock.now(),this.nextStartAt)+this.minIntervalMs;}acquire(){return this.active<this.maxConcurrent?(this.active+=1,Promise.resolve()):new Promise(e=>{this.waiters.push(()=>{this.active+=1,e();});})}release(){this.active-=1;let e=this.waiters.shift();e&&e();}};var Np="https://api.exchange.coinbase.com",BR="wss://ws-feed.exchange.coinbase.com",HR={Accept:"application/json"},zR=15e3,$R=2e3,WR=5e3,vu=300,GR=4,UR=120,YR=4,KR=600,XR=400;function jR(r,e){let t=Number(r.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t*1e3:e}var y0={1:60,5:300,15:900,60:3600,360:21600,D:86400},w0={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"D","1w":"W","1mo":"M","1D":"D","1W":"W","4H":"240",D:"D",W:"W",M:"M"},qR=[1,5,15,60,360,1440],ZR={1:60,5:300,15:900,60:3600,360:21600,1440:86400},JR=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],Fp=864e5;function x0(r){return w0[r]??w0[r.toLowerCase()]??r}function Vp(r){return r.trim().toUpperCase()}function QR(r){return {time:Number(r[0])*1e3,open:Number(r[3]),high:Number(r[2]),low:Number(r[1]),close:Number(r[4]),volume:Number(r[5])}}function _p(r){let e=new Map;for(let t of r)e.set(t.time,t);return [...e.values()].sort((t,n)=>t.time-n.time)}function e2(r,e){return S0(r,t=>Math.floor(t/e)*e)}function t2(r,e){return S0(r,e==="W"?n2:r2)}function S0(r,e){let t=new Map;for(let n of r){let i=e(n.time),o=t.get(i);o?(o.high=Math.max(o.high,n.high),o.low=Math.min(o.low,n.low),o.close=n.close,o.volume=(o.volume??0)+(n.volume??0)):t.set(i,{time:i,open:n.open,high:n.high,low:n.low,close:n.close,volume:n.volume??0});}return [...t.values()].sort((n,i)=>n.time-i.time)}function n2(r){let e=new Date(r),t=(e.getUTCDay()+6)%7;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()-t)}function r2(r){let e=new Date(r);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)}function i2(r){return qR.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}function Bp(r,e){return e!=null&&r.length>e?r.slice(-e):r}var yu=class{constructor(){this.symbolsPromise=null;this.gate=new bu(GR,UR);}info(){return {name:"coinbase",displayName:"Coinbase",requiresApiKey:false,supportedTimeframes:JR,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=Vp(e),o=x0(t),s=y0[o];if(s)return _p(await this.fetchCandles(i,s,n));if(o==="W"||o==="M"){let h=o==="W"?7*Fp:31*Fp,p=n.from!=null?n:{...n,limit:n.limit!=null?Math.ceil(n.limit*h/Fp)+31:void 0},m=await this.fetchCandles(i,86400,p);return Bp(t2(m,o),n.limit)}let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?i2(a):null;if(a==null||l==null)return console.warn(`[vela] Coinbase: timeframe "${t}" is not supported and cannot be aggregated.`),[];let c=a/l,u={...n,limit:n.limit!=null?n.limit*c+c:void 0},d=await this.fetchCandles(i,ZR[l],u);return Bp(e2(d,a*6e4),n.limit)}catch(i){return console.warn(`[vela] Coinbase: failed to fetch ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}async getSymbolInfo(e){let t=Vp(e),n=await this.json(`${Np}/products/${t}`).catch(()=>null);if(!n||!n.id)return;let i=n.quote_increment!=null?parseFloat(n.quote_increment):.01,o=i>0?i:.01;return {ticker:e,tickerid:`COINBASE:${e}`,prefix:"COINBASE",description:`${n.base_currency} / ${n.quote_currency}`,type:"crypto",basecurrency:n.base_currency,currency:n.quote_currency,mintick:o,pricescale:Math.round(1/o),timezone:"Etc/UTC",session:"24x7"}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=this.fetchProducts().then(e=>e.filter(t=>t.status==="online"&&!t.trading_disabled).map(t=>({ticker:t.id,description:`${t.base_currency} / ${t.quote_currency}`,type:"crypto"}))).catch(()=>[])),this.symbolsPromise}resolveSymbolIcon(e){return $i(zi(e))}subscribe(e,t,n){let i=y0[x0(t)];return i&&typeof WebSocket<"u"?this.streamTicker(e,t,i,n):this.pollBars(e,t,n)}async fetchProducts(){let e=await this.json(`${Np}/products`);return Array.isArray(e)?e:[]}async fetchCandles(e,t,n){return n.from!=null?this.paginateForward(e,t,n.from,n.to??Date.now(),n.limit):this.paginateBackward(e,t,n.limit??500,n.to??Date.now())}async paginateBackward(e,t,n,i){let o=t*1e3,s=[],a=n,l=i,c=Math.ceil(n/vu)+4;for(;a>0&&c-- >0;){let u=Math.min(a,vu),d=l-u*o,h=await this.candlesChunk(e,t,d,l);if(h.length===0||(s=h.concat(s),a-=h.length,l=h[0].time-1,h.length<u))break}return Bp(_p(s),n)}async paginateForward(e,t,n,i,o){let s=t*1e3,a=[],l=n,c=Math.ceil((i-n)/(vu*s))+4;for(;l<i&&c-- >0;){let d=Math.min(l+vu*s,i),h=await this.candlesChunk(e,t,l,d);if(h.length>0&&a.push(...h),l=d,o!=null&&a.length>=o)break}let u=_p(a);return o!=null?u.slice(0,o):u}async candlesChunk(e,t,n,i){let o=new URL(`${Np}/products/${e}/candles`);o.searchParams.set("granularity",String(t)),o.searchParams.set("start",String(Math.floor(n/1e3))),o.searchParams.set("end",String(Math.floor(i/1e3)));let s=await this.json(o.toString());return !Array.isArray(s)||s.length>0&&!Array.isArray(s[0])?[]:s.map(QR).sort((a,l)=>a.time-l.time)}streamTicker(e,t,n,i){let o=Vp(e),s=n*1e3,a=T=>Math.floor(T/s)*s,l=false,c=null,u=null,d=null,h=null,p=null,m=null,f=()=>{d&&(clearTimeout(d),d=null);},g=()=>{h&&(clearInterval(h),h=null);},b=()=>{m&&i({...m});},y=async T=>{try{let k=await this.getBars(e,t,{limit:2});if(l||k.length===0)return;T&&k.length>=2&&i(k[k.length-2]);let x=k[k.length-1];m=m&&m.time===x.time?{...x,high:Math.max(x.high,m.high),low:Math.min(x.low,m.low),close:m.close}:{...x},b();}catch{}},v=(T,k)=>{let x=Number(T);if(!Number.isFinite(x))return;let M=a(k);!m||M>m.time?(m={time:M,open:x,high:x,low:x,close:x,volume:0},b(),y(false)):M===m.time&&(m={...m,close:x,high:Math.max(m.high,x),low:Math.min(m.low,x)},b());},S=()=>{if(!(l||p)){f(),g(),u&&(clearTimeout(u),u=null);try{c?.close();}catch{}c=null,console.warn(`[vela] Coinbase: ${e} ${t} stream delivered no data; falling back to polling.`),p=this.pollBars(e,t,i);}},E=()=>{l||p||(c=new WebSocket(BR),d=setTimeout(S,zR),c.onopen=()=>{try{c?.send(JSON.stringify({type:"subscribe",product_ids:[o],channels:["ticker"]}));}catch{}y(false),h=setInterval(()=>{y(false);},WR);},c.onmessage=T=>{if(!(l||p))try{let k=JSON.parse(typeof T.data=="string"?T.data:"");k.type==="ticker"&&k.product_id===o&&k.price!=null&&(f(),v(k.price,k.time?Date.parse(k.time):Date.now()));}catch{}},c.onclose=()=>{g(),!l&&!p&&(u=setTimeout(E,$R));},c.onerror=()=>{try{c?.close();}catch{}});};return E(),()=>{l=true,f(),g(),u&&clearTimeout(u),p?.();try{c?.close();}catch{}}}pollBars(e,t,n){let i=false,o=null,s=async()=>{if(!i){try{let a=await this.getBars(e,t,{limit:2});for(let l of a)n(l);}catch{}i||(o=setTimeout(()=>{s();},3e3));}};return o=setTimeout(()=>{s();},3e3),()=>{i=true,o&&clearTimeout(o);}}async json(e){return (await this.request(e)).json()}async request(e){for(let t=0;;t+=1){let n=await this.gate.run(()=>fetch(e,{headers:HR}));if(n.status===429&&t<YR){let i=KR*2**t+Math.random()*XR;this.gate.pauseFor(Math.max(jR(n,0),i));continue}if(!n.ok)throw new Error(`Coinbase HTTP ${n.status} for ${e}`);return n}}};
|
|
1032
|
-
exports.ACCENT=Ke;exports.ACCENT_BRIGHT
|
|
1031
|
+
`;function qP(r){let e=r.getElementById(gx);e||(e=r.createElement("style"),e.id=gx,r.head.appendChild(e)),e.textContent=jP;}function np(r){return lt(r)?"#ffffff":"#000000"}function rp(r,e){let t=lt(e);r.style.color=t?"#ffffff":"#000000",r.style.setProperty("--vela-attr-shadow",t?"rgba(0,0,0,0.45)":"rgba(255,255,255,0.55)");}function bx(r,e,t){let n=r.createElement("div");return n.className="vela-attribution-custom",Object.assign(n.style,{position:"absolute",zIndex:"6",pointerEvents:"auto",display:"flex",alignItems:"center",lineHeight:"1"}),n.style.color=np(t),n.innerHTML=e,n.dataset.velaScreenshot="1",n}function vx(r,e){qP(r);let t=r.createElement("a");t.className="vela-attribution",t.href=XP,t.target="_blank",t.rel="noopener",t.title="Charting by Vela",t.setAttribute("aria-label","Charting by Vela"),Object.assign(t.style,{position:"absolute",zIndex:"6",pointerEvents:"auto",cursor:"pointer"}),rp(t,e),t.dataset.velaScreenshot="1";let n=r.createElement("span");n.className="vela-attr-symbol",n.setAttribute("aria-hidden","true"),n.innerHTML=mx;let i=r.createElement("span");return i.className="vela-attr-wordmark",i.innerHTML=fx,t.append(n,i),t}function iu(r){if(!r||r==="transparent")return false;let e=/rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*([\d.]+)\s*\)/.exec(r);return e?parseFloat(e[1])>.001:true}function yx(r,e,t){let n=r.borderTopLeftRadius,i=parseFloat(n)||0,o=n.endsWith("%")?i/100*Math.min(e,t):i;return Math.max(0,Math.min(o,Math.min(e,t)/2))}function ip(r,e,t,n,i,o){r.beginPath(),o>0&&typeof r.roundRect=="function"?r.roundRect(e,t,n,i,o):r.rect(e,t,n,i);}function ZP(r){try{let e=r.ownerDocument.createElement("canvas");e.width=1,e.height=1;let t=e.getContext("2d");return t?(t.drawImage(r,0,0,1,1),e.toDataURL(),!0):!1}catch{return false}}function ou(r,e,t){let n=e.ownerDocument.defaultView;if(!n)return;r.save(),r.scale(t.dpr,t.dpr);let i=(c,u,d)=>{let h=c.textContent?.replace(/\s+/g," ").trim();if(!h)return;let p=c.ownerDocument.createRange();p.selectNodeContents(c);let m=p.getBoundingClientRect();m.width<=0||m.height<=0||(r.globalAlpha=d,r.fillStyle=u.color,r.font=`${u.fontStyle} ${u.fontWeight} ${u.fontSize} ${u.fontFamily}`,r.textBaseline="middle",r.textAlign="left",r.fillText(h,m.left-t.left,m.top-t.top+m.height/2));},o=(c,u,d)=>{if(!c.complete||c.naturalWidth<=0||!ZP(c))return;let h=c.getBoundingClientRect();if(h.width<=0||h.height<=0)return;let p=h.left-t.left,m=h.top-t.top;r.save(),r.globalAlpha=d,ip(r,p,m,h.width,h.height,yx(u,h.width,h.height)),r.clip(),r.drawImage(c,p,m,h.width,h.height),r.restore();},s=(c,u)=>{for(let d of c.children){if(d.hasAttribute("transform"))continue;let h=d.tagName.toLowerCase();if(h==="g"){s(d,u);continue}let p=b=>parseFloat(d.getAttribute(b)??"0")||0,m=null;if(h==="path"){let b=d.getAttribute("d");b&&(m=new Path2D(b));}else if(h==="circle")m=new Path2D,m.arc(p("cx"),p("cy"),p("r"),0,Math.PI*2);else if(h==="ellipse")m=new Path2D,m.ellipse(p("cx"),p("cy"),p("rx"),p("ry"),0,0,Math.PI*2);else if(h==="rect")m=new Path2D,m.rect(p("x"),p("y"),p("width"),p("height"));else if(h==="line")m=new Path2D,m.moveTo(p("x1"),p("y1")),m.lineTo(p("x2"),p("y2"));else if(h==="polyline"||h==="polygon"){let b=(d.getAttribute("points")??"").trim().split(/[\s,]+/).map(Number);if(b.length<4||b.some(Number.isNaN))continue;m=new Path2D,m.moveTo(b[0],b[1]);for(let y=2;y+1<b.length;y+=2)m.lineTo(b[y],b[y+1]);h==="polygon"&&m.closePath();}if(!m)continue;let f=n.getComputedStyle(d);f.fill&&f.fill!=="none"&&iu(f.fill)&&(r.globalAlpha=u*(parseFloat(f.fillOpacity)||1),r.fillStyle=f.fill,r.fill(m));let g=parseFloat(f.strokeWidth)||0;f.stroke&&f.stroke!=="none"&&iu(f.stroke)&&g>0&&(r.globalAlpha=u*(parseFloat(f.strokeOpacity)||1),r.strokeStyle=f.stroke,r.lineWidth=g,(f.strokeLinecap==="round"||f.strokeLinecap==="square"||f.strokeLinecap==="butt")&&(r.lineCap=f.strokeLinecap),(f.strokeLinejoin==="round"||f.strokeLinejoin==="bevel"||f.strokeLinejoin==="miter")&&(r.lineJoin=f.strokeLinejoin),r.stroke(m));}},a=(c,u)=>{let d=c.getBoundingClientRect();if(d.width<=0||d.height<=0)return;let h=n.getComputedStyle(c);if(h.display==="none"||h.visibility==="hidden")return;let p=u*(parseFloat(h.opacity)||1);if(p<=.001)return;let m=c.viewBox.baseVal,f=m&&m.width>0?m.width:d.width,g=m&&m.height>0?m.height:d.height;r.save(),r.translate(d.left-t.left,d.top-t.top),r.scale(d.width/f,d.height/g),m&&r.translate(-m.x,-m.y),s(c,p),r.restore();},l=(c,u)=>{let d=n.getComputedStyle(c);if(d.display==="none"||d.visibility==="hidden")return;let h=u*(parseFloat(d.opacity)||1);if(h<=.001)return;let p=c.getBoundingClientRect();if(p.width>0&&p.height>0){let m=p.left-t.left,f=p.top-t.top,g=yx(d,p.width,p.height);iu(d.backgroundColor)&&(r.globalAlpha=h,r.fillStyle=d.backgroundColor,ip(r,m,f,p.width,p.height,g),r.fill());let b=parseFloat(d.borderTopWidth)||0;b>0&&d.borderTopStyle!=="none"&&iu(d.borderTopColor)&&(r.globalAlpha=h,r.strokeStyle=d.borderTopColor,r.lineWidth=b,ip(r,m+b/2,f+b/2,p.width-b,p.height-b,Math.max(0,g-b/2)),r.stroke());}for(let m of c.childNodes)m.nodeType===3?i(m,d,h):m instanceof n.HTMLImageElement?o(m,n.getComputedStyle(m),h):m instanceof n.SVGSVGElement?a(m,h):m instanceof n.HTMLElement&&l(m,h);};e instanceof n.HTMLElement&&l(e,1),r.restore();}function wx(r,e,t,n,i){let o=Math.max(0,e),s=Math.min(r.length-1,t);if(o>s)return null;let a=1/0,l=-1/0;for(let v=o;v<=s;v+=1){let S=r[v];S.volume!=null&&S.volume>0&&(S.low<a&&(a=S.low),S.high>l&&(l=S.high));}if(!Number.isFinite(a))return null;let c=l>a?Math.max(1,Math.round(n)):1,u=l>a?(l-a)/c:1,d=Array.from({length:c},(v,S)=>({price:a+S*u,up:0,down:0}));for(let v=o;v<=s;v+=1){let S=r[v],E=S.volume;if(!(E!=null&&E>0))continue;let T=S.close>=S.open?"up":"down",k=S.high-S.low;if(k<=0){let w=op(Math.floor((S.low-a)/u),c);d[w][T]+=E;continue}let x=op(Math.floor((S.low-a)/u),c),L=op(Math.floor((S.high-a)/u-1e-9),c);for(let w=x;w<=L;w+=1){let M=a+w*u,P=Math.min(S.high,M+u)-Math.max(S.low,M);P>0&&(d[w][T]+=E*P/k);}}let h=0,p=0,m=0;for(let v=0;v<c;v+=1){let S=d[v].up+d[v].down;h+=S,S>p&&(p=S,m=v);}if(p<=0)return null;let f=h*Math.min(1,Math.max(0,i)),g=m,b=m,y=p;for(;y<f&&(g>0||b<c-1);){let v=g>0?d[g-1].up+d[g-1].down:-1,S=b<c-1?d[b+1].up+d[b+1].down:-1;S>v?(b+=1,y+=S):(g-=1,y+=v);}return {rows:d,rowH:u,min:a,maxTotal:p,poc:m,vaFrom:g,vaTo:b}}function op(r,e){return r<0?0:r>=e?e-1:r}function xx(r,e,t,n){let{rows:i,rowH:o,maxTotal:s,poc:a,vaFrom:l,vaTo:c}=e,{rightX:u,maxW:d,yOf:h}=t;if(!(s<=0||d<=0)){for(let p=0;p<i.length;p+=1){let m=i[p],f=m.up+m.down;if(f<=0)continue;let g=h(m.price+o),b=Math.max(1,h(m.price)-g-1),y=f/s*d,v=m.up/f*y;r.globalAlpha=p>=l&&p<=c?.62:.28,v>0&&(r.fillStyle=n.upColor,r.fillRect(u-y,g,v,b)),y-v>0&&(r.fillStyle=n.downColor,r.fillRect(u-y+v,g,y-v,b));}if(n.showPoc){let p=i[a],m=h(p.price+o),f=Math.max(1,h(p.price)-m-1);r.globalAlpha=.9,r.strokeStyle=n.pocColor,r.lineWidth=1,r.strokeRect(u-d+.5,m+.5,d-1,f);}r.globalAlpha=1;}}var su=class{constructor(){this.canvas=null;this.ctx=null;this.memoKey="";this.memo=null;}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}destroy(){this.canvas=null,this.ctx=null,this.memoKey="",this.memo=null;}render(e){let t=this.ctx,n=this.canvas;if(!t||!n)return;let{bars:i,data:o,visible:s,coords:a,scale:l,bounds:c,theme:u}=e,d=a.dpr;if(t.setTransform(d,0,0,d,0,0),t.clearRect(0,0,n.width/d,n.height/d),!o||!s||i.length===0||c.height<=0)return;let h=a.visibleLogicalRange(),p=Math.max(0,Math.floor(h.from)),m=Math.min(i.length-1,Math.ceil(h.to));if(p>m)return;let f=i[m],g=`${p}:${m}:${i.length}:${f.high}:${f.low}:${f.close}:${f.volume??0}:${o.rows}:${o.valueAreaFrac}`;g!==this.memoKey&&(this.memoKey=g,this.memo=wx(i,p,m,o.rows,o.valueAreaFrac));let b=this.memo;b&&(t.save(),t.beginPath(),t.rect(0,c.top,a.width,c.height),t.clip(),xx(t,b,{rightX:a.width,maxW:a.width*o.widthFrac,yOf:y=>a.priceToY(y,l,c)},{upColor:o.upColor,downColor:o.downColor,showPoc:o.showPoc,pocColor:u.textColor}),t.restore());}};var He="price",nI=8,rI="rgba(0,0,0,0)",au=64,iI=56,Lx=26,Hi=22,ks=26,sp=24,oI=5,sI="0 2px 8px rgba(0,0,0,0.4)",aI=12,Dx=12,Mx=au+Dx,ap=Hi+14,lI=120,cI=2,Px=6,Ix=350,uI=.02,dI=220;function lp(){return typeof performance<"u"?performance.now():Date.now()}var hI=.004,pI=.2,mI=4,Es=class{constructor(e){this.capabilities=yy;this.surfaceBackground=Yt.background;this.surfaceTextColor=Yt.textColor;this.toolbarGutter=0;this.mountContainer=null;this.userDrawings=null;this.backdropRenderer=new nu;this.volumeRenderer=new ru;this.extLayers=[];this.layerOrderSig="";this.attributionEl=null;this.attributionEnabled=true;this.attributionHtml=null;this.vpvrRenderer=new su;this.resizeObserver=null;this.dprMedia=null;this.plotDeviceSize=null;this.coords=new xc;this.scene=new Mc;this.backendMode="auto";this.glowAmount=0;this.chrome=new Vc;this.indicatorSlices=new Qc;this.labelTooltip=null;this.markPopover=null;this.marksExpandedBy="hover";this.markPulseRaf=null;this.markClickCbs=new Set;this.crosshairLayer=new Bc;this.hostClock=null;this.ownClock=null;this.countdownUnsub=null;this.symbolPicker=null;this.indicatorTitlesOn=true;this.indicatorValuesOn=true;this.legendActionsProvider=null;this.legendCalloutsProvider=null;this.legendOverviewAction=null;this.keyboard=null;this.keyboardEnabled=true;this.historyChordsEnabled=true;this.liveRegion=null;this.animZoom=new Yn(70);this.animPan=new Yn(110);this.animScroll=new Yn(130);this.animAutoscale=new Yn(80);this.animLiveBar=new Yn(90,0);this.candleUp=z;this.candleDown=W;this.intro={style:"settle",duration:650};this.introOnStyle="settle";this.introPlayed=false;this.introRaf=null;this.loadingEl=null;this.modelAlpha=1;this.targetBarSpacing=0;this.zoomAnchorLogical=0;this.zoomAnchorX=0;this.zoomAnchorMode="right";this.panVelocity=0;this.bars=[];this.didInitialFit=false;this.paintedData=false;this.skeletonClockMs=0;this.candleBodyAlpha=1;this.candleStructureAlpha=1;this.lastPointer=null;this.volumeActive=false;this.volumeHidden=false;this.vpvrActive=false;this.vpvrHidden=false;this.liveEaseTime=0;this.liveEaseHigh=0;this.liveEaseLow=0;this.liveEaseClose=0;this.axisDragEnabled=true;this.scaleDragHolder=null;this.scaleDragHeight=0;this.scaleDragStart=null;this.paneResizeEnabled=true;this.resizeAbove=null;this.resizeBelow=null;this.resizeSplitStart=null;this.hoverSeparatorY=null;this.maximizedPaneId=null;this.rightAxisW=au;this.paneControls=null;this.axisScaleButtons=null;this.paneActionCbs=new Set;this.hoverLogical=null;this.settingsDialog=null;this.hiddenSettings=[];this.dialogHost=null;this.settingsButton=null;this.settingsEnabled=false;this.scrollButton=null;this.pointerNearScrollBtn=false;this.scrollTargetRO=null;this.scrollBtnBottomPx=ap;this.scrollBtnRightPx=Mx;this.layoutMode="desktop";this.viewportCbs=new Set;this.crosshairCbs=new Set;this.chartTypeSettingsCbs=new Set;this.configChangedCbs=new Set;this.themeSelectCbs=new Set;this.factoryConfig=null;this.hostSettingsSections=[];this.clickCbs=new Set;this.axisLongPressCbs=new Set;this.inputChangeCbs=new Set;this.removeIndicatorCbs=new Set;this.toggleVisibleCbs=new Set;this.moveIndicatorCbs=new Set;this.priceStyleCbs=new Set;this.name="native";this.features=["logScale","currentPriceLine","priceLabel","countdown","upColor","downColor","glow","animZoom","animPan","animScroll","animAutoscale","animLiveBar","intro","zoomAnchor","axisDrag","paneResize","candleZOrder","candleVisible","seriesOrder","highlights","sessionZones","gridlines","axisLabels","scaleMode","invertScale","paneScales","autoScale","timezone","keyboard","historyChords","priceStyle","priceBaseline","baselinePrice","settings","attribution","dialogHost","tradeMarkers","marks","indicatorTitles","indicatorValues"];this.onScrollProximityMove=e=>{if(!this.scrollButton||!this.plot)return;let t=this.plot.getBoundingClientRect(),n=t.width-this.scrollBtnRightPx-ks/2,i=t.height-this.scrollBtnBottomPx-ks/2,o=Math.hypot(e.clientX-t.left-n,e.clientY-t.top-i)<=lI;o!==this.pointerNearScrollBtn&&(this.pointerNearScrollBtn=o,this.updateScrollToRealtimeButton());};this.onScrollProximityLeave=()=>{this.pointerNearScrollBtn&&(this.pointerNearScrollBtn=false,this.updateScrollToRealtimeButton());};this.onDprChange=()=>{this.watchDpr(),this.resize();};this.externalCross=null;this.snapMode="off";e&&(this.scene.showPriceLine=e.currentPriceLine,this.scene.logScale=e.logScale,this.backendMode=e.nativeBackend,this.animZoom.set(e.animZoom),this.animPan.set(e.animPan),this.animScroll.set(e.animScroll),this.animAutoscale.set(e.animAutoscale),this.animLiveBar.set(e.animLiveBar),this.setIntro(e.animIntro),this.glowAmount=e.glow,this.candleUp=e.upColor,this.candleDown=e.downColor,this.scene.priceStyle=e.priceStyle,this.scene.basePainting=hh(e.priceStyle),this.scene.candleOverride=bc(e.priceStyle,this.scene.style.chartTypes)),this.theme=this.deriveTheme(Yt);}applyFeature(e,t){switch(e){case "logScale":if(t&&typeof t=="object"){let n=t;this.setPaneLog(n.pane??He,!!n.value);return}this.scene.logScale=!!t;break;case "currentPriceLine":this.scene.showPriceLine=!!t;break;case "priceLabel":this.scene.showPriceLabel=!!t;break;case "countdown":this.scene.showCountdown=!!t,this.syncCountdownTimer();break;case "upColor":this.candleUp=String(t),this.theme&&(this.theme=this.deriveTheme(this.theme));break;case "downColor":this.candleDown=String(t),this.theme&&(this.theme=this.deriveTheme(this.theme));break;case "glow":this.glowAmount=Number(t)||0,this.backend&&"glow"in this.backend&&(this.backend.glow=this.glowAmount);break;case "animZoom":this.animZoom.set(_t(t,70));return;case "animPan":{let n=_t(t,110);this.animPan.set(n),this.animScroll.toggle(n>0);return}case "animScroll":this.animScroll.set(_t(t,130));return;case "animAutoscale":this.animAutoscale.set(_t(t,80));return;case "animLiveBar":this.animLiveBar.set(Cu(t));return;case "intro":{this.setIntro(Tu(t)),this.intro.style&&this.playIntro();return}case "zoomAnchor":this.zoomAnchorMode=t==="right"?"right":"cursor",this.input&&(this.input.rightEdgeZoom=this.zoomAnchorMode==="right");return;case "axisDrag":this.axisDragEnabled=!!t,this.input&&(this.input.axisDrag=this.axisDragEnabled);return;case "paneResize":this.paneResizeEnabled=!!t,this.input&&(this.input.paneResize=this.paneResizeEnabled);return;case "candleZOrder":this.scene.candleZ=Number(t)||0;break;case "candleVisible":this.scene.candlesHidden=t===false;break;case "seriesOrder":this.applySeriesOrder(t);break;case "highlights":this.scene.highlights=vI(t);break;case "sessionZones":this.scene.sessionZones=yI(t);break;case "gridlines":this.scene.showGrid=!!t;break;case "axisLabels":this.scene.showAxisLabels=!!t;break;case "scaleMode":if(t&&typeof t=="object"){let n=t;this.setPaneScaleMode(n.pane??He,Ax(n.mode));return}this.scene.scaleMode=Ax(t);break;case "invertScale":if(t&&typeof t=="object"){let n=t;this.setPaneInvert(n.pane??He,!!n.value);return}this.scene.invertScale=!!t;break;case "autoScale":for(let n of this.scene.panes.values())n.manualScale=t?null:{...n.scale};break;case "timezone":this.scene.timezone=typeof t=="string"&&t?t:"UTC";break;case "priceStyle":this.setPriceStyle(wI(t)?t:"candles");break;case "priceBaseline":this.scene.baselineValue=t==null?null:Number(t);break;case "tradeMarkers":this.scene.tradeMarkers=Wy(this.scene.tradeMarkers,t);break;case "marks":this.scene.marks=qy(this.scene.marks,t),this.markPopover?.close();break;case "keyboard":this.setKeyboardEnabled(!!t);return;case "historyChords":this.historyChordsEnabled=!!t,this.userDrawings&&(this.userDrawings.historyChords=this.historyChordsEnabled);return;case "settings":this.setSettingsEnabled(!!t);return;case "indicatorTitles":this.indicatorTitlesOn=t!==false,this.inputsUI?.setTitlesVisible(this.indicatorTitlesOn);return;case "indicatorValues":this.indicatorValuesOn=t!==false,this.inputsUI?.setValuesVisible(this.indicatorValuesOn);return;case "attribution":this.attributionHtml=typeof t=="string"&&t.trim()?t:null,this.attributionEnabled=this.attributionHtml!==null||!!t,this.rebuildAttribution();return;case "dialogHost":this.dialogHost=t instanceof HTMLElement?t:null,this.settingsDialog?.close(),this.settingsDialog=null,this.inputsUI?.setDialogHost(this.dialogHost);return;default:return}this.scheduler?.invalidate(4);}readFeature(e){switch(e){case "logScale":return this.scene.logScale;case "currentPriceLine":return this.scene.showPriceLine;case "priceLabel":return this.scene.showPriceLabel;case "countdown":return this.scene.showCountdown;case "upColor":return this.candleUp;case "downColor":return this.candleDown;case "glow":return this.glowAmount;case "animZoom":return this.animZoom.tau;case "animPan":return this.animPan.tau;case "animScroll":return this.animScroll.tau;case "animAutoscale":return this.animAutoscale.tau;case "animLiveBar":return this.animLiveBar.tau;case "intro":return this.intro.style;case "zoomAnchor":return this.zoomAnchorMode;case "axisDrag":return this.input?this.input.axisDrag:this.axisDragEnabled;case "paneResize":return this.input?this.input.paneResize:this.paneResizeEnabled;case "candleZOrder":return this.scene.candleZ;case "candleVisible":return !this.scene.candlesHidden;case "seriesOrder":return this.scene.indicatorZOrder();case "highlights":return this.scene.highlights;case "sessionZones":return this.scene.sessionZones;case "gridlines":return this.scene.showGrid;case "axisLabels":return this.scene.showAxisLabels;case "scaleMode":return this.scene.scaleMode;case "invertScale":return this.scene.invertScale;case "paneScales":return this.paneScaleInfos();case "autoScale":{let t=this.scene.orderedPanes().find(n=>n.kind==="price");return t?t.manualScale==null:true}case "timezone":return this.scene.timezone;case "priceStyle":return this.scene.priceStyle;case "priceBaseline":return this.scene.baselineValue;case "baselinePrice":{let t=this.scene.panes.get(He);return t?this.scene.baselinePriceFor(t.scale):this.scene.baselineValue}case "tradeMarkers":return {...this.scene.tradeMarkers,colors:{...this.scene.tradeMarkers.colors}};case "marks":return {visible:this.scene.marks.visible,groups:{...this.scene.marks.groups}};case "keyboard":return this.keyboardEnabled;case "historyChords":return this.historyChordsEnabled;case "settings":return this.settingsEnabled;case "indicatorTitles":return this.indicatorTitlesOn;case "indicatorValues":return this.indicatorValuesOn;case "attribution":return this.attributionHtml??this.attributionEnabled;case "dialogHost":return this.dialogHost??void 0;default:return}}setNativeData(e,t){e==="volume"?(this.scene.volumeLayer=t??null,this.scheduler?.invalidate(3)):e==="vpvr"?(this.scene.vpvrLayer=t??null,this.scheduler?.invalidate(3)):e.endsWith("-pending")?(this.scene.nativePending.set(e.slice(0,-8),t??[]),this.scheduler?.invalidate(3)):(this.scene.nativeData.set(e,t),this.scheduler?.invalidate(3));}setIndicatorStatus(e,t){this.inputsUI.setStatus(e.id,t);}setLoading(e){if(!e||!this.wrapper){this.loadingEl?.remove(),this.loadingEl=null;return}if(this.loadingEl)return;let t=this.wrapper.ownerDocument,n=t.createElement("div");n.className="vela-loading",Object.assign(n.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",gap:"7px",pointerEvents:"none"});for(let i=0;i<3;i+=1){let o=t.createElement("span");Object.assign(o.style,{width:"7px",height:"7px",borderRadius:"50%",background:this.chromeTheme().textColor,opacity:"0.15"}),o.animate([{opacity:.12},{opacity:.55}],{duration:800,iterations:1/0,direction:"alternate",easing:"ease-in-out",delay:-i*260}),n.appendChild(o);}this.wrapper.appendChild(n),this.loadingEl=n;}setPricePrecision(e){let t=typeof e=="number"&&e>0?e:void 0;t!==this.scene.priceMintick&&(this.scene.priceMintick=t,this.scheduler?.invalidate(4));}getConfig(){let e=this.scene.style,t=Object.fromEntries(Object.entries(e.chartTypes).map(([i,o])=>[i,{...o}])),n=this.theme;return {version:dh,chartTypes:t,layout:{background:n.background,textColor:n.textColor,fontFamily:n.fontFamily,fontSize:e.fontSize},grid:{vertLines:{visible:e.gridVert.visible,color:e.gridVert.color??n.gridColor},horzLines:{visible:e.gridHorz.visible,color:e.gridHorz.color??n.gridColor}},crosshair:{color:e.crosshair.color??n.textColor,width:e.crosshair.width,style:e.crosshair.style,opacity:e.crosshair.opacity,labelBackground:e.crosshair.labelBackground??n.textColor},priceScale:{mode:this.scene.scaleMode,log:this.scene.logScale,invert:this.scene.invertScale,borderColor:e.borderColor??n.borderColor,labelsVisible:this.scene.showAxisLabels,currentPriceLine:this.scene.showPriceLine,priceLabel:this.scene.showPriceLabel,countdown:this.scene.showCountdown,animateLastPrice:this.animLiveBar.on},animations:{zoom:this.animZoom.on,pan:this.animPan.on,autoscale:this.animAutoscale.on,intro:this.intro.style!==false},panes:{separatorColor:e.separatorColor??n.borderColor},trades:{visible:this.scene.tradeMarkers.visible,labels:this.scene.tradeMarkers.labels,qty:this.scene.tradeMarkers.qty,longColor:this.scene.tradeMarkers.colors.long,shortColor:this.scene.tradeMarkers.colors.short,exitColor:this.scene.tradeMarkers.colors.exit},timeScale:{timezone:this.scene.timezone},marks:{visible:this.scene.marks.visible,groups:{...this.scene.marks.groups}},candles:{upColor:this.candleUp,downColor:this.candleDown,bodyVisible:e.candle.bodyVisible,borderVisible:e.candle.borderVisible,borderUpColor:e.candle.borderUpColor??this.candleUp,borderDownColor:e.candle.borderDownColor??this.candleDown,wickVisible:e.candle.wickVisible,wickUpColor:e.candle.wickUpColor??this.candleUp,wickDownColor:e.candle.wickDownColor??this.candleDown},bars:{upColor:e.bars.upColor??this.candleUp,downColor:e.bars.downColor??this.candleDown},line:{color:e.line.color??this.candleUp,width:e.line.width},stacking:{candles:this.scene.candleZ,series:Object.fromEntries(this.scene.indicatorZOrder().map(({id:i,z:o})=>[i,o]))},area:(()=>{let i=e.area.lineColor??this.candleUp;return {lineColor:i,width:e.area.width,topColor:e.area.topColor??i,bottomColor:e.area.bottomColor??rI}})(),baseline:(()=>{let i=e.baseline.topLineColor??Ei,o=e.baseline.bottomLineColor??Li;return {topLineColor:i,bottomLineColor:o,topFillColor:e.baseline.topFillColor??q(i,Cn),topFillColor2:e.baseline.topFillColor2??q(i,Tn),bottomFillColor:e.baseline.bottomFillColor??q(o,Cn),bottomFillColor2:e.baseline.bottomFillColor2??q(o,Tn),width:e.baseline.width,baselineLevel:e.baseline.baselineLevel}})(),series:{style:this.scene.priceStyle,baseline:this.scene.baselineValue,spacing:this.coords.spacingScale},sessions:{premarketColor:e.sessions.premarketColor,postmarketColor:e.sessions.postmarketColor,extendedColor:e.sessions.extendedColor}}}applyConfig(e){let t=ky(this.getConfig(),e),n=this.scene.style;for(let[u,d]of Object.entries(t.chartTypes))if(JSON.stringify(n.chartTypes[u])!==JSON.stringify(d)){this.scene.nativeData.set(`${u}-settings`,{...d});for(let h of this.chartTypeSettingsCbs)h(u,{...d});}n.chartTypes=Object.fromEntries(Object.entries(t.chartTypes).map(([u,d])=>[u,{...d}]));let i=e&&typeof e=="object"?e.layout:void 0,o=i&&typeof i=="object"?i.textColor:void 0,s=typeof o=="string"&&o.trim().length>0,a=this.theme,l={textColor:t.layout.textColor,gridColor:a.gridColor,borderColor:a.borderColor};if(!s&<(t.layout.textColor)===lt(t.layout.background)){let u=lt(t.layout.background)?Yt:lo;l={textColor:u.textColor,gridColor:u.gridColor,borderColor:u.borderColor};}this.theme={...this.theme,background:t.layout.background,textColor:l.textColor,gridColor:l.gridColor,borderColor:l.borderColor,fontFamily:t.layout.fontFamily},n.fontSize=t.layout.fontSize;let c=(u,d,h)=>u===null&&d===h?null:d;n.gridVert={visible:t.grid.vertLines.visible,color:c(n.gridVert.color,t.grid.vertLines.color,a.gridColor)},n.gridHorz={visible:t.grid.horzLines.visible,color:c(n.gridHorz.color,t.grid.horzLines.color,a.gridColor)},n.crosshair={color:t.crosshair.color,width:t.crosshair.width,style:t.crosshair.style,opacity:t.crosshair.opacity,labelBackground:t.crosshair.labelBackground},this.scene.scaleMode=t.priceScale.mode,this.scene.logScale=t.priceScale.log,this.scene.invertScale=t.priceScale.invert,n.borderColor=c(n.borderColor,t.priceScale.borderColor,a.borderColor),this.scene.showAxisLabels=t.priceScale.labelsVisible,this.scene.showPriceLine=t.priceScale.currentPriceLine,this.scene.showPriceLabel=t.priceScale.priceLabel,this.scene.showCountdown=t.priceScale.countdown,this.syncCountdownTimer(),this.animLiveBar.toggle(t.priceScale.animateLastPrice),this.animZoom.toggle(t.animations.zoom),this.animPan.toggle(t.animations.pan),this.animScroll.toggle(t.animations.pan),this.animAutoscale.toggle(t.animations.autoscale),this.intro={style:t.animations.intro?this.introOnStyle:false,duration:this.intro.duration||650},n.separatorColor=c(n.separatorColor,t.panes.separatorColor,a.borderColor),this.scene.tradeMarkers={visible:t.trades.visible,labels:t.trades.labels,qty:t.trades.qty,colors:{long:t.trades.longColor,short:t.trades.shortColor,exit:t.trades.exitColor}},this.scene.timezone=t.timeScale.timezone,this.scene.marks={visible:t.marks.visible,groups:{...t.marks.groups}},this.candleUp=t.candles.upColor,this.candleDown=t.candles.downColor,n.candle={bodyVisible:t.candles.bodyVisible,borderVisible:t.candles.borderVisible,borderUpColor:t.candles.borderUpColor,borderDownColor:t.candles.borderDownColor,wickVisible:t.candles.wickVisible,wickUpColor:t.candles.wickUpColor,wickDownColor:t.candles.wickDownColor},this.scene.candleZ=t.stacking.candles;for(let[u,d]of Object.entries(t.stacking.series))this.scene.setIndicatorZ(u,d);n.bars={upColor:t.bars.upColor,downColor:t.bars.downColor},n.line={color:t.line.color,width:t.line.width},n.area={lineColor:t.area.lineColor,width:t.area.width,topColor:t.area.topColor,bottomColor:t.area.bottomColor},n.baseline={topLineColor:t.baseline.topLineColor,bottomLineColor:t.baseline.bottomLineColor,topFillColor:t.baseline.topFillColor,topFillColor2:t.baseline.topFillColor2,bottomFillColor:t.baseline.bottomFillColor,bottomFillColor2:t.baseline.bottomFillColor2,width:t.baseline.width,baselineLevel:t.baseline.baselineLevel},n.sessions={premarketColor:t.sessions.premarketColor,postmarketColor:t.sessions.postmarketColor,extendedColor:t.sessions.extendedColor},this.setPriceStyle(t.series.style),this.scene.candleOverride=bc(this.scene.priceStyle,n.chartTypes),this.scene.baselineValue=t.series.baseline,this.coords.setPitchScale(t.series.spacing),this.coords.setViewport(this.clampViewport(this.coords.getViewport().barSpacing,this.coords.getViewport().rightOffset)),this.targetBarSpacing=this.coords.getViewport().barSpacing,this.theme=this.deriveTheme(this.theme),this.wrapper&&(Re(this.wrapper,this.chromeTheme()),this.applyBackground()),this.inputsUI?.setTheme(this.theme),this.paneControls?.setTheme(this.theme),this.axisScaleButtons?.setTheme(this.theme),this.userDrawings?.setTheme(this.chromeTheme()),this.refreshScrollButtonTheme(),this.refreshAttributionColor(),this.scheduler?.invalidate(4);for(let u of this.configChangedCbs)u();}applySeriesOrder(e){if(!e||typeof e!="object")return;let t=e;typeof t.id=="string"&&(typeof t.z=="number"?this.scene.setIndicatorZ(t.id,t.z):t.to==="front"?this.scene.bringIndicatorToFront(t.id):t.to==="back"&&this.scene.sendIndicatorToBack(t.id));}setSettingsEnabled(e){this.settingsEnabled=e,e?(this.plot&&!this.settingsButton&&(this.settingsButton=this.makeSettingsButton(),this.plot.appendChild(this.settingsButton)),this.settingsButton&&(this.settingsButton.style.display="flex"),this.plot&&!this.settingsDialog&&(this.settingsDialog=new vs(this.dialogHost??this.plot,this.theme))):(this.settingsButton?.style.setProperty("display","none"),this.settingsDialog?.close());}makeSettingsButton(){let e=document.createElement("button");return e.type="button",e.title="Chart settings",e.innerHTML=ye("gear",14),Object.assign(e.style,{position:"absolute",bottom:`${Hi+10}px`,right:`${au+10}px`,zIndex:"6",width:"26px",height:"26px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:"50%",border:`1px solid ${this.theme.borderColor}`,background:this.theme.background,color:this.theme.textColor,fontSize:"14px",lineHeight:"1",opacity:"0.75",pointerEvents:"auto",padding:"0"}),e.addEventListener("mouseenter",()=>e.style.opacity="1"),e.addEventListener("mouseleave",()=>e.style.opacity="0.75"),e.addEventListener("click",()=>this.toggleSettingsDialog()),e}openSettingsDialog(e){!this.settingsDialog&&this.plot&&(this.settingsDialog=new vs(this.dialogHost??this.plot,this.theme),this.settingsDialog.setLayoutMode(this.layoutMode)),this.toggleSettingsDialog(e);}syncThemeControl(){this.settingsDialog?.setThemeControl(lt(this.surfaceBackground)?"dark":"light",e=>{for(let t of this.themeSelectCbs)t(e);});}toggleSettingsDialog(e){if(this.settingsDialog){if(e!==void 0&&this.settingsDialog.isOpen()){this.settingsDialog.showSection(e);return}this.settingsDialog.setTheme(this.theme),this.settingsDialog.setHostSections(this.hostSettingsSections),this.settingsDialog.setMarkGroups(this.markGroupsInUse(),t=>Lc(this.scene.marks,t,this.scene.markGroups)),this.settingsDialog.setHiddenSettings(this.hiddenSettings),this.syncThemeControl(),this.settingsDialog.toggle(this.getConfig(),t=>this.applyConfig(t),t=>this.applyConfig(t),()=>{this.factoryConfig&&this.applyConfig(Ty(this.factoryConfig)),this.settingsDialog?.close(),this.openSettingsDialog();},e);}}closeDialogs(){this.inputsUI?.closeOpenDialog(),this.settingsDialog?.close();}makeScrollToRealtimeButton(){let e=document.createElement("button");return e.type="button",e.title="Scroll to most recent bar (Alt+Shift+\u2192)",e.setAttribute("aria-label","Scroll to most recent bar"),e.innerHTML=this.scrollButtonIcon(),Object.assign(e.style,{position:"absolute",bottom:`${ap}px`,right:`${Mx}px`,zIndex:"6",width:`${ks}px`,height:`${ks}px`,boxSizing:"border-box",display:"none",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:`${oI}px`,border:`1px solid ${this.theme.borderColor}`,boxShadow:sI,background:this.scrollButtonSurface(),color:this.theme.textColor,lineHeight:"0",opacity:"0.85",pointerEvents:"auto",padding:"0"}),e.addEventListener("mouseenter",()=>e.style.opacity="1"),e.addEventListener("mouseleave",()=>e.style.opacity="0.85"),e.addEventListener("click",()=>this.scrollToRealtime()),e}scrollButtonIcon(){return ye("chevrons-right",aI)}scrollButtonSurface(){return q(this.theme.background,.5)}refreshScrollButtonTheme(){this.scrollButton&&(this.scrollButton.style.background=this.scrollButtonSurface(),this.scrollButton.style.color=this.theme.textColor,this.scrollButton.style.borderColor=this.theme.borderColor);}updateScrollToRealtimeButton(){let e=this.scrollButton;if(!e)return;let t=this.coords.barCount>0&&this.coords.getViewport().rightOffset<0;if(this.layoutMode==="mobile"){e.style.display=t?"flex":"none";return}e.style.display=t&&this.pointerNearScrollBtn?"flex":"none";}scrollToRealtime(){this.coords.barCount!==0&&this.glideRightOffset(Px);}glideRightOffset(e){let t=this.coords.getViewport();if(!this.animScroll.on){this.applyViewport({barSpacing:t.barSpacing,rightOffset:e});return}this.panVelocity=0,this.targetBarSpacing=t.barSpacing,this.scrollTargetRO=e,this.animator.start();}screenshotCanvas(){if(!this.dataCanvas)return null;this.computeScales(),this.paintData();let e=document.createElement("canvas");e.width=this.dataCanvas.width,e.height=this.dataCanvas.height;let t=e.getContext("2d");if(!t)return null;t.fillStyle=this.theme.background,t.fillRect(0,0,e.width,e.height);let n=this.plot?.getBoundingClientRect(),i=n&&n.width>0?{left:n.left,top:n.top,dpr:e.width/n.width}:null,o=[...this.mountContainer?.querySelectorAll("[data-vela-screenshot]")??[]];if(i)for(let s of o)s.getAttribute("data-vela-screenshot")==="under"&&ou(t,s,i);for(let s of [...this.canvasPile(),this.chromeCanvas,this.drawingsCanvas])s&&s.width>0&&s.height>0&&t.drawImage(s,0,0);if(i){for(let s of this.plot?.querySelectorAll("[data-vela-pane]")??[])ou(t,s,i);for(let s of o)s.getAttribute("data-vela-screenshot")!=="under"&&ou(t,s,i);}return e}screenshot(){return this.screenshotCanvas()?.toDataURL("image/png")??null}playIntro(){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.introRaf=null;let{style:e,duration:t}=this.intro,n=this.bars,i=n.length;if(i===0||!e)return;this.computeScales();for(let a of this.scene.panes.values())a.scale={...a.scaleTarget};this.modelAlpha=0;let o=performance.now(),s=a=>{let l=Math.min(1,(a-o)/t);this.scene.bars=l>=1?n:n.map((c,u)=>this.revealCandle(c,u,l,i,e)),this.paintData(),l<1?this.introRaf=requestAnimationFrame(s):(this.scene.bars=n,this.fadeInModels());};this.introRaf=requestAnimationFrame(s);}fadeInModels(){let e=Math.min(Ix,this.intro.duration||Ix),t=performance.now(),n=i=>{this.modelAlpha=Math.min(1,(i-t)/e),this.paintData(),this.modelAlpha<1?this.introRaf=requestAnimationFrame(n):(this.modelAlpha=1,this.introRaf=null);};this.introRaf=requestAnimationFrame(n);}revealCandle(e,t,n,i,o){let a=Math.max(0,Math.min(1,(n-t/Math.max(1,i-1)*.55)/.44999999999999996)),l;if(o==="settle"){let d=a-1;l=1+(1.70158+1)*d*d*d+1.70158*d*d;}else {let u=1-a;l=1-u*u*u;}let c=e.open;return {...e,high:c+(e.high-c)*l,low:c+(e.low-c)*l,close:c+(e.close-c)*l}}deriveTheme(e){return {...e,upColor:this.candleUp,downColor:this.candleDown}}chromeTheme(){return {...this.theme,background:this.surfaceBackground,textColor:this.surfaceTextColor,borderColor:lt(this.surfaceBackground)?Yt.borderColor:lo.borderColor}}axisSurface(){return {background:this.theme.background,textColor:this.theme.textColor}}mount(e,t){this.mountContainer=e,this.publishGutters(),this.theme=this.deriveTheme(t),this.surfaceBackground=t.background,this.surfaceTextColor=t.textColor,this.wrapper=document.createElement("div"),Object.assign(this.wrapper.style,{position:"relative",width:"100%",height:"100%",overflow:"hidden",cursor:"crosshair",userSelect:"none",webkitUserSelect:"none"}),Re(this.wrapper,this.chromeTheme()),this.backdropCanvas=document.createElement("canvas"),Object.assign(this.backdropCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.volumeCanvas=document.createElement("canvas"),Object.assign(this.volumeCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.dataCanvas=this.createGeometryBackend(),this.vpvrCanvas=document.createElement("canvas"),Object.assign(this.vpvrCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.chromeCanvas=document.createElement("canvas"),Object.assign(this.chromeCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.drawingsCanvas=document.createElement("canvas"),Object.assign(this.drawingsCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.cursorCanvas=document.createElement("canvas"),Object.assign(this.cursorCanvas.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),this.overlayRoot=document.createElement("div"),Object.assign(this.overlayRoot.style,{position:"absolute",inset:"0",pointerEvents:"none"}),this.plot=document.createElement("div"),Object.assign(this.plot.style,{position:"absolute",top:"0",right:"0",bottom:"0",left:"0"}),this.extLayers=tp().map(o=>({def:o,instance:o.create(),canvas:this.createLayerCanvas(),channel:o.id,owner:null}));let n=this.extLayers.filter(o=>o.def.placement==="below-data").map(o=>o.canvas),i=this.extLayers.filter(o=>o.def.placement!=="below-data").map(o=>o.canvas);this.plot.append(this.backdropCanvas,...n,this.dataCanvas,this.volumeCanvas,this.vpvrCanvas,...i,this.chromeCanvas,this.drawingsCanvas,this.cursorCanvas,this.overlayRoot),this.layerOrderSig="",this.wrapper.appendChild(this.plot),this.factoryConfig=this.getConfig(),this.attributionEl=this.buildAttributionEl(),this.attributionEnabled||(this.attributionEl.style.display="none"),this.positionAttribution(),this.wrapper.appendChild(this.attributionEl),e.appendChild(this.wrapper),this.applyBackground(),this.backdropRenderer.mount(this.backdropCanvas),this.volumeRenderer.mount(this.volumeCanvas),this.vpvrRenderer.mount(this.vpvrCanvas);for(let o of this.extLayers)o.instance.mount(o.canvas);for(let o of this.scene.indicators.values())this.ensureInstanceLayer(o);this.chrome.mount(this.chromeCanvas),this.crosshairLayer.mount(this.cursorCanvas),this.coords.setViewport(cs()),this.scene.ensurePane(He,"price",0,3),this.scheduler=new Sc(o=>this.renderFrame(o)),this.animator=new Cc(o=>this.animTick(o)),this.targetBarSpacing=this.coords.getViewport().barSpacing,this.input=new Tc({getCoords:()=>this.coords,apply:o=>this.applyViewport(o),zoomTo:(o,s,a)=>this.zoomTo(o,s,a),fling:o=>this.fling(o),onPointerMove:(o,s)=>this.handlePointerMove(o,s),onClick:(o,s)=>{this.handleMarkClick(o,s)||(this.userDrawings?.deselect(),this.handleClick(o));},onAxisLongPress:(o,s,a)=>{for(let l of this.axisLongPressCbs)l({axis:o,x:s,y:a});},beginPriceScale:(o,s)=>this.beginPriceScale(o,s),priceScaleBy:o=>this.priceScaleBy(o),beginPricePan:o=>this.beginPricePan(o),pricePanBy:o=>this.pricePanBy(o),resetPriceScale:(o,s)=>this.resetPriceScale(o,s),dataDblClick:(o,s)=>this.dataDblClick(o,s),paneSeparatorAt:o=>this.paneSeparatorAt(o),beginPaneResize:o=>this.beginPaneResize(o),paneResizeBy:o=>this.paneResizeBy(o),resetPaneSize:o=>this.resetPaneSize(o),resetView:()=>this.resetView(),drawingsClaim:(o,s)=>this.userDrawings?.claim(o,s)??false,drawingsMeasureStart:(o,s,a)=>this.userDrawings?.beginMeasureAt(o,s,a)??false,drawingsMarqueeStart:(o,s)=>this.userDrawings?.beginMarqueeAt(o,s)??false,drawingsDeleteAt:(o,s)=>this.userDrawings?.deleteAt(o,s,true)??false,drawingsCancelPlacement:()=>this.userDrawings?.cancelPlacement()??false,drawingsSnapMode:()=>this.snapMode,drawingsPointerDown:(o,s,a,l,c)=>this.userDrawings?.pointerDown(o,s,a,l,c),drawingsPointerMove:(o,s,a,l,c)=>this.userDrawings?.pointerMove(o,s,a,l,c),drawingsPointerUp:(o,s,a)=>this.userDrawings?.pointerUp(o,s,a),drawingsCursor:(o,s)=>this.userDrawings?.cursorAt(o,s)??(this.chrome.markGlyphAt(o,s)?"pointer":null),drawingsDblClick:(o,s)=>this.userDrawings?.dblClick(o,s)??false,drawingsClearTransient:()=>this.userDrawings?.clearTransient()}),this.input.rightEdgeZoom=this.zoomAnchorMode==="right",this.input.axisDrag=this.axisDragEnabled,this.input.paneResize=this.paneResizeEnabled,this.input.attach(this.dataCanvas),this.settingsEnabled&&this.setSettingsEnabled(true),this.syncCountdownTimer(),this.scrollButton=this.makeScrollToRealtimeButton(),this.plot.appendChild(this.scrollButton),this.plot.addEventListener("pointermove",this.onScrollProximityMove),this.plot.addEventListener("pointerleave",this.onScrollProximityLeave),this.labelTooltip=new _c(this.plot,{theme:()=>this.chromeTheme(),lookup:(o,s)=>this.indicatorSlices.labelTooltipAt(o,s)??this.chrome.markTooltipAt(o,s,this.markGroupsInUse())}),this.markPopover=new tu({plot:this.plot,host:()=>this.dialogHost??this.plot,theme:()=>this.chromeTheme(),onOpenChange:o=>{this.scene.marksActiveKey=o,this.scheduler?.invalidate(2);}}),this.chrome.setMarkIconReady(()=>this.scheduler?.invalidate(2)),this.userDrawings=new Zc(this.wrapper,this.plot,this.drawingsCanvas,{projector:()=>this.drawingProjector(),dpr:()=>this.coords.dpr,theme:()=>this.theme,requestScaleUpdate:()=>this.scheduler.invalidate(3),seriesBoundaries:o=>this.scene.seriesBoundaries(o),priceZ:o=>o===He?this.scene.candleZ:null,requestDataPaint:()=>this.scheduler.invalidate(3),seriesLook:()=>{let o=this.scene.style,s=Mi(o.candle,this.scene.candleOverride,this.theme.upColor,this.theme.downColor),a=o.bars.upColor??this.theme.upColor,l=o.bars.downColor??this.theme.downColor,c=this.scene.priceStyle;return {style:c,upColor:c==="bars"?a:s.up,downColor:c==="bars"?l:s.down,lineColor:c==="area"?o.area.lineColor??this.theme.upColor:o.line.color??this.theme.upColor}},chartBarMs:()=>this.coords.barInterval,snap:(o,s,a,l)=>this.snapToCandle(o,s,a,l),setSnapMode:o=>this.setSnapMode(o),setToolbarGutter:o=>this.setToolbarGutter(o)}),this.userDrawings.historyChords=this.historyChordsEnabled,this.layoutMode==="mobile"&&(this.mountContainer?.setAttribute("data-vela-layout",this.layoutMode),this.userDrawings.setLayoutMode(this.layoutMode),this.scrollButton&&(this.scrollButton.style.width=`${sp}px`,this.scrollButton.style.height=`${sp}px`)),this.keyboard=new kc({panByBars:o=>this.panByBars(o),zoomByStep:o=>this.zoomByStep(o),stepCrosshair:o=>this.stepCrosshair(o),jumpToEdge:o=>this.focusBar(o==="first"?0:this.coords.barCount-1),resetView:()=>this.resetView(),scrollToRealtime:()=>this.scrollToRealtime(),clearCrosshair:()=>this.handlePointerMove(null,null),preempt:o=>this.userDrawings?.handleKey(o)??false}),this.setKeyboardEnabled(this.keyboardEnabled),this.inputsUI=new hc(this.plot,t,o=>this.paneBoundsFor(o)),this.inputsUI.setLayoutMode(this.layoutMode),this.inputsUI.setTitlesVisible(this.indicatorTitlesOn),this.inputsUI.setValuesVisible(this.indicatorValuesOn),this.inputsUI.setDialogHost(this.dialogHost),this.inputsUI.setSymbolPicker(this.symbolPicker),this.inputsUI.setLegendActions(this.legendActionsProvider),this.inputsUI.setLegendCallouts(this.legendCalloutsProvider),this.inputsUI.setLegendOverviewAction(this.legendOverviewAction),this.inputsUI.setOnChange(o=>{for(let s of this.inputChangeCbs)s({indicatorId:o.indicatorId,key:o.key,value:o.value,...o.kind?{kind:o.kind}:{}});}),this.inputsUI.setOnRemove(o=>{for(let s of this.removeIndicatorCbs)s(o);}),this.inputsUI.setOnToggleVisible((o,s)=>{for(let a of this.toggleVisibleCbs)a(o,s);}),this.inputsUI.setMoveApi({panes:()=>this.scene.orderedPanes().map((o,s)=>({id:o.id,kind:o.kind,label:o.kind==="price"?"Main chart":this.paneMasterTitle(o.id)??`Pane ${s}`,top:o.bounds.top,height:o.bounds.height})),move:(o,s)=>{for(let a of this.moveIndicatorCbs)a(o,s);}}),this.paneControls=new pc(this.plot,t,{panes:()=>this.paneControlViews(),rightAxis:()=>this.rightAxisW,onMove:(o,s)=>this.movePaneLocal(o,s),onToggleCollapse:o=>{let s=this.scene.panes.get(o);if(!s)return;let a=!s.collapsed;s.collapsed=a,this.afterPaneLayoutChange(),this.emitPaneAction({type:"collapse",paneId:o,collapsed:a});},onToggleMaximize:o=>{let s=this.maximizedPaneId!==o;this.maximizedPaneId=s?o:null,this.afterPaneLayoutChange(),this.emitPaneAction({type:"maximize",paneId:o,maximized:s});}}),this.paneControls.setSuspended(this.layoutMode==="mobile"),this.axisScaleButtons=new mc(this.plot,t,{panes:()=>this.axisScaleViews(),rightAxis:()=>this.rightAxisW,onToggleAuto:o=>this.togglePaneAuto(o),onToggleLog:o=>{let s=this.scene.panes.get(o);s&&this.setPaneLog(o,!Ri(this.scene,s));}}),this.resizeObserver=new ResizeObserver(o=>{for(let s of o){if(s.target!==this.plot)continue;let a=s.devicePixelContentBoxSize?.[0];a&&(this.plotDeviceSize={width:a.inlineSize,height:a.blockSize});}this.resize();}),this.resizeObserver.observe(this.wrapper);try{this.resizeObserver.observe(this.plot,{box:"device-pixel-content-box"});}catch{}this.watchDpr(),this.syncSize();}makeDataCanvas(){let e=document.createElement("canvas");return Object.assign(e.style,{position:"absolute",inset:"0",width:"100%",height:"100%"}),e}createGeometryBackend(){if((this.backendMode==="auto"||this.backendMode==="webgl2")&&wy()){let n=this.makeDataCanvas(),i=new wc;if(i.glow=this.glowAmount,i.onNeedsRedraw=()=>this.scheduler?.invalidate(4),i.onContextFailed=()=>this.swapToCanvas2dFallback(),i.mount(n),i.ok)return this.backend=i,n;i.destroy();}let e=this.makeDataCanvas(),t=new us;return t.mount(e),this.backend=t,e}swapToCanvas2dFallback(){if(this.backend.kind==="canvas2d")return;let e=this.dataCanvas;this.input?.detach(),this.backend.destroy();let t=this.makeDataCanvas(),n=new us;n.mount(t),this.backend=n,e.replaceWith(t),this.dataCanvas=t,this.input?.attach(t),this.syncSize();}watchDpr(){typeof window.matchMedia=="function"&&(this.dprMedia?.removeEventListener("change",this.onDprChange),this.dprMedia=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.dprMedia.addEventListener("change",this.onDprChange,{once:true}));}setTheme(e){this.theme=this.deriveTheme(e),this.surfaceBackground=e.background,this.surfaceTextColor=e.textColor,this.wrapper&&Re(this.wrapper,this.chromeTheme()),this.applyBackground(),this.inputsUI.setTheme(e),this.paneControls?.setTheme(this.theme),this.axisScaleButtons?.setTheme(this.theme),this.settingsDialog?.refreshConfig(this.getConfig()),this.syncThemeControl(),this.settingsDialog?.setTheme(this.theme),this.settingsButton&&(this.settingsButton.style.background=this.theme.background,this.settingsButton.style.color=this.theme.textColor,this.settingsButton.style.borderColor=this.theme.borderColor),this.refreshScrollButtonTheme(),this.userDrawings?.setTheme(this.chromeTheme()),this.refreshAttributionColor(),this.scheduler.invalidate(4);}resize(){this.syncSize();}setWallClock(e){e!==this.hostClock&&(this.hostClock=e,this.countdownUnsub!=null&&(this.countdownUnsub(),this.countdownUnsub=null),this.syncCountdownTimer());}syncCountdownTimer(){if(this.scene.showCountdown){if(this.countdownUnsub==null){let e=this.hostClock??this.ownClock??(this.ownClock=new yo);this.countdownUnsub=e.onTick(()=>{this.scene.showCountdown&&this.scene.bars.length>0&&this.scheduler?.invalidate(2);});}}else this.countdownUnsub!=null&&(this.countdownUnsub(),this.countdownUnsub=null);}destroy(){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.loadingEl?.remove(),this.loadingEl=null,this.countdownUnsub!=null&&(this.countdownUnsub(),this.countdownUnsub=null),this.scheduler?.destroy(),this.animator?.stop(),this.input?.detach(),this.keyboard?.detach(),this.keyboard=null,this.liveRegion=null,this.inputsUI?.destroy(),this.paneControls?.destroy(),this.axisScaleButtons?.destroy(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.dprMedia?.removeEventListener("change",this.onDprChange),this.dprMedia=null,this.userDrawings?.destroy(),this.userDrawings=null,this.settingsDialog?.destroy(),this.settingsDialog=null,this.settingsButton?.remove(),this.settingsButton=null,this.plot?.removeEventListener("pointermove",this.onScrollProximityMove),this.plot?.removeEventListener("pointerleave",this.onScrollProximityLeave),this.labelTooltip?.destroy(),this.labelTooltip=null,this.markPopover?.destroy(),this.markPopover=null,this.chrome.setMarkIconReady(null),this.markPulseRaf!==null&&cancelAnimationFrame(this.markPulseRaf),this.markPulseRaf=null,this.scrollButton?.remove(),this.scrollButton=null;for(let e of this.extLayers)e.instance.destroy?.();this.extLayers=[],this.backdropRenderer.destroy(),this.volumeRenderer.destroy(),this.vpvrRenderer.destroy(),this.backend.destroy(),this.chrome.destroy(),this.crosshairLayer.destroy(),this.attributionEl?.remove(),this.attributionEl=null,this.mountContainer?.style.removeProperty("--vela-toolbar-gutter"),this.mountContainer?.style.removeProperty("--vela-scale-gutter"),this.mountContainer?.style.removeProperty("--vela-bottom-gutter"),this.mountContainer?.style.removeProperty("--vela-price-pane-top"),this.mountContainer?.style.removeProperty("--vela-price-pane-bottom"),this.mountContainer=null,this.wrapper?.remove();}setBars(e,t){this.introRaf!=null&&(cancelAnimationFrame(this.introRaf),this.introRaf=null,this.modelAlpha=1),this.liveEaseTime=0;let n=this.bars,i=n[0]?.time;this.bars=xI(e),this.scene.bars=this.bars,this.coords.setBars(this.bars.map(s=>s.time));for(let s of this.scene.indicators.values())this.refreshAnchorOffset(s);if(t?.preserveView===true&&i!=null&&this.bars.length>0){let s=this.bars[0].time,a=0;if(s!==i){let l=this.bars.findIndex(c=>c.time===i);if(l>0)a=l;else {let c=n.findIndex(u=>u.time===s);c>0&&(a=-c);}}a!==0&&(this.zoomAnchorLogical+=a,this.hoverLogical!=null&&(this.hoverLogical+=a));}let o=t?.preserveView===true&&this.didInitialFit;if(this.coords.width>0&&!o&&(this.didInitialFit?this.reframeKeepZoom():this.fitContent(),this.didInitialFit=true),!this.introPlayed&&this.bars.length>0&&(this.introPlayed=true,this.intro.style)){this.playIntro();return}this.scheduler.invalidate(4);}updateBar(e){let t=this.bars.length,n=this.bars[t-1];if(n&&e.time===n.time)this.bars[t-1]=e,!this.animLiveBar.on||this.liveEaseTime!==e.time?this.syncLiveEase(e):this.animator.start();else if(!n||e.time>n.time)this.bars.push(e),this.syncLiveEase(e),this.coords.barInterval>0?this.coords.appendBar(e.time):this.coords.setBars(this.bars.map(i=>i.time));else return;this.scene.bars=this.bars,this.scheduler.invalidate(4);}setIntro(e){this.intro=e,e.style&&(this.introOnStyle=e.style);}syncLiveEase(e){this.liveEaseTime=e.time,this.liveEaseHigh=e.high,this.liveEaseLow=e.low,this.liveEaseClose=e.close;}easeLiveBar(e){let t=this.bars[this.bars.length-1];if(!t||this.liveEaseTime!==t.time)return false;let n=Math.max(1e-9,Math.abs(t.close)*1e-6),i=this.animLiveBar.tau,o=vt(this.liveEaseHigh,t.high,e,i),s=vt(this.liveEaseLow,t.low,e,i),a=vt(this.liveEaseClose,t.close,e,i),l=Math.abs(o-t.high)>n||Math.abs(s-t.low)>n||Math.abs(a-t.close)>n;return this.liveEaseHigh=l?o:t.high,this.liveEaseLow=l?s:t.low,this.liveEaseClose=l?a:t.close,l}ensurePane(e){this.scene.ensurePane(e.id,e.kind,e.order,e.heightWeight??(e.kind==="price"?3:1)),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}removePane(e){e!==He&&(this.scene.removePane(e),this.maximizedPaneId===e&&(this.maximizedPaneId=null),this.refreshAxisWidth(),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}setIndicatorPane(e,t,n){let i=this.scene.indicators.get(e.id);i&&(i.paneId=t,i.ownScale=n?.ownScale===true,i.ownScale||this.scene.dropIndicatorScale(e.id),this.inputsUI.setPane(e.id,t),this.refreshAnchorOffset(i),this.refreshAxisWidth(),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}orderPanes(e){this.scene.orderPanes(e),this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}setPaneCollapsed(e,t){let n=this.scene.panes.get(e);!n||n.collapsed===t||(n.collapsed=t,this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}setPaneMaximized(e){e!==null&&!this.scene.panes.has(e)&&(e=null),this.maximizedPaneId=e,this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}onPaneAction(e){return this.paneActionCbs.add(e),()=>this.paneActionCbs.delete(e)}emitPaneAction(e){for(let t of this.paneActionCbs)t(e);}onMoveIndicator(e){return this.moveIndicatorCbs.add(e),()=>this.moveIndicatorCbs.delete(e)}maxOwnScaleColumns(){let e=0;for(let t of this.scene.panes.values()){let n=this.scene.ownScaleIndicatorsForPane(t.id).length;n>e&&(e=n);}return e}refreshAxisWidth(){let e=au+iI*this.maxOwnScaleColumns();return e===this.rightAxisW?false:(this.rightAxisW=e,this.publishGutters(),this.coords.width>0&&this.syncSize(),true)}refreshAnchorOffset(e){let t=e.anchorTime;if(t==null||this.bars.length===0){this.scene.setAnchorOffset(e.id,0);return}let n=this.bars[0].time;if(t===n){this.scene.setAnchorOffset(e.id,0);return}if(t<n){let a=fI(e,n);if(a==null){console.warn(`[vela] indicator "${e.id}" starts before the first bar with no series to align on \u2014 rendering unanchored`),this.scene.setAnchorOffset(e.id,0);return}this.scene.setAnchorOffset(e.id,-a);return}let i=0,o=this.bars.length-1,s=this.bars.length;for(;i<=o;){let a=i+o>>1;this.bars[a].time>=t?(s=a,o=a-1):i=a+1;}if(s>=this.bars.length||this.bars[s].time!==t){console.warn(`[vela] indicator "${e.id}" anchorTime matches no chart bar \u2014 rendering unanchored`),this.scene.setAnchorOffset(e.id,0);return}this.scene.setAnchorOffset(e.id,s);}mountIndicator(e){return this.scene.indicators.set(e.id,e),this.refreshAnchorOffset(e),e.native&&this.extLayers.some(t=>t.def.id===e.native.type)?this.scene.assignIndicatorZTop(e.id):this.scene.assignIndicatorZ(e.id),this.ensureInstanceLayer(e),e.legend!==false&&this.inputsUI.upsert(e.id,e.shorttitle??e.title,e.inputs,e.inputValues,e.paneId,{native:!!e.native,...e.props?{props:e.props,propValues:e.propValues??{}}:{}}),e.native?.type==="volume"?(this.volumeActive=true,this.volumeHidden=false):e.native?.type==="vpvr"&&(this.vpvrActive=true,this.vpvrHidden=false),e.ownScale&&this.refreshAxisWidth(),this.paneControls?.refresh(),this.scheduler.invalidate(4),{id:e.id}}updateIndicator(e,t){let n=this.scene.indicators.get(e.id);if(n){if(t.kind==="value"&&t.anchorTime!==void 0){let i=t.anchorTime??void 0;i!==n.anchorTime&&(n.anchorTime=i,this.refreshAnchorOffset(n));}gI(n,t),this.scheduler.invalidate(3);}}removeIndicator(e){let t=this.scene.indicators.get(e.id)?.native?.type;t==="volume"?(this.volumeActive=false,this.volumeHidden=false,this.scene.volumeLayer=null):t==="vpvr"&&(this.vpvrActive=false,this.vpvrHidden=false,this.scene.vpvrLayer=null),this.scene.indicators.delete(e.id),this.dropInstanceLayer(e.id),this.scene.forgetIndicatorZ(e.id),this.scene.forgetAnchorOffset(e.id),this.scene.dropIndicatorScale(e.id),this.inputsUI.remove(e.id),this.refreshAxisWidth(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}setIndicatorInputs(e,t,n){this.inputsUI.setValues(e.id,t,n);}setSymbolPicker(e){this.symbolPicker=e,this.inputsUI?.setSymbolPicker(e);}setLegendActions(e){this.legendActionsProvider=e,this.inputsUI?.setLegendActions(e);}setLegendCallouts(e){this.legendCalloutsProvider=e,this.inputsUI?.setLegendCallouts(e);}setLegendOverviewAction(e){this.legendOverviewAction=e,this.inputsUI?.setLegendOverviewAction(e);}openIndicatorSettings(e){this.inputsUI?.openSettingsFor(e);}setIndicatorVisible(e,t){let n=this.scene.indicators.get(e.id)?.native?.type;if(n==="volume"||n==="vpvr"){n==="volume"?this.volumeHidden=!t:this.vpvrHidden=!t,this.inputsUI.setVisible(e.id,t),this.scheduler.invalidate(4);return}t||this.scene.indicators.delete(e.id),this.inputsUI.setVisible(e.id,t),this.scheduler.invalidate(4);}onInputChange(e){return this.inputChangeCbs.add(e),()=>this.inputChangeCbs.delete(e)}onToggleIndicatorVisible(e){return this.toggleVisibleCbs.add(e),()=>this.toggleVisibleCbs.delete(e)}onPriceStyleChange(e){return this.priceStyleCbs.add(e),()=>this.priceStyleCbs.delete(e)}setPriceStyle(e){if(e!==this.scene.priceStyle){this.scene.priceStyle=e,this.scene.basePainting=hh(e),this.scene.candleOverride=bc(e,this.scene.style.chartTypes);for(let t of this.priceStyleCbs)t(e);}}onRemoveIndicator(e){return this.removeIndicatorCbs.add(e),()=>this.removeIndicatorCbs.delete(e)}setLayoutMode(e){if(e!==this.layoutMode){if(this.layoutMode=e,this.mountContainer?.setAttribute("data-vela-layout",e),this.userDrawings?.setLayoutMode(e),this.settingsDialog?.setLayoutMode(e),this.inputsUI?.setLayoutMode(e),this.paneControls?.setSuspended(e==="mobile"),this.scrollButton){let t=e==="mobile"?sp:ks;this.scrollButton.style.width=`${t}px`,this.scrollButton.style.height=`${t}px`;}this.updateScrollToRealtimeButton();}}setSettingsSections(e){this.hostSettingsSections=e,this.settingsDialog?.setHostSections(e);}setSettingsVisibility(e){this.hiddenSettings=[...e.hidden??[]],this.settingsDialog?.setHiddenSettings(this.hiddenSettings);}listSettingsIds(){return Sw(this.hostSettingsSections,this.markGroupsInUse())}onChartTypeSettingsChange(e){return this.chartTypeSettingsCbs.add(e),()=>this.chartTypeSettingsCbs.delete(e)}onConfigChanged(e){return this.configChangedCbs.add(e),()=>this.configChangedCbs.delete(e)}onThemeSelect(e){return this.themeSelectCbs.add(e),()=>this.themeSelectCbs.delete(e)}onCrosshairMove(e){return this.crosshairCbs.add(e),()=>this.crosshairCbs.delete(e)}onClick(e){return this.clickCbs.add(e),()=>this.clickCbs.delete(e)}onAxisLongPress(e){return this.axisLongPressCbs.add(e),()=>this.axisLongPressCbs.delete(e)}setTimelineMarks(e,t){this.scene.timelineMarks=e,this.scene.markGroups=t,this.scene.marksExpandedStack=null,this.markPopover?.close(),this.scheduler?.invalidate(2);}onMarkClick(e){return this.markClickCbs.add(e),()=>this.markClickCbs.delete(e)}markGroupsInUse(){return mw(this.scene.timelineMarks,this.scene.markGroups)}onViewportChange(e){return this.viewportCbs.add(e),()=>this.viewportCbs.delete(e)}getVisibleRange(){let e=this.coords.barCount;if(e===0||this.coords.width===0)return null;let t=this.coords.visibleLogicalRange(),n=Math.max(0,Math.ceil(t.from)),i=Math.min(e-1,Math.floor(t.to));return i<n?null:{from:this.coords.logicalToTime(n),to:this.coords.logicalToTime(i)}}setVisibleRange(e){let t=this.coords.timeToLogical(e.from),n=this.coords.timeToLogical(e.to),i=Math.max(1e-6,n-t),o=rn(this.coords.width/(i*this.coords.spacingScale)),s=n-(this.coords.barCount-1);this.applyViewport({barSpacing:o,rightOffset:s});}panBy(e){if(this.coords.barCount===0||this.coords.width===0)return;let t=this.coords.getViewport(),n=this.coords.width/this.coords.pxPerBar(),i=this.scrollTargetRO??t.rightOffset;this.glideRightOffset(this.clampViewport(t.barSpacing,i+e*n).rightOffset);}applyViewport(e){this.animator.stop(),this.panVelocity=0,this.scrollTargetRO=null;let t=this.clampViewport(e.barSpacing,e.rightOffset);this.coords.setViewport(t),this.targetBarSpacing=t.barSpacing,this.scheduler.invalidate(4),this.emitViewportChange();}zoomTo(e,t,n){let i=this.clampViewport(e,this.coords.getViewport().rightOffset).barSpacing;if(this.zoomAnchorLogical=t,this.zoomAnchorX=n,this.panVelocity=0,this.scrollTargetRO=null,!this.animZoom.on){let o=this.clampViewport(i,this.anchoredRightOffset(i));this.coords.setViewport(o),this.targetBarSpacing=o.barSpacing,this.scheduler.invalidate(4),this.emitViewportChange();return}this.targetBarSpacing=i,this.animator.start();}fling(e){this.animPan.on&&(this.scrollTargetRO=null,this.panVelocity=e,this.animator.start());}anchoredRightOffset(e){let t=e*this.coords.spacingScale;return this.zoomAnchorLogical+(this.coords.width-this.zoomAnchorX)/t-(this.coords.barCount-1)}clampViewport(e,t){let n=this.coords.barCount,i=this.coords.width;if(n<=1||i<=0)return {barSpacing:rn(e),rightOffset:t};let o=Math.min(cI,n),s=this.coords.spacingScale,a=Math.min(1e3,i/(o*s)),l=Math.max(.5,Math.min(a,i/((n+Px)*s))),c=Math.max(l,Math.min(a,e)),d=i/(c*s)-(o-1),h=o-n,p=Math.max(h,Math.min(d,t));return {barSpacing:c,rightOffset:p}}animTick(e){let t=this.coords.getViewport(),n=t.barSpacing,i=t.rightOffset,o=false,s=this.targetBarSpacing;Math.abs(n-s)>s*.001?(n=rn(vt(n,s,e,this.animZoom.tau)),i=this.anchoredRightOffset(n),o=true):n!==s&&(n=s,i=this.anchoredRightOffset(n));let a=uI/Math.max(1e-6,n*this.coords.spacingScale);if(Math.abs(this.panVelocity)>a){i+=this.panVelocity*e;let c=this.animPan.tau;this.panVelocity=c>0?this.panVelocity*Math.exp(-e/c):0,Math.abs(this.panVelocity)<=a?this.panVelocity=0:o=true;}if(this.scrollTargetRO!=null){let c=this.scrollTargetRO,u=vt(i,c,e,this.animScroll.tau);Math.abs(u-c)<.001?(i=c,this.scrollTargetRO=null):(i=u,o=true);}let l=this.clampViewport(n,i);return l.barSpacing!==n&&(this.targetBarSpacing=l.barSpacing),this.scrollTargetRO!=null&&l.rightOffset!==i&&(this.scrollTargetRO=l.rightOffset),this.coords.setViewport(l),this.computeScales(),this.easeScales(e)&&(o=true),this.easeLiveBar(e)&&(o=true),this.skeletonClockMs+=e,this.paintData(),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx()),this.updateLegendValues(),this.emitViewportChange(),o}easeScales(e){let t=false,n=this.animAutoscale.tau;for(let i of this.scene.panes.values()){let o=i.scaleTarget,s=i.scale;if(o.log&&s.min>0&&o.min>0){let u=Math.log(o.min),d=Math.log(o.max),h=Math.max(1e-9,Math.abs(d-u)),p=vt(Math.log(s.min),u,e,n),m=vt(Math.log(s.max),d,e,n);Math.abs(p-u)<=h*.001&&Math.abs(m-d)<=h*.001?i.scale={min:o.min,max:o.max,log:true}:(t=true,i.scale={min:Math.exp(p),max:Math.exp(m),log:true});continue}let a=Math.max(1e-9,Math.abs(o.max-o.min)),l=vt(s.min,o.min,e,n),c=vt(s.max,o.max,e,n);Math.abs(l-o.min)<=a*.001&&Math.abs(c-o.max)<=a*.001?(l=o.min,c=o.max):t=true,i.scale={min:l,max:c,log:o.log};}for(let i of this.scene.indicatorScales.values()){let o=i.scaleTarget,s=i.scale,a=Math.max(1e-9,Math.abs(o.max-o.min)),l=vt(s.min,o.min,e,n),c=vt(s.max,o.max,e,n);Math.abs(l-o.min)<=a*.001&&Math.abs(c-o.max)<=a*.001?(l=o.min,c=o.max):t=true,i.scale={min:l,max:c};}return t}emitViewportChange(){this.updateScrollToRealtimeButton();let e=this.getVisibleRange();if(e)for(let t of this.viewportCbs)t(e);}handlePointerMove(e,t){if(e===null||t===null||this.coords.barCount===0){this.scene.crosshair=null,this.hoverSeparatorY=null,this.lastPointer=null,this.marksExpandedBy==="hover"&&this.setMarksExpanded(null),this.setMarkHover(null),this.scheduler.invalidate(1),this.hoverLogical=null;let p={time:null,price:null,paneKind:null,values:new Map,ohlc:null};for(let m of this.crosshairCbs)m(p);return}let n=e>=0&&t>=0&&e<=this.coords.width&&t<=this.coords.height;this.scene.crosshair=n?{x:e,y:t}:null,this.lastPointer=n?{x:e,y:t}:null,this.hoverSeparatorY=e>=0&&t>=0&&t<=this.coords.height?this.separatorHoverY(t):null,this.scheduler.invalidate(1),this.setMarksExpanded(n?this.chrome.markStackAt(e,t):null),this.setMarkHover(n?this.chrome.markGlyphAt(e,t)?.cluster.key??null:null);let i=Math.round(this.coords.xToLogical(e)),o=i>=0&&i<this.coords.barCount,s=o?this.coords.logicalToTime(i):null,a=this.paneNodeAtY(t),l=n&&a?this.coords.yToPrice(t,a.scale,a.bounds):null,c=new Map;if(o)for(let p of this.scene.indicators.values()){let m=this.scene.offsetOf(p.id);for(let f of p.series)if(Fe(f)){let g=f.points[i-m]?.value;g!=null&&c.set(f.id,g);}}let u=o?this.bars[i]:void 0,d=u?{time:u.time,open:u.open,high:u.high,low:u.low,close:u.close,volume:u.volume}:null;this.hoverLogical=o?i:null;let h={time:s,price:l,paneKind:n&&a?a.kind:null,values:c,ohlc:d};for(let p of this.crosshairCbs)p(h);}handleClick(e){if(this.coords.barCount===0)return;let t=Math.round(this.coords.xToLogical(e)),n=t>=0&&t<this.coords.barCount;for(let i of this.clickCbs)i({time:n?this.coords.logicalToTime(t):null,price:null});}setMarksExpanded(e,t="hover"){if(this.scene.marksExpandedStack!==e){if(e===null&&this.markPopover?.key){let n=this.chrome.markGlyphByKey(this.markPopover.key);if(n&&n.stack===this.scene.marksExpandedStack)return}this.scene.marksExpandedStack=e,this.marksExpandedBy=t,this.scheduler?.invalidate(2);}}handleMarkClick(e,t){let n=this.chrome.markGlyphAt(e,t);if(!n)return this.scene.marksExpandedStack!==null&&this.chrome.markStackAt(e,t)===null&&this.setMarksExpanded(null),false;if(n.decked)return this.setMarksExpanded(n.stack,"tap"),true;let i=n.cluster.marks,o=i[0],s={id:o.id,ids:i.map(a=>a.id),time:o.time,...n.cluster.group!==void 0?{group:n.cluster.group}:{}};for(let a of this.markClickCbs)a(s);return i.some(a=>a.content!==void 0)?this.markPopover?.open(n.cluster,{x:n.x,y:n.y,size:n.size}):(this.scene.marksFlash={key:n.cluster.key,until:lp()+dI},this.syncMarkPulse()),true}trackMarkPopover(){let e=this.markPopover?.key;if(!e)return;let t=this.chrome.markGlyphByKey(e);this.markPopover.track(t&&!(t.decked&&t.depth!==0)?{x:t.x,y:t.y,size:t.size}:null);}setMarkHover(e){this.scene.marksHoverKey!==e&&(this.scene.marksHoverKey=e,this.scene.marksHoverSince=lp(),this.scheduler?.invalidate(2),this.syncMarkPulse());}syncMarkPulse(){if(this.markPulseRaf!==null||typeof requestAnimationFrame!="function")return;let e=()=>{this.markPulseRaf=null;let t=lp();this.scene.marksFlash&&this.scene.marksFlash.until<=t&&(this.scene.marksFlash=null),this.scheduler?.invalidate(2),(this.scene.marksHoverKey!==null&&t-this.scene.marksHoverSince<Nc||this.scene.marksFlash!==null)&&(this.markPulseRaf=requestAnimationFrame(e));};this.markPulseRaf=requestAnimationFrame(e);}paneAtY(e){return this.paneNodeAtY(e)}paneNodeAtY(e){for(let t of this.scene.panes.values())if(e>=t.bounds.top&&e<=t.bounds.top+t.bounds.height)return t;return null}nearestPaneToY(e){let t=null,n=1/0;for(let i of this.scene.panes.values()){let o=e<i.bounds.top?i.bounds.top-e:e-(i.bounds.top+i.bounds.height);o<n&&(n=o,t=i);}return t}resolveScaleHolder(e,t){let n=this.paneNodeAtY(t);if(!n)return null;let i=this.coords.width,o=this.scene.ownScaleIndicatorsForPane(n.id);if(e>=i+64&&o.length>0){let s=Math.floor((e-i-64)/56),a=o[s];if(a)return {holder:this.scene.ensureIndicatorScale(a.id,n.scaleTarget),height:n.bounds.height}}return {holder:n,height:n.bounds.height}}beginPriceScale(e,t){let n=this.resolveScaleHolder(e,t);n&&(this.scaleDragHolder=n.holder,this.scaleDragHeight=n.height,this.scaleDragStart={...n.holder.scale},n.holder.manualScale={...n.holder.scale},this.axisScaleButtons?.reposition(),this.scheduler.invalidate(4));}priceScaleBy(e){let t=this.scaleDragHolder,n=this.scaleDragStart;!t||!n||this.setManualScale(t,lx(n,Math.exp(e*hI)));}beginPricePan(e){let t=this.paneNodeAtY(e);return !t||!t.manualScale?false:(this.scaleDragHolder=t,this.scaleDragHeight=t.bounds.height,this.scaleDragStart={...t.scale},true)}pricePanBy(e){let t=this.scaleDragHolder,n=this.scaleDragStart;!t||!n||this.setManualScale(t,cx(n,e,this.scaleDragHeight));}resetPriceScale(e,t){let n=this.resolveScaleHolder(e,t);n&&(n.holder.manualScale=null,this.axisScaleButtons?.reposition(),this.scheduler.invalidate(4));}dataDblClick(e,t){let n=this.paneNodeAtY(t)??this.nearestPaneToY(t);if(!n)return;let i=this.maximizedPaneId!==n.id;this.maximizedPaneId=i?n.id:null,this.afterPaneLayoutChange(),this.emitPaneAction({type:"maximize",paneId:n.id,maximized:i});}resetView(){this.fitContent(),this.scheduler.invalidate(4),this.emitViewportChange();}setManualScale(e,t){e.manualScale=t,e.scale={...t},e.scaleTarget={...t},e.initialized=true,this.scheduler.invalidate(4);}afterPaneLayoutChange(){this.layoutPanes(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}paneControlViews(){let e=this.scene.orderedPanes();return e.map((t,n)=>({id:t.id,kind:t.kind,collapsed:t.collapsed,maximized:this.maximizedPaneId===t.id,top:t.bounds.top,height:t.bounds.height,index:n,count:e.length}))}movePaneLocal(e,t){let n=this.scene.orderedPanes(),i=n.findIndex(l=>l.id===e);if(i<0)return;let o=t==="up"?i-1:i+1;if(o<1||o>=n.length)return;let s=n.map(l=>l.id),a=s[i];s[i]=s[o],s[o]=a,this.scene.orderPanes(s),this.afterPaneLayoutChange(),this.emitPaneAction({type:"move",paneId:e,dir:t});}paneSeparatorAt(e){return this.separatorPaneIndexAt(e)!==null}separatorHoverY(e){if(!this.paneResizeEnabled)return null;let t=this.separatorPaneIndexAt(e);return t===null?null:this.scene.orderedPanes()[t].bounds.top}separatorPaneIndexAt(e){let t=this.scene.orderedPanes();for(let n=1;n<t.length;n++)if(Math.abs(e-t[n].bounds.top)<=mI)return n;return null}beginPaneResize(e){let t=this.separatorPaneIndexAt(e);if(t===null)return;let n=this.scene.orderedPanes(),i=n[t-1],o=n[t];this.resizeAbove=i,this.resizeBelow=o,this.resizeSplitStart={combinedTop:i.bounds.top,combinedHeight:i.bounds.height+o.bounds.height,combinedWeight:i.heightWeight+o.heightWeight,startBoundaryY:o.bounds.top};}paneResizeBy(e){let t=this.resizeAbove,n=this.resizeBelow,i=this.resizeSplitStart;if(!t||!n||!i)return;let o=ux(i,e);t.heightWeight=o.above,n.heightWeight=o.below,this.layoutPanes(),this.scheduler.invalidate(4);}resetPaneSize(e){let t=this.separatorPaneIndexAt(e);if(t===null)return;let n=this.scene.orderedPanes(),i=n[t-1],o=n[t],s=(i.heightWeight+o.heightWeight)/2;i.heightWeight=s,o.heightWeight=s,this.layoutPanes(),this.scheduler.invalidate(4);}setKeyboardEnabled(e){this.keyboardEnabled=e,!(!this.dataCanvas||!this.keyboard)&&(e?(this.dataCanvas.tabIndex=0,this.dataCanvas.setAttribute("role","application"),this.dataCanvas.setAttribute("aria-label","Interactive price chart. Use Left/Right arrows to move between bars, Shift+Arrow to pan, plus/minus to zoom, Home/End to jump, 0 to reset."),!this.liveRegion&&this.wrapper&&(this.liveRegion=document.createElement("div"),this.liveRegion.setAttribute("aria-live","polite"),this.liveRegion.setAttribute("role","status"),Object.assign(this.liveRegion.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:"0"}),this.wrapper.appendChild(this.liveRegion)),this.keyboard.attach(this.dataCanvas)):(this.keyboard.detach(),this.dataCanvas.removeAttribute("tabindex"),this.dataCanvas.removeAttribute("role"),this.dataCanvas.removeAttribute("aria-label")));}panByBars(e){let t=this.coords.getViewport();this.applyViewport({barSpacing:t.barSpacing,rightOffset:t.rightOffset+e});}zoomByStep(e){let t=this.coords.getViewport(),n=rn(t.barSpacing*Math.exp(e*pI));this.zoomTo(n,this.coords.rightEdgeLogical,this.coords.width);}stepCrosshair(e){let t=this.coords.barCount;if(t===0)return;let n=this.hoverLogical??Math.min(t-1,Math.round(this.coords.xToLogical(this.coords.width)));this.focusBar(n+e);}focusBar(e){let t=this.coords.barCount;if(t===0)return;let n=Math.max(0,Math.min(t-1,e)),i=this.coords.getViewport(),o=2,s=this.coords.xToLogical(0),a=this.coords.xToLogical(this.coords.width),l=i.rightOffset;n<s+o?l-=s+o-n:n>a-o&&(l+=n-(a-o)),l!==i.rightOffset&&this.applyViewport({barSpacing:i.barSpacing,rightOffset:l});let c=this.scene.orderedPanes().find(d=>d.kind==="price")??this.scene.orderedPanes()[0]??null,u=this.scene.crosshair?.y??(c?c.bounds.top+c.bounds.height/2:this.coords.height/2);this.handlePointerMove(this.coords.logicalToX(n),u),this.announceBar(n);}announceBar(e){if(!this.liveRegion)return;let t=this.bars[e],n=this.dataWindowPricePane(),i=this.dataWindowOHLC(t,n),o=[];t&&o.push(bI(t.time,this.scene.timezone)),i&&o.push(`Open ${i.o}, High ${i.h}, Low ${i.l}, Close ${i.c}`);for(let s of this.dataWindowGroups(e,n))for(let a of s.rows)o.push(`${a.label} ${a.value}`);this.liveRegion.textContent=o.join(". ");}getDataWindowReadout(){let e=this.bars.length;if(e===0)return {date:"",time:"",ohlc:null,groups:[]};let t=this.hoverLogical!=null?this.hoverLogical:e-1,n=this.bars[t],i=this.dataWindowPricePane(),o=n?Ox(n.time,this.scene.timezone):{date:"",time:""};return {date:o.date,time:o.time,ohlc:this.dataWindowOHLC(n,i),groups:this.dataWindowGroups(t,i)}}dataWindowPricePane(){return this.scene.orderedPanes().find(e=>e.kind==="price")??null}dataWindowFmt(e,t){return t?Dc(t.scale,t.bounds.height,e,this.scene.priceMintick):String(e)}dataWindowOHLC(e,t){return e?{o:this.dataWindowFmt(e.open,t),h:this.dataWindowFmt(e.high,t),l:this.dataWindowFmt(e.low,t),c:this.dataWindowFmt(e.close,t),vol:e.volume!=null?Rx(e.volume):void 0,up:e.close>=e.open}:null}dataWindowGroups(e,t){let n=[];for(let i of this.scene.indicators.values()){let o=this.readoutRowsFor(i,e,t,"dataWindow");o.length&&n.push({name:i.title,rows:o});}return n}readoutRowsFor(e,t,n,i){if(e.native?.type==="volume")return this.volumeReadoutRows(e,t);let o=(e.paneId?this.scene.panes.get(e.paneId):null)??n,s=this.scene.offsetOf(e.id),a=[];for(let l of e.series){if(!Ct(l,i))continue;let c,u;if(l.kind==="candle"||l.kind==="bar")c=l.bars[t-s]?.close,u=l.style?.up??this.theme.upColor;else if(Fe(l))c=l.points[t-s]?.value,u=l.points[t-s]?.color??l.style.color;else continue;c==null||!Number.isFinite(c)||a.push({label:l.title||e.title,value:this.dataWindowFmt(c,o),color:u});}return a}volumeReadoutRows(e,t){if(this.volumeHidden)return [];let n=this.bars[t],i=n?.volume;if(n==null||i==null||!Number.isFinite(i))return [];let o=this.scene.volumeLayer,s=n.close>=n.open?o?.upColor??this.theme.upColor:o?.downColor??this.theme.downColor;return [{label:e.title,value:Rx(i),color:s}]}updateLegendValues(){if(!this.inputsUI)return;let e=this.bars.length,t=new Map;if(e>0){let n=this.hoverLogical!=null?this.hoverLogical:e-1,i=this.dataWindowPricePane();for(let o of this.scene.indicators.values())t.set(o.id,this.readoutRowsFor(o,n,i,"legend").map(s=>({value:s.value,color:s.color})));}this.inputsUI.setPlotValues(t);}renderFrame(e){this.animator.active||(bh(e)?(this.computeScales(),this.paintData()):Oy(e)&&this.paintedData&&(this.chrome.prepare(this.scene,this.coords,this.theme),this.chrome.render(this.scene,this.coords,this.theme,this.axisSurface()),this.trackMarkPopover()),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx()),!bh(e)&&this.paintedData&&this.repaintCursorLayers(),this.updateLegendValues());}repaintCursorLayers(){let e=this.scene.panes.get(He);if(!e)return;let t=typeof performance<"u"?performance.now():Date.now();for(let n of this.extLayers){if(!n.def.repaintOnCursor)continue;let i=this.layerPane(n)??e;i.collapsed||(n.instance.render(this.extLayerArgs(n,i.scale,i.bounds,t)),this.animZoom.on&&n.instance.animating?.()&&this.animator.start());}}clearLayerCanvas(e){e.width===0||e.height===0||e.getContext("2d")?.clearRect(0,0,e.width,e.height);}extLayerArgs(e,t,n,i){return {bars:this.scene.bars,data:this.scene.nativeData.get(e.channel),settings:this.scene.nativeData.get(`${e.def.id}-settings`)??{},pending:this.scene.nativePending.get(e.channel)??[],coords:this.coords,scale:t,bounds:n,theme:this.theme,priceStyle:this.scene.priceStyle,nowMs:i,cursor:this.lastPointer}}paintData(){this.syncLayerCanvasOrder(),this.stampScaleInvert(),this.backend.modelAlpha=this.modelAlpha,this.backend.candleBodyAlpha=this.candleBodyAlpha,this.backend.candleStructureAlpha=this.candleStructureAlpha;let e=1,t=1;this.backend.candleBodyScale=t;let n=this.scene.panes.get(He);if(n){let a=this.nativeLayerPane("volume")??n;this.volumeRenderer.render({bars:this.scene.bars,data:this.scene.volumeLayer,visible:this.volumeActive&&!this.volumeHidden&&!a.collapsed,coords:this.coords,bounds:a.bounds,fillPane:a.kind!=="price"}),this.vpvrRenderer.render({bars:this.scene.bars,data:this.scene.vpvrLayer,visible:this.vpvrActive&&!this.vpvrHidden,coords:this.coords,scale:n.scale,bounds:n.bounds,theme:this.theme});let l=typeof performance<"u"?performance.now():Date.now(),c=null;for(let u of this.extLayers){let d=this.layerPane(u)??n;if(d.collapsed){this.clearLayerCanvas(u.canvas);continue}let h=this.extLayerArgs(u,d.scale,d.bounds,l);u.instance.render(h),d===n&&(c=hx(c,u.instance.modulateBase?.(h)??null)),this.animZoom.on&&u.instance.animating?.()&&this.animator.start();}c&&(c.candleBodyScale!=null&&(this.backend.candleBodyScale=cp(c.candleBodyScale)||.01),c.candleBodyAlpha!=null&&(this.backend.candleBodyAlpha=cp(c.candleBodyAlpha)*this.candleBodyAlpha),c.gridAlpha!=null&&(e=cp(c.gridAlpha)));}let i=this.bars.length-1,o=i>=0?this.bars[i]:void 0,s=!!o&&this.liveEaseTime===o.time&&(o.high!==this.liveEaseHigh||o.low!==this.liveEaseLow||o.close!==this.liveEaseClose);s&&o&&(this.bars[i]={...o,high:this.liveEaseHigh,low:this.liveEaseLow,close:this.liveEaseClose}),this.scene.drawingSlices=ex(this.indicatorSlices.prepare(this.scene,this.coords,this.theme,this.dataCanvas),this.userDrawings?.prepareSlices(this.scene.orderedPanes().map(a=>a.id))??new Map),this.backdropRenderer.render(this.scene,this.coords,this.theme,e),this.backend.render(this.scene,this.coords,this.theme),this.chrome.render(this.scene,this.coords,this.theme,this.axisSurface()),this.trackMarkPopover(),this.userDrawings?.render(),s&&o&&(this.bars[i]=o),this.paintedData=true;}drawingProjector(){return tx(this.coords,e=>{let t=this.scene.panes.get(e);return t?{scale:t.scale,bounds:t.bounds,collapsed:t.collapsed}:null},e=>this.paneNodeAtY(e)?.id??null,(e,t)=>this.barsInTimeRange(e,t),this.userDrawings?.seriesGateway?(e,t,n)=>this.userDrawings.seriesGateway.seriesInRange(e,t,n):void 0)}barsInTimeRange(e,t){let n=Math.min(e,t),i=Math.max(e,t),o=[];for(let s of this.bars)if(!(s.time<n)){if(s.time>i)break;o.push(s);}return o}get userDrawingsPort(){return this.userDrawings??void 0}focus(){this.dataCanvas?.focus({preventScroll:true});}setExternalCrosshair(e,t=null){let n=e==null?null:{time:e,price:t},i=this.externalCross;!n&&!i||n&&i&&i.time===n.time&&i.price===n.price||(this.externalCross=n,this.scheduler.invalidate(1));}externalCrossPx(){let e=this.externalCross;if(!e||this.coords.barCount===0)return null;let t=Math.floor(this.coords.timeToLogical(e.time));if(t<0||t>=this.coords.barCount)return null;let n=this.coords.logicalToX(t);if(!Number.isFinite(n)||n<0||n>this.coords.width)return null;let i=null;if(e.price!=null){let o=this.scene.orderedPanes().find(s=>s.kind==="price");o&&(i=this.coords.priceToY(e.price,o.scale,o.bounds),(!Number.isFinite(i)||i<o.bounds.top||i>o.bounds.top+o.bounds.height)&&(i=null));}return {x:n,y:i,time:this.coords.logicalToTime(t),price:i!=null?e.price:null}}setSnapMode(e){this.snapMode=e;}snapToCandle(e,t,n="strong",i){if(n==="off")return e;let o=this.bars.length;if(o===0)return e;let s=Math.max(0,Math.min(o-1,Math.round(this.coords.timeToLogical(e.time)))),a=this.bars[s];if(!a)return e;let l;if(t!==He)l={time:a.time,price:e.price};else {let c=a.open;for(let u of [a.high,a.low,a.close])Math.abs(u-e.price)<Math.abs(c-e.price)&&(c=u);l={time:a.time,price:c};}if(n==="weak"&&i){let c=this.drawingProjector(),u=c.yOf(l.price,t);if(Math.hypot(c.xOf(l.time)-i.x,(u??i.y)-i.y)>nI)return e}return l}computeScales(){let e=this.coords.barCount;if(e===0)return;let t=this.coords.visibleLogicalRange(),n=Math.max(0,Math.floor(t.from)),i=Math.min(e-1,Math.ceil(t.to));if(i<n)return;this.scene.percentBaseline=this.bars[n]?.close??0;let o=this.scene.orderedPanes(),s=o.find(l=>l.kind==="price")??null;this.chrome.prepare(this.scene,this.coords,this.theme);let a=this.animator.active;for(let l of o){if(l.manualScale){l.scaleTarget=l.manualScale,l.scale={...l.manualScale},l.initialized=true;continue}let u=this.scene.indicatorsForPane(l.id).filter(p=>p.ownScale!==true),d=this.chrome.paneDrawingsRange(u,this.scene,l===s,t);if(l===s){let p=ox(this.scene.indicators.values(),n,i,m=>this.scene.offsetOf(m));p&&(d=d?{min:Math.min(d.min,p.min),max:Math.max(d.max,p.max)}:p);}let h=l.kind==="price"&&(!this.scene.candlesHidden||this.priceLayersAnchoredToBars(u));if(l.scaleTarget=eu(u,this.bars,h,n,i,d,Ri(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=l.kind==="price"?this.bars[n]?.close??0:this.firstVisibleValue(u,n),l.axisFormat=void 0,l.axisBands=void 0,this.volumeOwnsPane(l,u)){let p=this.maxVisibleVolume(n,i);p>0&&(l.scaleTarget={min:0,max:p/Jh},l.axisFormat="volume");}else if(this.layerNativesOwnPane(l,u)&&(l.scaleTarget=eu([],this.bars,true,n,i,d,Ri(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=this.bars[n]?.close??0,u.every(p=>p.paneAxis!=null))){l.axisFormat="none";let p=u.find(m=>typeof m.paneAxis=="object");l.axisBands=p?p.paneAxis.bands:void 0;}if(l===s&&this.scene.tradeMarkers.visible&&l.bounds.height>0){let p=this.tradesScaleHints(t);if(p){let m=l.scaleTarget,f={...m,min:Math.min(m.min,p.min),max:Math.max(m.max,p.max)};l.scaleTarget=sx(f,l.bounds.height,p.abovePx,p.belowPx);}}(!a||!l.initialized)&&(l.scale={...l.scaleTarget},l.initialized=true);for(let p of this.scene.ownScaleIndicatorsForPane(l.id)){let m=this.scene.ensureIndicatorScale(p.id,l.scaleTarget);if(m.manualScale){m.scaleTarget=m.manualScale,m.scale={...m.manualScale},m.initialized=true;continue}let f=this.chrome.paneDrawingsRange([p],this.scene,false,t);m.scaleTarget=eu([p],this.bars,false,n,i,f,false,g=>this.scene.offsetOf(g)),(!a||!m.initialized)&&(m.scale={...m.scaleTarget},m.initialized=true);}}}tradesScaleHints(e){let t=null,n={timeToLogical:i=>this.coords.timeToLogical(i),barAt:i=>{let o=this.bars[Math.round(i)];return o?{high:o.high,low:o.low}:null}};for(let i of this.scene.indicators.values()){if(!i.trades?.length)continue;let o=Ky(i.trades,this.scene.tradeMarkers,n,e.from,e.to,this.scene.style.fontSize);o&&(t=t?{min:Math.min(t.min,o.min),max:Math.max(t.max,o.max),abovePx:Math.max(t.abovePx,o.abovePx),belowPx:Math.max(t.belowPx,o.belowPx)}:o);}return t}fitContent(){let e=this.coords.barCount,t=this.coords.width;if(e<=0||t<=0)return;this.animator?.stop(),this.panVelocity=0;for(let s of this.scene.panes.values())s.manualScale=null;for(let s of this.scene.indicatorScales.values())s.manualScale=null;let n=Math.min(e,200),i=6,o=this.clampViewport(t/((n+i)*this.coords.spacingScale),i);this.coords.setViewport(o),this.targetBarSpacing=o.barSpacing;}reframeKeepZoom(){this.animator?.stop(),this.panVelocity=0;for(let t of this.scene.panes.values())t.manualScale=null;for(let t of this.scene.indicatorScales.values())t.manualScale=null;let e={barSpacing:rn(this.coords.getViewport().barSpacing),rightOffset:cs().rightOffset};this.coords.setViewport(e),this.targetBarSpacing=e.barSpacing;}paneBoundsFor(e){let t=this.scene.panes.get(e);return {top:t?.bounds.top??0,height:t?.bounds.height??0,rightAxis:this.rightAxisW}}paneMasterTitle(e){let t=this.scene.orderedIndicatorsForPane(e);return (t.find(i=>i.ownScale!==true)??t[0])?.title||null}nativeLayerPane(e){for(let t of this.scene.indicators.values())if(t.native?.type===e)return this.scene.panes.get(t.paneId??He)??null;return null}createLayerCanvas(){let e=document.createElement("canvas");return Object.assign(e.style,{position:"absolute",inset:"0",width:"100%",height:"100%",pointerEvents:"none"}),e}ensureInstanceLayer(e){let t=e.native?.channel;if(!t||!this.plot||this.extLayers.some(s=>s.owner===e.id))return;let n=this.extLayers.find(s=>s.owner===null&&s.def.id===e.native.type);if(!n)return;let i=this.createLayerCanvas();i.width=this.dataCanvas.width,i.height=this.dataCanvas.height,i.style.width=this.dataCanvas.style.width||"100%",i.style.height=this.dataCanvas.style.height||"100%";let o={def:n.def,instance:n.def.create(),canvas:i,channel:t,owner:e.id};this.extLayers.push(o),this.plot.insertBefore(i,this.chromeCanvas),o.instance.mount(i);}dropInstanceLayer(e){let t=this.extLayers.findIndex(i=>i.owner===e);if(t<0)return;let[n]=this.extLayers.splice(t,1);n.instance.destroy?.(),n.canvas.remove();}layerOwner(e){if(e.owner!==null)return this.scene.indicators.get(e.owner)??null;for(let t of this.scene.indicators.values())if(t.native?.type===e.def.id&&!t.native.channel)return t;return null}layerPane(e){let t=this.layerOwner(e),n=t?t.paneId??He:He;return this.scene.panes.get(n)??null}orderedLayerCanvases(){let e=new Map(this.extLayers.map(i=>[i.channel,i.canvas])),{below:t,above:n}=px(this.extLayers.map(i=>{let o=this.layerOwner(i);return {id:i.channel,placement:i.def.placement==="below-data"?"below-data":"above-data",ownerZ:o?this.scene.zOf(o.id):null}}),this.scene.candleZ);return {below:t.map(i=>e.get(i)),above:n.map(i=>e.get(i))}}canvasPile(){let{below:e,above:t}=this.orderedLayerCanvases();return [this.backdropCanvas,...e,this.dataCanvas,this.volumeCanvas,this.vpvrCanvas,...t]}syncLayerCanvasOrder(){if(this.extLayers.length===0||!this.plot)return;let{below:e,above:t}=this.orderedLayerCanvases(),n=[...e.map(i=>this.extLayers.find(o=>o.canvas===i).channel),"|",...t.map(i=>this.extLayers.find(o=>o.canvas===i).channel)].join(",");if(n!==this.layerOrderSig){this.layerOrderSig=n;for(let i of e)this.plot.insertBefore(i,this.dataCanvas);for(let i of t)this.plot.insertBefore(i,this.chromeCanvas);}}volumeOwnsPane(e,t){return e.kind==="price"||!this.volumeActive||this.volumeHidden||!this.scene.volumeLayer||this.nativeLayerPane("volume")!==e?false:t.every(n=>n.native?.type==="volume")}layerNativesOwnPane(e,t){return e.kind==="price"||t.length===0?false:t.every(n=>n.series.length===0&&!!n.native&&this.extLayers.some(i=>i.def.id===n.native.type))}priceLayersAnchoredToBars(e){return this.extLayers.some(t=>t.owner===null&&t.def.id===this.scene.priceStyle)?true:e.some(t=>t.series.length===0&&!!t.native&&this.extLayers.some(n=>n.def.id===t.native.type))}paneScaleInfos(){return this.scene.orderedPanes().map(e=>({id:e.id,kind:e.kind,top:e.bounds.top,height:e.bounds.height,mode:Sh(this.scene,e),log:Ri(this.scene,e),invert:Ch(this.scene,e)}))}axisScaleViews(){return this.scene.orderedPanes().map(e=>({id:e.id,top:e.bounds.top,height:e.bounds.height,collapsed:e.collapsed,auto:e.manualScale==null,log:Ri(this.scene,e)}))}togglePaneAuto(e){let t=this.scene.panes.get(e);t&&(t.manualScale=t.manualScale==null?{...t.scale}:null,this.scheduler?.invalidate(4));}setPaneScaleMode(e,t){if(e===He)this.scene.scaleMode=t;else {let n=this.scene.panes.get(e);if(!n)return;n.scaleMode=t;}this.scheduler?.invalidate(4);}setPaneLog(e,t){let n=e===He?this.scene.orderedPanes().find(i=>i.kind==="price"):this.scene.panes.get(e);if(e===He)this.scene.logScale=t;else {if(!n)return;n.logScale=t;}n?.manualScale&&(n.manualScale.log=t),this.scheduler?.invalidate(4);}setPaneInvert(e,t){if(e===He)this.scene.invertScale=t;else {let n=this.scene.panes.get(e);if(!n)return;n.invert=t;}this.scheduler?.invalidate(4);}stampScaleInvert(){for(let e of this.scene.panes.values()){let t=Ch(this.scene,e);e.scale.invert=t,e.scaleTarget.invert=t,e.manualScale&&(e.manualScale.invert=t);for(let n of this.scene.ownScaleIndicatorsForPane(e.id)){let i=this.scene.indicatorScales.get(n.id);i&&(i.scale.invert=t,i.scaleTarget.invert=t,i.manualScale&&(i.manualScale.invert=t));}}}firstVisibleValue(e,t){for(let n of e){let i=this.scene.offsetOf(n.id);for(let o of n.series)if(o.overlay!==true){if(Fe(o)){let s=o.points[t-i]?.value;if(s!=null&&Number.isFinite(s))return s}else if(o.kind==="candle"||o.kind==="bar"){let s=o.bars[t-i];if(s&&Number.isFinite(s.close))return s.close}}}return 0}maxVisibleVolume(e,t){let n=0;for(let i=e;i<=t;i+=1){let o=this.bars[i]?.volume;o!=null&&o>n&&(n=o);}return n}layoutPanes(){let e=this.scene.orderedPanes(),t=this.coords.height;this.inputsUI?.setCollapsedPanes(this.collapsedMasterMap());let n=this.maximizedPaneId?this.scene.panes.get(this.maximizedPaneId):null;if(n){let u=0;for(let d of e)d===n?d.bounds={top:0,height:t}:d.bounds={top:t,height:0},u+=d.bounds.height;this.inputsUI?.reposition(),this.paneControls?.reposition(),this.axisScaleButtons?.reposition(),this.repositionScrollButton(),this.positionAttribution(),this.publishPricePaneBounds();return}let i=e.filter(u=>u.collapsed),o=e.filter(u=>!u.collapsed),s=i.length*Lx,a=Math.max(0,t-s),l=o.reduce((u,d)=>u+(d.heightWeight||1),0)||1,c=0;for(let u of e){let d=u.collapsed?Lx:a*(u.heightWeight||1)/l;u.bounds={top:c,height:d},c+=d;}this.inputsUI?.reposition(),this.paneControls?.reposition(),this.axisScaleButtons?.reposition(),this.repositionScrollButton(),this.positionAttribution(),this.publishPricePaneBounds();}repositionScrollButton(){let e=this.coords.height;if(e<=0)return;let t=this.maximizedPaneId?this.scene.panes.get(this.maximizedPaneId):null,n=t?[t]:this.scene.orderedPanes().filter(o=>!o.collapsed),i=n.length?Math.max(...n.map(o=>o.bounds.top+o.bounds.height)):e;this.scrollBtnBottomPx=ap+Math.max(0,e-i),this.mountContainer?.style.setProperty("--vela-bottom-gutter",`${Hi+Math.max(0,e-i)}px`),this.scrollBtnRightPx=this.rightAxisW+Dx,this.scrollButton&&(this.scrollButton.style.bottom=`${this.scrollBtnBottomPx}px`,this.scrollButton.style.right=`${this.scrollBtnRightPx}px`);}collapsedMasterMap(){let e=new Map;for(let t of this.scene.panes.values()){if(!t.collapsed)continue;let n=this.scene.orderedIndicatorsForPane(t.id).filter(s=>s.legend!==false),i=new Set(this.scene.ownScaleIndicatorsForPane(t.id).map(s=>s.id)),o=n.find(s=>!i.has(s.id))??n[0];e.set(t.id,o?.id??null);}return e}setToolbarGutter(e){e!==this.toolbarGutter&&(this.toolbarGutter=e,this.publishGutters(),this.positionAttribution(),this.syncSize());}publishGutters(){this.mountContainer?.style.setProperty("--vela-toolbar-gutter",`${this.toolbarGutter}px`),this.mountContainer?.style.setProperty("--vela-scale-gutter",`${this.rightAxisW}px`);}publishPricePaneBounds(){if(!this.mountContainer)return;let e=this.coords.height+Hi,t=this.scene.panes.get(He),n=t?t.bounds.top:0,i=t?t.bounds.height:this.coords.height,o=Math.max(0,e-(n+i));this.mountContainer.style.setProperty("--vela-price-pane-top",`${n}px`),this.mountContainer.style.setProperty("--vela-price-pane-bottom",`${o}px`);}buildAttributionEl(){return this.attributionHtml!==null?bx(document,this.attributionHtml,this.theme.background):vx(document,this.theme.background)}rebuildAttribution(){this.attributionEl&&(this.attributionEl.remove(),this.attributionEl=this.buildAttributionEl(),this.attributionEnabled||(this.attributionEl.style.display="none"),this.positionAttribution(),this.wrapper.appendChild(this.attributionEl));}positionAttribution(){if(!this.attributionEl)return;let e=this.coords?.height??0,t=this.maximizedPaneId?this.scene.panes.get(this.maximizedPaneId):null,n=t?[t]:this.scene.orderedPanes().filter(o=>!o.collapsed),i=e>0&&n.length?Math.max(...n.map(o=>o.bounds.top+o.bounds.height)):e;Object.assign(this.attributionEl.style,{left:`${(this.toolbarGutter||0)+12}px`,bottom:`${Hi+10+Math.max(0,e-i)}px`});}refreshAttributionColor(){this.attributionEl&&(this.attributionHtml!==null?this.attributionEl.style.color=np(this.theme.background):rp(this.attributionEl,this.theme.background));}syncSize(){let e=this.wrapper.clientWidth,t=this.wrapper.clientHeight;if(e<=0||t<=0)return;let n=window.devicePixelRatio||1;this.plot.style.left=`${this.toolbarGutter}px`;let i=this.plot.getBoundingClientRect(),o=Math.max(1,Math.round(i.width*n)),s=Math.max(1,Math.round(i.height*n)),a=this.plotDeviceSize;a&&Math.abs(a.width-i.width*n)<=1&&Math.abs(a.height-i.height*n)<=1&&(o=Math.max(1,a.width),s=Math.max(1,a.height));let l=o/n,c=s/n,u=d=>{d.width=o,d.height=s,d.style.width=`${l}px`,d.style.height=`${c}px`;};u(this.dataCanvas),u(this.backdropCanvas),u(this.volumeCanvas);for(let d of this.extLayers)u(d.canvas);u(this.vpvrCanvas),u(this.chromeCanvas),u(this.drawingsCanvas),u(this.cursorCanvas),this.coords.setSize(Math.max(1,l-this.rightAxisW),Math.max(1,c-Hi),n),this.scene.crosshair=null,this.layoutPanes(),this.userDrawings?.onResize(),!this.didInitialFit&&this.coords.barCount>0&&(this.fitContent(),this.didInitialFit=true),this.animator.active?(this.computeScales(),this.paintData(),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx())):this.scheduler.flushNow(4);}applyBackground(){this.wrapper.style.background=this.theme.background;}};function fI(r,e){for(let t of r.series){let n=t.kind==="candle"||t.kind==="bar"?t.bars:Fe(t)?t.points:null;if(!n||n.length===0)continue;let i=0,o=n.length;for(;i<o;){let s=i+o>>1;n[s].time<e?i=s+1:o=s;}return i}return null}function gI(r,e){if(e.kind==="value"){for(let t of e.series){let n=r.series.find(i=>i.id===t.seriesId);n&&(t.kind==="points"&&Fe(n)?n.points=t.points:t.kind==="bars"&&(n.kind==="candle"||n.kind==="bar")&&(n.bars=t.bars));}e.lines&&(r.lines=e.lines),e.boxes&&(r.boxes=e.boxes),e.labels&&(r.labels=e.labels),e.polylines&&(r.polylines=e.polylines),e.linefills&&(r.linefills=e.linefills),e.tables&&(r.tables=e.tables),e.trades&&(r.trades=e.trades);return}for(let t of e.removed){let n=r.series.findIndex(i=>i.id===t);n>=0&&r.series.splice(n,1);}for(let t of e.added)r.series.push(t);}function Ox(r,e){let t=Pc(r,e),n=i=>i<10?`0${i}`:String(i);return {date:`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())}`,time:`${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}}function bI(r,e){let{date:t,time:n}=Ox(r,e);return `${t} ${n}`}function vI(r){if(!Array.isArray(r))return [];let e=[];for(let t of r){if(!t||typeof t!="object")continue;let n=t,i=Number(n.from),o=Number(n.to);!Number.isFinite(i)||!Number.isFinite(o)||o<=i||e.push({from:i,to:o,color:typeof n.color=="string"?n.color:"rgba(120,130,160,0.10)"});}return e.sort((t,n)=>t.from-n.from)}function yI(r){if(r==null||typeof r!="object")return null;let e=r,t=n=>{if(!Array.isArray(n))return [];let i=[];for(let o of n){if(!Array.isArray(o))continue;let s=Number(o[0]),a=Number(o[1]);Number.isFinite(s)&&Number.isFinite(a)&&a>s&&i.push([s,a]);}return i.sort((o,s)=>o[0]-s[0])};return {pre:t(e.pre),post:t(e.post),extended:t(e.extended)}}function cp(r){return Math.max(0,Math.min(1,r))}function wI(r){return typeof r=="string"&&Pi().includes(r)}function Ax(r){return r==="percent"||r==="indexed"?r:"price"}function Rx(r){let e=Math.abs(r);return e>=1e9?`${(r/1e9).toFixed(2)}B`:e>=1e6?`${(r/1e6).toFixed(2)}M`:e>=1e3?`${(r/1e3).toFixed(2)}K`:r.toFixed(2)}function xI(r){let e=[...r].sort((n,i)=>n.time-i.time),t=[];for(let n of e){let i=t[t.length-1];i&&i.time===n.time?t[t.length-1]=n:t.push(n);}return t}function up(r,e){let t=(r.open+r.high+r.low+r.close)/4,n=e?(e.open+e.close)/2:(r.open+r.close)/2;return {time:r.time,open:n,high:Math.max(r.high,n,t),low:Math.min(r.low,n,t),close:t,...r.volume!=null?{volume:r.volume}:{}}}function Nx(r){let e=new Array(r.length),t;for(let n=0;n<r.length;n+=1)t=up(r[n],t),e[n]=t;return e}var SI={full:Nx,next:up};function Fx(){_u({id:"heikinashi",label:"Heikin Ashi",barTransform:SI});}var dp=z,hp=W,pp=20;function CI(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function Vx(r,e){return typeof r=="string"&&r!==""?r:e}function lu(r){return {upColor:Vx(r.upColor,dp),downColor:Vx(r.downColor,hp),heightFrac:Math.min(.5,Math.max(.05,CI(r.heightPct,pp)/100))}}var mp=class{constructor(){this.ctx=null;this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(lu(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx?.pushData(lu(e));}suspend(){}resume(){this.ctx?.pushData(lu(this.inputs));}stop(){}},_x={type:"volume",title:"Volume",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"upColor",title:"Up color",type:"color",defval:dp},{key:"downColor",title:"Down color",type:"color",defval:hp},{key:"heightPct",title:"Height %",type:"int",defval:pp,min:5,max:50,step:1,tooltip:"Pane height the tallest visible bar occupies"}],defaultInputs:()=>({upColor:dp,downColor:hp,heightPct:pp}),create:()=>new mp};function fp(){Pn(_x);}var bp=24,vp=30,yp=Ke,wp=W,xp=70;function gp(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function Bx(r,e){return typeof r=="string"&&r!==""?r:e}function cu(r){return {rows:Math.round(Math.min(400,Math.max(2,gp(r.rows,bp)))),widthFrac:Math.min(.9,Math.max(.05,gp(r.widthPct,vp)/100)),upColor:Bx(r.upColor,yp),downColor:Bx(r.downColor,wp),showPoc:r.showPoc!==false,valueAreaFrac:Math.min(1,Math.max(0,gp(r.valueAreaPct,xp)/100))}}var Sp=class{constructor(){this.ctx=null;this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(cu(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx?.pushData(cu(e));}suspend(){}resume(){this.ctx?.pushData(cu(this.inputs));}stop(){}},Hx={type:"vpvr",title:"Visible Range Volume Profile",shortTitle:"VRVP",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"rows",title:"Rows",type:"int",defval:bp,min:2,max:400,step:1},{key:"widthPct",title:"Width %",type:"int",defval:vp,min:5,max:90,step:1,tooltip:"Pane width the largest row occupies"},{key:"upColor",title:"Up color",type:"color",defval:yp},{key:"downColor",title:"Down color",type:"color",defval:wp},{key:"showPoc",title:"Point of control",type:"bool",defval:true},{key:"valueAreaPct",title:"Value area %",type:"int",defval:xp,min:0,max:100,step:1}],defaultInputs:()=>({rows:bp,widthPct:vp,upColor:yp,downColor:wp,showPoc:true,valueAreaPct:xp}),create:()=>new Sp};function Cp(){Pn(Hx);}function Jn(r){let e=r.title.trim().toLowerCase().replace(/\s+/g,"-");return `${r.instanceId}:${r.kind}:${e}#${r.ordinal}`}function I(r,e,t){let n=r[e];return typeof n=="number"&&Number.isFinite(n)?n:t}function F(r,e,t){let n=r[e];return typeof n=="string"&&n!==""?n:t}function kp(r,e,t){let n=r[e];return typeof n=="boolean"?n:t}function TI(r,e,t){let n=new Array(r.length);for(let i=0;i<r.length;i++){let o=e[i],s={time:r[i].time,value:o!=null&&Number.isFinite(o)?o:null},a=t?.[i];a!=null&&(s.color=a),n[i]=s;}return n}var Tp=class{constructor(e){this.spec=e;this.ctx=null;this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,this.recompute();}onBars(){this.recompute();}onViewport(){}setInputs(e){this.inputs=e,this.ctx&&this.recompute();}suspend(){}resume(){this.recompute();}stop(){}recompute(){if(!this.ctx)return;let e=this.ctx.bars(),t=this.spec.compute(e,this.inputs),n=this.spec.type,i=[],o=new Map;t.plots.forEach((c,u)=>{let d=c.kind??"line",h=Jn({instanceId:n,kind:d,title:c.title,ordinal:u});o.set(c.key,h),i.push({id:h,title:c.title,paneId:"",kind:d,points:TI(e,c.values,c.colors),style:{color:c.color,width:c.width??1,lineStyle:c.lineStyle??"solid",...c.base!=null?{base:c.base}:{}},...c.overlay?{overlay:true}:{}});}),t.markers&&t.markers.length>0&&i.push({id:Jn({instanceId:n,kind:"markers",title:"markers",ordinal:0}),title:this.spec.shortTitle??this.spec.title,paneId:"",kind:"markers",markers:t.markers});let s=(t.bands??[]).flatMap((c,u)=>{let d=o.get(c.from),h=o.get(c.to);return !d||!h?[]:[{id:Jn({instanceId:n,kind:"fill",title:c.key,ordinal:u}),paneId:"",fromSeriesId:d,toSeriesId:h,color:c.color}]}),a=(t.levels??[]).map((c,u)=>({id:Jn({instanceId:n,kind:"hline",title:c.key,ordinal:u}),paneId:"",price:c.price,...c.color!=null?{color:c.color}:{},lineStyle:c.lineStyle??"dashed",width:1,...c.title!=null?{title:c.title}:{}})),l=(t.polylines??[]).map((c,u)=>{let{key:d,...h}=c;return {id:Jn({instanceId:n,kind:"polyline",title:d,ordinal:u}),paneId:"",...h}});this.ctx.emit({series:i,fills:s,priceLines:a,polylines:l}),this.ctx.setStatus("idle");}};function zx(r){return {type:r.type,title:r.title,...r.shortTitle!=null?{shortTitle:r.shortTitle}:{},paneHint:r.overlay?"price":"new",overlay:r.overlay,multiInstance:true,inputsSchema:()=>r.inputs,defaultInputs:()=>Object.fromEntries(r.inputs.map(e=>[e.key,e.defval])),create:()=>new Tp(r)}}var $x=["Close","Open","High","Low","HL2","HLC3","OHLC4","HLCC4"];function ee(r,e){let t=new Array(r.length);for(let n=0;n<r.length;n++){let i=r[n];switch(e){case "Open":t[n]=i.open;break;case "High":t[n]=i.high;break;case "Low":t[n]=i.low;break;case "HL2":t[n]=(i.high+i.low)/2;break;case "HLC3":t[n]=(i.high+i.low+i.close)/3;break;case "OHLC4":t[n]=(i.open+i.high+i.low+i.close)/4;break;case "HLCC4":t[n]=(i.high+i.low+i.close+i.close)/4;break;default:t[n]=i.close;}}return t}function xt(r){return r.map(e=>e.volume!=null&&Number.isFinite(e.volume)?e.volume:Number.NaN)}function Ue(r){return r.map(e=>e.high)}function Ye(r){return r.map(e=>e.low)}function Oe(r){return r.map(e=>e.close)}function Wx(r){return r.map(e=>e.open)}function K(r,e,t){let n=new Array(r.length);for(let i=0;i<r.length;i++){let o=r[i],s=e[i];n[i]=Number.isFinite(o)&&Number.isFinite(s)?t(o,s):Number.NaN;}return n}function ae(r,e){let t=new Array(r.length);for(let n=0;n<r.length;n++){let i=r[n];t[n]=Number.isFinite(i)?e(i):Number.NaN;}return t}function ke(r,e){return K(r,e,(t,n)=>t-n)}function Ln(r,e,t){let n=new Array(r.length).fill(Number.NaN);if(e<=0)return n;let i=0;for(let o=0;o<r.length;o++)i=Number.isFinite(r[o])?i+1:0,i>=e&&(n[o]=t(r,o-e+1,o));return n}function xe(r,e){return Ln(r,e,(t,n,i)=>{let o=0;for(let s=n;s<=i;s++)o+=t[s];return o})}function ge(r,e){return Ln(r,e,(t,n,i)=>{let o=0;for(let s=n;s<=i;s++)o+=t[s];return o/e})}function uu(r,e){let t=e*(e+1)/2;return Ln(r,e,(n,i,o)=>{let s=0;for(let a=i;a<=o;a++)s+=n[a]*(a-i+1);return s/t})}function Gx(r,e,t){let n=K(r,e,(i,o)=>i*o);return K(xe(n,t),xe(e,t),(i,o)=>o>0?i/o:Number.NaN)}function sn(r,e){return Ln(r,e,(t,n,i)=>{let o=0;for(let l=n;l<=i;l++)o+=t[l];let s=o/e,a=0;for(let l=n;l<=i;l++){let c=t[l]-s;a+=c*c;}return Math.sqrt(a/e)})}function ct(r,e){return Ln(r,e,(t,n,i)=>{let o=-1/0;for(let s=n;s<=i;s++)t[s]>o&&(o=t[s]);return o})}function St(r,e){return Ln(r,e,(t,n,i)=>{let o=1/0;for(let s=n;s<=i;s++)t[s]<o&&(o=t[s]);return o})}function Ux(r,e){return Ln(r,e,(t,n,i)=>{let o=-1/0,s=i;for(let a=n;a<=i;a++)t[a]>=o&&(o=t[a],s=a);return i-s})}function Yx(r,e){return Ln(r,e,(t,n,i)=>{let o=1/0,s=i;for(let a=n;a<=i;a++)t[a]<=o&&(o=t[a],s=a);return i-s})}function Kx(r,e,t){let n=new Array(r.length).fill(Number.NaN),i=0,o=Number.NaN;for(let s=0;s<r.length;s++){let a=r[s];if(!Number.isFinite(a)){i=0,o=Number.NaN;continue}if(i+=1,Number.isFinite(o))o=t*a+(1-t)*o,n[s]=o;else if(i>=e){let l=0;for(let c=s-e+1;c<=s;c++)l+=r[c];o=l/e,n[s]=o;}}return n}function Q(r,e){return Kx(r,e,2/(e+1))}function Pe(r,e){return Kx(r,e,1/e)}function ze(r,e=1){let t=new Array(r.length).fill(Number.NaN);for(let n=e;n<r.length;n++){let i=r[n],o=r[n-e];Number.isFinite(i)&&Number.isFinite(o)&&(t[n]=i-o);}return t}function Vt(r,e){let t=new Array(r.length).fill(Number.NaN);for(let n=e;n<r.length;n++){let i=r[n],o=r[n-e];Number.isFinite(i)&&Number.isFinite(o)&&o!==0&&(t[n]=100*(i-o)/o);}return t}function ot(r,e){let t=new Array(r.length).fill(Number.NaN);for(let n=0;n<r.length;n++){let i=n-e;i>=0&&i<r.length&&(t[n]=r[i]);}return t}function Qn(r){let e=new Array(r.length).fill(Number.NaN);for(let t=0;t<r.length;t++){let n=r[t];if(t===0){e[t]=n.high-n.low;continue}let i=r[t-1].close;e[t]=Math.max(n.high-n.low,Math.abs(n.high-i),Math.abs(n.low-i));}return e}function Hr(r,e){return Pe(Qn(r),e)}function Ls(r,e){let t=ze(r),n=ae(t,o=>Math.max(o,0)),i=ae(t,o=>Math.max(-o,0));return K(Pe(n,e),Pe(i,e),(o,s)=>s===0?100:100-100/(1+o/s))}function du(r,e,t,n){let i=ct(e,n),o=St(t,n),s=new Array(r.length).fill(Number.NaN);for(let a=0;a<r.length;a++){let l=r[a],c=i[a],u=o[a];!Number.isFinite(l)||!Number.isFinite(c)||!Number.isFinite(u)||(s[a]=c===u?50:100*(l-u)/(c-u));}return s}function hu(r,e){let t=(e-1)*e/2,n=(e-1)*e*(2*e-1)/6,i=e*n-t*t;return Ln(r,e,(o,s,a)=>{let l=0,c=0;for(let h=s;h<=a;h++){let p=h-s;l+=o[h],c+=p*o[h];}let u=i===0?0:(e*c-t*l)/i;return (l-u*t)/e+u*(e-1)})}function pu(r){let e=new Array(r.length).fill(Number.NaN);for(let t=3;t<r.length;t++){let n=r[t-3],i=r[t-2],o=r[t-1],s=r[t];Number.isFinite(n)&&Number.isFinite(i)&&Number.isFinite(o)&&Number.isFinite(s)&&(e[t]=(n+2*i+2*o+s)/6);}return e}function Xx(r,e){let t=new Array(r.length).fill(Number.NaN);for(let n=e;n<r.length;n++){let i=r[n];if(!Number.isFinite(i))continue;let o=0,s=0;for(let a=n-e;a<n;a++){let l=r[a];if(!Number.isFinite(l)){s=-1;break}s+=1,l<=i&&(o+=1);}s===e&&(t[n]=100*o/e);}return t}function Ms(r){let e=new Array(r.length).fill(Number.NaN),t=0,n=false;for(let i=0;i<r.length;i++){let o=r[i];Number.isFinite(o)&&(t+=o,n=true),n&&(e[i]=t);}return e}function D(r,e="length",t="Length",n=5e3){return {key:e,title:t,type:"int",defval:r,min:1,max:n,step:1}}function be(r="Close"){return {key:"source",title:"Source",type:"string",defval:r,options:$x}}function X(r=_,e="Color",t="color"){return {key:t,title:e,type:"color",defval:r}}function Mn(r,e=.08){let t=/^#([0-9a-f]{6})$/i.exec(r.trim());if(!t)return r;let n=Math.round(e*255).toString(16).padStart(2,"0");return `#${t[1]}${n}`}var kI=["SMA","EMA","WMA","RMA","VWMA"],jx={key:"offset",title:"Offset",type:"int",defval:0,min:-500,max:500,step:1};function qx(r,e,t,n){return {type:r,title:e,shortTitle:t,overlay:true,inputs:[D(20),be(),jx,X()],compute:(i,o)=>{let s=I(o,"length",20),a=n(ee(i,F(o,"source","Close")),s),l=Math.trunc(I(o,"offset",0));return l!==0&&(a=ot(a,l)),{plots:[{key:t.toLowerCase(),title:t,values:a,color:F(o,"color",_),width:2}]}}}}var EI=qx("sma","Simple Moving Average","SMA",ge),LI=qx("ema","Exponential Moving Average","EMA",Q),MI={type:"moving-average",title:"Moving Average",shortTitle:"MA",overlay:true,inputs:[{key:"maType",title:"Type",type:"string",defval:"SMA",options:kI},D(20),be(),jx,X()],compute:(r,e)=>{let t=I(e,"length",20),n=ee(r,F(e,"source","Close")),i=F(e,"maType","SMA"),o;switch(i){case "EMA":o=Q(n,t);break;case "WMA":o=uu(n,t);break;case "RMA":o=Pe(n,t);break;case "VWMA":o=Gx(n,xt(r),t);break;default:o=ge(n,t);}let s=Math.trunc(I(e,"offset",0));return s!==0&&(o=ot(o,s)),{plots:[{key:"ma",title:i,values:o,color:F(e,"color",_),width:2}]}}},PI={type:"rma",title:"Smoothed Moving Average",shortTitle:"RMA",overlay:true,inputs:[D(14),be(),X()],compute:(r,e)=>({plots:[{key:"rma",title:"RMA",values:Pe(ee(r,F(e,"source","Close")),I(e,"length",14)),color:F(e,"color",_),width:2}]})},II={type:"zlema",title:"Zero-Lag Exponential Moving Average",shortTitle:"ZLEMA",overlay:true,inputs:[D(14),be(),X()],compute:(r,e)=>{let t=I(e,"length",14),n=ee(r,F(e,"source","Close")),i=Math.floor((t-1)/2),o=ot(n,i),s=K(n,o,(a,l)=>2*a-l);return {plots:[{key:"zlema",title:"ZLEMA",values:Q(s,t),color:F(e,"color",_),width:2}]}}},AI={type:"vidya",title:"Variable Index Dynamic Average",shortTitle:"VIDYA",overlay:true,inputs:[D(14),{key:"cmoLength",title:"Momentum length",type:"int",defval:9,min:1,max:500,step:1},be(),X()],compute:(r,e)=>{let t=I(e,"length",14),n=I(e,"cmoLength",9),i=ee(r,F(e,"source","Close")),o=ze(i),s=new Array(i.length).fill(Number.NaN),a=new Array(i.length).fill(Number.NaN);for(let d=n;d<i.length;d++){let h=0,p=0,m=true;for(let f=d-n+1;f<=d;f++){let g=o[f];if(!Number.isFinite(g)){m=false;break}g>0?h+=g:p-=g;}m&&(s[d]=h,a[d]=p);}let l=2/(t+1),c=new Array(i.length).fill(Number.NaN),u=Number.NaN;for(let d=0;d<i.length;d++){let h=i[d],p=s[d],m=a[d];if(!Number.isFinite(h)||!Number.isFinite(p)||!Number.isFinite(m))continue;let f=p+m,g=f===0?0:Math.abs((p-m)/f);u=Number.isFinite(u)?l*g*h+(1-l*g)*u:h,c[d]=u;}return {plots:[{key:"vidya",title:"VIDYA",values:c,color:F(e,"color",_),width:2}]}}},RI={type:"ma-envelope",title:"Moving Average Envelope",shortTitle:"MA Env",overlay:true,inputs:[{key:"maType",title:"Type",type:"string",defval:"SMA",options:["SMA","EMA"]},D(20),be(),{key:"percent",title:"Percent",type:"float",defval:2.5,min:.01,max:50,step:.1},X()],compute:(r,e)=>{let t=I(e,"length",20),n=ee(r,F(e,"source","Close")),i=F(e,"maType","SMA")==="EMA"?Q(n,t):ge(n,t),o=I(e,"percent",2.5)/100,s=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:i,color:s,width:2},{key:"upper",title:"Upper",values:ae(i,a=>a*(1+o)),color:s},{key:"lower",title:"Lower",values:ae(i,a=>a*(1-o)),color:s}],bands:[{key:"envelope",from:"upper",to:"lower",color:Mn(s)}]}}},DI={type:"linear-regression",title:"Linear Regression Curve",shortTitle:"LinReg",overlay:true,inputs:[D(14),be(),X()],compute:(r,e)=>({plots:[{key:"linreg",title:"LinReg",values:hu(ee(r,F(e,"source","Close")),I(e,"length",14)),color:F(e,"color",_),width:2}]})},Zx=[EI,LI,MI,PI,II,AI,RI,DI];function Ep(r,e){let t=I(e,"length",20),n=I(e,"mult",2),i=ee(r,F(e,"source","Close")),o=ge(i,t),s=ae(sn(i,t),a=>a*n);return {basis:o,upper:K(o,s,(a,l)=>a+l),lower:K(o,s,(a,l)=>a-l)}}var Lp=[D(20),be(),{key:"mult",title:"StdDev",type:"float",defval:2,min:.1,max:50,step:.1}],OI={type:"bollinger-bands",title:"Bollinger Bands",shortTitle:"BB",overlay:true,inputs:[...Lp,X()],compute:(r,e)=>{let{basis:t,upper:n,lower:i}=Ep(r,e),o=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:t,color:ue},{key:"upper",title:"Upper",values:n,color:o},{key:"lower",title:"Lower",values:i,color:o}],bands:[{key:"bb",from:"upper",to:"lower",color:Mn(o)}]}}},NI={type:"percent-b",title:"Bollinger Bands %B",shortTitle:"%B",overlay:false,inputs:[...Lp,X()],compute:(r,e)=>{let{upper:t,lower:n}=Ep(r,e);return {plots:[{key:"pb",title:"%B",values:ee(r,F(e,"source","Close")).map((s,a)=>{let l=t[a],c=n[a];return Number.isFinite(l)&&Number.isFinite(c)&&l!==c?(s-c)/(l-c):Number.NaN}),color:F(e,"color",_),width:2}],levels:[{key:"upper",price:1,color:J},{key:"middle",price:.5,color:J,lineStyle:"dotted"},{key:"lower",price:0,color:J}]}}},FI={type:"bandwidth",title:"Bollinger Bands Width",shortTitle:"BandWidth",overlay:false,inputs:[...Lp,X()],compute:(r,e)=>{let{basis:t,upper:n,lower:i}=Ep(r,e);return {plots:[{key:"bbw",title:"BBW",values:t.map((s,a)=>{let l=n[a],c=i[a];return Number.isFinite(s)&&s!==0&&Number.isFinite(l)&&Number.isFinite(c)?(l-c)/s*100:Number.NaN}),color:F(e,"color",_),width:2}]}}},VI={type:"keltner-channels",title:"Keltner Channels",shortTitle:"KC",overlay:true,inputs:[D(20),{key:"mult",title:"Multiplier",type:"float",defval:2,min:.1,max:50,step:.1},{key:"atrLength",title:"ATR length",type:"int",defval:10,min:1,max:500,step:1},be(),X()],compute:(r,e)=>{let t=I(e,"length",20),n=I(e,"mult",2),i=Q(ee(r,F(e,"source","Close")),t),o=ae(Hr(r,I(e,"atrLength",10)),a=>a*n),s=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:i,color:ue},{key:"upper",title:"Upper",values:K(i,o,(a,l)=>a+l),color:s},{key:"lower",title:"Lower",values:K(i,o,(a,l)=>a-l),color:s}],bands:[{key:"kc",from:"upper",to:"lower",color:Mn(s)}]}}},_I={type:"donchian-channels",title:"Donchian Channels",shortTitle:"DC",overlay:true,inputs:[D(20),X()],compute:(r,e)=>{let t=I(e,"length",20),n=ct(Ue(r),t),i=St(Ye(r),t),o=F(e,"color",_);return {plots:[{key:"basis",title:"Basis",values:K(n,i,(s,a)=>(s+a)/2),color:ue},{key:"upper",title:"Upper",values:n,color:o},{key:"lower",title:"Lower",values:i,color:o}],bands:[{key:"dc",from:"upper",to:"lower",color:Mn(o)}]}}},BI={type:"chandelier-exit",title:"Chandelier Exit",shortTitle:"CE",overlay:true,inputs:[D(22),{key:"mult",title:"ATR multiplier",type:"float",defval:3,min:.1,max:50,step:.1}],compute:(r,e)=>{let t=I(e,"length",22),n=ae(Hr(r,t),s=>s*I(e,"mult",3)),i=K(ct(Ue(r),t),n,(s,a)=>s-a),o=K(St(Ye(r),t),n,(s,a)=>s+a);return {plots:[{key:"long",title:"Long stop",values:i,color:z},{key:"short",title:"Short stop",values:o,color:W}]}}},HI={type:"chande-kroll-stop",title:"Chande Kroll Stop",shortTitle:"CKS",overlay:true,inputs:[{key:"p",title:"ATR length",type:"int",defval:10,min:1,max:500,step:1},{key:"x",title:"ATR multiplier",type:"float",defval:1,min:.1,max:50,step:.1},{key:"q",title:"Stop length",type:"int",defval:9,min:1,max:500,step:1}],compute:(r,e)=>{let t=I(e,"p",10),n=I(e,"x",1),i=I(e,"q",9),o=ae(Hr(r,t),l=>l*n),s=K(ct(Ue(r),t),o,(l,c)=>l-c),a=K(St(Ye(r),t),o,(l,c)=>l+c);return {plots:[{key:"stopShort",title:"Stop short",values:ct(s,i),color:W},{key:"stopLong",title:"Stop long",values:St(a,i),color:z}]}}},zI={type:"supertrend",title:"SuperTrend",shortTitle:"SuperTrend",overlay:true,inputs:[{key:"atrLength",title:"ATR length",type:"int",defval:10,min:1,max:500,step:1},{key:"mult",title:"Factor",type:"float",defval:3,min:.1,max:50,step:.1}],compute:(r,e)=>{let t=I(e,"atrLength",10),n=I(e,"mult",3),i=Hr(r,t),o=r.length,s=new Array(o).fill(Number.NaN),a=new Array(o).fill(1),l=Number.NaN,c=Number.NaN,u=1;for(let h=0;h<o;h++){let p=i[h];if(!Number.isFinite(p))continue;let m=r[h],f=(m.high+m.low)/2,g=f-n*p,b=f+n*p,y=h>0?r[h-1].close:m.close;l=Number.isFinite(l)&&y>l?Math.max(g,l):g,c=Number.isFinite(c)&&y<c?Math.min(b,c):b,u===1&&m.close<l?u=-1:u===-1&&m.close>c&&(u=1),a[h]=u,s[h]=u===1?l:c;}let d=a.map((h,p)=>Number.isFinite(s[p])?h===1?z:W:null);return {plots:[{key:"st",title:"SuperTrend",values:s,color:z,width:2,colors:d}]}}},$I={type:"williams-alligator",title:"Williams Alligator",shortTitle:"Alligator",overlay:true,inputs:[{key:"jawLength",title:"Jaw length",type:"int",defval:13,min:1,max:500,step:1},{key:"teethLength",title:"Teeth length",type:"int",defval:8,min:1,max:500,step:1},{key:"lipsLength",title:"Lips length",type:"int",defval:5,min:1,max:500,step:1},{key:"jawOffset",title:"Jaw offset",type:"int",defval:8,min:0,max:100,step:1},{key:"teethOffset",title:"Teeth offset",type:"int",defval:5,min:0,max:100,step:1},{key:"lipsOffset",title:"Lips offset",type:"int",defval:3,min:0,max:100,step:1}],compute:(r,e)=>{let t=ee(r,"HL2"),n=ot(Pe(t,I(e,"jawLength",13)),I(e,"jawOffset",8)),i=ot(Pe(t,I(e,"teethLength",8)),I(e,"teethOffset",5)),o=ot(Pe(t,I(e,"lipsLength",5)),I(e,"lipsOffset",3));return {plots:[{key:"jaw",title:"Jaw",values:n,color:_},{key:"teeth",title:"Teeth",values:i,color:W},{key:"lips",title:"Lips",values:o,color:z}]}}},WI={type:"gator-oscillator",title:"Gator Oscillator",shortTitle:"Gator Oscillator",overlay:false,inputs:[],compute:r=>{let e=ee(r,"HL2"),t=ot(Pe(e,13),8),n=ot(Pe(e,8),5),i=ot(Pe(e,5),3),o=ae(ke(t,n),Math.abs),s=ae(ke(n,i),l=>-Math.abs(l)),a=l=>l.map((c,u)=>{if(!Number.isFinite(c))return null;let d=u>0?l[u-1]:Number.NaN;return Number.isFinite(d)&&Math.abs(c)>Math.abs(d)?z:W});return {plots:[{key:"upper",title:"Upper",values:o,kind:"histogram",color:z,colors:a(o),base:0},{key:"lower",title:"Lower",values:s,kind:"histogram",color:W,colors:a(s),base:0}]}}},Jx=[OI,NI,FI,VI,_I,BI,HI,zI,$I,WI];function an(r,e,t){let n=[{key:"upper",price:e,color:J},{key:"lower",price:r,color:J}];return t!=null&&n.splice(1,0,{key:"middle",price:t,color:J,lineStyle:"dotted"}),n}var st=[{key:"zero",price:0,color:J}];function mu(r){return r.map((e,t)=>{if(!Number.isFinite(e))return null;let n=t>0?r[t-1]:Number.NaN,i=Number.isFinite(n)?e>=n:true;return e>=0?i?z:`${z}80`:i?`${W}80`:W})}var GI={type:"rsi",title:"Relative Strength Index",shortTitle:"RSI",overlay:false,inputs:[D(14),be(),X()],compute:(r,e)=>({plots:[{key:"rsi",title:"RSI",values:Ls(ee(r,F(e,"source","Close")),I(e,"length",14)),color:F(e,"color",_),width:2}],levels:an(30,70,50)})},UI={type:"stochastic",title:"Stochastic",shortTitle:"Stoch",overlay:false,inputs:[D(14,"kLength","%K length"),D(1,"kSmoothing","%K smoothing",500),D(3,"dLength","%D smoothing",500)],compute:(r,e)=>{let t=ge(du(Oe(r),Ue(r),Ye(r),I(e,"kLength",14)),I(e,"kSmoothing",1)),n=ge(t,I(e,"dLength",3));return {plots:[{key:"k",title:"%K",values:t,color:_,width:2},{key:"d",title:"%D",values:n,color:ue}],levels:an(20,80)}}},YI={type:"stochastic-rsi",title:"Stochastic RSI",shortTitle:"Stoch RSI",overlay:false,inputs:[D(14,"rsiLength","RSI length"),D(14,"stochLength","Stochastic length"),D(3,"kSmoothing","%K smoothing",500),D(3,"dLength","%D smoothing",500),be()],compute:(r,e)=>{let t=Ls(ee(r,F(e,"source","Close")),I(e,"rsiLength",14)),n=ge(du(t,t,t,I(e,"stochLength",14)),I(e,"kSmoothing",3)),i=ge(n,I(e,"dLength",3));return {plots:[{key:"k",title:"%K",values:n,color:_,width:2},{key:"d",title:"%D",values:i,color:ue}],levels:an(20,80)}}},KI={type:"macd",title:"MACD",overlay:false,inputs:[D(12,"fastLength","Fast length"),D(26,"slowLength","Slow length"),D(9,"signalLength","Signal smoothing",500),be()],compute:(r,e)=>{let t=ee(r,F(e,"source","Close")),n=ke(Q(t,I(e,"fastLength",12)),Q(t,I(e,"slowLength",26))),i=Q(n,I(e,"signalLength",9)),o=ke(n,i);return {plots:[{key:"hist",title:"Histogram",values:o,kind:"histogram",color:z,colors:mu(o),base:0},{key:"macd",title:"MACD",values:n,color:_,width:2},{key:"signal",title:"Signal",values:i,color:ue}],levels:st}}},XI={type:"ppo",title:"Percentage Price Oscillator",shortTitle:"PPO",overlay:false,inputs:[D(12,"fastLength","Fast length"),D(26,"slowLength","Slow length"),D(9,"signalLength","Signal smoothing",500),be()],compute:(r,e)=>{let t=ee(r,F(e,"source","Close")),n=Q(t,I(e,"fastLength",12)),i=Q(t,I(e,"slowLength",26)),o=K(n,i,(l,c)=>c===0?Number.NaN:(l-c)/c*100),s=Q(o,I(e,"signalLength",9)),a=ke(o,s);return {plots:[{key:"hist",title:"Histogram",values:a,kind:"histogram",color:z,colors:mu(a),base:0},{key:"ppo",title:"PPO",values:o,color:_,width:2},{key:"signal",title:"Signal",values:s,color:ue}],levels:st}}},jI={type:"awesome-oscillator",title:"Awesome Oscillator",shortTitle:"AO",overlay:false,inputs:[],compute:r=>{let e=ee(r,"HL2"),t=ke(ge(e,5),ge(e,34)),n=t.map((i,o)=>{if(!Number.isFinite(i))return null;let s=o>0?t[o-1]:Number.NaN;return Number.isFinite(s)&&i<s?W:z});return {plots:[{key:"ao",title:"AO",values:t,kind:"histogram",color:z,colors:n,base:0}],levels:st}}},qI={type:"commodity-channel-index",title:"Commodity Channel Index",shortTitle:"CCI",overlay:false,inputs:[D(20),be("HLC3"),X()],compute:(r,e)=>{let t=I(e,"length",20),n=ee(r,F(e,"source","HLC3")),i=ge(n,t),o=new Array(n.length).fill(Number.NaN);for(let a=t-1;a<n.length;a++){let l=i[a];if(!Number.isFinite(l))continue;let c=0;for(let u=a-t+1;u<=a;u++)c+=Math.abs(n[u]-l);o[a]=c/t;}return {plots:[{key:"cci",title:"CCI",values:n.map((a,l)=>{let c=i[l],u=o[l];return Number.isFinite(c)&&Number.isFinite(u)&&u!==0?(a-c)/(.015*u):Number.NaN}),color:F(e,"color",_),width:2}],levels:an(-100,100,0)}}},ZI={type:"williams-percent-r",title:"Williams %R",shortTitle:"%R",overlay:false,inputs:[D(14),X()],compute:(r,e)=>({plots:[{key:"wr",title:"%R",values:ae(du(Oe(r),Ue(r),Ye(r),I(e,"length",14)),n=>n-100),color:F(e,"color",_),width:2}],levels:an(-80,-20)})},JI={type:"chande-momentum-oscillator",title:"Chande Momentum Oscillator",shortTitle:"CMO",overlay:false,inputs:[D(9),be(),X()],compute:(r,e)=>{let t=I(e,"length",9),n=ze(ee(r,F(e,"source","Close"))),i=xe(ae(n,a=>Math.max(a,0)),t),o=xe(ae(n,a=>Math.max(-a,0)),t);return {plots:[{key:"cmo",title:"CMO",values:K(i,o,(a,l)=>a+l===0?0:100*(a-l)/(a+l)),color:F(e,"color",_),width:2}],levels:an(-50,50,0)}}},QI={type:"connors-rsi",title:"Connors RSI",shortTitle:"CRSI",overlay:false,inputs:[D(3,"rsiLength","RSI length"),D(2,"streakLength","Streak RSI length"),D(100,"rankLength","Percent-rank length"),X()],compute:(r,e)=>{let t=Oe(r),n=new Array(t.length).fill(0);for(let l=1;l<t.length;l++){let c=t[l]-t[l-1];n[l]=c>0?Math.max(n[l-1],0)+1:c<0?Math.min(n[l-1],0)-1:0;}let i=Ls(t,I(e,"rsiLength",3)),o=Ls(n,I(e,"streakLength",2)),s=Xx(Vt(t,1),I(e,"rankLength",100));return {plots:[{key:"crsi",title:"CRSI",values:t.map((l,c)=>{let u=i[c],d=o[c],h=s[c];return Number.isFinite(u)&&Number.isFinite(d)&&Number.isFinite(h)?(u+d+h)/3:Number.NaN}),color:F(e,"color",_),width:2}],levels:an(20,80,50)}}},eA={type:"fisher-transform",title:"Fisher Transform",shortTitle:"Fisher",overlay:false,inputs:[D(9)],compute:(r,e)=>{let t=I(e,"length",9),n=ee(r,"HL2"),i=ct(n,t),o=St(n,t),s=r.length,a=new Array(s).fill(Number.NaN),l=0,c=0;for(let u=0;u<s;u++){let d=i[u],h=o[u];if(!Number.isFinite(d)||!Number.isFinite(h))continue;let p=d===h?0:(n[u]-h)/(d-h)-.5;l=Math.max(-0.999,Math.min(.999,.66*p+.67*l)),c=.5*Math.log((1+l)/(1-l))+.5*c,a[u]=c;}return {plots:[{key:"fisher",title:"Fisher",values:a,color:_,width:2},{key:"trigger",title:"Trigger",values:ot(a,1),color:ue}],levels:st}}},tA={type:"trix",title:"TRIX",overlay:false,inputs:[D(18),X()],compute:(r,e)=>{let t=I(e,"length",18),n=ae(Oe(r),Math.log),i=Q(Q(Q(n,t),t),t);return {plots:[{key:"trix",title:"TRIX",values:ae(ze(i),s=>s*1e4),color:F(e,"color",_),width:2}],levels:st}}};function Qx(r,e,t){let n=ze(r),i=Q(Q(n,e),t),o=Q(Q(ae(n,Math.abs),e),t);return K(i,o,(s,a)=>a===0?0:100*s/a)}var nA={type:"true-strength-index",title:"True Strength Index",shortTitle:"TSI",overlay:false,inputs:[D(25,"longLength","Long length"),D(13,"shortLength","Short length"),D(13,"signalLength","Signal length")],compute:(r,e)=>{let t=Qx(Oe(r),I(e,"longLength",25),I(e,"shortLength",13));return {plots:[{key:"tsi",title:"TSI",values:t,color:_,width:2},{key:"signal",title:"Signal",values:Q(t,I(e,"signalLength",13)),color:ue}],levels:st}}},rA={type:"smi-ergodic",title:"SMI Ergodic Oscillator",shortTitle:"SMIE",overlay:false,inputs:[D(5,"shortLength","Short length"),D(20,"longLength","Long length"),D(5,"signalLength","Signal length")],compute:(r,e)=>{let t=Qx(Oe(r),I(e,"longLength",20),I(e,"shortLength",5)),n=Q(t,I(e,"signalLength",5)),i=ke(t,n);return {plots:[{key:"osc",title:"Oscillator",values:i,kind:"histogram",color:z,colors:mu(i),base:0},{key:"smi",title:"SMI",values:t,color:_,width:2},{key:"signal",title:"Signal",values:n,color:ue}],levels:st}}},iA={type:"schaff-trend-cycle",title:"Schaff Trend Cycle",shortTitle:"Schaff Trend Cycle",overlay:false,inputs:[D(10,"cycleLength","Cycle length"),D(23,"fastLength","Fast length"),D(50,"slowLength","Slow length")],compute:(r,e)=>{let t=I(e,"cycleLength",10),n=Oe(r),i=ke(Q(n,I(e,"fastLength",23)),Q(n,I(e,"slowLength",50))),o=a=>{let l=St(a,t),c=ct(a,t),u=new Array(a.length).fill(Number.NaN),d=Number.NaN,h=Number.NaN;for(let p=0;p<a.length;p++){let m=a[p],f=l[p],g=c[p];if(!Number.isFinite(m)||!Number.isFinite(f)||!Number.isFinite(g))continue;let b=g>f?(m-f)/(g-f)*100:Number.isFinite(d)?d:50;d=b,h=Number.isFinite(h)?h+.5*(b-h):b,u[p]=h;}return u};return {plots:[{key:"stc",title:"STC",values:o(o(i)),color:_,width:2}],levels:an(25,75)}}},oA={type:"know-sure-thing",title:"Know Sure Thing",shortTitle:"KST",overlay:false,inputs:[be(),D(9,"signalLength","Signal length")],compute:(r,e)=>{let t=ee(r,F(e,"source","Close")),n=[ge(Vt(t,10),10),ge(Vt(t,15),10),ge(Vt(t,20),10),ge(Vt(t,30),15)].reduce((i,o,s)=>K(i,o,(a,l)=>a+l*(s+1)),new Array(t.length).fill(0));return {plots:[{key:"kst",title:"KST",values:n,color:_,width:2},{key:"signal",title:"Signal",values:ge(n,I(e,"signalLength",9)),color:ue}],levels:st}}},sA={type:"coppock-curve",title:"Coppock Curve",shortTitle:"Coppock",overlay:false,inputs:[D(10,"wmaLength","WMA length"),D(14,"longRoc","Long RoC length"),D(11,"shortRoc","Short RoC length"),be(),X()],compute:(r,e)=>{let t=ee(r,F(e,"source","Close"));return {plots:[{key:"coppock",title:"Coppock",values:uu(K(Vt(t,I(e,"longRoc",14)),Vt(t,I(e,"shortRoc",11)),(i,o)=>i+o),I(e,"wmaLength",10)),color:F(e,"color",_),width:2}],levels:st}}},aA={type:"detrended-price-oscillator",title:"Detrended Price Oscillator",shortTitle:"DPO",overlay:false,inputs:[D(21),X()],compute:(r,e)=>{let t=I(e,"length",21),n=Math.floor(t/2)+1;return {plots:[{key:"dpo",title:"DPO",values:ke(Oe(r),ot(ge(Oe(r),t),n)),color:F(e,"color",_),width:2}],levels:st}}},lA={type:"rate-of-change",title:"Rate of Change",shortTitle:"ROC",overlay:false,inputs:[D(9),be(),X()],compute:(r,e)=>({plots:[{key:"roc",title:"RoC",values:Vt(ee(r,F(e,"source","Close")),I(e,"length",9)),color:F(e,"color",_),width:2}],levels:st})},cA={type:"ultimate-oscillator",title:"Ultimate Oscillator",shortTitle:"UO",overlay:false,inputs:[D(7,"fastLength","Fast length"),D(14,"middleLength","Middle length"),D(28,"slowLength","Slow length"),X()],compute:(r,e)=>{let t=r.length,n=new Array(t).fill(Number.NaN),i=new Array(t).fill(Number.NaN);for(let u=0;u<t;u++){let d=r[u],h=u>0?r[u-1].close:d.close,p=Math.min(d.low,h),m=Math.max(d.high,h);n[u]=d.close-p,i[u]=m-p;}let o=u=>K(xe(n,u),xe(i,u),(d,h)=>h===0?Number.NaN:d/h),s=o(I(e,"fastLength",7)),a=o(I(e,"middleLength",14)),l=o(I(e,"slowLength",28));return {plots:[{key:"uo",title:"UO",values:s.map((u,d)=>{let h=a[d],p=l[d];return Number.isFinite(u)&&Number.isFinite(h)&&Number.isFinite(p)?100*(4*u+2*h+p)/7:Number.NaN}),color:F(e,"color",_),width:2}],levels:an(30,70,50)}}},uA={type:"relative-vigor-index",title:"Relative Vigor Index",shortTitle:"RVGI",overlay:false,inputs:[D(10)],compute:(r,e)=>{let t=I(e,"length",10),n=pu(ke(Oe(r),Wx(r))),i=pu(ke(Ue(r),Ye(r))),o=K(xe(n,t),xe(i,t),(s,a)=>a===0?0:s/a);return {plots:[{key:"rvgi",title:"RVGI",values:o,color:_,width:2},{key:"signal",title:"Signal",values:pu(o),color:ue}],levels:st}}},dA={type:"relative-volatility-index",title:"Relative Volatility Index",shortTitle:"RVI",overlay:false,inputs:[D(10,"stdevLength","StdDev length"),D(14,"smoothLength","Smoothing length"),be(),X()],compute:(r,e)=>{let t=I(e,"smoothLength",14),n=ee(r,F(e,"source","Close")),i=sn(n,I(e,"stdevLength",10)),o=ze(n),s=Pe(K(i,o,(c,u)=>u>0?c:0),t),a=Pe(K(i,o,(c,u)=>u<=0?c:0),t);return {plots:[{key:"rvi",title:"RVI",values:K(s,a,(c,u)=>c+u===0?50:100*c/(c+u)),color:F(e,"color",_),width:2}],levels:an(20,80,50)}}},hA={type:"balance-of-power",title:"Balance of Power",shortTitle:"BOP",overlay:false,inputs:[X()],compute:(r,e)=>({plots:[{key:"bop",title:"BOP",values:r.map(n=>n.high===n.low?0:(n.close-n.open)/(n.high-n.low)),color:F(e,"color",_),width:2}],levels:st})},pA={type:"elder-ray",title:"Elder Ray",overlay:false,inputs:[D(13)],compute:(r,e)=>{let t=Q(Oe(r),I(e,"length",13));return {plots:[{key:"bull",title:"Bull power",values:ke(Ue(r),t),kind:"histogram",color:z,base:0},{key:"bear",title:"Bear power",values:ke(Ye(r),t),kind:"histogram",color:W,base:0}],levels:st}}},mA={type:"ttm-squeeze",title:"TTM Squeeze",overlay:false,inputs:[D(20),{key:"bbMult",title:"Bollinger multiplier",type:"float",defval:2,min:.1,max:50,step:.1},{key:"kcMult",title:"Keltner multiplier",type:"float",defval:1.5,min:.1,max:50,step:.1}],compute:(r,e)=>{let t=I(e,"length",20),n=Oe(r),i=ge(n,t),o=ae(sn(n,t),h=>h*I(e,"bbMult",2)),s=ae(Pe(Qn(r),t),h=>h*I(e,"kcMult",1.5)),a=K(ct(Ue(r),t),St(Ye(r),t),(h,p)=>(h+p)/2),l=K(a,i,(h,p)=>(h+p)/2),c=hu(ke(n,l),t),d=n.map((h,p)=>{let m=o[p],f=s[p];return Number.isFinite(m)&&Number.isFinite(f)?m<f:false}).map((h,p)=>Number.isFinite(c[p])?h?W:z:null);return {plots:[{key:"mom",title:"Momentum",values:c,kind:"histogram",color:z,colors:mu(c),base:0},{key:"squeeze",title:"Squeeze",values:c.map(h=>Number.isFinite(h)?0:Number.NaN),kind:"cross",color:Je,colors:d}]}}},e0=[GI,UI,YI,KI,XI,jI,qI,ZI,JI,QI,eA,tA,nA,rA,iA,oA,sA,aA,lA,cA,uA,dA,hA,pA,mA];var fA={type:"aroon",title:"Aroon",overlay:false,inputs:[D(14)],compute:(r,e)=>{let t=I(e,"length",14),n=ae(Ux(Ue(r),t+1),o=>100*(t-o)/t),i=ae(Yx(Ye(r),t+1),o=>100*(t-o)/t);return {plots:[{key:"up",title:"Aroon up",values:n,color:z,width:2},{key:"down",title:"Aroon down",values:i,color:W,width:2}]}}},gA={type:"average-directional-index",title:"Average Directional Index",shortTitle:"ADX",overlay:false,inputs:[D(14,"diLength","DI length"),D(14,"adxLength","ADX smoothing")],compute:(r,e)=>{let t=I(e,"diLength",14),n=I(e,"adxLength",14),i=r.length,o=new Array(i).fill(Number.NaN),s=new Array(i).fill(Number.NaN);for(let d=1;d<i;d++){let h=r[d].high-r[d-1].high,p=r[d-1].low-r[d].low;o[d]=h>p&&h>0?h:0,s[d]=p>h&&p>0?p:0;}let a=Pe(Qn(r),t),l=K(Pe(o,t),a,(d,h)=>h===0?0:100*d/h),c=K(Pe(s,t),a,(d,h)=>h===0?0:100*d/h),u=K(l,c,(d,h)=>d+h===0?0:100*Math.abs(d-h)/(d+h));return {plots:[{key:"adx",title:"ADX",values:Pe(u,n),color:_,width:2},{key:"plusDi",title:"+DI",values:l,color:z},{key:"minusDi",title:"-DI",values:c,color:W}],levels:[{key:"threshold",price:25,color:J,lineStyle:"dotted"}]}}},bA={type:"vortex-indicator",title:"Vortex Indicator",shortTitle:"VI",overlay:false,inputs:[D(14)],compute:(r,e)=>{let t=I(e,"length",14),n=r.length,i=new Array(n).fill(Number.NaN),o=new Array(n).fill(Number.NaN);for(let a=1;a<n;a++)i[a]=Math.abs(r[a].high-r[a-1].low),o[a]=Math.abs(r[a].low-r[a-1].high);let s=xe(Qn(r),t);return {plots:[{key:"viPlus",title:"VI+",values:K(xe(i,t),s,(a,l)=>l===0?Number.NaN:a/l),color:z,width:2},{key:"viMinus",title:"VI-",values:K(xe(o,t),s,(a,l)=>l===0?Number.NaN:a/l),color:W,width:2}],levels:[{key:"one",price:1,color:J,lineStyle:"dotted"}]}}},t0=[fA,gA,bA];var vA={type:"average-true-range",title:"Average True Range",shortTitle:"ATR",overlay:false,inputs:[D(14),X()],compute:(r,e)=>({plots:[{key:"atr",title:"ATR",values:Hr(r,I(e,"length",14)),color:F(e,"color",_),width:2}]})},yA={type:"historical-volatility",title:"Historical Volatility",shortTitle:"HV",overlay:false,inputs:[D(10),{key:"annual",title:"Periods per year",type:"int",defval:365,min:1,max:1e5,step:1,tooltip:"Annualization factor (365 for daily crypto bars, 252 for stock sessions)"},X()],compute:(r,e)=>{let t=ae(ze(ae(Oe(r),Math.log)),i=>i);return {plots:[{key:"hv",title:"HV",values:ae(sn(t,I(e,"length",10)),i=>i*Math.sqrt(I(e,"annual",365))*100),color:F(e,"color",_),width:2}]}}},wA={type:"chaikin-volatility",title:"Chaikin Volatility",shortTitle:"CHV",overlay:false,inputs:[D(10,"emaLength","EMA length"),D(10,"rocLength","RoC length"),X()],compute:(r,e)=>{let t=Q(ke(Ue(r),Ye(r)),I(e,"emaLength",10));return {plots:[{key:"cv",title:"Chaikin Vol",values:Vt(t,I(e,"rocLength",10)),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},xA={type:"mass-index",title:"Mass Index",shortTitle:"MI",overlay:false,inputs:[D(25),X()],compute:(r,e)=>{let t=ke(Ue(r),Ye(r)),n=Q(t,9),i=K(n,Q(n,9),(o,s)=>s===0?Number.NaN:o/s);return {plots:[{key:"mi",title:"Mass Index",values:xe(i,I(e,"length",25)),color:F(e,"color",_),width:2}],levels:[{key:"reversal",price:27,color:J,lineStyle:"dotted"}]}}},SA={type:"standard-deviation",title:"Standard Deviation",shortTitle:"StdDev",overlay:false,inputs:[D(20),be(),X()],compute:(r,e)=>({plots:[{key:"stdev",title:"StdDev",values:sn(ee(r,F(e,"source","Close")),I(e,"length",20)),color:F(e,"color",_),width:2}]})},CA={type:"ulcer-index",title:"Ulcer Index",overlay:false,inputs:[D(14),X()],compute:(r,e)=>{let t=I(e,"length",14),n=Oe(r),i=K(n,ct(n,t),(s,a)=>a===0?0:100*(s-a)/a);return {plots:[{key:"ui",title:"Ulcer",values:ae(ge(ae(i,s=>s*s),t),Math.sqrt),color:F(e,"color",_),width:2}]}}},TA={type:"choppiness-index",title:"Choppiness Index",shortTitle:"CHOP",overlay:false,inputs:[D(14),X()],compute:(r,e)=>{let t=I(e,"length",14),n=xe(Qn(r),t),i=K(ct(Ue(r),t),St(Ye(r),t),(s,a)=>s-a);return {plots:[{key:"chop",title:"CHOP",values:K(n,i,(s,a)=>a>0&&s>0?100*Math.log10(s/a)/Math.log10(t):Number.NaN),color:F(e,"color",_),width:2}],levels:[{key:"upper",price:61.8,color:J},{key:"lower",price:38.2,color:J}]}}},n0=[vA,yA,wA,xA,SA,CA,TA];function fu(r){return r.map(e=>e.volume==null||!Number.isFinite(e.volume)?Number.NaN:e.high===e.low?0:(2*e.close-e.high-e.low)/(e.high-e.low)*e.volume)}var kA={type:"on-balance-volume",title:"On Balance Volume",shortTitle:"OBV",overlay:false,inputs:[X()],compute:(r,e)=>{let t=xt(r),n=ze(Oe(r)),i=K(t,n,(o,s)=>s>0?o:s<0?-o:0);return {plots:[{key:"obv",title:"OBV",values:Ms(i),color:F(e,"color",_),width:2}]}}},EA={type:"accumulation-distribution",title:"Accumulation / Distribution",shortTitle:"A/D",overlay:false,inputs:[X()],compute:(r,e)=>({plots:[{key:"ad",title:"A/D",values:Ms(fu(r)),color:F(e,"color",_),width:2}]})},LA={type:"chaikin-money-flow",title:"Chaikin Money Flow",shortTitle:"CMF",overlay:false,inputs:[D(20),X()],compute:(r,e)=>{let t=I(e,"length",20);return {plots:[{key:"cmf",title:"CMF",values:K(xe(fu(r),t),xe(xt(r),t),(i,o)=>o===0?0:i/o),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},MA={type:"chaikin-oscillator",title:"Chaikin Oscillator",shortTitle:"Chaikin Osc",overlay:false,inputs:[D(3,"fastLength","Fast length"),D(10,"slowLength","Slow length"),X()],compute:(r,e)=>{let t=Ms(fu(r));return {plots:[{key:"co",title:"Chaikin Osc",values:ke(Q(t,I(e,"fastLength",3)),Q(t,I(e,"slowLength",10))),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},PA={type:"ease-of-movement",title:"Ease of Movement",shortTitle:"EOM",overlay:false,inputs:[D(14),{key:"divisor",title:"Divisor",type:"int",defval:1e4,min:1,max:1e9,step:1},X()],compute:(r,e)=>{let t=I(e,"divisor",1e4),n=ee(r,"HL2"),i=ze(n),o=r.map((s,a)=>{let l=i[a];return s.volume==null||!Number.isFinite(s.volume)||s.volume===0||!Number.isFinite(l)?Number.NaN:t*l*(s.high-s.low)/s.volume});return {plots:[{key:"eom",title:"EOM",values:ge(o,I(e,"length",14)),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},IA={type:"force-index",title:"Force Index",shortTitle:"FI",overlay:false,inputs:[D(13),X()],compute:(r,e)=>{let t=K(ze(Oe(r)),xt(r),(n,i)=>n*i);return {plots:[{key:"force",title:"Force",values:Q(t,I(e,"length",13)),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},AA={type:"klinger-oscillator",title:"Klinger Oscillator",shortTitle:"KVO",overlay:false,inputs:[D(34,"fastLength","Fast length"),D(55,"slowLength","Slow length"),D(13,"signalLength","Signal length")],compute:(r,e)=>{let t=ee(r,"HLC3"),n=ze(t),i=K(xt(r),n,(s,a)=>a>=0?s:-s),o=ke(Q(i,I(e,"fastLength",34)),Q(i,I(e,"slowLength",55)));return {plots:[{key:"kvo",title:"KVO",values:o,color:_,width:2},{key:"signal",title:"Signal",values:Q(o,I(e,"signalLength",13)),color:ue}],levels:[{key:"zero",price:0,color:J}]}}},RA={type:"money-flow-index",title:"Money Flow Index",shortTitle:"MFI",overlay:false,inputs:[D(14),X()],compute:(r,e)=>{let t=I(e,"length",14),n=ee(r,"HLC3"),i=K(n,xt(r),(c,u)=>c*u),o=ze(n),s=xe(K(i,o,(c,u)=>u>0?c:0),t),a=xe(K(i,o,(c,u)=>u<0?c:0),t);return {plots:[{key:"mfi",title:"MFI",values:K(s,a,(c,u)=>u===0?100:100-100/(1+c/u)),color:F(e,"color",_),width:2}],levels:[{key:"upper",price:80,color:J},{key:"lower",price:20,color:J}]}}};function r0(r,e){let t=new Array(r.length).fill(Number.NaN),n=1e3,i=false;for(let o=1;o<r.length;o++){let s=r[o].volume,a=r[o-1].volume,l=r[o-1].close;if(s==null||a==null||!Number.isFinite(s)||!Number.isFinite(a)||l===0){i&&(t[o]=n);continue}i=true,e(s,a)&&(n+=(r[o].close-l)/l*n),t[o]=n;}return t}var DA={type:"negative-volume-index",title:"Negative Volume Index",shortTitle:"Negative Volume Index",overlay:false,inputs:[D(255,"signalLength","Signal length"),X()],compute:(r,e)=>{let t=r0(r,(n,i)=>n<i);return {plots:[{key:"nvi",title:"NVI",values:t,color:F(e,"color",_),width:2},{key:"signal",title:"Signal",values:Q(t,I(e,"signalLength",255)),color:ue}]}}},OA={type:"positive-volume-index",title:"Positive Volume Index",shortTitle:"Positive Volume Index",overlay:false,inputs:[D(255,"signalLength","Signal length"),X()],compute:(r,e)=>{let t=r0(r,(n,i)=>n>i);return {plots:[{key:"pvi",title:"PVI",values:t,color:F(e,"color",_),width:2},{key:"signal",title:"Signal",values:Q(t,I(e,"signalLength",255)),color:ue}]}}},NA={type:"price-volume-trend",title:"Price Volume Trend",shortTitle:"PVT",overlay:false,inputs:[X()],compute:(r,e)=>{let t=Oe(r),n=r.map((i,o)=>{if(o===0||i.volume==null||!Number.isFinite(i.volume))return Number.NaN;let s=t[o-1];return s===0?0:(t[o]-s)/s*i.volume});return {plots:[{key:"pvt",title:"PVT",values:Ms(n),color:F(e,"color",_),width:2}]}}},FA={type:"volume-oscillator",title:"Volume Oscillator",shortTitle:"Vol Osc",overlay:false,inputs:[D(5,"fastLength","Fast length"),D(10,"slowLength","Slow length"),X()],compute:(r,e)=>{let t=xt(r),n=Q(t,I(e,"fastLength",5)),i=Q(t,I(e,"slowLength",10));return {plots:[{key:"vo",title:"Volume Osc",values:K(n,i,(s,a)=>a===0?Number.NaN:100*(s-a)/a),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},VA={type:"pvo",title:"Percentage Volume Oscillator",shortTitle:"PVO",overlay:false,inputs:[D(12,"fastLength","Fast length"),D(26,"slowLength","Slow length"),D(9,"signalLength","Signal length")],compute:(r,e)=>{let t=xt(r),n=Q(t,I(e,"fastLength",12)),i=Q(t,I(e,"slowLength",26)),o=K(n,i,(l,c)=>c===0?Number.NaN:100*(l-c)/c),s=Q(o,I(e,"signalLength",9)),a=ke(o,s);return {plots:[{key:"hist",title:"Histogram",values:a,kind:"histogram",color:z,colors:a.map(l=>Number.isFinite(l)?l>=0?z:W:null),base:0},{key:"pvo",title:"PVO",values:o,color:_,width:2},{key:"signal",title:"Signal",values:s,color:ue}],levels:[{key:"zero",price:0,color:J}]}}},_A={type:"volume-flow-indicator",title:"Volume Flow Indicator",shortTitle:"Volume Flow Indicator",overlay:false,inputs:[D(130),{key:"coef",title:"Cutoff coefficient",type:"float",defval:.2,min:.01,max:10,step:.01},{key:"volCoef",title:"Volume cap",type:"float",defval:2.5,min:.1,max:50,step:.1},D(3,"smoothLength","Smoothing length")],compute:(r,e)=>{let t=I(e,"length",130),n=I(e,"coef",.2),i=I(e,"volCoef",2.5),o=ae(ee(r,"HLC3"),Math.log),s=ze(o),a=sn(s,30),l=xt(r),c=ge(l,t),u=ze(ee(r,"HLC3")),d=r.map((f,g)=>{let b=Number.isFinite(a[g])?n*a[g]*f.close:Number.NaN,y=l[g],v=g>0?c[g-1]:Number.NaN,S=u[g];if(!Number.isFinite(b)||!Number.isFinite(y)||!Number.isFinite(v)||!Number.isFinite(S))return Number.NaN;let E=Math.min(y,v*i);return S>b?E:S<-b?-E:0}),h=r.map((f,g)=>{let b=g>0?c[g-1]:Number.NaN;return Number.isFinite(b)&&b!==0?b:Number.NaN}),p=xe(d,t),m=K(p,h,(f,g)=>f/g);return {plots:[{key:"vfi",title:"VFI",values:ge(m,I(e,"smoothLength",3)),color:_,width:2}],levels:[{key:"zero",price:0,color:J}]}}},BA={type:"intraday-intensity",title:"Intraday Intensity",shortTitle:"Intraday Intensity",overlay:false,inputs:[D(21),X()],compute:(r,e)=>{let t=I(e,"length",21);return {plots:[{key:"ii",title:"II%",values:K(xe(fu(r),t),xe(xt(r),t),(i,o)=>o===0?0:100*i/o),color:F(e,"color",_),width:2}],levels:[{key:"zero",price:0,color:J}]}}},i0=[kA,EA,LA,MA,PA,IA,AA,RA,DA,OA,NA,FA,VA,_A,BA];var Pp=864e5;function Ip(r,e){if(r==="Week")return Math.floor((Math.floor(e/Pp)+3)/7);if(r==="Month"||r==="Quarter"||r==="Year"){let t=new Date(e);return r==="Year"?t.getUTCFullYear():r==="Quarter"?t.getUTCFullYear()*4+Math.floor(t.getUTCMonth()/3):t.getUTCFullYear()*12+t.getUTCMonth()}return Math.floor(e/Pp)}var HA={type:"parabolic-sar",title:"Parabolic SAR",shortTitle:"SAR",overlay:true,inputs:[{key:"start",title:"Start",type:"float",defval:.02,min:.001,max:1,step:.001},{key:"increment",title:"Increment",type:"float",defval:.02,min:.001,max:1,step:.001},{key:"maximum",title:"Max value",type:"float",defval:.2,min:.01,max:1,step:.01}],compute:(r,e)=>{let t=I(e,"start",.02),n=I(e,"increment",.02),i=I(e,"maximum",.2),o=r.length,s=new Array(o).fill(Number.NaN),a=new Array(o).fill(null);if(o>=2){let l=r[1].close>=r[0].close,c=l?r[0].low:r[0].high,u=l?r[0].high:r[0].low,d=t;for(let h=1;h<o;h++){let p=r[h];c+=d*(u-c),l?c=Math.min(c,r[h-1].low,h>=2?r[h-2].low:r[h-1].low):c=Math.max(c,r[h-1].high,h>=2?r[h-2].high:r[h-1].high),(l?p.low<c:p.high>c)?(l=!l,c=u,u=l?p.high:p.low,d=t):l&&p.high>u?(u=p.high,d=Math.min(i,d+n)):!l&&p.low<u&&(u=p.low,d=Math.min(i,d+n)),s[h]=c,a[h]=l?z:W;}}return {plots:[{key:"sar",title:"PSAR",values:s,kind:"circles",color:_,colors:a}]}}},o0="Bands",gu="Style",Mp=[{on:"band1",mult:"band1Mult",color:"band1Color",fill:"band1Fill",fillColor:"band1FillColor",defMult:1,defOn:true,defColor:z},{on:"band2",mult:"band2Mult",color:"band2Color",fill:"band2Fill",fillColor:"band2FillColor",defMult:2,defOn:false,defColor:ue},{on:"band3",mult:"band3Mult",color:"band3Color",fill:"band3Fill",fillColor:"band3FillColor",defMult:3,defOn:false,defColor:Bs[4]}],zA={type:"vwap",title:"Volume Weighted Average Price",shortTitle:"VWAP",overlay:true,inputs:[{key:"anchor",title:"Period",type:"string",defval:"Day",options:["Day","Week","Month","Quarter","Year"],tooltip:"Where the accumulation resets (UTC periods)"},be("HLC3"),...Mp.flatMap((r,e)=>[{key:r.on,title:`Band ${e+1} multiplier`,type:"bool",defval:r.defOn,inline:r.on,group:o0},{key:r.mult,title:"",type:"float",defval:r.defMult,min:.1,max:10,step:.1,inline:r.on,group:o0}]),{...X(Je,"VWAP color"),group:gu},...Mp.flatMap((r,e)=>[{...X(r.defColor,`Band ${e+1} color`,r.color),inline:r.color,group:gu},{key:r.fill,title:"Fill",type:"bool",defval:true,inline:r.color,group:gu},{...X(Mn(r.defColor),"",r.fillColor),inline:r.color,group:gu}])],compute:(r,e)=>{let t=F(e,"anchor","Day"),n=ee(r,F(e,"source","HLC3")),i=r.length,o=new Array(i).fill(Number.NaN),s=Mp.filter(p=>kp(e,p.on,p.defOn)).map(p=>({mult:Math.max(0,I(e,p.mult,p.defMult)),color:F(e,p.color,p.defColor),fill:kp(e,p.fill,true),fillColor:F(e,p.fillColor,Mn(p.defColor)),up:new Array(i).fill(Number.NaN),down:new Array(i).fill(Number.NaN)})),a=Number.NaN,l=0,c=0,u=0;for(let p=0;p<i;p++){let m=r[p],f=Ip(t,m.time);f!==a&&(a=f,l=0,c=0,u=0);let g=m.volume;if(g!=null&&Number.isFinite(g)&&g>0){let v=n[p];l+=v*g,c+=v*v*g,u+=g;}if(u<=0)continue;let b=l/u,y=Math.sqrt(Math.max(0,c/u-b*b));o[p]=b;for(let v of s)v.up[p]=b+v.mult*y,v.down[p]=b-v.mult*y;}let d=[{key:"vwap",title:"VWAP",values:o,color:F(e,"color",Je),width:2}],h=[];return s.forEach((p,m)=>{d.push({key:`up${m}`,title:`Upper ${p.mult}\u03C3`,values:p.up,color:p.color},{key:`down${m}`,title:`Lower ${p.mult}\u03C3`,values:p.down,color:p.color}),p.fill&&h.push({key:`band${m}`,from:`up${m}`,to:`down${m}`,color:p.fillColor});}),{plots:d,bands:h}}},$A={type:"pivot-points",title:"Pivot Points",shortTitle:"Pivots",overlay:true,inputs:[{key:"anchor",title:"Period",type:"string",defval:"Day",options:["Day","Week","Month"]}],compute:(r,e)=>{let t=F(e,"anchor","Day"),n=new Map;for(let l of r){let c=Ip(t,l.time),u=n.get(c);u?(u.high=Math.max(u.high,l.high),u.low=Math.min(u.low,l.low),u.close=l.close):n.set(c,{high:l.high,low:l.low,close:l.close});}let i=r.length,o=()=>new Array(i).fill(Number.NaN),s={p:o(),r1:o(),s1:o(),r2:o(),s2:o(),r3:o(),s3:o()};for(let l=0;l<i;l++){let c=n.get(Ip(t,r[l].time)-1);if(!c)continue;let u=(c.high+c.low+c.close)/3;s.p[l]=u,s.r1[l]=2*u-c.low,s.s1[l]=2*u-c.high,s.r2[l]=u+(c.high-c.low),s.s2[l]=u-(c.high-c.low),s.r3[l]=c.high+2*(u-c.low),s.s3[l]=c.low-2*(c.high-u);}let a=(l,c,u)=>({key:l,title:c,kind:"step",values:s[l],color:u});return {plots:[a("p","P",ue),a("r1","R1",W),a("s1","S1",z),a("r2","R2",W),a("s2","S2",z),a("r3","R3",W),a("s3","S3",z)]}}},WA={type:"52-week-high-low",title:"52 Week High/Low",shortTitle:"52W H/L",overlay:true,inputs:[{key:"weeks",title:"Weeks",type:"int",defval:52,min:1,max:520,step:1}],compute:(r,e)=>{let t=I(e,"weeks",52)*7*Pp,n=r.length,i=new Array(n).fill(Number.NaN),o=new Array(n).fill(Number.NaN),s=[],a=[],l=0;for(let c=0;c<n;c++){let u=r[c];for(;s.length>0&&r[s[s.length-1]].high<=u.high;)s.pop();for(s.push(c);a.length>0&&r[a[a.length-1]].low>=u.low;)a.pop();for(a.push(c);r[l].time<u.time-t;)l+=1;for(;s[0]<l;)s.shift();for(;a[0]<l;)a.shift();i[c]=r[s[0]].high,o[c]=r[a[0]].low;}return {plots:[{key:"high",title:"52W high",values:i,kind:"step",color:z},{key:"low",title:"52W low",values:o,kind:"step",color:W}]}}},GA={type:"zigzag",title:"ZigZag",overlay:true,inputs:[{key:"deviation",title:"Deviation %",type:"float",defval:5,min:.01,max:100,step:.1},{key:"depth",title:"Depth",type:"int",defval:10,min:1,max:500,step:1},X()],compute:(r,e)=>{let t=I(e,"deviation",5)/100,n=I(e,"depth",10),i=[];if(r.length>1){let o=r[1].close>=r[0].close,s=o?{i:0,price:r[0].high}:{i:0,price:r[0].low};for(let a=1;a<r.length;a++){let l=r[a];o?l.high>=s.price?s={i:a,price:l.high}:l.low<=s.price*(1-t)&&a-(i[i.length-1]?.i??-n)>=n&&(i.push(s),o=false,s={i:a,price:l.low}):l.low<=s.price?s={i:a,price:l.low}:l.high>=s.price*(1+t)&&a-(i[i.length-1]?.i??-n)>=n&&(i.push(s),o=true,s={i:a,price:l.high});}i.push(s);}return {plots:[],polylines:[{key:"zigzag",points:i.map(o=>({xloc:"bar_time",x:r[o.i].time,price:o.price})),curved:false,closed:false,lineColor:F(e,"color",_),lineWidth:2,lineStyle:"solid",arrowLeft:false,arrowRight:false}]}}},UA={type:"williams-fractal",title:"Williams Fractal",shortTitle:"Fractals",overlay:true,inputs:[{key:"periods",title:"Periods",type:"int",defval:2,min:1,max:50,step:1}],compute:(r,e)=>{let t=I(e,"periods",2),n=[],i=(o,s,a)=>{let l=s(r[o]);for(let c=o-t;c<=o+t;c++)if(c!==o&&!a(l,s(r[c])))return false;return true};for(let o=t;o<r.length-t;o++)i(o,s=>s.high,(s,a)=>s>=a)&&n.push({time:r[o].time,position:"aboveBar",shape:"triangleup",color:z}),i(o,s=>s.low,(s,a)=>s<=a)&&n.push({time:r[o].time,position:"belowBar",shape:"triangledown",color:W});return {plots:[],markers:n}}},s0=[HA,zA,$A,WA,GA,UA];var YA=[...Zx,...Jx,...e0,...t0,...n0,...i0,...s0];function a0(){for(let r of YA)Pn(zx(r));}var Ap=class{constructor(e,t={},n={}){Fx(),fp(),Cp(),a0();let i=KA(e),o=Qr(t.theme),s={currentPriceLine:t.currentPriceLine??true,logScale:t.logScale??false,nativeBackend:t.nativeBackend??"auto",...Wp(t.animations),glow:t.glow??0,upColor:t.upColor??z,downColor:t.downColor??W,priceStyle:t.priceStyle??"candles"},a=t.renderer??Es;if(typeof a!="function")throw new Error("[vela] options.renderer must be a renderer class, e.g. import { LwcRenderer } from 'vela/renderers/lwc'. The 'lwc'/'native' string options were removed.");let l=n.renderer??new a(s),c=n.engines??[],u=n.dataFeed??new vr,d={market:{symbol:t.symbol,timeframe:t.timeframe,bars:t.bars,session:t.session,visibleRange:t.visibleRange,data:t.data},live:t.live??false,theme:o,defaultLanguage:t.defaultLanguage??c[0]?.language??"pine",drawings:t.drawings,volume:t.volume??true};this.rendererControl=new co(l),t.settings&&this.rendererControl.setSettingsVisibility(t.settings),this.dataControl=new go(u),this.orchestrator=new tl(i,l,u,c,d,this.dataControl);let h=Hu();Object.keys(h).length>0&&this.rendererControl.set(h),this.panesControl=new nl(this.orchestrator),this.drawingsControl=new bo(this.orchestrator.drawings),this.marksControl=new vo(this.orchestrator.marks);}registerEngine(e,t){return this.orchestrator.registerEngine(e,t),this}addIndicator(e,t){return this.orchestrator.addIndicator(e,t)}addNativeIndicator(e,t){return this.orchestrator.addNativeIndicator(e,t)}availableNativeIndicators(){return this.orchestrator.availableNativeIndicators()}presentNativeIndicators(){return this.orchestrator.presentNativeIndicators()}indicators(){return this.orchestrator.listIndicators()}runScript(e,t){let n=this.addIndicator(e,t),i=new Set,o=()=>{try{n.remove();}catch{}};return new Promise(s=>{let a=false,l=this.on("script:run",u=>{if(u.id===n.id){if(a){for(let d of i)d(u);return}a=true,c(),s({ok:true,run:u,error:null,onUpdate:d=>(i.add(d),()=>i.delete(d)),remove:()=>{l(),i.clear(),o();}});}}),c=n.on("error",({error:u})=>{a||(a=true,l(),c(),o(),s({ok:false,run:null,error:u,onUpdate:()=>()=>{},remove:()=>{}}));});})}runIndicator(e,t){let n=this.addIndicator(e,t);return new Promise(i=>{let o=n.on("ready",()=>{o(),s(),i({ok:true,handle:n,error:null,context:null});}),s=n.on("error",({error:a})=>{o(),s(),n.context().catch(()=>null).then(l=>{try{n.remove();}catch{}i({ok:false,handle:null,error:a,context:l});});});})}setMarket(e){return this.orchestrator.setMarket(e)}get market(){return this.orchestrator.marketSnapshot()}ready(){return this.orchestrator.ready()}historyComplete(){return this.orchestrator.historyComplete()}inspect(){return this.orchestrator.inspect()}get renderer(){return this.rendererControl}get panes(){return this.panesControl}get data(){return this.dataControl}get drawings(){return this.drawingsControl}get marks(){return this.marksControl}on(e,t){return this.orchestrator.events.on(e,t)}getVisibleRange(){return this.orchestrator.getVisibleRange()}setVisibleRange(e){return this.orchestrator.setVisibleRange(e),this}panBy(e){return this.orchestrator.panBy(e),this}setVisibleRangePreset(e){return this.orchestrator.setVisibleRangePreset(e),this}resize(){this.orchestrator.resize();}setTheme(e){return this.orchestrator.setTheme(Qr(e)),this}destroy(){this.orchestrator.destroy();}};function KA(r){if(typeof r!="string")return r;let e=document.querySelector(r);if(!e)throw new Error(`[vela] container not found for selector "${r}"`);return e}var l0=["symbol","timeframes","style","layout","indicators","actions","undo-redo","alerts","panels","screenshot"];var zi=new Map,Ps=new Map,Is=new Map;function XA(r){return Ps.set(r.id,r),()=>{Ps.get(r.id)===r&&Ps.delete(r.id);}}function jA(r){Ps.delete(r);}function qA(){return [...Ps.values()]}var c0=100;function ZA(r){return Is.set(r.id,r),()=>{Is.get(r.id)===r&&Is.delete(r.id);}}function JA(r){Is.delete(r);}function QA(){return [...Is.values()].sort((r,e)=>(r.order??c0)-(e.order??c0))}var Rp=["indicators","screenshot"],u0=new Set(Rp),eR=new Set(l0);function tR(r){if(u0.has(r))return zi.get(r)}function nR(r){return eR.has(r.id)&&!u0.has(r.id)?(console.warn(`[vela] widget action "${r.id}": this built-in topbar slot is a stateful control and cannot be overridden \u2014 ignored. Overridable slots: ${Rp.join(", ")}.`),()=>{}):(zi.set(r.id,r),()=>{zi.get(r.id)===r&&zi.delete(r.id);})}function rR(r){zi.delete(r);}function iR(r,e){let t=[...zi.values()].filter(n=>n.target===r);return t.sort((n,i)=>(n.order??0)-(i.order??0)),e?t.filter(n=>!n.when||n.when(e)):t}var As=new Map;function oR(r){return As.set(r.id,r),()=>{As.get(r.id)===r&&As.delete(r.id);}}function sR(r){As.delete(r);}function aR(){return [...As.values()].sort((r,e)=>(r.order??0)-(e.order??0))}var Rs=new Map;function lR(r){return Rs.set(r.id,r),()=>{Rs.get(r.id)===r&&Rs.delete(r.id);}}function cR(r){Rs.delete(r);}function uR(){return [...Rs.values()].sort((r,e)=>(r.order??0)-(e.order??0))}var Ds=new Map;function dR(r){return Ds.set(r.key,r),()=>{Ds.get(r.key)===r&&Ds.delete(r.key);}}function hR(r){Ds.delete(r);}function pR(r){return [...Ds.values()].filter(e=>e.scope===r)}var bu;function mR(r){return bu=r,()=>{bu===r&&(bu=void 0);}}function fR(){return bu}var Os=new Map;function gR(r,e){return Os.set(r,e),()=>{Os.get(r)===e&&Os.delete(r);}}function bR(r){Os.delete(r);}function vR(r){return {...Object.fromEntries(Os),...r}}var d0=280,Dp=200,h0=640;function yR(r,e=Dp,t=h0){let n=Number.isFinite(e)&&e>0?e:Dp,i=Number.isFinite(t)?Math.max(t,n):Number.POSITIVE_INFINITY;return Number.isFinite(r)?Math.round(Math.min(Math.max(r,n),i)):n}function $i(r){let e=r.description?.split("/")[0]?.trim();return e?e.replace(/\s+Perpetual$/i,""):r.ticker.replace(/[-_/]?(USDT|USDC|USD1|USDS|BUSD|USD|EUR|PERP)$/i,"")||r.ticker}function Wi(r){let e=r.trim().toUpperCase();return e?`https://crypto-icons.ledger.com/${encodeURIComponent(e)}.png`:void 0}var p0="https://api.binance.com/api/v3",wR="https://api.binance.us/api/v3",Op="https://fapi.binance.com/fapi/v1",xR="wss://stream.binance.com:9443",SR="wss://stream.binance.us:9443",CR="wss://fstream.binance.com",TR=15e3,kR=2e3,m0={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h",720:"12h",D:"1d",W:"1w",M:"1M"},f0={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"D","1w":"W","1mo":"M","1D":"D","1W":"W","4H":"240",D:"D",W:"W",M:"M"},ER=[1,3,5,15,30,60,120,240,360,480,720],LR={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h",720:"12h"},MR=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function g0(r){return f0[r]??f0[r.toLowerCase()]??r}function Np(r){let e=r.trim().toUpperCase();return e.endsWith(".P")?{apiSymbol:e.slice(0,-2),isFutures:true}:{apiSymbol:e,isFutures:false}}function b0(r){return r.map(e=>({time:Number(e[0]),open:Number(e[1]),high:Number(e[2]),low:Number(e[3]),close:Number(e[4]),volume:Number(e[5])}))}function PR(r){return {time:Number(r.t),open:Number(r.o),high:Number(r.h),low:Number(r.l),close:Number(r.c),volume:Number(r.v)}}function IR(r){let e=new Map;for(let t of r)e.set(t.time,t);return [...e.values()].sort((t,n)=>t.time-n.time)}function AR(r,e){let t=new Map;for(let n of r){let i=Math.floor(n.time/e)*e,o=t.get(i);o?(o.high=Math.max(o.high,n.high),o.low=Math.min(o.low,n.low),o.close=n.close,o.volume=(o.volume??0)+(n.volume??0)):t.set(i,{time:i,open:n.open,high:n.high,low:n.low,close:n.close,volume:n.volume??0});}return [...t.values()].sort((n,i)=>n.time-i.time)}function RR(r){return ER.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var vu=class{constructor(){this.spotBaseUrl=null;this.spotBaseProbe=null;this.symbolsPromise=null;}info(){return {name:"binance",displayName:"Binance",requiresApiKey:false,supportedTimeframes:MR,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let{apiSymbol:i,isFutures:o}=Np(e),s=o?Op:await this.spotBase(),a=g0(t),l=m0[a];if(l)return IR(b0(await this.fetchKlines(s,i,l,n)));let c=/^\d+$/.test(a)?parseInt(a,10):null,u=c!=null?RR(c):null;if(c==null||u==null)return console.warn(`[vela] Binance: timeframe "${t}" is not supported and cannot be aggregated.`),[];let d=c/u,h={...n,limit:n.limit!=null?n.limit*d+d:void 0},p=b0(await this.fetchKlines(s,i,LR[u],h)),m=AR(p,c*6e4);return n.limit!=null&&m.length>n.limit?m.slice(-n.limit):m}catch(i){return console.warn(`[vela] Binance: failed to fetch ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}async getSymbolInfo(e){let{apiSymbol:t,isFutures:n}=Np(e),i=n?Op:await this.spotBase(),o=n?`${i}/exchangeInfo`:`${i}/exchangeInfo?symbol=${t}`,a=(await this.json(o).catch(()=>null))?.symbols??[],l=n?a.find(d=>d.symbol===t):a[0];if(!l)return;let c=l.filters?.find(d=>d.filterType==="PRICE_FILTER"),u=c?parseFloat(c.tickSize??"0.01"):.01;return {ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",description:`${l.baseAsset} / ${l.quoteAsset}${n?" Perpetual":""}`,type:n?"futures":"crypto",basecurrency:l.baseAsset,currency:l.quoteAsset,mintick:u,pricescale:Math.round(1/u),timezone:"Etc/UTC",session:"24x7"}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=Promise.all([this.listSpot().catch(()=>[]),this.listFutures().catch(()=>[])]).then(([e,t])=>[...e,...t])),this.symbolsPromise}resolveSymbolIcon(e){return Wi($i(e))}subscribe(e,t,n){let{apiSymbol:i,isFutures:o}=Np(e),s=m0[g0(t)];return s&&typeof WebSocket<"u"?this.streamKlines(e,t,i,o,s,n):this.pollBars(e,t,n)}streamKlines(e,t,n,i,o,s){let a=false,l=null,c=null,u=null,d=null,h=`${n.toLowerCase()}@kline_${o}`,p=()=>{u&&(clearTimeout(u),u=null);},m=()=>{if(!(a||d)){p(),c&&(clearTimeout(c),c=null);try{l?.close();}catch{}l=null,console.warn(`[vela] Binance: ${e} ${t} stream delivered no data; falling back to polling.`),d=this.pollBars(e,t,s);}},f=async()=>{if(a)return;let g=i?CR:await this.spotWsBase();a||(l=new WebSocket(`${g}/ws/${h}`),u=setTimeout(m,TR),l.onmessage=b=>{if(!(a||d))try{let y=JSON.parse(typeof b.data=="string"?b.data:"");y.k&&(p(),s(PR(y.k)));}catch{}},l.onclose=()=>{!a&&!d&&(c=setTimeout(()=>{f();},kR));},l.onerror=()=>{try{l?.close();}catch{}});};return f(),()=>{a=true,p(),c&&clearTimeout(c),d?.();try{l?.close();}catch{}}}async spotWsBase(){return (await this.spotBase()).includes("binance.us")?SR:xR}pollBars(e,t,n){let i=false,o=null,s=async()=>{if(!i){try{let a=await this.getBars(e,t,{limit:2});for(let l of a)n(l);}catch{}i||(o=setTimeout(()=>{s();},3e3));}};return o=setTimeout(()=>{s();},3e3),()=>{i=true,o&&clearTimeout(o);}}async listSpot(){let e=await this.spotBase();return ((await this.json(`${e}/exchangeInfo`)).symbols??[]).filter(n=>n.status==="TRADING").map(n=>({ticker:n.symbol,description:`${n.baseAsset} / ${n.quoteAsset}`,type:"crypto"}))}async listFutures(){return ((await this.json(`${Op}/exchangeInfo`)).symbols??[]).filter(t=>t.contractType==="PERPETUAL"&&t.status==="TRADING").map(t=>({ticker:`${t.symbol}.P`,description:`${t.baseAsset} / ${t.quoteAsset} Perpetual`,type:"futures"}))}async fetchKlines(e,t,n,i){if(i.from!=null)return this.paginateForward(e,t,n,i.from,i.to??Date.now(),i.limit);let o=i.limit??500;return o>1e3?this.paginateBackward(e,t,n,o,i.to):this.klinesChunk(e,{symbol:t,interval:n,limit:o,endTime:i.to})}async paginateForward(e,t,n,i,o,s){let a=[],l=i;for(;l<o;){let c=await this.klinesChunk(e,{symbol:t,interval:n,limit:1e3,startTime:l,endTime:o});if(c.length===0||(a.push(...c),l=Number(c[c.length-1][6])+1,c.length<1e3)||s&&a.length>=s)break}return s?a.slice(0,s):a}async paginateBackward(e,t,n,i,o){let s=[],a=i,l=o,c=Math.ceil(i/1e3)+5;for(;a>0&&c-- >0;){let u=Math.min(a,1e3),d=await this.klinesChunk(e,{symbol:t,interval:n,limit:u,endTime:l});if(d.length===0||(s=d.concat(s),a-=d.length,l=Number(d[0][0])-1,d.length<u))break}return s}async klinesChunk(e,t){let n=new URL(`${e}/klines`);n.searchParams.set("symbol",t.symbol),n.searchParams.set("interval",t.interval),t.limit&&n.searchParams.set("limit",String(Math.min(t.limit,1e3))),t.startTime!=null&&n.searchParams.set("startTime",String(t.startTime)),t.endTime!=null&&n.searchParams.set("endTime",String(t.endTime));let i=await this.json(n.toString());return Array.isArray(i)?i.length>0&&!Array.isArray(i[0])?[]:i:[]}spotBase(){return this.spotBaseUrl?Promise.resolve(this.spotBaseUrl):(this.spotBaseProbe||(this.spotBaseProbe=(async()=>{try{for(let e of [p0,wR])try{if((await fetch(`${e}/ping`,{signal:AbortSignal.timeout(5e3)})).ok)return this.spotBaseUrl=e}catch{}return p0}finally{this.spotBaseProbe=null;}})()),this.spotBaseProbe)}async json(e){let t=await fetch(e);if(!t.ok)throw new Error(`Binance HTTP ${t.status} for ${e}`);return t.json()}};var DR="https://api.hyperliquid.xyz/info",OR="wss://api.hyperliquid.xyz/ws",NR=15e3,FR=2e3,v0={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",480:"8h",720:"12h",D:"1d",W:"1w",M:"1M"},y0={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"D","1w":"W","1mo":"M","1D":"D","1W":"W","4H":"240",D:"D",W:"W",M:"M"},VR=[1,3,5,15,30,60,120,240,480,720],_R={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",480:"8h",720:"12h"},BR=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],w0={D:864e5,W:6048e5,M:2592e6};function HR(r){if(w0[r])return w0[r];let e=parseInt(r,10);return Number.isFinite(e)&&e>0?e*6e4:36e5}function x0(r){return y0[r]??y0[r.toLowerCase()]??r}function Fp(r){let e=r.trim();return e.includes("/")?e:e.toUpperCase()}function Vp(r){return {time:Number(r.t),open:Number(r.o),high:Number(r.h),low:Number(r.l),close:Number(r.c),volume:Number(r.v)}}function zR(r){let e=new Map;for(let t of r)e.set(t.time,t);return [...e.values()].sort((t,n)=>t.time-n.time)}function $R(r,e){let t=new Map;for(let n of r){let i=Math.floor(n.time/e)*e,o=t.get(i);o?(o.high=Math.max(o.high,n.high),o.low=Math.min(o.low,n.low),o.close=n.close,o.volume=(o.volume??0)+(n.volume??0)):t.set(i,{time:i,open:n.open,high:n.high,low:n.low,close:n.close,volume:n.volume??0});}return [...t.values()].sort((n,i)=>n.time-i.time)}function WR(r){return VR.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var yu=class{constructor(){this.metaPromise=null;this.spotMetaPromise=null;this.symbolsPromise=null;}info(){return {name:"hyperliquid",displayName:"Hyperliquid",requiresApiKey:false,supportedTimeframes:BR,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=Fp(e),o=x0(t),s=v0[o];if(s)return zR((await this.fetchCandles(i,s,HR(o),n)).map(Vp));let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?WR(a):null;if(a==null||l==null)return console.warn(`[vela] Hyperliquid: timeframe "${t}" is not supported and cannot be aggregated.`),[];let c=a/l,u={...n,limit:n.limit!=null?n.limit*c+c:void 0},d=(await this.fetchCandles(i,_R[l],l*6e4,u)).map(Vp),h=$R(d,a*6e4);return n.limit!=null&&h.length>n.limit?h.slice(-n.limit):h}catch(i){return console.warn(`[vela] Hyperliquid: failed to fetch ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}async getSymbolInfo(e){let t=Fp(e),i=(await this.fetchMeta().catch(()=>null))?.universe?.find(o=>o.name===t);if(i){let o=C0(Math.max(0,6-(i.szDecimals??2)));return S0(e,t,"USD","futures",`${t} / USD Perpetual`,o)}if(t.includes("/")){let o=await this.fetchSpotMeta().catch(()=>null),s=o?.universe?.find(d=>d.name===t),a=s&&o?.tokens?o.tokens[s.tokens?.[0]??-1]:void 0,[l=t,c="USDC"]=t.split("/"),u=C0(Math.max(0,8-(a?.szDecimals??2)));return S0(e,l,c,"crypto",`${l} / ${c}`,u)}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=Promise.all([this.listPerps().catch(()=>[]),this.listSpot().catch(()=>[])]).then(([e,t])=>[...e,...t])),this.symbolsPromise}resolveSymbolIcon(e){return Wi($i(e))}subscribe(e,t,n){let i=Fp(e),o=v0[x0(t)];return o&&typeof WebSocket<"u"?this.streamCandles(e,t,i,o,n):this.pollBars(e,t,n)}async listPerps(){return ((await this.fetchMeta()).universe??[]).filter(t=>!t.isDelisted).map(t=>({ticker:t.name,description:`${t.name} / USD Perpetual`,type:"futures"}))}async listSpot(){let e=await this.fetchSpotMeta(),t=e.tokens??[],n=i=>i!=null?t[i]?.name??null:null;return (e.universe??[]).map(i=>{let o=n(i.tokens?.[0]),s=n(i.tokens?.[1]),a=o&&s?`${o} / ${s}`:i.name;return {ticker:i.name,description:a,type:"crypto"}})}async fetchCandles(e,t,n,i){let o=i.to??Date.now(),s=i.from!=null?i.from:o-((i.limit??500)+2)*n,a=await this.candleSnapshot(e,t,s,o);return i.from==null&&i.limit!=null&&a.length>i.limit?a.slice(-i.limit):a}async candleSnapshot(e,t,n,i){let o=await this.post({type:"candleSnapshot",req:{coin:e,interval:t,startTime:Math.floor(n),endTime:Math.floor(i)}});return Array.isArray(o)?o:[]}streamCandles(e,t,n,i,o){let s=false,a=null,l=null,c=null,u=null,d=null,h=()=>{u&&(clearTimeout(u),u=null);},p=()=>{l&&(clearInterval(l),l=null);},m=()=>{if(!(s||d)){h(),p(),c&&(clearTimeout(c),c=null);try{a?.close();}catch{}a=null,console.warn(`[vela] Hyperliquid: ${e} ${t} stream delivered no data; falling back to polling.`),d=this.pollBars(e,t,o);}},f=()=>{s||d||(a=new WebSocket(OR),u=setTimeout(m,NR),a.onopen=()=>{try{a?.send(JSON.stringify({method:"subscribe",subscription:{type:"candle",coin:n,interval:i}}));}catch{}l=setInterval(()=>{try{a?.send(JSON.stringify({method:"ping"}));}catch{}},3e4);},a.onmessage=g=>{if(!(s||d))try{let b=JSON.parse(typeof g.data=="string"?g.data:"");b.channel==="candle"&&b.data&&b.data.s===n&&(h(),o(Vp(b.data)));}catch{}},a.onclose=()=>{p(),!s&&!d&&(c=setTimeout(f,FR));},a.onerror=()=>{try{a?.close();}catch{}});};return f(),()=>{s=true,h(),p(),c&&clearTimeout(c),d?.();try{a?.close();}catch{}}}pollBars(e,t,n){let i=false,o=null,s=async()=>{if(!i){try{let a=await this.getBars(e,t,{limit:2});for(let l of a)n(l);}catch{}i||(o=setTimeout(()=>{s();},3e3));}};return o=setTimeout(()=>{s();},3e3),()=>{i=true,o&&clearTimeout(o);}}fetchMeta(){return this.metaPromise??(this.metaPromise=this.post({type:"meta"}).then(e=>e))}fetchSpotMeta(){return this.spotMetaPromise??(this.spotMetaPromise=this.post({type:"spotMeta"}).then(e=>e))}async post(e){let t=await fetch(DR,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Hyperliquid HTTP ${t.status}`);return t.json()}};function S0(r,e,t,n,i,o){return {ticker:r,tickerid:`HYPERLIQUID:${r}`,prefix:"HYPERLIQUID",description:i,type:n,basecurrency:e,currency:t,mintick:o,pricescale:Math.round(1/o),timezone:"Etc/UTC",session:"24x7"}}function C0(r){return Math.pow(10,-r)}var GR={now:()=>Date.now(),delay:r=>new Promise(e=>setTimeout(e,r))},wu=class{constructor(e,t,n=GR){this.maxConcurrent=e;this.minIntervalMs=t;this.clock=n;this.active=0;this.waiters=[];this.nextStartAt=0;this.pausedUntil=0;}async run(e){await this.acquire();try{return await this.waitForTurn(),await e()}finally{this.release();}}pauseFor(e){e>0&&(this.pausedUntil=Math.max(this.pausedUntil,this.clock.now()+e));}async waitForTurn(){for(;;){let e=this.clock.now(),t=Math.max(this.pausedUntil-e,this.nextStartAt-e);if(t<=0)break;await this.clock.delay(t);}this.nextStartAt=Math.max(this.clock.now(),this.nextStartAt)+this.minIntervalMs;}acquire(){return this.active<this.maxConcurrent?(this.active+=1,Promise.resolve()):new Promise(e=>{this.waiters.push(()=>{this.active+=1,e();});})}release(){this.active-=1;let e=this.waiters.shift();e&&e();}};var _p="https://api.exchange.coinbase.com",UR="wss://ws-feed.exchange.coinbase.com",YR={Accept:"application/json"},KR=15e3,XR=2e3,jR=5e3,xu=300,qR=4,ZR=120,JR=4,QR=600,e2=400;function t2(r,e){let t=Number(r.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t*1e3:e}var T0={1:60,5:300,15:900,60:3600,360:21600,D:86400},k0={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","6h":"360","8h":"480","12h":"720","1d":"D","1w":"W","1mo":"M","1D":"D","1W":"W","4H":"240",D:"D",W:"W",M:"M"},n2=[1,5,15,60,360,1440],r2={1:60,5:300,15:900,60:3600,360:21600,1440:86400},i2=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],Bp=864e5;function E0(r){return k0[r]??k0[r.toLowerCase()]??r}function Hp(r){return r.trim().toUpperCase()}function o2(r){return {time:Number(r[0])*1e3,open:Number(r[3]),high:Number(r[2]),low:Number(r[1]),close:Number(r[4]),volume:Number(r[5])}}function zp(r){let e=new Map;for(let t of r)e.set(t.time,t);return [...e.values()].sort((t,n)=>t.time-n.time)}function s2(r,e){return L0(r,t=>Math.floor(t/e)*e)}function a2(r,e){return L0(r,e==="W"?l2:c2)}function L0(r,e){let t=new Map;for(let n of r){let i=e(n.time),o=t.get(i);o?(o.high=Math.max(o.high,n.high),o.low=Math.min(o.low,n.low),o.close=n.close,o.volume=(o.volume??0)+(n.volume??0)):t.set(i,{time:i,open:n.open,high:n.high,low:n.low,close:n.close,volume:n.volume??0});}return [...t.values()].sort((n,i)=>n.time-i.time)}function l2(r){let e=new Date(r),t=(e.getUTCDay()+6)%7;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()-t)}function c2(r){let e=new Date(r);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)}function u2(r){return n2.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}function $p(r,e){return e!=null&&r.length>e?r.slice(-e):r}var Su=class{constructor(){this.symbolsPromise=null;this.gate=new wu(qR,ZR);}info(){return {name:"coinbase",displayName:"Coinbase",requiresApiKey:false,supportedTimeframes:i2,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=Hp(e),o=E0(t),s=T0[o];if(s)return zp(await this.fetchCandles(i,s,n));if(o==="W"||o==="M"){let h=o==="W"?7*Bp:31*Bp,p=n.from!=null?n:{...n,limit:n.limit!=null?Math.ceil(n.limit*h/Bp)+31:void 0},m=await this.fetchCandles(i,86400,p);return $p(a2(m,o),n.limit)}let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?u2(a):null;if(a==null||l==null)return console.warn(`[vela] Coinbase: timeframe "${t}" is not supported and cannot be aggregated.`),[];let c=a/l,u={...n,limit:n.limit!=null?n.limit*c+c:void 0},d=await this.fetchCandles(i,r2[l],u);return $p(s2(d,a*6e4),n.limit)}catch(i){return console.warn(`[vela] Coinbase: failed to fetch ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}async getSymbolInfo(e){let t=Hp(e),n=await this.json(`${_p}/products/${t}`).catch(()=>null);if(!n||!n.id)return;let i=n.quote_increment!=null?parseFloat(n.quote_increment):.01,o=i>0?i:.01;return {ticker:e,tickerid:`COINBASE:${e}`,prefix:"COINBASE",description:`${n.base_currency} / ${n.quote_currency}`,type:"crypto",basecurrency:n.base_currency,currency:n.quote_currency,mintick:o,pricescale:Math.round(1/o),timezone:"Etc/UTC",session:"24x7"}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=this.fetchProducts().then(e=>e.filter(t=>t.status==="online"&&!t.trading_disabled).map(t=>({ticker:t.id,description:`${t.base_currency} / ${t.quote_currency}`,type:"crypto"}))).catch(()=>[])),this.symbolsPromise}resolveSymbolIcon(e){return Wi($i(e))}subscribe(e,t,n){let i=T0[E0(t)];return i&&typeof WebSocket<"u"?this.streamTicker(e,t,i,n):this.pollBars(e,t,n)}async fetchProducts(){let e=await this.json(`${_p}/products`);return Array.isArray(e)?e:[]}async fetchCandles(e,t,n){return n.from!=null?this.paginateForward(e,t,n.from,n.to??Date.now(),n.limit):this.paginateBackward(e,t,n.limit??500,n.to??Date.now())}async paginateBackward(e,t,n,i){let o=t*1e3,s=[],a=n,l=i,c=Math.ceil(n/xu)+4;for(;a>0&&c-- >0;){let u=Math.min(a,xu),d=l-u*o,h=await this.candlesChunk(e,t,d,l);if(h.length===0||(s=h.concat(s),a-=h.length,l=h[0].time-1,h.length<u))break}return $p(zp(s),n)}async paginateForward(e,t,n,i,o){let s=t*1e3,a=[],l=n,c=Math.ceil((i-n)/(xu*s))+4;for(;l<i&&c-- >0;){let d=Math.min(l+xu*s,i),h=await this.candlesChunk(e,t,l,d);if(h.length>0&&a.push(...h),l=d,o!=null&&a.length>=o)break}let u=zp(a);return o!=null?u.slice(0,o):u}async candlesChunk(e,t,n,i){let o=new URL(`${_p}/products/${e}/candles`);o.searchParams.set("granularity",String(t)),o.searchParams.set("start",String(Math.floor(n/1e3))),o.searchParams.set("end",String(Math.floor(i/1e3)));let s=await this.json(o.toString());return !Array.isArray(s)||s.length>0&&!Array.isArray(s[0])?[]:s.map(o2).sort((a,l)=>a.time-l.time)}streamTicker(e,t,n,i){let o=Hp(e),s=n*1e3,a=T=>Math.floor(T/s)*s,l=false,c=null,u=null,d=null,h=null,p=null,m=null,f=()=>{d&&(clearTimeout(d),d=null);},g=()=>{h&&(clearInterval(h),h=null);},b=()=>{m&&i({...m});},y=async T=>{try{let k=await this.getBars(e,t,{limit:2});if(l||k.length===0)return;T&&k.length>=2&&i(k[k.length-2]);let x=k[k.length-1];m=m&&m.time===x.time?{...x,high:Math.max(x.high,m.high),low:Math.min(x.low,m.low),close:m.close}:{...x},b();}catch{}},v=(T,k)=>{let x=Number(T);if(!Number.isFinite(x))return;let L=a(k);!m||L>m.time?(m={time:L,open:x,high:x,low:x,close:x,volume:0},b(),y(false)):L===m.time&&(m={...m,close:x,high:Math.max(m.high,x),low:Math.min(m.low,x)},b());},S=()=>{if(!(l||p)){f(),g(),u&&(clearTimeout(u),u=null);try{c?.close();}catch{}c=null,console.warn(`[vela] Coinbase: ${e} ${t} stream delivered no data; falling back to polling.`),p=this.pollBars(e,t,i);}},E=()=>{l||p||(c=new WebSocket(UR),d=setTimeout(S,KR),c.onopen=()=>{try{c?.send(JSON.stringify({type:"subscribe",product_ids:[o],channels:["ticker"]}));}catch{}y(false),h=setInterval(()=>{y(false);},jR);},c.onmessage=T=>{if(!(l||p))try{let k=JSON.parse(typeof T.data=="string"?T.data:"");k.type==="ticker"&&k.product_id===o&&k.price!=null&&(f(),v(k.price,k.time?Date.parse(k.time):Date.now()));}catch{}},c.onclose=()=>{g(),!l&&!p&&(u=setTimeout(E,XR));},c.onerror=()=>{try{c?.close();}catch{}});};return E(),()=>{l=true,f(),g(),u&&clearTimeout(u),p?.();try{c?.close();}catch{}}}pollBars(e,t,n){let i=false,o=null,s=async()=>{if(!i){try{let a=await this.getBars(e,t,{limit:2});for(let l of a)n(l);}catch{}i||(o=setTimeout(()=>{s();},3e3));}};return o=setTimeout(()=>{s();},3e3),()=>{i=true,o&&clearTimeout(o);}}async json(e){return (await this.request(e)).json()}async request(e){for(let t=0;;t+=1){let n=await this.gate.run(()=>fetch(e,{headers:YR}));if(n.status===429&&t<JR){let i=QR*2**t+Math.random()*e2;this.gate.pauseFor(Math.max(t2(n,0),i));continue}if(!n.ok)throw new Error(`Coinbase HTTP ${n.status} for ${e}`);return n}}};
|
|
1032
|
+
exports.ACCENT=Ke;exports.ACCENT_BRIGHT=$r;exports.BEARISH=W;exports.BULLISH=z;exports.BarStore=rl;exports.BinanceProvider=vu;exports.CATEGORICAL=Bs;exports.CHIP_PLATE=em;exports.CROSSHAIR=Zp;exports.CachingDataFeed=mo;exports.CoinbaseProvider=Su;exports.DARK_THEME=Yt;exports.DEFAULT_PANEL_MAX_WIDTH=h0;exports.DEFAULT_PANEL_MIN_WIDTH=Dp;exports.DEFAULT_PANEL_WIDTH=d0;exports.DataControl=go;exports.Drawing=G;exports.DrawingStore=qr;exports.DrawingToolbar=Ts;exports.DrawingsControl=bo;exports.HIGHLIGHT=jp;exports.HyperliquidProvider=yu;exports.INFO=Je;exports.INVALID=zs;exports.LIGHT_THEME=lo;exports.MARKER=qp;exports.MarksControl=vo;exports.MultiProviderFeed=vr;exports.NEUTRAL=J;exports.NativeRenderer=Es;exports.OVERRIDABLE_TOPBAR_IDS=Rp;exports.RendererControl=co;exports.SERIES_LINE=_;exports.SESSION_OFF=C2;exports.SESSION_POST=S2;exports.SESSION_PRE=x2;exports.SLATE=Qp;exports.SLATE_DEEP=Jp;exports.SecondClock=yo;exports.TRADE_EXIT=rm;exports.TRADE_LONG=tm;exports.TRADE_SHORT=nm;exports.TypedEventBus=er;exports.VALID=Hs;exports.Vela=Ap;exports.WARNING=ue;exports.buildColorPicker=Qo;exports.buildToolbar=io;exports.categoricalColor=T2;exports.chartType=pn;exports.chartTypes=Mt;exports.clampPanelWidth=yR;exports.combineColor=ec;exports.createDrawing=On;exports.defaultToolbar=ro;exports.deserializeDrawing=pt;exports.drawingTypes=Xa;exports.getDrawingType=Et;exports.getNativeIndicator=Ui;exports.iconMarkup=Wr;exports.inputDeltas=rv;exports.inputVisible=Xo;exports.legendActions=aR;exports.legendCallouts=uR;exports.nativeIndicatorDescriptors=Vs;exports.nativeIndicatorTypes=Yp;exports.normalizeSettingsRow=Zr;exports.registerChartType=_u;exports.registerDefaultEngine=gR;exports.registerDrawingType=V;exports.registerIcon=N;exports.registerLegendAction=oR;exports.registerLegendCallout=lR;exports.registerNativeIndicator=Pn;exports.registerRendererDefaults=x1;exports.registerRendererLayer=YP;exports.registerSidePanel=ZA;exports.registerStatePersistence=dR;exports.registerSymbolRanking=mR;exports.registerWidgetAction=nR;exports.registerWidgetAttachment=XA;exports.rendererDefaults=Hu;exports.rendererLayers=tp;exports.resolveEngines=vR;exports.resolveTheme=Qr;exports.seriesInScale=Ns;exports.seriesShownOn=Ct;exports.settingsRowValueKeys=so;exports.sharedBarStore=uo;exports.sidePanels=QA;exports.splitColor=Gn;exports.stableSeriesId=Jn;exports.statePersistenceHandlers=pR;exports.symbolRanking=fR;exports.tickerModifierIds=Bu;exports.timeframeToMs=Lt;exports.topbarActionOverride=tR;exports.unregisterChartType=d1;exports.unregisterDefaultEngine=bR;exports.unregisterLegendAction=sR;exports.unregisterLegendCallout=cR;exports.unregisterNativeIndicator=Up;exports.unregisterRendererDefaults=S1;exports.unregisterRendererLayer=KP;exports.unregisterSidePanel=JA;exports.unregisterStatePersistence=hR;exports.unregisterWidgetAction=rR;exports.unregisterWidgetAttachment=jA;exports.widgetActions=iR;exports.widgetAttachments=qA;return exports;})({});
|