@luxalgo/vela 0.6.6 → 0.6.7
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-JJq7M2it.d.ts → DataProvider-BSLlBpB9.d.ts} +10 -0
- package/dist/{DataProvider-DDUYw2qP.d.cts → DataProvider-BsQM2WNH.d.cts} +10 -0
- package/dist/{bottombar-COnL2Sk4.d.ts → bottombar-Br4rzx_R.d.ts} +52 -6
- package/dist/{bottombar-DeDXbF_K.d.cts → bottombar-Div5zibZ.d.cts} +52 -6
- package/dist/{chunk-JQFO2WMU.js → chunk-6WFKTAT4.js} +37 -1
- package/dist/{chunk-OEUGUXL7.js → chunk-L3I2CCYO.js} +49 -1
- package/dist/chunk-W4EJWLEO.js +12 -0
- package/dist/{chunk-TMXK2SJR.js → chunk-WVP4XV5A.js} +221 -65
- package/dist/{contributions-DNMqrAuw.d.cts → contributions-Hv4_cOJo.d.cts} +46 -3
- package/dist/{contributions-BqCIsbaP.d.ts → contributions-Z12BrWCy.d.ts} +46 -3
- package/dist/index.cjs +64 -0
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +2 -2
- package/dist/{plugin-WnvNNJOp.d.ts → plugin-9koBjc5H.d.ts} +2 -2
- package/dist/{plugin-CN8U2__Q.d.cts → plugin-BXhDHTYn.d.cts} +2 -2
- package/dist/plugin.cjs +28 -0
- package/dist/plugin.d.cts +3 -3
- package/dist/plugin.d.ts +3 -3
- package/dist/plugin.js +1 -1
- package/dist/providers/binance.cjs +16 -0
- package/dist/providers/binance.d.cts +4 -1
- package/dist/providers/binance.d.ts +4 -1
- package/dist/providers/binance.js +7 -0
- package/dist/providers/coinbase.cjs +16 -0
- package/dist/providers/coinbase.d.cts +4 -1
- package/dist/providers/coinbase.d.ts +4 -1
- package/dist/providers/coinbase.js +7 -0
- package/dist/providers/hyperliquid.cjs +16 -0
- package/dist/providers/hyperliquid.d.cts +4 -1
- package/dist/providers/hyperliquid.d.ts +4 -1
- package/dist/providers/hyperliquid.js +7 -0
- package/dist/vela.global.js +90 -0
- package/dist/vela.global.min.js +42 -42
- package/dist/widget.cjs +319 -63
- package/dist/widget.d.cts +52 -10
- package/dist/widget.d.ts +52 -10
- package/dist/widget.js +5 -4
- package/dist/workspace.cjs +265 -65
- package/dist/workspace.d.cts +13 -4
- package/dist/workspace.d.ts +13 -4
- package/dist/workspace.js +4 -3
- package/package.json +1 -1
package/dist/vela.global.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var Vela=(function(exports){'use strict';function be(r){return r.kind!=="candle"&&r.kind!=="bar"&&r.kind!=="markers"}var un=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 Ro=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 Zr=new Map;function Qn(r){Zr.set(r.type,r);}function Ju(r){Zr.delete(r);}function Jr(r){return Zr.get(r)}function Qu(){return [...Zr.keys()]}function Do(){return [...Zr.values()]}var Oo=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 er=class{constructor(e,t,n,i){this.controller=n;this.schema=[];this.visibleState=true;this.bus=new un;this.id=e,this.title=t,i!==void 0&&(this.source=i);}get inputs(){return this.schema}get visible(){return this.visibleState}setInput(e,t){this.controller.applyInputs(this.id,{[e]:t});}setInputs(e){this.controller.applyInputs(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;}setVisibleState(e){this.visibleState=e;}emit(e,t){this.bus.emit(e,t);}};function Oy(r){let e={};for(let t of r.series)e[t.kind]=(e[t.kind]??0)+1;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}}function eh(r){let e=r.map(Oy),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)}}}var Fy={"1D":864e5,"1W":6048e5,"1M":2592e6,"3M":7776e6,"6M":15552e6,"1Y":31536e6,"5Y":15768e7};function th(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-Fy[r],{from:Math.max(t,i),to:n}}var Te="#2962ff",tr="#38c0fd",J="#089981",X="#f23645",Ee="#787b86",rh="#e0b400",hn="#ff9800",St="#5b9cf6",ih="#ff5d00",Fo="#0ecb81",No="#f6465d",oM="#f97316",sM="#0ea5e9",aM="#9ca3af",Qr="#3b82f6",oh="#9aa0ad",sh="#1e293b",Vo="#475569",ah=Te,lh=X,ch="#d500f9",nh=[Te,J,X,hn,"#7e57c2","#26a69a",St,"#e573b5"];function lM(r){let e=0;for(let t=0;t<r.length;t++)e=e*31+r.charCodeAt(t)>>>0;return nh[e%nh.length]}var R=tr;function tc(){return {lineColor:R,lineWidth:2,lineStyle:"solid"}}function Ct(r=""){return {value:r,size:"normal",hAlign:"left",vAlign:"top"}}var _o=class _o{constructor(e){this.locked=false;this.visible=true;this.zIndex=0;this.id=e.id??`dw-${_o.seq+=1}`,this.paneId=e.paneId,this.anchors=(e.anchors??[]).map(t=>({time:t.time,price:t.price})),this.style=e.style?{...e.style}:tc(),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=Ct()),dh(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){}};_o.seq=0;var V=_o;function dh(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 nc=new Map;function D(r,e){nc.set(r,e);}function Bo(r){return nc.get(r)??null}function $(r){return nc.get(r)??""}function me(r,e){return $(r).replace("<svg ",`<svg width="${e}" height="${e}" `)}function uh(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 A(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 rc(r){return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${r}</svg>`}var B=uh;D("style-candles",B('<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"/>'));D("style-bars",B('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>'));D("style-line",B('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));D("style-area",B('<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"/>'));D("style-baseline",B('<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"/>'));D("style-heikinashi",B('<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"/>'));D("indicators",B('<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"/>'));D("undo",B('<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"/>'));D("redo",B('<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"/>'));D("objects",B('<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"/>'));D("clock",B('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));D("calendar",B('<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"/>'));D("datawindow",B('<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"/>'));D("camera",B('<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"/>'));D("gear",B('<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"/>'));D("search",B('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));D("bell",B('<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"/>'));D("market-open",A('<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"/>'));D("market-pre",A('<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="m16 6-4 4-4-4"/><path d="M16 18a4 4 0 0 0-8 0"/>'));D("market-post",A('<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 18-4-4-4 4"/><path d="M16 6a4 4 0 0 0-8 0"/>'));D("market-closed",A('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));D("market-holiday",A('<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"/>'));D("chevron-right",B('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));D("chevron-left",B('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));D("chevron-down",B('<path d="M3.5 6 8 10.5 12.5 6"/>'));D("chevron-up",B('<path d="M3.5 10 8 5.5 12.5 10"/>'));D("chevrons-right",B('<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"/>'));D("chevrons-left",B('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));D("check",B('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));D("close",B('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));D("eye",B('<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"/>'));D("eye-off",B('<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"/>'));D("lock",B('<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"/>'));D("unlock",B('<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"/>'));D("trash",B('<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"/>'));D("group",B('<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"/>'));D("ungroup",B('<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"/>'));D("clone",B('<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"/>'));D("arrow-up",B('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));D("arrow-down",B('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));D("move-vertical",B('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));D("move",B('<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"/>'));D("pen",B('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));D("wave",B('<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"/>'));D("folder-plus",B('<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"/>'));D("folder-minus",B('<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"/>'));D("collapse",B('<path d="M3 8h10"/>'));D("expand",B('<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"/>'));D("maximize",B('<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"/>'));D("restore",B('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));D("star",B('<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"/>'));D("star-filled",B('<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"'));D("grip",B('<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"'));D("kebab",B('<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"'));D("burger",B('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));D("reset",B('<rect x="6" y="6" width="4" height="4" rx="0.8"/><path d="M2.2 8a5.8 5.8 0 1 0 1.9-4.3L2.2 5.3"/><path d="M2.2 2.2v3.1h3.1"/>'));D("pane-collapse",B('<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"/>'));D("pane-expand",B('<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"/>'));D("cursor",A('<path d="M5 3l6 16 2-6 6-2z"/>','fill="currentColor" stroke="none"'));D("ruler",A('<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"/>'));D("magnet",A('<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"/>'));D("eraser",A('<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"/>'));D("pen-lock",A('<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"/>'));D("pen-sync",A('<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"/>'));D("brush",A('<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"/>'));D("bucket",A('<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"/>'));D("type",A('<path d="M5 6V4.5h14V6"/><path d="M12 4.5v15"/><path d="M9.5 19.5h5"/>'));D("bold",A('<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"'));D("italic",A('<path d="M15 5h-5M14 19H9M14.5 5 10 19"/>','stroke-width="2.2"'));D("price-delta",A('<path d="M12 4v16"/><path d="M8 8l4-4 4 4"/><path d="M8 16l4 4 4-4"/>'));D("date-delta",A('<path d="M4 12h16"/><path d="M8 8l-4 4 4 4"/><path d="M16 8l4 4-4 4"/>'));D("bring-front",A('<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"/>'));D("send-back",A('<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"/>'));D("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>');D("bands",A('<path d="M3 6h18"/><path d="M3 18h18"/><path d="M3 12h18" stroke-dasharray="3 3"/>'));D("dedekind",A('<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"/>'));D("sonic",A('<circle cx="15" cy="12" r="4"/><circle cx="12" cy="12" r="2.5"/><path d="M8 5v14"/>'));D("supersonic",A('<circle cx="16" cy="12" r="3.5"/><path d="M6 12 15 6M6 12 15 18"/>'));var Pe=[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}],F=[{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:Pe,group:"line"}],ee=[{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"}],qe=[{value:"small",label:"Small"},{value:"normal",label:"Normal"},{value:"large",label:"Large"},{value:"huge",label:"Huge"}],N=[{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:qe,group:"text"},{path:"text.bold",label:"Bold",kind:"boolean",group:"text"},{path:"text.italic",label:"Italic",kind:"boolean",group:"text"}];function j(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 nr(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=j(r,e,o[0],o[1],s[0],s[1]);a<n&&(n=a);}return n}function xe(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,d=Math.max(n,o)+s;return r>=a&&r<=l&&e>=c&&e<=d}function ot(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 ic(r,e,t,n,i,o,s,a){let l=t-r,c=n-e,d=s-i,u=a-o,h=d*c-u*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*d,o+p*u]}function H(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 d=(n-e)/a,u=m=>e+d*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,u(h),p,u(p)]}var Ho=class extends V{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&&j(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 H(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:[...F,{path:"style.arrowRight",label:"Arrow",kind:"boolean",group:"line"},...N]}}};var zo=class extends V{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 H(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:[...F,...N]}}};var $o=class extends V{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,d]=se(s[0],s[1],s[2],s[3],"right",i.width,i.height);return j(t,n,a,l,c,d)<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return H(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:[...F,...N]}}};var Ut=class extends V{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&&j(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 H(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:[...F,...N]}}};var Wo=class extends Ut{constructor(){super(...arguments);this.type="extendedline";}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,d]=se(s[0],s[1],s[2],s[3],"both",i.width,i.height);return j(t,n,a,l,c,d)<=o}timeExtent(){return null}};var Go=class extends V{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 H(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:[...F,...N]}}};var Uo=class extends V{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&&j(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 H(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:[...F,...N]}}};var Yo=class extends V{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 H(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:[...F,...N]}}};var Ko=class extends Ut{constructor(){super(...arguments);this.type="infoline";}};var Xo=class extends Ut{constructor(){super(...arguments);this.type="trendangle";}};var jo=class extends V{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&&xe(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=>j(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 H(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:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"},...N]}}};var Ny={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},Yt=class extends V{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=Ny[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&&xe(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 H(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&&xe(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&&j(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 H(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:[...F,...ee,...N],textIsContent:true}}};var st=class extends ze{constructor(){super(...arguments);this.type="callout";}};var fn=class extends ze{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:[...F,...ee,...N.filter(t=>t.path!=="text.value")]}}};var gn=class extends ze{constructor(){super(...arguments);this.type="comment";}defaultLabel(){return "Comment"}};var bn=class extends ze{constructor(){super(...arguments);this.type="signpost";}defaultLabel(){return "Signpost"}};var te=class extends V{hitTest(e,t,n,i){let o=this.geometry(n);return o?this.style.fillColor&&o.fill&&ot(e,t,o.fill)?true:o.segments.some(s=>j(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 H(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 qo=class extends te{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),d=t.yOf(n.price+o,this.paneId),u=t.yOf(i.price+o,this.paneId);return l==null||c==null||d==null||u==null?null:{segments:[[s,l,a,c],[s,d,a,u]],fill:[[s,l],[a,c],[a,u],[s,d]]}}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:[...F,...ee,...N]}}};var Zo=class extends te{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:[...F,...ee,...N]}}};var Jo=class extends te{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 d=t.yOf(c.price,this.paneId);return d==null?null:{segments:[[o,a,s,l],[o,d,s,d]],fill:[[o,a],[s,l],[s,d],[o,d]]}}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:[...F,...ee,...N]}}};var _y=2;function hh(){return {midColor:Ee,midStyle:"solid",upperColor:J,upperStyle:"solid",lowerColor:X,lowerStyle:"solid",upperFill:`${J}26`,lowerFill:`${X}26`,showR2:true}}function ph(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,d=0;for(let m=0;m<e;m+=1){let f=r[m].close-(c+l*m);d+=f*f;}let u=Math.sqrt(d/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:_y*u,r2:Math.max(0,Math.min(1,p*p)),n:e}}var Et=class extends V{constructor(t){super(t);this.type="regressionchannel";this.cachedRange=null;this.reg||(this.reg=hh());}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?ph(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 ot(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=>j(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 H(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={...hh(),...t};}};var mh=`${St}00`;function fh(){return {midColor:St,midStyle:"solid",multiplier:1,upperColor:mh,upperStyle:"solid",lowerColor:mh,lowerStyle:"solid",bandFill:`${St}33`}}function gh(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 d=r[c],u=(d.high+d.low+d.close)/3,h=i?Math.max(0,d.volume):1;o+=h,s+=u*h,a+=u*u*h;let p=o>0?s/o:u,m=o>0?Math.max(0,a/o-p*p):0,f=Math.sqrt(m)*e;l.push({time:d.time,mid:p,upper:p+f,lower:p-f});}return l}var vn=class extends V{constructor(t){super(t);this.type="anchoredvwap";this.cachedRange=null;this.cachedExtent=null;this.vwap||(this.vwap=fh());}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=gh(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),d=t.yOf(a.upper,this.paneId),u=t.yOf(a.lower,this.paneId);c==null||d==null||u==null||(i.push([l,c]),o.push([l,d]),s.push([l,u]));}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?ot(t,n,this.bandPolygon(s))?true:oc(t,n,s.mid,o)||oc(t,n,s.upper,o)||oc(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 H(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={...fh(),...t};}};function oc(r,e,t,n){for(let i=1;i<t.length;i+=1)if(j(r,e,t[i-1][0],t[i-1][1],t[i][0],t[i][1])<=n)return true;return false}var By=`${J}66`,Hy=`${X}66`,zy=`${J}BF`,$y=`${X}BF`;function bh(){return {rows:24,valueAreaPct:70,widthPct:35,anchor:"left",upColor:By,downColor:Hy,vaUpColor:zy,vaDownColor:$y,showVah:true,vahColor:Ee,vahStyle:"solid",showVal:true,valColor:Ee,valStyle:"solid",showPoc:true,pocColor:void 0,pocStyle:"solid",showDevelopingPoc:false,developingPocColor:Te,developingPocStyle:"dotted",showDevelopingVa:false,developingVaColor:Te,developingVaStyle:"dotted"}}function Wy(r,e){return r<0?0:r>=e?e-1:r}function vh(r,e,t){let n=r.length,i=0,o=0;for(let d=0;d<n;d+=1){let u=r[d].up+r[d].down;i+=u,u>o&&(o=u);}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 d=a>0?r[a-1].up+r[a-1].down:-1,u=l<n-1?r[l+1].up+r[l+1].down:-1;u>d?(l+=1,c+=u):(a-=1,c+=d);}return {vaFrom:a,vaTo:l}}function yh(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(Wy(Math.floor((l-e)/t),o));for(let l of a)r[l][s]+=i;}function wh(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 xh(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)yh(a,n,s,p);let l=wh(a);if(!l)return null;let{poc:c,maxTotal:d}=l,{vaFrom:u,vaTo:h}=vh(a,c,t);return {rows:a,rowH:s,min:n,maxTotal:d,poc:c,vaFrom:u,vaTo:h}}function Sh(r,e,t,n){let i=xh(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=[],d=[],u=[];for(let h of r){yh(l,o,s,h);let p=wh(l);if(!p)continue;let{poc:m}=p,{vaFrom:f,vaTo:g}=vh(l,m,t);c.push({time:h.time,price:l[m].price+s/2}),d.push({time:h.time,price:l[g].price+s}),u.push({time:h.time,price:l[f].price});}return {profile:i,developingPoc:c,developingVaHigh:d,developingVaLow:u}}var Ve=class extends V{constructor(t){super(t);this.type="fixedrangevp";this.cachedRange=null;this.frvp||(this.frvp=bh());}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=Sh(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),d=t.xOf(l),u=Math.abs(d-c),h=Math.max(1,Math.min(100,Math.max(0,this.frvp.widthPct))/100*u),p=this.frvp.anchor==="left",m=p?Math.min(c,d):Math.max(c,d),f=p?1:-1,g=[];for(let x=0;x<=s.rows.length;x+=1){let S=t.yOf(s.min+x*s.rowH,this.paneId);if(S==null)return null;g.push(S);}let b=x=>t.yOf(x,this.paneId),v=s.rows[s.vaTo].price+s.rowH,y=s.rows[s.vaFrom].price,w=s.rows[s.poc].price+s.rowH/2,P=x=>{let S=[];for(let E of x){let L=b(E.price);L!=null&&S.push([t.xOf(E.time),L]);}return S};return {x0:Math.min(c,d),x1:Math.max(c,d),anchorX:m,maxW:h,grow:f,profile:s,yEdges:g,vahY:b(v),valY:b(y),pocY:b(w),developingPoc:P(o.developingPoc),developingVaHigh:P(o.developingVaHigh),developingVaLow:P(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]),d=Math.max(s.yEdges[0],s.yEdges[s.yEdges.length-1]);if(ot(t,n,[[a,c],[l,c],[l,d],[a,d]]))return true;let u=[[s.x0,s.vahY],[s.x0,s.valY],[s.x0,s.pocY]];for(let[,h]of u)if(h!=null&&j(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(j(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 H(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:Pe,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:Pe,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:Pe,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:Pe,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:Pe,group:"line"}]}}writeProps(){return {...this.frvp}}readProps(t){this.frvp={...bh(),...t};}};var Qo=class extends te{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 d=(l[0]+c[0])/2,u=(l[1]+c[1])/2,h=d-a[0],p=u-a[1],m=t.width,f=t.height;return {segments:[se(a[0],a[1],d,u,"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:[...F,...N]}}};var rr=class extends te{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,d=(a[1]+l[1])/2,u=c-s[0],h=d-s[1],p=e.width,m=e.height;return {segments:[se(s[0],s[1],c,d,"right",p,m),se(a[0],a[1],a[0]+u,a[1]+h,"right",p,m),se(l[0],l[1],l[0]+u,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:[...F,...N]}}};var es=class extends rr{constructor(){super(...arguments);this.type="schiffpitchfork";}medianStart(t,n){return {time:t.time,price:(t.price+n.price)/2}}};var ts=class extends rr{constructor(){super(...arguments);this.type="modifiedschiffpitchfork";}medianStart(t,n){return {time:(t.time+n.time)/2,price:(t.price+n.price)/2}}};var ns=class extends te{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 v=t.yOf(b.price,this.paneId);return v==null?null:[t.xOf(b.time),v]},a=s({time:(n.time+i.time)/2,price:(n.price+i.price)/2}),l=s(n),c=s(i),d=s(o);if(!a||!l||!c||!d)return null;let u=(c[0]+d[0])/2,h=(c[1]+d[1])/2,p=d[0]-a[0],m=d[1]-a[1],f=t.width,g=t.height;return {segments:[se(u,h,u+p,h+m,"right",f,g),se(c[0],c[1],c[0]+p,c[1]+m,"right",f,g),se(d[0],d[1],d[0]+p,d[1]+m,"right",f,g),[c[0],c[1],d[0],d[1]],[a[0],a[1],d[0],d[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:[...F,...N]}}};var rs=class extends V{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&&j(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 H(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:[...F,{path:"style.arrowRight",label:"Head (end)",kind:"boolean",group:"line"},{path:"style.arrowLeft",label:"Head (start)",kind:"boolean",group:"line"},...N]}}};var Ch=48,is=class extends V{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<=Ch;i+=1){let o=i/Ch*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:nr(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 H(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:[...F,...ee,...N]}}};var os=class extends te{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=d=>{let u=t.yOf(d.price,this.paneId);return u==null?null:[t.xOf(d.time),u]},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:[...F,...ee,...N]}}};var Gy=512,Kt=class extends te{anchorSchema(){return {min:2,max:Gy,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:[...F,...N]}}};var ss=class extends Kt{constructor(){super(...arguments);this.type="polyline";}};var ei=class extends Kt{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}}},as=class extends ei{constructor(){super(...arguments);this.type="freehand";}};var Uy=[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Width",kind:"number",min:4,max:60,step:1,group:"line"}],ls=class extends ei{constructor(){super(...arguments);this.type="highlighter";}schema(){return {fields:Uy}}};var cs=class extends V{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 H(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:[...F,...ee,...N]}}};var ds=class extends te{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,d=s/l,u=(o[0]-n[0])*c+(o[1]-n[1])*d,h=c*u,p=d*u,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:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var us=class extends Kt{constructor(){super(...arguments);this.type="path";}};var Th=40,hs=class extends te{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,d=(i[1]-n[1])/2,u=Math.hypot(c,d);if(u<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let h=-d/u,p=c/u,m=(s-l)*p;m<0&&(h=-h,p=-p);let f=Math.abs(m),g=[];for(let v=0;v<=Th;v+=1){let y=v/Th*Math.PI,w=Math.cos(y),P=Math.sin(y);g.push([a+w*c+P*f*h,l+w*d+P*f*p]);}let b=[];for(let v=1;v<g.length;v+=1)b.push([g[v-1][0],g[v-1][1],g[v][0],g[v][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:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var Eh=40,ps=class extends te{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<=Eh;l+=1){let c=l/Eh,d=1-c;s.push([d*d*n[0]+2*d*c*o[0]+c*c*i[0],d*d*n[1]+2*d*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:[...F,...ee,...N]}}};var Yy={head:11,headW:9,stemW:3.5,len:22},yn=class extends V{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}=Yy,c=[[0,0],[-s,o],[-a,o],[-a,l],[a,l],[a,o],[s,o]],d=this.dir(),u=([h,p])=>{switch(d){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]=u(h);return [i+p,n+m]})}hitTest(e,t,n,i){let o=this.glyphPoints(n);return o!=null&&ot(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 H(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"},...N]}}},ti=class extends yn{constructor(){super(...arguments);this.type="arrowmarkup";}dir(){return "up"}},ni=class extends yn{constructor(){super(...arguments);this.type="arrowmarkdown";}dir(){return "down"}};var oi=["\u2605","\u2606","\u25CF","\u25C6","\u25B2","\u25BC","\u27A4","\u2691","\u271A","\u2715","\u2764","\u2666"],ms=["small","normal","large","huge"],Ph={small:16,normal:22,large:32,huge:44},wn=class extends V{constructor(e){super(e),this.glyph||(this.glyph=this.defaultGlyph()),this.size||(this.size="normal");}sizePx(){return Ph[this.size]??Ph.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 H(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:oi.map(e=>({value:e,label:e})),group:"line"},{path:"size",label:"Size",kind:"select",options:ms.map(e=>({value:e,label:e})),group:"line"},{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...N]}}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);}},ri=class extends wn{constructor(){super(...arguments);this.type="flagmark";}defaultGlyph(){return "\u2691"}},ii=class extends wn{constructor(){super(...arguments);this.type="iconstamp";}defaultGlyph(){return "\u2605"}};var Lh=r=>r==="small"||r==="normal"||r==="large"||r==="huge";function Ky(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 re=class extends V{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=>j(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 H(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:F.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(Ky).filter(n=>n!=null);t.length&&(this.levels=t);}Lh(e.numbersSize)&&(this.numbersSize=e.numbersSize),Lh(e.labelsSize)&&(this.labelsSize=e.labelsSize);}};var ir=class extends re{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 d of this.levels){if(!d.enabled)continue;let u=t.price+d.ratio*l,h=e.yOf(u,this.paneId);h!=null&&c.push({ratio:d.ratio,color:d.color,label:d.label,price:u,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 xn=Ee,at=X,lt=hn,Sn="#4caf50",Xt=J,Pt=St,Cn="#9c27b0",Xy="#e91e63",sc="#26a69a",jy="#ab47bc",qy="#ef5350",Mh="#ffb74d",Zy="#38c0fd",fs="#b2b5be",or=[Zy,Pt,Xt,Sn,lt,at,Xy,Cn,xn,sc,jy,qy];function kh(r){return or[(r%or.length+or.length)%or.length]}var Jy=[[0,xn],[.125,at],[.236,at],[.25,at],[.382,lt],[.5,Sn],[.618,Xt],[.75,Pt],[.786,Pt],[1,xn],[1.272,Pt],[1.382,lt],[1.618,at],[2,xn],[2.382,lt],[2.618,lt],[3,xn],[4.236,Sn],[6.854,Xt],[11.09,Pt]];function Qy(r,e=0){return Jy.find(([t])=>t===r)?.[1]??kh(e)}function ne(r){return r.map((e,t)=>{let n=typeof e=="number"?{ratio:e}:e;return {ratio:n.ratio,color:n.color??Qy(n.ratio,t),enabled:n.enabled!==false,...n.label?{label:n.label}:{}}})}function Ih(r,e=r){return Array.from({length:r},(t,n)=>({ratio:n+1,color:kh(n),enabled:n<e,label:String(n+1)}))}var ew=ne([0,.236,.382,.5,.618,.786,1]),gs=class extends ir{constructor(){super(...arguments);this.type="fibretracement";}defaultLevels(){return ew}};var tw=ne([0,.382,.618,1,1.272,1.618,{ratio:2.618,color:Cn}]),bs=class extends ir{constructor(){super(...arguments);this.type="fibextension";}defaultLevels(){return tw}};var nw=ne([0,.382,.5,.618,1,1.618,{ratio:2.618,color:Cn}]),vs=class extends re{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 nw}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),d=[];for(let u of this.levels){if(!u.enabled)continue;let h=o.price+u.ratio*s,p=t.yOf(h,this.paneId);p!=null&&d.push({color:u.color,label:u.label,x1:l,y1:p,x2:c,y2:p,numberText:`${u.ratio} (${h.toFixed(2)})`,numberX:l+4,numberY:p-7,numberAlign:"left",labelX:(l+c)/2,labelY:p-7});}return d}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 rw=ne([.236,.382,.5,.618,.786,1]),ys=class extends re{constructor(){super(...arguments);this.type="fibfan";}defaultLevels(){return rw}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 d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+d.ratio*l,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({ratio:d.ratio,color:d.color,label:d.label,x1:h,y1:p,x2:m,y2:f,labelX:a+5,labelY:u});}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 iw=[0,1,2,3,5,8,13,21,34].map(r=>({ratio:r,color:R,enabled:true})),ws=class extends re{constructor(){super(...arguments);this.type="fibtimezones";}defaultLevels(){return iw}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 ow=ne([0,.236,.382,.5,.618,.786,1,1.618,2.618]),xs=class extends re{constructor(){super(...arguments);this.type="fibchannel";}defaultLevels(){return ow}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,d=0,u=this.anchors[2];if(u){let p=t.yOf(u.price,this.paneId);if(p==null)return null;c=t.xOf(u.time)-a,d=p-o;}let h=[];for(let p of this.levels){if(!p.enabled)continue;let m=p.ratio*c,f=p.ratio*d,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 d=c+l.ratio*o;d<s&&(s=d),d>a&&(a=d);}return s<=a?{min:s,max:a}:null}};var sw=ne([0,.236,.382,.5,.618,.786,1]),Ss=class extends re{constructor(){super(...arguments);this.type="fibspeedfan";}defaultLevels(){return sw}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,d=s-o,u=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+d*f.ratio,v=se(a,o,g,b,u,h,p);if(m.push({color:f.color,label:f.label,x1:v[0],y1:v[1],x2:v[2],y2:v[3],numberText:String(f.ratio),numberX:u==="right"?g+5:g-5,numberY:b,numberAlign:u==="right"?"left":"right",labelX:g,labelY:b}),f.ratio===1)continue;let y=a+c*f.ratio,w=o+d,P=se(a,o,y,w,u,h,p);m.push({color:f.color,label:f.label,x1:P[0],y1:P[1],x2:P[2],y2:P[3],numberText:String(f.ratio),numberX:y,numberY:w+(d>=0?12:-12),numberAlign:"center",labelX:y,labelY:w+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 aw=ne([0,.382,{ratio:.5,enabled:false},.618,1,1.382,1.618,2,2.382,2.618,3]),Cs=class extends re{constructor(){super(...arguments);this.type="trendfibtime";}defaultLevels(){return aw}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 d=t.xOf(o.time+c.ratio*s);l.push({color:c.color,label:c.label,x1:d,y1:0,x2:d,y2:a,numberText:String(c.ratio),numberX:d,numberY:9,numberAlign:"center",labelX:d,labelY:24});}return l}priceRange(){return null}timeExtent(){return null}};function lw(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 Ze=class extends re{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(lw(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=>j(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 cw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),Ts=class extends Ze{constructor(){super(...arguments);this.type="fibcircles";}defaultLevels(){return cw}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 dw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),Es=class extends Ze{constructor(){super(...arguments);this.type="fibarcs";}defaultLevels(){return dw}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 uw=ne([.236,.382,.5,.618,.786,1]),Ps=class extends Ze{constructor(){super(...arguments);this.type="fibwedge";}defaultLevels(){return uw}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),d=Math.max(a,l);return d-c>Math.PI&&([c,d]=[d,c+Math.PI*2]),{cx:n[0],cy:n[1],R0:s,a0:c,a1:d}}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 hw=1.6180339887,Ah=Math.log(hw)/(Math.PI/2),pw=Math.PI/64,mw=Math.PI,fw=.5,Tn=class extends V{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 d=Math.atan2(s-o,l-a),u=Math.max(Math.log(fw/c)/Ah,-8*Math.PI*2),h=[];for(let p=u;p<=mw;p+=pw){let m=c*Math.exp(Ah*p),f=d+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&&nr(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 H(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:[...F,...N]}}};var gw=ne([{ratio:.125,color:at,label:"1/8"},{ratio:.25,color:lt,label:"1/4"},{ratio:.333,color:Mh,label:"1/3"},{ratio:.5,color:Sn,label:"1/2"},{ratio:1,color:fs,label:"1/1"},{ratio:2,color:Xt,label:"2/1"},{ratio:3,color:Pt,label:"3/1"},{ratio:4,color:sc,label:"4/1"},{ratio:8,color:Cn,label:"8/1"}]),Ls=class extends re{constructor(){super(...arguments);this.type="gannfan";}defaultLevels(){return gw}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 d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+l*d.ratio,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({color:d.color,x1:h,y1:p,x2:m,y2:f,numberText:d.label??String(d.ratio),numberX:a+5,numberY:u,numberAlign:"left",labelX:a+5,labelY:u});}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 bw=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),Ms=class extends re{constructor(){super(...arguments);this.type="gannbox";}defaultLevels(){return bw}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,d=[];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&&d.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));d.push({color:h.color,x1:m,y1:l,x2:m,y2:c,numberText:"",numberX:m,numberY:l,numberAlign:"center",labelX:m,labelY:l});}let u=this.levels.find(h=>h.ratio===1)?.color??xn;return d.push({color:u,x1:s,y1:l,x2:a,y2:c,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d.push({color:u,x1:s,y1:c,x2:a,y2:l,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d}hitTest(t,n,i,o){let s=this.corners(i);return s!=null&&xe(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 vw=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),yw=[{label:"3x1",x:3,y:1,color:at},{label:"2x1",x:2,y:1,color:lt},{label:"1x1",x:1,y:1,color:fs},{label:"1x2",x:1,y:2,color:Xt},{label:"1x3",x:1,y:3,color:Pt}],ac=[{k:.25,color:at},{k:.5,color:lt},{k:.75,color:Sn},{k:1,color:Xt}],En=class extends re{constructor(){super(...arguments);this.type="gannsquare";}defaultLevels(){return vw}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 yw){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&&xe(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 lc=[4,8,12,16,24,32,48,64],ww=24,xw=.75;function Rh(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 Dh(r){let e=[];for(let t=0;t<r;t+=1)Rh(t,r)&&e.push(t);return e}var Pn=class extends V{constructor(t){super(t);this.type="dedekind";this.maxCurvature===void 0&&(this.maxCurvature=ww);}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),d=Math.max(o,s),u=l-a,h=d-c;if(u<1||h<1)return null;let p=h,m=u/p;return {left:a,right:l,top:c,bot:d,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,d=Math.max(1,Math.min(64,Math.round(this.maxCurvature))),u=l-1/d,h=l+c+1/d,p=i+c*a,m=[],f=Math.floor(u*2),g=Math.ceil(h*2);for(let b=f;b<=g;b+=1){if(b%2===0)continue;let v=i+(b/2-l)*a;v<i-.5||v>p+.5||m.push({kind:"vline",x:v,y0:s,y1:o});}for(let b=1;b<=d;b+=1){let v=1/b,y=v*a;if(y<xw)continue;let w=Dh(b);if(w.length===0)continue;let P=Math.floor(u)-1,x=Math.ceil(h)+1;for(let S=P;S<=x;S+=1)for(let E of w){let L=E/b+S;if(L+v<u||L-v>h)continue;let T=i+(L-l)*a;T+y<i-1||T-y>p+1||m.push({kind:"arc",cx:T,cy:s,r:y});}}return m}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&xe(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 H(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:[...F,{path:"maxCurvature",label:"Max curvature",kind:"number",min:4,max:64,step:4,group:"behavior"},...N]}}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 cc=[3,4,5,6,8,10,12],dc=[1.5,2,2.5,3,4,5],ks=6,Sw=2;function uc(r=ks){return [...Ih(or.length,r)]}function Cw(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 sr={path:"showRatios",label:"Show ratios",kind:"boolean",group:"behavior"},Ae=class extends V{constructor(e){super(e),this.waveCount===void 0&&(this.waveCount=ks),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,d=Math.hypot(a-s,o-i)/2;if(d<1)return null;let u=a-s,h=o-i,p=Math.hypot(u,h);p<1e-9?(u=1,h=0):(u/=p,h/=p);let m=this.levels.filter(x=>x.enabled&&x.ratio>0).slice().sort((x,S)=>x.ratio-S.ratio);if(m.length===0)return null;let f=Math.max(1,this.machNumber()),g=[];for(let x of m){let S=x.ratio*d;g.push({cx:l+f*(S-d)*u,cy:c+f*(S-d)*h,r:S,color:x.color,ratio:x.ratio});}let b=l-f*d*u,v=c-f*d*h,y=g[g.length-1].r,w=f*y+2*d,P=[];if(f<=1+1e-9){let x=-h,S=u;P.push([b-x*w,v-S*w,b+x*w,v+S*w]);}else {let x=Math.asin(1/f),S=Math.cos(x),E=Math.sin(x),L=(I,_,U)=>[I*S-_*U*E,I*U*E+_*S],[T,k]=L(u,h,1),[M,C]=L(u,h,-1);P.push([b,v,b+T*w,v+k*w]),P.push([b,v,b+M*w,v+C*w]);}return {c0x:l,c0y:c,R:d,fx:u,fy:h,noseX:b,noseY:v,circles:g,rays:P}}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=>j(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 H(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:[...F,{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},sr,...N]}}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(Cw).filter(n=>n!=null);t.length&&(this.levels=t);}}},si=class extends Ae{constructor(){super(...arguments);this.type="sonic";}defaultLevels(){return uc(ks)}machNumber(){return 1}},ai=class extends Ae{constructor(t){super(t);this.type="supersonic";this.mach===void 0&&(this.mach=Sw);}defaultLevels(){return uc(ks)}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{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"},sr,...N]}}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 Oh=ne([.236,.382,.5,.618,.786,1,1.618,2.618,4.236,6.854,11.09]),Tw=2,Is=class extends Ae{constructor(){super(...arguments);this.type="goldensonic";}shouldSyncWaveCount(){return false}defaultLevels(){return Oh}machNumber(){return 1}schema(){return {fields:[...F,sr,...N]}}},As=class extends Ae{constructor(t){super(t);this.type="goldensupersonic";this.mach===void 0&&(this.mach=Tw);}shouldSyncWaveCount(){return false}defaultLevels(){return Oh}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},sr,...N]}}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 ge=class extends V{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&&nr(e,t,o)<=i}hitHandle(e,t,n,i){return H(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:[...F,...this.fillTriangles().length?ee:[]]}}};var Rs=class extends ge{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 Ds=class extends ge{constructor(){super(...arguments);this.type="abcd";}vertexLabels(){return ["A","B","C","D"]}legRatios(){return true}};var Os=class extends ge{constructor(){super(...arguments);this.type="elliottimpulse";}vertexLabels(){return ["1","2","3","4","5"]}};var Fs=class extends ge{constructor(){super(...arguments);this.type="elliottcorrection";}vertexLabels(){return ["A","B","C"]}};var Ns=class extends ge{constructor(){super(...arguments);this.type="headshoulders";}vertexLabels(){return ["","LS","","H","","RS",""]}necklineIndices(){return [2,4]}};var Re=class extends ge{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=(u,h)=>Math.abs(h.price-u.price),l=a(t,n),c=a(n,i),d=a(i,o);switch(e){case "ab":return l<1e-9?null:c/l;case "bc":return c<1e-9?null:d/c;case "cd":return d<1e-9?null:a(o,s)/d;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 Vs=class extends Re{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 _s=class extends Re{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 Bs=class extends Re{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 Hs=class extends Re{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 zs=class extends Re{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 Ew={min:1.272,max:1.414},Pw={min:.74,max:.83},$s=class extends Re{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(),Ew)&&this.inBand(this.cdOverXc(),Pw)}};function Fh(r){return `${r>=0?"+":""}${r.toFixed(2)}`}function li(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 Ln=class extends V{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 `${Fh(n)} (${Fh(i)}%)`}timeLabel(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return "";let i=li(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&&xe(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 H(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"},...F.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:qe,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 Ws=class extends Ln{constructor(){super(...arguments);this.type="datepricerange";}};var Gs=[{value:"long",label:"Long"},{value:"short",label:"Short"}],le=class le extends V{constructor(t){super(t);this.type="position";this.riskPercent===void 0&&(this.riskPercent=le.DEFAULT_RISK_PERCENT),this.accountBalance===void 0&&(this.accountBalance=le.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=le.DEFAULT_PROFIT_COLOR),this.lossColor===void 0&&(this.lossColor=le.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)>=le.MIN_DRAG_PX?(l=a,c=i+Math.max(Math.abs(t.xOf(s.time)-i),le.MIN_WIDTH_PX)):(l=o-le.DEFAULT_RISK_PX*le.DEFAULT_RR,c=i+le.DEFAULT_WIDTH_PX);let d=o-(l-o)/le.DEFAULT_RR,u=t.pxToPoint(c,o,this.paneId).time;this.anchors=[{time:n.time,price:n.price},{time:u,price:t.pxToPoint(i,d,this.paneId).price},{time:u,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)/le.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 $${Lw(this.dollarLoss())} \xB7 Size ${Mw(this.positionSize())}`}targetLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Nh(t.target)}`:"";return `Target +${this.rewardPct().toFixed(2)}%${n}`}stopLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Nh(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 Vh(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 xe(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 H(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:Gs,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"},...F.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:qe,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);}};le.DEFAULT_RR=2,le.MIN_DRAG_PX=6,le.DEFAULT_RISK_PX=64,le.DEFAULT_WIDTH_PX=150,le.MIN_WIDTH_PX=48,le.DEFAULT_RISK_PERCENT=1,le.DEFAULT_ACCOUNT_BALANCE=1e4,le.DEFAULT_PROFIT_COLOR=Fo,le.DEFAULT_LOSS_COLOR=No;var $e=le;function Lw(r){if(!Number.isFinite(r))return "0";let e=Math.round(r*100)/100;return Number.isInteger(e)?String(e):e.toFixed(2)}function Mw(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 Nh(r){return Number.isFinite(r)?Math.abs(r)>=1?r.toFixed(2):r.toPrecision(4).replace(/\.?0+$/,""):"0"}function Vh(r){return Math.round(r*1e8)/1e8}var ci=new Map;function O(r){ci.set(r.type,r);}function jt(r){return ci.get(r)}function Us(){return [...ci.values()]}function qt(r,e){let t=ci.get(r);if(!t)return null;let n={...t.defaultStyle,...e.style??{}};return t.create({...e,style:n})}function hc(r){let e=qt(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 ct(r){let e=ci.get(r.type);return e?e.create(r):null}var kw=A('<line x1="4" y1="19" x2="20" y2="5"/>'),Iw=A('<line x1="3" y1="12" x2="21" y2="12"/>');O({type:"trendline",group:"lines",label:"Trend Line",icon:kw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Ho(r)});O({type:"hline",group:"lines",label:"Horizontal Line",icon:Iw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"dashed"},create:r=>new zo(r)});var Aw=A('<line x1="3" y1="20" x2="21" y2="6"/><circle cx="3" cy="20" r="1.6" fill="currentColor"/>'),Rw=A('<rect x="4" y="6" width="16" height="12" rx="1"/>'),Dw=A('<path d="M5 6h14M12 6v13"/>');O({type:"ray",group:"lines",label:"Ray",icon:Aw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new $o(r)});var Ow=A('<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"/>'),Fw=A('<line x1="12" y1="3" x2="12" y2="21"/>'),Nw=A('<line x1="5" y1="12" x2="21" y2="12"/><circle cx="5" cy="12" r="1.6" fill="currentColor"/>'),Vw=A('<line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/>'),_w=A('<path d="M4 20 20 4"/><rect x="9" y="9" width="9" height="6" rx="1"/>'),Bw=A('<path d="M4 20 20 6"/><path d="M4 20 15 20"/><path d="M11 20a7 7 0 0 0-2-4.9"/>');O({type:"extendedline",group:"lines",label:"Extended Line",icon:Ow,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Wo(r)});O({type:"vline",group:"lines",label:"Vertical Line",icon:Fw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Go(r)});O({type:"hray",group:"lines",label:"Horizontal Ray",icon:Nw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Uo(r)});O({type:"crossline",group:"lines",label:"Cross Line",icon:Vw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Yo(r)});O({type:"infoline",group:"lines",label:"Info Line",icon:_w,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Ko(r)});O({type:"trendangle",group:"lines",label:"Trend Angle",icon:Bw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Xo(r)});O({type:"box",group:"shapes",label:"Rectangle",icon:Rw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}26`},create:r=>new jo(r)});O({type:"text",group:"annotations",label:"Text",icon:Dw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Tt(r)});var Hw=A('<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"/>');O({type:"callout",group:"annotations",label:"Callout",icon:Hw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new st(r)});var zw=A('<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"/>'),$w=A('<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"/>'),Ww=A('<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"/>'),Gw=A('<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"/>'),Uw=A('<path d="M12 11.5V21"/><rect x="5" y="4" width="14" height="7" rx="1"/><path d="M9 7.5h6"/>');O({type:"note",group:"annotations",label:"Note",icon:zw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new pn(r)});O({type:"pricenote",group:"annotations",label:"Price Note",icon:$w,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new fn(r)});O({type:"comment",group:"annotations",label:"Comment",icon:Ww,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new gn(r)});O({type:"pricelabel",group:"annotations",label:"Price Label",icon:Gw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new mn(r)});O({type:"signpost",group:"annotations",label:"Signpost",icon:Uw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new bn(r)});var Yw=A('<line x1="3" y1="16" x2="21" y2="8"/><line x1="3" y1="21" x2="21" y2="13"/>'),Kw=A('<line x1="3" y1="7" x2="21" y2="10"/><line x1="3" y1="18" x2="21" y2="14"/>'),Xw=A('<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"/>');O({type:"parallelchannel",group:"channels",label:"Parallel Channel",icon:Yw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new qo(r)});O({type:"disjointchannel",group:"channels",label:"Disjoint Channel",icon:Kw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new Zo(r)});var jw=A('<line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="18" x2="21" y2="11"/>');O({type:"flattopbottom",group:"channels",label:"Flat Top/Bottom",icon:jw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new Jo(r)});var qw=A('<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"/>');O({type:"regressionchannel",group:"channels",label:"Linear Regression",icon:qw,defaultStyle:{lineColor:Ee,lineWidth:1,lineStyle:"solid"},create:r=>new Et(r)});O({type:"pitchfork",group:"pitchforks",label:"Pitchfork",icon:Xw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Qo(r)});var Zw=A('<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"/>'),Jw=A('<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"/>'),Qw=A('<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"/>');O({type:"schiffpitchfork",group:"pitchforks",label:"Schiff Pitchfork",icon:Zw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new es(r)});O({type:"modifiedschiffpitchfork",group:"pitchforks",label:"Modified Schiff Pitchfork",icon:Jw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ts(r)});O({type:"insidepitchfork",group:"pitchforks",label:"Inside Pitchfork",icon:Qw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ns(r)});var ex=A('<path d="M7 7h10v10"/><path d="M7 17 17 7"/>'),tx=A('<ellipse cx="12" cy="12" rx="9" ry="6"/>'),nx=A('<path d="M12 4 20 19 4 19Z"/>');O({type:"arrow",group:"shapes",label:"Arrow",icon:ex,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",arrowRight:true},create:r=>new rs(r)});O({type:"ellipse",group:"shapes",label:"Ellipse",icon:tx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new is(r)});O({type:"triangle",group:"shapes",label:"Triangle",icon:nx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new os(r)});var rx=A('<polyline points="3 17 9 10 13 14 21 5"/>'),ix=A('<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"/>'),ox=A('<path d="M9 11 15 5l4 4-6 6H9Z"/><path d="M9 15l-2 2"/><path d="M4 21h6"/>');O({type:"polyline",group:"shapes",label:"Polyline",icon:rx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ss(r)});O({type:"freehand",group:"shapes",label:"Brush",icon:ix,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new as(r)});O({type:"highlighter",group:"shapes",label:"Highlighter",icon:ox,defaultStyle:{lineColor:`${ih}59`,lineWidth:14,lineStyle:"solid"},create:r=>new ls(r)});var sx=A('<circle cx="12" cy="12" r="8"/>'),ax=A('<path d="M5 14 9.5 5 19 10 14.5 19 Z"/>'),lx=A('<path d="M4 19 9 11 13 14 17 8 20 4"/><path d="M17.2 5.5 20 4 19.4 7.1"/>'),cx=A('<path d="M4 17a8 8 0 0 1 16 0"/><path d="M4 17 20 17"/>'),dx=A('<path d="M4 18Q12 1 20 14"/>'),ux=A('<path d="M12 5 12 19"/><path d="M6 11 12 5 18 11"/>'),hx=A('<path d="M12 5 12 19"/><path d="M6 13 12 19 18 13"/>');O({type:"circle",group:"shapes",label:"Circle",icon:sx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new cs(r)});O({type:"rotatedrect",group:"shapes",label:"Rotated Rectangle",icon:ax,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new ds(r)});O({type:"path",group:"shapes",label:"Path",icon:lx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new us(r)});O({type:"arc",group:"shapes",label:"Arc",icon:cx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new hs(r)});O({type:"curve",group:"shapes",label:"Curve",icon:dx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ps(r)});O({type:"arrowmarkup",group:"shapes",label:"Arrow Mark Up",icon:ux,defaultStyle:{lineColor:J,lineWidth:1,lineStyle:"solid"},create:r=>new ti(r)});O({type:"arrowmarkdown",group:"shapes",label:"Arrow Mark Down",icon:hx,defaultStyle:{lineColor:X,lineWidth:1,lineStyle:"solid"},create:r=>new ni(r)});var px=A('<path d="M6 21V4"/><path d="M6 5h11l-2.5 3.5L17 12H6" fill="currentColor" stroke="none"/>'),mx=A('<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"/>');O({type:"flagmark",group:"stamps",label:"Flag",icon:px,defaultStyle:{lineColor:Te,lineWidth:1,lineStyle:"solid"},create:r=>new ri(r)});O({type:"iconstamp",group:"stamps",label:"Icon",icon:mx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ii(r)});var fx=A('<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"/>'),gx=A('<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"/>');O({type:"fibretracement",group:"fibonacci",label:"Fib Retracement",icon:fx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new gs(r)});O({type:"fibextension",group:"fibonacci",label:"Fib Extension",icon:gx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new bs(r)});var bx=A('<path d="M3 20 10 9l4 5"/><path d="M14 14h7M14 9h7M14 4h7"/>');O({type:"fibextensiontrend",group:"fibonacci",label:"Trend-Based Fib Extension",icon:bx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new vs(r)});var vx=A('<path d="M4 20 20 5M4 20 21 11M4 20 21 17M4 20 20 20"/>'),yx=A('<path d="M3 5v14M6 5v14M11 5v14M19 5v14"/>');O({type:"fibfan",group:"fibonacci",label:"Fib Fan",icon:vx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ys(r)});O({type:"fibtimezones",group:"fibonacci",label:"Fib Time Zones",icon:yx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new ws(r)});var wx=A('<path d="M3 18 18 9M5 21 20 12M6 13 21 4"/>'),xx=A('<path d="M4 4 20 20M4 4 20 12M4 4 12 20M4 4 20 4M4 4 4 20"/>'),Sx=A('<path d="M3 19 9 8M9 8 12 5v14M14 5v14M18 5v14M21 5v14"/>');O({type:"fibchannel",group:"fibonacci",label:"Fib Channel",icon:wx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new xs(r)});O({type:"fibspeedfan",group:"fibonacci",label:"Fib Speed Resistance Fan",icon:xx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ss(r)});O({type:"trendfibtime",group:"fibonacci",label:"Trend-Based Fib Time",icon:Sx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new Cs(r)});var Cx=A('<circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/><circle cx="12" cy="12" r="10"/>'),Tx=A('<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"/>'),Ex=A('<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"/>'),Px=A('<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"/>');O({type:"fibcircles",group:"fibonacci",label:"Fib Circles",icon:Cx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ts(r)});O({type:"fibarcs",group:"fibonacci",label:"Fib Speed Resistance Arcs",icon:Tx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Es(r)});O({type:"fibwedge",group:"fibonacci",label:"Fib Wedge",icon:Ex,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ps(r)});O({type:"fibspiral",group:"fibonacci",label:"Fib Spiral",icon:Px,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Tn(r)});var Lx=A('<path d="M4 20 20 20M4 20 20 13M4 20 20 6M4 20 15 4M4 20 9 4M4 20 4 4"/>'),Mx=A('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 12h16M12 4v16M4 4 20 20" opacity="0.6"/>');O({type:"gannfan",group:"fibonacci",label:"Gann Fan",icon:Lx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ls(r)});O({type:"gannbox",group:"fibonacci",label:"Gann Box",icon:Mx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ms(r)});var kx=A('<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"/>');O({type:"gannsquare",group:"fibonacci",label:"Gann Square",icon:kx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new En(r)});var Ix=A('<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"/>');O({type:"dedekind",group:"geometry",label:"Dedekind Tessellation",icon:Ix,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Pn(r)});var Ax=A('<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"/>'),Rx=A('<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"/>');O({type:"sonic",group:"geometry",label:"Sonic",icon:Ax,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new si(r)});O({type:"supersonic",group:"geometry",label:"Supersonic",icon:Rx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ai(r)});var Dx=A('<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"/>'),Ox=A('<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"/>');O({type:"goldensonic",group:"geometry",label:"Golden Sonic",icon:Dx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Is(r)});O({type:"goldensupersonic",group:"geometry",label:"Golden Supersonic",icon:Ox,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new As(r)});var Fx=A('<path d="M3 18 7 8 11 14 15 6 20 16"/>'),Nx=A('<path d="M4 17 9 7 14 15 20 5"/>'),Vx=A('<path d="M3 19 8 9 12 13 17 5 21 9"/>'),_x=A('<path d="M4 7 11 16 20 9"/>'),Bx=A('<path d="M3 18 6 12 9 16 12 5 15 16 18 12 21 18"/>');O({type:"xabcd",group:"patterns",label:"XABCD Pattern",icon:Fx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rs(r)});O({type:"abcd",group:"patterns",label:"ABCD Pattern",icon:Nx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ds(r)});O({type:"elliottimpulse",group:"patterns",label:"Elliott Impulse Wave (1-5)",icon:Vx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Os(r)});O({type:"elliottcorrection",group:"patterns",label:"Elliott Correction Wave (ABC)",icon:_x,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Fs(r)});O({type:"headshoulders",group:"patterns",label:"Head & Shoulders",icon:Bx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ns(r)});var Hx=A('<path d="M3 17 7 6 12 14 17 5 21 16"/><path d="M3 17 21 16" opacity="0.45"/>'),ar={group:"patterns",icon:Hx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"}};O({type:"gartley",label:"Gartley",...ar,create:r=>new Vs(r)});O({type:"bat",label:"Bat",...ar,create:r=>new _s(r)});O({type:"butterfly",label:"Butterfly",...ar,create:r=>new Bs(r)});O({type:"crab",label:"Crab",...ar,create:r=>new Hs(r)});O({type:"shark",label:"Shark",...ar,create:r=>new zs(r)});O({type:"cypher",label:"Cypher",...ar,create:r=>new $s(r)});var zx=A('<rect x="4" y="6" width="16" height="12" rx="1"/><path d="M4 18 20 6" opacity="0.5"/>');O({type:"datepricerange",group:"measure",label:"Date & Price Range",icon:zx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ws(r)});var $x=A('<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"/>');O({type:"position",group:"measure",label:"Long/Short Position",icon:$x,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new $e(r)});var Wx=A('<line x1="5" y1="3" x2="5" y2="21"/><path d="M5 16c4 0 5-9 8-9s3 5 8 3"/>');O({type:"anchoredvwap",group:"measure",label:"Anchored VWAP",icon:Wx,defaultStyle:{lineColor:St,lineWidth:2,lineStyle:"solid"},create:r=>new vn(r)});var Gx=A('<path d="M4 4v16"/><path d="M4 8h10"/><path d="M4 12h14"/><path d="M4 16h8"/><path d="M4 20h12"/>');O({type:"fixedrangevp",group:"measure",label:"Fixed Range Volume Profile",icon:Gx,defaultStyle:{lineColor:J,lineWidth:1,lineStyle:"solid"},create:r=>new Ve(r)});var Ux=["fibretracement","fibextension","fibextensiontrend","fibfan","fibtimezones","fibchannel","fibspeedfan","trendfibtime","fibcircles","fibarcs","fibwedge","fibspiral"],Yx=["gannfan","gannbox","gannsquare"],Kx=["dedekind","sonic","supersonic","goldensonic","goldensupersonic"],Xx=["xabcd","abcd","headshoulders"],jx=["elliottimpulse","elliottcorrection"],qx=["gartley","bat","butterfly","crab","shark","cypher"],Zx=["position","datepricerange"],Jx=["anchoredvwap","fixedrangevp"],Qx=["freehand","highlighter"],e0=["arrow","arrowmarkup","arrowmarkdown"],t0=["box","ellipse","triangle","polyline","circle","rotatedrect","path","arc","curve"],n0=["text","callout","note","pricenote","comment","pricelabel","signpost"],r0=["flagmark","iconstamp"],i0=[{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:Ux},{label:"Gann",types:Yx},{label:"Geometry",types:Kx}]},{id:"patterns-waves-harmonics",label:"Patterns",sections:[{label:"Patterns",types:Xx},{label:"Elliott Waves",types:jx},{label:"Harmonics",types:qx}]},{id:"measurements",label:"Measurements",sections:[{label:"Measurements",types:Zx},{label:"Volume",types:Jx}]},{id:"brushes-arrows-shapes",label:"Shapes",sections:[{label:"Brushes",types:Qx},{label:"Arrows",types:e0},{label:"Shapes",types:t0}]},{id:"text",label:"Text",sections:[{label:"Text",types:n0}]},{id:"icons",label:"Icons",sections:[{label:"Icons",types:r0}]}];function o0(r){let e=jt(r);return e?{type:e.type,label:e.label,icon:e.icon}:null}function s0(r){let e=new Map;for(let t of Us()){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 a0(r,e,t){return "registryGroup"in r?e.get(r.registryGroup)??[]:r.types.map(n=>t.get(n)).filter(n=>n!=null)}function _h(r){let e=s0(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 i0){let o=[],s=[];for(let a of i.sections){let l=a0(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 l0(r){let e=new Set;for(let t of r)jt(t)&&e.add(t);return _h(e)}function c0(r){let e=[];for(let t of r){let n=t.tools.map(o0).filter(i=>i!=null);n.length>0&&e.push({id:t.id,label:t.label,tools:n});}return {groups:e}}function di(){return _h()}function ui(r){if(r===false)return {definition:di(),visible:false};if(r===void 0||r===true)return {definition:di(),visible:true};let e=r.toolbar??true;return r.groups?{definition:c0(r.groups),visible:e}:r.tools?{definition:l0(r.tools),visible:e}:{definition:di(),visible:e}}function dt(r){let e=globalThis.structuredClone;return e?e(r):JSON.parse(JSON.stringify(r))}function Bh(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 pc(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(Bh)}}var lr=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=pc(e);this.byId.clear(),this.seq=0,this.zCounter=1;for(let n of t.drawings){let i=ct(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 Ys=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=dt(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(dt(e));}undo(e){let t=this.undoStack.pop();return t?(this.redoStack.push(dt(e)),t):null}redo(e){let t=this.redoStack.pop();return t?(this.undoStack.push(dt(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 Ks=class{constructor(e,t,n){this.events=t;this.store=new lr;this.history=new Ys;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:i,visible:o}=ui(n);this.port.setToolbar(i),this.port.showToolbar(o),this.subs.push(this.port.onDrawingIntent(s=>this.onIntent(s))),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){jt(e)&&t!==this.favs.has(e)&&(t?this.favs.add(e):this.favs.delete(e),this.pushFavorites());}setFavorites(e){let t=e.filter(n=>jt(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(ui(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=qt(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(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){let t=this.port?.stackRange?.(e);return t?(t.price??t.front)-.5:void 0}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=>dt(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.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}restoreSnapshot(e){this.store.load(e),this.selectedIds=this.selectedIds.filter(t=>this.store.has(t)),this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}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=ct({...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=ct({...e.doc,id:this.store.nextId(),style:i});if(!o)return;o.zIndex||(o.zIndex=this.startZ(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 "copy":this.copy(e.ids);break;case "paste":this.paste();break}}};var zh={D:864e5,W:6048e5,M:2592e6};function hi(r){let e=r.trim();if(zh[e])return zh[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 Lt=r=>r.trim().toLowerCase(),Mn=r=>r.trim().toUpperCase();function Mt(r){let e=r.trim(),t=/^(?:([A-Za-z0-9_.]+):)?(.+)$/.exec(e);if(!t)return {provider:null,ticker:e};let n=t[1]?Lt(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 Xs=class{constructor(){this.entries=new Map;this.changeListeners=new Set;this.waits=new Set;this.unresolvedCbs=new Set;}register(e,t){let n=Lt(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=>Mn(n.ticker))),e.byTicker=new Map(t.map(n=>[Mn(n.ticker),n])),e.prefixIndex=new Map;for(let n of t)n.prefix&&e.prefixIndex.set(`${Lt(n.prefix)}:${Mn(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(Lt(e)),this.notify(false);}has(e){return this.entries.has(Lt(e))}get(e){return this.entries.get(Lt(e))?.provider}names(){return [...this.entries.keys()]}parse(e){return Mt(e)}resolve(e,t={}){let{provider:n,ticker:i}=this.parse(e);if(n){if(this.entries.has(n))return {provider:n,ticker:i};let s=`${n}:${Mn(i)}`;for(let a of this.candidateOrder(t.default)){let l=this.entries.get(a).prefixIndex?.get(s);if(l)return {provider:a,ticker:l.ticker}}return null}let o=Mn(i);for(let s of this.candidateOrder(t.default))if(this.entries.get(s).index?.has(o))return {provider:s,ticker: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}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=Lt(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(Mn(e.ticker))?.prefix??e.provider}canonicalSymbol(e){let t=this.entries.get(e.provider)?.byTicker?.get(Mn(e.ticker));return `${t?.prefix??e.provider}:${t?.ticker??e.ticker}`}symbolsOf(e){return e!=null?this.entries.get(Lt(e))?.descriptors??[]:[...this.entries.entries()].flatMap(([t,n])=>n.descriptors.map(i=>({...i,provider:t})))}infoOf(e){let t=Lt(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 cr(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 pi(r){if(r.kind==="heading"||r.kind==="header")return [];let e=cr(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 kn(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 mi=new Map;function mc(r){mi.set(r.id,r);}function d0(r){mi.delete(r);}function kt(r){return typeof r=="string"?mi.get(r):void 0}function Je(){return [...mi.values()]}function fc(){return [...mi.values()].filter(r=>r.tickerModifier??r.barTransform!=null).map(r=>r.id)}function js(r){return kt(r)?.barTransform??null}function $h(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"&&!fc().includes(t)?{symbol:r,modifier:null,transform:null}:{symbol:r.slice(0,e),modifier:t,transform:js(t)}}var ut={background:"#151619",textColor:"#b2b5be",gridColor:"#20222c",borderColor:"#2a2b30",upColor:J,downColor:X,fontFamily:"sans-serif"},fi={background:"#ffffff",textColor:"#1e293b",gridColor:"#cccccc",borderColor:"#d4dae3",upColor:J,downColor:X,fontFamily:"sans-serif"};function dr(r){return !r||r==="dark"?ut:r==="light"?fi:r}var u0=150,h0=1e3,p0=300,m0=5e3,Wh=1e4,f0=1.5,Gh=5e3,qs=class r{constructor(e,t,n,i,o,s){this.renderer=t;this.feed=n;this.config=o;this.dataControl=s;this.events=new un;this.registry=new Ro;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.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 l of i)this.registerEngine(l.language,l);this.defaultLanguage=o.defaultLanguage,this.renderer.mount(e,o.theme),this.renderer.onInputChange(l=>this.applyInputs(l.indicatorId,{[l.key]:l.value})),this.renderer.onRemoveIndicator(l=>this.removeIndicator(l)),this.renderer.onToggleIndicatorVisible?.((l,c)=>this.setVisible(l,c)),this.paneActionUnsub=this.renderer.onPaneAction?.(l=>this.handlePaneAction(l))??null,this.renderer.onChartTypeSettingsChange?.((l,c)=>{this.typeSettings.set(l,c),this.typeEngines.get(l)?.onSettings?.(c);}),this.renderer.onMoveIndicator?.((l,c)=>this.moveIndicator(l,c)),this.renderer.onThemeSelect?.(l=>this.setTheme(dr(l))),this.viewportUnsub=this.renderer.onViewportChange(l=>this.onViewportChange(l)),this.renderer.onPriceStyleChange?.(l=>this.syncPriceStyle(l));let a=this.renderer.readFeature("priceStyle");typeof a=="string"&&(this.priceStyle=a),this.barTransform=js(a),this.drawings=new Ks(this.renderer,this.events,o.drawings),this.unresolvedUnsub=this.feed.onUnresolved?.(l=>{this.endLoad(),this.events.emit("data:unresolved",l);})??null,this.readyPromise=this.init(),kt(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=$h(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});}},u0);}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;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>m0;if(s&&this.feed.loadRange){let a=await this.feed.load({...n,bars:Math.min(i,Wh)});if(this.generation!==e)return;this.setBarSeries(a),t.firstLoad&&this.activateBarLayers(),a.length>0&&i>a.length?(this.historyState="backfill",this.backfillHistory(e,i)):this.completeHistory("depth");}else if(s){let a=await this.feed.load({...n,bars:p0});if(this.generation!==e)return;this.setBarSeries(a),t.firstLoad&&this.activateBarLayers();let l=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(l,{preserveView:true}),this.completeHistory("depth");}else {let a=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(a),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 Oo(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<=Gh||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:Mt(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(u=>u.time>=l.left&&u.time<=l.right).length:0,d=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 u=Math.min(Math.ceil((Date.now()-l.left)/this.barIntervalMs())+50,5e3);u>(t.bars??500)&&(t.bars=u);}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(d,t.bars??500):await Promise.race([this.loadMarket(d,{firstLoad:!1}),new Promise(u=>this.supersedeWaiters.push(u))]),this.generation!==d)return}finally{this.generation===d&&(this.switchingMarket=false);}if(l&&c>=2&&this.rawBars.length>0){let u=this.rawBars,h=u.length-1;for(;h>0&&u[h].time>l.right;)h-=1;let p=u[Math.max(0,h-(c-1))].time;this.renderer.setVisibleRange({from:p,to:Math.max(l.right,u[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.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=Wh,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||Jr("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=kt(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=kt(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=js(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()*f0&&Date.now()-this.lastHealAt>Gh){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 hi(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 er(n,i,this,e);return this.handles.set(n,o),this.registry.add({id:n,title:i,source:e,options:t,inputValues:{...t.inputs??{}}}),this.startIndicator(n,e,t,o),o}addNativeIndicator(e,t={}){let n=this.registry.all().find(c=>c.native?.type===e);if(n)return this.handles.get(n.id)??new er(n.id,n.title,this);let i=Jr(e),o=this.registry.nextId("native"),s=i?.title??e,a=new er(o,s,this);if(this.handles.set(o,a),!i)return console.warn(`[vela] addNativeIndicator("${e}") \u2014 no native indicator registered for this type.`),a;let l={...i.defaultInputs(),...t.inputs??{}};return this.registry.add({id:o,title:s,source:e,inputValues:l,native:{type:e,instance:i.create(),descriptor:i}}),a.setSchema(i.inputsSchema()),this.startNativeIndicator(o,a),a}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(Do().map(async n=>({type:n.type,title:n.title,supported:await this.isNativeSupported(n,e),present:t.has(n.type),beta:n.beta})))}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));}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);else if(n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,true),n.pendingStructural=true,n.native)if(n.native.stale){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 eh(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=th(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.renderer.destroy(),this.events.clear();}async startIndicator(e,t,n,i){try{if(await this.readyPromise,!this.registry.get(e))return;await g0();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 c of a.inputs)l[c.key]=c.defval;o.inputValues={...l,...o.inputValues},i.setSchema(a.inputs),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,visibleRange:this.currentVisibleRange(),mode:i,historyState:this.historyState},{onModel:o=>{let s=!n.announced,a=n.pendingCause??"history";n.pendingCause=void 0,this.applyModel(e,o),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);}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},...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.hidden||!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},o=this.routePane(e,i,t.options??{});this.placeModel(i,e,o),t.model=i,this.ensurePaneFor(o),t.renderHandle=this.renderer.mountIndicator(i),t.pendingStructural=true,this.setLoading(t,true);}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)continue;let o=i.paneId??"price";e.has(o)||e.set(o,[]),e.get(o).push({id:n.id,title:i.title||n.title,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;let i=this.handles.get(e);if(!n.renderHandle){let a=this.routePane(e,t,n.options??{});this.placeModel(t,e,a),n.model=t,this.ensurePaneFor(a),n.renderHandle=this.renderer.mountIndicator(t),n.pendingStructural=false,this.announce(n,i);return}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);}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.pendingStructural=false):this.renderer.updateIndicator(n.renderHandle,b0(t)),n.loading&&this.setLoading(n,false),this.announce(n,i);}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)be(n)&&(t[n.title]=n.points[n.points.length-1]?.value??null);return t}placeModel(e,t,n){e.id=t,e.paneId=n;for(let i of e.series)i.paneId=n;for(let i of e.fills)i.paneId=n;for(let i of e.backgrounds)i.paneId=n;for(let i of e.priceLines)i.paneId=n;if(e.lines)for(let i of e.lines)i.paneId=n;if(e.boxes)for(let i of e.boxes)i.paneId=n;if(e.labels)for(let i of e.labels)i.paneId=n;if(e.polylines)for(let i of e.polylines)i.paneId=n;if(e.linefills)for(let i of e.linefills)i.paneId=n;if(e.tables)for(let i of e.tables)i.paneId=n;}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)<h0||(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 g0(){return typeof requestAnimationFrame=="function"?new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(()=>r()))):new Promise(r=>setTimeout(r,0))}function b0(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(be(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 gi=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);}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)}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}};var ur=new Map;function v0(r){let e=Object.entries(r);for(let[t,n]of e)ur.set(t,n);return ()=>{for(let[t,n]of e)ur.get(t)===n&&ur.delete(t);}}function y0(...r){if(r.length===0)ur.clear();else for(let e of r)ur.delete(e);}function gc(){return Object.fromEntries(ur)}var Zs=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 Uh(r,e,t,n){return `${r}|${e}|${t}${n&&n!=="regular"?`|${n}`:""}`}function w0(r){return r.split("|")[1]??""}var Js=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=w0(t);n!==e&&!this.retained.has(n)&&(this.series.delete(t),this.coveredFrom.delete(t));}}clear(){this.series.clear(),this.coveredFrom.clear();}},bi=new Js;function Yh(r,e,t){let{provider:n,ticker:i}=Mt(r);return Uh(n??"",i,e,t)}var vi=1e4,x0=vi+1,yi=class{constructor(e,t=bi){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=Yh(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,Qs(l));return Kh(c,l[l.length-1]).slice(-o)}let a=await this.inner.load(e);return this.store.merge(n,Qs(a)),a}async loadRange(e,t){if(!this.inner.loadRange)return this.inner.load(e);let n=Yh(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 d=i.filter(f=>f.time<=t.to),u=this.store.coveredFromOf(n)??1/0;if(t.limit!=null?d.length>=t.limit&&(t.from==null||u<=t.from):t.from!=null&&u<=t.from){let f=t.from!=null?d.filter(g=>g.time>=t.from):d;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 d=this.store.coveredFromOf(n);if(d!=null&&d>t.from){let{bars:u,coveredDownTo:h}=await this.fetchRange(e,{from:t.from,to:d});this.store.merge(n,u.filter(p=>p.time<=d)),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:d}=await this.fetchRange(e,{from:o.time,to:t.to,limit:t.limit}),u=this.store.merge(n,Qs(d)),h=Kh(u,d[d.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,Qs(l)),this.store.markCovered(n,c??t.from??l[0]?.time??0),l}async fetchRange(e,t){let n=hi(e.timeframe??"60"),i=S0(t,n);if(i<=x0){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:vi;if(c<=0)break;let d=await this.inner.loadRange(e,{to:s,limit:Math.min(vi,c)}),u=1/0;for(let h of d)h.time<u&&(u=h.time),h.time<=s&&(t.from==null||h.time>=t.from)&&o.set(h.time,h);if(d.length===0){if(t.from==null)break;s-=vi*n;continue}if(u-1>=s)break;s=u-1;}let a=[...o.values()].sort((c,d)=>c.time-d.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 S0(r,e){if(r.limit!=null)return r.limit;if(r.from==null)return vi;let t=Math.max(0,(r.to??Date.now())-r.from);return Math.ceil(t/e*1.1)+2}function Qs(r){return r.length>0?r.slice(0,-1):r}function Kh(r,e){if(!e)return r;let t=r[r.length-1];return !t||e.time>t.time?[...r,e]:r}function C0(r){return {"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,1:6e4,5:3e5,15:9e5,30:18e5,60:36e5,240:144e5,D:864e5,W:6048e5}[r]??36e5}var In=class{constructor(e=bi){this.registry=new Xs;this.primaryProvider=null;this.liveBars=[];this.symInfoCache=new Map;this.cache=new yi(new yc(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)}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(vc(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(ea(e),{default:this.primaryProvider});return this.primaryProvider=t.provider,this.prefetchSymbolInfo(t),this.cache.load(bc(e,t))}symbolInfo(e){if(e.data&&e.data.length>0)return;let t=this.registry.resolve(ea(e),{default:this.primaryProvider});return t?this.symInfoCache.get(vc(t)):void 0}prefetchSymbolInfo(e){let t=vc(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(ea(e),{default:this.primaryProvider});return n?this.cache.loadRange(bc(e,n),t):[]}subscribe(e,t){if(e.data&&e.data.length>0)return this.synthesizeTicks(e,t);let n=this.registry.resolve(ea(e),{default:this.primaryProvider});return n?this.cache.subscribe(bc(e,n),t):()=>{}}synthesizeTicks(e,t){if(this.liveBars.length===0)return ()=>{};let n=C0(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 d={time:c.time+n,open:c.close,high:c.close,low:c.close,close:c.close,volume:0};o.push(d),t(d);}},1e3);return ()=>clearInterval(i)}};function ea(r){return r.symbol??""}function bc(r,e){return {...r,symbol:`${e.provider}:${e.ticker}`}}function vc(r){return `${r.provider}|${r.ticker}`}async function Xh(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 yc=class{constructor(e){this.registry=e;}load(e){let{provider:t,ticker:n}=Mt(e.symbol??""),i=this.registry.get(t??"");return i?Xh(i,n,e.timeframe??"60",{limit:e.bars??500,session:e.session}):Promise.resolve([])}loadRange(e,t){let{provider:n,ticker:i}=Mt(e.symbol??""),o=this.registry.get(n??"");return o?Xh(o,i,e.timeframe??"60",{...t,session:e.session}):Promise.resolve([])}subscribe(e,t){let{provider:n,ticker:i}=Mt(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 d=await o.getBars(i,s,{limit:2,session:e.session});if(a)return;for(let u of d)t(u);}catch{}a||(l=setTimeout(()=>{c();},3e3));}};return l=setTimeout(()=>{c();},3e3),()=>{a=true,l&&clearTimeout(l);}}};var wi=class{constructor(e){this.registry=e instanceof In?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)??[]}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 xi=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)}};function ta(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 W(r,e){let t=ta(r);return t?`rgba(${t.r},${t.g},${t.b},${e})`:r}function jh(r,e,t){let n=ta(r),i=ta(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 _e(r){let e=ta(r);return e?.2126*e.r+.7152*e.g+.0722*e.b<128:true}var na={"--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 ra(r){let e=_e(r.background),t=i=>e?`rgba(255,255,255,${i})`:W(r.textColor,i+.02),n=jh(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":W(r.textColor,.62),"--vela-fg-faint":W(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":W(r.textColor,.28),"--vela-border-soft":r.borderColor,"--vela-border-faint":W(r.textColor,.08),"--vela-hover":t(.06),"--vela-active":t(.1),"--vela-hover-strong":t(.16),"--vela-focus":W(r.textColor,.5),"--vela-focus-soft":W(r.textColor,.12),"--vela-separator-hover-band":W(r.textColor,.1),"--vela-separator-hover-line":W(r.textColor,.55),"--vela-scroll":W(r.textColor,.3),"--vela-accent":Te,"--vela-accent-bright":tr,"--vela-highlight":rh,"--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 ve(r,e){let t=n=>{for(let i in n)r.style.setProperty(i,n[i]);};t(na),t(ra(e));}function ht(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;"),ve(n,e.theme()),e.host.appendChild(n);let c=r.getBoundingClientRect(),d=e.host.getBoundingClientRect();if(e.placement==="right")n.style.left=`${c.right-d.left+8}px`,n.style.top=`${c.top-d.top+(c.height-n.offsetHeight)/2}px`;else {let u=Math.min(c.left-d.left,Math.max(0,d.width-n.offsetWidth-4));n.style.left=`${Math.max(0,u)}px`,n.style.top=e.placement==="above"?`${Math.max(0,c.top-d.top-n.offsetHeight-6)}px`:`${c.bottom-d.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();}}var T0=Object.defineProperty,E0=(r,e,t)=>e in r?T0(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Z=(r,e,t)=>E0(r,typeof e!="symbol"?e+"":e,t);function qh(r){return r==null?[]:Array.isArray(r)?r:[r]}var Zh=r=>r[0],Jh=r=>r[r.length-1];function Qh(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 ep(r,e,t={}){return r[Qh(r,e,t)]}function P0(r,e,t={}){let{step:n=1,loop:i=true}=t;return Qh(r,e,{step:-n,loop:i})}function tp(r,e,t={}){return r[P0(r,e,t)]}var np=r=>r?.constructor.name==="Array",L0=(r,e)=>{if(r.length!==e.length)return false;for(let t=0;t<r.length;t++)if(!hr(r[t],e[t]))return false;return true},hr=(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(np(r)&&np(e))return L0(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(!hr(r[o],e[o]))return false}return true};var M0=r=>r!=null&&typeof r=="object";var pr=r=>typeof r=="string",De=r=>typeof r=="function",rp=r=>r==null,Si=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),k0=r=>Object.prototype.toString.call(r),ip=Function.prototype.toString,I0=ip.call(Object),An=r=>{if(!M0(r)||k0(r)!="[object Object]"||D0(r))return false;let e=Object.getPrototypeOf(r);if(e===null)return true;let t=Si(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&ip.call(t)==I0},A0=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,R0=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,D0=r=>A0(r)||R0(r);var Ci=(r,...e)=>(typeof r=="function"?r(...e):r)??void 0,wc=r=>r,op=r=>r(),xc=()=>{},Zt=(...r)=>(...e)=>{r.forEach(function(t){t?.(...e);});};function Jt(r){if(!An(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]=Jt(i));}return t}function mr(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Sc(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Ti(r,e){if(r==null)throw new Error(e())}var O0=(...r)=>r.map(e=>e?.trim?.()).filter(Boolean).join(" "),F0=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,sp=r=>{let e={},t;for(;t=F0.exec(r);)e[t[1]]=t[2];return e},N0=(r,e)=>{if(pr(r)){if(pr(e))return `${r};${e}`;r=sp(r);}else pr(e)&&(e=sp(e));return Object.assign({},r??{},e??{})};function ap(...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]=Zt(t[i],e[i]);continue}if(i==="className"||i==="class"){e[i]=O0(e[i],t[i]);continue}if(i==="style"){e[i]=N0(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 Qt=".",dp="#",lp=new WeakMap,up=new WeakMap;function Cc(r){return r.join(Qt)}function V0(r){return r.includes(Qt)}function hp(r){return r.startsWith(dp)}function _0(r){return r.startsWith(Qt)}function B0(r){return hp(r)?r.slice(dp.length):r}function Tc(r,e){return r?`${r}${Qt}${e}`:e}function H0(r){let e=new Map,t=new Map,n=(i,o)=>{e.set(i,o);let s=o.id;s&&(t.has(s)&&Sc(`[zag-js] Duplicate state id: "${s}"`),t.set(s,i));let a=o.states;if(a){Ti(o.initial,()=>`[zag-js] Compound state "${i}" has child states but no "initial" property`),o.initial in a||Sc(`[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 d=Tc(i,l);n(d,c);}}};for(let[i,o]of Object.entries(r.states))o&&n(i,o);return {index:e,idIndex:t}}function fr(r){let e=lp.get(r);if(e)return e;let{index:t,idIndex:n}=H0(r);return lp.set(r,t),up.set(r,n),t}function z0(r,e){return fr(r),up.get(r)?.get(e)}function Ec(r){return r?String(r).split(Qt).filter(Boolean):[]}function ia(r,e){if(!e)return [];let t=fr(r),n=Ec(e),i=[],o=[];for(let s of n){o.push(s);let a=Cc(o),l=t.get(a);if(!l)break;i.push({path:a,state:l});}return i}function Ei(r,e){let t=fr(r),n=Ec(e);if(!n.length)return e;let i=[];for(let a of n){i.push(a);let l=Cc(i);if(!t.has(l))return e}let o=Cc(i),s=t.get(o);for(;s?.initial;){let a=`${o}${Qt}${s.initial}`,l=t.get(a);if(!l)break;o=a,s=l;}return o}function cp(r,e){return fr(r).has(e)}function Pc(r,e,t){let n=String(e);if(hp(n)){let i=B0(n),o=z0(r,i);return Ti(o,()=>`[zag-js] Unknown state id: "${i}"`),Ei(r,o)}if(_0(n)&&t){let i=Tc(t,n.slice(1));return Ei(r,i)}if(!V0(n)&&t){let i=Ec(t);for(let o=i.length-1;o>=1;o--){let s=i.slice(0,o).join(Qt),a=Tc(s,n);if(cp(r,a))return Ei(r,a)}if(cp(r,n))return Ei(r,n)}return Ei(r,n)}function pp(r,e,t){let n=ia(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 mp(r,e,t,n){let i=e?ia(r,e):[],o=ia(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 fp(r,e){return r?r===e||r.startsWith(`${e}${Qt}`):false}function gp(r,e,t){return ia(r,e).some(n=>n.state.tags?.includes(t))}function bp(){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 oa(r){return fr(r),r}var gr=(r=>(r.NotStarted="Not Started",r.Started="Started",r.Stopped="Stopped",r))(gr||{}),Pi="__init__";var $0=Object.defineProperty,W0=(r,e,t)=>e in r?$0(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,sa=(r,e,t)=>W0(r,typeof e!="symbol"?e+"":e,t);var vp=(r,e)=>r.map((t,n)=>r[(Math.max(e,0)+n)%r.length]);var Li=()=>{},Mi=r=>typeof r=="object"&&r!==null;var We=r=>r?"":void 0,Lc=r=>r?"true":void 0;var G0=1,U0=9,Y0=11;var Q=r=>Mi(r)&&r.nodeType===G0&&typeof r.nodeName=="string",ki=r=>Mi(r)&&r.nodeType===U0,K0=r=>Mi(r)&&r===r.window;var yp=r=>Q(r)?r.localName||"":"#document";function wp(r){return ["html","body","#document"].includes(yp(r))}var xp=r=>Mi(r)&&r.nodeType!==void 0,Rn=r=>xp(r)&&r.nodeType===Y0&&"host"in r,Mc=r=>Q(r)&&r.localName==="input",Sp=r=>!!r?.matches("a[href]"),Cp=r=>Q(r)?r.offsetWidth>0||r.offsetHeight>0||r.getClientRects().length>0:false;function Ii(r){if(!r)return false;let e=r.getRootNode();return pt(e)===r}var X0=/(textarea|select)/;function br(r){if(r==null||!Q(r))return false;try{return Mc(r)&&r.selectionStart!=null||X0.test(r.localName)||r.isContentEditable||r.getAttribute("contenteditable")==="true"||r.getAttribute("contenteditable")===""}catch{return false}}function Oe(r,e){if(!r||!e||!Q(r)||!xp(e))return false;if(Q(e)&&r===e||r.contains(e))return true;let t=e.getRootNode?.();if(t&&Rn(t)){let n=e;for(;n;){if(r===n)return true;n=n.parentNode||n.host;}}return false}function ce(r){return ki(r)?r:K0(r)?r.document:r?.ownerDocument??document}function j0(r){return ce(r).documentElement}function ae(r){return Rn(r)?ae(r.host):ki(r)?r.defaultView??window:Q(r)?r.ownerDocument?.defaultView??window:window}function pt(r){let e=r.activeElement;for(;e?.shadowRoot;){let t=e.shadowRoot.activeElement;if(!t||t===e)break;e=t;}return e}function Tp(r){if(yp(r)==="html")return r;let e=r.assignedSlot||r.parentNode||Rn(r)&&r.host||j0(r);return Rn(e)?e.host:e}function aa(r){let e;try{if(e=r.getRootNode({composed:!0}),ki(e)||Rn(e))return e}catch{}return r.ownerDocument??document}var kc=new WeakMap;function vr(r){return kc.has(r)||kc.set(r,ae(r).getComputedStyle(r)),kc.get(r)}var Ic=new Set(["menu","listbox","dialog","grid","tree","region","application"]),q0=r=>Ic.has(r),Ep=r=>r.getAttribute("aria-controls")?.split(" ")||[];function la(r,e){let t=new Set,n=aa(r),i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=Ep(a);for(let c of l){if(!c||t.has(c))continue;t.add(c);let d=n.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";if(u&&q0(u)&&!h&&(d===e||d.contains(e)||i(d)))return true}}}return false};return i(r)}function Ac(r,e){let t=aa(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=Ep(a);for(let c of l){if(!c||n.has(c))continue;n.add(c);let d=t.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";u&&Ic.has(u)&&!h&&(e(d),i(d));}}}};i(r);}function Pp(r){let e=new Set;return Ac(r,t=>{r.contains(t)||e.add(t);}),Array.from(e)}function Z0(r){let e=r.getAttribute("role");return !!(e&&Ic.has(e))}function J0(r){return r.hasAttribute("aria-controls")&&r.getAttribute("aria-expanded")==="true"}function Lp(r){return J0(r)?true:!!r.querySelector?.('[aria-controls][aria-expanded="true"]')}function Mp(r){if(!r.id)return false;let e=aa(r),t=CSS.escape(r.id),n=`[aria-controls~="${t}"][aria-expanded="true"], [aria-controls="${t}"][aria-expanded="true"]`;return !!(e.querySelector(n)&&Z0(r))}var Rc=()=>typeof document<"u";function Q0(){return navigator.userAgentData?.platform??navigator.platform}function eS(){let r=navigator.userAgentData;return r&&Array.isArray(r.brands)?r.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" "):navigator.userAgent}var Dc=r=>Rc()&&r.test(Q0()),kp=r=>Rc()&&r.test(eS());var Oc=()=>Rc()&&!!navigator.maxTouchPoints,tS=()=>Dc(/^iPhone/i),nS=()=>Dc(/^iPad/i)||yr()&&navigator.maxTouchPoints>1,Ip=()=>tS()||nS();var yr=()=>Dc(/^Mac/i);var Ap=()=>kp(/Firefox/i);var Rp=()=>kp(/Android/i);function rS(r){return r.composedPath?.()??r.nativeEvent?.composedPath?.()}function fe(r){return rS(r)?.[0]??r.target}function Fc(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=iS(r);return n||i}function Nc(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 iS(r){return yr()?r.metaKey:r.ctrlKey}function Op(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function Fp(r){return r.pointerType===""&&r.isTrusted?true:Rp()&&r.pointerType?r.type==="click"&&r.buttons===1:r.detail===0&&!r.pointerType}var ca=r=>r.button===2||yr()&&r.ctrlKey&&r.button===0,Np=r=>r.ctrlKey||r.altKey||r.metaKey,oS=r=>"touches"in r&&r.touches.length>0,sS={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},Dp={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function Vc(r,e={}){let{dir:t="ltr",orientation:n="horizontal"}=e,i=r.key;return i=sS[i]??i,t==="rtl"&&n==="horizontal"&&i in Dp&&(i=Dp[i]),i}function wr(r,e="client"){let t=oS(r)?r.touches[0]||r.changedTouches[0]:r;return {x:t[`${e}X`],y:t[`${e}Y`]}}var Le=(r,e,t,n)=>{let i=typeof r=="function"?r():r;return i?.addEventListener(e,t,n),()=>{i?.removeEventListener(e,t,n);}};var Vp=r=>Q(r)&&r.tagName==="IFRAME",aS=/^(audio|video|details)$/;function _p(r){let e=r.getAttribute("tabindex");return e?parseInt(e,10):NaN}var lS=r=>!Number.isNaN(_p(r)),cS=r=>_p(r)<0;function dS(r){return Mc(r)&&r.type==="radio"}function uS(r){if(!dS(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&&Ge(o)),i=n.find(o=>o.checked);return i?i===r:n[0]===r}function hS(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 Bp(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=hS(l,e);if(c){let d=Array.from(c.querySelectorAll(da)).filter(t),u=s.get(l);if(u!==void 0){let h=u+1;n.splice(h,0,...d),d.forEach((p,m)=>{s.set(p,h+m);});for(let p=h+d.length;p<n.length;p++)s.set(n[p],p);}else {let h=n.length;n.push(...d),d.forEach((p,m)=>{s.set(p,h+m);});}i.push(...d);}}return n}var da="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",_c=(r,e={})=>{if(!r)return [];let{includeContainer:t=false,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(da));(t==true||t=="if-empty"&&i.length===0)&&Q(r)&&Ge(r)&&i.unshift(r);let s=[];for(let a of i)if(Ge(a)){if(Vp(a)&&a.contentDocument){let l=a.contentDocument.body;s.push(..._c(l,{getShadowRoot:n}));continue}s.push(a);}return n?Bp(s,n,Ge):s};function Ge(r){return !Q(r)||r.closest("[inert]")?false:r.matches(da)&&Cp(r)}function xr(r,e={}){if(!r)return [];let{includeContainer:t,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(da));t&&en(r)&&i.unshift(r);let o=[];for(let s of i)if(en(s)){if(Vp(s)&&s.contentDocument){let a=s.contentDocument.body;o.push(...xr(a,{getShadowRoot:n}));continue}o.push(s);}if(n){let s=Bp(o,n,en);return !s.length&&t?i:s}return !o.length&&t?i:o}function en(r){return Q(r)&&r.tabIndex>0?true:!Ge(r)||cS(r)?false:uS(r)}function Hp(r,e={}){let t=xr(r,e),n=t[0]||null,i=t[t.length-1]||null;return [n,i]}function Sr(r){return r.tabIndex<0&&(aS.test(r.localName)||br(r))&&!lS(r)?0:r.tabIndex}function ua(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=xr(e);o=n?s.filter(n)[0]:s[0];}return o||e||void 0}function zp(r){let e=r.currentTarget;if(!e)return false;let[t,n]=Hp(e);return !(Ii(t)&&r.shiftKey||Ii(n)&&!r.shiftKey||!t&&!n)}var pS=class $p{constructor(){sa(this,"id",null),sa(this,"fn_cleanup"),sa(this,"cleanup",()=>{this.cancel();});}static create(){return new $p}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 ue(r){let e=pS.create();return e.request(r),e.cleanup}function Wp(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 Gp(r,e,t){let n=ue(()=>{r.removeEventListener(e,i,true),t();}),i=()=>{n(),t();};return r.addEventListener(e,i,{once:true,capture:true}),n}function mS(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 Up(r,e){let n=ue,i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(mS(o,e));})),()=>{i.forEach(o=>o?.());}}function Yp(r){let e=()=>{let t=ae(r);r.dispatchEvent(new t.MouseEvent("click"));};Ap()?Gp(r,"keyup",e):queueMicrotask(e);}function ha(r){let e=Tp(r);return wp(e)?ce(e).body:Q(e)&&Bc(e)?e:ha(e)}var fS=/auto|scroll|overlay|hidden|clip/,gS=new Set(["inline","contents"]);function Bc(r){let e=ae(r),{overflow:t,overflowX:n,overflowY:i,display:o}=e.getComputedStyle(r);return fS.test(t+i+n)&&!gS.has(o)}function Cr(r,e){return Array.from(r?.querySelectorAll(e)??[])}var pa=r=>r.id;function bS(r,e,t=pa){return r.find(n=>t(n)===e)}function Kp(r,e,t=pa){let n=bS(r,e,t);return n?r.indexOf(n):-1}function vS(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth}function Xp(r,e){let{rootEl:t,...n}=e||{};!r||!t||!Bc(t)||!vS(t)||r.scrollIntoView(n);}var yS=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(),wS=r=>yS(r.dataset?.valuetext??r.textContent??""),xS=(r,e)=>r.trim().toLowerCase().startsWith(e.toLowerCase());function jp(r,e,t,n=pa){let i=t?Kp(r,t,n):-1,o=t?vp(r,i):r;return e.length===1&&(o=o.filter(a=>n(a)!==t)),o.find(a=>xS(wS(a),e))}function Ai(r,e){if(!r)return Li;let t=Object.keys(e).reduce((n,i)=>(n[i]=r.style.getPropertyValue(i),n),{});return SS(t,e)?Li:(Object.assign(r.style,e),()=>{Object.assign(r.style,t),r.style.length===0&&r.removeAttribute("style");})}function qp(r,e,t){if(!r)return Li;let n=r.style.getPropertyValue(e);return n===t?Li:(r.style.setProperty(e,t),()=>{r.style.setProperty(e,n),r.style.length===0&&r.removeAttribute("style");})}function SS(r,e){return Object.keys(r).every(t=>r[t]===e[t])}function CS(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,d=r.slice(),u=jp(d,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),u}var ma=Object.assign(CS,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:TS});function TS(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function ES(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 Zp(r,e){let{timeout:t,rootNode:n}=e,i=ae(n),o=ce(n),s=new i.AbortController;return ES(new Promise(a=>{let l=r();if(l){a(l);return}let c=new i.MutationObserver(()=>{let d=r();d&&d.isConnected&&(c.disconnect(),a(d));});c.observe(o.body,{childList:true,subtree:true});}),s,t)}function Jp(r){let e=()=>r.getRootNode?.()??document,t=()=>ce(e());return {...r,getRootNode:e,getDoc:t,getWin:()=>t().defaultView??window,getActiveElement:()=>pt(e()),isActiveElement:Ii,getById:s=>e().getElementById(s)}}function Qp(r){return new Proxy({},{get(e,t){return t==="style"?n=>r({style:n}).style:r}})}var em={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},PS=new Set(["viewBox","preserveAspectRatio"]),LS=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},Tr=Qp(r=>Object.entries(r).reduce((e,[t,n])=>{if(n===void 0)return e;if(t in em&&(t=em[t]),t==="style"&&typeof n=="object")return e.style=LS(n),e;let i=PS.has(t)?t:t.toLowerCase();return e[i]=n,e},{}));var fa=new WeakMap,tm=new Set(["value","checked","selected"]),MS=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),kS=r=>r.tagName==="svg"||r.namespaceURI==="http://www.w3.org/2000/svg",ga=(r,e)=>kS(r)&&MS.has(e)?e:e.toLowerCase();function Fe(r,e,t){let n=t||"default",i=fa.get(r);i||(i=new Map,fa.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"),d=f=>!f.startsWith("on"),u=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(tm.has(f)){r[f]=g??"";return}if(typeof g=="boolean"&&!f.includes("aria-")){r.toggleAttribute(ga(r,f),g);return}if(f==="children"){r.innerHTML=g;return}if(g!=null){r.setAttribute(ga(r,f),g);return}r.removeAttribute(ga(r,f));}};for(let f in o)e[f]==null&&(f==="class"?r.className="":tm.has(f)?r[f]="":r.removeAttribute(ga(r,f)));return Object.keys(o).filter(c).forEach(f=>{l(f.substring(2),o[f]);}),s.filter(c).forEach(u),s.filter(d).forEach(p),i.set(n,e),function(){s.filter(c).forEach(h);let g=fa.get(r);g&&(g.delete(n),g.size===0&&fa.delete(r));}}function IS(){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 Hc(r,e){let t=IS();return t?(t[r]||(t[r]=e()),t[r]):e()}var Er=Hc("__zag__refSet",()=>new WeakSet);var AS=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,RS=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,DS=r=>typeof r=="object"&&r!==null&&"nodeType"in r&&typeof r.nodeName=="string",OS=r=>AS(r)||RS(r)||DS(r),ba=r=>r!==null&&typeof r=="object",zc=r=>ba(r)&&!Er.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!OS(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 FS=Symbol();var nm=Object.getPrototypeOf,$c=new WeakMap,NS=r=>r&&($c.has(r)?$c.get(r):nm(r)===Object.prototype||nm(r)===Array.prototype);var rm=r=>NS(r)&&r[FS]||null,Wc=(r,e=true)=>{$c.set(r,e);};var Dn=Hc("__zag__proxyStateMap",()=>new WeakMap),VS=(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 d=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return Wc(d,true),t.set(a,[l,d]),Reflect.ownKeys(a).forEach(u=>{let h=Reflect.get(a,u);Er.has(h)?(Wc(h,false),d[u]=h):Dn.has(h)?d[u]=im(h):d[u]=h;}),Object.freeze(d)},i=new WeakMap,o=[1,1],s=a=>{if(!ba(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=o[0],d=new Set,u=(S,E=++o[0])=>{c!==E&&(c=E,d.forEach(L=>L(S,E)));},h=o[1],p=(S=++o[1])=>(h!==S&&!d.size&&(h=S,f.forEach(([E])=>{let L=E[1](S);L>c&&(c=L);})),c),m=S=>(E,L)=>{let T=[...E];T[1]=[S,...T[1]],u(T,L);},f=new Map,g=(S,E)=>{if(d.size){let L=E[3](m(S));f.set(S,[E,L]);}else f.set(S,[E]);},b=S=>{let E=f.get(S);E&&(f.delete(S),E[1]?.());},v=S=>(d.add(S),d.size===1&&f.forEach(([L,T],k)=>{let M=L[3](m(k));f.set(k,[L,M]);}),()=>{d.delete(S),d.size===0&&f.forEach(([L,T],k)=>{T&&(T(),f.set(k,[L]));});}),y=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),P=e(y,{deleteProperty(S,E){let L=Reflect.get(S,E);b(E);let T=Reflect.deleteProperty(S,E);return T&&u(["delete",[E],L]),T},set(S,E,L,T){let k=Reflect.has(S,E),M=Reflect.get(S,E,T);if(k&&(r(M,L)||i.has(L)&&r(M,i.get(L))))return true;b(E),ba(L)&&(L=rm(L)||L);let C=L;if(!Object.getOwnPropertyDescriptor(S,E)?.set){!Dn.has(L)&&zc(L)&&(C=va(L));let I=!Er.has(C)&&Dn.get(C);I&&g(E,I);}return Reflect.set(S,E,C,T),u(["set",[E],L,M]),true}});i.set(a,P);let x=[y,p,n,v];return Dn.set(P,x),Reflect.ownKeys(a).forEach(S=>{let E=Object.getOwnPropertyDescriptor(a,S);E.get||E.set?Object.defineProperty(y,S,E):P[S]=a[S];}),P})=>[s,Dn,Er,r,e,zc,t,n,i,o],[_S]=VS();function va(r={}){return _S(r)}function ya(r,e,t){let n=Dn.get(r);let i,o=[],s=n[3],a=false,c=s(d=>{if(o.push(d),t);i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(o.splice(0));}));});return a=true,()=>{a=false,c();}}function im(r){let e=Dn.get(r);let[t,n,i]=e;return i(t,n())}function Di(r){let e=r().value??r().defaultValue;r().debug&&console.log(`[bindable > ${r().debug}] initial`,e);let t=r().isEqual??Object.is,n=va({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=De(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)}}}Di.cleanup=r=>{};Di.ref=r=>{let e=r;return {get:()=>e,set:t=>{e=t;}}};function om(r){let e={current:r};return {get(t){return e.current[t]},set(t,n){e.current[t]=n;}}}function Gc(r,e){if(!An(r)||!An(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&&(An(o)&&An(i)?t[n]=Gc(o,i):t[n]=i);}return t}var Uc=class{constructor(r,e={}){Z(this,"machine",r),Z(this,"scope"),Z(this,"context"),Z(this,"prop"),Z(this,"state"),Z(this,"refs"),Z(this,"computed"),Z(this,"event",{type:""}),Z(this,"previousEvent",{type:""}),Z(this,"effects",new Map),Z(this,"transition",null),Z(this,"cleanups",[]),Z(this,"subscriptions",[]),Z(this,"userPropsRef"),Z(this,"getEvent",()=>({...this.event,current:()=>this.event,previous:()=>this.previousEvent})),Z(this,"getState",()=>({...this.state,matches:(...u)=>u.some(h=>fp(this.state.get(),h)),hasTag:u=>gp(this.machine,this.state.get(),u)})),Z(this,"debug",(...u)=>{this.machine.debug&&console.log(...u);}),Z(this,"notify",()=>{this.publish();}),Z(this,"send",u=>{this.status===gr.Started&&queueMicrotask(()=>{if(!u)return;this.previousEvent=this.event,this.event=u,this.debug("send",u);let h=this.state.get(),p=u.type,{transitions:m,source:f}=pp(this.machine,h,p),g=this.choose(m);if(!g)return;this.transition=g;let b=Pc(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);});}),Z(this,"action",u=>{let h=De(u)?u(this.getParams()):u;if(!h)return;let p=h.map(m=>{let f=this.machine.implementations?.actions?.[m];return f||mr(`[zag-js] No implementation found for action "${JSON.stringify(m)}"`),f});for(let m of p)m?.(this.getParams());}),Z(this,"guard",u=>{if(De(u))return u(this.getParams());let h=this.machine.implementations?.guards?.[u];return h||mr(`[zag-js] No implementation found for guard "${JSON.stringify(u)}"`),h?.(this.getParams())}),Z(this,"effect",u=>{let h=De(u)?u(this.getParams()):u;if(!h)return;let p=h.map(f=>{let g=this.machine.implementations?.effects?.[f];return g||mr(`[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?.())}),Z(this,"choose",u=>qh(u).find(h=>{let p=!h.guard;return pr(h.guard)?p=!!this.guard(h.guard):De(h.guard)&&(p=h.guard(this.getParams())),p})),Z(this,"subscribe",u=>(this.subscriptions.push(u),()=>{let h=this.subscriptions.indexOf(u);h>-1&&this.subscriptions.splice(h,1);})),Z(this,"status",gr.NotStarted),Z(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(u=>u(this.service));}),Z(this,"trackers",[]),Z(this,"setupTrackers",()=>{this.machine.watch?.(this.getParams());}),Z(this,"callTrackers",()=>{this.trackers.forEach(({deps:u,fn:h})=>{let p=u.map(m=>m());hr(h.prev,p)||(h(),h.prev=p);});}),Z(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(u,h)=>{h.prev=u.map(p=>p()),this.trackers.push({deps:u,fn:h});},refs:this.refs,computed:this.computed,flush:op,scope:this.scope,choose:this.choose})),this.userPropsRef={current:e};let{id:t,ids:n,getRootNode:i}=Ci(e);this.scope=Jp({id:t,ids:n,getRootNode:i});let o=u=>{let h=Ci(this.userPropsRef.current);return (r.props?.({props:Jt(h),scope:this.scope})??h)[u]};this.prop=o;let s=r.context?.({prop:o,bindable:Di,scope:this.scope,flush(u){queueMicrotask(u);},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});s&&Object.values(s).forEach(u=>{let h=ya(u.ref,()=>this.notify());this.cleanups.push(h);});let a={get(u){return s?.[u].get()},set(u,h){s?.[u].set(h);},initial(u){return s?.[u].initial},hash(u){let h=s?.[u].get();return s?.[u].hash(h)}};this.context=a;let l=u=>(Ti(r.computed,()=>"[zag-js] No computed object found on machine"),r.computed[u]({context:a,event:this.getEvent(),prop:o,refs:this.refs,scope:this.scope,computed:l}));this.computed=l;let c=om(r.refs?.({prop:o,context:a})??{});this.refs=c;let d=Di(()=>({defaultValue:Pc(r,r.initialState({prop:o})),onChange:(u,h)=>{let{exiting:p,entering:m}=mp(this.machine,h,u,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?Zt(b,g):g);}}),h===Pi){this.action(r.entry);let f=this.effect(r.effects);if(f){let g=this.effects.get(Pi);this.effects.set(Pi,g?Zt(g,f):f);}}m.forEach(f=>{this.action(f.state?.entry);});}}));this.state=d,this.cleanups.push(ya(this.state.ref,()=>this.notify()));}updateProps(r){let e=this.userPropsRef.current;this.userPropsRef.current=()=>{let t=Ci(e),n=Ci(r);return Gc(t,n)},this.notify();}start(){this.status=gr.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,Pi),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=gr.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 wa(r,e,t){let n=new Uc(r,e),i=n.subscribe(t);return n.start(),t(n.service),{service:n.service,flush:()=>t(n.service),stop:()=>{i(),n.stop();}}}var BS=0;function xa(r){return `${r}-${++BS}`}function On(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 sm="outline:none;transition:border-color .12s ease,box-shadow .12s ease;",am="border-color:var(--vela-focus);box-shadow:0 0 0 3px var(--vela-focus-soft);";function oe(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 Me(r,e=document){let t=e.createElement("span");t.className="vela-icon",t.setAttribute("aria-hidden","true");let n=Bo(r);return n&&(t.innerHTML=n),t}var It=(r,e=[])=>({parts:(...t)=>{if(HS(e))return It(r,t);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...t)=>It(r,[...e,...t]),omit:(...t)=>It(r,e.filter(n=>!t.includes(n))),rename:t=>It(t,e),keys:()=>e,build:()=>[...new Set(e)].reduce((t,n)=>Object.assign(t,{[n]:{selector:[`&[data-scope="${Pr(r)}"][data-part="${Pr(n)}"]`,`& [data-scope="${Pr(r)}"][data-part="${Pr(n)}"]`].join(", "),attrs:{"data-scope":Pr(r),"data-part":Pr(n)}}}),{})}),Pr=r=>r.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),HS=r=>r.length===0;var zS=It("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),Se=zS.build();var dm=["top","right","bottom","left"];var mt=Math.min,Qe=Math.max,Fi=Math.round,Ni=Math.floor,ft=r=>({x:r,y:r}),$S={left:"right",right:"left",bottom:"top",top:"bottom"};function Yc(r,e,t){return Qe(r,mt(e,t))}function gt(r,e){return typeof r=="function"?r(e):r}function At(r){return r.split("-")[0]}function Fn(r){return r.split("-")[1]}function Ca(r){return r==="x"?"y":"x"}function Ta(r){return r==="y"?"height":"width"}function et(r){let e=r[0];return e==="t"||e==="b"?"y":"x"}function Ea(r){return Ca(et(r))}function um(r,e,t){t===void 0&&(t=false);let n=Fn(r),i=Ea(r),o=Ta(i),s=i==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Oi(s)),[s,Oi(s)]}function hm(r){let e=Oi(r);return [Sa(r),e,Sa(e)]}function Sa(r){return r.includes("start")?r.replace("start","end"):r.replace("end","start")}var lm=["left","right"],cm=["right","left"],WS=["top","bottom"],GS=["bottom","top"];function US(r,e,t){switch(r){case "top":case "bottom":return t?e?cm:lm:e?lm:cm;case "left":case "right":return e?WS:GS;default:return []}}function pm(r,e,t,n){let i=Fn(r),o=US(At(r),t==="start",n);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(Sa)))),o}function Oi(r){let e=At(r);return $S[e]+r.slice(e.length)}function YS(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 Kc(r){return typeof r!="number"?YS(r):{top:r,right:r,bottom:r,left:r}}function Nn(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 mm(r,e,t){let{reference:n,floating:i}=r,o=et(e),s=Ea(e),a=Ta(s),l=At(e),c=o==="y",d=n.x+n.width/2-i.width/2,u=n.y+n.height/2-i.height/2,h=n[a]/2-i[a]/2,p;switch(l){case "top":p={x:d,y:n.y-i.height};break;case "bottom":p={x:d,y:n.y+n.height};break;case "right":p={x:n.x+n.width,y:u};break;case "left":p={x:n.x-i.width,y:u};break;default:p={x:n.x,y:n.y};}let m=Fn(e);return m&&(p[s]+=h*(m==="end"?1:-1)*(t&&c?-1:1)),p}async function bm(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:d="viewport",elementContext:u="floating",altBoundary:h=false,padding:p=0}=gt(e,r),m=Kc(p),g=a[h?u==="floating"?"reference":"floating":u],b=Nn(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:d,strategy:l})),v=u==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),w=await(o.isElement==null?void 0:o.isElement(y))&&await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1},P=Nn(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return {top:(b.top-P.top+m.top)/w.y,bottom:(P.bottom-b.bottom+m.bottom)/w.y,left:(b.left-P.left+m.left)/w.x,right:(P.right-b.right+m.right)/w.x}}var KS=50,vm=async(r,e,t)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:bm},l=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:r,floating:e,strategy:i}),{x:d,y:u}=mm(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:v}=g,{x:y,y:w,data:P,reset:x}=await v({x:d,y:u,initialPlacement:n,placement:h,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:r,floating:e}});d=y??d,u=w??u,m[b]={...m[b],...P},x&&p<KS&&(p++,typeof x=="object"&&(x.placement&&(h=x.placement),x.rects&&(c=x.rects===true?await s.getElementRects({reference:r,floating:e,strategy:i}):x.rects),{x:d,y:u}=mm(c,h,l)),f=-1);}return {x:d,y:u,placement:h,strategy:i,middlewareData:m}},ym=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:d=0}=gt(r,e)||{};if(c==null)return {};let u=Kc(d),h={x:t,y:n},p=Ea(i),m=Ta(p),f=await s.getDimensions(c),g=p==="y",b=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",w=o.reference[m]+o.reference[p]-h[p]-o.floating[m],P=h[p]-o.reference[p],x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),S=x?x[y]:0;(!S||!await(s.isElement==null?void 0:s.isElement(x)))&&(S=a.floating[y]||o.floating[m]);let E=w/2-P/2,L=S/2-f[m]/2-1,T=mt(u[b],L),k=mt(u[v],L),M=S-f[m]-k,C=S/2-f[m]/2+E,I=Yc(T,C,M),_=!l.arrow&&Fn(i)!=null&&C!==I&&o.reference[m]/2-(C<T?T:k)-f[m]/2<0,U=_?C<T?C-T:C-M:0;return {[p]:h[p]+U,data:{[p]:I,centerOffset:C-I-U,..._&&{alignmentOffset:U}},reset:_}}});var wm=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:d=true,crossAxis:u=true,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:f=true,...g}=gt(r,e);if((t=o.arrow)!=null&&t.alignmentOffset)return {};let b=At(i),v=et(a),y=At(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),P=h||(y||!f?[Oi(a)]:hm(a)),x=m!=="none";!h&&x&&P.push(...pm(a,f,m,w));let S=[a,...P],E=await l.detectOverflow(e,g),L=[],T=((n=o.flip)==null?void 0:n.overflows)||[];if(d&&L.push(E[b]),u){let I=um(i,s,w);L.push(E[I[0]],E[I[1]]);}if(T=[...T,{placement:i,overflows:L}],!L.every(I=>I<=0)){var k,M;let I=(((k=o.flip)==null?void 0:k.index)||0)+1,_=S[I];if(_&&(!(u==="alignment"?v!==et(_):false)||T.every(z=>et(z.placement)===v?z.overflows[0]>0:true)))return {data:{index:I,overflows:T},reset:{placement:_}};let U=(M=T.filter(Y=>Y.overflows[0]<=0).sort((Y,z)=>Y.overflows[1]-z.overflows[1])[0])==null?void 0:M.placement;if(!U)switch(p){case "bestFit":{var C;let Y=(C=T.filter(z=>{if(x){let He=et(z.placement);return He===v||He==="y"}return true}).map(z=>[z.placement,z.overflows.filter(He=>He>0).reduce((He,Dy)=>He+Dy,0)]).sort((z,He)=>z[1]-He[1])[0])==null?void 0:C[0];Y&&(U=Y);break}case "initialPlacement":U=a;break}if(i!==U)return {reset:{placement:U}}}return {}}}};function fm(r,e){return {top:r.top-e.height,right:r.right-e.width,bottom:r.bottom-e.height,left:r.left-e.width}}function gm(r){return dm.some(e=>r[e]>=0)}var xm=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(e){let{rects:t,platform:n}=e,{strategy:i="referenceHidden",...o}=gt(r,e);switch(i){case "referenceHidden":{let s=await n.detectOverflow(e,{...o,elementContext:"reference"}),a=fm(s,t.reference);return {data:{referenceHiddenOffsets:a,referenceHidden:gm(a)}}}case "escaped":{let s=await n.detectOverflow(e,{...o,altBoundary:true}),a=fm(s,t.floating);return {data:{escapedOffsets:a,escaped:gm(a)}}}default:return {}}}}};var Sm=new Set(["left","top"]);async function XS(r,e){let{placement:t,platform:n,elements:i}=r,o=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=At(t),a=Fn(t),l=et(t)==="y",c=Sm.has(s)?-1:1,d=o&&l?-1:1,u=gt(e,r),{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*d,y:h*c}:{x:h*c,y:p*d}}var Cm=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 XS(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}}}}},Tm=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:v=>{let{x:y,y:w}=v;return {x:y,y:w}}},...c}=gt(r,e),d={x:t,y:n},u=await o.detectOverflow(e,c),h=et(i),p=Ca(h),m=d[p],f=d[h],g=(v,y)=>Yc(y+u[v==="y"?"top":"left"],y,y-u[v==="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}}}}}},Em=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:d=true,crossAxis:u=true}=gt(r,e),h={x:i,y:o},p=et(s),m=Ca(p),f=h[m],g=h[p],b=gt(c,e),v=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(n=b.crossAxis)!=null?n:0};if(d){let P=m==="y"?"height":"width",x=a.reference[m]-a.floating[P]+v.mainAxis,S=a.reference[m]+a.reference[P]-v.mainAxis;f<x?f=x:f>S&&(f=S);}if(u){var y,w;let P=m==="y"?"width":"height",x=Sm.has(At(s)),S=a.reference[p]-a.floating[P]+(x&&((y=l.offset)==null?void 0:y[p])||0)+(x?0:v.crossAxis),E=a.reference[p]+a.reference[P]+(x?0:((w=l.offset)==null?void 0:w[p])||0)-(x?v.crossAxis:0);g<S?g=S:g>E&&(g=E);}return {[m]:f,[p]:g}}}},Pm=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}=gt(r,e),l=await i.detectOverflow(e,a),c=At(t),d=Fn(t),u=et(t)==="y",{width:h,height:p}=n.floating,m,f;c==="top"||c==="bottom"?(m=c,f=d===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(f=c,m=d==="end"?"top":"bottom");let g=p-l.top-l.bottom,b=h-l.left-l.right,v=mt(p-l[m],g),y=mt(h-l[f],b),w=e.middlewareData.shift,P=!w,x=v,S=y;w!=null&&w.enabled.x&&(S=b),w!=null&&w.enabled.y&&(x=g),P&&!d&&(u?S=h-2*Qe(l.left,l.right):x=p-2*Qe(l.top,l.bottom)),await s({...e,availableWidth:S,availableHeight:x});let E=await i.getDimensions(o.floating);return h!==E.width||p!==E.height?{reset:{rects:true}}:{}}}};function Pa(){return typeof window<"u"}function _n(r){return Mm(r)?(r.nodeName||"").toLowerCase():"#document"}function ke(r){var e;return (r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function bt(r){var e;return (e=(Mm(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function Mm(r){return Pa()?r instanceof Node||r instanceof ke(r).Node:false}function tt(r){return Pa()?r instanceof Element||r instanceof ke(r).Element:false}function Rt(r){return Pa()?r instanceof HTMLElement||r instanceof ke(r).HTMLElement:false}function Lm(r){return !Pa()||typeof ShadowRoot>"u"?false:r instanceof ShadowRoot||r instanceof ke(r).ShadowRoot}function Vi(r){let{overflow:e,overflowX:t,overflowY:n,display:i}=nt(r);return /auto|scroll|overlay|hidden|clip/.test(e+n+t)&&i!=="inline"&&i!=="contents"}function km(r){return /^(table|td|th)$/.test(_n(r))}function _i(r){try{if(r.matches(":popover-open"))return !0}catch{}try{return r.matches(":modal")}catch{return false}}var jS=/transform|translate|scale|rotate|perspective|filter/,qS=/paint|layout|strict|content/,Vn=r=>!!r&&r!=="none",Xc;function La(r){let e=tt(r)?nt(r):r;return Vn(e.transform)||Vn(e.translate)||Vn(e.scale)||Vn(e.rotate)||Vn(e.perspective)||!Ma()&&(Vn(e.backdropFilter)||Vn(e.filter))||jS.test(e.willChange||"")||qS.test(e.contain||"")}function Im(r){let e=tn(r);for(;Rt(e)&&!Mr(e);){if(La(e))return e;if(_i(e))return null;e=tn(e);}return null}function Ma(){return Xc==null&&(Xc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Xc}function Mr(r){return /^(html|body|#document)$/.test(_n(r))}function nt(r){return ke(r).getComputedStyle(r)}function Bi(r){return tt(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function tn(r){if(_n(r)==="html")return r;let e=r.assignedSlot||r.parentNode||Lm(r)&&r.host||bt(r);return Lm(e)?e.host:e}function Am(r){let e=tn(r);return Mr(e)?(r.ownerDocument||r).body:Rt(e)&&Vi(e)?e:Am(e)}function Lr(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=true);let i=Am(r),o=i===((n=r.ownerDocument)==null?void 0:n.body),s=ke(i);if(o){let a=ka(s);return e.concat(s,s.visualViewport||[],Vi(i)?i:[],a&&t?Lr(a):[])}else return e.concat(i,Lr(i,[],t))}function ka(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}function Om(r){let e=nt(r),t=parseFloat(e.width)||0,n=parseFloat(e.height)||0,i=Rt(r),o=i?r.offsetWidth:t,s=i?r.offsetHeight:n,a=Fi(t)!==o||Fi(n)!==s;return a&&(t=o,n=s),{width:t,height:n,$:a}}function qc(r){return tt(r)?r:r.contextElement}function kr(r){let e=qc(r);if(!Rt(e))return ft(1);let t=e.getBoundingClientRect(),{width:n,height:i,$:o}=Om(e),s=(o?Fi(t.width):t.width)/n,a=(o?Fi(t.height):t.height)/i;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var ZS=ft(0);function Fm(r){let e=ke(r);return !Ma()||!e.visualViewport?ZS:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function JS(r,e,t){return e===void 0&&(e=false),!!t&&e&&t===ke(r)}function Bn(r,e,t,n){e===void 0&&(e=false),t===void 0&&(t=false);let i=r.getBoundingClientRect(),o=qc(r),s=ft(1);e&&(n?tt(n)&&(s=kr(n)):s=kr(r));let a=JS(o,t,n)?Fm(o):ft(0),l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,d=i.width/s.x,u=i.height/s.y;if(o&&n){let h=ke(o),p=tt(n)?ke(n):n,m=h,f=ka(m);for(;f&&p!==m;){let g=kr(f),b=f.getBoundingClientRect(),v=nt(f),y=b.left+(f.clientLeft+parseFloat(v.paddingLeft))*g.x,w=b.top+(f.clientTop+parseFloat(v.paddingTop))*g.y;l*=g.x,c*=g.y,d*=g.x,u*=g.y,l+=y,c+=w,m=ke(f),f=ka(m);}}return Nn({width:d,height:u,x:l,y:c})}function Ia(r,e){let t=Bi(r).scrollLeft;return e?e.left+t:Bn(bt(r)).left+t}function Nm(r,e){let t=r.getBoundingClientRect(),n=t.left+e.scrollLeft-Ia(r,t),i=t.top+e.scrollTop;return {x:n,y:i}}function QS(r){let{elements:e,rect:t,offsetParent:n,strategy:i}=r,o=i==="fixed",s=bt(n),a=e?_i(e.floating):false;if(n===s||a&&o)return t;let l={scrollLeft:0,scrollTop:0},c=ft(1),d=ft(0),u=Rt(n);if((u||!o)&&((_n(n)!=="body"||Vi(s))&&(l=Bi(n)),u)){let p=Bn(n);c=kr(n),d.x=p.x+n.clientLeft,d.y=p.y+n.clientTop;}let h=s&&!u&&!o?Nm(s,l):ft(0);return {width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:t.y*c.y-l.scrollTop*c.y+d.y+h.y}}function eC(r){return r.getClientRects?Array.from(r.getClientRects()):[]}function tC(r){let e=Bi(r),t=r.ownerDocument.body,n=Qe(r.scrollWidth,r.clientWidth,t.scrollWidth,t.clientWidth),i=Qe(r.scrollHeight,r.clientHeight,t.scrollHeight,t.clientHeight),o=-e.scrollLeft+Ia(r),s=-e.scrollTop;return nt(t).direction==="rtl"&&(o+=Qe(r.clientWidth,t.clientWidth)-n),{width:n,height:i,x:o,y:s}}var nC=25;function rC(r,e,t){t===void 0&&(t="viewport");let n=t==="layoutViewport",i=ke(r),o=bt(r),s=i.visualViewport,a=o.clientWidth,l=o.clientHeight,c=0,d=0;if(s){let h=!Ma()||e==="fixed";n?h||(c=-s.offsetLeft,d=-s.offsetTop):(a=s.width,l=s.height,h&&(c=s.offsetLeft,d=s.offsetTop));}if(Ia(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<=nC&&(a-=b);}return {width:a,height:l,x:c,y:d}}function iC(r,e){let t=Bn(r,true,e==="fixed"),n=t.top+r.clientTop,i=t.left+r.clientLeft,o=kr(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 Rm(r,e,t){let n;if(e==="viewport"||e==="layoutViewport")n=rC(r,t,e);else if(e==="document")n=tC(bt(r));else if(tt(e))n=iC(e,t);else {let i=Fm(r);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height};}return Nn(n)}function oC(r,e){let t=e.get(r);if(t)return t;let n=Lr(r,[],false).filter(a=>tt(a)&&_n(a)!=="body"),i=null,o=nt(r).position==="fixed",s=o?tn(r):r;for(;tt(s)&&!Mr(s);){let a=nt(s),l=La(s),c=i?i.position:o?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?n=n.filter(u=>u!==s):i=a,s=tn(s);}return e.set(r,n),n}function sC(r){let{element:e,boundary:t,rootBoundary:n,strategy:i}=r,s=[...t==="clippingAncestors"?_i(e)?[]:oC(e,this._c):[].concat(t),n],a=Rm(e,s[0],i),l=a.top,c=a.right,d=a.bottom,u=a.left;for(let h=1;h<s.length;h++){let p=Rm(e,s[h],i);l=Qe(p.top,l),c=mt(p.right,c),d=mt(p.bottom,d),u=Qe(p.left,u);}return {width:c-u,height:d-l,x:u,y:l}}function aC(r){let{width:e,height:t}=Om(r);return {width:e,height:t}}function lC(r,e,t){let n=Rt(e),i=bt(e),o=t==="fixed",s=Bn(r,true,o,e),a={scrollLeft:0,scrollTop:0},l=ft(0);if((n||!o)&&((_n(e)!=="body"||Vi(i))&&(a=Bi(e)),n)){let h=Bn(e,true,o,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop;}!n&&i&&(l.x=Ia(i));let c=i&&!n&&!o?Nm(i,a):ft(0),d=s.left+a.scrollLeft-l.x-c.x,u=s.top+a.scrollTop-l.y-c.y;return {x:d,y:u,width:s.width,height:s.height}}function jc(r){return nt(r).position==="static"}function Dm(r,e){if(!Rt(r)||nt(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return bt(r)===t&&(t=t.ownerDocument.body),t}function Vm(r,e){let t=ke(r);if(_i(r))return t;if(!Rt(r)){let i=tn(r);for(;i&&!Mr(i);){if(tt(i)&&!jc(i))return i;i=tn(i);}return t}let n=Dm(r,e);for(;n&&km(n)&&jc(n);)n=Dm(n,e);return n&&Mr(n)&&jc(n)&&!La(n)?t:n||Im(r)||t}var cC=async function(r){let e=this.getOffsetParent||Vm,t=this.getDimensions,n=await t(r.floating);return {reference:lC(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function dC(r){return nt(r).direction==="rtl"}var uC={convertOffsetParentRelativeRectToViewportRelativeRect:QS,getDocumentElement:bt,getClippingRect:sC,getOffsetParent:Vm,getElementRects:cC,getClientRects:eC,getDimensions:aC,getScale:kr,isElement:tt,isRTL:dC};function _m(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function hC(r,e,t){let n=null,i,o=bt(r);function s(){var d;clearTimeout(i),(d=n)==null||d.disconnect(),n=null;}function a(d,u){d===void 0&&(d=false),u===void 0&&(u=1),s();let h=r.getBoundingClientRect(),{left:p,top:m,width:f,height:g}=h;if(d||e(),!f||!g)return;let b=Ni(m),v=Ni(o.clientWidth-(p+f)),y=Ni(o.clientHeight-(m+g)),w=Ni(p),x={rootMargin:-b+"px "+-v+"px "+-y+"px "+-w+"px",threshold:Qe(0,mt(1,u))||1},S=true;function E(L){let T=L[0].intersectionRatio;if(!_m(h,r.getBoundingClientRect()))return a();if(T!==u){if(!S)return a();T?a(false,T):i=setTimeout(()=>{a(false,1e-7);},1e3);}S=false;}try{n=new IntersectionObserver(E,{...x,root:o.ownerDocument});}catch{n=new IntersectionObserver(E,x);}n.observe(r);}let l=ke(r),c=()=>a(t);return l.addEventListener("resize",c),a(true),()=>{l.removeEventListener("resize",c),s();}}function Bm(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=qc(r),d=i||o?[...c?Lr(c):[],...e?Lr(e):[]]:[];d.forEach(b=>{i&&b.addEventListener("scroll",t),o&&b.addEventListener("resize",t);});let u=c&&a?hC(c,t,o):null,h=-1,p=null;s&&(p=new ResizeObserver(b=>{let[v]=b;v&&v.target===c&&p&&e&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(e);})),t();}),c&&!l&&p.observe(c),e&&p.observe(e));let m,f=l?Bn(r):null;l&&g();function g(){let b=Bn(r);f&&!_m(f,b)&&t(),f=b,m=requestAnimationFrame(g);}return t(),()=>{var b;d.forEach(v=>{i&&v.removeEventListener("scroll",t),o&&v.removeEventListener("resize",t);}),u?.(),(b=p)==null||b.disconnect(),p=null,l&&cancelAnimationFrame(m);}}var Hm=Cm;var zm=Tm,$m=wm,Wm=Pm,Gm=xm,Um=ym;var Ym=Em,Km=(r,e,t)=>{let n=new Map,i=t??{},o={...uC,...i.platform,_c:n};return vm(r,e,{...i,platform:o})};function Xm(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 pC(r){if(!r)return Xm();let{x:e,y:t,width:n,height:i}=r;return Xm(e,t,n,i)}function jm(r,e){return {contextElement:Q(r)?r:r?.contextElement,getBoundingClientRect:()=>{let t=r,n=e?.(t);return n||!t?pC(n):t.getBoundingClientRect()}}}var Hi=r=>({variable:r,reference:`var(${r})`}),vt={arrowSize:Hi("--arrow-size"),arrowSizeHalf:Hi("--arrow-size-half"),arrowBg:Hi("--arrow-background"),transformOrigin:Hi("--transform-origin"),arrowOffset:Hi("--arrow-offset")},mC=r=>r==="top"||r==="bottom"?"y":"x";function qm(r,e){return {name:"transformOrigin",fn(t){let{elements:n,middlewareData:i,placement:o,rects:s,y:a}=t,l=o.split("-")[0],c=mC(l),d=i.arrow?.x||0,u=i.arrow?.y||0,h=e?.clientWidth||0,p=e?.clientHeight||0,m=d+h/2,f=u+p/2,g=Math.abs(i.shift?.y||0),b=s.reference.height/2,v=p/2,y=r.offset?.mainAxis??r.gutter,w=typeof y=="number"?y+v:y??v,P=g>w,x={top:`${m}px calc(100% + ${w}px)`,bottom:`${m}px ${-w}px`,left:`calc(100% + ${w}px) ${f}px`,right:`${-w}px ${f}px`}[l],S=`${m}px ${s.reference.y+b-a}px`,E=!!r.overlap&&c==="y"&&P;return n.floating.style.setProperty(vt.transformOrigin.variable,E?S:x),{data:{transformOrigin:E?S:x}}}}}var Zm={name:"rects",fn({rects:r}){return {data:r}}},Jm=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% + ${vt.arrowOffset.reference})`}),{}}}};function Qm(r){let[e,t]=r.split("-");return {side:e,align:t,hasAlign:t!=null}}function zi(r){return r.split("-")[0]}var fC={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 ef(r,e){let t=r.devicePixelRatio||1;return Math.round(e*t)/t}function Ir(r,e){return r!=null&&Math.abs(r-e)<.5}function Aa(r){return typeof r=="function"?r():r==="clipping-ancestors"?"clippingAncestors":r}function gC(r,e,t){let n=r||e.createElement("div");return Um({element:n,padding:t.arrowPadding})}function bC(r,e){if(!rp(e.offset??e.gutter))return Hm(({placement:t})=>{let n=(r?.clientHeight||0)/2,i=e.offset?.mainAxis??e.gutter,o=typeof i=="number"?i+n:i??n,{hasAlign:s}=Qm(t),a=s?void 0:e.shift,l=e.offset?.crossAxis??a;return Jt({crossAxis:l,mainAxis:o,alignmentAxis:e.shift})})}function vC(r){if(r.flip)return $m(()=>{let e=Aa(r.boundary);return {...e?{boundary:e}:void 0,padding:r.overflowPadding,fallbackPlacements:r.flip===true?void 0:r.flip}})}function yC(r){if(!(!r.slide&&!r.overlap))return zm(()=>{let e=Aa(r.boundary);return {...e?{boundary:e}:void 0,mainAxis:r.slide,crossAxis:r.overlap,padding:r.overflowPadding,limiter:Ym()}})}function wC(r){if(r.sizeMiddleware===false&&!r.sameWidth&&!r.fitViewport)return;let e,t,n,i;return Wm(()=>{let o=Aa(r.boundary);return {padding:r.overflowPadding,...o?{boundary:o}:void 0,apply({elements:s,rects:a,availableHeight:l,availableWidth:c}){let d=s.floating,u=Math.round(a.reference.width),h=Math.round(a.reference.height);c=Math.floor(c),l=Math.floor(l),Ir(e,u)||(d.style.setProperty("--reference-width",`${u}px`),e=u),Ir(t,h)||(d.style.setProperty("--reference-height",`${h}px`),t=h),Ir(n,c)||(d.style.setProperty("--available-width",`${c}px`),n=c),Ir(i,l)||(d.style.setProperty("--available-height",`${l}px`),i=l);}}})}function xC(r){if(r.hideWhenDetached)return Gm(()=>({strategy:"referenceHidden",boundary:Aa(r.boundary)??"clippingAncestors"}))}function SC(r){return r?r===true?{ancestorResize:true,ancestorScroll:true,elementResize:true,layoutShift:true}:r:{}}var CC=["transform","visibility","pointer-events","--x","--y","--z-index","--reference-width","--reference-height","--available-width","--available-height","--transform-origin"],TC=["top","right","bottom","left"];function tf(r,e){if(!r)return xc;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 nf(r){return r==null?null:Q(r)?r:typeof r=="object"&&r&&"contextElement"in r&&r.contextElement?r.contextElement:r}function EC(r,e,t={}){let n=()=>(typeof e=="function"?e():e)??null,i=()=>{let T=typeof r=="function"?r():r;return t.getAnchorElement?.()??T},o=()=>{let T=i();return !T&&!t.getAnchorRect?null:jm(T,t.getAnchorRect)},s=Object.assign({},fC,t),a=[],l=null,c,d;function u(T){c?.(),d?.(),l=T,c=s.restoreStyles?tf(T,CC):void 0;let k=T.querySelector("[data-part=arrow]");d=s.restoreStyles?tf(k,TC):void 0,a=[bC(k,s),vC(s),yC(s),gC(k,T.ownerDocument,s),Jm(k),qm({gutter:s.gutter,offset:s.offset,overlap:s.overlap},k),wC(s),xC(s),Zm];}let{placement:h,strategy:p,onComplete:m,onPositioned:f}=s,g,b,v=false,y,w,P=xc,x=SC(s.listeners);function S(){if(!s.listeners)return;let T=i(),k=o(),M=n();if(!k||!M)return;(nf(T)!==nf(y)||M!==w)&&(P(),y=T,w=M,P=Bm(k,M,L,x));}async function E(){S();let T=n();if(!T)return;T!==l&&(u(T),v=false);let k=o();if(!k)return;let M=await Km(k,T,{placement:h,middleware:a,strategy:p});m?.(M);let C=ae(T),I=ef(C,M.x),_=ef(C,M.y);if(Ir(g,I)||(T.style.setProperty("--x",`${I}px`),g=I),Ir(b,_)||(T.style.setProperty("--y",`${_}px`),b=_),s.hideWhenDetached&&(M.middlewareData.hide?.referenceHidden?(T.style.setProperty("visibility","hidden"),T.style.setProperty("pointer-events","none")):(T.style.removeProperty("visibility"),T.style.removeProperty("pointer-events"))),!v){let U=T.firstElementChild;U&&(T.style.setProperty("--z-index",vr(U).zIndex),v=true);}}async function L(){t.updatePosition?(await t.updatePosition({updatePosition:E,floatingElement:n()}),f?.({placed:true})):await E();}return L(),()=>{P(),d?.(),c?.(),f?.({placed:false});}}function Ra(r,e,t={}){let{defer:n,...i}=t,o=n?ue:a=>a(),s=[];return s.push(o(()=>{s.push(EC(r,e,i));})),()=>{s.forEach(a=>a?.());}}var PC={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"};function Zc(r={}){let{placement:e,sameWidth:t,fitViewport:n,strategy:i="absolute"}=r;return {arrow:{position:"absolute",width:vt.arrowSize.reference,height:vt.arrowSize.reference,[vt.arrowSizeHalf.variable]:`calc(${vt.arrowSize.reference} / 2)`,[vt.arrowOffset.variable]:`calc(${vt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:e?PC[e.split("-")[0]]:void 0,background:vt.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 yt=(r,e)=>{let t=r.ids?.trigger;return t!=null?De(t)?t(e):t:e?`menu:${r.id}:trigger:${e}`:`menu:${r.id}:trigger`},Da=(r,e)=>{let t=r.ids?.contextTrigger;return t!=null?De(t)?t(e):t:e?`menu:${r.id}:ctx-trigger:${e}`:`menu:${r.id}:ctx-trigger`},nn=r=>r.ids?.content??`menu:${r.id}:content`,rf=r=>r.ids?.arrow??`menu:${r.id}:arrow`,Jc=r=>r.ids?.positioner??`menu:${r.id}:popper`,of=(r,e)=>r.ids?.group?.(e)??`menu:${r.id}:group:${e}`,Hn=(r,e)=>`${r.id}/${e}`,rn=r=>r?.dataset.value??null,Qc=(r,e)=>r.ids?.groupLabel?.(e)??`menu:${r.id}:group-label:${e}`,rt=r=>r.getById(nn(r)),ed=r=>r.getById(Jc(r)),td=r=>r.getById(yt(r)),sf=(r,e)=>e?r.getById(Hn(r,e)):null;var af=r=>r.getById(Da(r)),nd=r=>Cr(r.getRootNode(),`[data-scope="menu"][data-part="trigger"][data-ownedby="${r.id}"]`),rd=r=>Cr(r.getRootNode(),`[data-scope="menu"][data-part="context-trigger"][data-ownedby="${r.id}"]`),$i=(r,e)=>e==null?td(r)??nd(r)[0]:r.getById(yt(r,e)),Wi=r=>{let t=`[role^="menuitem"][data-ownedby=${CSS.escape(nn(r))}]:not([data-disabled])`;return Cr(rt(r),t)},lf=r=>Zh(Wi(r)),cf=r=>Jh(Wi(r)),id=(r,e)=>e?r.id===e||r.dataset.value===e:false,df=(r,e)=>{let t=Wi(r),n=t.findIndex(i=>id(i,e.value));return ep(t,n,{loop:e.loop??e.loopFocus})},uf=(r,e)=>{let t=Wi(r),n=t.findIndex(i=>id(i,e.value));return tp(t,n,{loop:e.loop??e.loopFocus})},hf=(r,e)=>{let t=Wi(r),n=t.find(i=>id(i,e.value));return ma(t,{state:e.typeaheadState,key:e.key,activeId:n?.id??null})},Gi=r=>Q(r)&&(r.dataset.disabled===""||r.hasAttribute("disabled")),od=r=>!!r?.getAttribute("role")?.startsWith("menuitem")&&!!r?.hasAttribute("data-controls");var Oa="menu:select";function pf(r,e){if(!r)return;let t=ae(r),n=new t.CustomEvent(Oa,{detail:{value:e}});r.dispatchEvent(n);}function LC(r){let e=nn(r);return rt(r)??r.getDoc().getElementById(e)}function sd(r,e){if(!Q(r))return false;for(let t in e){let n=e[t],i=LC(n.scope);if(i&&Oe(i,r))return true;let o=n.refs.get("children");if(Object.keys(o).length>0&&sd(r,o))return true}return false}var Ui=(r,e)=>({x:r,y:e});function mf(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:Ui(o,s)}}function ff(r){let e=Ui(r.minX,r.minY),t=Ui(r.maxX,r.minY),n=Ui(r.maxX,r.maxY),i=Ui(r.minX,r.maxY);return {top:e,right:t,bottom:n,left:i}}function gf(r,e){let t=mf(r),{top:n,right:i,left:o,bottom:s}=ff(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 Fa(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,d=r[s].y;l>n!=d>n&&t<(c-a)*(n-l)/(d-l)+a&&(i=!i);}return i}function ld(r){let e=r.parent;for(;e&&e.context.get("isSubmenu");)e=e.refs.get("parent");e?.send({type:"CLOSE"});}function bf(r,e){return r?Fa(r,e):false}function vf(r,e,t){let n=Object.keys(r).length>0;if(!e)return null;if(!n)return Hn(t,e);for(let i in r){let o=r[i],s=yt(o.scope);if(s===e)return s}return Hn(t,e)}function on(r,e){r&&(r.refs.set("pointerRoutingLocked",e),r.context.set("pointerRoutingMode",e?"locked":"interactive"));}function yf(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")&&yt(i.scope)===e)return true}return false}function wf(r,e){r&&(r.refs.get("pointerRoutingLocked")||e&&yf(r)||on(r,false));}function xf(r){r&&(yf(r)||on(r,false));}function cd(r,e){let{context:t,send:n,state:i,computed:o,prop:s,scope:a}=r,l=i.hasTag("open"),c=t.get("isSubmenu"),d=o("isTypingAhead"),u=s("composite"),h=t.get("currentPlacement"),p=h?zi(h):void 0,m=t.get("anchorPoint"),f=t.get("highlightedValue"),g=t.get("triggerValue"),b=Zc({...s("positioning"),placement:h});function v(x){return {id:Hn(a,x.value),disabled:!!x.disabled,highlighted:f===x.value}}function y(x){let S=x.valueText??x.value;return {...x,id:x.value,valueText:S}}function w(x){return {...v(y(x)),checked:!!x.checked}}function P(x){let{closeOnSelect:S,valueText:E,value:L}=x,T=v(x),k=Hn(a,L);return e.element({...Se.item.attrs,id:k,role:"menuitem","aria-disabled":Lc(T.disabled),"data-disabled":We(T.disabled),"data-ownedby":nn(a),"data-highlighted":We(T.highlighted),"data-value":L,"data-valuetext":E,onDragStart(M){M.currentTarget.matches("a[href]")&&M.preventDefault();},onPointerMove(M){if(T.disabled||M.pointerType!=="mouse")return;let C=M.currentTarget;if(T.highlighted)return;let I=wr(M);n({type:"ITEM_POINTERMOVE",id:k,target:C,closeOnSelect:S,point:I});},onPointerLeave(M){if(T.disabled||M.pointerType!=="mouse"||!r.event.previous()?.type.includes("POINTER"))return;let I=M.currentTarget;n({type:"ITEM_POINTERLEAVE",id:k,target:I,closeOnSelect:S});},onPointerDown(M){if(T.disabled)return;let C=M.currentTarget;n({type:"ITEM_POINTERDOWN",target:C,id:k,closeOnSelect:S});},onClick(M){if(Nc(M)||Fc(M)||T.disabled)return;let C=M.currentTarget;n({type:"ITEM_CLICK",target:C,id:k,closeOnSelect:S});}})}return {highlightedValue:f,open:l,setOpen(x){i.hasTag("open")!==x&&n({type:x?"OPEN":"CLOSE"});},triggerValue:g,setTriggerValue(x){n({type:"TRIGGER_VALUE.SET",value:x});},setHighlightedValue(x){n({type:"HIGHLIGHTED.SET",value:x});},setParent(x){n({type:"PARENT.SET",value:x,id:x.prop("id")});},setChild(x){n({type:"CHILD.SET",value:x,id:x.prop("id")});},reposition(x={}){n({type:"POSITIONING.SET",options:x});},addItemListener(x){let S=a.getById(x.id);if(!S)return;let E=()=>x.onSelect?.();return S.addEventListener(Oa,E),()=>S.removeEventListener(Oa,E)},getContextTriggerProps(x={}){let{value:S}=x,E=S==null?false:g===S,L=Da(a,S);return e.element({...Se.contextTrigger.attrs,dir:s("dir"),id:L,"data-ownedby":a.id,"data-value":S,"data-current":We(E),"data-state":l?"open":"closed",onPointerDown(T){if(T.pointerType==="mouse")return;let k=wr(T);n({type:"CONTEXT_MENU_START",point:k,value:S});},onPointerCancel(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerMove(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerUp(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onContextMenu(T){let k=wr(T),M=l&&S!=null&&!E;n({type:M?"TRIGGER_VALUE.SET":"CONTEXT_MENU",point:k,value:S}),T.preventDefault();},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}})},getTriggerItemProps(x){let S=x.getTriggerProps();return ap(P({value:S.id}),S)},getTriggerProps(x={}){let{value:S}=x,E=S==null?false:g===S,L=yt(a,S);return e.button({...c?Se.triggerItem.attrs:Se.trigger.attrs,"data-placement":h,"data-side":p,type:"button",dir:s("dir"),id:L,...S!=null&&{"data-ownedby":a.id,"data-value":S,"data-current":We(E)},"data-uid":s("id"),"aria-haspopup":u?"menu":"dialog","aria-controls":nn(a),"data-controls":nn(a),"aria-expanded":S==null?l:l&&E,"data-state":l?"open":"closed",onPointerMove(T){if(T.pointerType!=="mouse"||Gi(T.currentTarget)||!c)return;let M=wr(T);n({type:"TRIGGER_POINTERMOVE",target:T.currentTarget,point:M});},onPointerLeave(T){if(Gi(T.currentTarget)||T.pointerType!=="mouse"||!c)return;on(r.refs.get("parent"),true);let k=wr(T);n({type:"TRIGGER_POINTERLEAVE",target:T.currentTarget,point:k});},onPointerDown(T){Gi(T.currentTarget)||ca(T)||T.preventDefault();},onClick(T){if(T.defaultPrevented||Gi(T.currentTarget))return;let k=l&&S!=null&&!E;n({type:k?"TRIGGER_VALUE.SET":"TRIGGER_CLICK",target:T.currentTarget,value:S});},onBlur(){n({type:"TRIGGER_BLUR"});},onFocus(){n({type:"TRIGGER_FOCUS"});},onKeyDown(T){if(T.defaultPrevented)return;let k={ArrowDown(){n({type:"ARROW_DOWN",value:S});},ArrowUp(){n({type:"ARROW_UP",value:S});},Enter(){n({type:"ARROW_DOWN",src:"enter",value:S});},Space(){n({type:"ARROW_DOWN",src:"space",value:S});}},M=Vc(T,{orientation:"vertical",dir:s("dir")}),C=k[M];C&&(T.preventDefault(),C(T));}})},getIndicatorProps(){return e.element({...Se.indicator.attrs,dir:s("dir"),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...Se.positioner.attrs,dir:s("dir"),id:Jc(a),style:b.floating})},getArrowProps(){return e.element({id:rf(a),...Se.arrow.attrs,dir:s("dir"),style:b.arrow})},getArrowTipProps(){return e.element({...Se.arrowTip.attrs,dir:s("dir"),style:b.arrowTip})},getContentProps(){return e.element({...Se.content.attrs,id:nn(a),"aria-label":s("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:u?"menu":"dialog",tabIndex:0,dir:s("dir"),"aria-activedescendant":o("highlightedId")||void 0,"aria-labelledby":m?Da(a,g??void 0):yt(a,g??void 0),"data-placement":h,"data-side":p,onPointerEnter(x){x.pointerType==="mouse"&&n({type:"MENU_POINTERENTER"});},onKeyDown(x){if(x.defaultPrevented||!Oe(x.currentTarget,fe(x)))return;let S=fe(x);if(!(S?.closest("[role=menu]")===x.currentTarget||S===x.currentTarget))return;if(x.key==="Tab"&&!zp(x)){x.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(M){d?n({type:"TYPEAHEAD",key:M.key}):L.Enter?.(M);},Home(){n({type:"HOME"});},End(){n({type:"END"});}},T=Vc(x,{dir:s("dir")}),k=L[T];if(k){k(x),x.stopPropagation(),x.preventDefault();return}s("typeahead")&&Op(x)&&(Np(x)||br(S)||(n({type:"TYPEAHEAD",key:x.key}),x.preventDefault()));}})},getSeparatorProps(){return e.element({...Se.separator.attrs,role:"separator",dir:s("dir"),"aria-orientation":"horizontal"})},getItemState:v,getItemProps:P,getOptionItemState:w,getOptionItemProps(x){let{type:S,disabled:E,closeOnSelect:L}=x,T=y(x),k=w(x);return {...P(T),...e.element({"data-type":S,...Se.item.attrs,dir:s("dir"),"data-value":T.value,role:`menuitem${S}`,"aria-checked":!!k.checked,"data-state":k.checked?"checked":"unchecked",onClick(M){if(E||Nc(M)||Fc(M))return;let C=M.currentTarget;n({type:"ITEM_CLICK",target:C,option:T,closeOnSelect:L});}})}},getItemIndicatorProps(x){let S=w(wc(x)),E=S.checked?"checked":"unchecked";return e.element({...Se.itemIndicator.attrs,dir:s("dir"),"data-disabled":We(S.disabled),"data-highlighted":We(S.highlighted),"data-state":Si(x,"checked")?E:void 0,hidden:Si(x,"checked")?!S.checked:void 0})},getItemTextProps(x){let S=w(wc(x)),E=S.checked?"checked":"unchecked";return e.element({...Se.itemText.attrs,dir:s("dir"),"data-disabled":We(S.disabled),"data-highlighted":We(S.highlighted),"data-state":Si(x,"checked")?E:void 0})},getItemGroupLabelProps(x){return e.element({...Se.itemGroupLabel.attrs,id:Qc(a,x.htmlFor),dir:s("dir")})},getItemGroupProps(x){return e.element({id:of(a,x.id),...Se.itemGroup.attrs,dir:s("dir"),"aria-labelledby":Qc(a,x.id),role:"group"})}}}function Sf(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 Cf(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 Tf="pointerdown.outside",Ef="focus.outside";function MC(r){for(let e of r)if(Q(e)&&Ge(e))return true;return false}var Mf=r=>"clientY"in r;function kC(r,e){if(!Mf(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 IC(r,e){return r.y<=e.y&&e.y<=r.y+r.height&&r.x<=e.x&&e.x<=r.x+r.width}function Pf(r,e){if(!e||!Mf(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 IC(s,a)?n||o:false}function AC(r,e){let{exclude:t,onFocusOutside:n,onPointerDownOutside:i,onInteractOutside:o,defer:s,followControlledElements:a=true}=e;if(!r)return;let l=ce(r),c=ae(r),d=Sf(c),u=Cf(c);function h(w,P){if(!Q(P)||!P.isConnected||Oe(r,P)||kC(r,w)||a&&la(r,P))return false;let x=l.querySelector(`[aria-controls="${r.id}"]`);if(x){let E=ha(x);if(Pf(w,E))return false}let S=ha(r);return Pf(w,S)?false:!t?.(P)}let p=new Set,m=Rn(r?.getRootNode()),f=false;function g(w){f=true;let P=()=>{f=false;};l.addEventListener("pointerup",P,{once:true}),c.addEventListener("pointerup",P,{once:true});function x(S){let E=s&&!Oc()?ue:k=>k(),L=S??w,T=L?.composedPath?.()??[L?.target];E(()=>{let k=m?T[0]:fe(w);if(!(!r||!h(w,k))){if(i||o){let M=Zt(i,o);r.addEventListener(Tf,M,{once:true});}Lf(r,Tf,{bubbles:false,cancelable:true,detail:{originalEvent:L,contextmenu:ca(L),focusable:MC(T),target:k}});}});}w.pointerType==="touch"?(p.forEach(S=>S()),p.add(Le(l,"click",x,{once:true})),p.add(u.addEventListener("click",x,{once:true})),p.add(d.addEventListener("click",x,{once:true}))):x();}let b=new Set,v=setTimeout(()=>{b.add(Le(l,"pointerdown",g,true)),b.add(u.addEventListener("pointerdown",g,true)),b.add(d.addEventListener("pointerdown",g,true));},0);function y(w){if(f)return;(s?ue:x=>x())(()=>{let x=w?.composedPath?.()??[w?.target],S=m?x[0]:fe(w);if(!(!r||!h(w,S))){if(n||o){let E=Zt(n,o);r.addEventListener(Ef,E,{once:true});}Lf(r,Ef,{bubbles:false,cancelable:true,detail:{originalEvent:w,contextmenu:false,focusable:Ge(S),target:S}});}});}return Oc()||(b.add(Le(l,"focusin",y,true)),b.add(u.addEventListener("focusin",y,true)),b.add(d.addEventListener("focusin",y,true))),()=>{clearTimeout(v),p.forEach(w=>w()),b.forEach(w=>w());}}function kf(r,e){let{defer:t}=e,n=t?ue:o=>o(),i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(AC(o,e));})),()=>{i.forEach(o=>o?.());}}function Lf(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,t);return r.dispatchEvent(i)}function If(r,e){let t=n=>{n.key==="Escape"&&(n.isComposing||e?.(n));};return Le(ce(r),"keydown",t,{capture:true})}var Af="layer:request-dismiss",Ce={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=>Oe(n.node,e))||this.recentlyRemoved.size>0)},isInBranch(r){return Array.from(this.branches).some(e=>Oe(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&&RC(i);}),this.recentlyRemoved.add(r),Wp(()=>this.recentlyRemoved.delete(r)),e<this.count()-1&&this.getNestedLayers(r).forEach(i=>Ce.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)=>{Rf(r,e,r.node),r.styleTargets?.forEach(t=>{let n=t();if(!n||n===r.node)return;Rf(r,e,n);let{zIndex:i}=vr(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];OC(r,Af,i=>{n.requestDismiss?.(i),i.defaultPrevented||n?.dismiss();}),DC(r,Af,{originalLayer:r,targetLayer:e,originalIndex:t,targetIndex:e?this.indexOf(e):-1}),this.syncLayers();},clear(){this.remove(this.layers[0].node);}};function Rf(r,e,t){t.style.setProperty("--layer-index",`${e}`),t.removeAttribute("data-nested"),t.removeAttribute("data-has-nested"),Ce.getParentLayerOfType(r.node,r.type)&&t.setAttribute("data-nested",r.type);let i=Ce.countNestedLayersOfType(r.node,r.type);i>0&&t.setAttribute("data-has-nested",r.type),t.style.setProperty("--nested-layer-count",`${i}`);}function RC(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 DC(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 OC(r,e,t){r.addEventListener(e,t,{once:true});}var dd=new WeakMap,Yi=new WeakMap;function FC(r){return Ce.isBelowPointerBlockingLayer(r)?"none":"auto"}function Df(r){let e=FC(r);r.style.pointerEvents!==e&&(r.style.pointerEvents=e);}function NC(r){if(Yi.has(r))return;let e=ae(r);if(typeof e.MutationObserver>"u")return;let t=new e.MutationObserver(()=>{Yi.has(r)&&Df(r);});t.observe(r,{attributes:true,attributeFilter:["style"]}),Yi.set(r,t);}function ud(){Ce.layers.forEach(({node:r})=>{Df(r),NC(r);});}function Of(r){let e=Yi.get(r);e&&(e.disconnect(),Yi.delete(r)),r.style.pointerEvents="";}function Ff(r,e){let t=ce(r),n=[];return Ce.hasPointerBlockingLayer()&&!t.body.hasAttribute("data-inert")&&(dd.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]=Zp(()=>{let a=i();return Q(a)?a:null},{timeout:1e3});o.then(a=>n.push(Ai(a,{pointerEvents:"auto"}))),n.push(s);}),()=>{Ce.hasPointerBlockingLayer()||(queueMicrotask(()=>{let i=t.body;if(!i)return;let o=dd.get(i);o!==void 0&&(i.style.pointerEvents=o,dd.delete(i)),i.removeAttribute("data-inert"),i.style.length===0&&i.removeAttribute("style");}),n.forEach(i=>i()));}}function VC(r,e){let{warnOnMissingNode:t=true}=e;if(t&&!r){mr("[@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,d={dismiss:n,node:r,type:l,pointerBlocking:o,requestDismiss:i,styleTargets:c};Ce.add(d),ud();function u(g){let b=fe(g.detail.originalEvent);Ce.isBelowPointerBlockingLayer(r)||Ce.isInBranch(b)||(e.onPointerDownOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onPointerDownOutside:",g.detail.originalEvent),n?.()));}function h(g){let b=fe(g.detail.originalEvent);Ce.isInBranch(b)||(e.onFocusOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onFocusOutside:",g.detail.originalEvent),n?.()));}function p(g){Ce.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,v=Array.isArray(b)?b:[b],y=e.persistentElements?.map(w=>w()).filter(Q);return y&&v.push(...y),v.some(w=>Oe(w,g))||Ce.isInNestedLayer(r,g)}let f=[o?Ff(r,e.persistentElements):void 0,If(r,p),kf(r,{exclude:m,onFocusOutside:h,onPointerDownOutside:u,defer:e.defer})];return ()=>{Ce.remove(r),ud(),Of(r),f.forEach(g=>g?.());}}function Na(r,e){let{defer:t}=e,n=t?ue:o=>o(),i=[];return i.push(n(()=>{let o=De(r)?r():r;i.push(VC(o,e));})),()=>{i.forEach(o=>o?.());}}function _C(r){return !(r.metaKey||!yr()&&r.altKey||r.ctrlKey||r.key==="Control"||r.key==="Shift"||r.key==="Meta")}var BC=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function HC(r,e,t){let n=t?fe(t):null,i=ce(n),o=ae(n),s=pt(i);return r=r||s instanceof o.HTMLInputElement&&!BC.has(s?.type)||s instanceof o.HTMLTextAreaElement||s instanceof o.HTMLElement&&s.isContentEditable,!(r&&e==="keyboard"&&t instanceof o.KeyboardEvent&&!Reflect.has(zC,t.key))}var Dt=null,hd=new Set,Va=new Map,zn=false,pd=false,Vf=false,zC={Tab:true,Escape:true};function Ba(r,e){for(let t of hd)t(r,e);}function _a(r){zn=true,_C(r)&&(Dt="keyboard",Ba("keyboard",r));}function Ue(r){Dt="pointer",(r.type==="mousedown"||r.type==="pointerdown")&&(zn=true,Ba("pointer",r));}function _f(r){Fp(r)&&(zn=true,Dt="virtual");}function Bf(r){let e=fe(r);e===ae(e)||e===ce(e)||Vf||!r.isTrusted||(!zn&&!pd&&(Dt="virtual",Ba("virtual",r)),zn=false,pd=false);}function Hf(){(zn=false,pd=true);}function $C(r){if(typeof window>"u"||Va.get(ae(r)))return;let e=ae(r),t=ce(r),n=e.HTMLElement.prototype.focus;function i(){zn=true,n.apply(this,arguments);}try{Object.defineProperty(e.HTMLElement.prototype,"focus",{configurable:!0,value:i});}catch{}t.addEventListener("keydown",_a,true),t.addEventListener("keyup",_a,true),t.addEventListener("click",_f,true),e.addEventListener("focus",Bf,true),e.addEventListener("blur",Hf,false),typeof e.PointerEvent<"u"?(t.addEventListener("pointerdown",Ue,true),t.addEventListener("pointermove",Ue,true),t.addEventListener("pointerup",Ue,true)):(t.addEventListener("mousedown",Ue,true),t.addEventListener("mousemove",Ue,true),t.addEventListener("mouseup",Ue,true)),e.addEventListener("beforeunload",()=>{WC(r);},{once:true}),Va.set(e,{focus:n});}var WC=(r,e)=>{let t=ae(r),n=ce(r);let i=Va.get(t);if(i){try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus});}catch{}n.removeEventListener("keydown",_a,true),n.removeEventListener("keyup",_a,true),n.removeEventListener("click",_f,true),t.removeEventListener("focus",Bf,true),t.removeEventListener("blur",Hf,false),typeof t.PointerEvent<"u"?(n.removeEventListener("pointerdown",Ue,true),n.removeEventListener("pointermove",Ue,true),n.removeEventListener("pointerup",Ue,true)):(n.removeEventListener("mousedown",Ue,true),n.removeEventListener("mousemove",Ue,true),n.removeEventListener("mouseup",Ue,true)),Va.delete(t);}};function zf(){return Dt}function $f(r){Dt=r,Ba(r,null);}function Nf(){return Dt==="keyboard"||Dt==="virtual"}function Wf(r={}){let{isTextInput:e,autoFocus:t,onChange:n,root:i}=r;$C(i),n?.({isFocusVisible:t||Nf(),modality:Dt});let o=(s,a)=>{HC(!!e,s,a)&&n?.({isFocusVisible:Nf(),modality:s});};return hd.add(o),()=>{hd.delete(o);}}var{not:Ye,and:Ar,or:GC}=bp(),md=oa({props({props:r}){return {closeOnSelect:true,typeahead:true,composite:true,loopFocus:false,navigate(e){Yp(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=$i(t,n);i({value:n,triggerElement:o});}})),pointerRoutingMode:r(()=>({defaultValue:"interactive"}))}},refs(){return {parent:null,children:{},pointerRoutingLocked:false,typeaheadState:{...ma.defaultOptions},positioningOverride:{}}},computed:{isRtl:({prop:r})=>r("dir")==="rtl",isTypingAhead:({refs:r})=>r.get("typeaheadState").keysSoFar!=="",highlightedId:({context:r,scope:e,refs:t})=>vf(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:Ye("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:GC("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:Ar(Ye("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:Ye("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:Ar("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:Ye("isPointerRoutingLocked"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:Ar(Ye("isPointerRoutingLocked"),Ye("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:Ar(Ye("isTriggerItemHighlighted"),Ye("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock"]},{guard:Ar(Ye("isTriggerItemHighlighted"),Ye("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock","focusTrigger"]},{guard:Ar(Ye("isTriggerItemHighlighted"),Ye("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})=>od(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})=>br(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 Wf({root:r.getRootNode?.()})},trackPositioning({context:r,prop:e,scope:t,refs:n}){if(af(t)||rd(t).length>0)return;let o={...e("positioning"),...n.get("positioningOverride")};return r.set("currentPlacement",o.placement),Ra(()=>$i(t,r.get("triggerValue")),()=>ed(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=>rd(e).some(c=>Oe(c,l));return Na(o,{type:"menu",defer:true,exclude:[td(e),...nd(e)].filter(Boolean),onInteractOutside:t("onInteractOutside"),onRequestDismiss:t("onRequestDismiss"),onFocusOutside(l){t("onFocusOutside")?.(l);let c=fe(l.detail.originalEvent);if(a(c)){l.preventDefault();return}if(sd(c,r.get("children"))){l.preventDefault();return}},onEscapeKeyDown(l){t("onEscapeKeyDown")?.(l),n.get("isSubmenu")&&l.preventDefault(),ld({parent:r.get("parent")});},onPointerDownOutside(l){t("onPointerDownOutside")?.(l);let c=fe(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;on(i,true);let o=e.getDoc();return Le(o,"pointermove",s=>{bf(r.get("intentPolygon"),{x:s.clientX,y:s.clientY})||(t({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),on(i,false));})},scrollToHighlightedItem({scope:r,computed:e}){let t=()=>{if(zf()==="pointer")return;let o=r.getById(e("highlightedId")),s=rt(r);Xp(o,{rootEl:s,block:"nearest"});};return ue(()=>{$f("virtual"),t();}),Up(()=>rt(r),{attributes:["aria-activedescendant"],callback:t})}},actions:{setAnchorPoint({context:r,event:e}){r.set("anchorPoint",t=>hr(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=()=>ed(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");Ra(()=>$i(e,c),o,{...l,defer:true,getAnchorRect:a,...n.options??{},listeners:false,onComplete(u){r.set("currentPlacement",u.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");Sp(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=gf(o,i);if(!s)return;let l=zi(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=yt(t);n?.send({type:"HIGHLIGHTED.SUGGEST",value:i});}on(n,false);},unlockParentOnClose({refs:r,context:e}){wf(r.get("parent"),e.get("isSubmenu"));},setHighlightedItem({context:r,event:e}){let t=e.value||rn(e.target);r.set("highlightedValue",t);},clearHighlightedItem({context:r}){r.set("highlightedValue",null);},focusMenu({scope:r}){ue(()=>{let e=rt(r);ua({root:e,enabled:!Oe(e,r.getActiveElement()),filter(n){return !n.role?.startsWith("menuitem")}})?.focus({preventScroll:true});});},highlightFirstItem({context:r,scope:e}){(rt(e)?queueMicrotask:ue)(()=>{let n=lf(e);n&&r.set("highlightedValue",rn(n));});},highlightLastItem({context:r,scope:e}){(rt(e)?queueMicrotask:ue)(()=>{let n=cf(e);n&&r.set("highlightedValue",rn(n));});},highlightNextItem({context:r,scope:e,event:t,prop:n}){let i=df(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",rn(i));},highlightPrevItem({context:r,scope:e,event:t,prop:n}){let i=uf(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",rn(i));},invokeOnSelect({context:r,prop:e,scope:t}){let n=r.get("highlightedValue");if(n==null)return;let i=sf(t,n);pf(i,n),e("onSelect")?.({value:n});},focusTrigger({scope:r,context:e,event:t}){e.get("isSubmenu")||e.get("anchorPoint")||t.restoreFocus===false||queueMicrotask(()=>{$i(r,e.get("triggerValue"))?.focus({preventScroll:true});});},highlightMatchedItem({scope:r,context:e,event:t,refs:n}){let i=hf(r,{key:t.key,value:e.get("highlightedValue"),typeaheadState:n.get("typeaheadState")});i&&e.set("highlightedValue",rn(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(!od(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&&Fa(l,e.point)||(rt(t)?.focus({preventScroll:true}),a.send({type:"CLOSE"}));}},closeRootMenu({refs:r}){ld({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",rn(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")&&xf(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 Gf(r){return {machine:md,props:{id:r.id??xa("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=>cd(e,Tr)}}var Uf="vela-ui-menu",Yf=`
|
|
1
|
+
var Vela=(function(exports){'use strict';function be(r){return r.kind!=="candle"&&r.kind!=="bar"&&r.kind!=="markers"}var hn=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 Oo=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 ei=new Map;function Qn(r){ei.set(r.type,r);}function nh(r){ei.delete(r);}function ti(r){return ei.get(r)}function rh(){return [...ei.keys()]}function Fo(){return [...ei.values()]}var No=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 er=class{constructor(e,t,n,i){this.controller=n;this.schema=[];this.visibleState=true;this.bus=new hn;this.id=e,this.title=t,i!==void 0&&(this.source=i);}get inputs(){return this.schema}get visible(){return this.visibleState}setInput(e,t){this.controller.applyInputs(this.id,{[e]:t});}setInputs(e){this.controller.applyInputs(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;}setVisibleState(e){this.visibleState=e;}emit(e,t){this.bus.emit(e,t);}};function Hy(r){let e={};for(let t of r.series)e[t.kind]=(e[t.kind]??0)+1;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}}function ih(r){let e=r.map(Hy),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)}}}var zy={"1D":864e5,"1W":6048e5,"1M":2592e6,"3M":7776e6,"6M":15552e6,"1Y":31536e6,"5Y":15768e7};function oh(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-zy[r],{from:Math.max(t,i),to:n}}var Te="#2962ff",tr="#38c0fd",J="#089981",X="#f23645",Ee="#787b86",ah="#e0b400",pn="#ff9800",Ct="#5b9cf6",lh="#ff5d00",Vo="#0ecb81",_o="#f6465d",yM="#f97316",wM="#0ea5e9",xM="#9ca3af",ni="#3b82f6",ch="#9aa0ad",dh="#1e293b",Bo="#475569",uh=Te,hh=X,ph="#d500f9",sh=[Te,J,X,pn,"#7e57c2","#26a69a",Ct,"#e573b5"];function SM(r){let e=0;for(let t=0;t<r.length;t++)e=e*31+r.charCodeAt(t)>>>0;return sh[e%sh.length]}var R=tr;function ic(){return {lineColor:R,lineWidth:2,lineStyle:"solid"}}function Tt(r=""){return {value:r,size:"normal",hAlign:"left",vAlign:"top"}}var Ho=class Ho{constructor(e){this.locked=false;this.visible=true;this.zIndex=0;this.id=e.id??`dw-${Ho.seq+=1}`,this.paneId=e.paneId,this.anchors=(e.anchors??[]).map(t=>({time:t.time,price:t.price})),this.style=e.style?{...e.style}:ic(),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=Tt()),mh(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){}};Ho.seq=0;var V=Ho;function mh(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 oc=new Map;function D(r,e){oc.set(r,e);}function zo(r){return oc.get(r)??null}function $(r){return oc.get(r)??""}function me(r,e){return $(r).replace("<svg ",`<svg width="${e}" height="${e}" `)}function fh(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 A(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 sc(r){return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${r}</svg>`}var B=fh;D("style-candles",B('<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"/>'));D("style-bars",B('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>'));D("style-line",B('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));D("style-area",B('<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"/>'));D("style-baseline",B('<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"/>'));D("style-heikinashi",B('<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"/>'));D("indicators",B('<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"/>'));D("undo",B('<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"/>'));D("redo",B('<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"/>'));D("objects",B('<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"/>'));D("clock",B('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));D("calendar",B('<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"/>'));D("datawindow",B('<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"/>'));D("camera",B('<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"/>'));D("gear",B('<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"/>'));D("search",B('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));D("bell",B('<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"/>'));D("market-open",A('<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"/>'));D("market-pre",A('<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="m16 6-4 4-4-4"/><path d="M16 18a4 4 0 0 0-8 0"/>'));D("market-post",A('<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 18-4-4-4 4"/><path d="M16 6a4 4 0 0 0-8 0"/>'));D("market-closed",A('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));D("market-holiday",A('<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"/>'));D("chevron-right",B('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));D("chevron-left",B('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));D("chevron-down",B('<path d="M3.5 6 8 10.5 12.5 6"/>'));D("chevron-up",B('<path d="M3.5 10 8 5.5 12.5 10"/>'));D("chevrons-right",B('<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"/>'));D("chevrons-left",B('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));D("check",B('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));D("close",B('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));D("eye",B('<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"/>'));D("eye-off",B('<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"/>'));D("lock",B('<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"/>'));D("unlock",B('<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"/>'));D("trash",B('<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"/>'));D("group",B('<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"/>'));D("ungroup",B('<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"/>'));D("clone",B('<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"/>'));D("arrow-up",B('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));D("arrow-down",B('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));D("move-vertical",B('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));D("move",B('<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"/>'));D("pen",B('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));D("wave",B('<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"/>'));D("folder-plus",B('<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"/>'));D("folder-minus",B('<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"/>'));D("collapse",B('<path d="M3 8h10"/>'));D("expand",B('<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"/>'));D("maximize",B('<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"/>'));D("restore",B('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));D("star",B('<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"/>'));D("star-filled",B('<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"'));D("grip",B('<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"'));D("kebab",B('<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"'));D("burger",B('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));D("reset",B('<rect x="6" y="6" width="4" height="4" rx="0.8"/><path d="M2.2 8a5.8 5.8 0 1 0 1.9-4.3L2.2 5.3"/><path d="M2.2 2.2v3.1h3.1"/>'));D("pane-collapse",B('<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"/>'));D("pane-expand",B('<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"/>'));D("cursor",A('<path d="M5 3l6 16 2-6 6-2z"/>','fill="currentColor" stroke="none"'));D("ruler",A('<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"/>'));D("magnet",A('<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"/>'));D("eraser",A('<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"/>'));D("pen-lock",A('<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"/>'));D("pen-sync",A('<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"/>'));D("brush",A('<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"/>'));D("bucket",A('<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"/>'));D("type",A('<path d="M5 6V4.5h14V6"/><path d="M12 4.5v15"/><path d="M9.5 19.5h5"/>'));D("bold",A('<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"'));D("italic",A('<path d="M15 5h-5M14 19H9M14.5 5 10 19"/>','stroke-width="2.2"'));D("price-delta",A('<path d="M12 4v16"/><path d="M8 8l4-4 4 4"/><path d="M8 16l4 4 4-4"/>'));D("date-delta",A('<path d="M4 12h16"/><path d="M8 8l-4 4 4 4"/><path d="M16 8l4 4-4 4"/>'));D("bring-front",A('<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"/>'));D("send-back",A('<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"/>'));D("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>');D("bands",A('<path d="M3 6h18"/><path d="M3 18h18"/><path d="M3 12h18" stroke-dasharray="3 3"/>'));D("dedekind",A('<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"/>'));D("sonic",A('<circle cx="15" cy="12" r="4"/><circle cx="12" cy="12" r="2.5"/><path d="M8 5v14"/>'));D("supersonic",A('<circle cx="16" cy="12" r="3.5"/><path d="M6 12 15 6M6 12 15 18"/>'));var Pe=[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}],F=[{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:Pe,group:"line"}],ee=[{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"}],qe=[{value:"small",label:"Small"},{value:"normal",label:"Normal"},{value:"large",label:"Large"},{value:"huge",label:"Huge"}],N=[{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:qe,group:"text"},{path:"text.bold",label:"Bold",kind:"boolean",group:"text"},{path:"text.italic",label:"Italic",kind:"boolean",group:"text"}];function j(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 nr(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=j(r,e,o[0],o[1],s[0],s[1]);a<n&&(n=a);}return n}function xe(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,d=Math.max(n,o)+s;return r>=a&&r<=l&&e>=c&&e<=d}function ot(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 ac(r,e,t,n,i,o,s,a){let l=t-r,c=n-e,d=s-i,u=a-o,h=d*c-u*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*d,o+p*u]}function H(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 d=(n-e)/a,u=m=>e+d*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,u(h),p,u(p)]}var $o=class extends V{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&&j(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 H(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:[...F,{path:"style.arrowRight",label:"Arrow",kind:"boolean",group:"line"},...N]}}};var Wo=class extends V{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 H(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:[...F,...N]}}};var Go=class extends V{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,d]=se(s[0],s[1],s[2],s[3],"right",i.width,i.height);return j(t,n,a,l,c,d)<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return H(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:[...F,...N]}}};var Ut=class extends V{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&&j(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 H(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:[...F,...N]}}};var Uo=class extends Ut{constructor(){super(...arguments);this.type="extendedline";}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,d]=se(s[0],s[1],s[2],s[3],"both",i.width,i.height);return j(t,n,a,l,c,d)<=o}timeExtent(){return null}};var Yo=class extends V{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 H(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:[...F,...N]}}};var Ko=class extends V{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&&j(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 H(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:[...F,...N]}}};var Xo=class extends V{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 H(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:[...F,...N]}}};var jo=class extends Ut{constructor(){super(...arguments);this.type="infoline";}};var qo=class extends Ut{constructor(){super(...arguments);this.type="trendangle";}};var Zo=class extends V{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&&xe(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=>j(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 H(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:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"},...N]}}};var $y={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},Yt=class extends V{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=$y[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&&xe(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 H(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 Et=class extends Yt{constructor(t){super(t);this.type="text";this.text||(this.text={...Tt(),size:"large"});}schema(){return {fields:[...N],textIsContent:true}}};var mn=class extends Yt{constructor(t){super(t);this.type="note";this.text||(this.text=Tt("Note"));}defaultLabel(){return "Note"}schema(){return {fields:[...F,...ee,...N],textIsContent:true}}};var fn=class extends Yt{constructor(){super(...arguments);this.type="pricelabel";}labelText(){let t=this.anchors[0]?.price;return t==null?"0.00":t.toFixed(2)}schema(){return {fields:[...F,...ee,...N.filter(t=>t.path!=="text.value")]}}};var Wy={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},ze=class extends V{constructor(e){super(e),this.text||(this.text=Tt(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=Wy[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&&xe(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&&j(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 H(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:[...F,...ee,...N],textIsContent:true}}};var st=class extends ze{constructor(){super(...arguments);this.type="callout";}};var gn=class extends ze{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:[...F,...ee,...N.filter(t=>t.path!=="text.value")]}}};var bn=class extends ze{constructor(){super(...arguments);this.type="comment";}defaultLabel(){return "Comment"}};var vn=class extends ze{constructor(){super(...arguments);this.type="signpost";}defaultLabel(){return "Signpost"}};var te=class extends V{hitTest(e,t,n,i){let o=this.geometry(n);return o?this.style.fillColor&&o.fill&&ot(e,t,o.fill)?true:o.segments.some(s=>j(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 H(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 Jo=class extends te{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),d=t.yOf(n.price+o,this.paneId),u=t.yOf(i.price+o,this.paneId);return l==null||c==null||d==null||u==null?null:{segments:[[s,l,a,c],[s,d,a,u]],fill:[[s,l],[a,c],[a,u],[s,d]]}}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:[...F,...ee,...N]}}};var Qo=class extends te{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:[...F,...ee,...N]}}};var es=class extends te{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 d=t.yOf(c.price,this.paneId);return d==null?null:{segments:[[o,a,s,l],[o,d,s,d]],fill:[[o,a],[s,l],[s,d],[o,d]]}}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:[...F,...ee,...N]}}};var Gy=2;function gh(){return {midColor:Ee,midStyle:"solid",upperColor:J,upperStyle:"solid",lowerColor:X,lowerStyle:"solid",upperFill:`${J}26`,lowerFill:`${X}26`,showR2:true}}function bh(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,d=0;for(let m=0;m<e;m+=1){let f=r[m].close-(c+l*m);d+=f*f;}let u=Math.sqrt(d/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:Gy*u,r2:Math.max(0,Math.min(1,p*p)),n:e}}var Pt=class extends V{constructor(t){super(t);this.type="regressionchannel";this.cachedRange=null;this.reg||(this.reg=gh());}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?bh(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 ot(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=>j(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 H(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={...gh(),...t};}};var vh=`${Ct}00`;function yh(){return {midColor:Ct,midStyle:"solid",multiplier:1,upperColor:vh,upperStyle:"solid",lowerColor:vh,lowerStyle:"solid",bandFill:`${Ct}33`}}function wh(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 d=r[c],u=(d.high+d.low+d.close)/3,h=i?Math.max(0,d.volume):1;o+=h,s+=u*h,a+=u*u*h;let p=o>0?s/o:u,m=o>0?Math.max(0,a/o-p*p):0,f=Math.sqrt(m)*e;l.push({time:d.time,mid:p,upper:p+f,lower:p-f});}return l}var yn=class extends V{constructor(t){super(t);this.type="anchoredvwap";this.cachedRange=null;this.cachedExtent=null;this.vwap||(this.vwap=yh());}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=wh(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),d=t.yOf(a.upper,this.paneId),u=t.yOf(a.lower,this.paneId);c==null||d==null||u==null||(i.push([l,c]),o.push([l,d]),s.push([l,u]));}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?ot(t,n,this.bandPolygon(s))?true:lc(t,n,s.mid,o)||lc(t,n,s.upper,o)||lc(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 H(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={...yh(),...t};}};function lc(r,e,t,n){for(let i=1;i<t.length;i+=1)if(j(r,e,t[i-1][0],t[i-1][1],t[i][0],t[i][1])<=n)return true;return false}var Uy=`${J}66`,Yy=`${X}66`,Ky=`${J}BF`,Xy=`${X}BF`;function xh(){return {rows:24,valueAreaPct:70,widthPct:35,anchor:"left",upColor:Uy,downColor:Yy,vaUpColor:Ky,vaDownColor:Xy,showVah:true,vahColor:Ee,vahStyle:"solid",showVal:true,valColor:Ee,valStyle:"solid",showPoc:true,pocColor:void 0,pocStyle:"solid",showDevelopingPoc:false,developingPocColor:Te,developingPocStyle:"dotted",showDevelopingVa:false,developingVaColor:Te,developingVaStyle:"dotted"}}function jy(r,e){return r<0?0:r>=e?e-1:r}function Sh(r,e,t){let n=r.length,i=0,o=0;for(let d=0;d<n;d+=1){let u=r[d].up+r[d].down;i+=u,u>o&&(o=u);}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 d=a>0?r[a-1].up+r[a-1].down:-1,u=l<n-1?r[l+1].up+r[l+1].down:-1;u>d?(l+=1,c+=u):(a-=1,c+=d);}return {vaFrom:a,vaTo:l}}function Ch(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(jy(Math.floor((l-e)/t),o));for(let l of a)r[l][s]+=i;}function Th(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 Eh(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)Ch(a,n,s,p);let l=Th(a);if(!l)return null;let{poc:c,maxTotal:d}=l,{vaFrom:u,vaTo:h}=Sh(a,c,t);return {rows:a,rowH:s,min:n,maxTotal:d,poc:c,vaFrom:u,vaTo:h}}function Ph(r,e,t,n){let i=Eh(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=[],d=[],u=[];for(let h of r){Ch(l,o,s,h);let p=Th(l);if(!p)continue;let{poc:m}=p,{vaFrom:f,vaTo:g}=Sh(l,m,t);c.push({time:h.time,price:l[m].price+s/2}),d.push({time:h.time,price:l[g].price+s}),u.push({time:h.time,price:l[f].price});}return {profile:i,developingPoc:c,developingVaHigh:d,developingVaLow:u}}var Ve=class extends V{constructor(t){super(t);this.type="fixedrangevp";this.cachedRange=null;this.frvp||(this.frvp=xh());}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=Ph(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),d=t.xOf(l),u=Math.abs(d-c),h=Math.max(1,Math.min(100,Math.max(0,this.frvp.widthPct))/100*u),p=this.frvp.anchor==="left",m=p?Math.min(c,d):Math.max(c,d),f=p?1:-1,g=[];for(let x=0;x<=s.rows.length;x+=1){let S=t.yOf(s.min+x*s.rowH,this.paneId);if(S==null)return null;g.push(S);}let b=x=>t.yOf(x,this.paneId),v=s.rows[s.vaTo].price+s.rowH,y=s.rows[s.vaFrom].price,w=s.rows[s.poc].price+s.rowH/2,P=x=>{let S=[];for(let E of x){let L=b(E.price);L!=null&&S.push([t.xOf(E.time),L]);}return S};return {x0:Math.min(c,d),x1:Math.max(c,d),anchorX:m,maxW:h,grow:f,profile:s,yEdges:g,vahY:b(v),valY:b(y),pocY:b(w),developingPoc:P(o.developingPoc),developingVaHigh:P(o.developingVaHigh),developingVaLow:P(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]),d=Math.max(s.yEdges[0],s.yEdges[s.yEdges.length-1]);if(ot(t,n,[[a,c],[l,c],[l,d],[a,d]]))return true;let u=[[s.x0,s.vahY],[s.x0,s.valY],[s.x0,s.pocY]];for(let[,h]of u)if(h!=null&&j(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(j(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 H(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:Pe,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:Pe,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:Pe,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:Pe,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:Pe,group:"line"}]}}writeProps(){return {...this.frvp}}readProps(t){this.frvp={...xh(),...t};}};var ts=class extends te{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 d=(l[0]+c[0])/2,u=(l[1]+c[1])/2,h=d-a[0],p=u-a[1],m=t.width,f=t.height;return {segments:[se(a[0],a[1],d,u,"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:[...F,...N]}}};var rr=class extends te{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,d=(a[1]+l[1])/2,u=c-s[0],h=d-s[1],p=e.width,m=e.height;return {segments:[se(s[0],s[1],c,d,"right",p,m),se(a[0],a[1],a[0]+u,a[1]+h,"right",p,m),se(l[0],l[1],l[0]+u,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:[...F,...N]}}};var ns=class extends rr{constructor(){super(...arguments);this.type="schiffpitchfork";}medianStart(t,n){return {time:t.time,price:(t.price+n.price)/2}}};var rs=class extends rr{constructor(){super(...arguments);this.type="modifiedschiffpitchfork";}medianStart(t,n){return {time:(t.time+n.time)/2,price:(t.price+n.price)/2}}};var is=class extends te{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 v=t.yOf(b.price,this.paneId);return v==null?null:[t.xOf(b.time),v]},a=s({time:(n.time+i.time)/2,price:(n.price+i.price)/2}),l=s(n),c=s(i),d=s(o);if(!a||!l||!c||!d)return null;let u=(c[0]+d[0])/2,h=(c[1]+d[1])/2,p=d[0]-a[0],m=d[1]-a[1],f=t.width,g=t.height;return {segments:[se(u,h,u+p,h+m,"right",f,g),se(c[0],c[1],c[0]+p,c[1]+m,"right",f,g),se(d[0],d[1],d[0]+p,d[1]+m,"right",f,g),[c[0],c[1],d[0],d[1]],[a[0],a[1],d[0],d[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:[...F,...N]}}};var os=class extends V{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&&j(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 H(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:[...F,{path:"style.arrowRight",label:"Head (end)",kind:"boolean",group:"line"},{path:"style.arrowLeft",label:"Head (start)",kind:"boolean",group:"line"},...N]}}};var Lh=48,ss=class extends V{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<=Lh;i+=1){let o=i/Lh*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:nr(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 H(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:[...F,...ee,...N]}}};var as=class extends te{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=d=>{let u=t.yOf(d.price,this.paneId);return u==null?null:[t.xOf(d.time),u]},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:[...F,...ee,...N]}}};var qy=512,Kt=class extends te{anchorSchema(){return {min:2,max:qy,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:[...F,...N]}}};var ls=class extends Kt{constructor(){super(...arguments);this.type="polyline";}};var ri=class extends Kt{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}}},cs=class extends ri{constructor(){super(...arguments);this.type="freehand";}};var Zy=[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Width",kind:"number",min:4,max:60,step:1,group:"line"}],ds=class extends ri{constructor(){super(...arguments);this.type="highlighter";}schema(){return {fields:Zy}}};var us=class extends V{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 H(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:[...F,...ee,...N]}}};var hs=class extends te{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,d=s/l,u=(o[0]-n[0])*c+(o[1]-n[1])*d,h=c*u,p=d*u,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:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var ps=class extends Kt{constructor(){super(...arguments);this.type="path";}};var Mh=40,ms=class extends te{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,d=(i[1]-n[1])/2,u=Math.hypot(c,d);if(u<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let h=-d/u,p=c/u,m=(s-l)*p;m<0&&(h=-h,p=-p);let f=Math.abs(m),g=[];for(let v=0;v<=Mh;v+=1){let y=v/Mh*Math.PI,w=Math.cos(y),P=Math.sin(y);g.push([a+w*c+P*f*h,l+w*d+P*f*p]);}let b=[];for(let v=1;v<g.length;v+=1)b.push([g[v-1][0],g[v-1][1],g[v][0],g[v][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:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var kh=40,fs=class extends te{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<=kh;l+=1){let c=l/kh,d=1-c;s.push([d*d*n[0]+2*d*c*o[0]+c*c*i[0],d*d*n[1]+2*d*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:[...F,...ee,...N]}}};var Jy={head:11,headW:9,stemW:3.5,len:22},wn=class extends V{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}=Jy,c=[[0,0],[-s,o],[-a,o],[-a,l],[a,l],[a,o],[s,o]],d=this.dir(),u=([h,p])=>{switch(d){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]=u(h);return [i+p,n+m]})}hitTest(e,t,n,i){let o=this.glyphPoints(n);return o!=null&&ot(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 H(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"},...N]}}},ii=class extends wn{constructor(){super(...arguments);this.type="arrowmarkup";}dir(){return "up"}},oi=class extends wn{constructor(){super(...arguments);this.type="arrowmarkdown";}dir(){return "down"}};var li=["\u2605","\u2606","\u25CF","\u25C6","\u25B2","\u25BC","\u27A4","\u2691","\u271A","\u2715","\u2764","\u2666"],gs=["small","normal","large","huge"],Ih={small:16,normal:22,large:32,huge:44},xn=class extends V{constructor(e){super(e),this.glyph||(this.glyph=this.defaultGlyph()),this.size||(this.size="normal");}sizePx(){return Ih[this.size]??Ih.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 H(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:li.map(e=>({value:e,label:e})),group:"line"},{path:"size",label:"Size",kind:"select",options:gs.map(e=>({value:e,label:e})),group:"line"},{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...N]}}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);}},si=class extends xn{constructor(){super(...arguments);this.type="flagmark";}defaultGlyph(){return "\u2691"}},ai=class extends xn{constructor(){super(...arguments);this.type="iconstamp";}defaultGlyph(){return "\u2605"}};var Ah=r=>r==="small"||r==="normal"||r==="large"||r==="huge";function Qy(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 re=class extends V{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=>j(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 H(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:F.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(Qy).filter(n=>n!=null);t.length&&(this.levels=t);}Ah(e.numbersSize)&&(this.numbersSize=e.numbersSize),Ah(e.labelsSize)&&(this.labelsSize=e.labelsSize);}};var ir=class extends re{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 d of this.levels){if(!d.enabled)continue;let u=t.price+d.ratio*l,h=e.yOf(u,this.paneId);h!=null&&c.push({ratio:d.ratio,color:d.color,label:d.label,price:u,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 Sn=Ee,at=X,lt=pn,Cn="#4caf50",Xt=J,Lt=Ct,Tn="#9c27b0",ew="#e91e63",cc="#26a69a",tw="#ab47bc",nw="#ef5350",Rh="#ffb74d",rw="#38c0fd",bs="#b2b5be",or=[rw,Lt,Xt,Cn,lt,at,ew,Tn,Sn,cc,tw,nw];function Dh(r){return or[(r%or.length+or.length)%or.length]}var iw=[[0,Sn],[.125,at],[.236,at],[.25,at],[.382,lt],[.5,Cn],[.618,Xt],[.75,Lt],[.786,Lt],[1,Sn],[1.272,Lt],[1.382,lt],[1.618,at],[2,Sn],[2.382,lt],[2.618,lt],[3,Sn],[4.236,Cn],[6.854,Xt],[11.09,Lt]];function ow(r,e=0){return iw.find(([t])=>t===r)?.[1]??Dh(e)}function ne(r){return r.map((e,t)=>{let n=typeof e=="number"?{ratio:e}:e;return {ratio:n.ratio,color:n.color??ow(n.ratio,t),enabled:n.enabled!==false,...n.label?{label:n.label}:{}}})}function Oh(r,e=r){return Array.from({length:r},(t,n)=>({ratio:n+1,color:Dh(n),enabled:n<e,label:String(n+1)}))}var sw=ne([0,.236,.382,.5,.618,.786,1]),vs=class extends ir{constructor(){super(...arguments);this.type="fibretracement";}defaultLevels(){return sw}};var aw=ne([0,.382,.618,1,1.272,1.618,{ratio:2.618,color:Tn}]),ys=class extends ir{constructor(){super(...arguments);this.type="fibextension";}defaultLevels(){return aw}};var lw=ne([0,.382,.5,.618,1,1.618,{ratio:2.618,color:Tn}]),ws=class extends re{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 lw}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),d=[];for(let u of this.levels){if(!u.enabled)continue;let h=o.price+u.ratio*s,p=t.yOf(h,this.paneId);p!=null&&d.push({color:u.color,label:u.label,x1:l,y1:p,x2:c,y2:p,numberText:`${u.ratio} (${h.toFixed(2)})`,numberX:l+4,numberY:p-7,numberAlign:"left",labelX:(l+c)/2,labelY:p-7});}return d}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 cw=ne([.236,.382,.5,.618,.786,1]),xs=class extends re{constructor(){super(...arguments);this.type="fibfan";}defaultLevels(){return cw}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 d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+d.ratio*l,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({ratio:d.ratio,color:d.color,label:d.label,x1:h,y1:p,x2:m,y2:f,labelX:a+5,labelY:u});}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 dw=[0,1,2,3,5,8,13,21,34].map(r=>({ratio:r,color:R,enabled:true})),Ss=class extends re{constructor(){super(...arguments);this.type="fibtimezones";}defaultLevels(){return dw}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 uw=ne([0,.236,.382,.5,.618,.786,1,1.618,2.618]),Cs=class extends re{constructor(){super(...arguments);this.type="fibchannel";}defaultLevels(){return uw}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,d=0,u=this.anchors[2];if(u){let p=t.yOf(u.price,this.paneId);if(p==null)return null;c=t.xOf(u.time)-a,d=p-o;}let h=[];for(let p of this.levels){if(!p.enabled)continue;let m=p.ratio*c,f=p.ratio*d,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 d=c+l.ratio*o;d<s&&(s=d),d>a&&(a=d);}return s<=a?{min:s,max:a}:null}};var hw=ne([0,.236,.382,.5,.618,.786,1]),Ts=class extends re{constructor(){super(...arguments);this.type="fibspeedfan";}defaultLevels(){return hw}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,d=s-o,u=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+d*f.ratio,v=se(a,o,g,b,u,h,p);if(m.push({color:f.color,label:f.label,x1:v[0],y1:v[1],x2:v[2],y2:v[3],numberText:String(f.ratio),numberX:u==="right"?g+5:g-5,numberY:b,numberAlign:u==="right"?"left":"right",labelX:g,labelY:b}),f.ratio===1)continue;let y=a+c*f.ratio,w=o+d,P=se(a,o,y,w,u,h,p);m.push({color:f.color,label:f.label,x1:P[0],y1:P[1],x2:P[2],y2:P[3],numberText:String(f.ratio),numberX:y,numberY:w+(d>=0?12:-12),numberAlign:"center",labelX:y,labelY:w+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 pw=ne([0,.382,{ratio:.5,enabled:false},.618,1,1.382,1.618,2,2.382,2.618,3]),Es=class extends re{constructor(){super(...arguments);this.type="trendfibtime";}defaultLevels(){return pw}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 d=t.xOf(o.time+c.ratio*s);l.push({color:c.color,label:c.label,x1:d,y1:0,x2:d,y2:a,numberText:String(c.ratio),numberX:d,numberY:9,numberAlign:"center",labelX:d,labelY:24});}return l}priceRange(){return null}timeExtent(){return null}};function mw(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 Ze=class extends re{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(mw(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=>j(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 fw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),Ps=class extends Ze{constructor(){super(...arguments);this.type="fibcircles";}defaultLevels(){return fw}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 gw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),Ls=class extends Ze{constructor(){super(...arguments);this.type="fibarcs";}defaultLevels(){return gw}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 bw=ne([.236,.382,.5,.618,.786,1]),Ms=class extends Ze{constructor(){super(...arguments);this.type="fibwedge";}defaultLevels(){return bw}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),d=Math.max(a,l);return d-c>Math.PI&&([c,d]=[d,c+Math.PI*2]),{cx:n[0],cy:n[1],R0:s,a0:c,a1:d}}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 vw=1.6180339887,Fh=Math.log(vw)/(Math.PI/2),yw=Math.PI/64,ww=Math.PI,xw=.5,En=class extends V{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 d=Math.atan2(s-o,l-a),u=Math.max(Math.log(xw/c)/Fh,-8*Math.PI*2),h=[];for(let p=u;p<=ww;p+=yw){let m=c*Math.exp(Fh*p),f=d+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&&nr(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 H(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:[...F,...N]}}};var Sw=ne([{ratio:.125,color:at,label:"1/8"},{ratio:.25,color:lt,label:"1/4"},{ratio:.333,color:Rh,label:"1/3"},{ratio:.5,color:Cn,label:"1/2"},{ratio:1,color:bs,label:"1/1"},{ratio:2,color:Xt,label:"2/1"},{ratio:3,color:Lt,label:"3/1"},{ratio:4,color:cc,label:"4/1"},{ratio:8,color:Tn,label:"8/1"}]),ks=class extends re{constructor(){super(...arguments);this.type="gannfan";}defaultLevels(){return Sw}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 d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+l*d.ratio,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({color:d.color,x1:h,y1:p,x2:m,y2:f,numberText:d.label??String(d.ratio),numberX:a+5,numberY:u,numberAlign:"left",labelX:a+5,labelY:u});}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 Cw=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),Is=class extends re{constructor(){super(...arguments);this.type="gannbox";}defaultLevels(){return Cw}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,d=[];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&&d.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));d.push({color:h.color,x1:m,y1:l,x2:m,y2:c,numberText:"",numberX:m,numberY:l,numberAlign:"center",labelX:m,labelY:l});}let u=this.levels.find(h=>h.ratio===1)?.color??Sn;return d.push({color:u,x1:s,y1:l,x2:a,y2:c,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d.push({color:u,x1:s,y1:c,x2:a,y2:l,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d}hitTest(t,n,i,o){let s=this.corners(i);return s!=null&&xe(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 Tw=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),Ew=[{label:"3x1",x:3,y:1,color:at},{label:"2x1",x:2,y:1,color:lt},{label:"1x1",x:1,y:1,color:bs},{label:"1x2",x:1,y:2,color:Xt},{label:"1x3",x:1,y:3,color:Lt}],dc=[{k:.25,color:at},{k:.5,color:lt},{k:.75,color:Cn},{k:1,color:Xt}],Pn=class extends re{constructor(){super(...arguments);this.type="gannsquare";}defaultLevels(){return Tw}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 Ew){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&&xe(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 uc=[4,8,12,16,24,32,48,64],Pw=24,Lw=.75;function Nh(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 Vh(r){let e=[];for(let t=0;t<r;t+=1)Nh(t,r)&&e.push(t);return e}var Ln=class extends V{constructor(t){super(t);this.type="dedekind";this.maxCurvature===void 0&&(this.maxCurvature=Pw);}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),d=Math.max(o,s),u=l-a,h=d-c;if(u<1||h<1)return null;let p=h,m=u/p;return {left:a,right:l,top:c,bot:d,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,d=Math.max(1,Math.min(64,Math.round(this.maxCurvature))),u=l-1/d,h=l+c+1/d,p=i+c*a,m=[],f=Math.floor(u*2),g=Math.ceil(h*2);for(let b=f;b<=g;b+=1){if(b%2===0)continue;let v=i+(b/2-l)*a;v<i-.5||v>p+.5||m.push({kind:"vline",x:v,y0:s,y1:o});}for(let b=1;b<=d;b+=1){let v=1/b,y=v*a;if(y<Lw)continue;let w=Vh(b);if(w.length===0)continue;let P=Math.floor(u)-1,x=Math.ceil(h)+1;for(let S=P;S<=x;S+=1)for(let E of w){let L=E/b+S;if(L+v<u||L-v>h)continue;let T=i+(L-l)*a;T+y<i-1||T-y>p+1||m.push({kind:"arc",cx:T,cy:s,r:y});}}return m}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&xe(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 H(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:[...F,{path:"maxCurvature",label:"Max curvature",kind:"number",min:4,max:64,step:4,group:"behavior"},...N]}}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 hc=[3,4,5,6,8,10,12],pc=[1.5,2,2.5,3,4,5],As=6,Mw=2;function mc(r=As){return [...Oh(or.length,r)]}function kw(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 sr={path:"showRatios",label:"Show ratios",kind:"boolean",group:"behavior"},Ae=class extends V{constructor(e){super(e),this.waveCount===void 0&&(this.waveCount=As),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,d=Math.hypot(a-s,o-i)/2;if(d<1)return null;let u=a-s,h=o-i,p=Math.hypot(u,h);p<1e-9?(u=1,h=0):(u/=p,h/=p);let m=this.levels.filter(x=>x.enabled&&x.ratio>0).slice().sort((x,S)=>x.ratio-S.ratio);if(m.length===0)return null;let f=Math.max(1,this.machNumber()),g=[];for(let x of m){let S=x.ratio*d;g.push({cx:l+f*(S-d)*u,cy:c+f*(S-d)*h,r:S,color:x.color,ratio:x.ratio});}let b=l-f*d*u,v=c-f*d*h,y=g[g.length-1].r,w=f*y+2*d,P=[];if(f<=1+1e-9){let x=-h,S=u;P.push([b-x*w,v-S*w,b+x*w,v+S*w]);}else {let x=Math.asin(1/f),S=Math.cos(x),E=Math.sin(x),L=(I,_,U)=>[I*S-_*U*E,I*U*E+_*S],[T,k]=L(u,h,1),[M,C]=L(u,h,-1);P.push([b,v,b+T*w,v+k*w]),P.push([b,v,b+M*w,v+C*w]);}return {c0x:l,c0y:c,R:d,fx:u,fy:h,noseX:b,noseY:v,circles:g,rays:P}}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=>j(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 H(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:[...F,{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},sr,...N]}}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(kw).filter(n=>n!=null);t.length&&(this.levels=t);}}},ci=class extends Ae{constructor(){super(...arguments);this.type="sonic";}defaultLevels(){return mc(As)}machNumber(){return 1}},di=class extends Ae{constructor(t){super(t);this.type="supersonic";this.mach===void 0&&(this.mach=Mw);}defaultLevels(){return mc(As)}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{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"},sr,...N]}}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 _h=ne([.236,.382,.5,.618,.786,1,1.618,2.618,4.236,6.854,11.09]),Iw=2,Rs=class extends Ae{constructor(){super(...arguments);this.type="goldensonic";}shouldSyncWaveCount(){return false}defaultLevels(){return _h}machNumber(){return 1}schema(){return {fields:[...F,sr,...N]}}},Ds=class extends Ae{constructor(t){super(t);this.type="goldensupersonic";this.mach===void 0&&(this.mach=Iw);}shouldSyncWaveCount(){return false}defaultLevels(){return _h}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},sr,...N]}}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 ge=class extends V{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&&nr(e,t,o)<=i}hitHandle(e,t,n,i){return H(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:[...F,...this.fillTriangles().length?ee:[]]}}};var Os=class extends ge{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 Fs=class extends ge{constructor(){super(...arguments);this.type="abcd";}vertexLabels(){return ["A","B","C","D"]}legRatios(){return true}};var Ns=class extends ge{constructor(){super(...arguments);this.type="elliottimpulse";}vertexLabels(){return ["1","2","3","4","5"]}};var Vs=class extends ge{constructor(){super(...arguments);this.type="elliottcorrection";}vertexLabels(){return ["A","B","C"]}};var _s=class extends ge{constructor(){super(...arguments);this.type="headshoulders";}vertexLabels(){return ["","LS","","H","","RS",""]}necklineIndices(){return [2,4]}};var Re=class extends ge{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=(u,h)=>Math.abs(h.price-u.price),l=a(t,n),c=a(n,i),d=a(i,o);switch(e){case "ab":return l<1e-9?null:c/l;case "bc":return c<1e-9?null:d/c;case "cd":return d<1e-9?null:a(o,s)/d;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 Bs=class extends Re{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 Hs=class extends Re{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 zs=class extends Re{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 $s=class extends Re{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 Ws=class extends Re{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 Aw={min:1.272,max:1.414},Rw={min:.74,max:.83},Gs=class extends Re{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(),Aw)&&this.inBand(this.cdOverXc(),Rw)}};function Bh(r){return `${r>=0?"+":""}${r.toFixed(2)}`}function ui(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 Mn=class extends V{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 `${Bh(n)} (${Bh(i)}%)`}timeLabel(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return "";let i=ui(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&&xe(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 H(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"},...F.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:qe,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 Us=class extends Mn{constructor(){super(...arguments);this.type="datepricerange";}};var Ys=[{value:"long",label:"Long"},{value:"short",label:"Short"}],le=class le extends V{constructor(t){super(t);this.type="position";this.riskPercent===void 0&&(this.riskPercent=le.DEFAULT_RISK_PERCENT),this.accountBalance===void 0&&(this.accountBalance=le.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=le.DEFAULT_PROFIT_COLOR),this.lossColor===void 0&&(this.lossColor=le.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)>=le.MIN_DRAG_PX?(l=a,c=i+Math.max(Math.abs(t.xOf(s.time)-i),le.MIN_WIDTH_PX)):(l=o-le.DEFAULT_RISK_PX*le.DEFAULT_RR,c=i+le.DEFAULT_WIDTH_PX);let d=o-(l-o)/le.DEFAULT_RR,u=t.pxToPoint(c,o,this.paneId).time;this.anchors=[{time:n.time,price:n.price},{time:u,price:t.pxToPoint(i,d,this.paneId).price},{time:u,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)/le.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 $${Dw(this.dollarLoss())} \xB7 Size ${Ow(this.positionSize())}`}targetLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Hh(t.target)}`:"";return `Target +${this.rewardPct().toFixed(2)}%${n}`}stopLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${Hh(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 zh(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 xe(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 H(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:Ys,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"},...F.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:qe,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);}};le.DEFAULT_RR=2,le.MIN_DRAG_PX=6,le.DEFAULT_RISK_PX=64,le.DEFAULT_WIDTH_PX=150,le.MIN_WIDTH_PX=48,le.DEFAULT_RISK_PERCENT=1,le.DEFAULT_ACCOUNT_BALANCE=1e4,le.DEFAULT_PROFIT_COLOR=Vo,le.DEFAULT_LOSS_COLOR=_o;var $e=le;function Dw(r){if(!Number.isFinite(r))return "0";let e=Math.round(r*100)/100;return Number.isInteger(e)?String(e):e.toFixed(2)}function Ow(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 Hh(r){return Number.isFinite(r)?Math.abs(r)>=1?r.toFixed(2):r.toPrecision(4).replace(/\.?0+$/,""):"0"}function zh(r){return Math.round(r*1e8)/1e8}var hi=new Map;function O(r){hi.set(r.type,r);}function jt(r){return hi.get(r)}function Ks(){return [...hi.values()]}function qt(r,e){let t=hi.get(r);if(!t)return null;let n={...t.defaultStyle,...e.style??{}};return t.create({...e,style:n})}function fc(r){let e=qt(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 ct(r){let e=hi.get(r.type);return e?e.create(r):null}var Fw=A('<line x1="4" y1="19" x2="20" y2="5"/>'),Nw=A('<line x1="3" y1="12" x2="21" y2="12"/>');O({type:"trendline",group:"lines",label:"Trend Line",icon:Fw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new $o(r)});O({type:"hline",group:"lines",label:"Horizontal Line",icon:Nw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"dashed"},create:r=>new Wo(r)});var Vw=A('<line x1="3" y1="20" x2="21" y2="6"/><circle cx="3" cy="20" r="1.6" fill="currentColor"/>'),_w=A('<rect x="4" y="6" width="16" height="12" rx="1"/>'),Bw=A('<path d="M5 6h14M12 6v13"/>');O({type:"ray",group:"lines",label:"Ray",icon:Vw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Go(r)});var Hw=A('<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"/>'),zw=A('<line x1="12" y1="3" x2="12" y2="21"/>'),$w=A('<line x1="5" y1="12" x2="21" y2="12"/><circle cx="5" cy="12" r="1.6" fill="currentColor"/>'),Ww=A('<line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/>'),Gw=A('<path d="M4 20 20 4"/><rect x="9" y="9" width="9" height="6" rx="1"/>'),Uw=A('<path d="M4 20 20 6"/><path d="M4 20 15 20"/><path d="M11 20a7 7 0 0 0-2-4.9"/>');O({type:"extendedline",group:"lines",label:"Extended Line",icon:Hw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Uo(r)});O({type:"vline",group:"lines",label:"Vertical Line",icon:zw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Yo(r)});O({type:"hray",group:"lines",label:"Horizontal Ray",icon:$w,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Ko(r)});O({type:"crossline",group:"lines",label:"Cross Line",icon:Ww,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Xo(r)});O({type:"infoline",group:"lines",label:"Info Line",icon:Gw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new jo(r)});O({type:"trendangle",group:"lines",label:"Trend Angle",icon:Uw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new qo(r)});O({type:"box",group:"shapes",label:"Rectangle",icon:_w,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}26`},create:r=>new Zo(r)});O({type:"text",group:"annotations",label:"Text",icon:Bw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Et(r)});var Yw=A('<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"/>');O({type:"callout",group:"annotations",label:"Callout",icon:Yw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new st(r)});var Kw=A('<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"/>'),Xw=A('<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"/>'),jw=A('<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"/>'),qw=A('<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"/>'),Zw=A('<path d="M12 11.5V21"/><rect x="5" y="4" width="14" height="7" rx="1"/><path d="M9 7.5h6"/>');O({type:"note",group:"annotations",label:"Note",icon:Kw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new mn(r)});O({type:"pricenote",group:"annotations",label:"Price Note",icon:Xw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new gn(r)});O({type:"comment",group:"annotations",label:"Comment",icon:jw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new bn(r)});O({type:"pricelabel",group:"annotations",label:"Price Label",icon:qw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new fn(r)});O({type:"signpost",group:"annotations",label:"Signpost",icon:Zw,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new vn(r)});var Jw=A('<line x1="3" y1="16" x2="21" y2="8"/><line x1="3" y1="21" x2="21" y2="13"/>'),Qw=A('<line x1="3" y1="7" x2="21" y2="10"/><line x1="3" y1="18" x2="21" y2="14"/>'),ex=A('<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"/>');O({type:"parallelchannel",group:"channels",label:"Parallel Channel",icon:Jw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new Jo(r)});O({type:"disjointchannel",group:"channels",label:"Disjoint Channel",icon:Qw,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new Qo(r)});var tx=A('<line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="18" x2="21" y2="11"/>');O({type:"flattopbottom",group:"channels",label:"Flat Top/Bottom",icon:tx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new es(r)});var nx=A('<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"/>');O({type:"regressionchannel",group:"channels",label:"Linear Regression",icon:nx,defaultStyle:{lineColor:Ee,lineWidth:1,lineStyle:"solid"},create:r=>new Pt(r)});O({type:"pitchfork",group:"pitchforks",label:"Pitchfork",icon:ex,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ts(r)});var rx=A('<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"/>'),ix=A('<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"/>'),ox=A('<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"/>');O({type:"schiffpitchfork",group:"pitchforks",label:"Schiff Pitchfork",icon:rx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ns(r)});O({type:"modifiedschiffpitchfork",group:"pitchforks",label:"Modified Schiff Pitchfork",icon:ix,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new rs(r)});O({type:"insidepitchfork",group:"pitchforks",label:"Inside Pitchfork",icon:ox,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new is(r)});var sx=A('<path d="M7 7h10v10"/><path d="M7 17 17 7"/>'),ax=A('<ellipse cx="12" cy="12" rx="9" ry="6"/>'),lx=A('<path d="M12 4 20 19 4 19Z"/>');O({type:"arrow",group:"shapes",label:"Arrow",icon:sx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",arrowRight:true},create:r=>new os(r)});O({type:"ellipse",group:"shapes",label:"Ellipse",icon:ax,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new ss(r)});O({type:"triangle",group:"shapes",label:"Triangle",icon:lx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new as(r)});var cx=A('<polyline points="3 17 9 10 13 14 21 5"/>'),dx=A('<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"/>'),ux=A('<path d="M9 11 15 5l4 4-6 6H9Z"/><path d="M9 15l-2 2"/><path d="M4 21h6"/>');O({type:"polyline",group:"shapes",label:"Polyline",icon:cx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ls(r)});O({type:"freehand",group:"shapes",label:"Brush",icon:dx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new cs(r)});O({type:"highlighter",group:"shapes",label:"Highlighter",icon:ux,defaultStyle:{lineColor:`${lh}59`,lineWidth:14,lineStyle:"solid"},create:r=>new ds(r)});var hx=A('<circle cx="12" cy="12" r="8"/>'),px=A('<path d="M5 14 9.5 5 19 10 14.5 19 Z"/>'),mx=A('<path d="M4 19 9 11 13 14 17 8 20 4"/><path d="M17.2 5.5 20 4 19.4 7.1"/>'),fx=A('<path d="M4 17a8 8 0 0 1 16 0"/><path d="M4 17 20 17"/>'),gx=A('<path d="M4 18Q12 1 20 14"/>'),bx=A('<path d="M12 5 12 19"/><path d="M6 11 12 5 18 11"/>'),vx=A('<path d="M12 5 12 19"/><path d="M6 13 12 19 18 13"/>');O({type:"circle",group:"shapes",label:"Circle",icon:hx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new us(r)});O({type:"rotatedrect",group:"shapes",label:"Rotated Rectangle",icon:px,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new hs(r)});O({type:"path",group:"shapes",label:"Path",icon:mx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ps(r)});O({type:"arc",group:"shapes",label:"Arc",icon:fx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new ms(r)});O({type:"curve",group:"shapes",label:"Curve",icon:gx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new fs(r)});O({type:"arrowmarkup",group:"shapes",label:"Arrow Mark Up",icon:bx,defaultStyle:{lineColor:J,lineWidth:1,lineStyle:"solid"},create:r=>new ii(r)});O({type:"arrowmarkdown",group:"shapes",label:"Arrow Mark Down",icon:vx,defaultStyle:{lineColor:X,lineWidth:1,lineStyle:"solid"},create:r=>new oi(r)});var yx=A('<path d="M6 21V4"/><path d="M6 5h11l-2.5 3.5L17 12H6" fill="currentColor" stroke="none"/>'),wx=A('<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"/>');O({type:"flagmark",group:"stamps",label:"Flag",icon:yx,defaultStyle:{lineColor:Te,lineWidth:1,lineStyle:"solid"},create:r=>new si(r)});O({type:"iconstamp",group:"stamps",label:"Icon",icon:wx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ai(r)});var xx=A('<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"/>'),Sx=A('<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"/>');O({type:"fibretracement",group:"fibonacci",label:"Fib Retracement",icon:xx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new vs(r)});O({type:"fibextension",group:"fibonacci",label:"Fib Extension",icon:Sx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ys(r)});var Cx=A('<path d="M3 20 10 9l4 5"/><path d="M14 14h7M14 9h7M14 4h7"/>');O({type:"fibextensiontrend",group:"fibonacci",label:"Trend-Based Fib Extension",icon:Cx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ws(r)});var Tx=A('<path d="M4 20 20 5M4 20 21 11M4 20 21 17M4 20 20 20"/>'),Ex=A('<path d="M3 5v14M6 5v14M11 5v14M19 5v14"/>');O({type:"fibfan",group:"fibonacci",label:"Fib Fan",icon:Tx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new xs(r)});O({type:"fibtimezones",group:"fibonacci",label:"Fib Time Zones",icon:Ex,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new Ss(r)});var Px=A('<path d="M3 18 18 9M5 21 20 12M6 13 21 4"/>'),Lx=A('<path d="M4 4 20 20M4 4 20 12M4 4 12 20M4 4 20 4M4 4 4 20"/>'),Mx=A('<path d="M3 19 9 8M9 8 12 5v14M14 5v14M18 5v14M21 5v14"/>');O({type:"fibchannel",group:"fibonacci",label:"Fib Channel",icon:Px,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Cs(r)});O({type:"fibspeedfan",group:"fibonacci",label:"Fib Speed Resistance Fan",icon:Lx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ts(r)});O({type:"trendfibtime",group:"fibonacci",label:"Trend-Based Fib Time",icon:Mx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new Es(r)});var kx=A('<circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/><circle cx="12" cy="12" r="10"/>'),Ix=A('<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"/>'),Ax=A('<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"/>'),Rx=A('<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"/>');O({type:"fibcircles",group:"fibonacci",label:"Fib Circles",icon:kx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ps(r)});O({type:"fibarcs",group:"fibonacci",label:"Fib Speed Resistance Arcs",icon:Ix,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ls(r)});O({type:"fibwedge",group:"fibonacci",label:"Fib Wedge",icon:Ax,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ms(r)});O({type:"fibspiral",group:"fibonacci",label:"Fib Spiral",icon:Rx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new En(r)});var Dx=A('<path d="M4 20 20 20M4 20 20 13M4 20 20 6M4 20 15 4M4 20 9 4M4 20 4 4"/>'),Ox=A('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 12h16M12 4v16M4 4 20 20" opacity="0.6"/>');O({type:"gannfan",group:"fibonacci",label:"Gann Fan",icon:Dx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ks(r)});O({type:"gannbox",group:"fibonacci",label:"Gann Box",icon:Ox,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Is(r)});var Fx=A('<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"/>');O({type:"gannsquare",group:"fibonacci",label:"Gann Square",icon:Fx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Pn(r)});var Nx=A('<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"/>');O({type:"dedekind",group:"geometry",label:"Dedekind Tessellation",icon:Nx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ln(r)});var Vx=A('<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"/>'),_x=A('<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"/>');O({type:"sonic",group:"geometry",label:"Sonic",icon:Vx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ci(r)});O({type:"supersonic",group:"geometry",label:"Supersonic",icon:_x,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new di(r)});var Bx=A('<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"/>'),Hx=A('<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"/>');O({type:"goldensonic",group:"geometry",label:"Golden Sonic",icon:Bx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rs(r)});O({type:"goldensupersonic",group:"geometry",label:"Golden Supersonic",icon:Hx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ds(r)});var zx=A('<path d="M3 18 7 8 11 14 15 6 20 16"/>'),$x=A('<path d="M4 17 9 7 14 15 20 5"/>'),Wx=A('<path d="M3 19 8 9 12 13 17 5 21 9"/>'),Gx=A('<path d="M4 7 11 16 20 9"/>'),Ux=A('<path d="M3 18 6 12 9 16 12 5 15 16 18 12 21 18"/>');O({type:"xabcd",group:"patterns",label:"XABCD Pattern",icon:zx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Os(r)});O({type:"abcd",group:"patterns",label:"ABCD Pattern",icon:$x,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Fs(r)});O({type:"elliottimpulse",group:"patterns",label:"Elliott Impulse Wave (1-5)",icon:Wx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ns(r)});O({type:"elliottcorrection",group:"patterns",label:"Elliott Correction Wave (ABC)",icon:Gx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Vs(r)});O({type:"headshoulders",group:"patterns",label:"Head & Shoulders",icon:Ux,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new _s(r)});var Yx=A('<path d="M3 17 7 6 12 14 17 5 21 16"/><path d="M3 17 21 16" opacity="0.45"/>'),ar={group:"patterns",icon:Yx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"}};O({type:"gartley",label:"Gartley",...ar,create:r=>new Bs(r)});O({type:"bat",label:"Bat",...ar,create:r=>new Hs(r)});O({type:"butterfly",label:"Butterfly",...ar,create:r=>new zs(r)});O({type:"crab",label:"Crab",...ar,create:r=>new $s(r)});O({type:"shark",label:"Shark",...ar,create:r=>new Ws(r)});O({type:"cypher",label:"Cypher",...ar,create:r=>new Gs(r)});var Kx=A('<rect x="4" y="6" width="16" height="12" rx="1"/><path d="M4 18 20 6" opacity="0.5"/>');O({type:"datepricerange",group:"measure",label:"Date & Price Range",icon:Kx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Us(r)});var Xx=A('<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"/>');O({type:"position",group:"measure",label:"Long/Short Position",icon:Xx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new $e(r)});var jx=A('<line x1="5" y1="3" x2="5" y2="21"/><path d="M5 16c4 0 5-9 8-9s3 5 8 3"/>');O({type:"anchoredvwap",group:"measure",label:"Anchored VWAP",icon:jx,defaultStyle:{lineColor:Ct,lineWidth:2,lineStyle:"solid"},create:r=>new yn(r)});var qx=A('<path d="M4 4v16"/><path d="M4 8h10"/><path d="M4 12h14"/><path d="M4 16h8"/><path d="M4 20h12"/>');O({type:"fixedrangevp",group:"measure",label:"Fixed Range Volume Profile",icon:qx,defaultStyle:{lineColor:J,lineWidth:1,lineStyle:"solid"},create:r=>new Ve(r)});var Zx=["fibretracement","fibextension","fibextensiontrend","fibfan","fibtimezones","fibchannel","fibspeedfan","trendfibtime","fibcircles","fibarcs","fibwedge","fibspiral"],Jx=["gannfan","gannbox","gannsquare"],Qx=["dedekind","sonic","supersonic","goldensonic","goldensupersonic"],eS=["xabcd","abcd","headshoulders"],tS=["elliottimpulse","elliottcorrection"],nS=["gartley","bat","butterfly","crab","shark","cypher"],rS=["position","datepricerange"],iS=["anchoredvwap","fixedrangevp"],oS=["freehand","highlighter"],sS=["arrow","arrowmarkup","arrowmarkdown"],aS=["box","ellipse","triangle","polyline","circle","rotatedrect","path","arc","curve"],lS=["text","callout","note","pricenote","comment","pricelabel","signpost"],cS=["flagmark","iconstamp"],dS=[{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:Zx},{label:"Gann",types:Jx},{label:"Geometry",types:Qx}]},{id:"patterns-waves-harmonics",label:"Patterns",sections:[{label:"Patterns",types:eS},{label:"Elliott Waves",types:tS},{label:"Harmonics",types:nS}]},{id:"measurements",label:"Measurements",sections:[{label:"Measurements",types:rS},{label:"Volume",types:iS}]},{id:"brushes-arrows-shapes",label:"Shapes",sections:[{label:"Brushes",types:oS},{label:"Arrows",types:sS},{label:"Shapes",types:aS}]},{id:"text",label:"Text",sections:[{label:"Text",types:lS}]},{id:"icons",label:"Icons",sections:[{label:"Icons",types:cS}]}];function uS(r){let e=jt(r);return e?{type:e.type,label:e.label,icon:e.icon}:null}function hS(r){let e=new Map;for(let t of Ks()){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 pS(r,e,t){return "registryGroup"in r?e.get(r.registryGroup)??[]:r.types.map(n=>t.get(n)).filter(n=>n!=null)}function $h(r){let e=hS(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 dS){let o=[],s=[];for(let a of i.sections){let l=pS(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 mS(r){let e=new Set;for(let t of r)jt(t)&&e.add(t);return $h(e)}function fS(r){let e=[];for(let t of r){let n=t.tools.map(uS).filter(i=>i!=null);n.length>0&&e.push({id:t.id,label:t.label,tools:n});}return {groups:e}}function pi(){return $h()}function mi(r){if(r===false)return {definition:pi(),visible:false};if(r===void 0||r===true)return {definition:pi(),visible:true};let e=r.toolbar??true;return r.groups?{definition:fS(r.groups),visible:e}:r.tools?{definition:mS(r.tools),visible:e}:{definition:pi(),visible:e}}function dt(r){let e=globalThis.structuredClone;return e?e(r):JSON.parse(JSON.stringify(r))}function Wh(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 gc(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(Wh)}}var lr=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=gc(e);this.byId.clear(),this.seq=0,this.zCounter=1;for(let n of t.drawings){let i=ct(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 Xs=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=dt(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(dt(e));}undo(e){let t=this.undoStack.pop();return t?(this.redoStack.push(dt(e)),t):null}redo(e){let t=this.redoStack.pop();return t?(this.undoStack.push(dt(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 js=class{constructor(e,t,n){this.events=t;this.store=new lr;this.history=new Xs;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:i,visible:o}=mi(n);this.port.setToolbar(i),this.port.showToolbar(o),this.subs.push(this.port.onDrawingIntent(s=>this.onIntent(s))),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){jt(e)&&t!==this.favs.has(e)&&(t?this.favs.add(e):this.favs.delete(e),this.pushFavorites());}setFavorites(e){let t=e.filter(n=>jt(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(mi(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=qt(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(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){let t=this.port?.stackRange?.(e);return t?(t.price??t.front)-.5:void 0}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=>dt(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.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}restoreSnapshot(e){this.store.load(e),this.selectedIds=this.selectedIds.filter(t=>this.store.has(t)),this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}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=ct({...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=ct({...e.doc,id:this.store.nextId(),style:i});if(!o)return;o.zIndex||(o.zIndex=this.startZ(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 "copy":this.copy(e.ids);break;case "paste":this.paste();break}}};var Uh={D:864e5,W:6048e5,M:2592e6};function fi(r){let e=r.trim();if(Uh[e])return Uh[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 ut=r=>r.trim().toLowerCase(),Zt=r=>r.trim().toUpperCase();function Mt(r){let e=r.trim(),t=/^(?:([A-Za-z0-9_.]+):)?(.+)$/.exec(e);if(!t)return {provider:null,ticker:e};let n=t[1]?ut(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 qs=class{constructor(){this.entries=new Map;this.changeListeners=new Set;this.waits=new Set;this.unresolvedCbs=new Set;}register(e,t){let n=ut(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=>Zt(n.ticker))),e.byTicker=new Map(t.map(n=>[Zt(n.ticker),n])),e.prefixIndex=new Map;for(let n of t)n.prefix&&e.prefixIndex.set(`${ut(n.prefix)}:${Zt(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(ut(e)),this.notify(false);}has(e){return this.entries.has(ut(e))}get(e){return this.entries.get(ut(e))?.provider}names(){return [...this.entries.keys()]}parse(e){return Mt(e)}resolve(e,t={}){let{provider:n,ticker:i}=this.parse(e);if(n){if(this.entries.has(n))return {provider:n,ticker:i};let s=`${n}:${Zt(i)}`;for(let a of this.candidateOrder(t.default)){let l=this.entries.get(a).prefixIndex?.get(s);if(l)return {provider:a,ticker:l.ticker}}return null}let o=Zt(i);for(let s of this.candidateOrder(t.default))if(this.entries.get(s).index?.has(o))return {provider:s,ticker: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}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=ut(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(Zt(e.ticker))?.prefix??e.provider}canonicalSymbol(e){let t=this.entries.get(e.provider)?.byTicker?.get(Zt(e.ticker));return `${t?.prefix??e.provider}:${t?.ticker??e.ticker}`}symbolIconOf(e){let t=e.provider?ut(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(Zt(e.ticker));return this.symbolIconOf({...t??{ticker:e.ticker},provider:t?.provider??e.provider})}symbolsOf(e){return e!=null?this.entries.get(ut(e))?.descriptors??[]:[...this.entries.entries()].flatMap(([t,n])=>n.descriptors.map(i=>({...i,provider:t})))}infoOf(e){let t=ut(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 cr(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 gi(r){if(r.kind==="heading"||r.kind==="header")return [];let e=cr(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 kn(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 bi=new Map;function bc(r){bi.set(r.id,r);}function gS(r){bi.delete(r);}function kt(r){return typeof r=="string"?bi.get(r):void 0}function Je(){return [...bi.values()]}function vc(){return [...bi.values()].filter(r=>r.tickerModifier??r.barTransform!=null).map(r=>r.id)}function Zs(r){return kt(r)?.barTransform??null}function Yh(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"&&!vc().includes(t)?{symbol:r,modifier:null,transform:null}:{symbol:r.slice(0,e),modifier:t,transform:Zs(t)}}var ht={background:"#151619",textColor:"#b2b5be",gridColor:"#20222c",borderColor:"#2a2b30",upColor:J,downColor:X,fontFamily:"sans-serif"},vi={background:"#ffffff",textColor:"#1e293b",gridColor:"#cccccc",borderColor:"#d4dae3",upColor:J,downColor:X,fontFamily:"sans-serif"};function dr(r){return !r||r==="dark"?ht:r==="light"?vi:r}var bS=150,vS=1e3,yS=300,wS=5e3,Kh=1e4,xS=1.5,Xh=5e3,Js=class r{constructor(e,t,n,i,o,s){this.renderer=t;this.feed=n;this.config=o;this.dataControl=s;this.events=new hn;this.registry=new Oo;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.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 l of i)this.registerEngine(l.language,l);this.defaultLanguage=o.defaultLanguage,this.renderer.mount(e,o.theme),this.renderer.onInputChange(l=>this.applyInputs(l.indicatorId,{[l.key]:l.value})),this.renderer.onRemoveIndicator(l=>this.removeIndicator(l)),this.renderer.onToggleIndicatorVisible?.((l,c)=>this.setVisible(l,c)),this.paneActionUnsub=this.renderer.onPaneAction?.(l=>this.handlePaneAction(l))??null,this.renderer.onChartTypeSettingsChange?.((l,c)=>{this.typeSettings.set(l,c),this.typeEngines.get(l)?.onSettings?.(c);}),this.renderer.onMoveIndicator?.((l,c)=>this.moveIndicator(l,c)),this.renderer.onThemeSelect?.(l=>this.setTheme(dr(l))),this.viewportUnsub=this.renderer.onViewportChange(l=>this.onViewportChange(l)),this.renderer.onPriceStyleChange?.(l=>this.syncPriceStyle(l));let a=this.renderer.readFeature("priceStyle");typeof a=="string"&&(this.priceStyle=a),this.barTransform=Zs(a),this.drawings=new js(this.renderer,this.events,o.drawings),this.unresolvedUnsub=this.feed.onUnresolved?.(l=>{this.endLoad(),this.events.emit("data:unresolved",l);})??null,this.readyPromise=this.init(),kt(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=Yh(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});}},bS);}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;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>wS;if(s&&this.feed.loadRange){let a=await this.feed.load({...n,bars:Math.min(i,Kh)});if(this.generation!==e)return;this.setBarSeries(a),t.firstLoad&&this.activateBarLayers(),a.length>0&&i>a.length?(this.historyState="backfill",this.backfillHistory(e,i)):this.completeHistory("depth");}else if(s){let a=await this.feed.load({...n,bars:yS});if(this.generation!==e)return;this.setBarSeries(a),t.firstLoad&&this.activateBarLayers();let l=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(l,{preserveView:true}),this.completeHistory("depth");}else {let a=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(a),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 No(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<=Xh||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:Mt(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(u=>u.time>=l.left&&u.time<=l.right).length:0,d=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 u=Math.min(Math.ceil((Date.now()-l.left)/this.barIntervalMs())+50,5e3);u>(t.bars??500)&&(t.bars=u);}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(d,t.bars??500):await Promise.race([this.loadMarket(d,{firstLoad:!1}),new Promise(u=>this.supersedeWaiters.push(u))]),this.generation!==d)return}finally{this.generation===d&&(this.switchingMarket=false);}if(l&&c>=2&&this.rawBars.length>0){let u=this.rawBars,h=u.length-1;for(;h>0&&u[h].time>l.right;)h-=1;let p=u[Math.max(0,h-(c-1))].time;this.renderer.setVisibleRange({from:p,to:Math.max(l.right,u[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.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=Kh,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||ti("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=kt(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=kt(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=Zs(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()*xS&&Date.now()-this.lastHealAt>Xh){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 fi(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 er(n,i,this,e);return this.handles.set(n,o),this.registry.add({id:n,title:i,source:e,options:t,inputValues:{...t.inputs??{}}}),this.startIndicator(n,e,t,o),o}addNativeIndicator(e,t={}){let n=this.registry.all().find(c=>c.native?.type===e);if(n)return this.handles.get(n.id)??new er(n.id,n.title,this);let i=ti(e),o=this.registry.nextId("native"),s=i?.title??e,a=new er(o,s,this);if(this.handles.set(o,a),!i)return console.warn(`[vela] addNativeIndicator("${e}") \u2014 no native indicator registered for this type.`),a;let l={...i.defaultInputs(),...t.inputs??{}};return this.registry.add({id:o,title:s,source:e,inputValues:l,native:{type:e,instance:i.create(),descriptor:i}}),a.setSchema(i.inputsSchema()),this.startNativeIndicator(o,a),a}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(Fo().map(async n=>({type:n.type,title:n.title,supported:await this.isNativeSupported(n,e),present:t.has(n.type),beta:n.beta})))}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));}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);else if(n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,true),n.pendingStructural=true,n.native)if(n.native.stale){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 ih(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=oh(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.renderer.destroy(),this.events.clear();}async startIndicator(e,t,n,i){try{if(await this.readyPromise,!this.registry.get(e))return;await SS();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 c of a.inputs)l[c.key]=c.defval;o.inputValues={...l,...o.inputValues},i.setSchema(a.inputs),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,visibleRange:this.currentVisibleRange(),mode:i,historyState:this.historyState},{onModel:o=>{let s=!n.announced,a=n.pendingCause??"history";n.pendingCause=void 0,this.applyModel(e,o),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);}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},...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.hidden||!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},o=this.routePane(e,i,t.options??{});this.placeModel(i,e,o),t.model=i,this.ensurePaneFor(o),t.renderHandle=this.renderer.mountIndicator(i),t.pendingStructural=true,this.setLoading(t,true);}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)continue;let o=i.paneId??"price";e.has(o)||e.set(o,[]),e.get(o).push({id:n.id,title:i.title||n.title,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;let i=this.handles.get(e);if(!n.renderHandle){let a=this.routePane(e,t,n.options??{});this.placeModel(t,e,a),n.model=t,this.ensurePaneFor(a),n.renderHandle=this.renderer.mountIndicator(t),n.pendingStructural=false,this.announce(n,i);return}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);}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.pendingStructural=false):this.renderer.updateIndicator(n.renderHandle,CS(t)),n.loading&&this.setLoading(n,false),this.announce(n,i);}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)be(n)&&(t[n.title]=n.points[n.points.length-1]?.value??null);return t}placeModel(e,t,n){e.id=t,e.paneId=n;for(let i of e.series)i.paneId=n;for(let i of e.fills)i.paneId=n;for(let i of e.backgrounds)i.paneId=n;for(let i of e.priceLines)i.paneId=n;if(e.lines)for(let i of e.lines)i.paneId=n;if(e.boxes)for(let i of e.boxes)i.paneId=n;if(e.labels)for(let i of e.labels)i.paneId=n;if(e.polylines)for(let i of e.polylines)i.paneId=n;if(e.linefills)for(let i of e.linefills)i.paneId=n;if(e.tables)for(let i of e.tables)i.paneId=n;}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)<vS||(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 SS(){return typeof requestAnimationFrame=="function"?new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(()=>r()))):new Promise(r=>setTimeout(r,0))}function CS(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(be(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 yi=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);}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)}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}};var ur=new Map;function TS(r){let e=Object.entries(r);for(let[t,n]of e)ur.set(t,n);return ()=>{for(let[t,n]of e)ur.get(t)===n&&ur.delete(t);}}function ES(...r){if(r.length===0)ur.clear();else for(let e of r)ur.delete(e);}function yc(){return Object.fromEntries(ur)}var Qs=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 jh(r,e,t,n){return `${r}|${e}|${t}${n&&n!=="regular"?`|${n}`:""}`}function PS(r){return r.split("|")[1]??""}var ea=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=PS(t);n!==e&&!this.retained.has(n)&&(this.series.delete(t),this.coveredFrom.delete(t));}}clear(){this.series.clear(),this.coveredFrom.clear();}},wi=new ea;function qh(r,e,t){let{provider:n,ticker:i}=Mt(r);return jh(n??"",i,e,t)}var xi=1e4,LS=xi+1,Si=class{constructor(e,t=wi){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=qh(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,ta(l));return Zh(c,l[l.length-1]).slice(-o)}let a=await this.inner.load(e);return this.store.merge(n,ta(a)),a}async loadRange(e,t){if(!this.inner.loadRange)return this.inner.load(e);let n=qh(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 d=i.filter(f=>f.time<=t.to),u=this.store.coveredFromOf(n)??1/0;if(t.limit!=null?d.length>=t.limit&&(t.from==null||u<=t.from):t.from!=null&&u<=t.from){let f=t.from!=null?d.filter(g=>g.time>=t.from):d;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 d=this.store.coveredFromOf(n);if(d!=null&&d>t.from){let{bars:u,coveredDownTo:h}=await this.fetchRange(e,{from:t.from,to:d});this.store.merge(n,u.filter(p=>p.time<=d)),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:d}=await this.fetchRange(e,{from:o.time,to:t.to,limit:t.limit}),u=this.store.merge(n,ta(d)),h=Zh(u,d[d.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,ta(l)),this.store.markCovered(n,c??t.from??l[0]?.time??0),l}async fetchRange(e,t){let n=fi(e.timeframe??"60"),i=MS(t,n);if(i<=LS){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:xi;if(c<=0)break;let d=await this.inner.loadRange(e,{to:s,limit:Math.min(xi,c)}),u=1/0;for(let h of d)h.time<u&&(u=h.time),h.time<=s&&(t.from==null||h.time>=t.from)&&o.set(h.time,h);if(d.length===0){if(t.from==null)break;s-=xi*n;continue}if(u-1>=s)break;s=u-1;}let a=[...o.values()].sort((c,d)=>c.time-d.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 MS(r,e){if(r.limit!=null)return r.limit;if(r.from==null)return xi;let t=Math.max(0,(r.to??Date.now())-r.from);return Math.ceil(t/e*1.1)+2}function ta(r){return r.length>0?r.slice(0,-1):r}function Zh(r,e){if(!e)return r;let t=r[r.length-1];return !t||e.time>t.time?[...r,e]:r}function kS(r){return {"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,1:6e4,5:3e5,15:9e5,30:18e5,60:36e5,240:144e5,D:864e5,W:6048e5}[r]??36e5}var In=class{constructor(e=wi){this.registry=new qs;this.primaryProvider=null;this.liveBars=[];this.symInfoCache=new Map;this.cache=new Si(new Sc(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(xc(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(na(e),{default:this.primaryProvider});return this.primaryProvider=t.provider,this.prefetchSymbolInfo(t),this.cache.load(wc(e,t))}symbolInfo(e){if(e.data&&e.data.length>0)return;let t=this.registry.resolve(na(e),{default:this.primaryProvider});return t?this.symInfoCache.get(xc(t)):void 0}prefetchSymbolInfo(e){let t=xc(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(na(e),{default:this.primaryProvider});return n?this.cache.loadRange(wc(e,n),t):[]}subscribe(e,t){if(e.data&&e.data.length>0)return this.synthesizeTicks(e,t);let n=this.registry.resolve(na(e),{default:this.primaryProvider});return n?this.cache.subscribe(wc(e,n),t):()=>{}}synthesizeTicks(e,t){if(this.liveBars.length===0)return ()=>{};let n=kS(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 d={time:c.time+n,open:c.close,high:c.close,low:c.close,close:c.close,volume:0};o.push(d),t(d);}},1e3);return ()=>clearInterval(i)}};function na(r){return r.symbol??""}function wc(r,e){return {...r,symbol:`${e.provider}:${e.ticker}`}}function xc(r){return `${r.provider}|${r.ticker}`}async function Jh(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 Sc=class{constructor(e){this.registry=e;}load(e){let{provider:t,ticker:n}=Mt(e.symbol??""),i=this.registry.get(t??"");return i?Jh(i,n,e.timeframe??"60",{limit:e.bars??500,session:e.session}):Promise.resolve([])}loadRange(e,t){let{provider:n,ticker:i}=Mt(e.symbol??""),o=this.registry.get(n??"");return o?Jh(o,i,e.timeframe??"60",{...t,session:e.session}):Promise.resolve([])}subscribe(e,t){let{provider:n,ticker:i}=Mt(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 d=await o.getBars(i,s,{limit:2,session:e.session});if(a)return;for(let u of d)t(u);}catch{}a||(l=setTimeout(()=>{c();},3e3));}};return l=setTimeout(()=>{c();},3e3),()=>{a=true,l&&clearTimeout(l);}}};var Ci=class{constructor(e){this.registry=e instanceof In?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 Ti=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)}};function ra(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 W(r,e){let t=ra(r);return t?`rgba(${t.r},${t.g},${t.b},${e})`:r}function Qh(r,e,t){let n=ra(r),i=ra(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 _e(r){let e=ra(r);return e?.2126*e.r+.7152*e.g+.0722*e.b<128:true}var ia={"--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 oa(r){let e=_e(r.background),t=i=>e?`rgba(255,255,255,${i})`:W(r.textColor,i+.02),n=Qh(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":W(r.textColor,.62),"--vela-fg-faint":W(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":W(r.textColor,.28),"--vela-border-soft":r.borderColor,"--vela-border-faint":W(r.textColor,.08),"--vela-hover":t(.06),"--vela-active":t(.1),"--vela-hover-strong":t(.16),"--vela-focus":W(r.textColor,.5),"--vela-focus-soft":W(r.textColor,.12),"--vela-separator-hover-band":W(r.textColor,.1),"--vela-separator-hover-line":W(r.textColor,.55),"--vela-scroll":W(r.textColor,.3),"--vela-accent":Te,"--vela-accent-bright":tr,"--vela-highlight":ah,"--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 ve(r,e){let t=n=>{for(let i in n)r.style.setProperty(i,n[i]);};t(ia),t(oa(e));}function pt(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;"),ve(n,e.theme()),e.host.appendChild(n);let c=r.getBoundingClientRect(),d=e.host.getBoundingClientRect();if(e.placement==="right")n.style.left=`${c.right-d.left+8}px`,n.style.top=`${c.top-d.top+(c.height-n.offsetHeight)/2}px`;else {let u=Math.min(c.left-d.left,Math.max(0,d.width-n.offsetWidth-4));n.style.left=`${Math.max(0,u)}px`,n.style.top=e.placement==="above"?`${Math.max(0,c.top-d.top-n.offsetHeight-6)}px`:`${c.bottom-d.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();}}var IS=Object.defineProperty,AS=(r,e,t)=>e in r?IS(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,Z=(r,e,t)=>AS(r,typeof e!="symbol"?e+"":e,t);function ep(r){return r==null?[]:Array.isArray(r)?r:[r]}var tp=r=>r[0],np=r=>r[r.length-1];function rp(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 ip(r,e,t={}){return r[rp(r,e,t)]}function RS(r,e,t={}){let{step:n=1,loop:i=true}=t;return rp(r,e,{step:-n,loop:i})}function op(r,e,t={}){return r[RS(r,e,t)]}var sp=r=>r?.constructor.name==="Array",DS=(r,e)=>{if(r.length!==e.length)return false;for(let t=0;t<r.length;t++)if(!hr(r[t],e[t]))return false;return true},hr=(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(sp(r)&&sp(e))return DS(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(!hr(r[o],e[o]))return false}return true};var OS=r=>r!=null&&typeof r=="object";var pr=r=>typeof r=="string",De=r=>typeof r=="function",ap=r=>r==null,Ei=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),FS=r=>Object.prototype.toString.call(r),lp=Function.prototype.toString,NS=lp.call(Object),An=r=>{if(!OS(r)||FS(r)!="[object Object]"||BS(r))return false;let e=Object.getPrototypeOf(r);if(e===null)return true;let t=Ei(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&lp.call(t)==NS},VS=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,_S=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,BS=r=>VS(r)||_S(r);var Pi=(r,...e)=>(typeof r=="function"?r(...e):r)??void 0,Cc=r=>r,cp=r=>r(),Tc=()=>{},Jt=(...r)=>(...e)=>{r.forEach(function(t){t?.(...e);});};function Qt(r){if(!An(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]=Qt(i));}return t}function mr(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Ec(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Li(r,e){if(r==null)throw new Error(e())}var HS=(...r)=>r.map(e=>e?.trim?.()).filter(Boolean).join(" "),zS=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,dp=r=>{let e={},t;for(;t=zS.exec(r);)e[t[1]]=t[2];return e},$S=(r,e)=>{if(pr(r)){if(pr(e))return `${r};${e}`;r=dp(r);}else pr(e)&&(e=dp(e));return Object.assign({},r??{},e??{})};function up(...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]=Jt(t[i],e[i]);continue}if(i==="className"||i==="class"){e[i]=HS(e[i],t[i]);continue}if(i==="style"){e[i]=$S(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 en=".",mp="#",hp=new WeakMap,fp=new WeakMap;function Pc(r){return r.join(en)}function WS(r){return r.includes(en)}function gp(r){return r.startsWith(mp)}function GS(r){return r.startsWith(en)}function US(r){return gp(r)?r.slice(mp.length):r}function Lc(r,e){return r?`${r}${en}${e}`:e}function YS(r){let e=new Map,t=new Map,n=(i,o)=>{e.set(i,o);let s=o.id;s&&(t.has(s)&&Ec(`[zag-js] Duplicate state id: "${s}"`),t.set(s,i));let a=o.states;if(a){Li(o.initial,()=>`[zag-js] Compound state "${i}" has child states but no "initial" property`),o.initial in a||Ec(`[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 d=Lc(i,l);n(d,c);}}};for(let[i,o]of Object.entries(r.states))o&&n(i,o);return {index:e,idIndex:t}}function fr(r){let e=hp.get(r);if(e)return e;let{index:t,idIndex:n}=YS(r);return hp.set(r,t),fp.set(r,n),t}function KS(r,e){return fr(r),fp.get(r)?.get(e)}function Mc(r){return r?String(r).split(en).filter(Boolean):[]}function sa(r,e){if(!e)return [];let t=fr(r),n=Mc(e),i=[],o=[];for(let s of n){o.push(s);let a=Pc(o),l=t.get(a);if(!l)break;i.push({path:a,state:l});}return i}function Mi(r,e){let t=fr(r),n=Mc(e);if(!n.length)return e;let i=[];for(let a of n){i.push(a);let l=Pc(i);if(!t.has(l))return e}let o=Pc(i),s=t.get(o);for(;s?.initial;){let a=`${o}${en}${s.initial}`,l=t.get(a);if(!l)break;o=a,s=l;}return o}function pp(r,e){return fr(r).has(e)}function kc(r,e,t){let n=String(e);if(gp(n)){let i=US(n),o=KS(r,i);return Li(o,()=>`[zag-js] Unknown state id: "${i}"`),Mi(r,o)}if(GS(n)&&t){let i=Lc(t,n.slice(1));return Mi(r,i)}if(!WS(n)&&t){let i=Mc(t);for(let o=i.length-1;o>=1;o--){let s=i.slice(0,o).join(en),a=Lc(s,n);if(pp(r,a))return Mi(r,a)}if(pp(r,n))return Mi(r,n)}return Mi(r,n)}function bp(r,e,t){let n=sa(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 vp(r,e,t,n){let i=e?sa(r,e):[],o=sa(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 yp(r,e){return r?r===e||r.startsWith(`${e}${en}`):false}function wp(r,e,t){return sa(r,e).some(n=>n.state.tags?.includes(t))}function xp(){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 aa(r){return fr(r),r}var gr=(r=>(r.NotStarted="Not Started",r.Started="Started",r.Stopped="Stopped",r))(gr||{}),ki="__init__";var XS=Object.defineProperty,jS=(r,e,t)=>e in r?XS(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,la=(r,e,t)=>jS(r,typeof e!="symbol"?e+"":e,t);var Sp=(r,e)=>r.map((t,n)=>r[(Math.max(e,0)+n)%r.length]);var Ii=()=>{},Ai=r=>typeof r=="object"&&r!==null;var We=r=>r?"":void 0,Ic=r=>r?"true":void 0;var qS=1,ZS=9,JS=11;var Q=r=>Ai(r)&&r.nodeType===qS&&typeof r.nodeName=="string",Ri=r=>Ai(r)&&r.nodeType===ZS,QS=r=>Ai(r)&&r===r.window;var Cp=r=>Q(r)?r.localName||"":"#document";function Tp(r){return ["html","body","#document"].includes(Cp(r))}var Ep=r=>Ai(r)&&r.nodeType!==void 0,Rn=r=>Ep(r)&&r.nodeType===JS&&"host"in r,Ac=r=>Q(r)&&r.localName==="input",Pp=r=>!!r?.matches("a[href]"),Lp=r=>Q(r)?r.offsetWidth>0||r.offsetHeight>0||r.getClientRects().length>0:false;function Di(r){if(!r)return false;let e=r.getRootNode();return mt(e)===r}var e0=/(textarea|select)/;function br(r){if(r==null||!Q(r))return false;try{return Ac(r)&&r.selectionStart!=null||e0.test(r.localName)||r.isContentEditable||r.getAttribute("contenteditable")==="true"||r.getAttribute("contenteditable")===""}catch{return false}}function Oe(r,e){if(!r||!e||!Q(r)||!Ep(e))return false;if(Q(e)&&r===e||r.contains(e))return true;let t=e.getRootNode?.();if(t&&Rn(t)){let n=e;for(;n;){if(r===n)return true;n=n.parentNode||n.host;}}return false}function ce(r){return Ri(r)?r:QS(r)?r.document:r?.ownerDocument??document}function t0(r){return ce(r).documentElement}function ae(r){return Rn(r)?ae(r.host):Ri(r)?r.defaultView??window:Q(r)?r.ownerDocument?.defaultView??window:window}function mt(r){let e=r.activeElement;for(;e?.shadowRoot;){let t=e.shadowRoot.activeElement;if(!t||t===e)break;e=t;}return e}function Mp(r){if(Cp(r)==="html")return r;let e=r.assignedSlot||r.parentNode||Rn(r)&&r.host||t0(r);return Rn(e)?e.host:e}function ca(r){let e;try{if(e=r.getRootNode({composed:!0}),Ri(e)||Rn(e))return e}catch{}return r.ownerDocument??document}var Rc=new WeakMap;function vr(r){return Rc.has(r)||Rc.set(r,ae(r).getComputedStyle(r)),Rc.get(r)}var Dc=new Set(["menu","listbox","dialog","grid","tree","region","application"]),n0=r=>Dc.has(r),kp=r=>r.getAttribute("aria-controls")?.split(" ")||[];function da(r,e){let t=new Set,n=ca(r),i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=kp(a);for(let c of l){if(!c||t.has(c))continue;t.add(c);let d=n.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";if(u&&n0(u)&&!h&&(d===e||d.contains(e)||i(d)))return true}}}return false};return i(r)}function Oc(r,e){let t=ca(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=kp(a);for(let c of l){if(!c||n.has(c))continue;n.add(c);let d=t.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";u&&Dc.has(u)&&!h&&(e(d),i(d));}}}};i(r);}function Ip(r){let e=new Set;return Oc(r,t=>{r.contains(t)||e.add(t);}),Array.from(e)}function r0(r){let e=r.getAttribute("role");return !!(e&&Dc.has(e))}function i0(r){return r.hasAttribute("aria-controls")&&r.getAttribute("aria-expanded")==="true"}function Ap(r){return i0(r)?true:!!r.querySelector?.('[aria-controls][aria-expanded="true"]')}function Rp(r){if(!r.id)return false;let e=ca(r),t=CSS.escape(r.id),n=`[aria-controls~="${t}"][aria-expanded="true"], [aria-controls="${t}"][aria-expanded="true"]`;return !!(e.querySelector(n)&&r0(r))}var Fc=()=>typeof document<"u";function o0(){return navigator.userAgentData?.platform??navigator.platform}function s0(){let r=navigator.userAgentData;return r&&Array.isArray(r.brands)?r.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" "):navigator.userAgent}var Nc=r=>Fc()&&r.test(o0()),Dp=r=>Fc()&&r.test(s0());var Vc=()=>Fc()&&!!navigator.maxTouchPoints,a0=()=>Nc(/^iPhone/i),l0=()=>Nc(/^iPad/i)||yr()&&navigator.maxTouchPoints>1,Op=()=>a0()||l0();var yr=()=>Nc(/^Mac/i);var Fp=()=>Dp(/Firefox/i);var Np=()=>Dp(/Android/i);function c0(r){return r.composedPath?.()??r.nativeEvent?.composedPath?.()}function fe(r){return c0(r)?.[0]??r.target}function _c(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=d0(r);return n||i}function Bc(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 d0(r){return yr()?r.metaKey:r.ctrlKey}function _p(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function Bp(r){return r.pointerType===""&&r.isTrusted?true:Np()&&r.pointerType?r.type==="click"&&r.buttons===1:r.detail===0&&!r.pointerType}var ua=r=>r.button===2||yr()&&r.ctrlKey&&r.button===0,Hp=r=>r.ctrlKey||r.altKey||r.metaKey,u0=r=>"touches"in r&&r.touches.length>0,h0={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},Vp={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function Hc(r,e={}){let{dir:t="ltr",orientation:n="horizontal"}=e,i=r.key;return i=h0[i]??i,t==="rtl"&&n==="horizontal"&&i in Vp&&(i=Vp[i]),i}function wr(r,e="client"){let t=u0(r)?r.touches[0]||r.changedTouches[0]:r;return {x:t[`${e}X`],y:t[`${e}Y`]}}var Le=(r,e,t,n)=>{let i=typeof r=="function"?r():r;return i?.addEventListener(e,t,n),()=>{i?.removeEventListener(e,t,n);}};var zp=r=>Q(r)&&r.tagName==="IFRAME",p0=/^(audio|video|details)$/;function $p(r){let e=r.getAttribute("tabindex");return e?parseInt(e,10):NaN}var m0=r=>!Number.isNaN($p(r)),f0=r=>$p(r)<0;function g0(r){return Ac(r)&&r.type==="radio"}function b0(r){if(!g0(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&&Ge(o)),i=n.find(o=>o.checked);return i?i===r:n[0]===r}function v0(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 Wp(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=v0(l,e);if(c){let d=Array.from(c.querySelectorAll(ha)).filter(t),u=s.get(l);if(u!==void 0){let h=u+1;n.splice(h,0,...d),d.forEach((p,m)=>{s.set(p,h+m);});for(let p=h+d.length;p<n.length;p++)s.set(n[p],p);}else {let h=n.length;n.push(...d),d.forEach((p,m)=>{s.set(p,h+m);});}i.push(...d);}}return n}var ha="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",zc=(r,e={})=>{if(!r)return [];let{includeContainer:t=false,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(ha));(t==true||t=="if-empty"&&i.length===0)&&Q(r)&&Ge(r)&&i.unshift(r);let s=[];for(let a of i)if(Ge(a)){if(zp(a)&&a.contentDocument){let l=a.contentDocument.body;s.push(...zc(l,{getShadowRoot:n}));continue}s.push(a);}return n?Wp(s,n,Ge):s};function Ge(r){return !Q(r)||r.closest("[inert]")?false:r.matches(ha)&&Lp(r)}function xr(r,e={}){if(!r)return [];let{includeContainer:t,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(ha));t&&tn(r)&&i.unshift(r);let o=[];for(let s of i)if(tn(s)){if(zp(s)&&s.contentDocument){let a=s.contentDocument.body;o.push(...xr(a,{getShadowRoot:n}));continue}o.push(s);}if(n){let s=Wp(o,n,tn);return !s.length&&t?i:s}return !o.length&&t?i:o}function tn(r){return Q(r)&&r.tabIndex>0?true:!Ge(r)||f0(r)?false:b0(r)}function Gp(r,e={}){let t=xr(r,e),n=t[0]||null,i=t[t.length-1]||null;return [n,i]}function Sr(r){return r.tabIndex<0&&(p0.test(r.localName)||br(r))&&!m0(r)?0:r.tabIndex}function pa(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=xr(e);o=n?s.filter(n)[0]:s[0];}return o||e||void 0}function Up(r){let e=r.currentTarget;if(!e)return false;let[t,n]=Gp(e);return !(Di(t)&&r.shiftKey||Di(n)&&!r.shiftKey||!t&&!n)}var y0=class Yp{constructor(){la(this,"id",null),la(this,"fn_cleanup"),la(this,"cleanup",()=>{this.cancel();});}static create(){return new Yp}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 ue(r){let e=y0.create();return e.request(r),e.cleanup}function Kp(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 Xp(r,e,t){let n=ue(()=>{r.removeEventListener(e,i,true),t();}),i=()=>{n(),t();};return r.addEventListener(e,i,{once:true,capture:true}),n}function w0(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 jp(r,e){let n=ue,i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(w0(o,e));})),()=>{i.forEach(o=>o?.());}}function qp(r){let e=()=>{let t=ae(r);r.dispatchEvent(new t.MouseEvent("click"));};Fp()?Xp(r,"keyup",e):queueMicrotask(e);}function ma(r){let e=Mp(r);return Tp(e)?ce(e).body:Q(e)&&$c(e)?e:ma(e)}var x0=/auto|scroll|overlay|hidden|clip/,S0=new Set(["inline","contents"]);function $c(r){let e=ae(r),{overflow:t,overflowX:n,overflowY:i,display:o}=e.getComputedStyle(r);return x0.test(t+i+n)&&!S0.has(o)}function Cr(r,e){return Array.from(r?.querySelectorAll(e)??[])}var fa=r=>r.id;function C0(r,e,t=fa){return r.find(n=>t(n)===e)}function Zp(r,e,t=fa){let n=C0(r,e,t);return n?r.indexOf(n):-1}function T0(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth}function Jp(r,e){let{rootEl:t,...n}=e||{};!r||!t||!$c(t)||!T0(t)||r.scrollIntoView(n);}var E0=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(),P0=r=>E0(r.dataset?.valuetext??r.textContent??""),L0=(r,e)=>r.trim().toLowerCase().startsWith(e.toLowerCase());function Qp(r,e,t,n=fa){let i=t?Zp(r,t,n):-1,o=t?Sp(r,i):r;return e.length===1&&(o=o.filter(a=>n(a)!==t)),o.find(a=>L0(P0(a),e))}function Oi(r,e){if(!r)return Ii;let t=Object.keys(e).reduce((n,i)=>(n[i]=r.style.getPropertyValue(i),n),{});return M0(t,e)?Ii:(Object.assign(r.style,e),()=>{Object.assign(r.style,t),r.style.length===0&&r.removeAttribute("style");})}function em(r,e,t){if(!r)return Ii;let n=r.style.getPropertyValue(e);return n===t?Ii:(r.style.setProperty(e,t),()=>{r.style.setProperty(e,n),r.style.length===0&&r.removeAttribute("style");})}function M0(r,e){return Object.keys(r).every(t=>r[t]===e[t])}function k0(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,d=r.slice(),u=Qp(d,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),u}var ga=Object.assign(k0,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:I0});function I0(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function A0(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 tm(r,e){let{timeout:t,rootNode:n}=e,i=ae(n),o=ce(n),s=new i.AbortController;return A0(new Promise(a=>{let l=r();if(l){a(l);return}let c=new i.MutationObserver(()=>{let d=r();d&&d.isConnected&&(c.disconnect(),a(d));});c.observe(o.body,{childList:true,subtree:true});}),s,t)}function nm(r){let e=()=>r.getRootNode?.()??document,t=()=>ce(e());return {...r,getRootNode:e,getDoc:t,getWin:()=>t().defaultView??window,getActiveElement:()=>mt(e()),isActiveElement:Di,getById:s=>e().getElementById(s)}}function rm(r){return new Proxy({},{get(e,t){return t==="style"?n=>r({style:n}).style:r}})}var im={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},R0=new Set(["viewBox","preserveAspectRatio"]),D0=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},Tr=rm(r=>Object.entries(r).reduce((e,[t,n])=>{if(n===void 0)return e;if(t in im&&(t=im[t]),t==="style"&&typeof n=="object")return e.style=D0(n),e;let i=R0.has(t)?t:t.toLowerCase();return e[i]=n,e},{}));var ba=new WeakMap,om=new Set(["value","checked","selected"]),O0=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),F0=r=>r.tagName==="svg"||r.namespaceURI==="http://www.w3.org/2000/svg",va=(r,e)=>F0(r)&&O0.has(e)?e:e.toLowerCase();function Fe(r,e,t){let n=t||"default",i=ba.get(r);i||(i=new Map,ba.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"),d=f=>!f.startsWith("on"),u=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(om.has(f)){r[f]=g??"";return}if(typeof g=="boolean"&&!f.includes("aria-")){r.toggleAttribute(va(r,f),g);return}if(f==="children"){r.innerHTML=g;return}if(g!=null){r.setAttribute(va(r,f),g);return}r.removeAttribute(va(r,f));}};for(let f in o)e[f]==null&&(f==="class"?r.className="":om.has(f)?r[f]="":r.removeAttribute(va(r,f)));return Object.keys(o).filter(c).forEach(f=>{l(f.substring(2),o[f]);}),s.filter(c).forEach(u),s.filter(d).forEach(p),i.set(n,e),function(){s.filter(c).forEach(h);let g=ba.get(r);g&&(g.delete(n),g.size===0&&ba.delete(r));}}function N0(){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 Wc(r,e){let t=N0();return t?(t[r]||(t[r]=e()),t[r]):e()}var Er=Wc("__zag__refSet",()=>new WeakSet);var V0=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,_0=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,B0=r=>typeof r=="object"&&r!==null&&"nodeType"in r&&typeof r.nodeName=="string",H0=r=>V0(r)||_0(r)||B0(r),ya=r=>r!==null&&typeof r=="object",Gc=r=>ya(r)&&!Er.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!H0(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 z0=Symbol();var sm=Object.getPrototypeOf,Uc=new WeakMap,$0=r=>r&&(Uc.has(r)?Uc.get(r):sm(r)===Object.prototype||sm(r)===Array.prototype);var am=r=>$0(r)&&r[z0]||null,Yc=(r,e=true)=>{Uc.set(r,e);};var Dn=Wc("__zag__proxyStateMap",()=>new WeakMap),W0=(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 d=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return Yc(d,true),t.set(a,[l,d]),Reflect.ownKeys(a).forEach(u=>{let h=Reflect.get(a,u);Er.has(h)?(Yc(h,false),d[u]=h):Dn.has(h)?d[u]=lm(h):d[u]=h;}),Object.freeze(d)},i=new WeakMap,o=[1,1],s=a=>{if(!ya(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=o[0],d=new Set,u=(S,E=++o[0])=>{c!==E&&(c=E,d.forEach(L=>L(S,E)));},h=o[1],p=(S=++o[1])=>(h!==S&&!d.size&&(h=S,f.forEach(([E])=>{let L=E[1](S);L>c&&(c=L);})),c),m=S=>(E,L)=>{let T=[...E];T[1]=[S,...T[1]],u(T,L);},f=new Map,g=(S,E)=>{if(d.size){let L=E[3](m(S));f.set(S,[E,L]);}else f.set(S,[E]);},b=S=>{let E=f.get(S);E&&(f.delete(S),E[1]?.());},v=S=>(d.add(S),d.size===1&&f.forEach(([L,T],k)=>{let M=L[3](m(k));f.set(k,[L,M]);}),()=>{d.delete(S),d.size===0&&f.forEach(([L,T],k)=>{T&&(T(),f.set(k,[L]));});}),y=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),P=e(y,{deleteProperty(S,E){let L=Reflect.get(S,E);b(E);let T=Reflect.deleteProperty(S,E);return T&&u(["delete",[E],L]),T},set(S,E,L,T){let k=Reflect.has(S,E),M=Reflect.get(S,E,T);if(k&&(r(M,L)||i.has(L)&&r(M,i.get(L))))return true;b(E),ya(L)&&(L=am(L)||L);let C=L;if(!Object.getOwnPropertyDescriptor(S,E)?.set){!Dn.has(L)&&Gc(L)&&(C=wa(L));let I=!Er.has(C)&&Dn.get(C);I&&g(E,I);}return Reflect.set(S,E,C,T),u(["set",[E],L,M]),true}});i.set(a,P);let x=[y,p,n,v];return Dn.set(P,x),Reflect.ownKeys(a).forEach(S=>{let E=Object.getOwnPropertyDescriptor(a,S);E.get||E.set?Object.defineProperty(y,S,E):P[S]=a[S];}),P})=>[s,Dn,Er,r,e,Gc,t,n,i,o],[G0]=W0();function wa(r={}){return G0(r)}function xa(r,e,t){let n=Dn.get(r);let i,o=[],s=n[3],a=false,c=s(d=>{if(o.push(d),t);i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(o.splice(0));}));});return a=true,()=>{a=false,c();}}function lm(r){let e=Dn.get(r);let[t,n,i]=e;return i(t,n())}function Ni(r){let e=r().value??r().defaultValue;r().debug&&console.log(`[bindable > ${r().debug}] initial`,e);let t=r().isEqual??Object.is,n=wa({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=De(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)}}}Ni.cleanup=r=>{};Ni.ref=r=>{let e=r;return {get:()=>e,set:t=>{e=t;}}};function cm(r){let e={current:r};return {get(t){return e.current[t]},set(t,n){e.current[t]=n;}}}function Kc(r,e){if(!An(r)||!An(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&&(An(o)&&An(i)?t[n]=Kc(o,i):t[n]=i);}return t}var Xc=class{constructor(r,e={}){Z(this,"machine",r),Z(this,"scope"),Z(this,"context"),Z(this,"prop"),Z(this,"state"),Z(this,"refs"),Z(this,"computed"),Z(this,"event",{type:""}),Z(this,"previousEvent",{type:""}),Z(this,"effects",new Map),Z(this,"transition",null),Z(this,"cleanups",[]),Z(this,"subscriptions",[]),Z(this,"userPropsRef"),Z(this,"getEvent",()=>({...this.event,current:()=>this.event,previous:()=>this.previousEvent})),Z(this,"getState",()=>({...this.state,matches:(...u)=>u.some(h=>yp(this.state.get(),h)),hasTag:u=>wp(this.machine,this.state.get(),u)})),Z(this,"debug",(...u)=>{this.machine.debug&&console.log(...u);}),Z(this,"notify",()=>{this.publish();}),Z(this,"send",u=>{this.status===gr.Started&&queueMicrotask(()=>{if(!u)return;this.previousEvent=this.event,this.event=u,this.debug("send",u);let h=this.state.get(),p=u.type,{transitions:m,source:f}=bp(this.machine,h,p),g=this.choose(m);if(!g)return;this.transition=g;let b=kc(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);});}),Z(this,"action",u=>{let h=De(u)?u(this.getParams()):u;if(!h)return;let p=h.map(m=>{let f=this.machine.implementations?.actions?.[m];return f||mr(`[zag-js] No implementation found for action "${JSON.stringify(m)}"`),f});for(let m of p)m?.(this.getParams());}),Z(this,"guard",u=>{if(De(u))return u(this.getParams());let h=this.machine.implementations?.guards?.[u];return h||mr(`[zag-js] No implementation found for guard "${JSON.stringify(u)}"`),h?.(this.getParams())}),Z(this,"effect",u=>{let h=De(u)?u(this.getParams()):u;if(!h)return;let p=h.map(f=>{let g=this.machine.implementations?.effects?.[f];return g||mr(`[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?.())}),Z(this,"choose",u=>ep(u).find(h=>{let p=!h.guard;return pr(h.guard)?p=!!this.guard(h.guard):De(h.guard)&&(p=h.guard(this.getParams())),p})),Z(this,"subscribe",u=>(this.subscriptions.push(u),()=>{let h=this.subscriptions.indexOf(u);h>-1&&this.subscriptions.splice(h,1);})),Z(this,"status",gr.NotStarted),Z(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(u=>u(this.service));}),Z(this,"trackers",[]),Z(this,"setupTrackers",()=>{this.machine.watch?.(this.getParams());}),Z(this,"callTrackers",()=>{this.trackers.forEach(({deps:u,fn:h})=>{let p=u.map(m=>m());hr(h.prev,p)||(h(),h.prev=p);});}),Z(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(u,h)=>{h.prev=u.map(p=>p()),this.trackers.push({deps:u,fn:h});},refs:this.refs,computed:this.computed,flush:cp,scope:this.scope,choose:this.choose})),this.userPropsRef={current:e};let{id:t,ids:n,getRootNode:i}=Pi(e);this.scope=nm({id:t,ids:n,getRootNode:i});let o=u=>{let h=Pi(this.userPropsRef.current);return (r.props?.({props:Qt(h),scope:this.scope})??h)[u]};this.prop=o;let s=r.context?.({prop:o,bindable:Ni,scope:this.scope,flush(u){queueMicrotask(u);},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});s&&Object.values(s).forEach(u=>{let h=xa(u.ref,()=>this.notify());this.cleanups.push(h);});let a={get(u){return s?.[u].get()},set(u,h){s?.[u].set(h);},initial(u){return s?.[u].initial},hash(u){let h=s?.[u].get();return s?.[u].hash(h)}};this.context=a;let l=u=>(Li(r.computed,()=>"[zag-js] No computed object found on machine"),r.computed[u]({context:a,event:this.getEvent(),prop:o,refs:this.refs,scope:this.scope,computed:l}));this.computed=l;let c=cm(r.refs?.({prop:o,context:a})??{});this.refs=c;let d=Ni(()=>({defaultValue:kc(r,r.initialState({prop:o})),onChange:(u,h)=>{let{exiting:p,entering:m}=vp(this.machine,h,u,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?Jt(b,g):g);}}),h===ki){this.action(r.entry);let f=this.effect(r.effects);if(f){let g=this.effects.get(ki);this.effects.set(ki,g?Jt(g,f):f);}}m.forEach(f=>{this.action(f.state?.entry);});}}));this.state=d,this.cleanups.push(xa(this.state.ref,()=>this.notify()));}updateProps(r){let e=this.userPropsRef.current;this.userPropsRef.current=()=>{let t=Pi(e),n=Pi(r);return Kc(t,n)},this.notify();}start(){this.status=gr.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,ki),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=gr.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 Sa(r,e,t){let n=new Xc(r,e),i=n.subscribe(t);return n.start(),t(n.service),{service:n.service,flush:()=>t(n.service),stop:()=>{i(),n.stop();}}}var U0=0;function Ca(r){return `${r}-${++U0}`}function On(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 dm="outline:none;transition:border-color .12s ease,box-shadow .12s ease;",um="border-color:var(--vela-focus);box-shadow:0 0 0 3px var(--vela-focus-soft);";function oe(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 Me(r,e=document){let t=e.createElement("span");t.className="vela-icon",t.setAttribute("aria-hidden","true");let n=zo(r);return n&&(t.innerHTML=n),t}var It=(r,e=[])=>({parts:(...t)=>{if(Y0(e))return It(r,t);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...t)=>It(r,[...e,...t]),omit:(...t)=>It(r,e.filter(n=>!t.includes(n))),rename:t=>It(t,e),keys:()=>e,build:()=>[...new Set(e)].reduce((t,n)=>Object.assign(t,{[n]:{selector:[`&[data-scope="${Pr(r)}"][data-part="${Pr(n)}"]`,`& [data-scope="${Pr(r)}"][data-part="${Pr(n)}"]`].join(", "),attrs:{"data-scope":Pr(r),"data-part":Pr(n)}}}),{})}),Pr=r=>r.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),Y0=r=>r.length===0;var K0=It("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),Se=K0.build();var mm=["top","right","bottom","left"];var ft=Math.min,Qe=Math.max,_i=Math.round,Bi=Math.floor,gt=r=>({x:r,y:r}),X0={left:"right",right:"left",bottom:"top",top:"bottom"};function jc(r,e,t){return Qe(r,ft(e,t))}function bt(r,e){return typeof r=="function"?r(e):r}function At(r){return r.split("-")[0]}function Fn(r){return r.split("-")[1]}function Ea(r){return r==="x"?"y":"x"}function Pa(r){return r==="y"?"height":"width"}function et(r){let e=r[0];return e==="t"||e==="b"?"y":"x"}function La(r){return Ea(et(r))}function fm(r,e,t){t===void 0&&(t=false);let n=Fn(r),i=La(r),o=Pa(i),s=i==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Vi(s)),[s,Vi(s)]}function gm(r){let e=Vi(r);return [Ta(r),e,Ta(e)]}function Ta(r){return r.includes("start")?r.replace("start","end"):r.replace("end","start")}var hm=["left","right"],pm=["right","left"],j0=["top","bottom"],q0=["bottom","top"];function Z0(r,e,t){switch(r){case "top":case "bottom":return t?e?pm:hm:e?hm:pm;case "left":case "right":return e?j0:q0;default:return []}}function bm(r,e,t,n){let i=Fn(r),o=Z0(At(r),t==="start",n);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(Ta)))),o}function Vi(r){let e=At(r);return X0[e]+r.slice(e.length)}function J0(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 qc(r){return typeof r!="number"?J0(r):{top:r,right:r,bottom:r,left:r}}function Nn(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 vm(r,e,t){let{reference:n,floating:i}=r,o=et(e),s=La(e),a=Pa(s),l=At(e),c=o==="y",d=n.x+n.width/2-i.width/2,u=n.y+n.height/2-i.height/2,h=n[a]/2-i[a]/2,p;switch(l){case "top":p={x:d,y:n.y-i.height};break;case "bottom":p={x:d,y:n.y+n.height};break;case "right":p={x:n.x+n.width,y:u};break;case "left":p={x:n.x-i.width,y:u};break;default:p={x:n.x,y:n.y};}let m=Fn(e);return m&&(p[s]+=h*(m==="end"?1:-1)*(t&&c?-1:1)),p}async function xm(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:d="viewport",elementContext:u="floating",altBoundary:h=false,padding:p=0}=bt(e,r),m=qc(p),g=a[h?u==="floating"?"reference":"floating":u],b=Nn(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:d,strategy:l})),v=u==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),w=await(o.isElement==null?void 0:o.isElement(y))&&await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1},P=Nn(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return {top:(b.top-P.top+m.top)/w.y,bottom:(P.bottom-b.bottom+m.bottom)/w.y,left:(b.left-P.left+m.left)/w.x,right:(P.right-b.right+m.right)/w.x}}var Q0=50,Sm=async(r,e,t)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:xm},l=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:r,floating:e,strategy:i}),{x:d,y:u}=vm(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:v}=g,{x:y,y:w,data:P,reset:x}=await v({x:d,y:u,initialPlacement:n,placement:h,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:r,floating:e}});d=y??d,u=w??u,m[b]={...m[b],...P},x&&p<Q0&&(p++,typeof x=="object"&&(x.placement&&(h=x.placement),x.rects&&(c=x.rects===true?await s.getElementRects({reference:r,floating:e,strategy:i}):x.rects),{x:d,y:u}=vm(c,h,l)),f=-1);}return {x:d,y:u,placement:h,strategy:i,middlewareData:m}},Cm=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:d=0}=bt(r,e)||{};if(c==null)return {};let u=qc(d),h={x:t,y:n},p=La(i),m=Pa(p),f=await s.getDimensions(c),g=p==="y",b=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",w=o.reference[m]+o.reference[p]-h[p]-o.floating[m],P=h[p]-o.reference[p],x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),S=x?x[y]:0;(!S||!await(s.isElement==null?void 0:s.isElement(x)))&&(S=a.floating[y]||o.floating[m]);let E=w/2-P/2,L=S/2-f[m]/2-1,T=ft(u[b],L),k=ft(u[v],L),M=S-f[m]-k,C=S/2-f[m]/2+E,I=jc(T,C,M),_=!l.arrow&&Fn(i)!=null&&C!==I&&o.reference[m]/2-(C<T?T:k)-f[m]/2<0,U=_?C<T?C-T:C-M:0;return {[p]:h[p]+U,data:{[p]:I,centerOffset:C-I-U,..._&&{alignmentOffset:U}},reset:_}}});var Tm=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:d=true,crossAxis:u=true,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:f=true,...g}=bt(r,e);if((t=o.arrow)!=null&&t.alignmentOffset)return {};let b=At(i),v=et(a),y=At(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),P=h||(y||!f?[Vi(a)]:gm(a)),x=m!=="none";!h&&x&&P.push(...bm(a,f,m,w));let S=[a,...P],E=await l.detectOverflow(e,g),L=[],T=((n=o.flip)==null?void 0:n.overflows)||[];if(d&&L.push(E[b]),u){let I=fm(i,s,w);L.push(E[I[0]],E[I[1]]);}if(T=[...T,{placement:i,overflows:L}],!L.every(I=>I<=0)){var k,M;let I=(((k=o.flip)==null?void 0:k.index)||0)+1,_=S[I];if(_&&(!(u==="alignment"?v!==et(_):false)||T.every(z=>et(z.placement)===v?z.overflows[0]>0:true)))return {data:{index:I,overflows:T},reset:{placement:_}};let U=(M=T.filter(Y=>Y.overflows[0]<=0).sort((Y,z)=>Y.overflows[1]-z.overflows[1])[0])==null?void 0:M.placement;if(!U)switch(p){case "bestFit":{var C;let Y=(C=T.filter(z=>{if(x){let He=et(z.placement);return He===v||He==="y"}return true}).map(z=>[z.placement,z.overflows.filter(He=>He>0).reduce((He,By)=>He+By,0)]).sort((z,He)=>z[1]-He[1])[0])==null?void 0:C[0];Y&&(U=Y);break}case "initialPlacement":U=a;break}if(i!==U)return {reset:{placement:U}}}return {}}}};function ym(r,e){return {top:r.top-e.height,right:r.right-e.width,bottom:r.bottom-e.height,left:r.left-e.width}}function wm(r){return mm.some(e=>r[e]>=0)}var Em=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(e){let{rects:t,platform:n}=e,{strategy:i="referenceHidden",...o}=bt(r,e);switch(i){case "referenceHidden":{let s=await n.detectOverflow(e,{...o,elementContext:"reference"}),a=ym(s,t.reference);return {data:{referenceHiddenOffsets:a,referenceHidden:wm(a)}}}case "escaped":{let s=await n.detectOverflow(e,{...o,altBoundary:true}),a=ym(s,t.floating);return {data:{escapedOffsets:a,escaped:wm(a)}}}default:return {}}}}};var Pm=new Set(["left","top"]);async function eC(r,e){let{placement:t,platform:n,elements:i}=r,o=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=At(t),a=Fn(t),l=et(t)==="y",c=Pm.has(s)?-1:1,d=o&&l?-1:1,u=bt(e,r),{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*d,y:h*c}:{x:h*c,y:p*d}}var Lm=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 eC(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}}}}},Mm=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:v=>{let{x:y,y:w}=v;return {x:y,y:w}}},...c}=bt(r,e),d={x:t,y:n},u=await o.detectOverflow(e,c),h=et(i),p=Ea(h),m=d[p],f=d[h],g=(v,y)=>jc(y+u[v==="y"?"top":"left"],y,y-u[v==="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}}}}}},km=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:d=true,crossAxis:u=true}=bt(r,e),h={x:i,y:o},p=et(s),m=Ea(p),f=h[m],g=h[p],b=bt(c,e),v=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(n=b.crossAxis)!=null?n:0};if(d){let P=m==="y"?"height":"width",x=a.reference[m]-a.floating[P]+v.mainAxis,S=a.reference[m]+a.reference[P]-v.mainAxis;f<x?f=x:f>S&&(f=S);}if(u){var y,w;let P=m==="y"?"width":"height",x=Pm.has(At(s)),S=a.reference[p]-a.floating[P]+(x&&((y=l.offset)==null?void 0:y[p])||0)+(x?0:v.crossAxis),E=a.reference[p]+a.reference[P]+(x?0:((w=l.offset)==null?void 0:w[p])||0)-(x?v.crossAxis:0);g<S?g=S:g>E&&(g=E);}return {[m]:f,[p]:g}}}},Im=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}=bt(r,e),l=await i.detectOverflow(e,a),c=At(t),d=Fn(t),u=et(t)==="y",{width:h,height:p}=n.floating,m,f;c==="top"||c==="bottom"?(m=c,f=d===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(f=c,m=d==="end"?"top":"bottom");let g=p-l.top-l.bottom,b=h-l.left-l.right,v=ft(p-l[m],g),y=ft(h-l[f],b),w=e.middlewareData.shift,P=!w,x=v,S=y;w!=null&&w.enabled.x&&(S=b),w!=null&&w.enabled.y&&(x=g),P&&!d&&(u?S=h-2*Qe(l.left,l.right):x=p-2*Qe(l.top,l.bottom)),await s({...e,availableWidth:S,availableHeight:x});let E=await i.getDimensions(o.floating);return h!==E.width||p!==E.height?{reset:{rects:true}}:{}}}};function Ma(){return typeof window<"u"}function _n(r){return Rm(r)?(r.nodeName||"").toLowerCase():"#document"}function ke(r){var e;return (r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function vt(r){var e;return (e=(Rm(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function Rm(r){return Ma()?r instanceof Node||r instanceof ke(r).Node:false}function tt(r){return Ma()?r instanceof Element||r instanceof ke(r).Element:false}function Rt(r){return Ma()?r instanceof HTMLElement||r instanceof ke(r).HTMLElement:false}function Am(r){return !Ma()||typeof ShadowRoot>"u"?false:r instanceof ShadowRoot||r instanceof ke(r).ShadowRoot}function Hi(r){let{overflow:e,overflowX:t,overflowY:n,display:i}=nt(r);return /auto|scroll|overlay|hidden|clip/.test(e+n+t)&&i!=="inline"&&i!=="contents"}function Dm(r){return /^(table|td|th)$/.test(_n(r))}function zi(r){try{if(r.matches(":popover-open"))return !0}catch{}try{return r.matches(":modal")}catch{return false}}var tC=/transform|translate|scale|rotate|perspective|filter/,nC=/paint|layout|strict|content/,Vn=r=>!!r&&r!=="none",Zc;function ka(r){let e=tt(r)?nt(r):r;return Vn(e.transform)||Vn(e.translate)||Vn(e.scale)||Vn(e.rotate)||Vn(e.perspective)||!Ia()&&(Vn(e.backdropFilter)||Vn(e.filter))||tC.test(e.willChange||"")||nC.test(e.contain||"")}function Om(r){let e=nn(r);for(;Rt(e)&&!Mr(e);){if(ka(e))return e;if(zi(e))return null;e=nn(e);}return null}function Ia(){return Zc==null&&(Zc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Zc}function Mr(r){return /^(html|body|#document)$/.test(_n(r))}function nt(r){return ke(r).getComputedStyle(r)}function $i(r){return tt(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function nn(r){if(_n(r)==="html")return r;let e=r.assignedSlot||r.parentNode||Am(r)&&r.host||vt(r);return Am(e)?e.host:e}function Fm(r){let e=nn(r);return Mr(e)?(r.ownerDocument||r).body:Rt(e)&&Hi(e)?e:Fm(e)}function Lr(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=true);let i=Fm(r),o=i===((n=r.ownerDocument)==null?void 0:n.body),s=ke(i);if(o){let a=Aa(s);return e.concat(s,s.visualViewport||[],Hi(i)?i:[],a&&t?Lr(a):[])}else return e.concat(i,Lr(i,[],t))}function Aa(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}function _m(r){let e=nt(r),t=parseFloat(e.width)||0,n=parseFloat(e.height)||0,i=Rt(r),o=i?r.offsetWidth:t,s=i?r.offsetHeight:n,a=_i(t)!==o||_i(n)!==s;return a&&(t=o,n=s),{width:t,height:n,$:a}}function Qc(r){return tt(r)?r:r.contextElement}function kr(r){let e=Qc(r);if(!Rt(e))return gt(1);let t=e.getBoundingClientRect(),{width:n,height:i,$:o}=_m(e),s=(o?_i(t.width):t.width)/n,a=(o?_i(t.height):t.height)/i;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var rC=gt(0);function Bm(r){let e=ke(r);return !Ia()||!e.visualViewport?rC:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function iC(r,e,t){return e===void 0&&(e=false),!!t&&e&&t===ke(r)}function Bn(r,e,t,n){e===void 0&&(e=false),t===void 0&&(t=false);let i=r.getBoundingClientRect(),o=Qc(r),s=gt(1);e&&(n?tt(n)&&(s=kr(n)):s=kr(r));let a=iC(o,t,n)?Bm(o):gt(0),l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,d=i.width/s.x,u=i.height/s.y;if(o&&n){let h=ke(o),p=tt(n)?ke(n):n,m=h,f=Aa(m);for(;f&&p!==m;){let g=kr(f),b=f.getBoundingClientRect(),v=nt(f),y=b.left+(f.clientLeft+parseFloat(v.paddingLeft))*g.x,w=b.top+(f.clientTop+parseFloat(v.paddingTop))*g.y;l*=g.x,c*=g.y,d*=g.x,u*=g.y,l+=y,c+=w,m=ke(f),f=Aa(m);}}return Nn({width:d,height:u,x:l,y:c})}function Ra(r,e){let t=$i(r).scrollLeft;return e?e.left+t:Bn(vt(r)).left+t}function Hm(r,e){let t=r.getBoundingClientRect(),n=t.left+e.scrollLeft-Ra(r,t),i=t.top+e.scrollTop;return {x:n,y:i}}function oC(r){let{elements:e,rect:t,offsetParent:n,strategy:i}=r,o=i==="fixed",s=vt(n),a=e?zi(e.floating):false;if(n===s||a&&o)return t;let l={scrollLeft:0,scrollTop:0},c=gt(1),d=gt(0),u=Rt(n);if((u||!o)&&((_n(n)!=="body"||Hi(s))&&(l=$i(n)),u)){let p=Bn(n);c=kr(n),d.x=p.x+n.clientLeft,d.y=p.y+n.clientTop;}let h=s&&!u&&!o?Hm(s,l):gt(0);return {width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:t.y*c.y-l.scrollTop*c.y+d.y+h.y}}function sC(r){return r.getClientRects?Array.from(r.getClientRects()):[]}function aC(r){let e=$i(r),t=r.ownerDocument.body,n=Qe(r.scrollWidth,r.clientWidth,t.scrollWidth,t.clientWidth),i=Qe(r.scrollHeight,r.clientHeight,t.scrollHeight,t.clientHeight),o=-e.scrollLeft+Ra(r),s=-e.scrollTop;return nt(t).direction==="rtl"&&(o+=Qe(r.clientWidth,t.clientWidth)-n),{width:n,height:i,x:o,y:s}}var lC=25;function cC(r,e,t){t===void 0&&(t="viewport");let n=t==="layoutViewport",i=ke(r),o=vt(r),s=i.visualViewport,a=o.clientWidth,l=o.clientHeight,c=0,d=0;if(s){let h=!Ia()||e==="fixed";n?h||(c=-s.offsetLeft,d=-s.offsetTop):(a=s.width,l=s.height,h&&(c=s.offsetLeft,d=s.offsetTop));}if(Ra(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<=lC&&(a-=b);}return {width:a,height:l,x:c,y:d}}function dC(r,e){let t=Bn(r,true,e==="fixed"),n=t.top+r.clientTop,i=t.left+r.clientLeft,o=kr(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 Nm(r,e,t){let n;if(e==="viewport"||e==="layoutViewport")n=cC(r,t,e);else if(e==="document")n=aC(vt(r));else if(tt(e))n=dC(e,t);else {let i=Bm(r);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height};}return Nn(n)}function uC(r,e){let t=e.get(r);if(t)return t;let n=Lr(r,[],false).filter(a=>tt(a)&&_n(a)!=="body"),i=null,o=nt(r).position==="fixed",s=o?nn(r):r;for(;tt(s)&&!Mr(s);){let a=nt(s),l=ka(s),c=i?i.position:o?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?n=n.filter(u=>u!==s):i=a,s=nn(s);}return e.set(r,n),n}function hC(r){let{element:e,boundary:t,rootBoundary:n,strategy:i}=r,s=[...t==="clippingAncestors"?zi(e)?[]:uC(e,this._c):[].concat(t),n],a=Nm(e,s[0],i),l=a.top,c=a.right,d=a.bottom,u=a.left;for(let h=1;h<s.length;h++){let p=Nm(e,s[h],i);l=Qe(p.top,l),c=ft(p.right,c),d=ft(p.bottom,d),u=Qe(p.left,u);}return {width:c-u,height:d-l,x:u,y:l}}function pC(r){let{width:e,height:t}=_m(r);return {width:e,height:t}}function mC(r,e,t){let n=Rt(e),i=vt(e),o=t==="fixed",s=Bn(r,true,o,e),a={scrollLeft:0,scrollTop:0},l=gt(0);if((n||!o)&&((_n(e)!=="body"||Hi(i))&&(a=$i(e)),n)){let h=Bn(e,true,o,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop;}!n&&i&&(l.x=Ra(i));let c=i&&!n&&!o?Hm(i,a):gt(0),d=s.left+a.scrollLeft-l.x-c.x,u=s.top+a.scrollTop-l.y-c.y;return {x:d,y:u,width:s.width,height:s.height}}function Jc(r){return nt(r).position==="static"}function Vm(r,e){if(!Rt(r)||nt(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return vt(r)===t&&(t=t.ownerDocument.body),t}function zm(r,e){let t=ke(r);if(zi(r))return t;if(!Rt(r)){let i=nn(r);for(;i&&!Mr(i);){if(tt(i)&&!Jc(i))return i;i=nn(i);}return t}let n=Vm(r,e);for(;n&&Dm(n)&&Jc(n);)n=Vm(n,e);return n&&Mr(n)&&Jc(n)&&!ka(n)?t:n||Om(r)||t}var fC=async function(r){let e=this.getOffsetParent||zm,t=this.getDimensions,n=await t(r.floating);return {reference:mC(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function gC(r){return nt(r).direction==="rtl"}var bC={convertOffsetParentRelativeRectToViewportRelativeRect:oC,getDocumentElement:vt,getClippingRect:hC,getOffsetParent:zm,getElementRects:fC,getClientRects:sC,getDimensions:pC,getScale:kr,isElement:tt,isRTL:gC};function $m(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function vC(r,e,t){let n=null,i,o=vt(r);function s(){var d;clearTimeout(i),(d=n)==null||d.disconnect(),n=null;}function a(d,u){d===void 0&&(d=false),u===void 0&&(u=1),s();let h=r.getBoundingClientRect(),{left:p,top:m,width:f,height:g}=h;if(d||e(),!f||!g)return;let b=Bi(m),v=Bi(o.clientWidth-(p+f)),y=Bi(o.clientHeight-(m+g)),w=Bi(p),x={rootMargin:-b+"px "+-v+"px "+-y+"px "+-w+"px",threshold:Qe(0,ft(1,u))||1},S=true;function E(L){let T=L[0].intersectionRatio;if(!$m(h,r.getBoundingClientRect()))return a();if(T!==u){if(!S)return a();T?a(false,T):i=setTimeout(()=>{a(false,1e-7);},1e3);}S=false;}try{n=new IntersectionObserver(E,{...x,root:o.ownerDocument});}catch{n=new IntersectionObserver(E,x);}n.observe(r);}let l=ke(r),c=()=>a(t);return l.addEventListener("resize",c),a(true),()=>{l.removeEventListener("resize",c),s();}}function Wm(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=Qc(r),d=i||o?[...c?Lr(c):[],...e?Lr(e):[]]:[];d.forEach(b=>{i&&b.addEventListener("scroll",t),o&&b.addEventListener("resize",t);});let u=c&&a?vC(c,t,o):null,h=-1,p=null;s&&(p=new ResizeObserver(b=>{let[v]=b;v&&v.target===c&&p&&e&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(e);})),t();}),c&&!l&&p.observe(c),e&&p.observe(e));let m,f=l?Bn(r):null;l&&g();function g(){let b=Bn(r);f&&!$m(f,b)&&t(),f=b,m=requestAnimationFrame(g);}return t(),()=>{var b;d.forEach(v=>{i&&v.removeEventListener("scroll",t),o&&v.removeEventListener("resize",t);}),u?.(),(b=p)==null||b.disconnect(),p=null,l&&cancelAnimationFrame(m);}}var Gm=Lm;var Um=Mm,Ym=Tm,Km=Im,Xm=Em,jm=Cm;var qm=km,Zm=(r,e,t)=>{let n=new Map,i=t??{},o={...bC,...i.platform,_c:n};return Sm(r,e,{...i,platform:o})};function Jm(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 yC(r){if(!r)return Jm();let{x:e,y:t,width:n,height:i}=r;return Jm(e,t,n,i)}function Qm(r,e){return {contextElement:Q(r)?r:r?.contextElement,getBoundingClientRect:()=>{let t=r,n=e?.(t);return n||!t?yC(n):t.getBoundingClientRect()}}}var Wi=r=>({variable:r,reference:`var(${r})`}),yt={arrowSize:Wi("--arrow-size"),arrowSizeHalf:Wi("--arrow-size-half"),arrowBg:Wi("--arrow-background"),transformOrigin:Wi("--transform-origin"),arrowOffset:Wi("--arrow-offset")},wC=r=>r==="top"||r==="bottom"?"y":"x";function ef(r,e){return {name:"transformOrigin",fn(t){let{elements:n,middlewareData:i,placement:o,rects:s,y:a}=t,l=o.split("-")[0],c=wC(l),d=i.arrow?.x||0,u=i.arrow?.y||0,h=e?.clientWidth||0,p=e?.clientHeight||0,m=d+h/2,f=u+p/2,g=Math.abs(i.shift?.y||0),b=s.reference.height/2,v=p/2,y=r.offset?.mainAxis??r.gutter,w=typeof y=="number"?y+v:y??v,P=g>w,x={top:`${m}px calc(100% + ${w}px)`,bottom:`${m}px ${-w}px`,left:`calc(100% + ${w}px) ${f}px`,right:`${-w}px ${f}px`}[l],S=`${m}px ${s.reference.y+b-a}px`,E=!!r.overlap&&c==="y"&&P;return n.floating.style.setProperty(yt.transformOrigin.variable,E?S:x),{data:{transformOrigin:E?S:x}}}}}var tf={name:"rects",fn({rects:r}){return {data:r}}},nf=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% + ${yt.arrowOffset.reference})`}),{}}}};function rf(r){let[e,t]=r.split("-");return {side:e,align:t,hasAlign:t!=null}}function Gi(r){return r.split("-")[0]}var xC={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 of(r,e){let t=r.devicePixelRatio||1;return Math.round(e*t)/t}function Ir(r,e){return r!=null&&Math.abs(r-e)<.5}function Da(r){return typeof r=="function"?r():r==="clipping-ancestors"?"clippingAncestors":r}function SC(r,e,t){let n=r||e.createElement("div");return jm({element:n,padding:t.arrowPadding})}function CC(r,e){if(!ap(e.offset??e.gutter))return Gm(({placement:t})=>{let n=(r?.clientHeight||0)/2,i=e.offset?.mainAxis??e.gutter,o=typeof i=="number"?i+n:i??n,{hasAlign:s}=rf(t),a=s?void 0:e.shift,l=e.offset?.crossAxis??a;return Qt({crossAxis:l,mainAxis:o,alignmentAxis:e.shift})})}function TC(r){if(r.flip)return Ym(()=>{let e=Da(r.boundary);return {...e?{boundary:e}:void 0,padding:r.overflowPadding,fallbackPlacements:r.flip===true?void 0:r.flip}})}function EC(r){if(!(!r.slide&&!r.overlap))return Um(()=>{let e=Da(r.boundary);return {...e?{boundary:e}:void 0,mainAxis:r.slide,crossAxis:r.overlap,padding:r.overflowPadding,limiter:qm()}})}function PC(r){if(r.sizeMiddleware===false&&!r.sameWidth&&!r.fitViewport)return;let e,t,n,i;return Km(()=>{let o=Da(r.boundary);return {padding:r.overflowPadding,...o?{boundary:o}:void 0,apply({elements:s,rects:a,availableHeight:l,availableWidth:c}){let d=s.floating,u=Math.round(a.reference.width),h=Math.round(a.reference.height);c=Math.floor(c),l=Math.floor(l),Ir(e,u)||(d.style.setProperty("--reference-width",`${u}px`),e=u),Ir(t,h)||(d.style.setProperty("--reference-height",`${h}px`),t=h),Ir(n,c)||(d.style.setProperty("--available-width",`${c}px`),n=c),Ir(i,l)||(d.style.setProperty("--available-height",`${l}px`),i=l);}}})}function LC(r){if(r.hideWhenDetached)return Xm(()=>({strategy:"referenceHidden",boundary:Da(r.boundary)??"clippingAncestors"}))}function MC(r){return r?r===true?{ancestorResize:true,ancestorScroll:true,elementResize:true,layoutShift:true}:r:{}}var kC=["transform","visibility","pointer-events","--x","--y","--z-index","--reference-width","--reference-height","--available-width","--available-height","--transform-origin"],IC=["top","right","bottom","left"];function sf(r,e){if(!r)return Tc;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 af(r){return r==null?null:Q(r)?r:typeof r=="object"&&r&&"contextElement"in r&&r.contextElement?r.contextElement:r}function AC(r,e,t={}){let n=()=>(typeof e=="function"?e():e)??null,i=()=>{let T=typeof r=="function"?r():r;return t.getAnchorElement?.()??T},o=()=>{let T=i();return !T&&!t.getAnchorRect?null:Qm(T,t.getAnchorRect)},s=Object.assign({},xC,t),a=[],l=null,c,d;function u(T){c?.(),d?.(),l=T,c=s.restoreStyles?sf(T,kC):void 0;let k=T.querySelector("[data-part=arrow]");d=s.restoreStyles?sf(k,IC):void 0,a=[CC(k,s),TC(s),EC(s),SC(k,T.ownerDocument,s),nf(k),ef({gutter:s.gutter,offset:s.offset,overlap:s.overlap},k),PC(s),LC(s),tf];}let{placement:h,strategy:p,onComplete:m,onPositioned:f}=s,g,b,v=false,y,w,P=Tc,x=MC(s.listeners);function S(){if(!s.listeners)return;let T=i(),k=o(),M=n();if(!k||!M)return;(af(T)!==af(y)||M!==w)&&(P(),y=T,w=M,P=Wm(k,M,L,x));}async function E(){S();let T=n();if(!T)return;T!==l&&(u(T),v=false);let k=o();if(!k)return;let M=await Zm(k,T,{placement:h,middleware:a,strategy:p});m?.(M);let C=ae(T),I=of(C,M.x),_=of(C,M.y);if(Ir(g,I)||(T.style.setProperty("--x",`${I}px`),g=I),Ir(b,_)||(T.style.setProperty("--y",`${_}px`),b=_),s.hideWhenDetached&&(M.middlewareData.hide?.referenceHidden?(T.style.setProperty("visibility","hidden"),T.style.setProperty("pointer-events","none")):(T.style.removeProperty("visibility"),T.style.removeProperty("pointer-events"))),!v){let U=T.firstElementChild;U&&(T.style.setProperty("--z-index",vr(U).zIndex),v=true);}}async function L(){t.updatePosition?(await t.updatePosition({updatePosition:E,floatingElement:n()}),f?.({placed:true})):await E();}return L(),()=>{P(),d?.(),c?.(),f?.({placed:false});}}function Oa(r,e,t={}){let{defer:n,...i}=t,o=n?ue:a=>a(),s=[];return s.push(o(()=>{s.push(AC(r,e,i));})),()=>{s.forEach(a=>a?.());}}var RC={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"};function ed(r={}){let{placement:e,sameWidth:t,fitViewport:n,strategy:i="absolute"}=r;return {arrow:{position:"absolute",width:yt.arrowSize.reference,height:yt.arrowSize.reference,[yt.arrowSizeHalf.variable]:`calc(${yt.arrowSize.reference} / 2)`,[yt.arrowOffset.variable]:`calc(${yt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:e?RC[e.split("-")[0]]:void 0,background:yt.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 wt=(r,e)=>{let t=r.ids?.trigger;return t!=null?De(t)?t(e):t:e?`menu:${r.id}:trigger:${e}`:`menu:${r.id}:trigger`},Fa=(r,e)=>{let t=r.ids?.contextTrigger;return t!=null?De(t)?t(e):t:e?`menu:${r.id}:ctx-trigger:${e}`:`menu:${r.id}:ctx-trigger`},rn=r=>r.ids?.content??`menu:${r.id}:content`,lf=r=>r.ids?.arrow??`menu:${r.id}:arrow`,td=r=>r.ids?.positioner??`menu:${r.id}:popper`,cf=(r,e)=>r.ids?.group?.(e)??`menu:${r.id}:group:${e}`,Hn=(r,e)=>`${r.id}/${e}`,on=r=>r?.dataset.value??null,nd=(r,e)=>r.ids?.groupLabel?.(e)??`menu:${r.id}:group-label:${e}`,rt=r=>r.getById(rn(r)),rd=r=>r.getById(td(r)),id=r=>r.getById(wt(r)),df=(r,e)=>e?r.getById(Hn(r,e)):null;var uf=r=>r.getById(Fa(r)),od=r=>Cr(r.getRootNode(),`[data-scope="menu"][data-part="trigger"][data-ownedby="${r.id}"]`),sd=r=>Cr(r.getRootNode(),`[data-scope="menu"][data-part="context-trigger"][data-ownedby="${r.id}"]`),Ui=(r,e)=>e==null?id(r)??od(r)[0]:r.getById(wt(r,e)),Yi=r=>{let t=`[role^="menuitem"][data-ownedby=${CSS.escape(rn(r))}]:not([data-disabled])`;return Cr(rt(r),t)},hf=r=>tp(Yi(r)),pf=r=>np(Yi(r)),ad=(r,e)=>e?r.id===e||r.dataset.value===e:false,mf=(r,e)=>{let t=Yi(r),n=t.findIndex(i=>ad(i,e.value));return ip(t,n,{loop:e.loop??e.loopFocus})},ff=(r,e)=>{let t=Yi(r),n=t.findIndex(i=>ad(i,e.value));return op(t,n,{loop:e.loop??e.loopFocus})},gf=(r,e)=>{let t=Yi(r),n=t.find(i=>ad(i,e.value));return ga(t,{state:e.typeaheadState,key:e.key,activeId:n?.id??null})},Ki=r=>Q(r)&&(r.dataset.disabled===""||r.hasAttribute("disabled")),ld=r=>!!r?.getAttribute("role")?.startsWith("menuitem")&&!!r?.hasAttribute("data-controls");var Na="menu:select";function bf(r,e){if(!r)return;let t=ae(r),n=new t.CustomEvent(Na,{detail:{value:e}});r.dispatchEvent(n);}function DC(r){let e=rn(r);return rt(r)??r.getDoc().getElementById(e)}function cd(r,e){if(!Q(r))return false;for(let t in e){let n=e[t],i=DC(n.scope);if(i&&Oe(i,r))return true;let o=n.refs.get("children");if(Object.keys(o).length>0&&cd(r,o))return true}return false}var Xi=(r,e)=>({x:r,y:e});function vf(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:Xi(o,s)}}function yf(r){let e=Xi(r.minX,r.minY),t=Xi(r.maxX,r.minY),n=Xi(r.maxX,r.maxY),i=Xi(r.minX,r.maxY);return {top:e,right:t,bottom:n,left:i}}function wf(r,e){let t=vf(r),{top:n,right:i,left:o,bottom:s}=yf(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 Va(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,d=r[s].y;l>n!=d>n&&t<(c-a)*(n-l)/(d-l)+a&&(i=!i);}return i}function ud(r){let e=r.parent;for(;e&&e.context.get("isSubmenu");)e=e.refs.get("parent");e?.send({type:"CLOSE"});}function xf(r,e){return r?Va(r,e):false}function Sf(r,e,t){let n=Object.keys(r).length>0;if(!e)return null;if(!n)return Hn(t,e);for(let i in r){let o=r[i],s=wt(o.scope);if(s===e)return s}return Hn(t,e)}function sn(r,e){r&&(r.refs.set("pointerRoutingLocked",e),r.context.set("pointerRoutingMode",e?"locked":"interactive"));}function Cf(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")&&wt(i.scope)===e)return true}return false}function Tf(r,e){r&&(r.refs.get("pointerRoutingLocked")||e&&Cf(r)||sn(r,false));}function Ef(r){r&&(Cf(r)||sn(r,false));}function hd(r,e){let{context:t,send:n,state:i,computed:o,prop:s,scope:a}=r,l=i.hasTag("open"),c=t.get("isSubmenu"),d=o("isTypingAhead"),u=s("composite"),h=t.get("currentPlacement"),p=h?Gi(h):void 0,m=t.get("anchorPoint"),f=t.get("highlightedValue"),g=t.get("triggerValue"),b=ed({...s("positioning"),placement:h});function v(x){return {id:Hn(a,x.value),disabled:!!x.disabled,highlighted:f===x.value}}function y(x){let S=x.valueText??x.value;return {...x,id:x.value,valueText:S}}function w(x){return {...v(y(x)),checked:!!x.checked}}function P(x){let{closeOnSelect:S,valueText:E,value:L}=x,T=v(x),k=Hn(a,L);return e.element({...Se.item.attrs,id:k,role:"menuitem","aria-disabled":Ic(T.disabled),"data-disabled":We(T.disabled),"data-ownedby":rn(a),"data-highlighted":We(T.highlighted),"data-value":L,"data-valuetext":E,onDragStart(M){M.currentTarget.matches("a[href]")&&M.preventDefault();},onPointerMove(M){if(T.disabled||M.pointerType!=="mouse")return;let C=M.currentTarget;if(T.highlighted)return;let I=wr(M);n({type:"ITEM_POINTERMOVE",id:k,target:C,closeOnSelect:S,point:I});},onPointerLeave(M){if(T.disabled||M.pointerType!=="mouse"||!r.event.previous()?.type.includes("POINTER"))return;let I=M.currentTarget;n({type:"ITEM_POINTERLEAVE",id:k,target:I,closeOnSelect:S});},onPointerDown(M){if(T.disabled)return;let C=M.currentTarget;n({type:"ITEM_POINTERDOWN",target:C,id:k,closeOnSelect:S});},onClick(M){if(Bc(M)||_c(M)||T.disabled)return;let C=M.currentTarget;n({type:"ITEM_CLICK",target:C,id:k,closeOnSelect:S});}})}return {highlightedValue:f,open:l,setOpen(x){i.hasTag("open")!==x&&n({type:x?"OPEN":"CLOSE"});},triggerValue:g,setTriggerValue(x){n({type:"TRIGGER_VALUE.SET",value:x});},setHighlightedValue(x){n({type:"HIGHLIGHTED.SET",value:x});},setParent(x){n({type:"PARENT.SET",value:x,id:x.prop("id")});},setChild(x){n({type:"CHILD.SET",value:x,id:x.prop("id")});},reposition(x={}){n({type:"POSITIONING.SET",options:x});},addItemListener(x){let S=a.getById(x.id);if(!S)return;let E=()=>x.onSelect?.();return S.addEventListener(Na,E),()=>S.removeEventListener(Na,E)},getContextTriggerProps(x={}){let{value:S}=x,E=S==null?false:g===S,L=Fa(a,S);return e.element({...Se.contextTrigger.attrs,dir:s("dir"),id:L,"data-ownedby":a.id,"data-value":S,"data-current":We(E),"data-state":l?"open":"closed",onPointerDown(T){if(T.pointerType==="mouse")return;let k=wr(T);n({type:"CONTEXT_MENU_START",point:k,value:S});},onPointerCancel(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerMove(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerUp(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onContextMenu(T){let k=wr(T),M=l&&S!=null&&!E;n({type:M?"TRIGGER_VALUE.SET":"CONTEXT_MENU",point:k,value:S}),T.preventDefault();},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}})},getTriggerItemProps(x){let S=x.getTriggerProps();return up(P({value:S.id}),S)},getTriggerProps(x={}){let{value:S}=x,E=S==null?false:g===S,L=wt(a,S);return e.button({...c?Se.triggerItem.attrs:Se.trigger.attrs,"data-placement":h,"data-side":p,type:"button",dir:s("dir"),id:L,...S!=null&&{"data-ownedby":a.id,"data-value":S,"data-current":We(E)},"data-uid":s("id"),"aria-haspopup":u?"menu":"dialog","aria-controls":rn(a),"data-controls":rn(a),"aria-expanded":S==null?l:l&&E,"data-state":l?"open":"closed",onPointerMove(T){if(T.pointerType!=="mouse"||Ki(T.currentTarget)||!c)return;let M=wr(T);n({type:"TRIGGER_POINTERMOVE",target:T.currentTarget,point:M});},onPointerLeave(T){if(Ki(T.currentTarget)||T.pointerType!=="mouse"||!c)return;sn(r.refs.get("parent"),true);let k=wr(T);n({type:"TRIGGER_POINTERLEAVE",target:T.currentTarget,point:k});},onPointerDown(T){Ki(T.currentTarget)||ua(T)||T.preventDefault();},onClick(T){if(T.defaultPrevented||Ki(T.currentTarget))return;let k=l&&S!=null&&!E;n({type:k?"TRIGGER_VALUE.SET":"TRIGGER_CLICK",target:T.currentTarget,value:S});},onBlur(){n({type:"TRIGGER_BLUR"});},onFocus(){n({type:"TRIGGER_FOCUS"});},onKeyDown(T){if(T.defaultPrevented)return;let k={ArrowDown(){n({type:"ARROW_DOWN",value:S});},ArrowUp(){n({type:"ARROW_UP",value:S});},Enter(){n({type:"ARROW_DOWN",src:"enter",value:S});},Space(){n({type:"ARROW_DOWN",src:"space",value:S});}},M=Hc(T,{orientation:"vertical",dir:s("dir")}),C=k[M];C&&(T.preventDefault(),C(T));}})},getIndicatorProps(){return e.element({...Se.indicator.attrs,dir:s("dir"),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...Se.positioner.attrs,dir:s("dir"),id:td(a),style:b.floating})},getArrowProps(){return e.element({id:lf(a),...Se.arrow.attrs,dir:s("dir"),style:b.arrow})},getArrowTipProps(){return e.element({...Se.arrowTip.attrs,dir:s("dir"),style:b.arrowTip})},getContentProps(){return e.element({...Se.content.attrs,id:rn(a),"aria-label":s("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:u?"menu":"dialog",tabIndex:0,dir:s("dir"),"aria-activedescendant":o("highlightedId")||void 0,"aria-labelledby":m?Fa(a,g??void 0):wt(a,g??void 0),"data-placement":h,"data-side":p,onPointerEnter(x){x.pointerType==="mouse"&&n({type:"MENU_POINTERENTER"});},onKeyDown(x){if(x.defaultPrevented||!Oe(x.currentTarget,fe(x)))return;let S=fe(x);if(!(S?.closest("[role=menu]")===x.currentTarget||S===x.currentTarget))return;if(x.key==="Tab"&&!Up(x)){x.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(M){d?n({type:"TYPEAHEAD",key:M.key}):L.Enter?.(M);},Home(){n({type:"HOME"});},End(){n({type:"END"});}},T=Hc(x,{dir:s("dir")}),k=L[T];if(k){k(x),x.stopPropagation(),x.preventDefault();return}s("typeahead")&&_p(x)&&(Hp(x)||br(S)||(n({type:"TYPEAHEAD",key:x.key}),x.preventDefault()));}})},getSeparatorProps(){return e.element({...Se.separator.attrs,role:"separator",dir:s("dir"),"aria-orientation":"horizontal"})},getItemState:v,getItemProps:P,getOptionItemState:w,getOptionItemProps(x){let{type:S,disabled:E,closeOnSelect:L}=x,T=y(x),k=w(x);return {...P(T),...e.element({"data-type":S,...Se.item.attrs,dir:s("dir"),"data-value":T.value,role:`menuitem${S}`,"aria-checked":!!k.checked,"data-state":k.checked?"checked":"unchecked",onClick(M){if(E||Bc(M)||_c(M))return;let C=M.currentTarget;n({type:"ITEM_CLICK",target:C,option:T,closeOnSelect:L});}})}},getItemIndicatorProps(x){let S=w(Cc(x)),E=S.checked?"checked":"unchecked";return e.element({...Se.itemIndicator.attrs,dir:s("dir"),"data-disabled":We(S.disabled),"data-highlighted":We(S.highlighted),"data-state":Ei(x,"checked")?E:void 0,hidden:Ei(x,"checked")?!S.checked:void 0})},getItemTextProps(x){let S=w(Cc(x)),E=S.checked?"checked":"unchecked";return e.element({...Se.itemText.attrs,dir:s("dir"),"data-disabled":We(S.disabled),"data-highlighted":We(S.highlighted),"data-state":Ei(x,"checked")?E:void 0})},getItemGroupLabelProps(x){return e.element({...Se.itemGroupLabel.attrs,id:nd(a,x.htmlFor),dir:s("dir")})},getItemGroupProps(x){return e.element({id:cf(a,x.id),...Se.itemGroup.attrs,dir:s("dir"),"aria-labelledby":nd(a,x.id),role:"group"})}}}function Pf(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 Lf(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 Mf="pointerdown.outside",kf="focus.outside";function OC(r){for(let e of r)if(Q(e)&&Ge(e))return true;return false}var Rf=r=>"clientY"in r;function FC(r,e){if(!Rf(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 NC(r,e){return r.y<=e.y&&e.y<=r.y+r.height&&r.x<=e.x&&e.x<=r.x+r.width}function If(r,e){if(!e||!Rf(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 NC(s,a)?n||o:false}function VC(r,e){let{exclude:t,onFocusOutside:n,onPointerDownOutside:i,onInteractOutside:o,defer:s,followControlledElements:a=true}=e;if(!r)return;let l=ce(r),c=ae(r),d=Pf(c),u=Lf(c);function h(w,P){if(!Q(P)||!P.isConnected||Oe(r,P)||FC(r,w)||a&&da(r,P))return false;let x=l.querySelector(`[aria-controls="${r.id}"]`);if(x){let E=ma(x);if(If(w,E))return false}let S=ma(r);return If(w,S)?false:!t?.(P)}let p=new Set,m=Rn(r?.getRootNode()),f=false;function g(w){f=true;let P=()=>{f=false;};l.addEventListener("pointerup",P,{once:true}),c.addEventListener("pointerup",P,{once:true});function x(S){let E=s&&!Vc()?ue:k=>k(),L=S??w,T=L?.composedPath?.()??[L?.target];E(()=>{let k=m?T[0]:fe(w);if(!(!r||!h(w,k))){if(i||o){let M=Jt(i,o);r.addEventListener(Mf,M,{once:true});}Af(r,Mf,{bubbles:false,cancelable:true,detail:{originalEvent:L,contextmenu:ua(L),focusable:OC(T),target:k}});}});}w.pointerType==="touch"?(p.forEach(S=>S()),p.add(Le(l,"click",x,{once:true})),p.add(u.addEventListener("click",x,{once:true})),p.add(d.addEventListener("click",x,{once:true}))):x();}let b=new Set,v=setTimeout(()=>{b.add(Le(l,"pointerdown",g,true)),b.add(u.addEventListener("pointerdown",g,true)),b.add(d.addEventListener("pointerdown",g,true));},0);function y(w){if(f)return;(s?ue:x=>x())(()=>{let x=w?.composedPath?.()??[w?.target],S=m?x[0]:fe(w);if(!(!r||!h(w,S))){if(n||o){let E=Jt(n,o);r.addEventListener(kf,E,{once:true});}Af(r,kf,{bubbles:false,cancelable:true,detail:{originalEvent:w,contextmenu:false,focusable:Ge(S),target:S}});}});}return Vc()||(b.add(Le(l,"focusin",y,true)),b.add(u.addEventListener("focusin",y,true)),b.add(d.addEventListener("focusin",y,true))),()=>{clearTimeout(v),p.forEach(w=>w()),b.forEach(w=>w());}}function Df(r,e){let{defer:t}=e,n=t?ue:o=>o(),i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(VC(o,e));})),()=>{i.forEach(o=>o?.());}}function Af(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,t);return r.dispatchEvent(i)}function Of(r,e){let t=n=>{n.key==="Escape"&&(n.isComposing||e?.(n));};return Le(ce(r),"keydown",t,{capture:true})}var Ff="layer:request-dismiss",Ce={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=>Oe(n.node,e))||this.recentlyRemoved.size>0)},isInBranch(r){return Array.from(this.branches).some(e=>Oe(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&&_C(i);}),this.recentlyRemoved.add(r),Kp(()=>this.recentlyRemoved.delete(r)),e<this.count()-1&&this.getNestedLayers(r).forEach(i=>Ce.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)=>{Nf(r,e,r.node),r.styleTargets?.forEach(t=>{let n=t();if(!n||n===r.node)return;Nf(r,e,n);let{zIndex:i}=vr(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];HC(r,Ff,i=>{n.requestDismiss?.(i),i.defaultPrevented||n?.dismiss();}),BC(r,Ff,{originalLayer:r,targetLayer:e,originalIndex:t,targetIndex:e?this.indexOf(e):-1}),this.syncLayers();},clear(){this.remove(this.layers[0].node);}};function Nf(r,e,t){t.style.setProperty("--layer-index",`${e}`),t.removeAttribute("data-nested"),t.removeAttribute("data-has-nested"),Ce.getParentLayerOfType(r.node,r.type)&&t.setAttribute("data-nested",r.type);let i=Ce.countNestedLayersOfType(r.node,r.type);i>0&&t.setAttribute("data-has-nested",r.type),t.style.setProperty("--nested-layer-count",`${i}`);}function _C(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 BC(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 HC(r,e,t){r.addEventListener(e,t,{once:true});}var pd=new WeakMap,ji=new WeakMap;function zC(r){return Ce.isBelowPointerBlockingLayer(r)?"none":"auto"}function Vf(r){let e=zC(r);r.style.pointerEvents!==e&&(r.style.pointerEvents=e);}function $C(r){if(ji.has(r))return;let e=ae(r);if(typeof e.MutationObserver>"u")return;let t=new e.MutationObserver(()=>{ji.has(r)&&Vf(r);});t.observe(r,{attributes:true,attributeFilter:["style"]}),ji.set(r,t);}function md(){Ce.layers.forEach(({node:r})=>{Vf(r),$C(r);});}function _f(r){let e=ji.get(r);e&&(e.disconnect(),ji.delete(r)),r.style.pointerEvents="";}function Bf(r,e){let t=ce(r),n=[];return Ce.hasPointerBlockingLayer()&&!t.body.hasAttribute("data-inert")&&(pd.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]=tm(()=>{let a=i();return Q(a)?a:null},{timeout:1e3});o.then(a=>n.push(Oi(a,{pointerEvents:"auto"}))),n.push(s);}),()=>{Ce.hasPointerBlockingLayer()||(queueMicrotask(()=>{let i=t.body;if(!i)return;let o=pd.get(i);o!==void 0&&(i.style.pointerEvents=o,pd.delete(i)),i.removeAttribute("data-inert"),i.style.length===0&&i.removeAttribute("style");}),n.forEach(i=>i()));}}function WC(r,e){let{warnOnMissingNode:t=true}=e;if(t&&!r){mr("[@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,d={dismiss:n,node:r,type:l,pointerBlocking:o,requestDismiss:i,styleTargets:c};Ce.add(d),md();function u(g){let b=fe(g.detail.originalEvent);Ce.isBelowPointerBlockingLayer(r)||Ce.isInBranch(b)||(e.onPointerDownOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onPointerDownOutside:",g.detail.originalEvent),n?.()));}function h(g){let b=fe(g.detail.originalEvent);Ce.isInBranch(b)||(e.onFocusOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onFocusOutside:",g.detail.originalEvent),n?.()));}function p(g){Ce.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,v=Array.isArray(b)?b:[b],y=e.persistentElements?.map(w=>w()).filter(Q);return y&&v.push(...y),v.some(w=>Oe(w,g))||Ce.isInNestedLayer(r,g)}let f=[o?Bf(r,e.persistentElements):void 0,Of(r,p),Df(r,{exclude:m,onFocusOutside:h,onPointerDownOutside:u,defer:e.defer})];return ()=>{Ce.remove(r),md(),_f(r),f.forEach(g=>g?.());}}function _a(r,e){let{defer:t}=e,n=t?ue:o=>o(),i=[];return i.push(n(()=>{let o=De(r)?r():r;i.push(WC(o,e));})),()=>{i.forEach(o=>o?.());}}function GC(r){return !(r.metaKey||!yr()&&r.altKey||r.ctrlKey||r.key==="Control"||r.key==="Shift"||r.key==="Meta")}var UC=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function YC(r,e,t){let n=t?fe(t):null,i=ce(n),o=ae(n),s=mt(i);return r=r||s instanceof o.HTMLInputElement&&!UC.has(s?.type)||s instanceof o.HTMLTextAreaElement||s instanceof o.HTMLElement&&s.isContentEditable,!(r&&e==="keyboard"&&t instanceof o.KeyboardEvent&&!Reflect.has(KC,t.key))}var Dt=null,fd=new Set,Ba=new Map,zn=false,gd=false,zf=false,KC={Tab:true,Escape:true};function za(r,e){for(let t of fd)t(r,e);}function Ha(r){zn=true,GC(r)&&(Dt="keyboard",za("keyboard",r));}function Ue(r){Dt="pointer",(r.type==="mousedown"||r.type==="pointerdown")&&(zn=true,za("pointer",r));}function $f(r){Bp(r)&&(zn=true,Dt="virtual");}function Wf(r){let e=fe(r);e===ae(e)||e===ce(e)||zf||!r.isTrusted||(!zn&&!gd&&(Dt="virtual",za("virtual",r)),zn=false,gd=false);}function Gf(){(zn=false,gd=true);}function XC(r){if(typeof window>"u"||Ba.get(ae(r)))return;let e=ae(r),t=ce(r),n=e.HTMLElement.prototype.focus;function i(){zn=true,n.apply(this,arguments);}try{Object.defineProperty(e.HTMLElement.prototype,"focus",{configurable:!0,value:i});}catch{}t.addEventListener("keydown",Ha,true),t.addEventListener("keyup",Ha,true),t.addEventListener("click",$f,true),e.addEventListener("focus",Wf,true),e.addEventListener("blur",Gf,false),typeof e.PointerEvent<"u"?(t.addEventListener("pointerdown",Ue,true),t.addEventListener("pointermove",Ue,true),t.addEventListener("pointerup",Ue,true)):(t.addEventListener("mousedown",Ue,true),t.addEventListener("mousemove",Ue,true),t.addEventListener("mouseup",Ue,true)),e.addEventListener("beforeunload",()=>{jC(r);},{once:true}),Ba.set(e,{focus:n});}var jC=(r,e)=>{let t=ae(r),n=ce(r);let i=Ba.get(t);if(i){try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus});}catch{}n.removeEventListener("keydown",Ha,true),n.removeEventListener("keyup",Ha,true),n.removeEventListener("click",$f,true),t.removeEventListener("focus",Wf,true),t.removeEventListener("blur",Gf,false),typeof t.PointerEvent<"u"?(n.removeEventListener("pointerdown",Ue,true),n.removeEventListener("pointermove",Ue,true),n.removeEventListener("pointerup",Ue,true)):(n.removeEventListener("mousedown",Ue,true),n.removeEventListener("mousemove",Ue,true),n.removeEventListener("mouseup",Ue,true)),Ba.delete(t);}};function Uf(){return Dt}function Yf(r){Dt=r,za(r,null);}function Hf(){return Dt==="keyboard"||Dt==="virtual"}function Kf(r={}){let{isTextInput:e,autoFocus:t,onChange:n,root:i}=r;XC(i),n?.({isFocusVisible:t||Hf(),modality:Dt});let o=(s,a)=>{YC(!!e,s,a)&&n?.({isFocusVisible:Hf(),modality:s});};return fd.add(o),()=>{fd.delete(o);}}var{not:Ye,and:Ar,or:qC}=xp(),bd=aa({props({props:r}){return {closeOnSelect:true,typeahead:true,composite:true,loopFocus:false,navigate(e){qp(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=Ui(t,n);i({value:n,triggerElement:o});}})),pointerRoutingMode:r(()=>({defaultValue:"interactive"}))}},refs(){return {parent:null,children:{},pointerRoutingLocked:false,typeaheadState:{...ga.defaultOptions},positioningOverride:{}}},computed:{isRtl:({prop:r})=>r("dir")==="rtl",isTypingAhead:({refs:r})=>r.get("typeaheadState").keysSoFar!=="",highlightedId:({context:r,scope:e,refs:t})=>Sf(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:Ye("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:qC("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:Ar(Ye("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:Ye("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:Ar("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:Ye("isPointerRoutingLocked"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:Ar(Ye("isPointerRoutingLocked"),Ye("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:Ar(Ye("isTriggerItemHighlighted"),Ye("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock"]},{guard:Ar(Ye("isTriggerItemHighlighted"),Ye("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock","focusTrigger"]},{guard:Ar(Ye("isTriggerItemHighlighted"),Ye("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})=>ld(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})=>br(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 Kf({root:r.getRootNode?.()})},trackPositioning({context:r,prop:e,scope:t,refs:n}){if(uf(t)||sd(t).length>0)return;let o={...e("positioning"),...n.get("positioningOverride")};return r.set("currentPlacement",o.placement),Oa(()=>Ui(t,r.get("triggerValue")),()=>rd(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=>sd(e).some(c=>Oe(c,l));return _a(o,{type:"menu",defer:true,exclude:[id(e),...od(e)].filter(Boolean),onInteractOutside:t("onInteractOutside"),onRequestDismiss:t("onRequestDismiss"),onFocusOutside(l){t("onFocusOutside")?.(l);let c=fe(l.detail.originalEvent);if(a(c)){l.preventDefault();return}if(cd(c,r.get("children"))){l.preventDefault();return}},onEscapeKeyDown(l){t("onEscapeKeyDown")?.(l),n.get("isSubmenu")&&l.preventDefault(),ud({parent:r.get("parent")});},onPointerDownOutside(l){t("onPointerDownOutside")?.(l);let c=fe(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;sn(i,true);let o=e.getDoc();return Le(o,"pointermove",s=>{xf(r.get("intentPolygon"),{x:s.clientX,y:s.clientY})||(t({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),sn(i,false));})},scrollToHighlightedItem({scope:r,computed:e}){let t=()=>{if(Uf()==="pointer")return;let o=r.getById(e("highlightedId")),s=rt(r);Jp(o,{rootEl:s,block:"nearest"});};return ue(()=>{Yf("virtual"),t();}),jp(()=>rt(r),{attributes:["aria-activedescendant"],callback:t})}},actions:{setAnchorPoint({context:r,event:e}){r.set("anchorPoint",t=>hr(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=()=>rd(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");Oa(()=>Ui(e,c),o,{...l,defer:true,getAnchorRect:a,...n.options??{},listeners:false,onComplete(u){r.set("currentPlacement",u.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");Pp(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=wf(o,i);if(!s)return;let l=Gi(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=wt(t);n?.send({type:"HIGHLIGHTED.SUGGEST",value:i});}sn(n,false);},unlockParentOnClose({refs:r,context:e}){Tf(r.get("parent"),e.get("isSubmenu"));},setHighlightedItem({context:r,event:e}){let t=e.value||on(e.target);r.set("highlightedValue",t);},clearHighlightedItem({context:r}){r.set("highlightedValue",null);},focusMenu({scope:r}){ue(()=>{let e=rt(r);pa({root:e,enabled:!Oe(e,r.getActiveElement()),filter(n){return !n.role?.startsWith("menuitem")}})?.focus({preventScroll:true});});},highlightFirstItem({context:r,scope:e}){(rt(e)?queueMicrotask:ue)(()=>{let n=hf(e);n&&r.set("highlightedValue",on(n));});},highlightLastItem({context:r,scope:e}){(rt(e)?queueMicrotask:ue)(()=>{let n=pf(e);n&&r.set("highlightedValue",on(n));});},highlightNextItem({context:r,scope:e,event:t,prop:n}){let i=mf(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",on(i));},highlightPrevItem({context:r,scope:e,event:t,prop:n}){let i=ff(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",on(i));},invokeOnSelect({context:r,prop:e,scope:t}){let n=r.get("highlightedValue");if(n==null)return;let i=df(t,n);bf(i,n),e("onSelect")?.({value:n});},focusTrigger({scope:r,context:e,event:t}){e.get("isSubmenu")||e.get("anchorPoint")||t.restoreFocus===false||queueMicrotask(()=>{Ui(r,e.get("triggerValue"))?.focus({preventScroll:true});});},highlightMatchedItem({scope:r,context:e,event:t,refs:n}){let i=gf(r,{key:t.key,value:e.get("highlightedValue"),typeaheadState:n.get("typeaheadState")});i&&e.set("highlightedValue",on(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(!ld(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&&Va(l,e.point)||(rt(t)?.focus({preventScroll:true}),a.send({type:"CLOSE"}));}},closeRootMenu({refs:r}){ud({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",on(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")&&Ef(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 Xf(r){return {machine:bd,props:{id:r.id??Ca("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=>hd(e,Tr)}}var jf="vela-ui-menu",qf=`
|
|
4
4
|
.vela-menu {
|
|
5
5
|
/* The list is a <ul>: without this, block rows (the separator) paint a ::marker dot. */
|
|
6
6
|
list-style: none;
|
|
@@ -117,10 +117,10 @@ var Vela=(function(exports){'use strict';function be(r){return r.kind!=="candle"
|
|
|
117
117
|
color: var(--vela-fg-faint);
|
|
118
118
|
}
|
|
119
119
|
.vela-menu-item[data-state='open'] { background: var(--vela-hover); }
|
|
120
|
-
`;var
|
|
121
|
-
`),
|
|
120
|
+
`;var vd=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=Xf({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=Sa(this.ctrl.machine,this.ctrl.props,i=>{let o=this.ctrl.connect(i);n&&Fe(n,o.getTriggerProps(),this.mid),Fe(this.positioner,o.getPositionerProps(),this.mid),Fe(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){Fe(t,e.getTriggerItemProps(i.api),this.mid);continue}let o=this.byId(n);Fe(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(Me("check",e)),o.dataset.checkmark="1"),o.appendChild(a);}else !i&&!n.toggle&&n.checked&&(o.dataset.checked="1");n.icon&&o.appendChild(Me(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=Me(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,d=>d.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=Me("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);}}},Rr=class{constructor(e){let t=e.trigger??e.host??document.body,n=t.ownerDocument;oe(jf,qf,n);let i=e.host??t.closest?.(".vela-ui")??n.body;this.root=new vd(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 qi(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 JC="vela-ui-tokens",QC=Object.entries(ia).map(([r,e])=>` ${r}: ${e};`).join(`
|
|
121
|
+
`),e1=`
|
|
122
122
|
.vela-ui, .vela-ui-layer {
|
|
123
|
-
${
|
|
123
|
+
${QC}
|
|
124
124
|
font-family: var(--vela-font, -apple-system, system-ui, sans-serif);
|
|
125
125
|
box-sizing: border-box;
|
|
126
126
|
/* Chrome text (titles, buttons, menus, readouts) is UI, not copy \u2014 never selectable. */
|
|
@@ -132,7 +132,7 @@ ${KC}
|
|
|
132
132
|
.vela-ui :is(input, textarea), .vela-ui-layer :is(input, textarea) { user-select: text; -webkit-user-select: text; }
|
|
133
133
|
.vela-icon { display: inline-flex; align-items: center; flex: none; }
|
|
134
134
|
.vela-icon svg { display: block; }
|
|
135
|
-
`;function
|
|
135
|
+
`;function t1(r,e){let t=oa(e);for(let n in t)r.style.setProperty(n,t[n]);}function Zf(r,e){oe(JC,e1,r.getRootNode()),r.classList.add("vela-ui"),e&&t1(r,e);}function Jf(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 Qf(r,e,t){return {left:t,top:t,right:r-t,bottom:e-t,width:r-t*2,height:e-t*2}}function eg(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 tg(r){let e=r.align==="end"?r.trigger.right-r.pop.width: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 ng(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 rg="vela-ui-popover",ig=`
|
|
136
136
|
.vela-popover {
|
|
137
137
|
position: fixed;
|
|
138
138
|
z-index: var(--vela-z-popover);
|
|
@@ -143,7 +143,7 @@ ${KC}
|
|
|
143
143
|
}
|
|
144
144
|
.vela-popover[data-position='absolute'] { position: absolute; }
|
|
145
145
|
.vela-popover[hidden] { display: none !important; }
|
|
146
|
-
`;var Ot=null;function de(){Ot?.hide();}function
|
|
146
|
+
`;var Ot=null;function de(){Ot?.hide();}function xt(){return Ot!==null}function Ft(){return Ot?.trigger??null}var sg="__velaPopoverDismiss";function n1(r){r[sg]=true;}function $n(r){return r[sg]===true}function og(r){return {left:r.left,top:r.top,right:r.right,bottom:r.bottom,width:r.width,height:r.height}}var Be=class{constructor(e){this.onOutside=null;this.onKey=null;this.onReflow=null;this.shown=false;let t=e.trigger.ownerDocument;oe(rg,ig,t),this.trigger=e.trigger,this.host=e.host??t.body,this.ctrl=ng(e),this.boundary=e.boundary??"viewport",this.theme=e.theme,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}Ot&&Ot!==this&&Ot.hide(),Zf(this.el,this.theme),this.host.appendChild(this.el),this.shown=true,Ot=this,this.place();let e=i=>{let o=i.target;this.el.contains(o)||this.trigger.contains(o)||(n1(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.el.remove(),this.shown=false,Ot===this&&(Ot=null),this.ctrl.onClose?.());}toggle(){this.shown?this.hide():this.show();}destroy(){this.hide();}reposition(){this.shown&&this.place();}clampRect(){let e=Qf(window.innerWidth,window.innerHeight,this.ctrl.viewportInset),t=this.readBoundary();if(!t)return e;let n=Jf(t,this.ctrl.boundaryInset);return eg(e,n)}readBoundary(){let e=this.boundary;if(e==="viewport")return null;let t=typeof e=="function"?e():e.getBoundingClientRect();return t?og(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=tg({trigger:og(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 ag(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 lg="vela-ui-select-3",cg=`
|
|
147
147
|
.vela-select { position: relative; display: inline-block; min-width: 0; }
|
|
148
148
|
.vela-select[data-fill] { width: 100%; }
|
|
149
149
|
/* Closed trigger matches NumberInput / TextField (100px). Long labels ellipsis;
|
|
@@ -238,7 +238,7 @@ ${KC}
|
|
|
238
238
|
.vela-select-item:hover { background: var(--vela-hover); }
|
|
239
239
|
.vela-select-item[data-checked] { background: var(--vela-hover-strong); color: var(--vela-fg-bright); }
|
|
240
240
|
.vela-select-item[data-checked]:hover { background: var(--vela-hover-strong); }
|
|
241
|
-
`;function ag(r){oe(ig,og,r);}function sg(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 lg(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 cg(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",()=>sg(e,n)),sg(e,n);}r.querySelector(".vela-select-item[data-checked]")?.scrollIntoView({block:"nearest"}),e.dispatchEvent(new Event("scroll"));}}function Ha(r,e,t,n,i={}){return Ft()===r?(de(),null):dg(r,e,t,n,i)}function dg(r,e,t,n,i={}){ag(r.ownerDocument),de();let o=new Be({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),lg(s,e,t,(a,l)=>{o.hide(),n(a,l);});}});return o.show(),cg(o.el),o.reposition(),o}var Xi=class{constructor(e){this.list=null;let t=e.list?.host?.ownerDocument??document;ag(t),this.ctrl=rg(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(Me("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=Ha(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 ZC=It("dialog").parts("trigger","backdrop","positioner","content","title","description","closeTrigger"),sn=ZC.build();var gd=r=>r.ids?.positioner??`dialog:${r.id}:positioner`,bd=r=>r.ids?.backdrop??`dialog:${r.id}:backdrop`,za=r=>r.ids?.content??`dialog:${r.id}:content`,$a=(r,e)=>{let t=r.ids?.trigger;return t!=null?De(t)?t(e):t:e?`dialog:${r.id}:trigger:${e}`:`dialog:${r.id}:trigger`},Wa=r=>r.ids?.title??`dialog:${r.id}:title`,Ga=r=>r.ids?.description??`dialog:${r.id}:description`,vd=r=>r.ids?.closeTrigger??`dialog:${r.id}:close`,ji=r=>r.getById(za(r)),ug=r=>r.getById(gd(r)),hg=r=>r.getById(bd(r)),yd=r=>r.getById($a(r)),pg=r=>r.getById(Wa(r)),mg=r=>r.getById(Ga(r)),fg=r=>r.getById(vd(r)),Ua=r=>Cr(r.getRootNode(),`[data-scope="dialog"][data-part="trigger"][data-ownedby="${r.id}"]`),wd=(r,e)=>e==null?yd(r)??Ua(r)[0]:r.getById($a(r,e));function xd(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(d){t.matches("open")!==d&&n({type:d?"OPEN":"CLOSE"});},triggerValue:c,setTriggerValue(d){n({type:"TRIGGER_VALUE.SET",value:d});},getTriggerProps(d={}){let{value:u}=d,h=u==null?false:c===u;return e.button({...sn.trigger.attrs,dir:o("dir"),id:$a(s,u),"data-ownedby":s.id,"data-value":u,"aria-haspopup":"dialog",type:"button","aria-expanded":u==null?l:l&&h,"data-state":l?"open":"closed","aria-controls":za(s),"data-current":We(h),onClick(p){if(p.defaultPrevented)return;let m=l&&u!=null&&!h;n({type:m?"TRIGGER_VALUE.SET":"TOGGLE",value:u});}})},getBackdropProps(){return e.element({...sn.backdrop.attrs,dir:o("dir"),hidden:!l,id:bd(s),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...sn.positioner.attrs,dir:o("dir"),id:gd(s),style:Jt({pointerEvents:!l||!o("modal")?"none":void 0})})},getContentProps(){let d=i.get("rendered");return e.element({...sn.content.attrs,dir:o("dir"),role:o("role"),hidden:!l,id:za(s),tabIndex:-1,"data-state":l?"open":"closed","aria-modal":o("modal"),"aria-label":a||void 0,"aria-labelledby":a||!d.title?void 0:Wa(s),"aria-describedby":d.description?Ga(s):void 0,style:Jt({pointerEvents:o("modal")?void 0:"auto"})})},getTitleProps(){return e.element({...sn.title.attrs,dir:o("dir"),id:Wa(s)})},getDescriptionProps(){return e.element({...sn.description.attrs,dir:o("dir"),id:Ga(s)})},getCloseTriggerProps(){return e.button({...sn.closeTrigger.attrs,dir:o("dir"),id:vd(s),type:"button",onClick(d){d.defaultPrevented||(d.stopPropagation(),n({type:"CLOSE"}));}})}}}var Dr=new WeakMap,Ya=new WeakMap,Ka={},Sd=0,bg=r=>r&&(r.host||bg(r.parentNode)),JC=(r,e)=>e.map(t=>{if(r.contains(t))return t;let n=bg(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),QC=new Set(["script","output","status","next-route-announcer"]),e1=r=>QC.has(r.localName)||r.role==="status"||r.hasAttribute("aria-live")?true:r.matches("[data-live-announcer]"),vg=(r,e)=>{let{parentNode:t,markerName:n,controlAttribute:i,explicitBooleanValue:o,followControlledElements:s=true}=e,a=JC(t,Array.isArray(r)?r:[r]);Ka[n]||(Ka[n]=new WeakMap);let l=Ka[n],c=[],d=new Set,u=new Set(a),h=m=>{!m||d.has(m)||(d.add(m),h(m.parentNode));};a.forEach(m=>{h(m),s&&Q(m)&&Ac(m,f=>{h(f);});});let p=m=>{!m||u.has(m)||Array.prototype.forEach.call(m.children,f=>{if(d.has(f))p(f);else try{if(e1(f))return;let g=f.getAttribute(i),b=o?g==="true":g!==null&&g!=="false",v=(Dr.get(f)||0)+1,y=(l.get(f)||0)+1;Dr.set(f,v),l.set(f,y),c.push(f),v===1&&b&&Ya.set(f,!0),y===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),d.clear(),Sd++,()=>{c.forEach(m=>{let f=Dr.get(m)-1,g=l.get(m)-1;Dr.set(m,f),l.set(m,g),f||(Ya.has(m)||m.removeAttribute(i),Ya.delete(m)),g||m.removeAttribute(n);}),Sd--,Sd||(Dr=new WeakMap,Dr=new WeakMap,Ya=new WeakMap,Ka={});}};var t1=r=>(Array.isArray(r)?r[0]:r).ownerDocument.body,yg=(r,e=t1(r),t="data-aria-hidden",n=true)=>{if(e)return vg(r,{parentNode:e,markerName:t,controlAttribute:"aria-hidden",explicitBooleanValue:true,followControlledElements:n})};var n1=r=>{let e=requestAnimationFrame(()=>r());return ()=>cancelAnimationFrame(e)};function wg(r,e={}){let{defer:t=true}=e,n=t?n1:o=>o(),i=[];return i.push(n(()=>{let s=(typeof r=="function"?r():r).filter(Boolean);s.length!==0&&i.push(yg(s));})),()=>{i.forEach(o=>o?.());}}var r1=Object.defineProperty,i1=(r,e,t)=>e in r?r1(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ie=(r,e,t)=>i1(r,typeof e!="symbol"?e+"":e,t);var xg={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();}},o1=[],Cg=class{constructor(r,e){ie(this,"trapStack"),ie(this,"config"),ie(this,"doc"),ie(this,"state",{containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:false,paused:false,delayInitialFocusTimer:void 0,recentNavEvent:void 0}),ie(this,"portalContainers",new Set),ie(this,"listenerCleanups",[]),ie(this,"handleFocus",n=>{let i=fe(n),o=this.findContainerIndex(i,n)>=0;if(o||ki(i))o&&(this.state.mostRecentlyFocusedNode=i);else {n.stopImmediatePropagation();let s,a=true;if(this.state.mostRecentlyFocusedNode)if(Sr(this.state.mostRecentlyFocusedNode)>0){let l=this.findContainerIndex(this.state.mostRecentlyFocusedNode),{tabbableNodes:c}=this.state.containerGroups[l];if(c.length>0){let d=c.findIndex(u=>u===this.state.mostRecentlyFocusedNode);d>=0&&(this.config.isKeyForward(this.state.recentNavEvent)?d+1<c.length&&(s=c[d+1],a=false):d-1>=0&&(s=c[d-1],a=false));}}else this.state.containerGroups.some(l=>l.tabbableNodes.some(c=>Sr(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;}),ie(this,"handlePointerDown",n=>{let i=fe(n);if(!(this.findContainerIndex(i,n)>=0)){if(qi(this.config.clickOutsideDeactivates,n)){this.deactivate({returnFocus:this.config.returnFocusOnDeactivate});return}qi(this.config.allowOutsideClick,n)||n.preventDefault();}}),ie(this,"handleClick",n=>{let i=fe(n);this.findContainerIndex(i,n)>=0||qi(this.config.clickOutsideDeactivates,n)||qi(this.config.allowOutsideClick,n)||(n.preventDefault(),n.stopImmediatePropagation());}),ie(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;Cd(n)&&n.preventDefault(),this.tryFocus(o);}}),ie(this,"handleEscapeKey",n=>{l1(n)&&qi(this.config.escapeDeactivates,n)!==false&&(n.preventDefault(),this.deactivate());}),ie(this,"_mutationObserver"),ie(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 Lp(c)?true:c.id&&!this.state.containers.some(d=>d.contains(c))?Mp(c):false}):false)&&this.state.active&&!this.state.paused&&(this.updateTabbableNodes(),this.updatePortalContainers());});}),ie(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);}));}),ie(this,"getInitialFocusNode",()=>{let n=this.getNodeForOption("initialFocus",{hasFallback:true});if(n===false)return false;if(n===void 0||n&&!Ge(n)){let i=pt(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}),ie(this,"tryFocus",n=>{if(n!==false&&n!==pt(this.doc)){if(!n||!n.focus){this.tryFocus(this.getInitialFocusNode());return}n.focus({preventScroll:!!this.config.preventScroll}),this.state.mostRecentlyFocusedNode=n,c1(n)&&n.select();}}),ie(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(),xg.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=()=>{Sg(()=>{if(l){let d=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);this.tryFocus(d);}s?.();});};if(l&&a){let d=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);return a(d).then(c,c),this}return c(),this}),ie(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}),ie(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}),ie(this,"updateContainerElements",n=>(this.state.containers=Array.isArray(n)?n.filter(Boolean):[n].filter(Boolean),this.state.active&&this.updateTabbableNodes(),this.updateObservedNodes(),this)),ie(this,"getReturnFocusNode",n=>{let i=this.getNodeForOption("setReturnFocus",{params:[n]});return i||(i===false?false:n)}),ie(this,"getOption",(n,i,o)=>n&&n[i]!==void 0?n[i]:this.config[o||i]),ie(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}),ie(this,"findNextNavNode",n=>{let{event:i,isBackward:o=false}=n,s=n.target||fe(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 d=this.state.tabbableGroups.findIndex(({firstTabbableNode:u})=>s===u);if(d<0&&(c?.container===s||Ge(s)&&!en(s)&&!c?.nextTabbableNode(s,false))&&(d=l),d>=0){let u=d===0?this.state.tabbableGroups.length-1:d-1,h=this.state.tabbableGroups[u];a=Sr(s)>=0?h.lastTabbableNode:h.lastDomTabbableNode;}else Cd(i)||(a=c?.nextTabbableNode(s,false));}else {let d=this.state.tabbableGroups.findIndex(({lastTabbableNode:u})=>s===u);if(d<0&&(c?.container===s||Ge(s)&&!en(s)&&!c?.nextTabbableNode(s))&&(d=l),d>=0){let u=d===this.state.tabbableGroups.length-1?0:d+1,h=this.state.tabbableGroups[u];a=Sr(s)>=0?h.firstTabbableNode:h.firstDomTabbableNode;}else Cd(i)||(a=c?.nextTabbableNode(s));}}else a=this.getNodeForOption("fallbackFocus");return a}),this.trapStack=e.trapStack||o1;let t={returnFocusOnDeactivate:true,escapeDeactivates:true,delayInitialFocus:true,followControlledElements:true,isKeyForward:s1,isKeyBackward:a1,...e};this.doc=t.document||ce(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=>{Pp(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?la(r,e):false}updateTabbableNodes(){if(this.state.containerGroups=this.state.containers.map(r=>{let e=xr(r,{getShadowRoot:this.config.getShadowRoot}),t=_c(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(Sr(e[c])>0){a=true;break}function l(c,d=true){let u=e.indexOf(c);if(u>=0)return e[u+(d?1:-1)];let h=t.indexOf(c);if(!(h<0)){if(d){for(let p=h+1;p<t.length;p++)if(en(t[p]))return t[p]}else for(let p=h-1;p>=0;p--)if(en(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 xg.activateTrap(this.trapStack,this),this.state.delayInitialFocusTimer=this.config.delayInitialFocus?Sg(()=>{this.tryFocus(this.getInitialFocusNode());}):this.tryFocus(this.getInitialFocusNode()),this.listenerCleanups.push(Le(this.doc,"focusin",this.handleFocus,true),Le(this.doc,"mousedown",this.handlePointerDown,{capture:true,passive:false}),Le(this.doc,"touchstart",this.handlePointerDown,{capture:true,passive:false}),Le(this.doc,"click",this.handleClick,{capture:true,passive:false}),Le(this.doc,"keydown",this.handleTabKey,{capture:true,passive:false}),Le(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=pt(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)}},Td=r=>r?.type==="keydown",Cd=r=>Td(r)&&r?.key==="Tab",s1=r=>Td(r)&&r.key==="Tab"&&!r?.shiftKey,a1=r=>Td(r)&&r.key==="Tab"&&r?.shiftKey,qi=(r,...e)=>typeof r=="function"?r(...e):r,l1=r=>!r.isComposing&&r.key==="Escape",Sg=r=>setTimeout(r,0),c1=r=>r.localName==="input"&&"select"in r&&typeof r.select=="function";function Tg(r,e={}){let t,n=ue(()=>{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 Cg(o,{escapeDeactivates:false,allowOutsideClick:true,preventScroll:true,returnFocusOnDeactivate:true,delayInitialFocus:false,fallbackFocus:s,...e,document:ce(s)});try{t.activate();}catch{}});return function(){t?.deactivate(),n();}}var Eg="data-scroll-lock",Ed=new WeakMap;function d1(r){let e=r.getBoundingClientRect().left;return Math.round(e)+r.scrollLeft?"paddingLeft":"paddingRight"}function Pg(r){let t=vr(r)?.scrollbarGutter;return t==="stable"||t?.startsWith("stable ")===true}function u1(r){let e=r.defaultView??window,{documentElement:t,body:n}=r,i=Pg(t)||Pg(n),o=e.innerWidth-t.clientWidth;n.setAttribute(Eg,"");let s=()=>qp(t,"--scrollbar-width",`${o}px`),a=d1(t),l=()=>{let u={overflow:"hidden"};return !i&&o>0&&(u[a]=`${o}px`),Ai(n,u)},c=()=>{let{scrollX:u,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:`${-(u-Math.floor(m))}px`,right:"0"};!i&&o>0&&(g[a]=`${o}px`);let b=Ai(n,g);return ()=>{b?.(),e.scrollTo({left:u,top:h,behavior:"instant"});}},d=[s(),Ip()?c():l()];return ()=>{d.forEach(u=>u?.()),n.removeAttribute(Eg);}}function Lg(r){let e=r??document,t=Ed.get(e);t||(t={count:0,cleanup:u1(e)},Ed.set(e,t)),t.count++;let n=t,i=false;return ()=>{i||(i=true,n.count--,n.count===0&&(n.cleanup(),Ed.delete(e)));}}var Pd=oa({props({props:r,scope:e}){let t=r.role==="alertdialog",n=t?()=>fg(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=wd(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 Na(()=>ji(r),{type:"dialog",defer:true,pointerBlocking:t("modal"),layerStyleTargets:[()=>hg(r),()=>ug(r)],exclude:[yd(r),...Ua(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 Lg(r.getDoc())},trapFocus({scope:r,prop:e,context:t}){return e("trapFocus")?Tg(()=>ji(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=wd(r,s);if(l)return l}let a=Ua(r)[0];return a||i},getShadowRoot:true}):void 0},hideContentBelow({scope:r,prop:e}){return e("modal")?wg(()=>[ji(r)],{defer:true}):void 0}},actions:{setInitialFocus({prop:r,scope:e}){r("trapFocus")||ue(()=>{ua({root:ji(e),getInitialEl:r("initialFocusEl")})?.focus({preventScroll:true});});},checkRenderedElements({context:r,scope:e}){ue(()=>{r.set("rendered",{title:!!pg(e),description:!!mg(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 Mg(r={}){return {machine:Pd,props:{id:xa("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=>xd(e,Tr)}}var kg="vela-ui-dialog-5",Ig=`
|
|
241
|
+
`;function ug(r){oe(lg,cg,r);}function dg(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 hg(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 pg(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",()=>dg(e,n)),dg(e,n);}r.querySelector(".vela-select-item[data-checked]")?.scrollIntoView({block:"nearest"}),e.dispatchEvent(new Event("scroll"));}}function $a(r,e,t,n,i={}){return Ft()===r?(de(),null):mg(r,e,t,n,i)}function mg(r,e,t,n,i={}){ug(r.ownerDocument),de();let o=new Be({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),hg(s,e,t,(a,l)=>{o.hide(),n(a,l);});}});return o.show(),pg(o.el),o.reposition(),o}var Zi=class{constructor(e){this.list=null;let t=e.list?.host?.ownerDocument??document;ug(t),this.ctrl=ag(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(Me("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=$a(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 r1=It("dialog").parts("trigger","backdrop","positioner","content","title","description","closeTrigger"),an=r1.build();var yd=r=>r.ids?.positioner??`dialog:${r.id}:positioner`,wd=r=>r.ids?.backdrop??`dialog:${r.id}:backdrop`,Wa=r=>r.ids?.content??`dialog:${r.id}:content`,Ga=(r,e)=>{let t=r.ids?.trigger;return t!=null?De(t)?t(e):t:e?`dialog:${r.id}:trigger:${e}`:`dialog:${r.id}:trigger`},Ua=r=>r.ids?.title??`dialog:${r.id}:title`,Ya=r=>r.ids?.description??`dialog:${r.id}:description`,xd=r=>r.ids?.closeTrigger??`dialog:${r.id}:close`,Ji=r=>r.getById(Wa(r)),fg=r=>r.getById(yd(r)),gg=r=>r.getById(wd(r)),Sd=r=>r.getById(Ga(r)),bg=r=>r.getById(Ua(r)),vg=r=>r.getById(Ya(r)),yg=r=>r.getById(xd(r)),Ka=r=>Cr(r.getRootNode(),`[data-scope="dialog"][data-part="trigger"][data-ownedby="${r.id}"]`),Cd=(r,e)=>e==null?Sd(r)??Ka(r)[0]:r.getById(Ga(r,e));function Td(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(d){t.matches("open")!==d&&n({type:d?"OPEN":"CLOSE"});},triggerValue:c,setTriggerValue(d){n({type:"TRIGGER_VALUE.SET",value:d});},getTriggerProps(d={}){let{value:u}=d,h=u==null?false:c===u;return e.button({...an.trigger.attrs,dir:o("dir"),id:Ga(s,u),"data-ownedby":s.id,"data-value":u,"aria-haspopup":"dialog",type:"button","aria-expanded":u==null?l:l&&h,"data-state":l?"open":"closed","aria-controls":Wa(s),"data-current":We(h),onClick(p){if(p.defaultPrevented)return;let m=l&&u!=null&&!h;n({type:m?"TRIGGER_VALUE.SET":"TOGGLE",value:u});}})},getBackdropProps(){return e.element({...an.backdrop.attrs,dir:o("dir"),hidden:!l,id:wd(s),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...an.positioner.attrs,dir:o("dir"),id:yd(s),style:Qt({pointerEvents:!l||!o("modal")?"none":void 0})})},getContentProps(){let d=i.get("rendered");return e.element({...an.content.attrs,dir:o("dir"),role:o("role"),hidden:!l,id:Wa(s),tabIndex:-1,"data-state":l?"open":"closed","aria-modal":o("modal"),"aria-label":a||void 0,"aria-labelledby":a||!d.title?void 0:Ua(s),"aria-describedby":d.description?Ya(s):void 0,style:Qt({pointerEvents:o("modal")?void 0:"auto"})})},getTitleProps(){return e.element({...an.title.attrs,dir:o("dir"),id:Ua(s)})},getDescriptionProps(){return e.element({...an.description.attrs,dir:o("dir"),id:Ya(s)})},getCloseTriggerProps(){return e.button({...an.closeTrigger.attrs,dir:o("dir"),id:xd(s),type:"button",onClick(d){d.defaultPrevented||(d.stopPropagation(),n({type:"CLOSE"}));}})}}}var Dr=new WeakMap,Xa=new WeakMap,ja={},Ed=0,xg=r=>r&&(r.host||xg(r.parentNode)),i1=(r,e)=>e.map(t=>{if(r.contains(t))return t;let n=xg(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),o1=new Set(["script","output","status","next-route-announcer"]),s1=r=>o1.has(r.localName)||r.role==="status"||r.hasAttribute("aria-live")?true:r.matches("[data-live-announcer]"),Sg=(r,e)=>{let{parentNode:t,markerName:n,controlAttribute:i,explicitBooleanValue:o,followControlledElements:s=true}=e,a=i1(t,Array.isArray(r)?r:[r]);ja[n]||(ja[n]=new WeakMap);let l=ja[n],c=[],d=new Set,u=new Set(a),h=m=>{!m||d.has(m)||(d.add(m),h(m.parentNode));};a.forEach(m=>{h(m),s&&Q(m)&&Oc(m,f=>{h(f);});});let p=m=>{!m||u.has(m)||Array.prototype.forEach.call(m.children,f=>{if(d.has(f))p(f);else try{if(s1(f))return;let g=f.getAttribute(i),b=o?g==="true":g!==null&&g!=="false",v=(Dr.get(f)||0)+1,y=(l.get(f)||0)+1;Dr.set(f,v),l.set(f,y),c.push(f),v===1&&b&&Xa.set(f,!0),y===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),d.clear(),Ed++,()=>{c.forEach(m=>{let f=Dr.get(m)-1,g=l.get(m)-1;Dr.set(m,f),l.set(m,g),f||(Xa.has(m)||m.removeAttribute(i),Xa.delete(m)),g||m.removeAttribute(n);}),Ed--,Ed||(Dr=new WeakMap,Dr=new WeakMap,Xa=new WeakMap,ja={});}};var a1=r=>(Array.isArray(r)?r[0]:r).ownerDocument.body,Cg=(r,e=a1(r),t="data-aria-hidden",n=true)=>{if(e)return Sg(r,{parentNode:e,markerName:t,controlAttribute:"aria-hidden",explicitBooleanValue:true,followControlledElements:n})};var l1=r=>{let e=requestAnimationFrame(()=>r());return ()=>cancelAnimationFrame(e)};function Tg(r,e={}){let{defer:t=true}=e,n=t?l1:o=>o(),i=[];return i.push(n(()=>{let s=(typeof r=="function"?r():r).filter(Boolean);s.length!==0&&i.push(Cg(s));})),()=>{i.forEach(o=>o?.());}}var c1=Object.defineProperty,d1=(r,e,t)=>e in r?c1(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,ie=(r,e,t)=>d1(r,typeof e!="symbol"?e+"":e,t);var Eg={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();}},u1=[],Lg=class{constructor(r,e){ie(this,"trapStack"),ie(this,"config"),ie(this,"doc"),ie(this,"state",{containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:false,paused:false,delayInitialFocusTimer:void 0,recentNavEvent:void 0}),ie(this,"portalContainers",new Set),ie(this,"listenerCleanups",[]),ie(this,"handleFocus",n=>{let i=fe(n),o=this.findContainerIndex(i,n)>=0;if(o||Ri(i))o&&(this.state.mostRecentlyFocusedNode=i);else {n.stopImmediatePropagation();let s,a=true;if(this.state.mostRecentlyFocusedNode)if(Sr(this.state.mostRecentlyFocusedNode)>0){let l=this.findContainerIndex(this.state.mostRecentlyFocusedNode),{tabbableNodes:c}=this.state.containerGroups[l];if(c.length>0){let d=c.findIndex(u=>u===this.state.mostRecentlyFocusedNode);d>=0&&(this.config.isKeyForward(this.state.recentNavEvent)?d+1<c.length&&(s=c[d+1],a=false):d-1>=0&&(s=c[d-1],a=false));}}else this.state.containerGroups.some(l=>l.tabbableNodes.some(c=>Sr(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;}),ie(this,"handlePointerDown",n=>{let i=fe(n);if(!(this.findContainerIndex(i,n)>=0)){if(Qi(this.config.clickOutsideDeactivates,n)){this.deactivate({returnFocus:this.config.returnFocusOnDeactivate});return}Qi(this.config.allowOutsideClick,n)||n.preventDefault();}}),ie(this,"handleClick",n=>{let i=fe(n);this.findContainerIndex(i,n)>=0||Qi(this.config.clickOutsideDeactivates,n)||Qi(this.config.allowOutsideClick,n)||(n.preventDefault(),n.stopImmediatePropagation());}),ie(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;Pd(n)&&n.preventDefault(),this.tryFocus(o);}}),ie(this,"handleEscapeKey",n=>{m1(n)&&Qi(this.config.escapeDeactivates,n)!==false&&(n.preventDefault(),this.deactivate());}),ie(this,"_mutationObserver"),ie(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 Ap(c)?true:c.id&&!this.state.containers.some(d=>d.contains(c))?Rp(c):false}):false)&&this.state.active&&!this.state.paused&&(this.updateTabbableNodes(),this.updatePortalContainers());});}),ie(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);}));}),ie(this,"getInitialFocusNode",()=>{let n=this.getNodeForOption("initialFocus",{hasFallback:true});if(n===false)return false;if(n===void 0||n&&!Ge(n)){let i=mt(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}),ie(this,"tryFocus",n=>{if(n!==false&&n!==mt(this.doc)){if(!n||!n.focus){this.tryFocus(this.getInitialFocusNode());return}n.focus({preventScroll:!!this.config.preventScroll}),this.state.mostRecentlyFocusedNode=n,f1(n)&&n.select();}}),ie(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(),Eg.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=()=>{Pg(()=>{if(l){let d=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);this.tryFocus(d);}s?.();});};if(l&&a){let d=this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);return a(d).then(c,c),this}return c(),this}),ie(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}),ie(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}),ie(this,"updateContainerElements",n=>(this.state.containers=Array.isArray(n)?n.filter(Boolean):[n].filter(Boolean),this.state.active&&this.updateTabbableNodes(),this.updateObservedNodes(),this)),ie(this,"getReturnFocusNode",n=>{let i=this.getNodeForOption("setReturnFocus",{params:[n]});return i||(i===false?false:n)}),ie(this,"getOption",(n,i,o)=>n&&n[i]!==void 0?n[i]:this.config[o||i]),ie(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}),ie(this,"findNextNavNode",n=>{let{event:i,isBackward:o=false}=n,s=n.target||fe(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 d=this.state.tabbableGroups.findIndex(({firstTabbableNode:u})=>s===u);if(d<0&&(c?.container===s||Ge(s)&&!tn(s)&&!c?.nextTabbableNode(s,false))&&(d=l),d>=0){let u=d===0?this.state.tabbableGroups.length-1:d-1,h=this.state.tabbableGroups[u];a=Sr(s)>=0?h.lastTabbableNode:h.lastDomTabbableNode;}else Pd(i)||(a=c?.nextTabbableNode(s,false));}else {let d=this.state.tabbableGroups.findIndex(({lastTabbableNode:u})=>s===u);if(d<0&&(c?.container===s||Ge(s)&&!tn(s)&&!c?.nextTabbableNode(s))&&(d=l),d>=0){let u=d===this.state.tabbableGroups.length-1?0:d+1,h=this.state.tabbableGroups[u];a=Sr(s)>=0?h.firstTabbableNode:h.firstDomTabbableNode;}else Pd(i)||(a=c?.nextTabbableNode(s));}}else a=this.getNodeForOption("fallbackFocus");return a}),this.trapStack=e.trapStack||u1;let t={returnFocusOnDeactivate:true,escapeDeactivates:true,delayInitialFocus:true,followControlledElements:true,isKeyForward:h1,isKeyBackward:p1,...e};this.doc=t.document||ce(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=>{Ip(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?da(r,e):false}updateTabbableNodes(){if(this.state.containerGroups=this.state.containers.map(r=>{let e=xr(r,{getShadowRoot:this.config.getShadowRoot}),t=zc(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(Sr(e[c])>0){a=true;break}function l(c,d=true){let u=e.indexOf(c);if(u>=0)return e[u+(d?1:-1)];let h=t.indexOf(c);if(!(h<0)){if(d){for(let p=h+1;p<t.length;p++)if(tn(t[p]))return t[p]}else for(let p=h-1;p>=0;p--)if(tn(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 Eg.activateTrap(this.trapStack,this),this.state.delayInitialFocusTimer=this.config.delayInitialFocus?Pg(()=>{this.tryFocus(this.getInitialFocusNode());}):this.tryFocus(this.getInitialFocusNode()),this.listenerCleanups.push(Le(this.doc,"focusin",this.handleFocus,true),Le(this.doc,"mousedown",this.handlePointerDown,{capture:true,passive:false}),Le(this.doc,"touchstart",this.handlePointerDown,{capture:true,passive:false}),Le(this.doc,"click",this.handleClick,{capture:true,passive:false}),Le(this.doc,"keydown",this.handleTabKey,{capture:true,passive:false}),Le(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=mt(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)}},Ld=r=>r?.type==="keydown",Pd=r=>Ld(r)&&r?.key==="Tab",h1=r=>Ld(r)&&r.key==="Tab"&&!r?.shiftKey,p1=r=>Ld(r)&&r.key==="Tab"&&r?.shiftKey,Qi=(r,...e)=>typeof r=="function"?r(...e):r,m1=r=>!r.isComposing&&r.key==="Escape",Pg=r=>setTimeout(r,0),f1=r=>r.localName==="input"&&"select"in r&&typeof r.select=="function";function Mg(r,e={}){let t,n=ue(()=>{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 Lg(o,{escapeDeactivates:false,allowOutsideClick:true,preventScroll:true,returnFocusOnDeactivate:true,delayInitialFocus:false,fallbackFocus:s,...e,document:ce(s)});try{t.activate();}catch{}});return function(){t?.deactivate(),n();}}var kg="data-scroll-lock",Md=new WeakMap;function g1(r){let e=r.getBoundingClientRect().left;return Math.round(e)+r.scrollLeft?"paddingLeft":"paddingRight"}function Ig(r){let t=vr(r)?.scrollbarGutter;return t==="stable"||t?.startsWith("stable ")===true}function b1(r){let e=r.defaultView??window,{documentElement:t,body:n}=r,i=Ig(t)||Ig(n),o=e.innerWidth-t.clientWidth;n.setAttribute(kg,"");let s=()=>em(t,"--scrollbar-width",`${o}px`),a=g1(t),l=()=>{let u={overflow:"hidden"};return !i&&o>0&&(u[a]=`${o}px`),Oi(n,u)},c=()=>{let{scrollX:u,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:`${-(u-Math.floor(m))}px`,right:"0"};!i&&o>0&&(g[a]=`${o}px`);let b=Oi(n,g);return ()=>{b?.(),e.scrollTo({left:u,top:h,behavior:"instant"});}},d=[s(),Op()?c():l()];return ()=>{d.forEach(u=>u?.()),n.removeAttribute(kg);}}function Ag(r){let e=r??document,t=Md.get(e);t||(t={count:0,cleanup:b1(e)},Md.set(e,t)),t.count++;let n=t,i=false;return ()=>{i||(i=true,n.count--,n.count===0&&(n.cleanup(),Md.delete(e)));}}var kd=aa({props({props:r,scope:e}){let t=r.role==="alertdialog",n=t?()=>yg(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=Cd(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 _a(()=>Ji(r),{type:"dialog",defer:true,pointerBlocking:t("modal"),layerStyleTargets:[()=>gg(r),()=>fg(r)],exclude:[Sd(r),...Ka(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 Ag(r.getDoc())},trapFocus({scope:r,prop:e,context:t}){return e("trapFocus")?Mg(()=>Ji(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=Cd(r,s);if(l)return l}let a=Ka(r)[0];return a||i},getShadowRoot:true}):void 0},hideContentBelow({scope:r,prop:e}){return e("modal")?Tg(()=>[Ji(r)],{defer:true}):void 0}},actions:{setInitialFocus({prop:r,scope:e}){r("trapFocus")||ue(()=>{pa({root:Ji(e),getInitialEl:r("initialFocusEl")})?.focus({preventScroll:true});});},checkRenderedElements({context:r,scope:e}){ue(()=>{r.set("rendered",{title:!!bg(e),description:!!vg(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 Rg(r={}){return {machine:kd,props:{id:Ca("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=>Td(e,Tr)}}var Dg="vela-ui-dialog-5",Og=`
|
|
242
242
|
.vela-dialog-backdrop {
|
|
243
243
|
position: fixed;
|
|
244
244
|
inset: 0;
|
|
@@ -377,7 +377,7 @@ ${On(".vela-dialog *")}
|
|
|
377
377
|
}
|
|
378
378
|
[data-layout='mobile'] .vela-dialog-close { width: 40px; height: 40px; }
|
|
379
379
|
[data-layout='mobile'] .vela-dialog-body { padding-bottom: calc(var(--vela-space-4) + env(safe-area-inset-bottom, 0px)); }
|
|
380
|
-
`;var Nt=class{constructor(e={}){let t=(e.host??document.body).ownerDocument;oe(
|
|
380
|
+
`;var Nt=class{constructor(e={}){let t=(e.host??document.body).ownerDocument;oe(Dg,Og,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,d=0,u=0,h=false;i.addEventListener("pointerdown",p=>{p.target.closest(".vela-dialog-close")||(h=true,l=p.clientX-d,c=p.clientY-u,i.setPointerCapture(p.pointerId));}),i.addEventListener("pointermove",p=>{h&&(d=p.clientX-l,u=p.clientY-c,this.panel.style.transform=`translate(${d}px, ${u}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(Me("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(xt()||$n(c)){de();return}this.hide();}};this.backdrop.addEventListener("pointerdown",l),this.positioner.addEventListener("pointerdown",l);}this.ctrl=Rg({...e,initialFocusEl:()=>this.positioner.closest('[data-layout="mobile"]')?this.panel:e.initialFocusEl?.()??null});let a=String(this.ctrl.props.id);this.handle=Sa(this.ctrl.machine,this.ctrl.props,l=>{let c=this.ctrl.connect(l);Fe(this.backdrop,c.getBackdropProps(),a),Fe(this.positioner,c.getPositionerProps(),a),Fe(this.panel,c.getContentProps(),a),Fe(o,c.getTitleProps(),a),Fe(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 Fg(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 Ng="vela-ui-switch",Vg=`
|
|
381
381
|
.vela-switch {
|
|
382
382
|
width: 20px;
|
|
383
383
|
height: 20px;
|
|
@@ -415,7 +415,7 @@ ${On(".vela-dialog *")}
|
|
|
415
415
|
color: var(--vela-selected-fg);
|
|
416
416
|
}
|
|
417
417
|
.vela-switch[disabled] { opacity: 0.4; cursor: default; }
|
|
418
|
-
`;var Wn=class{constructor(e={}){oe(
|
|
418
|
+
`;var Wn=class{constructor(e={}){oe(Ng,Vg,document),this.ctrl=Fg(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(Me("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 y1(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 _g(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 Id(r,e,t){let n=Math.min(20,Math.max(_g(e),_g(t)));return Number(r.toFixed(n))}function Bg(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?y1(c,{min:r.min,max:r.max,integer:t}):c,l=c=>{if(!Number.isFinite(c))return null;let d=a(c);return d!==e&&(e=d,s?.(d)),d};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 d=Number.isFinite(c)?a(c):e;return e=d,d},nudge(c){return l(Id(e+c*o,e,o))}}}var Hg="vela-ui-number-3",zg=`
|
|
419
419
|
.vela-num { position: relative; display: inline-block; min-width: 0; }
|
|
420
420
|
.vela-num[data-fill] { width: 100%; }
|
|
421
421
|
.vela-num:not([data-fill]) { width: 100px; flex: none; justify-self: start; }
|
|
@@ -486,7 +486,7 @@ ${On(".vela-dialog *")}
|
|
|
486
486
|
}
|
|
487
487
|
.vela-num-step button:hover { background: var(--vela-hover); color: var(--vela-fg-bright); }
|
|
488
488
|
.vela-num-step .vela-icon, .vela-num-step svg { width: 12px; height: 12px; display: block; }
|
|
489
|
-
`;var Gn=class{constructor(e){let t=document;oe(
|
|
489
|
+
`;var Gn=class{constructor(e){let t=document;oe(Hg,zg,t),this.ctrl=Bg(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(Id(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(Me(s,e));let c=0,d=()=>t(o),u=()=>{c&&(window.clearTimeout(c),c=0);};return l.addEventListener("pointerdown",h=>{h.preventDefault(),h.stopPropagation(),d(),c=window.setTimeout(function p(){d(),c=window.setTimeout(p,60);},400);}),l.addEventListener("pointerup",u),l.addEventListener("pointerleave",u),l.addEventListener("pointercancel",u),l};return n.append(i(1,"chevron-up","Increase"),i(-1,"chevron-down","Decrease")),n}};function $g(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 Wg="vela-ui-text-2",Gg=`
|
|
490
490
|
.vela-text {
|
|
491
491
|
display: inline-block;
|
|
492
492
|
min-width: 0;
|
|
@@ -522,7 +522,7 @@ ${On(".vela-dialog *")}
|
|
|
522
522
|
color: var(--vela-fg);
|
|
523
523
|
font-size: 13px;
|
|
524
524
|
}
|
|
525
|
-
`;var
|
|
525
|
+
`;var eo=class{constructor(e={}){let t=document;oe(Wg,Gg,t),this.ctrl=$g(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 Ug(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 Yg="vela-ui-textarea",Kg=`
|
|
526
526
|
.vela-textarea { display: block; width: 100%; min-width: 0; }
|
|
527
527
|
.vela-textarea-field {
|
|
528
528
|
display: block;
|
|
@@ -554,14 +554,14 @@ ${On(".vela-dialog *")}
|
|
|
554
554
|
padding: 6px 9px;
|
|
555
555
|
line-height: 18px;
|
|
556
556
|
}
|
|
557
|
-
`;var Un=class{constructor(e={}){let t=document;oe(
|
|
557
|
+
`;var Un=class{constructor(e={}){let t=document;oe(Yg,Kg,t),this.ctrl=Ug(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 ln(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:tr,alpha:1}}function qa(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 Rd(r,e,t){let n=h=>{let p=parseInt(ln(h).hex6.slice(1),16);return [p>>16&255,p>>8&255,p&255]},[i,o,s]=n(r),[a,l,c]=n(e),d=Math.max(0,Math.min(1,t)),u=h=>Math.round(h).toString(16).padStart(2,"0");return `#${u(i*d+a*(1-d))}${u(o*d+l*(1-d))}${u(s*d+c*(1-d))}`}function Ad(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 Dd(){let r=[100,90,80,68,56,45,35,25,14,0].map(n=>Ad(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=>Ad(o,n,i)))]}function Za(r){return `repeating-conic-gradient(#9aa0a6 0% 25%, #d3d6da 0% 50%) 0 0 / ${r}px ${r}px`}var Xg="vela-ui-color",jg=`
|
|
558
558
|
.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;}
|
|
559
559
|
.vela-color-field:hover{border-color:var(--vela-fg-muted);}
|
|
560
560
|
.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);}
|
|
561
561
|
.vela-color-field-circle{width:26px;height:26px;padding:3px;border:1px solid var(--vela-border-strong);border-radius:4px;background:transparent;overflow:hidden;}
|
|
562
562
|
.vela-color-field-circle .vela-color-field-swatch{border-radius:2px;box-shadow:none;}
|
|
563
563
|
.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;}
|
|
564
|
-
`;var
|
|
564
|
+
`;var w1=Dd(),x1=Za(10),S1=Za(8),Or=[Te,J,X,pn,Ee];function C1(r){let e=Or.findIndex(t=>t.toLowerCase()===r.toLowerCase());e>=0&&Or.splice(e,1),Or.unshift(r),Or.length>10&&(Or.length=10);}function to(r,e,t){let n=ln(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 x of w1)for(let S of x){let E=document.createElement("button");E.type="button",E.dataset.c=S,E.style.cssText=`width:100%;aspect-ratio:1;border-radius:4px;border:none;cursor:pointer;background:${S};padding:0;`,E.addEventListener("click",L=>{L.stopPropagation(),P(S);}),a.appendChild(E),l.push(E);}let c=()=>{for(let x of l){let S=(x.dataset.c??"").toLowerCase()===i.toLowerCase();x.style.outline=S?`2px solid ${e.textColor}`:"none",x.style.outlineOffset="2px",x.style.zIndex=S?"1":"",x.style.position=S?"relative":"";}},d=document.createElement("div");d.style.cssText="display:flex;align-items:center;gap:5px;flex-wrap:wrap;border-top:1px solid var(--vela-border);padding-top:9px;";let u=()=>{d.replaceChildren();for(let E of Or){let L=document.createElement("button");L.type="button",L.style.cssText=`width:17px;height:17px;border-radius:var(--vela-radius-sm);border:1px solid var(--vela-border);cursor:pointer;background:${E};padding:0;`,L.addEventListener("click",T=>{T.stopPropagation(),P(E);}),d.appendChild(L);}let x=document.createElement("label");x.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;`,x.textContent="+";let S=document.createElement("input");S.type="color",S.value=i,S.style.cssText="position:absolute;inset:0;opacity:0;cursor:pointer;",S.addEventListener("input",()=>P(S.value,true)),x.appendChild(S),d.appendChild(x);},h=document.createElement("div");h.textContent="Opacity",h.style.cssText=`font:11px ${e.fontFamily};color:var(--vela-fg-muted);`;let p=document.createElement("div");p.style.cssText="display:flex;align-items:center;gap:10px;";let m=document.createElement("div");m.style.cssText="flex:1;position:relative;height:13px;border-radius:7px;cursor:pointer;";let f=document.createElement("div");f.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;",m.appendChild(f);let g=document.createElement("div");g.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;`,p.append(m,g);let b=()=>{m.style.background=`linear-gradient(to right, ${i}00, ${i}ff), ${x1}`,f.style.left=`${o*100}%`,g.textContent=`${Math.round(o*100)}%`;},v=false,y=x=>{let S=m.getBoundingClientRect();o=Math.max(0,Math.min(1,(x-S.left)/S.width)),b(),w();};m.addEventListener("pointerdown",x=>{x.stopPropagation(),v=true,m.setPointerCapture(x.pointerId),y(x.clientX);}),m.addEventListener("pointermove",x=>{v&&y(x.clientX);}),m.addEventListener("pointerup",()=>v=false);function w(){t(qa(i,o));}function P(x,S=false){i=ln(x).hex6,C1(i),c(),b(),S&&u(),w();}return u(),c(),b(),s.append(a,d,h,p),s}function Od(r,e,t,n){return new Ja({theme:r,getVal:e,onVal:t,shape:n?.shape,id:n?.id,popover:n?.popover}).el}var Ja=class{constructor(e){oe(Xg,jg,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}), ${S1}`;}toggle(){if(Ft()===this.el){de();return}new Be({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:to(this.getVal(),this.theme,t=>{this.onVal(t),this.paint();})}).show();}};function qg(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 T1=[1,2,3,4,5];function E1(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 Zg(){return T1.map(r=>({value:r,label:`${r}px`,glyph:E1(r)}))}var Jg="vela-ui-glyph-select",Qg=`
|
|
565
565
|
.vela-glyph-select {
|
|
566
566
|
height: 34px;
|
|
567
567
|
padding: 0 26px 0 8px;
|
|
@@ -622,7 +622,7 @@ ${On(".vela-dialog *")}
|
|
|
622
622
|
}
|
|
623
623
|
.vela-glyph-select-item:hover { background: var(--vela-hover); }
|
|
624
624
|
.vela-glyph-select-item[data-active='1'] { background: var(--vela-hover-strong); color: var(--vela-fg-bright); }
|
|
625
|
-
`;var
|
|
625
|
+
`;var Qa=class{constructor(e){oe(Jg,Qg,document),this.ctrl=qg(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(Me("chevron-down",this.el.ownerDocument)),this.el.replaceChildren(n,i);}toggle(){if(Ft()===this.el){de();return}let e=this.get(),t=new Be({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 Fd(r,e,t){return new Qa({theme:r,options:Zg(),value:e(),get:e,onChange:t}).el}function Nd(){de();}function no(r,e){return r==="inputs"?e?"minmax(0,1fr) auto":"max-content 1fr":e?"minmax(0,1fr) max-content":"max-content max-content"}var eb="vela-ui-field",tb=`
|
|
626
626
|
.vela-field-grid {
|
|
627
627
|
display: grid;
|
|
628
628
|
align-items: center;
|
|
@@ -675,10 +675,10 @@ ${On(".vela-dialog *")}
|
|
|
675
675
|
.vela-field-section[data-variant='inputs'][data-first] { padding-top: 4px; }
|
|
676
676
|
.vela-field-sep { grid-column: 1 / -1; height: 14px; }
|
|
677
677
|
.vela-field-dim { opacity: 0.4 !important; pointer-events: none !important; }
|
|
678
|
-
`;function el(r=document){oe(qg,Zg,r);}function to(r={}){el();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=Qi(t,r.mobile===true),e}function Vt(r,e={}){el();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 Fd(){el();let r=document.createElement("div");return r.className="vela-field-sep",r}function eo(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 Jg(r){return r?Array.isArray(r)?r:[r]:[]}function Qa(r,e){if(e)for(let t of e.split(/\s+/))t&&r.classList.add(t);}function Od(r,e){for(let t of r)t.dataset.sdSelfGated!=="1"&&t.classList.toggle("vela-field-dim",!e);}function he(r){el();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(eo(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),Qa(o,r.className),o}if(r.bool){let o=document.createElement("div");o.className="vela-field-span vela-field-bool";let s=new Wn({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,eo(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 Qa(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(eo(r.label,{id:r.id,size:e})),r.info&&s.appendChild(r.info),o.appendChild(s);for(let a of Jg(r.control))o.appendChild(a);return Qa(o,r.className),o}let t=document.createElement("div");t.className="vela-field-row";let n=Jg(r.control);if(r.toggle){let o=document.createElement("div");o.className="vela-field-toggle-label";let s=new Wn({id:r.toggle.id??r.id,checked:r.toggle.checked,size:"md",tone:"bright",onChange:a=>{r.toggle.onChange(a),n.length>0&&Od(n,a);}});if(o.append(s.el,eo(r.label,{id:r.toggle.id??r.id,size:e})),t.appendChild(o),n.length>0&&Od(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&&Od(n,l);});}}else t.appendChild(eo(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),Qa(t,r.className),t}function q(r){if(r.kind==="number"){let t=new Gn({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 Xi({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 Wn({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=Ad(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 Zi({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 Un({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=Rd(r.theme,r.get,r.onChange);return r.title&&(e.title=r.title),{el:e}}var w1=["close","open","high","low","hl2","hlc3","ohlc4","volume"],rl=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.dialogTips=[];this.refreshVisibility=null;this.choicePop=null;this.calendarPop=null;this.calendarAnchor=null;this.onDialogKey=e=>{if(e.key==="Escape"){if(e.preventDefault(),wt()){de();return}this.close();}};}isOpen(){return this.dialog!==null}open(e){if(this.close(),e.inputs.length===0)return;this.row=e,this.openId=e.id,this.snapshot={...e.values},il();let t=this.host.theme(),n="var(--vela-border)",i="var(--vela-fg-bright)",o=this.host.dialogHost()??this.host.container,s=new Nt({host:o,title:e.settingsTitle,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.dialogButton("Cancel",false,()=>this.revertAndClose()),this.dialogButton("Ok",true,()=>this.close()));},onOpenChange:g=>{g||this.close();}});ve(s.panel,t),s.panel.style.colorScheme=this.isDarkTheme()?"dark":"light",this.dialogTips.push(ht(s.panel.querySelector(".vela-dialog-close"),{host:this.host.container,theme:()=>this.host.theme(),text:()=>"Close"}));let a=S1(e.inputs),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=[],d=[],u=[],h=0,p=g=>{h=g;for(let b=0;b<c.length;b+=1){let v=b===g,y=c[b];y.style.borderBottomColor=v?i:"transparent",y.style.color=v?"inherit":"var(--vela-fg-muted)",y.classList.toggle("vela-ind-tab-active",v),d[b].style.display=v?"grid":"none";}};for(let[g,b]of a.entries()){let v=document.createElement("div");v.textContent=b.name,v.className="vela-ind-tab",v.style.cssText=`padding:0 0 8px;margin-bottom:-1px;border-bottom:2px solid transparent;${a.length>1?"cursor:pointer;":""}`,v.addEventListener("click",()=>p(g)),l.appendChild(v),c.push(v),d.push(this.buildTabBody(b.inputs,e,u)),b.inputs.every(y=>y.when)&&u.push({el:v,visible:y=>b.inputs.some(w=>Ki(w.when,y))});}s.body.appendChild(l);for(let g of d)s.body.appendChild(g);p(0);let m=()=>{let g=C1(e);for(let b of u)b.el.style.display=b.visible(g)?"":"none";if(c[h]?.style.display==="none"){let b=c.findIndex(v=>v.style.display!=="none");b>=0&&p(b);}};this.refreshVisibility=m,m();let f=g=>{if(!(g.target!==s.backdrop&&g.target!==s.positioner)){if(wt()||$n(g)){de();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=x1(this.host.mobile());for(let o of T1(e)){let s=document.createElement("div");s.style.cssText="display:contents;";let a=null;o.name&&(a=Vt(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(d=>d.when)&&n.push({el:c,visible:d=>eb(l,d)});}if(a&&o.rows.every(l=>l.every(c=>c.when))){let l=o.rows;n.push({el:a,visible:c=>l.some(d=>eb(d,c))});}i.appendChild(s);}return i}close(){document.removeEventListener("keydown",this.onDialogKey),de(),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,e?.destroy();}revertAndClose(){let e=this.row,t=this.snapshot;if(e&&t)for(let n of e.inputs){let i=t[n.key],o=i!==void 0?i:n.defval;e.values[n.key]!==o&&(e.values[n.key]=o,this.host.onChange?.({indicatorId:e.id,key:n.key,value:o}));}this.close();}commit(e,t,n){e.values[t]=n,this.host.onChange?.({indicatorId:e.id,key:t,value:n}),this.refreshVisibility?.();}buildInputRow(e,t,n){let i=d=>`vela-inp-${n.id}-${d.key}`,o=d=>(e.appendChild(d),d);if(t.length>1)return o(he({label:"",inline:t.map(d=>({label:tl(d)||void 0,id:i(d),control:this.buildControl(n,d,i(d)),toggleFirst:d.type==="bool",fit:d.type==="color"||d.type==="bool"})),info:[...t].reverse().find(d=>d.tooltip)?.tooltip?this.infoButton([...t].reverse().find(d=>d.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 d=!!(n.values[s.key]??s.defval);return o(he({label:tl(s),id:a,bool:true,info:l,toggle:{id:a,checked:d,onChange:u=>this.commit(n,s.key,u)}}))}if(s.type==="text_area")return o(he({label:tl(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(he({label:tl(s),id:a,fit:c,controlWidth:c?void 0:100,info:l,control:this.buildControl(n,s,a)}))}buildControl(e,t,n){let i=e.values[t.key]??t.defval,o=s=>this.commit(e,t.key,s);return t.type==="bool"?q({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,w1,String(i),o):t.type==="color"?q({kind:"color",id:n,theme:this.host.theme(),get:()=>String(e.values[t.key]??t.defval),onChange:s=>o(s)}).el:t.type==="symbol"?this.buildSymbol(n,String(i),o):t.type==="timeframe"?this.selectPairs(n,L1,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"?q({kind:"textarea",id:n,value:String(i),onChange:s=>o(s)}).el:t.type==="int"||t.type==="float"||t.type==="price"?q({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 q({kind:"text",id:e,value:t,onChange:n}).el}infoButton(e){let t=document.createElement("span");return t.textContent="i",this.dialogTips.push(ht(t,{host:this.host.container,theme:()=>this.host.theme(),text:()=>e,wrap:true,delayMs:250})),t.className="vela-ind-hint",t.style.cssText="flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;font-weight:600;font-size:11px;font-family:inherit;line-height:1;cursor:help;user-select:none;",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 q({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]=D1(t),s=document.createElement("div");s.style.cssText="display:flex;align-items:center;gap:6px;";let a=i,l=o,c=()=>n(O1(a,l));return s.append(this.timeCombobox(e,a,86,d=>{a=d,c();}),this.timeCombobox(`${e}-end`,l,86,d=>{l=d,c();})),s}buildTime(e,t,n){let i=F1(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 u=Date.parse(`${s}T${a}:00`);Number.isFinite(u)&&n(u);},c=this.dateField(e,s,u=>{s=u,l();}),d=this.timeCombobox(`${e}-time`,a,86,u=>{a=u,l();});return o.append(c,d),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=P1;let l=t,c=()=>{let p=R1(s.value);if(!p){s.value=l;return}s.value=p,p!==l&&(l=p,i(p));};s.addEventListener("blur",()=>{wt()||c();});let d=p=>{l=p,s.value=p,i(p);},u=()=>{this.choicePop=Ha(o,M1,l,d,{...this.listPopover(),onClose:()=>{this.choicePop=null;}});};s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),c(),s.blur()),p.key==="ArrowDown"&&(p.preventDefault(),u());});let h=p=>{p.preventDefault(),p.stopPropagation(),u();};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=E1;let a=t,l=()=>{let u=ib(o.value);if(!u){o.value=a;return}o.value=u,u!==a&&(a=u,n(u));};o.addEventListener("blur",()=>{wt()||l();});let c=u=>{a=u,o.value=u,n(u);};o.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l(),o.blur()),u.key==="ArrowDown"&&(u.preventDefault(),this.openCalendar(i,a,c));});let d=u=>{if(u.preventDefault(),u.stopPropagation(),Ft()===i){de();return}this.openCalendar(i,a,c);};return o.addEventListener("click",d),s.addEventListener("mousedown",u=>u.preventDefault()),s.addEventListener("click",d),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=A1(t),o=i?.getFullYear()??new Date().getFullYear(),s=i?.getMonth()??new Date().getMonth(),a=i?Nd(i):t,l=new Be({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 d=document.createElement("div");d.className="vela-ind-cal-title";let u=document.createElement("button");u.type="button",u.className="vela-ind-cal-nav",u.setAttribute("aria-label","Previous month"),u.innerHTML=me("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=me("chevron-right",14);let p=document.createElement("div");p.className="vela-ind-cal-head",p.append(u,d,h);let m=document.createElement("div");m.className="vela-ind-cal-week";for(let b of I1){let v=document.createElement("span");v.textContent=b,m.appendChild(v);}let f=document.createElement("div");f.className="vela-ind-cal-grid";let g=()=>{d.textContent=`${k1[s]} ${o}`,f.replaceChildren();let v=new Date(o,s,1).getDay(),y=new Date(o,s+1,0).getDate(),w=Nd(new Date);for(let P=0;P<v;P++){let x=document.createElement("span");x.className="vela-ind-cal-blank",f.appendChild(x);}for(let P=1;P<=y;P++){let x=`${o}-${String(s+1).padStart(2,"0")}-${String(P).padStart(2,"0")}`,S=document.createElement("button");S.type="button",S.className="vela-ind-cal-day",S.textContent=String(P),x===a&&(S.dataset.checked="1"),x===w&&(S.dataset.today="1"),S.addEventListener("click",E=>{E.stopPropagation(),l.hide(),n(x);}),f.appendChild(S);}};u.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 _e(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 tl(r){let e=r.title;return e.length>0?e.charAt(0).toUpperCase()+e.slice(1):""}var Qg=16;function x1(r){return `padding:16px 20px;overflow-y:auto;overflow-x:hidden;overflow-anchor:none;flex:1 1 auto;display:grid;grid-template-columns:${Qi("inputs",r)};align-items:center;align-content:start;column-gap:${Qg}px;row-gap:${Qg}px;`}var nl="Inputs";function S1(r){let e=new Map;for(let n of r){let i=n.tab&&n.tab.length>0?n.tab:nl;e.has(i)||e.set(i,[]),e.get(i).push(n);}let t=[...e.keys()];return t.includes(nl)&&(t.splice(t.indexOf(nl),1),t.unshift(nl)),t.map(n=>({name:n,inputs:e.get(n)}))}function eb(r,e){return r.some(t=>Ki(t.when,e))}function C1(r){let e={};for(let t of r.inputs)e[t.key]=r.values[t.key]??t.defval;return e}function T1(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 E1=me("calendar",14),P1=me("clock",14),tb="vela-ind-dialog-styles",nb="29",rb=16;function il(){if(typeof document>"u")return;let r=document.getElementById(tb);if(r?.dataset.rev===nb)return;let e=r??document.createElement("style");e.id=tb,e.dataset.rev=nb,e.textContent=`
|
|
679
|
-
.vela-ind-combo input{${
|
|
678
|
+
`;function nl(r=document){oe(eb,tb,r);}function io(r={}){nl();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=no(t,r.mobile===true),e}function Vt(r,e={}){nl();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 _d(){nl();let r=document.createElement("div");return r.className="vela-field-sep",r}function ro(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 nb(r){return r?Array.isArray(r)?r:[r]:[]}function tl(r,e){if(e)for(let t of e.split(/\s+/))t&&r.classList.add(t);}function Vd(r,e){for(let t of r)t.dataset.sdSelfGated!=="1"&&t.classList.toggle("vela-field-dim",!e);}function he(r){nl();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(ro(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),tl(o,r.className),o}if(r.bool){let o=document.createElement("div");o.className="vela-field-span vela-field-bool";let s=new Wn({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,ro(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 tl(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(ro(r.label,{id:r.id,size:e})),r.info&&s.appendChild(r.info),o.appendChild(s);for(let a of nb(r.control))o.appendChild(a);return tl(o,r.className),o}let t=document.createElement("div");t.className="vela-field-row";let n=nb(r.control);if(r.toggle){let o=document.createElement("div");o.className="vela-field-toggle-label";let s=new Wn({id:r.toggle.id??r.id,checked:r.toggle.checked,size:"md",tone:"bright",onChange:a=>{r.toggle.onChange(a),n.length>0&&Vd(n,a);}});if(o.append(s.el,ro(r.label,{id:r.toggle.id??r.id,size:e})),t.appendChild(o),n.length>0&&Vd(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&&Vd(n,l);});}}else t.appendChild(ro(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),tl(t,r.className),t}function q(r){if(r.kind==="number"){let t=new Gn({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 Zi({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 Wn({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=Od(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 eo({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 Un({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=Fd(r.theme,r.get,r.onChange);return r.title&&(e.title=r.title),{el:e}}var P1=["close","open","high","low","hl2","hlc3","ohlc4","volume"],ol=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.dialogTips=[];this.refreshVisibility=null;this.choicePop=null;this.calendarPop=null;this.calendarAnchor=null;this.onDialogKey=e=>{if(e.key==="Escape"){if(e.preventDefault(),xt()){de();return}this.close();}};}isOpen(){return this.dialog!==null}open(e){if(this.close(),e.inputs.length===0)return;this.row=e,this.openId=e.id,this.snapshot={...e.values},sl();let t=this.host.theme(),n="var(--vela-border)",i="var(--vela-fg-bright)",o=this.host.dialogHost()??this.host.container,s=new Nt({host:o,title:e.settingsTitle,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.dialogButton("Cancel",false,()=>this.revertAndClose()),this.dialogButton("Ok",true,()=>this.close()));},onOpenChange:g=>{g||this.close();}});ve(s.panel,t),s.panel.style.colorScheme=this.isDarkTheme()?"dark":"light",this.dialogTips.push(pt(s.panel.querySelector(".vela-dialog-close"),{host:this.host.container,theme:()=>this.host.theme(),text:()=>"Close"}));let a=M1(e.inputs),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=[],d=[],u=[],h=0,p=g=>{h=g;for(let b=0;b<c.length;b+=1){let v=b===g,y=c[b];y.style.borderBottomColor=v?i:"transparent",y.style.color=v?"inherit":"var(--vela-fg-muted)",y.classList.toggle("vela-ind-tab-active",v),d[b].style.display=v?"grid":"none";}};for(let[g,b]of a.entries()){let v=document.createElement("div");v.textContent=b.name,v.className="vela-ind-tab",v.style.cssText=`padding:0 0 8px;margin-bottom:-1px;border-bottom:2px solid transparent;${a.length>1?"cursor:pointer;":""}`,v.addEventListener("click",()=>p(g)),l.appendChild(v),c.push(v),d.push(this.buildTabBody(b.inputs,e,u)),b.inputs.every(y=>y.when)&&u.push({el:v,visible:y=>b.inputs.some(w=>qi(w.when,y))});}s.body.appendChild(l);for(let g of d)s.body.appendChild(g);p(0);let m=()=>{let g=k1(e);for(let b of u)b.el.style.display=b.visible(g)?"":"none";if(c[h]?.style.display==="none"){let b=c.findIndex(v=>v.style.display!=="none");b>=0&&p(b);}};this.refreshVisibility=m,m();let f=g=>{if(!(g.target!==s.backdrop&&g.target!==s.positioner)){if(xt()||$n(g)){de();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=L1(this.host.mobile());for(let o of I1(e)){let s=document.createElement("div");s.style.cssText="display:contents;";let a=null;o.name&&(a=Vt(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(d=>d.when)&&n.push({el:c,visible:d=>ib(l,d)});}if(a&&o.rows.every(l=>l.every(c=>c.when))){let l=o.rows;n.push({el:a,visible:c=>l.some(d=>ib(d,c))});}i.appendChild(s);}return i}close(){document.removeEventListener("keydown",this.onDialogKey),de(),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,e?.destroy();}revertAndClose(){let e=this.row,t=this.snapshot;if(e&&t)for(let n of e.inputs){let i=t[n.key],o=i!==void 0?i:n.defval;e.values[n.key]!==o&&(e.values[n.key]=o,this.host.onChange?.({indicatorId:e.id,key:n.key,value:o}));}this.close();}commit(e,t,n){e.values[t]=n,this.host.onChange?.({indicatorId:e.id,key:t,value:n}),this.refreshVisibility?.();}buildInputRow(e,t,n){let i=d=>`vela-inp-${n.id}-${d.key}`,o=d=>(e.appendChild(d),d);if(t.length>1)return o(he({label:"",inline:t.map(d=>({label:rl(d)||void 0,id:i(d),control:this.buildControl(n,d,i(d)),toggleFirst:d.type==="bool",fit:d.type==="color"||d.type==="bool"})),info:[...t].reverse().find(d=>d.tooltip)?.tooltip?this.infoButton([...t].reverse().find(d=>d.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 d=!!(n.values[s.key]??s.defval);return o(he({label:rl(s),id:a,bool:true,info:l,toggle:{id:a,checked:d,onChange:u=>this.commit(n,s.key,u)}}))}if(s.type==="text_area")return o(he({label:rl(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(he({label:rl(s),id:a,fit:c,controlWidth:c?void 0:100,info:l,control:this.buildControl(n,s,a)}))}buildControl(e,t,n){let i=e.values[t.key]??t.defval,o=s=>this.commit(e,t.key,s);return t.type==="bool"?q({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,P1,String(i),o):t.type==="color"?q({kind:"color",id:n,theme:this.host.theme(),get:()=>String(e.values[t.key]??t.defval),onChange:s=>o(s)}).el:t.type==="symbol"?this.buildSymbol(n,String(i),o):t.type==="timeframe"?this.selectPairs(n,D1,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"?q({kind:"textarea",id:n,value:String(i),onChange:s=>o(s)}).el:t.type==="int"||t.type==="float"||t.type==="price"?q({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 q({kind:"text",id:e,value:t,onChange:n}).el}infoButton(e){let t=document.createElement("span");return t.textContent="i",this.dialogTips.push(pt(t,{host:this.host.container,theme:()=>this.host.theme(),text:()=>e,wrap:true,delayMs:250})),t.className="vela-ind-hint",t.style.cssText="flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;font-weight:600;font-size:11px;font-family:inherit;line-height:1;cursor:help;user-select:none;",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 q({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]=B1(t),s=document.createElement("div");s.style.cssText="display:flex;align-items:center;gap:6px;";let a=i,l=o,c=()=>n(H1(a,l));return s.append(this.timeCombobox(e,a,86,d=>{a=d,c();}),this.timeCombobox(`${e}-end`,l,86,d=>{l=d,c();})),s}buildTime(e,t,n){let i=z1(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 u=Date.parse(`${s}T${a}:00`);Number.isFinite(u)&&n(u);},c=this.dateField(e,s,u=>{s=u,l();}),d=this.timeCombobox(`${e}-time`,a,86,u=>{a=u,l();});return o.append(c,d),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=R1;let l=t,c=()=>{let p=_1(s.value);if(!p){s.value=l;return}s.value=p,p!==l&&(l=p,i(p));};s.addEventListener("blur",()=>{xt()||c();});let d=p=>{l=p,s.value=p,i(p);},u=()=>{this.choicePop=$a(o,O1,l,d,{...this.listPopover(),onClose:()=>{this.choicePop=null;}});};s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),c(),s.blur()),p.key==="ArrowDown"&&(p.preventDefault(),u());});let h=p=>{p.preventDefault(),p.stopPropagation(),u();};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=A1;let a=t,l=()=>{let u=lb(o.value);if(!u){o.value=a;return}o.value=u,u!==a&&(a=u,n(u));};o.addEventListener("blur",()=>{xt()||l();});let c=u=>{a=u,o.value=u,n(u);};o.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l(),o.blur()),u.key==="ArrowDown"&&(u.preventDefault(),this.openCalendar(i,a,c));});let d=u=>{if(u.preventDefault(),u.stopPropagation(),Ft()===i){de();return}this.openCalendar(i,a,c);};return o.addEventListener("click",d),s.addEventListener("mousedown",u=>u.preventDefault()),s.addEventListener("click",d),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=V1(t),o=i?.getFullYear()??new Date().getFullYear(),s=i?.getMonth()??new Date().getMonth(),a=i?Bd(i):t,l=new Be({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 d=document.createElement("div");d.className="vela-ind-cal-title";let u=document.createElement("button");u.type="button",u.className="vela-ind-cal-nav",u.setAttribute("aria-label","Previous month"),u.innerHTML=me("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=me("chevron-right",14);let p=document.createElement("div");p.className="vela-ind-cal-head",p.append(u,d,h);let m=document.createElement("div");m.className="vela-ind-cal-week";for(let b of N1){let v=document.createElement("span");v.textContent=b,m.appendChild(v);}let f=document.createElement("div");f.className="vela-ind-cal-grid";let g=()=>{d.textContent=`${F1[s]} ${o}`,f.replaceChildren();let v=new Date(o,s,1).getDay(),y=new Date(o,s+1,0).getDate(),w=Bd(new Date);for(let P=0;P<v;P++){let x=document.createElement("span");x.className="vela-ind-cal-blank",f.appendChild(x);}for(let P=1;P<=y;P++){let x=`${o}-${String(s+1).padStart(2,"0")}-${String(P).padStart(2,"0")}`,S=document.createElement("button");S.type="button",S.className="vela-ind-cal-day",S.textContent=String(P),x===a&&(S.dataset.checked="1"),x===w&&(S.dataset.today="1"),S.addEventListener("click",E=>{E.stopPropagation(),l.hide(),n(x);}),f.appendChild(S);}};u.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 _e(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 rl(r){let e=r.title;return e.length>0?e.charAt(0).toUpperCase()+e.slice(1):""}var rb=16;function L1(r){return `padding:16px 20px;overflow-y:auto;overflow-x:hidden;overflow-anchor:none;flex:1 1 auto;display:grid;grid-template-columns:${no("inputs",r)};align-items:center;align-content:start;column-gap:${rb}px;row-gap:${rb}px;`}var il="Inputs";function M1(r){let e=new Map;for(let n of r){let i=n.tab&&n.tab.length>0?n.tab:il;e.has(i)||e.set(i,[]),e.get(i).push(n);}let t=[...e.keys()];return t.includes(il)&&(t.splice(t.indexOf(il),1),t.unshift(il)),t.map(n=>({name:n,inputs:e.get(n)}))}function ib(r,e){return r.some(t=>qi(t.when,e))}function k1(r){let e={};for(let t of r.inputs)e[t.key]=r.values[t.key]??t.defval;return e}function I1(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 A1=me("calendar",14),R1=me("clock",14),ob="vela-ind-dialog-styles",sb="29",ab=16;function sl(){if(typeof document>"u")return;let r=document.getElementById(ob);if(r?.dataset.rev===sb)return;let e=r??document.createElement("style");e.id=ob,e.dataset.rev=sb,e.textContent=`
|
|
679
|
+
.vela-ind-combo input{${dm}}
|
|
680
680
|
.vela-ind-combo input:hover{border-color:var(--vela-fg-muted);}
|
|
681
|
-
.vela-ind-combo input:focus{${
|
|
681
|
+
.vela-ind-combo input:focus{${um}}
|
|
682
682
|
.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;}
|
|
683
683
|
.vela-ind-combo-chevron:hover{opacity:0.9;}
|
|
684
684
|
.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;}
|
|
@@ -700,20 +700,20 @@ ${On(".vela-dialog.vela-ind-dialog *",9)}
|
|
|
700
700
|
.vela-ind-hint{background:var(--vela-hover);color:var(--vela-fg-muted);transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease;}
|
|
701
701
|
.vela-ind-hint:hover{background:var(--vela-active);color:var(--vela-fg-bright);}
|
|
702
702
|
.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;}
|
|
703
|
-
.vela-ind-ctl svg,.vela-ind-close svg{width:${
|
|
703
|
+
.vela-ind-ctl svg,.vela-ind-close svg{width:${ab}px;height:${ab}px;display:block;flex:none;stroke-width:1;}
|
|
704
704
|
.vela-ind-ctl:hover{background-color:var(--vela-hover-strong);}
|
|
705
705
|
.vela-ind-close:hover{color:var(--vela-danger) !important;background-color:var(--vela-hover-strong);}
|
|
706
706
|
.vela-ind-fold{transition:border-color var(--vela-dur-fast) ease,opacity var(--vela-dur-fast) ease;}
|
|
707
|
-
.vela-ind-fold:hover{border-color:var(--vela-border-strong);opacity:0.9;}`,r||document.head.appendChild(e);}var L1=[{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"}],M1=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}}),k1=["January","February","March","April","May","June","July","August","September","October","November","December"],I1=["Su","Mo","Tu","We","Th","Fr","Sa"];function ib(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:Nd(s)}function A1(r){let e=ib(r);if(!e)return null;let[t,n,i]=e.split("-").map(Number);return new Date(t,n-1,i)}function Nd(r){return `${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function R1(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 D1(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 O1(r,e){return `${r.replace(":","")}-${e.replace(":","")}`}function F1(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 N1="@keyframes vela-ind-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.6)}}",_t=16,Vd=18,cb=2,ob=6,V1=6,sb=8,ab=6,no=`cursor:pointer;display:inline-flex;align-items:center;justify-content:center;border:none;line-height:0;padding:0;width:${Vd}px;height:${Vd}px;border-radius:3px;box-sizing:border-box;flex:none;`,_1=Vd+cb*2,lb=me("eye",_t),B1=me("eye-off",_t),H1=me("gear",_t),z1=me("close",_t),$1=me("chevron-up",_t),W1=me("chevron-down",_t),G1=me("objects",_t),ol=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.rowTips=new Map;this.extrasTips=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),il(),this.inputsDialog=new rl({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(ht(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())ve(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=me(n.icon,_t),i.className="vela-ind-ctl",i.dataset.legendAction=n.id,i.style.cssText=no,i.addEventListener("click",o=>{o.stopPropagation(),n.run();}),t.appendChild(i);}}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 u of s)u.id!==o&&a.push({label:`Move to ${u.label}`,target:u.kind==="price"?"price":{pane:u.id}});o!=="price"&&[...this.rows.values()].filter(u=>u.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(u=>u.target),this.moveMenuId=e;let c=a.map((u,h)=>({id:String(h),label:u.label}));this.moveMenu?this.moveMenu.setItems(c):this.moveMenu=new Rr({host:this.container,items:c,placement:"bottom-start",onSelect:u=>{let h=this.moveTargets[Number(u)],p=this.moveMenuId;h&&p&&n.move(p,h);}});let d=t.getBoundingClientRect();this.moveMenu.openAt(d.left,d.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 Rr({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;",ve(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.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?G1:i?W1:$1,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=s.settingsTitle??t,l=this.rows.get(e);if(l){l.title=t,l.settingsTitle=a,l.inputs=n,l.values={...i},l.titleEl.textContent=t,l.paneId!==o&&(l.paneId=o,this.attach(this.legendFor(o),l.el,l.native),this.syncFoldToggle());return}il();let c=document.createElement("div");c.style.cssText=`pointer-events:auto;display:flex;align-items:center;background:${this.idleRowFill()};border-radius:4px;padding:${cb}px ${ob}px;margin-left:-${ob}px;min-height:${_1}px;box-sizing:border-box;color:${this.theme.textColor};user-select:none;-webkit-user-select:none;`,c.addEventListener("mouseleave",()=>{this.selectedId!==e&&this.setRowHighlighted(e,false);}),c.addEventListener("click",v=>{v.button!==0||v.target.closest("button")||this.selectRow(e);}),c.addEventListener("dblclick",v=>{v.target.closest("button")||this.openDialog(e);}),c.addEventListener("mousedown",v=>{v.button===1&&v.preventDefault();}),c.addEventListener("auxclick",v=>{v.button===1&&(v.preventDefault(),this.onRemove?.(e));}),c.addEventListener("contextmenu",v=>{v.preventDefault(),v.stopPropagation(),this.openRowMenu(e,v.clientX,v.clientY);});let d=document.createElement("span");d.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 h=document.createElement("span");if(h.textContent=t,h.style.cssText="font-weight:600;",u.appendChild(h),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);}c.appendChild(u),c.appendChild(d);let p=document.createElement("span");p.style.cssText=`display:none;align-items:center;gap:5px;margin-left:${V1}px;white-space:nowrap;font-variant-numeric:tabular-nums;`,c.appendChild(p);let m=document.createElement("span");m.style.cssText=`display:none;align-items:center;gap:${ab}px;flex:none;margin-left:${ab}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=lb,v.className="vela-ind-ctl",v.style.cssText=no,v.addEventListener("click",()=>{let y=this.rows.get(e);this.onToggleVisible?.(e,!!y?.hidden);}),m.appendChild(v),f=v;}if(n.length>0){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Settings"),this.tip(this.rowTips,e,v,"Settings"),v.innerHTML=H1,v.className="vela-ind-ctl",v.style.cssText=no,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=me("move",_t),v.className="vela-ind-ctl",v.style.cssText=no,v.addEventListener("click",y=>{y.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=z1,b.className="vela-ind-close",b.style.cssText=no,b.addEventListener("click",()=>this.onRemove?.(e)),m.appendChild(b),c.appendChild(m),this.attach(this.legendFor(o),c,!!s.native),this.rows.set(e,{id:e,title:t,settingsTitle:a,inputs:n,values:{...i},el:c,titleEl:h,statusEl:d,valuesEl:p,plotValues:[],plotValuesKey:"",showValues:null,highlighted:false,paneId:o,hidden:false,eyeEl:f,controlsEl:m,extrasEl:g,native:!!s.native}),this.syncFoldToggle();}attach(e,t,n){n?e.prepend(t):e.appendChild(t);}setValues(e,t){let n=this.rows.get(e);n&&(n.values={...n.values,...t});}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:${sb}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:${sb}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=N1,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?lb:B1,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;e.controlsEl.style.display=t||e.hidden?"inline-flex":"none",t?e.el.appendChild(e.statusEl):e.el.insertBefore(e.statusEl,e.valuesEl);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);if(t?.el.remove(),this.rows.delete(e),this.disposeTips(this.rowTips,e),this.disposeTips(this.extrasTips,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.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 W(this.theme.background,.6)}neutralBorder(){return "var(--vela-border)"}};var Fr={up:$("chevron-up"),down:$("chevron-down"),collapse:$("pane-collapse"),expand:$("pane-expand"),maximize:$("maximize"),restore:$("restore")},db="vela-pane-controls",U1=12,ub="rgba(0,0,0,0.28)";function Y1(){if(typeof document>"u"||document.getElementById(db))return;let r=document.createElement("style");r.id=db,r.textContent=`
|
|
708
|
-
.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:${
|
|
707
|
+
.vela-ind-fold:hover{border-color:var(--vela-border-strong);opacity:0.9;}`,r||document.head.appendChild(e);}var D1=[{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"}],O1=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}}),F1=["January","February","March","April","May","June","July","August","September","October","November","December"],N1=["Su","Mo","Tu","We","Th","Fr","Sa"];function lb(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:Bd(s)}function V1(r){let e=lb(r);if(!e)return null;let[t,n,i]=e.split("-").map(Number);return new Date(t,n-1,i)}function Bd(r){return `${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function _1(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 B1(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 H1(r,e){return `${r.replace(":","")}-${e.replace(":","")}`}function z1(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 $1="@keyframes vela-ind-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.6)}}",_t=16,Hd=18,pb=2,cb=6,W1=6,db=8,ub=6,oo=`cursor:pointer;display:inline-flex;align-items:center;justify-content:center;border:none;line-height:0;padding:0;width:${Hd}px;height:${Hd}px;border-radius:3px;box-sizing:border-box;flex:none;`,G1=Hd+pb*2,hb=me("eye",_t),U1=me("eye-off",_t),Y1=me("gear",_t),K1=me("close",_t),X1=me("chevron-up",_t),j1=me("chevron-down",_t),q1=me("objects",_t),al=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.rowTips=new Map;this.extrasTips=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),sl(),this.inputsDialog=new ol({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(pt(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())ve(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=me(n.icon,_t),i.className="vela-ind-ctl",i.dataset.legendAction=n.id,i.style.cssText=oo,i.addEventListener("click",o=>{o.stopPropagation(),n.run();}),t.appendChild(i);}}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 u of s)u.id!==o&&a.push({label:`Move to ${u.label}`,target:u.kind==="price"?"price":{pane:u.id}});o!=="price"&&[...this.rows.values()].filter(u=>u.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(u=>u.target),this.moveMenuId=e;let c=a.map((u,h)=>({id:String(h),label:u.label}));this.moveMenu?this.moveMenu.setItems(c):this.moveMenu=new Rr({host:this.container,items:c,placement:"bottom-start",onSelect:u=>{let h=this.moveTargets[Number(u)],p=this.moveMenuId;h&&p&&n.move(p,h);}});let d=t.getBoundingClientRect();this.moveMenu.openAt(d.left,d.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 Rr({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;",ve(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.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?q1:i?j1:X1,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=s.settingsTitle??t,l=this.rows.get(e);if(l){l.title=t,l.settingsTitle=a,l.inputs=n,l.values={...i},l.titleEl.textContent=t,l.paneId!==o&&(l.paneId=o,this.attach(this.legendFor(o),l.el,l.native),this.syncFoldToggle());return}sl();let c=document.createElement("div");c.style.cssText=`pointer-events:auto;display:flex;align-items:center;background:${this.idleRowFill()};border-radius:4px;padding:${pb}px ${cb}px;margin-left:-${cb}px;min-height:${G1}px;box-sizing:border-box;color:${this.theme.textColor};user-select:none;-webkit-user-select:none;`,c.addEventListener("mouseleave",()=>{this.selectedId!==e&&this.setRowHighlighted(e,false);}),c.addEventListener("click",v=>{v.button!==0||v.target.closest("button")||this.selectRow(e);}),c.addEventListener("dblclick",v=>{v.target.closest("button")||this.openDialog(e);}),c.addEventListener("mousedown",v=>{v.button===1&&v.preventDefault();}),c.addEventListener("auxclick",v=>{v.button===1&&(v.preventDefault(),this.onRemove?.(e));}),c.addEventListener("contextmenu",v=>{v.preventDefault(),v.stopPropagation(),this.openRowMenu(e,v.clientX,v.clientY);});let d=document.createElement("span");d.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 h=document.createElement("span");if(h.textContent=t,h.style.cssText="font-weight:600;",u.appendChild(h),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);}c.appendChild(u),c.appendChild(d);let p=document.createElement("span");p.style.cssText=`display:none;align-items:center;gap:5px;margin-left:${W1}px;white-space:nowrap;font-variant-numeric:tabular-nums;`,c.appendChild(p);let m=document.createElement("span");m.style.cssText=`display:none;align-items:center;gap:${ub}px;flex:none;margin-left:${ub}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=hb,v.className="vela-ind-ctl",v.style.cssText=oo,v.addEventListener("click",()=>{let y=this.rows.get(e);this.onToggleVisible?.(e,!!y?.hidden);}),m.appendChild(v),f=v;}if(n.length>0){let v=document.createElement("button");v.type="button",v.setAttribute("aria-label","Settings"),this.tip(this.rowTips,e,v,"Settings"),v.innerHTML=Y1,v.className="vela-ind-ctl",v.style.cssText=oo,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=me("move",_t),v.className="vela-ind-ctl",v.style.cssText=oo,v.addEventListener("click",y=>{y.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=K1,b.className="vela-ind-close",b.style.cssText=oo,b.addEventListener("click",()=>this.onRemove?.(e)),m.appendChild(b),c.appendChild(m),this.attach(this.legendFor(o),c,!!s.native),this.rows.set(e,{id:e,title:t,settingsTitle:a,inputs:n,values:{...i},el:c,titleEl:h,statusEl:d,valuesEl:p,plotValues:[],plotValuesKey:"",showValues:null,highlighted:false,paneId:o,hidden:false,eyeEl:f,controlsEl:m,extrasEl:g,native:!!s.native}),this.syncFoldToggle();}attach(e,t,n){n?e.prepend(t):e.appendChild(t);}setValues(e,t){let n=this.rows.get(e);n&&(n.values={...n.values,...t});}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:${db}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:${db}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=$1,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?hb:U1,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;e.controlsEl.style.display=t||e.hidden?"inline-flex":"none",t?e.el.appendChild(e.statusEl):e.el.insertBefore(e.statusEl,e.valuesEl);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);if(t?.el.remove(),this.rows.delete(e),this.disposeTips(this.rowTips,e),this.disposeTips(this.extrasTips,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.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 W(this.theme.background,.6)}neutralBorder(){return "var(--vela-border)"}};var Fr={up:$("chevron-up"),down:$("chevron-down"),collapse:$("pane-collapse"),expand:$("pane-expand"),maximize:$("maximize"),restore:$("restore")},mb="vela-pane-controls",Z1=12,fb="rgba(0,0,0,0.28)";function J1(){if(typeof document>"u"||document.getElementById(mb))return;let r=document.createElement("style");r.id=mb,r.textContent=`
|
|
708
|
+
.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:${Z1}px;color:var(--vela-fg-muted);}
|
|
709
709
|
.vela-pc-btn svg{display:block;}
|
|
710
710
|
.vela-pc-btn:not(:disabled):hover{opacity:1 !important;background:var(--vela-active);color:var(--vela-fg-bright);}
|
|
711
711
|
.vela-pc-on,.vela-pc-on:not(:disabled):hover{background:var(--vela-selected-bg);color:var(--vela-selected-fg);}
|
|
712
|
-
`,document.head.appendChild(r);}var
|
|
712
|
+
`,document.head.appendChild(r);}var ll=class{constructor(e,t,n){this.plot=e;this.theme=t;this.deps=n;this.clusters=new Map;this.hoverPaneId=null;this.onPlotMove=e=>{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);J1(),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:fb,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(Fr.up,"Move pane up",t.index<=1,()=>this.deps.onMove(t.id,"up"),{role:"up"})),e.appendChild(this.button(Fr.down,"Move pane down",t.index>=t.count-1,()=>this.deps.onMove(t.id,"down"),{role:"down"})),e.appendChild(this.button(t.collapsed?Fr.expand:Fr.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?Fr.restore:Fr.maximize,t.maximized?"Restore pane":"Maximize pane",false,()=>this.deps.onToggleMaximize(t.id),{role:"maximize"}));}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,l=i.children.length>0&&(s||o.collapsed)&&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=l?"flex":"none",!l)continue;let c=o.collapsed&&!s;i.style.background=c?"transparent":fb;for(let d of i.children){let u=d;u.style.display="inline-flex",u.style.visibility=c&&u.dataset.role!=="collapse"?"hidden":"visible";}}}setHoverPane(e){this.hoverPaneId!==e&&(this.hoverPaneId=e,this.reposition());}destroy(){this.plot.removeEventListener("pointermove",this.onPlotMove),this.plot.removeEventListener("pointerleave",this.onPlotLeave),this.root.remove(),this.clusters.clear();}};function gb(r,e){return e===0?r:r+64+(e-1)*56}var bb="vela-axis-scale-buttons",zd=18,Q1=4,eT=1,tT=64-eT,yb=8,wb=6,nT=zd+yb+wb,vb=48;function rT(){if(typeof document>"u"||document.getElementById(bb))return;let r=document.createElement("style");r.id=bb,r.textContent=`
|
|
713
713
|
.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);}
|
|
714
714
|
.vela-axis-btn:hover{background:var(--vela-active);color:var(--vela-fg-bright);}
|
|
715
715
|
.vela-axis-on,.vela-axis-on:hover{background:var(--vela-selected-bg);color:var(--vela-selected-fg);}
|
|
716
|
-
`,document.head.appendChild(r);}var al=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<mb)&&s>=a.top&&s<=a.top+a.height){o=a.id;break}}this.setHoverPane(o),o&&this.sync();};this.onPlotLeave=()=>this.setHoverPane(null);Z1(),this.cluster=document.createElement("div"),Object.assign(this.cluster.style,{position:"absolute",display:"none",justifyContent:"center",alignItems:"center",gap:`${K1}px`,padding:`${fb}px 0 ${gb}px`,width:`${j1}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:`${_d}px`,height:`${_d}px`}),this.tipDisposers.push(ht(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<mb){this.cluster.style.display="none";return}this.cluster.style.right=`${this.deps.rightAxis()-64}px`,this.cluster.style.top=`${e.top+e.height-q1}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 J1={auto:13,tiny:10,small:11,normal:13,large:16,huge:20},ll=class{constructor(e,t,n){this.container=e;this.theme=t;this.paneBounds=n;this.lastTables=[];getComputedStyle(e).position==="static"&&(e.style.position="relative"),this.root=document.createElement("div"),Object.assign(this.root.style,{position:"absolute",inset:"0",pointerEvents:"none",overflow:"hidden",zIndex:"3"}),e.appendChild(this.root);}update(e){this.lastTables=e,this.root.replaceChildren();for(let t of e)this.root.appendChild(this.renderTable(t));}reposition(){this.root.isConnected&&this.update(this.lastTables);}setVisible(e){this.root.style.display=e?"":"none";}destroy(){this.root.remove();}renderTable(e){let t=document.createElement("div");t.style.position="absolute",this.anchor(t,e.position,this.paneBounds(e.paneId));let n=document.createElement("table");Object.assign(n.style,{borderCollapse:"collapse",background:e.bgColor??"transparent",fontFamily:this.theme.fontFamily||"sans-serif",boxShadow:e.frameColor&&e.frameWidth>0?`inset 0 0 0 ${e.frameWidth}px ${e.frameColor}`:"none",border:"none",tableLayout:"auto",pointerEvents:"auto"});let i=new Map,o=new Set;for(let a of e.merges){i.set(`${a.startRow}:${a.startCol}`,{cs:a.endCol-a.startCol+1,rs:a.endRow-a.startRow+1});for(let l=a.startRow;l<=a.endRow;l+=1)for(let c=a.startCol;c<=a.endCol;c+=1)(l!==a.startRow||c!==a.startCol)&&o.add(`${l}:${c}`);}let s=e.borderColor&&e.borderWidth>0?`${e.borderWidth}px solid ${e.borderColor}`:"none";for(let a=0;a<e.rows;a+=1){let l=document.createElement("tr");for(let c=0;c<e.columns;c+=1){let d=e.cells[a]?.[c]??null;if(o.has(`${a}:${c}`)||d?.merged)continue;let u=document.createElement("td"),h=i.get(`${a}:${c}`);h&&(h.cs>1&&(u.colSpan=h.cs),h.rs>1&&(u.rowSpan=h.rs)),Object.assign(u.style,{border:s,padding:"2px 6px",background:d?.bgColor??"transparent",color:d?.textColor??this.theme.textColor,textAlign:d?.hAlign??"center",verticalAlign:d?.vAlign==="top"?"top":d?.vAlign==="bottom"?"bottom":"middle",fontSize:`${J1[d?.textSize??"normal"]}px`,fontFamily:d?.fontFamily==="monospace"?"monospace":"inherit",fontWeight:d?.bold?"bold":"normal",fontStyle:d?.italic?"italic":"normal",whiteSpace:"pre-line"}),d?.tooltip&&(u.title=d.tooltip),u.textContent=d?.text??"",l.appendChild(u);}n.appendChild(l);}return t.appendChild(n),t}anchor(e,t,n){let o=this.root.clientHeight||this.container.clientHeight,s=n.top+n.height;t.startsWith("top")?e.style.top=`${n.top+6}px`:t.startsWith("bottom")?e.style.bottom=`${Math.max(0,o-s)+6}px`:e.style.top=`${n.top+n.height/2}px`,t.endsWith("left")?e.style.left="6px":t.endsWith("right")?e.style.right=`${n.rightAxis+6}px`:e.style.left=`calc(50% - ${n.rightAxis/2}px)`;let a=t.endsWith("center")?"-50%":"0",l=t.startsWith("middle")?"-50%":"0";(a!=="0"||l!=="0")&&(e.style.transform=`translate(${a}, ${l})`);}};var bb={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,inputsUI:true},io=null;function vb(){if(io!==null)return io;try{io=!!document.createElement("canvas").getContext("webgl2");}catch{io=false;}return io}function oo(r){let e=Math.max(.5,Math.floor(r*.7)/2);return Math.max(1,Math.min(1.5,e))}function Nr(r){return r<1?"aggregate":r<3?"wick":"full"}function cl(r,e,t,n=1){let i=Math.max(1,Math.round(oo(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}}var Hd=1,Vr=J,_r=X,Bt=.25,Ht=.05,Q1=50,eT=W(hn,.08),tT=W(Te,.08);function yb(){return {chartTypes:{},fontSize:11,gridVert:{visible:true,color:null},gridHorz:{visible:true,color:null},borderColor:null,separatorColor:null,crosshair:{color:oh,width:1,style:"dashed",opacity:.4,labelBackground:Vo},candle:{bodyVisible:true,borderVisible:false,borderUpColor:null,borderDownColor:null,wickVisible:true,wickUpColor:null,wickDownColor:null},bars:{upColor:null,downColor:null},line:{color:Qr,width:2},area:{lineColor:Qr,width:2,topColor:W(Qr,.28),bottomColor:W(Qr,.02)},baseline:{topLineColor:null,bottomLineColor:null,topFillColor:null,topFillColor2:null,bottomFillColor:null,bottomFillColor2:null,width:2,baselineLevel:Q1},sessions:{premarketColor:eT,postmarketColor:tT}}}var nT=["solid","dashed","dotted"],wb=["candles","bars","line","area","baseline","heikinashi"];function zd(r){for(let e of Je())if(e.id===r)return e.basePainting??"candles";return "candles"}function so(r){if(wb.includes(r))return false;for(let e of Je())if(e.id===r)return (e.basePainting??"candles")==="candles";return false}function dl(r,e){if(!so(r))return null;let t=e[r]??{},n=o=>K(o)?o:null,i=o=>Ie(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 ul(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 Br(){let r=[...wb];for(let e of Je())r.includes(e.id)||r.push(e.id);return r}function K(r){return typeof r=="string"&&r.trim().length>0}function Ie(r){return typeof r=="boolean"}function it(r){return typeof r=="number"&&Number.isFinite(r)}function rT(r){return typeof r=="string"&&nT.includes(r)}function iT(r){return typeof r=="string"&&Br().includes(r)}function oT(r){return r==="price"||r==="percent"||r==="indexed"}function pe(r){return r&&typeof r=="object"?r:{}}function sT(r){return r<0?0:r>1?1:r}function Bd(r){return r<1?1:r>10?10:r}function aT(r){return r<0?0:r>100?100:r}function lT(r){return r<.1?.1:r>10?10:r}function xb(r){let e={};for(let t of Je()){let n=t.settings;if(!n)continue;let i={},o=s=>{for(let a of s??[])for(let l of pi(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 Sb(r,e){let t=pe(e),n=pe(t.chartTypes),i={...r.chartTypes};for(let[S,E]of Object.entries(n))i[S]={...i[S]??{},...pe(E)};let o=pe(t.layout),s=pe(t.grid),a=pe(s.vertLines),l=pe(s.horzLines),c=pe(t.crosshair),d=pe(t.priceScale),u=pe(t.panes),h=pe(t.trades),p=pe(t.timeScale),m=pe(t.candles),f=pe(t.bars),g=pe(t.line),b=pe(t.area),v=pe(t.baseline),y=pe(t.series),w=pe(t.sessions),P=pe(t.stacking),x=pe(P.series);return {version:Hd,chartTypes:i,layout:{background:K(o.background)?o.background:r.layout.background,textColor:K(o.textColor)?o.textColor:r.layout.textColor,fontFamily:K(o.fontFamily)?o.fontFamily:r.layout.fontFamily,fontSize:it(o.fontSize)?Math.max(6,Math.min(32,o.fontSize)):r.layout.fontSize},grid:{vertLines:{visible:Ie(a.visible)?a.visible:r.grid.vertLines.visible,color:K(a.color)?a.color:r.grid.vertLines.color},horzLines:{visible:Ie(l.visible)?l.visible:r.grid.horzLines.visible,color:K(l.color)?l.color:r.grid.horzLines.color}},crosshair:{color:K(c.color)?c.color:r.crosshair.color,width:it(c.width)?Math.max(.5,Math.min(8,c.width)):r.crosshair.width,style:rT(c.style)?c.style:r.crosshair.style,opacity:it(c.opacity)?sT(c.opacity):r.crosshair.opacity,labelBackground:K(c.labelBackground)?c.labelBackground:r.crosshair.labelBackground},priceScale:{mode:oT(d.mode)?d.mode:r.priceScale.mode,log:Ie(d.log)?d.log:r.priceScale.log,invert:Ie(d.invert)?d.invert:r.priceScale.invert,borderColor:K(d.borderColor)?d.borderColor:r.priceScale.borderColor,labelsVisible:Ie(d.labelsVisible)?d.labelsVisible:r.priceScale.labelsVisible,currentPriceLine:Ie(d.currentPriceLine)?d.currentPriceLine:r.priceScale.currentPriceLine,priceLabel:Ie(d.priceLabel)?d.priceLabel:r.priceScale.priceLabel,countdown:Ie(d.countdown)?d.countdown:r.priceScale.countdown},panes:{separatorColor:K(u.separatorColor)?u.separatorColor:r.panes.separatorColor},trades:{visible:Ie(h.visible)?h.visible:r.trades.visible,labels:Ie(h.labels)?h.labels:r.trades.labels,qty:Ie(h.qty)?h.qty:r.trades.qty,longColor:K(h.longColor)?h.longColor:r.trades.longColor,shortColor:K(h.shortColor)?h.shortColor:r.trades.shortColor,exitColor:K(h.exitColor)?h.exitColor:r.trades.exitColor},timeScale:{timezone:typeof p.timezone=="string"&&p.timezone?p.timezone:r.timeScale.timezone},candles:{upColor:K(m.upColor)?m.upColor:r.candles.upColor,downColor:K(m.downColor)?m.downColor:r.candles.downColor,bodyVisible:Ie(m.bodyVisible)?m.bodyVisible:r.candles.bodyVisible,borderVisible:Ie(m.borderVisible)?m.borderVisible:r.candles.borderVisible,borderUpColor:K(m.borderUpColor)?m.borderUpColor:r.candles.borderUpColor,borderDownColor:K(m.borderDownColor)?m.borderDownColor:r.candles.borderDownColor,wickVisible:Ie(m.wickVisible)?m.wickVisible:r.candles.wickVisible,wickUpColor:K(m.wickUpColor)?m.wickUpColor:r.candles.wickUpColor,wickDownColor:K(m.wickDownColor)?m.wickDownColor:r.candles.wickDownColor},bars:{upColor:K(f.upColor)?f.upColor:r.bars.upColor,downColor:K(f.downColor)?f.downColor:r.bars.downColor},line:{color:K(g.color)?g.color:r.line.color,width:it(g.width)?Bd(g.width):r.line.width},area:{lineColor:K(b.lineColor)?b.lineColor:r.area.lineColor,width:it(b.width)?Bd(b.width):r.area.width,topColor:K(b.topColor)?b.topColor:r.area.topColor,bottomColor:K(b.bottomColor)?b.bottomColor:r.area.bottomColor},baseline:{topLineColor:K(v.topLineColor)?v.topLineColor:r.baseline.topLineColor,bottomLineColor:K(v.bottomLineColor)?v.bottomLineColor:r.baseline.bottomLineColor,topFillColor:K(v.topFillColor)?v.topFillColor:r.baseline.topFillColor,topFillColor2:K(v.topFillColor2)?v.topFillColor2:r.baseline.topFillColor2,bottomFillColor:K(v.bottomFillColor)?v.bottomFillColor:r.baseline.bottomFillColor,bottomFillColor2:K(v.bottomFillColor2)?v.bottomFillColor2:r.baseline.bottomFillColor2,width:it(v.width)?Bd(v.width):r.baseline.width,baselineLevel:it(v.baselineLevel)?aT(v.baselineLevel):r.baseline.baselineLevel},series:{style:iT(y.style)?y.style:r.series.style,baseline:y.baseline===null?null:it(y.baseline)?y.baseline:r.series.baseline,spacing:it(y.spacing)?lT(y.spacing):r.series.spacing},sessions:{premarketColor:K(w.premarketColor)?w.premarketColor:r.sessions.premarketColor,postmarketColor:K(w.postmarketColor)?w.postmarketColor:r.sessions.postmarketColor},stacking:{candles:it(P.candles)?P.candles:r.stacking.candles,series:{...r.stacking.series,...Object.fromEntries(Object.entries(x).filter(([,S])=>it(S)))}}}}var ao=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,d,u,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(d,u,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 d=o/2,u=d+1,h=-l/c*u,p=a/c*u,m=e+h,f=t+p,g=n+h,b=i+p,v=n-h,y=i-p,w=e-h,P=t-p;this.ensure(6),this.v(m,f,s,u,d),this.v(g,b,s,u,d),this.v(v,y,s,-u,d),this.v(m,f,s,u,d),this.v(v,y,s,-u,d),this.v(w,P,s,-u,d);}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,d=Math.hypot(l,c);if(d<1e-6)return;let u=l/d,h=c/d,p=a[0]+a[1];if(p<=0){this.seg(e,t,n,i,o,s);return}let m=0;for(;m<d;){let f=Math.min(a[0],d-m),g=m,b=m+f;this.seg(e+u*g,t+h*g,e+u*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,d=e+Math.cos(c)*n,u=t+Math.sin(c)*n;this.tri(e,t,i,s,a,i,d,u,i),s=d,a=u;}}};var Tb=[0,0,0,1],ln=null,cT=8192,Hr=new Map,Cb=new Map;function G(r){if(!r)return Tb;let e=Hr.get(r);return e||(e=Cb.get(r),e?(Hr.set(r,e),e):(e=dT(r),Hr.set(r,e),Hr.size>=cT&&(Cb=Hr,Hr=new Map),e))}function Eb(r,e="#000000"){let[t,n,i,o]=G(r),s=t,a=n,l=i;if(o<1){let[h,p,m]=G(e);s=t*o+h*(1-o),a=n*o+p*(1-o),l=i*o+m*(1-o);}let c=.2126*$d(s)+.7152*$d(a)+.0722*$d(l),d=(c+.05)/.05,u=1.05/(c+.05);return d>=u?"#000000":"#ffffff"}function $d(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function dT(r){if(!ln){let t=document.createElement("canvas");t.width=1,t.height=1,ln=t.getContext("2d",{willReadFrequently:true});}if(!ln)return Tb;ln.clearRect(0,0,1,1),ln.fillStyle="#000",ln.fillStyle=r,ln.fillRect(0,0,1,1);let e=ln.getImageData(0,0,1,1).data;return [e[0]/255,e[1]/255,e[2]/255,e[3]/255]}var uT=`#version 300 es
|
|
716
|
+
`,document.head.appendChild(r);}var cl=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<vb)&&s>=a.top&&s<=a.top+a.height){o=a.id;break}}this.setHoverPane(o),o&&this.sync();};this.onPlotLeave=()=>this.setHoverPane(null);rT(),this.cluster=document.createElement("div"),Object.assign(this.cluster.style,{position:"absolute",display:"none",justifyContent:"center",alignItems:"center",gap:`${Q1}px`,padding:`${yb}px 0 ${wb}px`,width:`${tT}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:`${zd}px`,height:`${zd}px`}),this.tipDisposers.push(pt(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<vb){this.cluster.style.display="none";return}this.cluster.style.right=`${this.deps.rightAxis()-64}px`,this.cluster.style.top=`${e.top+e.height-nT}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 iT={auto:13,tiny:10,small:11,normal:13,large:16,huge:20},dl=class{constructor(e,t,n){this.container=e;this.theme=t;this.paneBounds=n;this.lastTables=[];getComputedStyle(e).position==="static"&&(e.style.position="relative"),this.root=document.createElement("div"),Object.assign(this.root.style,{position:"absolute",inset:"0",pointerEvents:"none",overflow:"hidden",zIndex:"3"}),e.appendChild(this.root);}update(e){this.lastTables=e,this.root.replaceChildren();for(let t of e)this.root.appendChild(this.renderTable(t));}reposition(){this.root.isConnected&&this.update(this.lastTables);}setVisible(e){this.root.style.display=e?"":"none";}destroy(){this.root.remove();}renderTable(e){let t=document.createElement("div");t.style.position="absolute",this.anchor(t,e.position,this.paneBounds(e.paneId));let n=document.createElement("table");Object.assign(n.style,{borderCollapse:"collapse",background:e.bgColor??"transparent",fontFamily:this.theme.fontFamily||"sans-serif",boxShadow:e.frameColor&&e.frameWidth>0?`inset 0 0 0 ${e.frameWidth}px ${e.frameColor}`:"none",border:"none",tableLayout:"auto",pointerEvents:"auto"});let i=new Map,o=new Set;for(let a of e.merges){i.set(`${a.startRow}:${a.startCol}`,{cs:a.endCol-a.startCol+1,rs:a.endRow-a.startRow+1});for(let l=a.startRow;l<=a.endRow;l+=1)for(let c=a.startCol;c<=a.endCol;c+=1)(l!==a.startRow||c!==a.startCol)&&o.add(`${l}:${c}`);}let s=e.borderColor&&e.borderWidth>0?`${e.borderWidth}px solid ${e.borderColor}`:"none";for(let a=0;a<e.rows;a+=1){let l=document.createElement("tr");for(let c=0;c<e.columns;c+=1){let d=e.cells[a]?.[c]??null;if(o.has(`${a}:${c}`)||d?.merged)continue;let u=document.createElement("td"),h=i.get(`${a}:${c}`);h&&(h.cs>1&&(u.colSpan=h.cs),h.rs>1&&(u.rowSpan=h.rs)),Object.assign(u.style,{border:s,padding:"2px 6px",background:d?.bgColor??"transparent",color:d?.textColor??this.theme.textColor,textAlign:d?.hAlign??"center",verticalAlign:d?.vAlign==="top"?"top":d?.vAlign==="bottom"?"bottom":"middle",fontSize:`${iT[d?.textSize??"normal"]}px`,fontFamily:d?.fontFamily==="monospace"?"monospace":"inherit",fontWeight:d?.bold?"bold":"normal",fontStyle:d?.italic?"italic":"normal",whiteSpace:"pre-line"}),d?.tooltip&&(u.title=d.tooltip),u.textContent=d?.text??"",l.appendChild(u);}n.appendChild(l);}return t.appendChild(n),t}anchor(e,t,n){let o=this.root.clientHeight||this.container.clientHeight,s=n.top+n.height;t.startsWith("top")?e.style.top=`${n.top+6}px`:t.startsWith("bottom")?e.style.bottom=`${Math.max(0,o-s)+6}px`:e.style.top=`${n.top+n.height/2}px`,t.endsWith("left")?e.style.left="6px":t.endsWith("right")?e.style.right=`${n.rightAxis+6}px`:e.style.left=`calc(50% - ${n.rightAxis/2}px)`;let a=t.endsWith("center")?"-50%":"0",l=t.startsWith("middle")?"-50%":"0";(a!=="0"||l!=="0")&&(e.style.transform=`translate(${a}, ${l})`);}};var xb={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,inputsUI:true},ao=null;function Sb(){if(ao!==null)return ao;try{ao=!!document.createElement("canvas").getContext("webgl2");}catch{ao=false;}return ao}function lo(r){let e=Math.max(.5,Math.floor(r*.7)/2);return Math.max(1,Math.min(1.5,e))}function Nr(r){return r<1?"aggregate":r<3?"wick":"full"}function ul(r,e,t,n=1){let i=Math.max(1,Math.round(lo(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}}var Wd=1,Vr=J,_r=X,Bt=.25,Ht=.05,oT=50,sT=W(pn,.08),aT=W(Te,.08);function Cb(){return {chartTypes:{},fontSize:11,gridVert:{visible:true,color:null},gridHorz:{visible:true,color:null},borderColor:null,separatorColor:null,crosshair:{color:ch,width:1,style:"dashed",opacity:.4,labelBackground:Bo},candle:{bodyVisible:true,borderVisible:false,borderUpColor:null,borderDownColor:null,wickVisible:true,wickUpColor:null,wickDownColor:null},bars:{upColor:null,downColor:null},line:{color:ni,width:2},area:{lineColor:ni,width:2,topColor:W(ni,.28),bottomColor:W(ni,.02)},baseline:{topLineColor:null,bottomLineColor:null,topFillColor:null,topFillColor2:null,bottomFillColor:null,bottomFillColor2:null,width:2,baselineLevel:oT},sessions:{premarketColor:sT,postmarketColor:aT}}}var lT=["solid","dashed","dotted"],Tb=["candles","bars","line","area","baseline","heikinashi"];function Gd(r){for(let e of Je())if(e.id===r)return e.basePainting??"candles";return "candles"}function co(r){if(Tb.includes(r))return false;for(let e of Je())if(e.id===r)return (e.basePainting??"candles")==="candles";return false}function hl(r,e){if(!co(r))return null;let t=e[r]??{},n=o=>K(o)?o:null,i=o=>Ie(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 pl(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 Br(){let r=[...Tb];for(let e of Je())r.includes(e.id)||r.push(e.id);return r}function K(r){return typeof r=="string"&&r.trim().length>0}function Ie(r){return typeof r=="boolean"}function it(r){return typeof r=="number"&&Number.isFinite(r)}function cT(r){return typeof r=="string"&&lT.includes(r)}function dT(r){return typeof r=="string"&&Br().includes(r)}function uT(r){return r==="price"||r==="percent"||r==="indexed"}function pe(r){return r&&typeof r=="object"?r:{}}function hT(r){return r<0?0:r>1?1:r}function $d(r){return r<1?1:r>10?10:r}function pT(r){return r<0?0:r>100?100:r}function mT(r){return r<.1?.1:r>10?10:r}function Eb(r){let e={};for(let t of Je()){let n=t.settings;if(!n)continue;let i={},o=s=>{for(let a of s??[])for(let l of gi(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 Pb(r,e){let t=pe(e),n=pe(t.chartTypes),i={...r.chartTypes};for(let[S,E]of Object.entries(n))i[S]={...i[S]??{},...pe(E)};let o=pe(t.layout),s=pe(t.grid),a=pe(s.vertLines),l=pe(s.horzLines),c=pe(t.crosshair),d=pe(t.priceScale),u=pe(t.panes),h=pe(t.trades),p=pe(t.timeScale),m=pe(t.candles),f=pe(t.bars),g=pe(t.line),b=pe(t.area),v=pe(t.baseline),y=pe(t.series),w=pe(t.sessions),P=pe(t.stacking),x=pe(P.series);return {version:Wd,chartTypes:i,layout:{background:K(o.background)?o.background:r.layout.background,textColor:K(o.textColor)?o.textColor:r.layout.textColor,fontFamily:K(o.fontFamily)?o.fontFamily:r.layout.fontFamily,fontSize:it(o.fontSize)?Math.max(6,Math.min(32,o.fontSize)):r.layout.fontSize},grid:{vertLines:{visible:Ie(a.visible)?a.visible:r.grid.vertLines.visible,color:K(a.color)?a.color:r.grid.vertLines.color},horzLines:{visible:Ie(l.visible)?l.visible:r.grid.horzLines.visible,color:K(l.color)?l.color:r.grid.horzLines.color}},crosshair:{color:K(c.color)?c.color:r.crosshair.color,width:it(c.width)?Math.max(.5,Math.min(8,c.width)):r.crosshair.width,style:cT(c.style)?c.style:r.crosshair.style,opacity:it(c.opacity)?hT(c.opacity):r.crosshair.opacity,labelBackground:K(c.labelBackground)?c.labelBackground:r.crosshair.labelBackground},priceScale:{mode:uT(d.mode)?d.mode:r.priceScale.mode,log:Ie(d.log)?d.log:r.priceScale.log,invert:Ie(d.invert)?d.invert:r.priceScale.invert,borderColor:K(d.borderColor)?d.borderColor:r.priceScale.borderColor,labelsVisible:Ie(d.labelsVisible)?d.labelsVisible:r.priceScale.labelsVisible,currentPriceLine:Ie(d.currentPriceLine)?d.currentPriceLine:r.priceScale.currentPriceLine,priceLabel:Ie(d.priceLabel)?d.priceLabel:r.priceScale.priceLabel,countdown:Ie(d.countdown)?d.countdown:r.priceScale.countdown},panes:{separatorColor:K(u.separatorColor)?u.separatorColor:r.panes.separatorColor},trades:{visible:Ie(h.visible)?h.visible:r.trades.visible,labels:Ie(h.labels)?h.labels:r.trades.labels,qty:Ie(h.qty)?h.qty:r.trades.qty,longColor:K(h.longColor)?h.longColor:r.trades.longColor,shortColor:K(h.shortColor)?h.shortColor:r.trades.shortColor,exitColor:K(h.exitColor)?h.exitColor:r.trades.exitColor},timeScale:{timezone:typeof p.timezone=="string"&&p.timezone?p.timezone:r.timeScale.timezone},candles:{upColor:K(m.upColor)?m.upColor:r.candles.upColor,downColor:K(m.downColor)?m.downColor:r.candles.downColor,bodyVisible:Ie(m.bodyVisible)?m.bodyVisible:r.candles.bodyVisible,borderVisible:Ie(m.borderVisible)?m.borderVisible:r.candles.borderVisible,borderUpColor:K(m.borderUpColor)?m.borderUpColor:r.candles.borderUpColor,borderDownColor:K(m.borderDownColor)?m.borderDownColor:r.candles.borderDownColor,wickVisible:Ie(m.wickVisible)?m.wickVisible:r.candles.wickVisible,wickUpColor:K(m.wickUpColor)?m.wickUpColor:r.candles.wickUpColor,wickDownColor:K(m.wickDownColor)?m.wickDownColor:r.candles.wickDownColor},bars:{upColor:K(f.upColor)?f.upColor:r.bars.upColor,downColor:K(f.downColor)?f.downColor:r.bars.downColor},line:{color:K(g.color)?g.color:r.line.color,width:it(g.width)?$d(g.width):r.line.width},area:{lineColor:K(b.lineColor)?b.lineColor:r.area.lineColor,width:it(b.width)?$d(b.width):r.area.width,topColor:K(b.topColor)?b.topColor:r.area.topColor,bottomColor:K(b.bottomColor)?b.bottomColor:r.area.bottomColor},baseline:{topLineColor:K(v.topLineColor)?v.topLineColor:r.baseline.topLineColor,bottomLineColor:K(v.bottomLineColor)?v.bottomLineColor:r.baseline.bottomLineColor,topFillColor:K(v.topFillColor)?v.topFillColor:r.baseline.topFillColor,topFillColor2:K(v.topFillColor2)?v.topFillColor2:r.baseline.topFillColor2,bottomFillColor:K(v.bottomFillColor)?v.bottomFillColor:r.baseline.bottomFillColor,bottomFillColor2:K(v.bottomFillColor2)?v.bottomFillColor2:r.baseline.bottomFillColor2,width:it(v.width)?$d(v.width):r.baseline.width,baselineLevel:it(v.baselineLevel)?pT(v.baselineLevel):r.baseline.baselineLevel},series:{style:dT(y.style)?y.style:r.series.style,baseline:y.baseline===null?null:it(y.baseline)?y.baseline:r.series.baseline,spacing:it(y.spacing)?mT(y.spacing):r.series.spacing},sessions:{premarketColor:K(w.premarketColor)?w.premarketColor:r.sessions.premarketColor,postmarketColor:K(w.postmarketColor)?w.postmarketColor:r.sessions.postmarketColor},stacking:{candles:it(P.candles)?P.candles:r.stacking.candles,series:{...r.stacking.series,...Object.fromEntries(Object.entries(x).filter(([,S])=>it(S)))}}}}var uo=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,d,u,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(d,u,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 d=o/2,u=d+1,h=-l/c*u,p=a/c*u,m=e+h,f=t+p,g=n+h,b=i+p,v=n-h,y=i-p,w=e-h,P=t-p;this.ensure(6),this.v(m,f,s,u,d),this.v(g,b,s,u,d),this.v(v,y,s,-u,d),this.v(m,f,s,u,d),this.v(v,y,s,-u,d),this.v(w,P,s,-u,d);}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,d=Math.hypot(l,c);if(d<1e-6)return;let u=l/d,h=c/d,p=a[0]+a[1];if(p<=0){this.seg(e,t,n,i,o,s);return}let m=0;for(;m<d;){let f=Math.min(a[0],d-m),g=m,b=m+f;this.seg(e+u*g,t+h*g,e+u*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,d=e+Math.cos(c)*n,u=t+Math.sin(c)*n;this.tri(e,t,i,s,a,i,d,u,i),s=d,a=u;}}};var Mb=[0,0,0,1],cn=null,fT=8192,Hr=new Map,Lb=new Map;function G(r){if(!r)return Mb;let e=Hr.get(r);return e||(e=Lb.get(r),e?(Hr.set(r,e),e):(e=gT(r),Hr.set(r,e),Hr.size>=fT&&(Lb=Hr,Hr=new Map),e))}function kb(r,e="#000000"){let[t,n,i,o]=G(r),s=t,a=n,l=i;if(o<1){let[h,p,m]=G(e);s=t*o+h*(1-o),a=n*o+p*(1-o),l=i*o+m*(1-o);}let c=.2126*Ud(s)+.7152*Ud(a)+.0722*Ud(l),d=(c+.05)/.05,u=1.05/(c+.05);return d>=u?"#000000":"#ffffff"}function Ud(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function gT(r){if(!cn){let t=document.createElement("canvas");t.width=1,t.height=1,cn=t.getContext("2d",{willReadFrequently:true});}if(!cn)return Mb;cn.clearRect(0,0,1,1),cn.fillStyle="#000",cn.fillStyle=r,cn.fillRect(0,0,1,1);let e=cn.getImageData(0,0,1,1).data;return [e[0]/255,e[1]/255,e[2]/255,e[3]/255]}var bT=`#version 300 es
|
|
717
717
|
layout(location=0) in vec2 aPos;
|
|
718
718
|
layout(location=1) in vec4 aColor;
|
|
719
719
|
layout(location=2) in vec2 aEdge; // (signed perpendicular distance from line center, half-width)
|
|
@@ -725,7 +725,7 @@ void main() {
|
|
|
725
725
|
gl_Position = vec4(clip, 0.0, 1.0);
|
|
726
726
|
vColor = aColor;
|
|
727
727
|
vEdge = aEdge;
|
|
728
|
-
}`,
|
|
728
|
+
}`,vT=`#version 300 es
|
|
729
729
|
precision highp float;
|
|
730
730
|
in vec4 vColor;
|
|
731
731
|
in vec2 vEdge;
|
|
@@ -735,13 +735,13 @@ void main() {
|
|
|
735
735
|
float aa = fwidth(vEdge.x);
|
|
736
736
|
float cov = clamp((vEdge.y - abs(vEdge.x)) / max(aa, 1e-4) + 0.5, 0.0, 1.0);
|
|
737
737
|
frag = vec4(vColor.rgb, vColor.a * cov);
|
|
738
|
-
}`,
|
|
738
|
+
}`,yT=`#version 300 es
|
|
739
739
|
layout(location=0) in vec2 aPos;
|
|
740
740
|
out vec2 vUv;
|
|
741
741
|
void main() {
|
|
742
742
|
vUv = aPos * 0.5 + 0.5;
|
|
743
743
|
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
744
|
-
}`,
|
|
744
|
+
}`,wT=`#version 300 es
|
|
745
745
|
precision mediump float;
|
|
746
746
|
in vec2 vUv;
|
|
747
747
|
uniform sampler2D uTex;
|
|
@@ -761,13 +761,13 @@ void main() {
|
|
|
761
761
|
sum += texture(uTex, vUv + o2) * 0.0702702703;
|
|
762
762
|
sum += texture(uTex, vUv - o2) * 0.0702702703;
|
|
763
763
|
frag = sum;
|
|
764
|
-
}`,Wd={solid:null,dashed:[6,4],dotted:[2,3]};function Pb(r){return Math.max(6,Math.min(20,Math.round(r*4)))}var ml=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 ao;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 ao;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=hl(e,e.VERTEX_SHADER,uT),n=hl(e,e.FRAGMENT_SHADER,hT),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=hl(e,e.VERTEX_SHADER,pT),n=hl(e,e.FRAGMENT_SHADER,mT),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(),d=Math.max(0,Math.floor(c.from)),u=Math.min(l-1,Math.ceil(c.to));if(u<d)return;i.enable(i.BLEND),i.enable(i.SCISSOR_TEST);let h=bT(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),v=Math.round((f.bounds.top+f.bounds.height)*s);i.scissor(0,o.height-v,Math.round(a*s),v-b);let y=()=>{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());},w=f.collapsed?[]:e.drawingSlices.get(f.id)??[],P=0,x=S=>{for(;P<w.length&&w[P].beforeZ<=S;P+=1)y(),this.drawSliceTexture(i,w[P].canvas)&&m.add(w[P].canvas);};if(g.alpha=1,!f.collapsed){let S=e.orderedIndicatorsForPane(f.id),E=f.kind==="price",L=M=>{let C=e.scaleFor(M,f);return C===f.scale?f:{...f,scale:C}};g.alpha=this.modelAlpha;for(let M of S)for(let C of M.backgrounds)this.emitBackground(g,C,f,t);for(let M of S)for(let C of M.fills)this.emitFill(g,M,C,L(M),t,d,u,e.offsetOf(M.id));let T=E&&!e.candlesHidden,k=false;for(let M of S){T&&!k&&e.zOf(M.id)>=e.candleZ&&(x(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,d,u,t,f,n,h,a),k=true),x(e.zOf(M.id)),g.alpha=this.modelAlpha;let C=e.offsetOf(M.id),I=L(M);for(let _ of M.series)this.emitSeries(g,_,I,t,d,u,n,C);}T&&!k&&(x(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,d,u,t,f,n,h,a)),x(1/0),g.alpha=this.modelAlpha;for(let M of S){let C=L(M);for(let I of M.priceLines)this.emitHline(g,I,C,t,a,n);}g.alpha=1;}y();}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,d,u));}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,d=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 u of t.orderedPanes()){let h=this.glowBatch;if(h.reset(),this.emitGlowSources(h,t.indicatorsForPane(u.id),u,n,i,o,f=>t.offsetOf(f)),h.vertexCount===0)continue;let p=Math.round(u.bounds.top*c*.5),m=Math.round((u.bounds.top+u.bounds.height)*c*.5);e.scissor(0,l-m,Math.round(d*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,a=()=>0){for(let l of t){let c=a(l.id);for(let d of l.series)!be(d)||d.visible===false||d.kind==="histogram"||d.kind==="columns"||(d.kind==="circles"||d.kind==="cross"?this.emitPointMarkers(e,d,n,i,o,s,c):this.emitPolyline(e,d,n,i,o,s,d.kind==="step",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,G(t.color));}emitFill(e,t,n,i,o,s,a,l=0){let c=Mb(t,n.fromSeriesId),d=Mb(t,n.toSeriesId);if(!(!c||!d))for(let u=Math.max(1,s);u<=a;u+=1){let h=c[u-1-l],p=d[u-1-l],m=c[u-l],f=d[u-l];if(!h||!p||!m||!f||h.value===null||p.value===null||m.value===null||f.value===null)continue;let g=o.logicalToX(u-1),b=o.logicalToX(u),v=o.priceToY(h.value,i.scale,i.bounds),y=o.priceToY(p.value,i.scale,i.bounds),w=o.priceToY(m.value,i.scale,i.bounds),P=o.priceToY(f.value,i.scale,i.bounds),x=n.gradient?.[u-1-l];if(x){let S=o.priceToY(x.topValue,i.scale,i.bounds),E=o.priceToY(x.bottomValue,i.scale,i.bounds),L=E===S?S+1:E,T=G(x.topColor),k=G(x.bottomColor),M=L-S,C=I=>Gd(T,k,pl((I-S)/M));e.quad4(g,v,C(v),b,w,C(w),b,P,C(P),g,y,C(y));}else {let S=n.colors?n.colors[u-1-l]:n.color;if(!S)continue;e.quad(g,v,b,w,b,P,g,y,G(S));}}}emitPriceSeries(e,t,n,i,o,s,a,l,c){if(t.basePainting==="none")return;let d=t.bars,u=t.style;switch(t.priceStyle){case "bars":this.emitBars(e,d,n,i,o,s,u.bars.upColor??a.upColor,u.bars.downColor??a.downColor,l);return;case "line":this.emitPriceLine(e,d,n,i,o,s,G(u.line.color??a.upColor),u.line.width);return;case "area":{let h=u.area.lineColor??a.upColor;this.emitPriceArea(e,d,n,i,o,s,G(u.area.topColor??h),G(u.area.bottomColor??"rgba(0,0,0,0)")),this.emitPriceLine(e,d,n,i,o,s,G(h),u.area.width);return}case "baseline":this.emitBaseline(e,d,n,i,o,s,t,a,c);return;default:this.emitCandles(e,t,d,n,i,o,s,a,l);}}emitBars(e,t,n,i,o,s,a,l,c){let d=o.bodySpacing(),u=Nr(d);if(u==="aggregate"){this.emitCandlesAggregated(e,t,n,i,o,s,a,l,c);return}let h=Math.max(1,Math.round(d*.35)),p=u==="full";for(let m=n;m<=i;m+=1){let f=t[m];if(!f||f.high<=f.low)continue;let g=G(c.get(f.time)??(f.close>=f.open?a:l)),b=Math.round(o.logicalToX(m)),v=o.priceToY(f.high,s.scale,s.bounds),y=o.priceToY(f.low,s.scale,s.bounds);if(e.rect(b-.5,v,1,y-v,g),p){let w=o.priceToY(f.open,s.scale,s.bounds),P=o.priceToY(f.close,s.scale,s.bounds);e.rect(b-h,w-.5,h,1,g),e.rect(b,P-.5,h,1,g);}}}emitPriceLine(e,t,n,i,o,s,a,l){let c=Math.max(1,l)/2,d=Pb(c),u=false,h=0,p=0;for(let m=Math.max(0,n-1);m<=i;m+=1){let f=t[m];if(!f){u=false;continue}let g=o.logicalToX(m),b=o.priceToY(f.close,s.scale,s.bounds);u&&e.seg(h,p,g,b,l,a),e.circle(g,b,c,a,d),h=g,p=b,u=true;}}emitPriceArea(e,t,n,i,o,s,a,l){let c=s.bounds.top+s.bounds.height,d=[],u=1/0,h=()=>{if(d.length>=2){let p=c-u,m=f=>Gd(a,l,p<1e-6?0:pl((f-u)/p));for(let f=1;f<d.length;f+=1){let g=d[f-1],b=d[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);}}d.length=0,u=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);d.push({x:f,y:g}),g<u&&(u=g);}h();}emitBaseline(e,t,n,i,o,s,a,l,c){let d=a.baselinePriceFor(s.scale),u=o.priceToY(d,s.scale,s.bounds),h=a.style.baseline,p=h.topLineColor??Vr,m=h.bottomLineColor??_r,f=G(p),g=G(m),b=G(h.topFillColor??W(p,Bt)),v=G(h.topFillColor2??W(p,Ht)),y=G(h.bottomFillColor??W(m,Bt)),w=G(h.bottomFillColor2??W(m,Ht)),P=[];for(let T=Math.max(0,n-1);T<=i;T+=1){let k=t[T];k&&P.push({x:o.logicalToX(T),y:o.priceToY(k.close,s.scale,s.bounds)});}if(P.length<2)return;let x=s.bounds.top,S=s.bounds.top+s.bounds.height,E=T=>T<=u?v:w,L=T=>{let k=T<=u,M=k?u-x:S-u,C=M>0?pl(Math.abs(T-u)/M):0;return Gd(k?v:w,k?b:y,C)};for(let T=1;T<P.length;T+=1){let k=P[T-1],M=P[T];if(k.y<=u!=M.y<=u&&M.y!==k.y){let C=(u-k.y)/(M.y-k.y),I=k.x+(M.x-k.x)*C;e.tri(k.x,k.y,L(k.y),I,u,E(k.y),k.x,u,E(k.y)),e.tri(I,u,E(M.y),M.x,M.y,L(M.y),M.x,u,E(M.y));}else e.quad4(k.x,k.y,L(k.y),M.x,M.y,L(M.y),M.x,u,E(M.y),k.x,u,E(k.y));}e.dashedSeg(0,u,c,u,1,G(a.style.borderColor??l.borderColor),Wd.dashed??null);for(let T=1;T<P.length;T+=1){let k=P[T-1],M=P[T],C=k.y<=u,I=M.y<=u;if(C!==I&&M.y!==k.y){let _=(u-k.y)/(M.y-k.y),U=k.x+(M.x-k.x)*_;e.seg(k.x,k.y,U,u,h.width,C?f:g),e.seg(U,u,M.x,M.y,h.width,I?f:g);}else e.seg(k.x,k.y,M.x,M.y,h.width,C?f:g);}}emitCandles(e,t,n,i,o,s,a,l,c){let d=s.bodySpacing(),u=Nr(d),h=ul(t.style.candle,t.candleOverride,l.upColor,l.downColor);if(u==="aggregate"){this.emitCandlesAggregated(e,n,i,o,s,a,h.up,h.down,c);return}let p=u==="full",m=h.up,f=h.down,g=h.candle,b=this.candleStructureAlpha>this.candleBodyAlpha+.001;for(let v=i;v<=o;v+=1){let y=n[v];if(!y||y.high<=y.low)continue;let w=cl(s.logicalToX(v),d,s.dpr,this.candleBodyScale),P=y.close>=y.open,x=P?m:f,S=c.get(y.time),E=S??x,L=G(E),T=0,k=0;if(p){let M=s.priceToY(y.open,a.scale,a.bounds),C=s.priceToY(y.close,a.scale,a.bounds);T=Math.min(M,C),k=Math.max(1,Math.abs(C-M));}if(g.wickVisible){let M=s.priceToY(y.high,a.scale,a.bounds),C=s.priceToY(y.low,a.scale,a.bounds);e.alpha=this.candleStructureAlpha;let I=G((P?g.wickUpColor:g.wickDownColor)??(p?x:E));p?(e.rect(w.wickX,M,w.wickW,Math.max(0,T-M),I),e.rect(w.wickX,T+k,w.wickW,Math.max(0,C-(T+k)),I)):e.rect(w.wickX,M,w.wickW,C-M,I);}if(p&&(g.bodyVisible&&(e.alpha=this.candleBodyAlpha,e.rect(w.bodyX,T,w.bodyW,k,L)),g.borderVisible||S||b&&g.bodyVisible)){e.alpha=this.candleStructureAlpha;let M=g.borderVisible||S?G((P?g.borderUpColor:g.borderDownColor)??x):L,C=Math.max(0,w.bodyW-1),I=Math.max(0,k-1);e.rectStroke(w.bodyX+.5,T+.5,C,I,1,M);}}}emitCandlesAggregated(e,t,n,i,o,s,a,l,c){let d=NaN,u=1/0,h=-1/0,p=0,m=0,f=0,g=false,b=()=>{if(!g)return;let v=G(c.get(f)??(m>=p?a:l)),y=o.priceToY(h,s.scale,s.bounds),w=o.priceToY(u,s.scale,s.bounds);e.rect(d-.5,y,1,w-y,v);};for(let v=n;v<=i;v+=1){let y=t[v];if(!y||y.high<=y.low)continue;let w=Math.round(o.logicalToX(v));!g||w!==d?(b(),d=w,u=y.low,h=y.high,p=y.open,f=y.time,g=true):(y.low<u&&(u=y.low),y.high>h&&(h=y.high)),m=y.close;}b();}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(!(!be(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),d=c/2,u=Wd[t.style.lineStyle]??null,h=!u&&!a,p=Pb(d),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 v=i.logicalToX(f),y=i.priceToY(g.value,n.scale,n.bounds),w=i.logicalToX(f-1),P=i.priceToY(b.value,n.scale,n.bounds),x=G(g.color??t.style.color);a?(e.dashedSeg(w,P,v,P,c,x,u),e.dashedSeg(v,P,v,y,c,x,u)):e.dashedSeg(w,P,v,y,c,x,u),h&&(m||e.circle(w,P,d,G(b.color??t.style.color),p),e.circle(v,y,d,x,p)),m=true;}}emitArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=G(t.style.color),d=[],u=1/0,h=()=>{if(d.length<1){d=[],u=1/0;return}let p=l-u,m=f=>fT(c,p<1e-6?0:pl((f-u)/p));for(let f=1;f<d.length;f+=1){let g=d[f-1],b=d[f];e.quad4(g.x,g.y,m(g.y),b.x,b.y,m(b.y),b.x,l,Lb,g.x,l,Lb);}d=[],u=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);d.push({x:f,y:g}),g<u&&(u=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),d=c/2,u=t.style.base??0,h=i.priceToY(u,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-d,Math.min(h,g),c,Math.max(1,Math.abs(g-h)),G(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 d=t.points[c-a];if(!d||d.value===null)continue;let u=i.logicalToX(c),h=i.priceToY(d.value,n.scale,n.bounds),p=G(d.color??t.style.color);t.kind==="cross"?(e.seg(u-l,h,u+l,h,1,p),e.seg(u,h-l,u,h+l,1,p)):e.circle(u,h,l,p,Math.max(16,Math.ceil(l*2)));}}emitPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),d=t.style?.up??a.upColor,u=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],v=G(b?.color??(g.close>=g.open?d:u)),y=Math.round(i.logicalToX(f)),w=i.priceToY(g.high,n.scale,n.bounds),P=i.priceToY(g.low,n.scale,n.bounds),x=i.priceToY(g.open,n.scale,n.bounds),S=i.priceToY(g.close,n.scale,n.bounds);if(h){e.rect(y-.5,w,1,P-w,v),e.rect(y-m,x-.5,m,1,v),e.rect(y,S-.5,m,1,v);continue}let E=Math.max(1,Math.round(oo(c)*i.dpr)),L=(Math.round(y*i.dpr)-(E>>1))/i.dpr;e.rect(L,w,E/i.dpr,P-w,G(b?.wickColor??b?.color??(g.close>=g.open?d:u)));let T=Math.min(x,S),k=Math.max(1,Math.abs(S-x));if(e.rect(y-p,T,p*2,k,v),b?.borderColor){let M=G(b.borderColor);e.rect(y-p,T,p*2,1,M),e.rect(y-p,T+k-1,p*2,1,M),e.rect(y-p,T,1,k,M),e.rect(y+p-1,T,1,k,M);}}}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,G(t.color??s.textColor),Wd[t.lineStyle??"solid"]??null);}};function hl(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 Lb=[0,0,0,0];function pl(r){return r<0?0:r>1?1:r}function Gd(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 fT(r,e){let t=1-e;return [r[0]*t,r[1]*t,r[2]*t,r[3]*t]}function Mb(r,e){let t=r.series.find(n=>n.id===e);return t&&be(t)?t.points:null}var gT=new Map;function bT(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return gT;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 fl(){return {barSpacing:8,rightOffset:6}}function zt(r){return Math.max(.5,Math.min(1e3,r))}function Ud(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 kb(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 Ib(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 gl=class{constructor(){this.widthPx=0;this.dataHeightPx=0;this.devicePixelRatio=1;this.viewport=fl();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=Ud(this.times);}appendBar(e){this.times.push(e),this.intervalMs<=0&&this.times.length>=2&&(this.intervalMs=Ud(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 kb(e,this.times,this.intervalMs)}logicalToTime(e){return Ib(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 Yd(r){return r>=3}function Ab(r){return r>=2}var bl=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 vl=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);}};function Ke(r,e,t,n){return n<=0?e:r+(e-r)*(1-Math.exp(-t/n))}var vT=.04,yT=60,wT=2,xT=350,Rb=8,ST=14,CT=350,TT=30,ET=.004,PT=.004;function LT(r,e,t){return t?{logical:r.rightEdgeLogical,x:r.width}:{logical:r.xToLogical(e),x:e}}function MT(r,e){return Math.abs(r)>Math.abs(e)}function kT(r,e,t){return r+e/t}function IT(r,e,t){return MT(r,e)?r:t?e:null}function AT(r,e){return r?"strong":e}function RT(r,e,t){return zt(r*(t/Math.max(1,e)))}function DT(r,e,t,n,i){return r-(e-1)+(t-n)/i}var yl=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);};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),this.capture(e.pointerId);return}if(e.shiftKey&&this.regionAt(t,n)==="data"&&this.deps.drawingsMeasureStart?.(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)>Rb&&this.cancelLongPress();let i=e.pointerType==="touch"?Rb:wT;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=zt(this.startBarSpacing*Math.exp((this.startX-t)*ET));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);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.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)<=ST);if(this.dragging&&this.region==="drawing")this.deps.drawingsPointerUp?.(t,n);else if(o&&this.region==="data")this.deps.onClick(t,n);else if(this.dragging&&this.region==="data"&&!(e.timeStamp-this.lastT>yT)&&Math.abs(this.vx)>vT){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.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 t=this.deps.getCoords(),n=t.getViewport(),i=IT(e.deltaX,e.deltaY,e.shiftKey);if(i!=null){this.deps.apply({barSpacing:n.barSpacing,rightOffset:kT(n.rightOffset,i,t.pxPerBar())});return}let o=this.local(e).x,s=this.rightEdgeZoom&&!(e.ctrlKey||e.metaKey),a=LT(t,o,s),l=zt(n.barSpacing*Math.exp(-e.deltaY*PT));this.deps.zoomTo(l,a.logical,a.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 AT(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);}},xT);}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=RT(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:DT(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<=CT&&Math.hypot(t-this.lastTapX,n-this.lastTapY)<=TT){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 OT(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 wl=class{constructor(e){this.deps=e;this.el=null;this.onKey=e=>{if(this.deps.preempt?.(e)){e.preventDefault();return}let t=OT(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 FT=ah,NT=lh,VT=ch;function Bb(){return {visible:true,labels:true,qty:true,colors:{long:FT,short:NT,exit:VT}}}function Hb(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 Kd=10,cn=9,Yn=6,zr=14,xl=3,Xd=2,zb=2,jd=3,qd=6,Db=6,Ob=8;function $b(r){return r+4}function _T(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 BT(r,e,t){let n=[];if(e.labels&&r.label&&n.push(r.label),e.qty){let i=_T(r);i&&n.push(i);}return {exec:r,lines:n,height:zr+(n.length?jd+n.length*t:0)}}function Wb(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(BT(a,e,o));}return [...s.values()]}function Fb(r){if(r.length===0)return 0;let e=Kd;for(let t of r)e+=t.height;return e+(r.length-1)*qd}function Gb(r,e,t,n,i,o){if(r.length===0)return null;let s=$b(o),a=1/0,l=-1/0,c=0,d=0;for(let u of Wb(r,e,t,Math.floor(n),Math.ceil(i),s)){let h=t.barAt(u.logical);h&&(h.low<a&&(a=h.low),h.high>l&&(l=h.high),d=Math.max(d,Fb(u.buys)),c=Math.max(c,Fb(u.sells)));}return !Number.isFinite(a)||!Number.isFinite(l)?null:{min:a,max:l,abovePx:c,belowPx:d}}function Ub(r,e,t,n,i,o,s,a,l){if(e.length===0)return;let c=$b(s.fontSize),d=Wb(e,t,n,-1/0,1/0,c);if(d.length!==0){r.save(),r.font=`${s.fontSize}px ${s.fontFamily}`,r.textAlign="center",r.textBaseline="middle";for(let u of d){let h=i(u.logical);if(h<-150||h>a+150)continue;let p=n.barAt(u.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+Kd;for(let b of u.buys)r.fillStyle=Nb(b.exec,t.colors),HT(r,h,g,b.exec.kind==="exit"),Vb(r,b.exec.side,h,o(b.exec.price),l),_b(r,b.lines,h,g+zr+jd+c/2,c,s.color),g+=b.height+qd;g=f-Kd;for(let b of u.sells)r.fillStyle=Nb(b.exec,t.colors),zT(r,h,g,b.exec.kind==="exit"),Vb(r,b.exec.side,h,o(b.exec.price),l),_b(r,b.lines,h,g-zr-jd-c/2,-c,s.color),g-=b.height+qd;}r.restore();}}function Nb(r,e){return r.kind==="exit"?e.exit:r.side==="buy"?e.long:e.short}function HT(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-cn/2,t+Yn),r.lineTo(e+cn/2,t+Yn),r.closePath(),r.fill(),r.fillRect(e-xl/2,t+Yn,xl,zr-Yn),n&&r.fillRect(e-cn/2,t-zb-Xd,cn,Xd);}function zT(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-cn/2,t-Yn),r.lineTo(e+cn/2,t-Yn),r.closePath(),r.fill(),r.fillRect(e-xl/2,t-zr,xl,zr-Yn),n&&r.fillRect(e-cn/2,t+zb,cn,Xd);}function Vb(r,e,t,n,i){let o=e==="buy"?t-i:t+i,s=e==="buy"?o-Db:o+Db;r.beginPath(),r.moveTo(o,n),r.lineTo(s,n-Ob/2),r.lineTo(s,n+Ob/2),r.closePath(),r.fill();}function _b(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);}}var Sl=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=yb();this.showAxisLabels=true;this.tradeMarkers=Bb();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});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 Zd(r,e){return e.kind==="price"?r.scaleMode:e.scaleMode??"price"}function $r(r,e){return e.kind==="price"?r.logScale:e.logScale??false}function Jd(r,e){return e.kind==="price"?r.invertScale:e.invert??false}function $t(r,e){let t=Zd(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 lo=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 d=t.barCount;if(d===0)return;let u=t.visibleLogicalRange(),h=Math.max(0,Math.floor(u.from)),p=Math.min(d-1,Math.ceil(u.to));if(p<h)return;let m=WT(e.indicators),f=e.orderedPanes();for(let g of f){if(g.collapsed)continue;let b=e.orderedIndicatorsForPane(g.id),v=g.kind==="price";i.save(),i.beginPath(),i.rect(0,g.bounds.top,c,g.bounds.height),i.clip();let y=L=>{let T=e.scaleFor(L,g);return T===g.scale?g:{...g,scale:T}};i.globalAlpha=this.modelAlpha;for(let L of b)for(let T of L.backgrounds)this.drawBackground(i,T,g,t);for(let L of b)for(let T of L.fills)this.drawFill(i,L,T,y(L),t,h,p,e.offsetOf(L.id));let w=e.drawingSlices.get(g.id)??[],P=0,x=L=>{for(;P<w.length&&w[P].beforeZ<=L;P+=1)i.globalAlpha=1,i.drawImage(w[P].canvas,0,0,a,l);},S=v&&!e.candlesHidden,E=false;for(let L of b){S&&!E&&e.zOf(L.id)>=e.candleZ&&(x(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c),E=true),x(e.zOf(L.id)),i.globalAlpha=this.modelAlpha;let T=e.offsetOf(L.id),k=y(L);for(let M of L.series)this.drawSeries(i,M,k,t,h,p,n,T);}S&&!E&&(x(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c)),x(1/0),i.globalAlpha=this.modelAlpha;for(let L of b){let T=y(L);for(let k of L.priceLines)this.drawHline(i,k,T,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 d=t.bars,u=t.style;switch(t.priceStyle){case "bars":this.drawBars(e,d,n,i,o,s,u.bars.upColor??a.upColor,u.bars.downColor??a.downColor,l);return;case "line":this.drawPriceLine(e,d,n,i,o,s,u.line.color??a.upColor,u.line.width);return;case "area":{let h=u.area.lineColor??a.upColor;this.drawPriceArea(e,d,n,i,o,s,u.area.topColor??h,u.area.bottomColor??"rgba(0,0,0,0)"),this.drawPriceLine(e,d,n,i,o,s,h,u.area.width);return}case "baseline":this.drawBaseline(e,d,n,i,o,s,t,a,c);return;default:this.drawCandles(e,t,d,n,i,o,s,a,l);}}drawBars(e,t,n,i,o,s,a,l,c){let d=o.bodySpacing(),u=Nr(d);if(u==="aggregate"){this.drawCandlesAggregated(e,t,n,i,o,s,a,l,c);return}let h=Math.max(1,Math.round(d*.35)),p=u==="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),v=o.priceToY(f.high,s.scale,s.bounds),y=o.priceToY(f.low,s.scale,s.bounds);if(e.strokeStyle=b,e.beginPath(),e.moveTo(g,v),e.lineTo(g,y),p){let w=o.priceToY(f.open,s.scale,s.bounds),P=o.priceToY(f.close,s.scale,s.bounds);e.moveTo(g-h,w),e.lineTo(g,w),e.moveTo(g,P),e.lineTo(g+h,P);}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 d=Math.max(0,n-1);d<=i;d+=1){let u=t[d];if(!u){c=false;continue}let h=o.logicalToX(d),p=o.priceToY(u.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,d=[],u=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);d.push({x:f,y:g}),g<u&&(u=g);}if(d.length<2)return;let h=e.createLinearGradient(0,u,0,c);h.addColorStop(0,a),h.addColorStop(1,l),e.fillStyle=h,e.beginPath(),e.moveTo(d[0].x,c);for(let p of d)e.lineTo(p.x,p.y);e.lineTo(d[d.length-1].x,c),e.closePath(),e.fill();}drawBaseline(e,t,n,i,o,s,a,l,c){let d=a.baselinePriceFor(s.scale),u=o.priceToY(d,s.scale,s.bounds),h=s.bounds.top,p=s.bounds.top+s.bounds.height,m=a.style.baseline,f=m.topLineColor??Vr,g=m.bottomLineColor??_r,b=m.topFillColor??W(f,Bt),v=m.topFillColor2??W(f,Ht),y=m.bottomFillColor??W(g,Bt),w=m.bottomFillColor2??W(g,Ht),P=[];for(let E=Math.max(0,n-1);E<=i;E+=1){let L=t[E];L&&P.push({x:o.logicalToX(E),y:o.priceToY(L.close,s.scale,s.bounds)});}if(P.length<2)return;let x=()=>{e.beginPath(),e.moveTo(P[0].x,u);for(let E of P)e.lineTo(E.x,E.y);e.lineTo(P[P.length-1].x,u),e.closePath();};if(u>h){e.save(),e.beginPath(),e.rect(0,h,c,u-h),e.clip();let E=e.createLinearGradient(0,h,0,u);E.addColorStop(0,b),E.addColorStop(1,v),e.fillStyle=E,x(),e.fill(),e.restore();}if(u<p){e.save(),e.beginPath(),e.rect(0,u,c,p-u),e.clip();let E=e.createLinearGradient(0,u,0,p);E.addColorStop(0,w),E.addColorStop(1,y),e.fillStyle=E,x(),e.fill(),e.restore();}e.strokeStyle=a.style.borderColor??l.borderColor,e.lineWidth=1,Wr(e,"dashed"),e.beginPath(),e.moveTo(0,Math.round(u)+.5),e.lineTo(c,Math.round(u)+.5),e.stroke(),Wr(e,"solid"),e.lineWidth=m.width,e.lineJoin="round",e.lineCap="round";let S=(E,L,T,k,M)=>{e.strokeStyle=M,e.beginPath(),e.moveTo(E,L),e.lineTo(T,k),e.stroke();};for(let E=1;E<P.length;E+=1){let L=P[E-1],T=P[E],k=L.y<=u,M=T.y<=u;if(k!==M&&T.y!==L.y){let C=(u-L.y)/(T.y-L.y),I=L.x+(T.x-L.x)*C;S(L.x,L.y,I,u,k?f:g),S(I,u,T.x,T.y,M?f:g);}else S(L.x,L.y,T.x,T.y,k?f:g);}e.lineCap="butt";}drawCandles(e,t,n,i,o,s,a,l,c){let d=s.bodySpacing(),u=Nr(d),h=ul(t.style.candle,t.candleOverride,l.upColor,l.downColor);if(u==="aggregate"){this.drawCandlesAggregated(e,n,i,o,s,a,h.up,h.down,c);return}let p=u==="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 v=cl(s.logicalToX(g),d,s.dpr,this.candleBodyScale),y=v.center,w=b.close>=b.open,P=w?h.up:h.down,x=c.get(b.time),S=x??P,E=0,L=0;if(p){let T=s.priceToY(b.open,a.scale,a.bounds),k=s.priceToY(b.close,a.scale,a.bounds);E=Math.min(T,k),L=Math.max(1,Math.abs(k-T));}if(m.wickVisible){let T=(w?m.wickUpColor:m.wickDownColor)??(p?P:S),k=s.priceToY(b.high,a.scale,a.bounds),M=s.priceToY(b.low,a.scale,a.bounds);e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=T,e.lineWidth=v.wickW,e.beginPath(),p?(e.moveTo(y,k),e.lineTo(y,E),e.moveTo(y,E+L),e.lineTo(y,M)):(e.moveTo(y,k),e.lineTo(y,M)),e.stroke();}if(p&&(m.bodyVisible&&(e.globalAlpha=this.candleBodyAlpha,e.fillStyle=S,e.fillRect(v.bodyX,E,v.bodyW,L)),m.borderVisible||x||f&&m.bodyVisible)){e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=m.borderVisible||x?(w?m.borderUpColor:m.borderDownColor)??P:S,e.lineWidth=1;let T=Math.max(0,v.bodyW-1),k=Math.max(0,L-1);e.strokeRect(v.bodyX+.5,E+.5,T,k);}}}drawCandlesAggregated(e,t,n,i,o,s,a,l,c){let d=NaN,u=1/0,h=-1/0,p=0,m=0,f=0,g=false,b=()=>{if(!g)return;let v=c.get(f)??(m>=p?a:l),y=o.priceToY(h,s.scale,s.bounds),w=o.priceToY(u,s.scale,s.bounds);e.strokeStyle=v,e.lineWidth=1,e.beginPath(),e.moveTo(d,y),e.lineTo(d,w),e.stroke();};for(let v=n;v<=i;v+=1){let y=t[v];if(!y||y.high<=y.low)continue;let w=Math.round(o.logicalToX(v))+.5;!g||w!==d?(b(),d=w,u=y.low,h=y.high,p=y.open,f=y.time,g=true):(y.low<u&&(u=y.low),y.high>h&&(h=y.high)),m=y.close;}b();}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(!(!be(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",Wr(e,t.style.lineStyle);let c=0,d=0,u=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){u=false;continue}let f=i.logicalToX(h),g=i.priceToY(p.value,n.scale,n.bounds);u||(c=i.logicalToX(h-1),d=i.priceToY(m.value,n.scale,n.bounds)),e.strokeStyle=p.color??t.style.color,e.beginPath(),e.moveTo(c,d),a&&e.lineTo(f,d),e.lineTo(f,g),e.stroke(),c=f,d=g,u=true;}Wr(e,"solid");}drawArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=[],d=1/0,u=()=>{if(c.length===0)return;let h=e.createLinearGradient(0,d,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=[],d=1/0;};for(let h=o;h<=s;h+=1){let p=t.points[h-a];if(!p||p.value===null){u();continue}let m=i.logicalToX(h),f=i.priceToY(p.value,n.scale,n.bounds);c.push({x:m,y:f}),f<d&&(d=f);}u();}drawHistogram(e,t,n,i,o,s,a=0){let l=i.bodySpacing(),c=Math.max(1,(t.kind==="columns"?.7:.8)*l),d=c/2,u=t.style.base??0,h=i.priceToY(u,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-d,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 d=t.points[c-a];if(!d||d.value===null)continue;let u=i.logicalToX(c),h=i.priceToY(d.value,n.scale,n.bounds);e.strokeStyle=d.color??t.style.color,e.fillStyle=d.color??t.style.color,t.kind==="cross"?(e.lineWidth=1,e.beginPath(),e.moveTo(u-l,h),e.lineTo(u+l,h),e.moveTo(u,h-l),e.lineTo(u,h+l),e.stroke()):(e.beginPath(),e.arc(u,h,l,0,Math.PI*2),e.fill());}}drawPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),d=t.style?.up??a.upColor,u=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],v=b?.color??(g.close>=g.open?d:u),y=Math.round(i.logicalToX(f))+.5,w=i.priceToY(g.high,n.scale,n.bounds),P=i.priceToY(g.low,n.scale,n.bounds),x=i.priceToY(g.open,n.scale,n.bounds),S=i.priceToY(g.close,n.scale,n.bounds);if(h){e.strokeStyle=v,e.lineWidth=1,e.beginPath(),e.moveTo(y,w),e.lineTo(y,P),e.moveTo(y-m,x),e.lineTo(y,x),e.moveTo(y,S),e.lineTo(y+m,S),e.stroke();continue}e.strokeStyle=b?.wickColor??v,e.lineWidth=oo(c),e.beginPath(),e.moveTo(y,w),e.lineTo(y,P),e.stroke(),e.fillStyle=v,e.fillRect(y-p,Math.min(x,S),p*2,Math.max(1,Math.abs(S-x))),b?.borderColor&&(e.strokeStyle=b.borderColor,e.strokeRect(y-p,Math.min(x,S),p*2,Math.max(1,Math.abs(S-x))));}}drawFill(e,t,n,i,o,s,a,l=0){let c=Yb(t,n.fromSeriesId),d=Yb(t,n.toSeriesId);if(!c||!d)return;let u=NaN,h=NaN,p="",m="",f=null;for(let g=Math.max(1,s);g<=a;g+=1){let b=c[g-1-l],v=d[g-1-l],y=c[g-l],w=d[g-l];if(!b||!v||!y||!w||b.value===null||v.value===null||y.value===null||w.value===null)continue;let P=o.logicalToX(g-1),x=o.logicalToX(g),S=o.priceToY(b.value,i.scale,i.bounds),E=o.priceToY(v.value,i.scale,i.bounds),L=o.priceToY(y.value,i.scale,i.bounds),T=o.priceToY(w.value,i.scale,i.bounds),k=n.gradient?.[g-1-l];if(k){let M=o.priceToY(k.topValue,i.scale,i.bounds),C=o.priceToY(k.bottomValue,i.scale,i.bounds),I=C===M?M+1:C;(!f||M!==u||I!==h||k.topColor!==p||k.bottomColor!==m)&&(f=e.createLinearGradient(0,M,0,I),f.addColorStop(0,k.topColor),f.addColorStop(1,k.bottomColor),u=M,h=I,p=k.topColor,m=k.bottomColor),e.fillStyle=f;}else {let M=n.colors?n.colors[g-1-l]:n.color;if(!M)continue;e.fillStyle=M;}e.beginPath(),e.moveTo(P,S),e.lineTo(x,L),e.lineTo(x,T),e.lineTo(P,E),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,Wr(e,t.lineStyle??"solid"),e.beginPath(),e.moveTo(0,a),e.lineTo(o,a),e.stroke(),Wr(e,"solid"));}};function Wr(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function Yb(r,e){let t=r.series.find(n=>n.id===e);return t&&be(t)?t.points:null}var $T=new Map;function WT(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return $T;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 Gr(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 d=(n-e)/a,u=m=>e+d*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,u(h),p,u(p)]}function Kb(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 GT(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 UT(r,e,t){return (.299*r+.587*e+.114*t)/255}function Ne(r){if(!r)return "#000000";let e=GT(r);return e?UT(e.r,e.g,e.b)>.55?"#000000":"#ffffff":"#000000"}function xt(r){return Math.round(r*1.4)}var Xn=5,jn=3;function ye(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 Xb(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 YT={lines:[],boxes:[],labels:[],polylines:[],linefills:[]};function jb(r){return r==="auto"?12:ye(r)}var Cl=class{constructor(e,t=YT){this.deps=e;this.set=t;this.widthCache=new Map;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}render(e,t,n,i,o){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=(u,h,p)=>p!=="none"?true:Math.max(u,h)>=n&&Math.min(u,h)<=i,s=1/0,a=-1/0,l=u=>{u<s&&(s=u),u>a&&(a=u);};for(let u of this.set.lines)u.invisible||o(this.logicalOf(u.xloc,u.x1),this.logicalOf(u.xloc,u.x2),u.extend)&&(l(u.y1),l(u.y2));for(let u of this.set.boxes)!u.bgColor&&!(u.borderColor&&u.borderWidth>0)&&!u.text||o(this.logicalOf(u.xloc,u.left),this.logicalOf(u.xloc,u.right),u.extend)&&(l(u.top),l(u.bottom));for(let u of this.set.linefills){if(!u.color)continue;let h=[u.line1.x1,u.line1.x2,u.line2.x1,u.line2.x2].map((m,f)=>this.logicalOf(f<2?u.line1.xloc:u.line2.xloc,m)),p=u.line1.extend!=="none"||u.line2.extend!=="none"?"both":"none";o(Math.min(...h),Math.max(...h),p)&&(l(u.line1.y1),l(u.line1.y2),l(u.line2.y1),l(u.line2.y2));}for(let u of this.set.polylines){if(u.points.length<2)continue;let h=u.points.map(p=>this.logicalOf(p.xloc,p.x));if(o(Math.min(...h),Math.max(...h),"none"))for(let p of u.points)l(p.price);}let c=0,d=0;for(let u of this.set.labels){let h=this.logicalOf(u.xloc,u.x);if(!o(h,h,"none"))continue;if(u.yloc==="price"){l(u.y);continue}if(u.yloc==="top"||u.yloc==="bottom")continue;let p=this.deps.barAt(h);if(!p)continue;l(u.yloc==="abovebar"?p.high:p.low);let m=jb(u.size),f=Math.max(1,(u.text??"").split(`
|
|
764
|
+
}`,Yd={solid:null,dashed:[6,4],dotted:[2,3]};function Ib(r){return Math.max(6,Math.min(20,Math.round(r*4)))}var gl=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 uo;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 uo;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=ml(e,e.VERTEX_SHADER,bT),n=ml(e,e.FRAGMENT_SHADER,vT),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=ml(e,e.VERTEX_SHADER,yT),n=ml(e,e.FRAGMENT_SHADER,wT),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(),d=Math.max(0,Math.floor(c.from)),u=Math.min(l-1,Math.ceil(c.to));if(u<d)return;i.enable(i.BLEND),i.enable(i.SCISSOR_TEST);let h=CT(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),v=Math.round((f.bounds.top+f.bounds.height)*s);i.scissor(0,o.height-v,Math.round(a*s),v-b);let y=()=>{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());},w=f.collapsed?[]:e.drawingSlices.get(f.id)??[],P=0,x=S=>{for(;P<w.length&&w[P].beforeZ<=S;P+=1)y(),this.drawSliceTexture(i,w[P].canvas)&&m.add(w[P].canvas);};if(g.alpha=1,!f.collapsed){let S=e.orderedIndicatorsForPane(f.id),E=f.kind==="price",L=M=>{let C=e.scaleFor(M,f);return C===f.scale?f:{...f,scale:C}};g.alpha=this.modelAlpha;for(let M of S)for(let C of M.backgrounds)this.emitBackground(g,C,f,t);for(let M of S)for(let C of M.fills)this.emitFill(g,M,C,L(M),t,d,u,e.offsetOf(M.id));let T=E&&!e.candlesHidden,k=false;for(let M of S){T&&!k&&e.zOf(M.id)>=e.candleZ&&(x(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,d,u,t,f,n,h,a),k=true),x(e.zOf(M.id)),g.alpha=this.modelAlpha;let C=e.offsetOf(M.id),I=L(M);for(let _ of M.series)this.emitSeries(g,_,I,t,d,u,n,C);}T&&!k&&(x(e.candleZ),g.alpha=this.candleStructureAlpha,this.emitPriceSeries(g,e,d,u,t,f,n,h,a)),x(1/0),g.alpha=this.modelAlpha;for(let M of S){let C=L(M);for(let I of M.priceLines)this.emitHline(g,I,C,t,a,n);}g.alpha=1;}y();}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,d,u));}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,d=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 u of t.orderedPanes()){let h=this.glowBatch;if(h.reset(),this.emitGlowSources(h,t.indicatorsForPane(u.id),u,n,i,o,f=>t.offsetOf(f)),h.vertexCount===0)continue;let p=Math.round(u.bounds.top*c*.5),m=Math.round((u.bounds.top+u.bounds.height)*c*.5);e.scissor(0,l-m,Math.round(d*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,a=()=>0){for(let l of t){let c=a(l.id);for(let d of l.series)!be(d)||d.visible===false||d.kind==="histogram"||d.kind==="columns"||(d.kind==="circles"||d.kind==="cross"?this.emitPointMarkers(e,d,n,i,o,s,c):this.emitPolyline(e,d,n,i,o,s,d.kind==="step",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,G(t.color));}emitFill(e,t,n,i,o,s,a,l=0){let c=Rb(t,n.fromSeriesId),d=Rb(t,n.toSeriesId);if(!(!c||!d))for(let u=Math.max(1,s);u<=a;u+=1){let h=c[u-1-l],p=d[u-1-l],m=c[u-l],f=d[u-l];if(!h||!p||!m||!f||h.value===null||p.value===null||m.value===null||f.value===null)continue;let g=o.logicalToX(u-1),b=o.logicalToX(u),v=o.priceToY(h.value,i.scale,i.bounds),y=o.priceToY(p.value,i.scale,i.bounds),w=o.priceToY(m.value,i.scale,i.bounds),P=o.priceToY(f.value,i.scale,i.bounds),x=n.gradient?.[u-1-l];if(x){let S=o.priceToY(x.topValue,i.scale,i.bounds),E=o.priceToY(x.bottomValue,i.scale,i.bounds),L=E===S?S+1:E,T=G(x.topColor),k=G(x.bottomColor),M=L-S,C=I=>Kd(T,k,fl((I-S)/M));e.quad4(g,v,C(v),b,w,C(w),b,P,C(P),g,y,C(y));}else {let S=n.colors?n.colors[u-1-l]:n.color;if(!S)continue;e.quad(g,v,b,w,b,P,g,y,G(S));}}}emitPriceSeries(e,t,n,i,o,s,a,l,c){if(t.basePainting==="none")return;let d=t.bars,u=t.style;switch(t.priceStyle){case "bars":this.emitBars(e,d,n,i,o,s,u.bars.upColor??a.upColor,u.bars.downColor??a.downColor,l);return;case "line":this.emitPriceLine(e,d,n,i,o,s,G(u.line.color??a.upColor),u.line.width);return;case "area":{let h=u.area.lineColor??a.upColor;this.emitPriceArea(e,d,n,i,o,s,G(u.area.topColor??h),G(u.area.bottomColor??"rgba(0,0,0,0)")),this.emitPriceLine(e,d,n,i,o,s,G(h),u.area.width);return}case "baseline":this.emitBaseline(e,d,n,i,o,s,t,a,c);return;default:this.emitCandles(e,t,d,n,i,o,s,a,l);}}emitBars(e,t,n,i,o,s,a,l,c){let d=o.bodySpacing(),u=Nr(d);if(u==="aggregate"){this.emitCandlesAggregated(e,t,n,i,o,s,a,l,c);return}let h=Math.max(1,Math.round(d*.35)),p=u==="full";for(let m=n;m<=i;m+=1){let f=t[m];if(!f||f.high<=f.low)continue;let g=G(c.get(f.time)??(f.close>=f.open?a:l)),b=Math.round(o.logicalToX(m)),v=o.priceToY(f.high,s.scale,s.bounds),y=o.priceToY(f.low,s.scale,s.bounds);if(e.rect(b-.5,v,1,y-v,g),p){let w=o.priceToY(f.open,s.scale,s.bounds),P=o.priceToY(f.close,s.scale,s.bounds);e.rect(b-h,w-.5,h,1,g),e.rect(b,P-.5,h,1,g);}}}emitPriceLine(e,t,n,i,o,s,a,l){let c=Math.max(1,l)/2,d=Ib(c),u=false,h=0,p=0;for(let m=Math.max(0,n-1);m<=i;m+=1){let f=t[m];if(!f){u=false;continue}let g=o.logicalToX(m),b=o.priceToY(f.close,s.scale,s.bounds);u&&e.seg(h,p,g,b,l,a),e.circle(g,b,c,a,d),h=g,p=b,u=true;}}emitPriceArea(e,t,n,i,o,s,a,l){let c=s.bounds.top+s.bounds.height,d=[],u=1/0,h=()=>{if(d.length>=2){let p=c-u,m=f=>Kd(a,l,p<1e-6?0:fl((f-u)/p));for(let f=1;f<d.length;f+=1){let g=d[f-1],b=d[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);}}d.length=0,u=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);d.push({x:f,y:g}),g<u&&(u=g);}h();}emitBaseline(e,t,n,i,o,s,a,l,c){let d=a.baselinePriceFor(s.scale),u=o.priceToY(d,s.scale,s.bounds),h=a.style.baseline,p=h.topLineColor??Vr,m=h.bottomLineColor??_r,f=G(p),g=G(m),b=G(h.topFillColor??W(p,Bt)),v=G(h.topFillColor2??W(p,Ht)),y=G(h.bottomFillColor??W(m,Bt)),w=G(h.bottomFillColor2??W(m,Ht)),P=[];for(let T=Math.max(0,n-1);T<=i;T+=1){let k=t[T];k&&P.push({x:o.logicalToX(T),y:o.priceToY(k.close,s.scale,s.bounds)});}if(P.length<2)return;let x=s.bounds.top,S=s.bounds.top+s.bounds.height,E=T=>T<=u?v:w,L=T=>{let k=T<=u,M=k?u-x:S-u,C=M>0?fl(Math.abs(T-u)/M):0;return Kd(k?v:w,k?b:y,C)};for(let T=1;T<P.length;T+=1){let k=P[T-1],M=P[T];if(k.y<=u!=M.y<=u&&M.y!==k.y){let C=(u-k.y)/(M.y-k.y),I=k.x+(M.x-k.x)*C;e.tri(k.x,k.y,L(k.y),I,u,E(k.y),k.x,u,E(k.y)),e.tri(I,u,E(M.y),M.x,M.y,L(M.y),M.x,u,E(M.y));}else e.quad4(k.x,k.y,L(k.y),M.x,M.y,L(M.y),M.x,u,E(M.y),k.x,u,E(k.y));}e.dashedSeg(0,u,c,u,1,G(a.style.borderColor??l.borderColor),Yd.dashed??null);for(let T=1;T<P.length;T+=1){let k=P[T-1],M=P[T],C=k.y<=u,I=M.y<=u;if(C!==I&&M.y!==k.y){let _=(u-k.y)/(M.y-k.y),U=k.x+(M.x-k.x)*_;e.seg(k.x,k.y,U,u,h.width,C?f:g),e.seg(U,u,M.x,M.y,h.width,I?f:g);}else e.seg(k.x,k.y,M.x,M.y,h.width,C?f:g);}}emitCandles(e,t,n,i,o,s,a,l,c){let d=s.bodySpacing(),u=Nr(d),h=pl(t.style.candle,t.candleOverride,l.upColor,l.downColor);if(u==="aggregate"){this.emitCandlesAggregated(e,n,i,o,s,a,h.up,h.down,c);return}let p=u==="full",m=h.up,f=h.down,g=h.candle,b=this.candleStructureAlpha>this.candleBodyAlpha+.001;for(let v=i;v<=o;v+=1){let y=n[v];if(!y||y.high<=y.low)continue;let w=ul(s.logicalToX(v),d,s.dpr,this.candleBodyScale),P=y.close>=y.open,x=P?m:f,S=c.get(y.time),E=S??x,L=G(E),T=0,k=0;if(p){let M=s.priceToY(y.open,a.scale,a.bounds),C=s.priceToY(y.close,a.scale,a.bounds);T=Math.min(M,C),k=Math.max(1,Math.abs(C-M));}if(g.wickVisible){let M=s.priceToY(y.high,a.scale,a.bounds),C=s.priceToY(y.low,a.scale,a.bounds);e.alpha=this.candleStructureAlpha;let I=G((P?g.wickUpColor:g.wickDownColor)??(p?x:E));p?(e.rect(w.wickX,M,w.wickW,Math.max(0,T-M),I),e.rect(w.wickX,T+k,w.wickW,Math.max(0,C-(T+k)),I)):e.rect(w.wickX,M,w.wickW,C-M,I);}if(p&&(g.bodyVisible&&(e.alpha=this.candleBodyAlpha,e.rect(w.bodyX,T,w.bodyW,k,L)),g.borderVisible||S||b&&g.bodyVisible)){e.alpha=this.candleStructureAlpha;let M=g.borderVisible||S?G((P?g.borderUpColor:g.borderDownColor)??x):L,C=Math.max(0,w.bodyW-1),I=Math.max(0,k-1);e.rectStroke(w.bodyX+.5,T+.5,C,I,1,M);}}}emitCandlesAggregated(e,t,n,i,o,s,a,l,c){let d=NaN,u=1/0,h=-1/0,p=0,m=0,f=0,g=false,b=()=>{if(!g)return;let v=G(c.get(f)??(m>=p?a:l)),y=o.priceToY(h,s.scale,s.bounds),w=o.priceToY(u,s.scale,s.bounds);e.rect(d-.5,y,1,w-y,v);};for(let v=n;v<=i;v+=1){let y=t[v];if(!y||y.high<=y.low)continue;let w=Math.round(o.logicalToX(v));!g||w!==d?(b(),d=w,u=y.low,h=y.high,p=y.open,f=y.time,g=true):(y.low<u&&(u=y.low),y.high>h&&(h=y.high)),m=y.close;}b();}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(!(!be(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),d=c/2,u=Yd[t.style.lineStyle]??null,h=!u&&!a,p=Ib(d),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 v=i.logicalToX(f),y=i.priceToY(g.value,n.scale,n.bounds),w=i.logicalToX(f-1),P=i.priceToY(b.value,n.scale,n.bounds),x=G(g.color??t.style.color);a?(e.dashedSeg(w,P,v,P,c,x,u),e.dashedSeg(v,P,v,y,c,x,u)):e.dashedSeg(w,P,v,y,c,x,u),h&&(m||e.circle(w,P,d,G(b.color??t.style.color),p),e.circle(v,y,d,x,p)),m=true;}}emitArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=G(t.style.color),d=[],u=1/0,h=()=>{if(d.length<1){d=[],u=1/0;return}let p=l-u,m=f=>xT(c,p<1e-6?0:fl((f-u)/p));for(let f=1;f<d.length;f+=1){let g=d[f-1],b=d[f];e.quad4(g.x,g.y,m(g.y),b.x,b.y,m(b.y),b.x,l,Ab,g.x,l,Ab);}d=[],u=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);d.push({x:f,y:g}),g<u&&(u=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),d=c/2,u=t.style.base??0,h=i.priceToY(u,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-d,Math.min(h,g),c,Math.max(1,Math.abs(g-h)),G(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 d=t.points[c-a];if(!d||d.value===null)continue;let u=i.logicalToX(c),h=i.priceToY(d.value,n.scale,n.bounds),p=G(d.color??t.style.color);t.kind==="cross"?(e.seg(u-l,h,u+l,h,1,p),e.seg(u,h-l,u,h+l,1,p)):e.circle(u,h,l,p,Math.max(16,Math.ceil(l*2)));}}emitPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),d=t.style?.up??a.upColor,u=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],v=G(b?.color??(g.close>=g.open?d:u)),y=Math.round(i.logicalToX(f)),w=i.priceToY(g.high,n.scale,n.bounds),P=i.priceToY(g.low,n.scale,n.bounds),x=i.priceToY(g.open,n.scale,n.bounds),S=i.priceToY(g.close,n.scale,n.bounds);if(h){e.rect(y-.5,w,1,P-w,v),e.rect(y-m,x-.5,m,1,v),e.rect(y,S-.5,m,1,v);continue}let E=Math.max(1,Math.round(lo(c)*i.dpr)),L=(Math.round(y*i.dpr)-(E>>1))/i.dpr;e.rect(L,w,E/i.dpr,P-w,G(b?.wickColor??b?.color??(g.close>=g.open?d:u)));let T=Math.min(x,S),k=Math.max(1,Math.abs(S-x));if(e.rect(y-p,T,p*2,k,v),b?.borderColor){let M=G(b.borderColor);e.rect(y-p,T,p*2,1,M),e.rect(y-p,T+k-1,p*2,1,M),e.rect(y-p,T,1,k,M),e.rect(y+p-1,T,1,k,M);}}}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,G(t.color??s.textColor),Yd[t.lineStyle??"solid"]??null);}};function ml(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 Ab=[0,0,0,0];function fl(r){return r<0?0:r>1?1:r}function Kd(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 xT(r,e){let t=1-e;return [r[0]*t,r[1]*t,r[2]*t,r[3]*t]}function Rb(r,e){let t=r.series.find(n=>n.id===e);return t&&be(t)?t.points:null}var ST=new Map;function CT(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return ST;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 bl(){return {barSpacing:8,rightOffset:6}}function zt(r){return Math.max(.5,Math.min(1e3,r))}function Xd(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 Db(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 Ob(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 vl=class{constructor(){this.widthPx=0;this.dataHeightPx=0;this.devicePixelRatio=1;this.viewport=bl();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=Xd(this.times);}appendBar(e){this.times.push(e),this.intervalMs<=0&&this.times.length>=2&&(this.intervalMs=Xd(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 Db(e,this.times,this.intervalMs)}logicalToTime(e){return Ob(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 jd(r){return r>=3}function Fb(r){return r>=2}var yl=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 wl=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);}};function Ke(r,e,t,n){return n<=0?e:r+(e-r)*(1-Math.exp(-t/n))}var TT=.04,ET=60,PT=2,LT=350,Nb=8,MT=14,kT=350,IT=30,AT=.004,RT=.004;function DT(r,e,t){return t?{logical:r.rightEdgeLogical,x:r.width}:{logical:r.xToLogical(e),x:e}}function OT(r,e){return Math.abs(r)>Math.abs(e)}function FT(r,e,t){return r+e/t}function NT(r,e,t){return OT(r,e)?r:t?e:null}function VT(r,e){return r?"strong":e}function _T(r,e,t){return zt(r*(t/Math.max(1,e)))}function BT(r,e,t,n,i){return r-(e-1)+(t-n)/i}var xl=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);};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),this.capture(e.pointerId);return}if(e.shiftKey&&this.regionAt(t,n)==="data"&&this.deps.drawingsMeasureStart?.(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)>Nb&&this.cancelLongPress();let i=e.pointerType==="touch"?Nb:PT;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=zt(this.startBarSpacing*Math.exp((this.startX-t)*AT));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);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.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)<=MT);if(this.dragging&&this.region==="drawing")this.deps.drawingsPointerUp?.(t,n);else if(o&&this.region==="data")this.deps.onClick(t,n);else if(this.dragging&&this.region==="data"&&!(e.timeStamp-this.lastT>ET)&&Math.abs(this.vx)>TT){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.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 t=this.deps.getCoords(),n=t.getViewport(),i=NT(e.deltaX,e.deltaY,e.shiftKey);if(i!=null){this.deps.apply({barSpacing:n.barSpacing,rightOffset:FT(n.rightOffset,i,t.pxPerBar())});return}let o=this.local(e).x,s=this.rightEdgeZoom&&!(e.ctrlKey||e.metaKey),a=DT(t,o,s),l=zt(n.barSpacing*Math.exp(-e.deltaY*RT));this.deps.zoomTo(l,a.logical,a.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 VT(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);}},LT);}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=_T(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:BT(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<=kT&&Math.hypot(t-this.lastTapX,n-this.lastTapY)<=IT){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 HT(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 Sl=class{constructor(e){this.deps=e;this.el=null;this.onKey=e=>{if(this.deps.preempt?.(e)){e.preventDefault();return}let t=HT(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 zT=uh,$T=hh,WT=ph;function Wb(){return {visible:true,labels:true,qty:true,colors:{long:zT,short:$T,exit:WT}}}function Gb(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 qd=10,dn=9,Yn=6,zr=14,Cl=3,Zd=2,Ub=2,Jd=3,Qd=6,Vb=6,_b=8;function Yb(r){return r+4}function GT(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 UT(r,e,t){let n=[];if(e.labels&&r.label&&n.push(r.label),e.qty){let i=GT(r);i&&n.push(i);}return {exec:r,lines:n,height:zr+(n.length?Jd+n.length*t:0)}}function Kb(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(UT(a,e,o));}return [...s.values()]}function Bb(r){if(r.length===0)return 0;let e=qd;for(let t of r)e+=t.height;return e+(r.length-1)*Qd}function Xb(r,e,t,n,i,o){if(r.length===0)return null;let s=Yb(o),a=1/0,l=-1/0,c=0,d=0;for(let u of Kb(r,e,t,Math.floor(n),Math.ceil(i),s)){let h=t.barAt(u.logical);h&&(h.low<a&&(a=h.low),h.high>l&&(l=h.high),d=Math.max(d,Bb(u.buys)),c=Math.max(c,Bb(u.sells)));}return !Number.isFinite(a)||!Number.isFinite(l)?null:{min:a,max:l,abovePx:c,belowPx:d}}function jb(r,e,t,n,i,o,s,a,l){if(e.length===0)return;let c=Yb(s.fontSize),d=Kb(e,t,n,-1/0,1/0,c);if(d.length!==0){r.save(),r.font=`${s.fontSize}px ${s.fontFamily}`,r.textAlign="center",r.textBaseline="middle";for(let u of d){let h=i(u.logical);if(h<-150||h>a+150)continue;let p=n.barAt(u.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+qd;for(let b of u.buys)r.fillStyle=Hb(b.exec,t.colors),YT(r,h,g,b.exec.kind==="exit"),zb(r,b.exec.side,h,o(b.exec.price),l),$b(r,b.lines,h,g+zr+Jd+c/2,c,s.color),g+=b.height+Qd;g=f-qd;for(let b of u.sells)r.fillStyle=Hb(b.exec,t.colors),KT(r,h,g,b.exec.kind==="exit"),zb(r,b.exec.side,h,o(b.exec.price),l),$b(r,b.lines,h,g-zr-Jd-c/2,-c,s.color),g-=b.height+Qd;}r.restore();}}function Hb(r,e){return r.kind==="exit"?e.exit:r.side==="buy"?e.long:e.short}function YT(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-dn/2,t+Yn),r.lineTo(e+dn/2,t+Yn),r.closePath(),r.fill(),r.fillRect(e-Cl/2,t+Yn,Cl,zr-Yn),n&&r.fillRect(e-dn/2,t-Ub-Zd,dn,Zd);}function KT(r,e,t,n){r.beginPath(),r.moveTo(e,t),r.lineTo(e-dn/2,t-Yn),r.lineTo(e+dn/2,t-Yn),r.closePath(),r.fill(),r.fillRect(e-Cl/2,t-zr,Cl,zr-Yn),n&&r.fillRect(e-dn/2,t+Ub,dn,Zd);}function zb(r,e,t,n,i){let o=e==="buy"?t-i:t+i,s=e==="buy"?o-Vb:o+Vb;r.beginPath(),r.moveTo(o,n),r.lineTo(s,n-_b/2),r.lineTo(s,n+_b/2),r.closePath(),r.fill();}function $b(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);}}var Tl=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=Cb();this.showAxisLabels=true;this.tradeMarkers=Wb();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});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 eu(r,e){return e.kind==="price"?r.scaleMode:e.scaleMode??"price"}function $r(r,e){return e.kind==="price"?r.logScale:e.logScale??false}function tu(r,e){return e.kind==="price"?r.invertScale:e.invert??false}function $t(r,e){let t=eu(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 ho=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 d=t.barCount;if(d===0)return;let u=t.visibleLogicalRange(),h=Math.max(0,Math.floor(u.from)),p=Math.min(d-1,Math.ceil(u.to));if(p<h)return;let m=jT(e.indicators),f=e.orderedPanes();for(let g of f){if(g.collapsed)continue;let b=e.orderedIndicatorsForPane(g.id),v=g.kind==="price";i.save(),i.beginPath(),i.rect(0,g.bounds.top,c,g.bounds.height),i.clip();let y=L=>{let T=e.scaleFor(L,g);return T===g.scale?g:{...g,scale:T}};i.globalAlpha=this.modelAlpha;for(let L of b)for(let T of L.backgrounds)this.drawBackground(i,T,g,t);for(let L of b)for(let T of L.fills)this.drawFill(i,L,T,y(L),t,h,p,e.offsetOf(L.id));let w=e.drawingSlices.get(g.id)??[],P=0,x=L=>{for(;P<w.length&&w[P].beforeZ<=L;P+=1)i.globalAlpha=1,i.drawImage(w[P].canvas,0,0,a,l);},S=v&&!e.candlesHidden,E=false;for(let L of b){S&&!E&&e.zOf(L.id)>=e.candleZ&&(x(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c),E=true),x(e.zOf(L.id)),i.globalAlpha=this.modelAlpha;let T=e.offsetOf(L.id),k=y(L);for(let M of L.series)this.drawSeries(i,M,k,t,h,p,n,T);}S&&!E&&(x(e.candleZ),i.globalAlpha=this.candleStructureAlpha,this.drawPriceSeries(i,e,h,p,t,g,n,m,c)),x(1/0),i.globalAlpha=this.modelAlpha;for(let L of b){let T=y(L);for(let k of L.priceLines)this.drawHline(i,k,T,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 d=t.bars,u=t.style;switch(t.priceStyle){case "bars":this.drawBars(e,d,n,i,o,s,u.bars.upColor??a.upColor,u.bars.downColor??a.downColor,l);return;case "line":this.drawPriceLine(e,d,n,i,o,s,u.line.color??a.upColor,u.line.width);return;case "area":{let h=u.area.lineColor??a.upColor;this.drawPriceArea(e,d,n,i,o,s,u.area.topColor??h,u.area.bottomColor??"rgba(0,0,0,0)"),this.drawPriceLine(e,d,n,i,o,s,h,u.area.width);return}case "baseline":this.drawBaseline(e,d,n,i,o,s,t,a,c);return;default:this.drawCandles(e,t,d,n,i,o,s,a,l);}}drawBars(e,t,n,i,o,s,a,l,c){let d=o.bodySpacing(),u=Nr(d);if(u==="aggregate"){this.drawCandlesAggregated(e,t,n,i,o,s,a,l,c);return}let h=Math.max(1,Math.round(d*.35)),p=u==="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),v=o.priceToY(f.high,s.scale,s.bounds),y=o.priceToY(f.low,s.scale,s.bounds);if(e.strokeStyle=b,e.beginPath(),e.moveTo(g,v),e.lineTo(g,y),p){let w=o.priceToY(f.open,s.scale,s.bounds),P=o.priceToY(f.close,s.scale,s.bounds);e.moveTo(g-h,w),e.lineTo(g,w),e.moveTo(g,P),e.lineTo(g+h,P);}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 d=Math.max(0,n-1);d<=i;d+=1){let u=t[d];if(!u){c=false;continue}let h=o.logicalToX(d),p=o.priceToY(u.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,d=[],u=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);d.push({x:f,y:g}),g<u&&(u=g);}if(d.length<2)return;let h=e.createLinearGradient(0,u,0,c);h.addColorStop(0,a),h.addColorStop(1,l),e.fillStyle=h,e.beginPath(),e.moveTo(d[0].x,c);for(let p of d)e.lineTo(p.x,p.y);e.lineTo(d[d.length-1].x,c),e.closePath(),e.fill();}drawBaseline(e,t,n,i,o,s,a,l,c){let d=a.baselinePriceFor(s.scale),u=o.priceToY(d,s.scale,s.bounds),h=s.bounds.top,p=s.bounds.top+s.bounds.height,m=a.style.baseline,f=m.topLineColor??Vr,g=m.bottomLineColor??_r,b=m.topFillColor??W(f,Bt),v=m.topFillColor2??W(f,Ht),y=m.bottomFillColor??W(g,Bt),w=m.bottomFillColor2??W(g,Ht),P=[];for(let E=Math.max(0,n-1);E<=i;E+=1){let L=t[E];L&&P.push({x:o.logicalToX(E),y:o.priceToY(L.close,s.scale,s.bounds)});}if(P.length<2)return;let x=()=>{e.beginPath(),e.moveTo(P[0].x,u);for(let E of P)e.lineTo(E.x,E.y);e.lineTo(P[P.length-1].x,u),e.closePath();};if(u>h){e.save(),e.beginPath(),e.rect(0,h,c,u-h),e.clip();let E=e.createLinearGradient(0,h,0,u);E.addColorStop(0,b),E.addColorStop(1,v),e.fillStyle=E,x(),e.fill(),e.restore();}if(u<p){e.save(),e.beginPath(),e.rect(0,u,c,p-u),e.clip();let E=e.createLinearGradient(0,u,0,p);E.addColorStop(0,w),E.addColorStop(1,y),e.fillStyle=E,x(),e.fill(),e.restore();}e.strokeStyle=a.style.borderColor??l.borderColor,e.lineWidth=1,Wr(e,"dashed"),e.beginPath(),e.moveTo(0,Math.round(u)+.5),e.lineTo(c,Math.round(u)+.5),e.stroke(),Wr(e,"solid"),e.lineWidth=m.width,e.lineJoin="round",e.lineCap="round";let S=(E,L,T,k,M)=>{e.strokeStyle=M,e.beginPath(),e.moveTo(E,L),e.lineTo(T,k),e.stroke();};for(let E=1;E<P.length;E+=1){let L=P[E-1],T=P[E],k=L.y<=u,M=T.y<=u;if(k!==M&&T.y!==L.y){let C=(u-L.y)/(T.y-L.y),I=L.x+(T.x-L.x)*C;S(L.x,L.y,I,u,k?f:g),S(I,u,T.x,T.y,M?f:g);}else S(L.x,L.y,T.x,T.y,k?f:g);}e.lineCap="butt";}drawCandles(e,t,n,i,o,s,a,l,c){let d=s.bodySpacing(),u=Nr(d),h=pl(t.style.candle,t.candleOverride,l.upColor,l.downColor);if(u==="aggregate"){this.drawCandlesAggregated(e,n,i,o,s,a,h.up,h.down,c);return}let p=u==="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 v=ul(s.logicalToX(g),d,s.dpr,this.candleBodyScale),y=v.center,w=b.close>=b.open,P=w?h.up:h.down,x=c.get(b.time),S=x??P,E=0,L=0;if(p){let T=s.priceToY(b.open,a.scale,a.bounds),k=s.priceToY(b.close,a.scale,a.bounds);E=Math.min(T,k),L=Math.max(1,Math.abs(k-T));}if(m.wickVisible){let T=(w?m.wickUpColor:m.wickDownColor)??(p?P:S),k=s.priceToY(b.high,a.scale,a.bounds),M=s.priceToY(b.low,a.scale,a.bounds);e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=T,e.lineWidth=v.wickW,e.beginPath(),p?(e.moveTo(y,k),e.lineTo(y,E),e.moveTo(y,E+L),e.lineTo(y,M)):(e.moveTo(y,k),e.lineTo(y,M)),e.stroke();}if(p&&(m.bodyVisible&&(e.globalAlpha=this.candleBodyAlpha,e.fillStyle=S,e.fillRect(v.bodyX,E,v.bodyW,L)),m.borderVisible||x||f&&m.bodyVisible)){e.globalAlpha=this.candleStructureAlpha,e.strokeStyle=m.borderVisible||x?(w?m.borderUpColor:m.borderDownColor)??P:S,e.lineWidth=1;let T=Math.max(0,v.bodyW-1),k=Math.max(0,L-1);e.strokeRect(v.bodyX+.5,E+.5,T,k);}}}drawCandlesAggregated(e,t,n,i,o,s,a,l,c){let d=NaN,u=1/0,h=-1/0,p=0,m=0,f=0,g=false,b=()=>{if(!g)return;let v=c.get(f)??(m>=p?a:l),y=o.priceToY(h,s.scale,s.bounds),w=o.priceToY(u,s.scale,s.bounds);e.strokeStyle=v,e.lineWidth=1,e.beginPath(),e.moveTo(d,y),e.lineTo(d,w),e.stroke();};for(let v=n;v<=i;v+=1){let y=t[v];if(!y||y.high<=y.low)continue;let w=Math.round(o.logicalToX(v))+.5;!g||w!==d?(b(),d=w,u=y.low,h=y.high,p=y.open,f=y.time,g=true):(y.low<u&&(u=y.low),y.high>h&&(h=y.high)),m=y.close;}b();}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(!(!be(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",Wr(e,t.style.lineStyle);let c=0,d=0,u=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){u=false;continue}let f=i.logicalToX(h),g=i.priceToY(p.value,n.scale,n.bounds);u||(c=i.logicalToX(h-1),d=i.priceToY(m.value,n.scale,n.bounds)),e.strokeStyle=p.color??t.style.color,e.beginPath(),e.moveTo(c,d),a&&e.lineTo(f,d),e.lineTo(f,g),e.stroke(),c=f,d=g,u=true;}Wr(e,"solid");}drawArea(e,t,n,i,o,s,a=0){let l=n.bounds.top+n.bounds.height,c=[],d=1/0,u=()=>{if(c.length===0)return;let h=e.createLinearGradient(0,d,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=[],d=1/0;};for(let h=o;h<=s;h+=1){let p=t.points[h-a];if(!p||p.value===null){u();continue}let m=i.logicalToX(h),f=i.priceToY(p.value,n.scale,n.bounds);c.push({x:m,y:f}),f<d&&(d=f);}u();}drawHistogram(e,t,n,i,o,s,a=0){let l=i.bodySpacing(),c=Math.max(1,(t.kind==="columns"?.7:.8)*l),d=c/2,u=t.style.base??0,h=i.priceToY(u,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-d,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 d=t.points[c-a];if(!d||d.value===null)continue;let u=i.logicalToX(c),h=i.priceToY(d.value,n.scale,n.bounds);e.strokeStyle=d.color??t.style.color,e.fillStyle=d.color??t.style.color,t.kind==="cross"?(e.lineWidth=1,e.beginPath(),e.moveTo(u-l,h),e.lineTo(u+l,h),e.moveTo(u,h-l),e.lineTo(u,h+l),e.stroke()):(e.beginPath(),e.arc(u,h,l,0,Math.PI*2),e.fill());}}drawPlotCandles(e,t,n,i,o,s,a,l=0){let c=i.bodySpacing(),d=t.style?.up??a.upColor,u=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],v=b?.color??(g.close>=g.open?d:u),y=Math.round(i.logicalToX(f))+.5,w=i.priceToY(g.high,n.scale,n.bounds),P=i.priceToY(g.low,n.scale,n.bounds),x=i.priceToY(g.open,n.scale,n.bounds),S=i.priceToY(g.close,n.scale,n.bounds);if(h){e.strokeStyle=v,e.lineWidth=1,e.beginPath(),e.moveTo(y,w),e.lineTo(y,P),e.moveTo(y-m,x),e.lineTo(y,x),e.moveTo(y,S),e.lineTo(y+m,S),e.stroke();continue}e.strokeStyle=b?.wickColor??v,e.lineWidth=lo(c),e.beginPath(),e.moveTo(y,w),e.lineTo(y,P),e.stroke(),e.fillStyle=v,e.fillRect(y-p,Math.min(x,S),p*2,Math.max(1,Math.abs(S-x))),b?.borderColor&&(e.strokeStyle=b.borderColor,e.strokeRect(y-p,Math.min(x,S),p*2,Math.max(1,Math.abs(S-x))));}}drawFill(e,t,n,i,o,s,a,l=0){let c=qb(t,n.fromSeriesId),d=qb(t,n.toSeriesId);if(!c||!d)return;let u=NaN,h=NaN,p="",m="",f=null;for(let g=Math.max(1,s);g<=a;g+=1){let b=c[g-1-l],v=d[g-1-l],y=c[g-l],w=d[g-l];if(!b||!v||!y||!w||b.value===null||v.value===null||y.value===null||w.value===null)continue;let P=o.logicalToX(g-1),x=o.logicalToX(g),S=o.priceToY(b.value,i.scale,i.bounds),E=o.priceToY(v.value,i.scale,i.bounds),L=o.priceToY(y.value,i.scale,i.bounds),T=o.priceToY(w.value,i.scale,i.bounds),k=n.gradient?.[g-1-l];if(k){let M=o.priceToY(k.topValue,i.scale,i.bounds),C=o.priceToY(k.bottomValue,i.scale,i.bounds),I=C===M?M+1:C;(!f||M!==u||I!==h||k.topColor!==p||k.bottomColor!==m)&&(f=e.createLinearGradient(0,M,0,I),f.addColorStop(0,k.topColor),f.addColorStop(1,k.bottomColor),u=M,h=I,p=k.topColor,m=k.bottomColor),e.fillStyle=f;}else {let M=n.colors?n.colors[g-1-l]:n.color;if(!M)continue;e.fillStyle=M;}e.beginPath(),e.moveTo(P,S),e.lineTo(x,L),e.lineTo(x,T),e.lineTo(P,E),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,Wr(e,t.lineStyle??"solid"),e.beginPath(),e.moveTo(0,a),e.lineTo(o,a),e.stroke(),Wr(e,"solid"));}};function Wr(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function qb(r,e){let t=r.series.find(n=>n.id===e);return t&&be(t)?t.points:null}var XT=new Map;function jT(r){let e=false;for(let n of r.values())if(n.barColors&&n.barColors.length>0){e=true;break}if(!e)return XT;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 Gr(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 d=(n-e)/a,u=m=>e+d*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,u(h),p,u(p)]}function Zb(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 qT(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 ZT(r,e,t){return (.299*r+.587*e+.114*t)/255}function Ne(r){if(!r)return "#000000";let e=qT(r);return e?ZT(e.r,e.g,e.b)>.55?"#000000":"#ffffff":"#000000"}function St(r){return Math.round(r*1.4)}var Xn=5,jn=3;function ye(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 Jb(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 JT={lines:[],boxes:[],labels:[],polylines:[],linefills:[]};function Qb(r){return r==="auto"?12:ye(r)}var El=class{constructor(e,t=JT){this.deps=e;this.set=t;this.widthCache=new Map;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}render(e,t,n,i,o){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=(u,h,p)=>p!=="none"?true:Math.max(u,h)>=n&&Math.min(u,h)<=i,s=1/0,a=-1/0,l=u=>{u<s&&(s=u),u>a&&(a=u);};for(let u of this.set.lines)u.invisible||o(this.logicalOf(u.xloc,u.x1),this.logicalOf(u.xloc,u.x2),u.extend)&&(l(u.y1),l(u.y2));for(let u of this.set.boxes)!u.bgColor&&!(u.borderColor&&u.borderWidth>0)&&!u.text||o(this.logicalOf(u.xloc,u.left),this.logicalOf(u.xloc,u.right),u.extend)&&(l(u.top),l(u.bottom));for(let u of this.set.linefills){if(!u.color)continue;let h=[u.line1.x1,u.line1.x2,u.line2.x1,u.line2.x2].map((m,f)=>this.logicalOf(f<2?u.line1.xloc:u.line2.xloc,m)),p=u.line1.extend!=="none"||u.line2.extend!=="none"?"both":"none";o(Math.min(...h),Math.max(...h),p)&&(l(u.line1.y1),l(u.line1.y2),l(u.line2.y1),l(u.line2.y2));}for(let u of this.set.polylines){if(u.points.length<2)continue;let h=u.points.map(p=>this.logicalOf(p.xloc,p.x));if(o(Math.min(...h),Math.max(...h),"none"))for(let p of u.points)l(p.price);}let c=0,d=0;for(let u of this.set.labels){let h=this.logicalOf(u.xloc,u.x);if(!o(h,h,"none"))continue;if(u.yloc==="price"){l(u.y);continue}if(u.yloc==="top"||u.yloc==="bottom")continue;let p=this.deps.barAt(h);if(!p)continue;l(u.yloc==="abovebar"?p.high:p.low);let m=Qb(u.size),f=Math.max(1,(u.text??"").split(`
|
|
765
765
|
`).length),g=this.isPointShape(u.style)?14+Math.max(4,m*.6)+2:14+m*1.25*f+8+7;u.yloc==="abovebar"?c=Math.max(c,g):d=Math.max(d,g);}return !Number.isFinite(s)||!Number.isFinite(a)?null:{min:s,max:a,aboveMargin:c,belowMargin:d}}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),d=o(s.y2);if(c===null||d===null)continue;let u=s.extend==="left"||s.extend==="both",h=s.extend==="right"||s.extend==="both";if(!u&&!h&&(Math.max(a,l)<0||Math.min(a,l)>t))continue;let[p,m,f,g]=Gr(a,c,l,d,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(Kn(s.style,s.width)),e.stroke(),e.setLineDash([]);let v=l>=a;if(s.arrowRight){let y=(v?h:u)?v?[f,g]:[p,m]:[l,d];this.drawArrow(e,y[0],y[1],a,c,s.width,b);}if(s.arrowLeft){let y=(v?u:h)?v?[p,m]:[f,g]:[a,c];this.drawArrow(e,y[0],y[1],l,d,s.width,b);}}}drawArrow(e,t,n,i,o,s,a){let l=Math.atan2(n-o,t-i),c=6+s*2,d=.45;e.beginPath(),e.moveTo(t,n),e.lineTo(t-c*Math.cos(l-d),n-c*Math.sin(l-d)),e.lineTo(t-c*Math.cos(l+d),n-c*Math.sin(l+d)),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,d=c(a),u=c(l);e.beginPath(),e.moveTo(d[0],d[1]),e.lineTo(d[2],d[3]),e.lineTo(u[2],u[3]),e.lineTo(u[0],u[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:Gr(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 d=i(c.price);d!==null&&s.push([n(this.logicalOf(c.xloc,c.x)),d]);}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(Kn(o.lineStyle,o.lineWidth)),e.stroke(),e.setLineDash([]),o.arrowLeft||o.arrowRight)){let c=o.closed?s.length:s.length-1;for(let d=0;d<c;d+=1){let u=s[d],h=s[(d+1)%s.length];o.arrowRight&&this.drawArrow(e,h[0],h[1],u[0],u[1],o.lineWidth,o.lineColor),o.arrowLeft&&this.drawArrow(e,u[0],u[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),d=o(a+1),u=o(a+2),h=c[0]+(d[0]-l[0])/6,p=c[1]+(d[1]-l[1])/6,m=d[0]-(u[0]-c[0])/6,f=d[1]-(u[1]-c[1])/6;e.bezierCurveTo(h,p,m,f,d[0],d[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),d=o(s.bottom);if(c===null||d===null)continue;let u=Math.min(a,l),h=Math.max(a,l),p=Math.min(c,d),m=Math.max(c,d),f=h-u,g=m-p;h<0||u>t||m<0||p>n||(s.bgColor&&(e.fillStyle=s.bgColor,e.fillRect(u,p,f,g)),s.borderColor&&s.borderWidth>0&&(e.strokeStyle=s.borderColor,e.lineWidth=s.borderWidth,e.setLineDash(Kn(s.borderStyle,s.borderWidth)),e.strokeRect(u,p,f,g),e.setLineDash([])),s.text&&this.drawBoxText(e,s,u,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(`
|
|
766
766
|
`)){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 ":""}`,d=4,u=ye(t.textSize),h;if(u===0){let b=`${c}14px ${l}`;h=t.wrap?this.wrapText(e,b,a,Math.max(1,o-d*2)):a.split(`
|
|
767
|
-
`),u=
|
|
768
|
-
`);}e.font=`${c}${u}px ${l}`,e.fillStyle=t.textColor??Ne(t.bgColor);let p=u*1.3,m=p*h.length,f;t.hAlign==="left"?(e.textAlign="left",f=n+d):t.hAlign==="right"?(e.textAlign="right",f=n+o-d):(e.textAlign="center",f=n+o/2),e.textBaseline="top";let g;t.vAlign==="top"?g=i+d:t.vAlign==="bottom"?g=i+s-d-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 u=this.deps.barAt(this.logicalOf(s.xloc,s.x));if(!u)continue;let h=o(s.yloc==="abovebar"?u.high:u.low);l=h===null?null:h+(s.yloc==="abovebar"?-14:14);}if(l===null)continue;let c=s.color??this.deps.theme.textColor,d=
|
|
767
|
+
`),u=Jb(h,o,s,t.bold);}else {let b=`${c}${u}px ${l}`;h=t.wrap?this.wrapText(e,b,a,Math.max(1,o-d*2)):a.split(`
|
|
768
|
+
`);}e.font=`${c}${u}px ${l}`,e.fillStyle=t.textColor??Ne(t.bgColor);let p=u*1.3,m=p*h.length,f;t.hAlign==="left"?(e.textAlign="left",f=n+d):t.hAlign==="right"?(e.textAlign="right",f=n+o-d):(e.textAlign="center",f=n+o/2),e.textBaseline="top";let g;t.vAlign==="top"?g=i+d:t.vAlign==="bottom"?g=i+s-d-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 u=this.deps.barAt(this.logicalOf(s.xloc,s.x));if(!u)continue;let h=o(s.yloc==="abovebar"?u.high:u.low);l=h===null?null:h+(s.yloc==="abovebar"?-14:14);}if(l===null)continue;let c=s.color??this.deps.theme.textColor,d=Qb(s.size);this.isPointShape(s.style)?(s.noFill||this.drawLabelShape(e,s.style,a,l,d,c),s.text&&this.drawLabelText(e,s,a,l+d,d)):s.style==="none"||s.style==="text_outline"||s.noFill?s.text&&this.drawLabelText(e,s,a,l,d,s.style==="text_outline"):this.drawBubble(e,s,a,l,d,c);}}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){let a=t.fontFamily==="monospace"?"monospace":this.deps.theme.fontFamily||"sans-serif";e.font=`${o}px ${a}`,e.textAlign=t.textAlign==="left"?"left":t.textAlign==="right"?"right":"center",e.textBaseline="middle";let l=t.text.split(`
|
|
769
769
|
`),c=o*1.25,d=i-c*(l.length-1)/2;if(s){e.lineWidth=3,e.strokeStyle=Ne(t.textColor??this.deps.theme.textColor);for(let u=0;u<l.length;u+=1)e.strokeText(l[u],n,d+u*c);}e.fillStyle=t.textColor??this.deps.theme.textColor;for(let u=0;u<l.length;u+=1)e.fillText(l[u],n,d+u*c);}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){let a=t.fontFamily==="monospace"?"monospace":this.deps.theme.fontFamily||"sans-serif";e.font=`${o}px ${a}`;let l=(t.text??"").split(`
|
|
770
|
-
`),c=6,d=4,u=o*1.25,p=Math.max(1,...l.map(y=>this.measure(e,e.font,y)))+c*2,m=u*l.length+d*2,f=7,g=n-p/2,b=i-m-f,v="down";switch(t.style){case "label_up":g=n-p/2,b=i+f,v="up";break;case "label_left":g=n+f,b=i-m/2,v="left";break;case "label_right":g=n-p-f,b=i-m/2,v="right";break;case "label_center":g=n-p/2,b=i-m/2,v="none";break;case "label_lower_left":g=n+f,b=i-m-f,v="none";break;case "label_lower_right":g=n-p-f,b=i-m-f,v="none";break;case "label_upper_left":g=n+f,b=i+f,v="none";break;case "label_upper_right":g=n-p-f,b=i+f,v="none";break;default:g=n-p/2,b=i-m-f,v="down";}if(e.fillStyle=s,this.roundRect(e,g,b,p,m,4),e.fill(),v!=="none"&&(e.beginPath(),v==="down"?(e.moveTo(n-f,b+m),e.lineTo(n+f,b+m),e.lineTo(n,i)):v==="up"?(e.moveTo(n-f,b),e.lineTo(n+f,b),e.lineTo(n,i)):v==="left"?(e.moveTo(g,i-f),e.lineTo(g,i+f),e.lineTo(n,i)):(e.moveTo(g+p,i-f),e.lineTo(g+p,i+f),e.lineTo(n,i)),e.closePath(),e.fill()),t.text){e.fillStyle=t.textColor??Ne(s),e.textAlign="center",e.textBaseline="middle";let y=b+d+u/2;for(let w=0;w<l.length;w+=1)e.fillText(l[w],g+p/2,y+w*u);}}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 El(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 d=c;d<=e+s*1e-6;d+=s)l.push(Number(d.toFixed(a)));return l}function KT(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 XT(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 El(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 ru(r){let e=Math.abs(r);return e>=100?0:e>=1?2:e>=.01?4:6}function jT(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 qT(r,e,t){let n=t!=null&&t>0?jT(t):KT(r.min,r.max,ho(e));return n===0?2:n}function ho(r){return Math.max(2,Math.min(16,Math.round(r/50)))}function qb(r,e){return r.log?XT(r.min,r.max,ho(e)):El(r.min,r.max,ho(e))}function tu(r,e){return (r/e-1)*100}function nu(r,e){return r/e*100}function Qb(r){return `${r>=0?"+":"-"}${Math.abs(r).toFixed(2)}%`}function ev(r){return r.toFixed(2)}function tv(r){let e=Math.abs(r);return e>=1e9?`${Tl(r/1e9)}B`:e>=1e6?`${Tl(r/1e6)}M`:e>=1e3?`${Tl(r/1e3)}K`:Tl(r)}function Tl(r){return Number(r.toFixed(2)).toString()}function po(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 u=nu(a,o),h=nu(l,o);return El(u,h,ho(e)).map(p=>({price:o*p/100,label:ev(p)}))}let c=tu(a,o),d=tu(l,o);return El(c,d,ho(e)).map(u=>({price:o*(1+u/100),label:Qb(u)}))}return i==="volume"?qb(r,e).map(o=>({price:o,label:tv(o)})):qb(r,e).map(o=>({price:o,label:Pl(r,e,o,n)}))}function mo(r,e,t,n,i,o){return o==="none"?"":n?n.indexed?ev(nu(t,n.baseline)):Qb(tu(t,n.baseline)):o==="volume"?tv(t):Pl(r,e,t,i)}function Pl(r,e,t,n){if(r.log&&Math.log10(r.max)-Math.log10(r.min)>=1.1){let o=ru(t);return t.toFixed(o===0?2:o)}return t.toFixed(qT(r,e,n))}var co=1e3,uo=60*co,Ur=60*uo,Yr=24*Ur,ZT=7*Yr,Zb=30*Yr,nv=365*Yr,Qd=[co,5*co,15*co,30*co,uo,5*uo,15*uo,30*uo,Ur,2*Ur,4*Ur,6*Ur,12*Ur,Yr,2*Yr,ZT,Zb,3*Zb,nv],eu=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Jb=r=>r<10?`0${r}`:String(r);function JT(r){for(let e of Qd)if(e>=r)return e;return Qd[Qd.length-1]}function Ll(r,e,t=8,n=0){let i=e-r;if(!(i>0))return [];let o=JT(i/Math.max(1,t)),s=r+n,a=e+n,l=Math.ceil(s/o)*o,c=[];for(let d=l;d<=a;d+=o){let u=d-n,h=new Date(d),p,m=false;if(o<Yr){let f=h.getUTCHours(),g=h.getUTCMinutes();f===0&&g===0?(p=`${eu[h.getUTCMonth()]} ${h.getUTCDate()}`,m=true):p=`${Jb(f)}:${Jb(g)}`;}else o<nv?(p=`${eu[h.getUTCMonth()]} ${h.getUTCDate()}`,h.getUTCDate()===1&&(p=eu[h.getUTCMonth()],m=true)):(p=String(h.getUTCFullYear()),m=true);c.push({time:u,label:p,major:m});}return c}function fo(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 Ml(r,e){return new Date(r+fo(r,e))}var kl=class{constructor(){this.canvas=null;this.ctx=null;this.axisTextColor=ut.textColor;this.drawScene=new Cl({timeToLogical:()=>0,barAt:()=>null,theme:{}});}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}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=rv(o,this.drawingsRange(this.ownDrawings(s),i,t.offsetOf(s.id)));if(n)for(let s of t.indicators.values())o=rv(o,this.drawingsRange(this.overlayDrawings(s),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,d=t.width,u=t.height;this.axisTextColor=i?.textColor??n.textColor,o.setTransform(a,0,0,a,0,0),o.clearRect(0,0,l,c),i&&(l>d||c>u)&&(o.fillStyle=i.background,l>d&&o.fillRect(d,0,l-d,c),c>u&&o.fillRect(0,u,d,c-u)),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);return}let p=h.find(m=>m.kind==="price")??null;for(let m of h)if(!m.collapsed)for(let f of e.indicatorsForPane(m.id)){let g=e.scaleFor(f,m),b=g===m.scale?m:{...m,scale:g};this.renderDrawings(o,t,this.ownDrawings(f),b,d,e.offsetOf(f.id));}if(p)for(let m of e.indicators.values())this.renderDrawings(o,t,this.overlayDrawings(m),p,d,e.offsetOf(m.id));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,d);this.drawPriceAxes(o,e,t,n,d,h),this.drawMergedScaleColumns(o,e,t,d),this.drawPaneSeparators(o,e,n,l,h),this.drawPriceLineAndCountdown(o,e,t,n,d,p),this.drawTimeAxis(o,e,t,n,d,u,c);}destroy(){this.canvas=null,this.ctx=null;}ownDrawings(e){return {lines:(e.lines??[]).filter(t=>!t.overlay),boxes:(e.boxes??[]).filter(t=>!t.overlay),labels:(e.labels??[]).filter(t=>!t.overlay),polylines:(e.polylines??[]).filter(t=>!t.overlay),linefills:(e.linefills??[]).filter(t=>!t.overlay)}}overlayDrawings(e){return {lines:(e.lines??[]).filter(t=>t.overlay),boxes:(e.boxes??[]).filter(t=>t.overlay),labels:(e.labels??[]).filter(t=>t.overlay),polylines:(e.polylines??[]).filter(t=>t.overlay),linefills:(e.linefills??[]).filter(t=>t.overlay)}}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(),Ub(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();}renderDrawings(e,t,n,i,o,s=0){this.drawScene.setSet(n,s),!this.drawScene.isEmpty()&&(e.save(),e.translate(0,i.bounds.top),e.beginPath(),e.rect(0,0,o,i.bounds.height),e.clip(),this.drawScene.render(e,o,i.bounds.height,a=>t.logicalToX(a),a=>t.priceToY(a,i.scale,i.bounds)-i.bounds.top),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=$t(t,a);for(let c of po(a.scale,a.bounds.height,l,t.priceMintick,a.axisFormat)){let d=n.priceToY(c.price,a.scale,a.bounds);d<a.bounds.top+6||d>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,d);}if(a.axisBands)for(let c of a.axisBands){let d=a.bounds.top+c.frac*a.bounds.height;d<a.bounds.top+6||d>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,d);}}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 d=hb(i,l+1);for(let u of po(c,o.bounds.height,void 0,t.priceMintick)){let h=n.priceToY(u.price,c,o.bounds);h<o.bounds.top+6||h>o.bounds.top+o.bounds.height-4||e.fillText(u.label,d+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 d=this.priceElementColor(t,n,i,l);if(t.showPriceLine){let P=Math.round(c)+.5;e.strokeStyle=d,e.lineWidth=1,iv(e,"dotted"),e.beginPath(),e.moveTo(0,P),e.lineTo(o,P),e.stroke(),iv(e,"solid");}let u=n.barInterval,h=t.showCountdown&&u>0,p=t.showPriceLabel;if(!p&&!h)return;let m=mo(s.scale,s.bounds.height,l.close,$t(t,s),t.priceMintick),f=h?tE(l.time+u-Date.now()):"",g=8,b=o+1,v=eE(d,i.background);if(e.textBaseline="middle",p&&h){let P=Math.max(e.measureText(m).width,e.measureText(f).width)+g,x=c-8,S=b+g/2;e.fillStyle=d,e.fillRect(b,x,P,32),e.fillStyle=v,e.textAlign="left",e.fillText(m,S,x+8),e.fillText(f,S,x+24),e.textAlign="start";return}let y=p?m:f,w=e.measureText(y).width+g;e.fillStyle=d,e.fillRect(b,c-8,w,16),e.fillStyle=v,e.textAlign="center",e.fillText(y,b+w/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(),d=fo((c.from+c.to)/2,t.timezone),u=Math.max(3,Math.min(8,Math.floor(o/64))),h=Ll(c.from,c.to,u,d).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,v=g.x+g.half;m.every(y=>v+p<=y.l||b-p>=y.r)&&(m.push({l:b,r:v}),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 rv(r,e){return r?e?{min:Math.min(r.min,e.min),max:Math.max(r.max,e.max)}:r:e}function iv(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function eE(r,e){let[t,n,i,o]=G(r),s=t,a=n,l=i;if(o<1){let[u,h,p]=G(e);s=t*o+u*(1-o),a=n*o+h*(1-o),l=i*o+p*(1-o);}let c=u=>u<=.04045?u/12.92:Math.pow((u+.055)/1.055,2.4);return .2126*c(s)+.7152*c(a)+.0722*c(l)>=.4?"#000000":"#ffffff"}function tE(r){let e=Math.max(0,Math.floor(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)}`}var Il=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,d=t.width,u=t.height;if(!c||c.x<0||c.x>d||c.y<0||c.y>u)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,ov(s,h.style),s.beginPath(),s.moveTo(m,0),s.lineTo(m,u),s.moveTo(0,Math.round(c.y)+.5),s.lineTo(d,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,d+1,c.y,mo(f.scale,f.bounds.height,b,$t(e,f),e.priceMintick,f.axisFormat),g,"left",false,n.background);}this.chip(s,m,u+1,sv(t.logicalToTime(p),e.timezone),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,ov(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 d=s.labelBackground??o.borderColor;if(t.y!=null&&t.price!=null){let u;for(let h of n.panes.values())if(t.y>=h.bounds.top&&t.y<=h.bounds.top+h.bounds.height){u=h;break}u&&u.axisFormat!=="none"&&this.chip(e,a+1,t.y,mo(u.scale,u.bounds.height,t.price,$t(n,u),n.priceMintick,u.axisFormat),d,"left",false,o.background);}this.chip(e,c,l+1,sv(t.time,n.timezone),d,"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,d=16,u=s==="left"?t:t-c/2,h=a?n:n-d/2;e.fillStyle=o,e.fillRect(u,h,c,d),e.fillStyle=Eb(o,l),e.textAlign="center",e.fillText(i,u+c/2,h+d/2+(a?2:0)),e.textAlign="start";}};function ov(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function sv(r,e){let t=Ml(r,e),n=i=>i<10?`0${i}`:String(i);return `${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}var iu=[{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 Al(r){return r==="UTC"||r==="Etc/UTC"||r==="Etc/GMT"?"Etc/UTC":r}function nE(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 ou(r,e){return Al(r)==="Etc/UTC"?e:`(${nE(r)}) ${e}`}function qn(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Xe(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 av(r){if(r.kind==="heading"||r.kind==="header")return qn(r.label);let e=cr(r);if(e.toggle)return e.toggle.key;for(let t of e.controls)if(t.kind!=="hint")return t.key;return qn(e.label)}function Rl(r,e,t){if(t.size===0)return [...r];let n=[],i=false,o=false;for(let s of r){let a=`${e}.${av(s)}`;if(s.kind==="heading"){i=Xe(a,t),o=false,i||n.push(s);continue}if(s.kind==="header"){if(i)continue;o=Xe(a,t),o||n.push(s);continue}i||o||Xe(a,t)||n.push(s);}return n}function su(r){return r.id??qn(r.title)}function lv(r){return r.id??qn(r.label)}function cv(r,e,t){if(t.size===0)return [...r];let n=[],i=false;for(let o of r){let s=`${e}.${lv(o)}`;if(o.kind==="heading"){i=Xe(s,t),i||n.push(o);continue}i||Xe(s,t)||n.push(o);}return n}var rE=["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.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 dv(r){let e=new Set(rE);for(let t of Je()){if(so(t.id)){let s=`symbol.style.${t.id}`;for(let a of ["",".body",".borders",".wick",".spacing"])e.add(s+a);}let n=t.settings;if(!n)continue;let i=`type:${t.id}`;e.add(i);let o=s=>{for(let a of s)e.add(`${i}.${av(a)}`);};n.rows&&o(n.rows);for(let s of n.instances??[])o(s.rows);for(let s of n.subsections??[])e.add(`${i}.${qn(s.title)}`),o(s.rows);}for(let t of r){let n=su(t);e.add(n);for(let i of t.rows)e.add(`${n}.${lv(i)}`);}return [...e]}var iE={candles:"Candles",bars:"Bars",line:"Line",area:"Area",baseline:"Baseline"};function oE(r){return kt(r)?.label??iE[r]??r}var uv="vela-settings-controls",hv="5";var sE="var(--vela-border)";function aE(){if(typeof document>"u")return;let r=document.getElementById(uv);if(r?.dataset.rev===hv)return;let e=r??document.createElement("style");e.id=uv,e.dataset.rev=hv,e.textContent=`
|
|
770
|
+
`),c=6,d=4,u=o*1.25,p=Math.max(1,...l.map(y=>this.measure(e,e.font,y)))+c*2,m=u*l.length+d*2,f=7,g=n-p/2,b=i-m-f,v="down";switch(t.style){case "label_up":g=n-p/2,b=i+f,v="up";break;case "label_left":g=n+f,b=i-m/2,v="left";break;case "label_right":g=n-p-f,b=i-m/2,v="right";break;case "label_center":g=n-p/2,b=i-m/2,v="none";break;case "label_lower_left":g=n+f,b=i-m-f,v="none";break;case "label_lower_right":g=n-p-f,b=i-m-f,v="none";break;case "label_upper_left":g=n+f,b=i+f,v="none";break;case "label_upper_right":g=n-p-f,b=i+f,v="none";break;default:g=n-p/2,b=i-m-f,v="down";}if(e.fillStyle=s,this.roundRect(e,g,b,p,m,4),e.fill(),v!=="none"&&(e.beginPath(),v==="down"?(e.moveTo(n-f,b+m),e.lineTo(n+f,b+m),e.lineTo(n,i)):v==="up"?(e.moveTo(n-f,b),e.lineTo(n+f,b),e.lineTo(n,i)):v==="left"?(e.moveTo(g,i-f),e.lineTo(g,i+f),e.lineTo(n,i)):(e.moveTo(g+p,i-f),e.lineTo(g+p,i+f),e.lineTo(n,i)),e.closePath(),e.fill()),t.text){e.fillStyle=t.textColor??Ne(s),e.textAlign="center",e.textBaseline="middle";let y=b+d+u/2;for(let w=0;w<l.length;w+=1)e.fillText(l[w],g+p/2,y+w*u);}}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 Ll(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 d=c;d<=e+s*1e-6;d+=s)l.push(Number(d.toFixed(a)));return l}function QT(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 eE(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 Ll(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 su(r){let e=Math.abs(r);return e>=100?0:e>=1?2:e>=.01?4:6}function tE(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 nE(r,e,t){let n=t!=null&&t>0?tE(t):QT(r.min,r.max,fo(e));return n===0?2:n}function fo(r){return Math.max(2,Math.min(16,Math.round(r/50)))}function ev(r,e){return r.log?eE(r.min,r.max,fo(e)):Ll(r.min,r.max,fo(e))}function iu(r,e){return (r/e-1)*100}function ou(r,e){return r/e*100}function rv(r){return `${r>=0?"+":"-"}${Math.abs(r).toFixed(2)}%`}function iv(r){return r.toFixed(2)}function ov(r){let e=Math.abs(r);return e>=1e9?`${Pl(r/1e9)}B`:e>=1e6?`${Pl(r/1e6)}M`:e>=1e3?`${Pl(r/1e3)}K`:Pl(r)}function Pl(r){return Number(r.toFixed(2)).toString()}function go(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 u=ou(a,o),h=ou(l,o);return Ll(u,h,fo(e)).map(p=>({price:o*p/100,label:iv(p)}))}let c=iu(a,o),d=iu(l,o);return Ll(c,d,fo(e)).map(u=>({price:o*(1+u/100),label:rv(u)}))}return i==="volume"?ev(r,e).map(o=>({price:o,label:ov(o)})):ev(r,e).map(o=>({price:o,label:Ml(r,e,o,n)}))}function bo(r,e,t,n,i,o){return o==="none"?"":n?n.indexed?iv(ou(t,n.baseline)):rv(iu(t,n.baseline)):o==="volume"?ov(t):Ml(r,e,t,i)}function Ml(r,e,t,n){if(r.log&&Math.log10(r.max)-Math.log10(r.min)>=1.1){let o=su(t);return t.toFixed(o===0?2:o)}return t.toFixed(nE(r,e,n))}var po=1e3,mo=60*po,Ur=60*mo,Yr=24*Ur,rE=7*Yr,tv=30*Yr,sv=365*Yr,nu=[po,5*po,15*po,30*po,mo,5*mo,15*mo,30*mo,Ur,2*Ur,4*Ur,6*Ur,12*Ur,Yr,2*Yr,rE,tv,3*tv,sv],ru=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],nv=r=>r<10?`0${r}`:String(r);function iE(r){for(let e of nu)if(e>=r)return e;return nu[nu.length-1]}function kl(r,e,t=8,n=0){let i=e-r;if(!(i>0))return [];let o=iE(i/Math.max(1,t)),s=r+n,a=e+n,l=Math.ceil(s/o)*o,c=[];for(let d=l;d<=a;d+=o){let u=d-n,h=new Date(d),p,m=false;if(o<Yr){let f=h.getUTCHours(),g=h.getUTCMinutes();f===0&&g===0?(p=`${ru[h.getUTCMonth()]} ${h.getUTCDate()}`,m=true):p=`${nv(f)}:${nv(g)}`;}else o<sv?(p=`${ru[h.getUTCMonth()]} ${h.getUTCDate()}`,h.getUTCDate()===1&&(p=ru[h.getUTCMonth()],m=true)):(p=String(h.getUTCFullYear()),m=true);c.push({time:u,label:p,major:m});}return c}function vo(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 Il(r,e){return new Date(r+vo(r,e))}var Al=class{constructor(){this.canvas=null;this.ctx=null;this.axisTextColor=ht.textColor;this.drawScene=new El({timeToLogical:()=>0,barAt:()=>null,theme:{}});}mount(e){this.canvas=e,this.ctx=e.getContext("2d");}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=av(o,this.drawingsRange(this.ownDrawings(s),i,t.offsetOf(s.id)));if(n)for(let s of t.indicators.values())o=av(o,this.drawingsRange(this.overlayDrawings(s),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,d=t.width,u=t.height;this.axisTextColor=i?.textColor??n.textColor,o.setTransform(a,0,0,a,0,0),o.clearRect(0,0,l,c),i&&(l>d||c>u)&&(o.fillStyle=i.background,l>d&&o.fillRect(d,0,l-d,c),c>u&&o.fillRect(0,u,d,c-u)),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);return}let p=h.find(m=>m.kind==="price")??null;for(let m of h)if(!m.collapsed)for(let f of e.indicatorsForPane(m.id)){let g=e.scaleFor(f,m),b=g===m.scale?m:{...m,scale:g};this.renderDrawings(o,t,this.ownDrawings(f),b,d,e.offsetOf(f.id));}if(p)for(let m of e.indicators.values())this.renderDrawings(o,t,this.overlayDrawings(m),p,d,e.offsetOf(m.id));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,d);this.drawPriceAxes(o,e,t,n,d,h),this.drawMergedScaleColumns(o,e,t,d),this.drawPaneSeparators(o,e,n,l,h),this.drawPriceLineAndCountdown(o,e,t,n,d,p),this.drawTimeAxis(o,e,t,n,d,u,c);}destroy(){this.canvas=null,this.ctx=null;}ownDrawings(e){return {lines:(e.lines??[]).filter(t=>!t.overlay),boxes:(e.boxes??[]).filter(t=>!t.overlay),labels:(e.labels??[]).filter(t=>!t.overlay),polylines:(e.polylines??[]).filter(t=>!t.overlay),linefills:(e.linefills??[]).filter(t=>!t.overlay)}}overlayDrawings(e){return {lines:(e.lines??[]).filter(t=>t.overlay),boxes:(e.boxes??[]).filter(t=>t.overlay),labels:(e.labels??[]).filter(t=>t.overlay),polylines:(e.polylines??[]).filter(t=>t.overlay),linefills:(e.linefills??[]).filter(t=>t.overlay)}}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(),jb(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();}renderDrawings(e,t,n,i,o,s=0){this.drawScene.setSet(n,s),!this.drawScene.isEmpty()&&(e.save(),e.translate(0,i.bounds.top),e.beginPath(),e.rect(0,0,o,i.bounds.height),e.clip(),this.drawScene.render(e,o,i.bounds.height,a=>t.logicalToX(a),a=>t.priceToY(a,i.scale,i.bounds)-i.bounds.top),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=$t(t,a);for(let c of go(a.scale,a.bounds.height,l,t.priceMintick,a.axisFormat)){let d=n.priceToY(c.price,a.scale,a.bounds);d<a.bounds.top+6||d>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,d);}if(a.axisBands)for(let c of a.axisBands){let d=a.bounds.top+c.frac*a.bounds.height;d<a.bounds.top+6||d>a.bounds.top+a.bounds.height-4||e.fillText(c.label,o+6,d);}}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 d=gb(i,l+1);for(let u of go(c,o.bounds.height,void 0,t.priceMintick)){let h=n.priceToY(u.price,c,o.bounds);h<o.bounds.top+6||h>o.bounds.top+o.bounds.height-4||e.fillText(u.label,d+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 d=this.priceElementColor(t,n,i,l);if(t.showPriceLine){let P=Math.round(c)+.5;e.strokeStyle=d,e.lineWidth=1,lv(e,"dotted"),e.beginPath(),e.moveTo(0,P),e.lineTo(o,P),e.stroke(),lv(e,"solid");}let u=n.barInterval,h=t.showCountdown&&u>0,p=t.showPriceLabel;if(!p&&!h)return;let m=bo(s.scale,s.bounds.height,l.close,$t(t,s),t.priceMintick),f=h?aE(l.time+u-Date.now()):"",g=8,b=o+1,v=sE(d,i.background);if(e.textBaseline="middle",p&&h){let P=Math.max(e.measureText(m).width,e.measureText(f).width)+g,x=c-8,S=b+g/2;e.fillStyle=d,e.fillRect(b,x,P,32),e.fillStyle=v,e.textAlign="left",e.fillText(m,S,x+8),e.fillText(f,S,x+24),e.textAlign="start";return}let y=p?m:f,w=e.measureText(y).width+g;e.fillStyle=d,e.fillRect(b,c-8,w,16),e.fillStyle=v,e.textAlign="center",e.fillText(y,b+w/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(),d=vo((c.from+c.to)/2,t.timezone),u=Math.max(3,Math.min(8,Math.floor(o/64))),h=kl(c.from,c.to,u,d).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,v=g.x+g.half;m.every(y=>v+p<=y.l||b-p>=y.r)&&(m.push({l:b,r:v}),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 av(r,e){return r?e?{min:Math.min(r.min,e.min),max:Math.max(r.max,e.max)}:r:e}function lv(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function sE(r,e){let[t,n,i,o]=G(r),s=t,a=n,l=i;if(o<1){let[u,h,p]=G(e);s=t*o+u*(1-o),a=n*o+h*(1-o),l=i*o+p*(1-o);}let c=u=>u<=.04045?u/12.92:Math.pow((u+.055)/1.055,2.4);return .2126*c(s)+.7152*c(a)+.0722*c(l)>=.4?"#000000":"#ffffff"}function aE(r){let e=Math.max(0,Math.floor(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)}`}var Rl=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,d=t.width,u=t.height;if(!c||c.x<0||c.x>d||c.y<0||c.y>u)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,cv(s,h.style),s.beginPath(),s.moveTo(m,0),s.lineTo(m,u),s.moveTo(0,Math.round(c.y)+.5),s.lineTo(d,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,d+1,c.y,bo(f.scale,f.bounds.height,b,$t(e,f),e.priceMintick,f.axisFormat),g,"left",false,n.background);}this.chip(s,m,u+1,dv(t.logicalToTime(p),e.timezone),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,cv(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 d=s.labelBackground??o.borderColor;if(t.y!=null&&t.price!=null){let u;for(let h of n.panes.values())if(t.y>=h.bounds.top&&t.y<=h.bounds.top+h.bounds.height){u=h;break}u&&u.axisFormat!=="none"&&this.chip(e,a+1,t.y,bo(u.scale,u.bounds.height,t.price,$t(n,u),n.priceMintick,u.axisFormat),d,"left",false,o.background);}this.chip(e,c,l+1,dv(t.time,n.timezone),d,"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,d=16,u=s==="left"?t:t-c/2,h=a?n:n-d/2;e.fillStyle=o,e.fillRect(u,h,c,d),e.fillStyle=kb(o,l),e.textAlign="center",e.fillText(i,u+c/2,h+d/2+(a?2:0)),e.textAlign="start";}};function cv(r,e){e==="dashed"?r.setLineDash([6,4]):e==="dotted"?r.setLineDash([2,3]):r.setLineDash([]);}function dv(r,e){let t=Il(r,e),n=i=>i<10?`0${i}`:String(i);return `${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}var au=[{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 Dl(r){return r==="UTC"||r==="Etc/UTC"||r==="Etc/GMT"?"Etc/UTC":r}function lE(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 lu(r,e){return Dl(r)==="Etc/UTC"?e:`(${lE(r)}) ${e}`}function qn(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Xe(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 uv(r){if(r.kind==="heading"||r.kind==="header")return qn(r.label);let e=cr(r);if(e.toggle)return e.toggle.key;for(let t of e.controls)if(t.kind!=="hint")return t.key;return qn(e.label)}function Ol(r,e,t){if(t.size===0)return [...r];let n=[],i=false,o=false;for(let s of r){let a=`${e}.${uv(s)}`;if(s.kind==="heading"){i=Xe(a,t),o=false,i||n.push(s);continue}if(s.kind==="header"){if(i)continue;o=Xe(a,t),o||n.push(s);continue}i||o||Xe(a,t)||n.push(s);}return n}function cu(r){return r.id??qn(r.title)}function hv(r){return r.id??qn(r.label)}function pv(r,e,t){if(t.size===0)return [...r];let n=[],i=false;for(let o of r){let s=`${e}.${hv(o)}`;if(o.kind==="heading"){i=Xe(s,t),i||n.push(o);continue}i||Xe(s,t)||n.push(o);}return n}var cE=["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.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 mv(r){let e=new Set(cE);for(let t of Je()){if(co(t.id)){let s=`symbol.style.${t.id}`;for(let a of ["",".body",".borders",".wick",".spacing"])e.add(s+a);}let n=t.settings;if(!n)continue;let i=`type:${t.id}`;e.add(i);let o=s=>{for(let a of s)e.add(`${i}.${uv(a)}`);};n.rows&&o(n.rows);for(let s of n.instances??[])o(s.rows);for(let s of n.subsections??[])e.add(`${i}.${qn(s.title)}`),o(s.rows);}for(let t of r){let n=cu(t);e.add(n);for(let i of t.rows)e.add(`${n}.${hv(i)}`);}return [...e]}var dE={candles:"Candles",bars:"Bars",line:"Line",area:"Area",baseline:"Baseline"};function uE(r){return kt(r)?.label??dE[r]??r}var fv="vela-settings-controls",gv="5";var hE="var(--vela-border)";function pE(){if(typeof document>"u")return;let r=document.getElementById(fv);if(r?.dataset.rev===gv)return;let e=r??document.createElement("style");e.id=fv,e.dataset.rev=gv,e.textContent=`
|
|
771
771
|
${On(".vela-sd-pane")}
|
|
772
772
|
/* Tab rail / footer button / header close: base styles live HERE, not inline on the
|
|
773
773
|
elements \u2014 inline declarations always beat stylesheet :hover rules, which is exactly
|
|
@@ -835,11 +835,11 @@ ${On(".vela-sd-pane")}
|
|
|
835
835
|
.vela-sd-mobile .vela-sd-close{width:40px;height:40px;}
|
|
836
836
|
.vela-sd-mobile .vela-sd-btn{height:38px;}
|
|
837
837
|
.vela-sd-mobile .vela-sd-row span,.vela-sd-mobile .vela-sd-bool span,.vela-sd-mobile .vela-field-label{white-space:normal !important;}
|
|
838
|
-
`,r||document.head.appendChild(e);}var go=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.themeControl=null;this.tabs=[];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;}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,aE();let s=this.mobileLayout,a=null,l;s&&(l=document.createElement("button"),l.type="button",l.className="vela-sd-burger",l.innerHTML=me("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 d=(C,I)=>(C.dataset.sdId=I,C);c.append(d(this.section("Symbol"),"symbol")),c.append(d(this.sectionTitle("Chart type"),"symbol.type"));let u={},h=C=>{let I=C==="heikinashi"?"candles":C;for(let _ of Br())u[_]?.classList.toggle("vela-sd-hide",_!==I);};c.append(d(this.selectRowLabeled("Type",e.series.style,Br().map(C=>[C,oE(C)]),C=>{this.emit({series:{style:C}}),h(C),this.syncTypeTabs?.(C);}),"symbol.type"));let p=d(this.group(),"symbol.style.candles");p.append(this.sectionTitle("Candles")),p.append(d(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(d(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(d(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(d(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.candles.spacing")),u.candles=p,c.append(p);let m=d(this.group(),"symbol.style.bars");m.append(this.sectionTitle("Bars")),m.append(d(this.colorRow("Color Up",e.bars.upColor,C=>this.emit({bars:{upColor:C}})),"symbol.style.bars.up-color")),m.append(d(this.colorRow("Color Down",e.bars.downColor,C=>this.emit({bars:{downColor:C}})),"symbol.style.bars.down-color")),m.append(d(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.bars.spacing")),u.bars=m,c.append(m);let f=d(this.group(),"symbol.style.line");f.append(this.sectionTitle("Line")),f.append(d(this.colorRow("Color",e.line.color,C=>this.emit({line:{color:C}})),"symbol.style.line.color")),f.append(d(this.numberRow("Width",e.line.width,1,10,1,C=>this.emit({line:{width:C}})),"symbol.style.line.width")),u.line=f,c.append(f);let g=d(this.group(),"symbol.style.area");g.append(this.sectionTitle("Area")),g.append(d(this.colorRow("Line color",e.area.lineColor,C=>this.emit({area:{lineColor:C}})),"symbol.style.area.line-color")),g.append(d(this.numberRow("Width",e.area.width,1,10,1,C=>this.emit({area:{width:C}})),"symbol.style.area.width")),g.append(d(this.colorRow("Top fill",e.area.topColor,C=>this.emit({area:{topColor:C}})),"symbol.style.area.top-fill")),g.append(d(this.colorRow("Bottom fill",e.area.bottomColor,C=>this.emit({area:{bottomColor:C}})),"symbol.style.area.bottom-fill")),u.area=g,c.append(g);let b=d(this.group(),"symbol.style.baseline");b.append(this.sectionTitle("Baseline")),b.append(d(this.rowWith("Top line",[this.swatch(e.baseline.topLineColor,C=>this.emit({baseline:{topLineColor:C}}))]),"symbol.style.baseline.top-line")),b.append(d(this.rowWith("Bottom line",[this.swatch(e.baseline.bottomLineColor,C=>this.emit({baseline:{bottomLineColor:C}}))]),"symbol.style.baseline.bottom-line")),b.append(d(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(d(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(d(this.numberRow("Base level %",e.baseline.baselineLevel,0,100,1,C=>this.emit({baseline:{baselineLevel:C}})),"symbol.style.baseline.base-level")),b.append(d(this.numberRow("Width",e.baseline.width,1,10,1,C=>this.emit({baseline:{width:C}})),"symbol.style.baseline.width")),u.baseline=b,c.append(b);for(let C of Je()){if(!so(C.id))continue;let I=e.chartTypes[C.id]??{},_=(z,He)=>typeof I[z]=="string"&&I[z]!==""?I[z]:He,U=(z,He)=>typeof I[z]=="boolean"?I[z]:He,Y=d(this.group(),`symbol.style.${C.id}`);Y.append(this.sectionTitle("Candles")),Y.append(d(this.toggleRow("Body",U("candleBodyVisible",e.candles.bodyVisible),z=>this.emitType(C.id,"candleBodyVisible",z),[this.swatch(_("candleUpColor",e.candles.upColor),z=>this.emitType(C.id,"candleUpColor",z)),this.swatch(_("candleDownColor",e.candles.downColor),z=>this.emitType(C.id,"candleDownColor",z))]),`symbol.style.${C.id}.body`)),Y.append(d(this.toggleRow("Borders",U("candleBorderVisible",e.candles.borderVisible),z=>this.emitType(C.id,"candleBorderVisible",z),[this.swatch(_("candleBorderUpColor",e.candles.borderUpColor),z=>this.emitType(C.id,"candleBorderUpColor",z)),this.swatch(_("candleBorderDownColor",e.candles.borderDownColor),z=>this.emitType(C.id,"candleBorderDownColor",z))]),`symbol.style.${C.id}.borders`)),Y.append(d(this.toggleRow("Wick",U("candleWickVisible",e.candles.wickVisible),z=>this.emitType(C.id,"candleWickVisible",z),[this.swatch(_("candleWickUpColor",e.candles.wickUpColor),z=>this.emitType(C.id,"candleWickUpColor",z)),this.swatch(_("candleWickDownColor",e.candles.wickDownColor),z=>this.emitType(C.id,"candleWickDownColor",z))]),`symbol.style.${C.id}.wick`)),Y.append(d(this.numberRow("Spacing",e.series.spacing,.1,10,.1,z=>this.emit({series:{spacing:z}})),`symbol.style.${C.id}.spacing`)),u[C.id]=Y,c.append(Y);}h(e.series.style),c.append(d(this.sectionTitle("Time zone"),"symbol.timezone")),c.append(d(this.selectRowLabeled("Time zone",Al(e.timeScale.timezone),cE(e.timeScale.timezone),C=>this.emit({timeScale:{timezone:C}})),"symbol.timezone"));let v=C=>{for(let I of this.hostSections){if((I.placement??"after-symbol")!==C)continue;let _=su(I);if(Xe(_,this.hiddenSettings))continue;let U=cv(I.rows,_,this.hiddenSettings);if(U.length!==0){c.append(C==="symbol"?this.sectionTitle(I.title):this.section(I.title));for(let Y of U)Y.kind==="heading"?c.append(this.sectionTitle(Y.label)):Y.kind==="toggle"?c.append(this.boolRow(Y.label,Y.get(),z=>Y.set(z))):Y.kind==="color"?c.append(this.colorRow(Y.label,Y.get(),z=>Y.set(z))):c.append(this.selectRowLabeled(Y.label,Y.get(),Y.options.map(z=>[z,z]),z=>Y.set(z)));}}},y=C=>{for(let I of Je()){let _=I.settings;_&&(_.placement??"end")===C&&(Xe(`type:${I.id}`,this.hiddenSettings)||this.chartTypeSection(I.id,_,e,c));}};if(v("symbol"),y("after-symbol"),v("after-symbol"),c.append(d(this.section("Scales and lines"),"scales")),c.append(d(this.sectionTitle("Price scale"),"scales.price-scale")),c.append(d(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(d(this.boolRow("Invert scale",e.priceScale.invert,C=>this.emit({priceScale:{invert:C}})),"scales.price-scale.invert")),c.append(d(this.separator(),"scales.price-scale")),c.append(d(this.boolRow("Last Price Line",e.priceScale.currentPriceLine,C=>this.emit({priceScale:{currentPriceLine:C}})),"scales.price-scale.last-price-line")),c.append(d(this.boolRow("Last price label",e.priceScale.priceLabel,C=>this.emit({priceScale:{priceLabel:C}})),"scales.price-scale.last-price-label")),c.append(d(this.boolRow("Countdown to bar close",e.priceScale.countdown,C=>this.emit({priceScale:{countdown:C}})),"scales.price-scale.countdown")),c.append(d(this.boolRow("Axis labels",e.priceScale.labelsVisible,C=>this.emit({priceScale:{labelsVisible:C}})),"scales.price-scale.axis-labels")),c.append(d(this.colorRow("Scale border color",e.priceScale.borderColor,C=>this.emit({priceScale:{borderColor:C}})),"scales.price-scale.border-color")),c.append(d(this.sectionTitle("Crosshair"),"scales.crosshair")),c.append(d(this.colorRow("Color",e.crosshair.color,C=>this.emit({crosshair:{color:C}})),"scales.crosshair.color")),c.append(d(this.numberRow("Width",e.crosshair.width,.5,8,.5,C=>this.emit({crosshair:{width:C}})),"scales.crosshair.width")),c.append(d(this.selectRowLabeled("Style",e.crosshair.style,[["solid","Solid"],["dashed","Dashed"],["dotted","Dotted"]],C=>this.emit({crosshair:{style:C}})),"scales.crosshair.style")),c.append(d(this.section("Canvas"),"canvas")),c.append(d(this.sectionTitle("Background & text"),"canvas.background")),c.append(d(this.colorRow("Background",e.layout.background,C=>this.emit({layout:{background:C}})),"canvas.background.color")),c.append(d(this.colorRow("Text color",e.layout.textColor,C=>this.emit({layout:{textColor:C}})),"canvas.background.text-color")),c.append(d(this.numberRow("Text size",e.layout.fontSize,6,32,1,C=>this.emit({layout:{fontSize:C}})),"canvas.background.text-size")),c.append(d(this.colorRow("Pane separator color",e.panes.separatorColor,C=>this.emit({panes:{separatorColor:C}})),"canvas.background.pane-separator")),c.append(d(this.sectionTitle("Grid"),"canvas.grid")),c.append(d(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(d(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(d(this.sectionTitle("Theme"),"canvas.theme")),c.append(d(this.selectRow("Color theme",C.current==="dark"?"Dark":"Light",["Dark","Light"],I=>C.onSelect(I==="Dark"?"dark":"light")),"canvas.theme"));}if(y("end"),v("end"),this.hiddenSettings.size>0){let C=false;for(let I of [...c.children]){if(I.dataset.sdTab!==void 0&&(C=I.dataset.sdId!==void 0&&Xe(I.dataset.sdId,this.hiddenSettings)),C||I.dataset.sdId!==void 0&&Xe(I.dataset.sdId,this.hiddenSettings)){I.remove();continue}for(let _ of [...I.querySelectorAll("[data-sd-id]")])Xe(_.dataset.sdId,this.hiddenSettings)&&_.remove();}}let w=document.createElement("div");w.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 P=document.createElement("div");P.className="vela-sd-rail",P.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 ${sE};overflow-y:auto;`;let x=null;s&&(x=document.createElement("div"),x.className="vela-sd-railscrim",x.addEventListener("click",()=>a?.()),a=C=>{let I=C??!P.classList.contains("open");P.classList.toggle("open",I),x?.classList.toggle("open",I);});let S=document.createElement("div");S.className="vela-sd-pane",S.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 E=[],L=null;for(let C of [...c.children]){let I=C.dataset.sdTab;if(I!==void 0){let _=document.createElement("div");_.style.display="none";let U=document.createElement("button");U.type="button",U.textContent=I,U.className="vela-sd-tab"+(C.dataset.sdSub!==void 0?" vela-sd-tab-sub":""),E.push({title:I,el:_,tab:U,style:C.dataset.sdStyle,visibility:C.dataset.sdVisibility}),L=_,C.remove();continue}L&&L.appendChild(C);}for(let C=E.length-1;C>=0;C--)E[C].el.childElementCount===0&&E.splice(C,1);this.syncTypeTabs=C=>{let I=false;E.forEach((_,U)=>{if(!_.style)return;let Y=_.visibility==="always"||_.style===C||C==="heikinashi"&&_.style==="heikinashi";_.tab.style.display=Y?"":"none",!Y&&_.el.style.display==="block"&&(I=true);}),I&&k(0);};let T=new Nt({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 I=document.createElement("button");I.type="button",I.textContent="Reset defaults",I.className="vela-sd-btn",I.addEventListener("click",()=>this.onReset?.()),C.appendChild(I);},onOpenChange:C=>{C||this.close();}});s&&T.positioner.classList.add("vela-sd-mobile"),T.positioner.style.paddingTop=s?"0":"8vh";let k=C=>{E.forEach((I,_)=>{I.el.style.display=_===C?"block":"none",I.tab.classList.toggle("on",_===C);}),this.activeSection=E[C]?.title??null,s&&(T.titleEl.textContent=E[C]?.title??"Chart settings",a?.(false));};E.forEach((C,I)=>{C.tab.addEventListener("click",()=>k(I)),P.appendChild(C.tab),S.appendChild(C.el);}),this.tabs=E.map((C,I)=>({title:C.title,show:()=>k(I)}));let M=o!==void 0?E.findIndex(C=>C.title.toLowerCase()===o.toLowerCase()):E.findIndex(C=>C.style===e.series.style&&!C.tab.classList.contains("vela-sd-tab-sub"));k(M>=0?M:0),this.syncTypeTabs?.(e.series.style),w.append(P,S),x&&w.append(x),T.body.appendChild(w),this.root=T.positioner,this.ui=T,T.show();for(let C of E){let I=[...C.el.querySelectorAll("[data-sd-rows-host]")];if(I.length===0){this.layoutSettingsGrids(C.el);continue}for(let _ of I)this.layoutSettingsGrids(_);}}close(){de(),Dd();let e=this.ui;this.ui=null,this.root=null,this.tabs=[],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 Vt(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 pi(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=[],d=(h,p)=>{a[h]=p,this.emitType(e,h,p);for(let m of c)m();},u=`type:${e}`;if(t.instances&&t.instances.length>0){let h=t.instances.map(p=>({...p,rows:Rl(p.rows,u,this.hiddenSettings)}));i.append(this.instancesBlock(e,h,a,d,c));}else if(t.rows){let h=Rl(t.rows,u,this.hiddenSettings);t.layout==="grouped"?i.append(this.groupedRows(`${e}/rows`,h,a,d,c)):this.flatTypeRows(h,a,d,c,i);}for(let h of t.subsections??[]){if(Xe(`${u}.${qn(h.title)}`,this.hiddenSettings))continue;let p=Rl(h.rows,u,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,d,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",!kn(a.when,t));});}typeRow(e,t,n,i){let o=cr(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=kn(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 q({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 q({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 q({kind:"select",options:lE(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 q({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((u,h)=>{let p=this.groupedRows(`${e}/#${h}`,u.rows,n,i,o);return s.append(p),p}),c=u=>!u.enableKey||n[u.enableKey]===true,d=()=>{let u=this.typeActiveInstance.get(e)??0;c(t[u]??t[0])||(u=0),this.typeActiveInstance.set(e,u),a.replaceChildren(),t.forEach((p,m)=>{if(!c(p))return;let f=document.createElement("button");f.type="button",f.className="vela-sd-itab"+(m===u?" on":"");let g=document.createElement("span");if(g.textContent=p.label,f.append(g),m===u&&p.enableKey){let b=document.createElement("span");b.className="vela-sd-ix",b.textContent="\u2715",b.title=`Remove ${p.label}`,b.addEventListener("click",v=>{v.stopPropagation(),this.typeActiveInstance.set(e,0),i(p.enableKey,false);}),f.append(b);}f.addEventListener("click",()=>{this.typeActiveInstance.set(e,m),d();}),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!==u));};return o.push(d),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 d=[],u=[],h=[],p=-1;for(let f of t){if(f.kind==="heading"){p=u.length,u.push(f.label),h.push(f.when);continue}if(f.kind==="header"){d.push({el:this.sectionTitle(f.label),when:f.when,group:p,header:true}),c.append(d[d.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;d.push({el:g,when:f.when,group:p,key:b}),c.append(g);}let m=()=>{let f=u.map((y,w)=>kn(h[w],n)&&d.some(P=>P.group===w&&!P.header&&kn(P.when,n))),g=u.indexOf(this.typeActiveGroup.get(e)??"");(g<0||!f[g])&&(g=f.findIndex(Boolean)),g>=0&&this.typeActiveGroup.set(e,u[g]),l.replaceChildren(),u.forEach((y,w)=>{if(!f[w])return;let P=document.createElement("button");P.type="button",P.className="vela-sd-toc-btn"+(w===g?" on":""),P.textContent=y,P.addEventListener("click",()=>{this.typeActiveGroup.set(e,y),m();}),l.append(P);});let b=f.some(Boolean);l.classList.toggle("vela-sd-hide",!b),a.classList.toggle("no-toc",!b);let v=!s||n[s]===true;for(let y=0;y<d.length;y++){let w=d[y],P=(w.group===-1||w.group===g)&&kn(w.when,n);if(P&&w.header){let x=false;for(let S=y+1;S<d.length;S++){let E=d[S];if(E.group!==w.group||E.header)break;if(kn(E.when,n)){x=true;break}}P=x;}w.el.classList.toggle("vela-sd-hide",!P),w.el.classList.toggle("vela-sd-soft",P&&!v&&w.key!==s);}};return o.push(m),a}separator(){return Fd()}layoutSettingsGrids(e){if(e.childElementCount===0)return;let t=to({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 q({kind:"color",theme:this.theme,get:()=>n?n():i,onChange:o=>{i=o,t(o);}}).el}rowWith(e,t){return he({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 he({label:e,labelSize:"sm",fit:true,className:"vela-sd-row",control:q({kind:"color",theme:this.theme,get:()=>i,onChange:o=>{i=o,n(o);}}).el})}boolRow(e,t,n){return this.toggleRow(e,t,n,[])}toggleRow(e,t,n,i,o){return he({label:e,labelSize:"sm",bool:i.length===0,toggle:{checked:t,onChange:n,get:o},control:i,className:i.length===0?"vela-sd-bool":"vela-sd-row"})}numberRow(e,t,n,i,o,s){return he({label:e,labelSize:"sm",className:"vela-sd-row",control:q({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 he({label:e,labelSize:"sm",className:"vela-sd-row",control:q({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 lE(r){return r.map(e=>typeof e=="string"?[e,e]:e)}function cE(r){let e=iu.map(n=>[n.value,ou(n.value,n.label)]),t=Al(r);return iu.some(n=>n.value===t)?e:[[t,ou(t,t)],...e]}var bo=Fo,vo=No;function je(r,e){if(r instanceof ge){if(!r.fillTriangles().length)return null;let t=r.valid();return r.style.fillColor??(t==null?r.style.lineColor:t?bo:vo)}return r instanceof ze?r.style.fillColor??e.background:r.style.fillColor??null}var dE=4.5,uE=R,hE=W(Ee,.55),pE=.7,pv=sh,mE=Vo,mv={selected:.3,hovered:.12};function au(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 Dl=class{constructor(){this.targets={};}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,au(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=pE,t instanceof Et||t instanceof Ve?this.paintTimeSpanGhost(e,t,n):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 Et?t.reg?.midColor||Ee:Ee,a=u=>{let h=n.xOf(u);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,d=[];l!=null&&d.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(),d.push([n.xOf(o.time),c])),this.paintHandles(e,d);}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 te){this.paintHighlighter(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof te){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 yn){this.paintArrowMark(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof wn){this.paintGlyphStamp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof Ze){this.paintRadialFib(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof Tn){this.paintFibSpiral(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Pn){this.paintDedekind(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Ae){this.paintMachFigure(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof En){this.paintFibRatios(e,t,n,i),this.paintGannArcs(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof re){this.paintFibRatios(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof Ln){this.paintMeasureBox(e,t,n,i);return}if(t instanceof $e){this.paintPosition(e,t,n,i);return}if(t instanceof Et){this.paintRegressionChannel(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof vn){this.paintAnchoredVwap(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Ve){this.paintFixedRangeVp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof ge){this.paintPattern(e,t,n,i);return}if(t instanceof gn){this.paintComment(e,t,n,i);return}if(t instanceof fn){this.paintPriceNote(e,t,n,i);return}if(t instanceof bn){this.paintSignpost(e,t,n,i);return}if(t instanceof st){this.paintCallout(e,t,n,i);return}if(t instanceof pn){this.paintNote(e,t,n,i);return}if(t instanceof mn){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]=Gr(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]=Gr(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=gE(t,n);if(!s)return;let a=ye(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=xt(a),c=o.value.split(`
|
|
839
|
-
`);c.forEach((d,u)=>e.fillText(d,s.x,s.top+u*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)?
|
|
840
|
-
`),m=Math.max(8,...p.map(M=>e.measureText(M).width)),f=9,g=6,b=
|
|
841
|
-
`),l=Math.max(8,...a.map(c=>e.measureText(c).width));return {lines:a,tw:l,fs:s,lh:
|
|
842
|
-
`).length,o=xt(ye(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:Kb(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 Kr(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}var vv=3,bE=4,yv=Math.PI/4,wv=new Set(["trendline","ray","extendedline","infoline","trendangle","arrow"]),Ol=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}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)/yv)*yv;return o.pxToPoint(s+l*Math.cos(c),a+l*Math.sin(c),t)}placingPivot(e){return wv.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}down(e,t,n="off",i=false){let o=this.deps.projector();if(this.state.kind==="placing"){if(this.state.draft.placementMode()!=="click")return;let l=i?this.placingPivot(this.state.draft):null,c=l?this.resolveAngleSnapped(l,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,c)),this.state.draft.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let s=this.deps.activeTool();if(s){let l=o.paneIdAtY(t)??"price",c=qt(s,{paneId:l,anchors:[this.resolve(e,t,l,n)],style:this.deps.lastStyle()});if(!c)return;this.state={kind:"placing",draft:c,need:c.anchorSchema().max,cursor:null},c.placementMode()==="click"&&c.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let a=this.hitAt(e,t);if(a){if(i){this.deps.emit({kind:"select",ids:[a.id],additive:true});return}let l=a.hitHandle(e,t,o,6);this.state={kind:"pressed",id:a.id,handle:l,grab:o.pxToPoint(e,t,a.paneId),orig:vE(a),px:e,py:t,moved:false};}}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!=="pressed")return;let o=this.byId(this.state.id);if(!(!o||o.locked)&&!(!this.state.moved&&Math.abs(e-this.state.px)<=vv&&Math.abs(t-this.state.py)<=vv)){if(this.state.moved=true,this.state.handle>=0){let s=o.anchors[this.state.handle];if(s){let a=i&&wv.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);yE(s,l,o.anchorSchema().slots[this.state.handle]?.free??"both");}o.constrainHandleDrag(this.state.handle);}else {let s=this.deps.projector().pxToPoint(e,t,o.paneId);this.snapAt=null;let a=s.time-this.state.grab.time,l=s.price-this.state.grab.price;o.anchors=o.translateBody(a,l,this.state.orig);}this.deps.changed();}}up(e,t){if(this.snapAt=null,this.state.kind==="placing"){let s=this.state.draft.placementMode();s==="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()):s==="freehand"&&(this.state.draft.anchors.length>=this.state.draft.anchorSchema().min?this.finalize():this.discardPlacing());return}if(this.state.kind!=="pressed")return;let{id:n,moved:i}=this.state;this.state={kind:"idle"};let o=this.byId(n);i?(o&&this.deps.emit({kind:"edit",doc:o.serialize()}),this.deps.changed()):this.deps.openSettings(n,e,t);}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"){let e=this.byId(this.state.id);return e&&this.state.moved&&(e.anchors=this.state.orig.map(t=>({time:t.time,price:t.price}))),this.state={kind:"idle"},this.deps.changed(),true}return 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?qt(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)>bE){if(n.anchors.length>=this.state.need){let l=n.anchors.length-1;n.anchors=n.anchors.filter((c,d)=>d%2===0||d===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 Kr(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 vE(r){return r.anchors.map(e=>({time:e.time,price:e.price}))}function yE(r,e,t){(t==="both"||t==="x")&&(r.time=e.time),(t==="both"||t==="y")&&(r.price=e.price);}var wE=[{value:"price",label:"Price"},{value:"points",label:"Points"}],xE=[{value:"right",label:"Right"},{value:"left",label:"Left"}],SE={position:"Position size",frvp:"Volume profile",levels:"Levels"},Fl=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=dt(e.serialize()),o=to({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 $e)this.buildPosition(o,e,t);else if(n==="frvp"&&e instanceof Ve)this.buildFrvp(o,e,t);else if(n==="levels")this.buildLevels(o,e,t);else return;let s=new Nt({host:this.host,title:SE[n],modal:false,contained:true,align:"center",draggable:true,flush:true,className:"vela-dialog--form",closeOnEscape:false,footer:l=>{l.append(xv("Cancel",false,()=>{t.restore?.(i),this.close();}),xv("Ok",true,()=>this.close()));},onOpenChange:l=>{l||this.close();}});ve(s.panel,this.theme),s.body.appendChild(o);let a=l=>{if(!(l.target!==s.backdrop&&l.target!==s.positioner)){if(wt()||$n(l)){de();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 $e?p:t},o=[],s=()=>o.forEach(p=>p()),a=p=>Math.round(p*1e8)/1e8,l=(p,m,f)=>{let g=q({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(he({label:p,control:g.el}));},c=(p,m,f)=>{let g="price",b=()=>a(i().levelDisplayValue(f,g)),v=q({kind:"number",value:b(),fill:false,commit:"blur",onChange:w=>{n.patch({[m]:i().levelPriceFromDisplay(f,g,w)}),s();}}),y=q({kind:"select",options:wE,value:g,fill:false,theme:this.theme,onChange:w=>{g=w,v.setValue?.(b());}});o.push(()=>{document.activeElement!==v.el.querySelector("input")&&v.setValue?.(b());}),e.appendChild(he({label:p,control:[v.el,y.el]}));};e.appendChild(Vt("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(Vt("Levels",{variant:"inputs"}));let d=q({kind:"select",options:Gs,value:i().direction,fill:false,theme:this.theme,onChange:p=>{n.patch({direction:p}),s();}});o.push(()=>d.setValue?.(i().direction)),e.appendChild(he({label:"Direction",control:d.el})),l("Entry price","entryPrice"),c("Stop","stopPrice","stop"),c("Target","targetPrice","target"),e.appendChild(Vt("Display",{variant:"inputs"}));let u=[["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 u)e.appendChild(he({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 d=n.resolve();return d instanceof Ve?d.frvp:t.frvp},o=i(),s=(d,u,h,p,m,f=true)=>{e.appendChild(he({label:d,control:q({kind:"number",value:o[u],min:h,max:p,step:m,integer:f,fill:false,commit:"blur",onChange:g=>n.patch({[`frvp.${u}`]:g})}).el}));};s("Rows","rows",1,500,1),s("Value Area","valueAreaPct",0,100,1),s("Width %","widthPct",0,100,1),e.appendChild(he({label:"Anchor",control:q({kind:"select",options:xE,value:o.anchor,fill:false,theme:this.theme,onChange:d=>n.patch({"frvp.anchor":d})}).el}));let a=(d,u)=>{e.appendChild(he({label:d,fit:true,control:q({kind:"color",theme:this.theme,get:()=>i()[u],onChange:h=>n.patch({[`frvp.${u}`]:h})}).el}));};a("Up Volume","upColor"),a("Down Volume","downColor"),a("Value Area Up","vaUpColor"),a("Value Area Down","vaDownColor");let l=Pe.map(d=>({value:d.value,label:d.label})),c=(d,u,h,p)=>{let m=document.createElement("div");m.className="vela-field-span",m.style.cssText="display:flex;align-items:center;gap:8px;";let f=q({kind:"switch",checked:!!o[u],onChange:w=>n.patch({[`frvp.${u}`]:w})}),g=document.createElement("span");g.className="vela-field-label",g.style.flex="1",g.textContent=d;let b=o[h]??Ne(this.theme.background),v=q({kind:"color",theme:this.theme,get:()=>b,onChange:w=>{b=w,n.patch({[`frvp.${h}`]:w});}}),y=q({kind:"select",options:l,value:o[p],fill:false,theme:this.theme,onChange:w=>n.patch({[`frvp.${p}`]:w})});m.append(f.el,g,v.el,y.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 Ae;if(o){let s=t;e.appendChild(he({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=q({kind:"switch",checked:s.enabled,onChange:m=>n.patch({[`levels.${a}.enabled`]:m})}),d=s.color,u=q({kind:"color",theme:this.theme,get:()=>d,onChange:m=>{d=m,n.patch({[`levels.${a}.color`]:m});}}),h=s.ratio,p=q({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,u.el,p.el),!o){let m=q({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 xv(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 dn=30,CE=21,Sv="vela-drawing-popup-styles",Cv="3";function TE(){if(typeof document>"u")return;let r=document.getElementById(Sv);if(r?.dataset.rev===Cv)return;let e=r??document.createElement("style");e.id=Sv,e.dataset.rev=Cv,e.textContent=`
|
|
838
|
+
`,r||document.head.appendChild(e);}var yo=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.themeControl=null;this.tabs=[];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;}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,pE();let s=this.mobileLayout,a=null,l;s&&(l=document.createElement("button"),l.type="button",l.className="vela-sd-burger",l.innerHTML=me("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 d=(C,I)=>(C.dataset.sdId=I,C);c.append(d(this.section("Symbol"),"symbol")),c.append(d(this.sectionTitle("Chart type"),"symbol.type"));let u={},h=C=>{let I=C==="heikinashi"?"candles":C;for(let _ of Br())u[_]?.classList.toggle("vela-sd-hide",_!==I);};c.append(d(this.selectRowLabeled("Type",e.series.style,Br().map(C=>[C,uE(C)]),C=>{this.emit({series:{style:C}}),h(C),this.syncTypeTabs?.(C);}),"symbol.type"));let p=d(this.group(),"symbol.style.candles");p.append(this.sectionTitle("Candles")),p.append(d(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(d(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(d(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(d(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.candles.spacing")),u.candles=p,c.append(p);let m=d(this.group(),"symbol.style.bars");m.append(this.sectionTitle("Bars")),m.append(d(this.colorRow("Color Up",e.bars.upColor,C=>this.emit({bars:{upColor:C}})),"symbol.style.bars.up-color")),m.append(d(this.colorRow("Color Down",e.bars.downColor,C=>this.emit({bars:{downColor:C}})),"symbol.style.bars.down-color")),m.append(d(this.numberRow("Spacing",e.series.spacing,.1,10,.1,C=>this.emit({series:{spacing:C}})),"symbol.style.bars.spacing")),u.bars=m,c.append(m);let f=d(this.group(),"symbol.style.line");f.append(this.sectionTitle("Line")),f.append(d(this.colorRow("Color",e.line.color,C=>this.emit({line:{color:C}})),"symbol.style.line.color")),f.append(d(this.numberRow("Width",e.line.width,1,10,1,C=>this.emit({line:{width:C}})),"symbol.style.line.width")),u.line=f,c.append(f);let g=d(this.group(),"symbol.style.area");g.append(this.sectionTitle("Area")),g.append(d(this.colorRow("Line color",e.area.lineColor,C=>this.emit({area:{lineColor:C}})),"symbol.style.area.line-color")),g.append(d(this.numberRow("Width",e.area.width,1,10,1,C=>this.emit({area:{width:C}})),"symbol.style.area.width")),g.append(d(this.colorRow("Top fill",e.area.topColor,C=>this.emit({area:{topColor:C}})),"symbol.style.area.top-fill")),g.append(d(this.colorRow("Bottom fill",e.area.bottomColor,C=>this.emit({area:{bottomColor:C}})),"symbol.style.area.bottom-fill")),u.area=g,c.append(g);let b=d(this.group(),"symbol.style.baseline");b.append(this.sectionTitle("Baseline")),b.append(d(this.rowWith("Top line",[this.swatch(e.baseline.topLineColor,C=>this.emit({baseline:{topLineColor:C}}))]),"symbol.style.baseline.top-line")),b.append(d(this.rowWith("Bottom line",[this.swatch(e.baseline.bottomLineColor,C=>this.emit({baseline:{bottomLineColor:C}}))]),"symbol.style.baseline.bottom-line")),b.append(d(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(d(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(d(this.numberRow("Base level %",e.baseline.baselineLevel,0,100,1,C=>this.emit({baseline:{baselineLevel:C}})),"symbol.style.baseline.base-level")),b.append(d(this.numberRow("Width",e.baseline.width,1,10,1,C=>this.emit({baseline:{width:C}})),"symbol.style.baseline.width")),u.baseline=b,c.append(b);for(let C of Je()){if(!co(C.id))continue;let I=e.chartTypes[C.id]??{},_=(z,He)=>typeof I[z]=="string"&&I[z]!==""?I[z]:He,U=(z,He)=>typeof I[z]=="boolean"?I[z]:He,Y=d(this.group(),`symbol.style.${C.id}`);Y.append(this.sectionTitle("Candles")),Y.append(d(this.toggleRow("Body",U("candleBodyVisible",e.candles.bodyVisible),z=>this.emitType(C.id,"candleBodyVisible",z),[this.swatch(_("candleUpColor",e.candles.upColor),z=>this.emitType(C.id,"candleUpColor",z)),this.swatch(_("candleDownColor",e.candles.downColor),z=>this.emitType(C.id,"candleDownColor",z))]),`symbol.style.${C.id}.body`)),Y.append(d(this.toggleRow("Borders",U("candleBorderVisible",e.candles.borderVisible),z=>this.emitType(C.id,"candleBorderVisible",z),[this.swatch(_("candleBorderUpColor",e.candles.borderUpColor),z=>this.emitType(C.id,"candleBorderUpColor",z)),this.swatch(_("candleBorderDownColor",e.candles.borderDownColor),z=>this.emitType(C.id,"candleBorderDownColor",z))]),`symbol.style.${C.id}.borders`)),Y.append(d(this.toggleRow("Wick",U("candleWickVisible",e.candles.wickVisible),z=>this.emitType(C.id,"candleWickVisible",z),[this.swatch(_("candleWickUpColor",e.candles.wickUpColor),z=>this.emitType(C.id,"candleWickUpColor",z)),this.swatch(_("candleWickDownColor",e.candles.wickDownColor),z=>this.emitType(C.id,"candleWickDownColor",z))]),`symbol.style.${C.id}.wick`)),Y.append(d(this.numberRow("Spacing",e.series.spacing,.1,10,.1,z=>this.emit({series:{spacing:z}})),`symbol.style.${C.id}.spacing`)),u[C.id]=Y,c.append(Y);}h(e.series.style),c.append(d(this.sectionTitle("Time zone"),"symbol.timezone")),c.append(d(this.selectRowLabeled("Time zone",Dl(e.timeScale.timezone),fE(e.timeScale.timezone),C=>this.emit({timeScale:{timezone:C}})),"symbol.timezone"));let v=C=>{for(let I of this.hostSections){if((I.placement??"after-symbol")!==C)continue;let _=cu(I);if(Xe(_,this.hiddenSettings))continue;let U=pv(I.rows,_,this.hiddenSettings);if(U.length!==0){c.append(C==="symbol"?this.sectionTitle(I.title):this.section(I.title));for(let Y of U)Y.kind==="heading"?c.append(this.sectionTitle(Y.label)):Y.kind==="toggle"?c.append(this.boolRow(Y.label,Y.get(),z=>Y.set(z))):Y.kind==="color"?c.append(this.colorRow(Y.label,Y.get(),z=>Y.set(z))):c.append(this.selectRowLabeled(Y.label,Y.get(),Y.options.map(z=>[z,z]),z=>Y.set(z)));}}},y=C=>{for(let I of Je()){let _=I.settings;_&&(_.placement??"end")===C&&(Xe(`type:${I.id}`,this.hiddenSettings)||this.chartTypeSection(I.id,_,e,c));}};if(v("symbol"),y("after-symbol"),v("after-symbol"),c.append(d(this.section("Scales and lines"),"scales")),c.append(d(this.sectionTitle("Price scale"),"scales.price-scale")),c.append(d(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(d(this.boolRow("Invert scale",e.priceScale.invert,C=>this.emit({priceScale:{invert:C}})),"scales.price-scale.invert")),c.append(d(this.separator(),"scales.price-scale")),c.append(d(this.boolRow("Last Price Line",e.priceScale.currentPriceLine,C=>this.emit({priceScale:{currentPriceLine:C}})),"scales.price-scale.last-price-line")),c.append(d(this.boolRow("Last price label",e.priceScale.priceLabel,C=>this.emit({priceScale:{priceLabel:C}})),"scales.price-scale.last-price-label")),c.append(d(this.boolRow("Countdown to bar close",e.priceScale.countdown,C=>this.emit({priceScale:{countdown:C}})),"scales.price-scale.countdown")),c.append(d(this.boolRow("Axis labels",e.priceScale.labelsVisible,C=>this.emit({priceScale:{labelsVisible:C}})),"scales.price-scale.axis-labels")),c.append(d(this.colorRow("Scale border color",e.priceScale.borderColor,C=>this.emit({priceScale:{borderColor:C}})),"scales.price-scale.border-color")),c.append(d(this.sectionTitle("Crosshair"),"scales.crosshair")),c.append(d(this.colorRow("Color",e.crosshair.color,C=>this.emit({crosshair:{color:C}})),"scales.crosshair.color")),c.append(d(this.numberRow("Width",e.crosshair.width,.5,8,.5,C=>this.emit({crosshair:{width:C}})),"scales.crosshair.width")),c.append(d(this.selectRowLabeled("Style",e.crosshair.style,[["solid","Solid"],["dashed","Dashed"],["dotted","Dotted"]],C=>this.emit({crosshair:{style:C}})),"scales.crosshair.style")),c.append(d(this.section("Canvas"),"canvas")),c.append(d(this.sectionTitle("Background & text"),"canvas.background")),c.append(d(this.colorRow("Background",e.layout.background,C=>this.emit({layout:{background:C}})),"canvas.background.color")),c.append(d(this.colorRow("Text color",e.layout.textColor,C=>this.emit({layout:{textColor:C}})),"canvas.background.text-color")),c.append(d(this.numberRow("Text size",e.layout.fontSize,6,32,1,C=>this.emit({layout:{fontSize:C}})),"canvas.background.text-size")),c.append(d(this.colorRow("Pane separator color",e.panes.separatorColor,C=>this.emit({panes:{separatorColor:C}})),"canvas.background.pane-separator")),c.append(d(this.sectionTitle("Grid"),"canvas.grid")),c.append(d(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(d(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(d(this.sectionTitle("Theme"),"canvas.theme")),c.append(d(this.selectRow("Color theme",C.current==="dark"?"Dark":"Light",["Dark","Light"],I=>C.onSelect(I==="Dark"?"dark":"light")),"canvas.theme"));}if(y("end"),v("end"),this.hiddenSettings.size>0){let C=false;for(let I of [...c.children]){if(I.dataset.sdTab!==void 0&&(C=I.dataset.sdId!==void 0&&Xe(I.dataset.sdId,this.hiddenSettings)),C||I.dataset.sdId!==void 0&&Xe(I.dataset.sdId,this.hiddenSettings)){I.remove();continue}for(let _ of [...I.querySelectorAll("[data-sd-id]")])Xe(_.dataset.sdId,this.hiddenSettings)&&_.remove();}}let w=document.createElement("div");w.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 P=document.createElement("div");P.className="vela-sd-rail",P.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 ${hE};overflow-y:auto;`;let x=null;s&&(x=document.createElement("div"),x.className="vela-sd-railscrim",x.addEventListener("click",()=>a?.()),a=C=>{let I=C??!P.classList.contains("open");P.classList.toggle("open",I),x?.classList.toggle("open",I);});let S=document.createElement("div");S.className="vela-sd-pane",S.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 E=[],L=null;for(let C of [...c.children]){let I=C.dataset.sdTab;if(I!==void 0){let _=document.createElement("div");_.style.display="none";let U=document.createElement("button");U.type="button",U.textContent=I,U.className="vela-sd-tab"+(C.dataset.sdSub!==void 0?" vela-sd-tab-sub":""),E.push({title:I,el:_,tab:U,style:C.dataset.sdStyle,visibility:C.dataset.sdVisibility}),L=_,C.remove();continue}L&&L.appendChild(C);}for(let C=E.length-1;C>=0;C--)E[C].el.childElementCount===0&&E.splice(C,1);this.syncTypeTabs=C=>{let I=false;E.forEach((_,U)=>{if(!_.style)return;let Y=_.visibility==="always"||_.style===C||C==="heikinashi"&&_.style==="heikinashi";_.tab.style.display=Y?"":"none",!Y&&_.el.style.display==="block"&&(I=true);}),I&&k(0);};let T=new Nt({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 I=document.createElement("button");I.type="button",I.textContent="Reset defaults",I.className="vela-sd-btn",I.addEventListener("click",()=>this.onReset?.()),C.appendChild(I);},onOpenChange:C=>{C||this.close();}});s&&T.positioner.classList.add("vela-sd-mobile"),T.positioner.style.paddingTop=s?"0":"8vh";let k=C=>{E.forEach((I,_)=>{I.el.style.display=_===C?"block":"none",I.tab.classList.toggle("on",_===C);}),this.activeSection=E[C]?.title??null,s&&(T.titleEl.textContent=E[C]?.title??"Chart settings",a?.(false));};E.forEach((C,I)=>{C.tab.addEventListener("click",()=>k(I)),P.appendChild(C.tab),S.appendChild(C.el);}),this.tabs=E.map((C,I)=>({title:C.title,show:()=>k(I)}));let M=o!==void 0?E.findIndex(C=>C.title.toLowerCase()===o.toLowerCase()):E.findIndex(C=>C.style===e.series.style&&!C.tab.classList.contains("vela-sd-tab-sub"));k(M>=0?M:0),this.syncTypeTabs?.(e.series.style),w.append(P,S),x&&w.append(x),T.body.appendChild(w),this.root=T.positioner,this.ui=T,T.show();for(let C of E){let I=[...C.el.querySelectorAll("[data-sd-rows-host]")];if(I.length===0){this.layoutSettingsGrids(C.el);continue}for(let _ of I)this.layoutSettingsGrids(_);}}close(){de(),Nd();let e=this.ui;this.ui=null,this.root=null,this.tabs=[],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 Vt(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 gi(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=[],d=(h,p)=>{a[h]=p,this.emitType(e,h,p);for(let m of c)m();},u=`type:${e}`;if(t.instances&&t.instances.length>0){let h=t.instances.map(p=>({...p,rows:Ol(p.rows,u,this.hiddenSettings)}));i.append(this.instancesBlock(e,h,a,d,c));}else if(t.rows){let h=Ol(t.rows,u,this.hiddenSettings);t.layout==="grouped"?i.append(this.groupedRows(`${e}/rows`,h,a,d,c)):this.flatTypeRows(h,a,d,c,i);}for(let h of t.subsections??[]){if(Xe(`${u}.${qn(h.title)}`,this.hiddenSettings))continue;let p=Ol(h.rows,u,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,d,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",!kn(a.when,t));});}typeRow(e,t,n,i){let o=cr(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=kn(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 q({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 q({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 q({kind:"select",options:mE(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 q({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((u,h)=>{let p=this.groupedRows(`${e}/#${h}`,u.rows,n,i,o);return s.append(p),p}),c=u=>!u.enableKey||n[u.enableKey]===true,d=()=>{let u=this.typeActiveInstance.get(e)??0;c(t[u]??t[0])||(u=0),this.typeActiveInstance.set(e,u),a.replaceChildren(),t.forEach((p,m)=>{if(!c(p))return;let f=document.createElement("button");f.type="button",f.className="vela-sd-itab"+(m===u?" on":"");let g=document.createElement("span");if(g.textContent=p.label,f.append(g),m===u&&p.enableKey){let b=document.createElement("span");b.className="vela-sd-ix",b.textContent="\u2715",b.title=`Remove ${p.label}`,b.addEventListener("click",v=>{v.stopPropagation(),this.typeActiveInstance.set(e,0),i(p.enableKey,false);}),f.append(b);}f.addEventListener("click",()=>{this.typeActiveInstance.set(e,m),d();}),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!==u));};return o.push(d),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 d=[],u=[],h=[],p=-1;for(let f of t){if(f.kind==="heading"){p=u.length,u.push(f.label),h.push(f.when);continue}if(f.kind==="header"){d.push({el:this.sectionTitle(f.label),when:f.when,group:p,header:true}),c.append(d[d.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;d.push({el:g,when:f.when,group:p,key:b}),c.append(g);}let m=()=>{let f=u.map((y,w)=>kn(h[w],n)&&d.some(P=>P.group===w&&!P.header&&kn(P.when,n))),g=u.indexOf(this.typeActiveGroup.get(e)??"");(g<0||!f[g])&&(g=f.findIndex(Boolean)),g>=0&&this.typeActiveGroup.set(e,u[g]),l.replaceChildren(),u.forEach((y,w)=>{if(!f[w])return;let P=document.createElement("button");P.type="button",P.className="vela-sd-toc-btn"+(w===g?" on":""),P.textContent=y,P.addEventListener("click",()=>{this.typeActiveGroup.set(e,y),m();}),l.append(P);});let b=f.some(Boolean);l.classList.toggle("vela-sd-hide",!b),a.classList.toggle("no-toc",!b);let v=!s||n[s]===true;for(let y=0;y<d.length;y++){let w=d[y],P=(w.group===-1||w.group===g)&&kn(w.when,n);if(P&&w.header){let x=false;for(let S=y+1;S<d.length;S++){let E=d[S];if(E.group!==w.group||E.header)break;if(kn(E.when,n)){x=true;break}}P=x;}w.el.classList.toggle("vela-sd-hide",!P),w.el.classList.toggle("vela-sd-soft",P&&!v&&w.key!==s);}};return o.push(m),a}separator(){return _d()}layoutSettingsGrids(e){if(e.childElementCount===0)return;let t=io({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 q({kind:"color",theme:this.theme,get:()=>n?n():i,onChange:o=>{i=o,t(o);}}).el}rowWith(e,t){return he({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 he({label:e,labelSize:"sm",fit:true,className:"vela-sd-row",control:q({kind:"color",theme:this.theme,get:()=>i,onChange:o=>{i=o,n(o);}}).el})}boolRow(e,t,n){return this.toggleRow(e,t,n,[])}toggleRow(e,t,n,i,o){return he({label:e,labelSize:"sm",bool:i.length===0,toggle:{checked:t,onChange:n,get:o},control:i,className:i.length===0?"vela-sd-bool":"vela-sd-row"})}numberRow(e,t,n,i,o,s){return he({label:e,labelSize:"sm",className:"vela-sd-row",control:q({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 he({label:e,labelSize:"sm",className:"vela-sd-row",control:q({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 mE(r){return r.map(e=>typeof e=="string"?[e,e]:e)}function fE(r){let e=au.map(n=>[n.value,lu(n.value,n.label)]),t=Dl(r);return au.some(n=>n.value===t)?e:[[t,lu(t,t)],...e]}var wo=Vo,xo=_o;function je(r,e){if(r instanceof ge){if(!r.fillTriangles().length)return null;let t=r.valid();return r.style.fillColor??(t==null?r.style.lineColor:t?wo:xo)}return r instanceof ze?r.style.fillColor??e.background:r.style.fillColor??null}var gE=4.5,bE=R,vE=W(Ee,.55),yE=.7,bv=dh,wE=Bo,vv={selected:.3,hovered:.12};function du(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 Fl=class{constructor(){this.targets={};}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,du(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=yE,t instanceof Pt||t instanceof Ve?this.paintTimeSpanGhost(e,t,n):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 Pt?t.reg?.midColor||Ee:Ee,a=u=>{let h=n.xOf(u);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,d=[];l!=null&&d.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(),d.push([n.xOf(o.time),c])),this.paintHandles(e,d);}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 te){this.paintHighlighter(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof te){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 wn){this.paintArrowMark(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof xn){this.paintGlyphStamp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof Ze){this.paintRadialFib(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof En){this.paintFibSpiral(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Ln){this.paintDedekind(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Ae){this.paintMachFigure(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof Pn){this.paintFibRatios(e,t,n,i),this.paintGannArcs(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof re){this.paintFibRatios(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof Mn){this.paintMeasureBox(e,t,n,i);return}if(t instanceof $e){this.paintPosition(e,t,n,i);return}if(t instanceof Pt){this.paintRegressionChannel(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof yn){this.paintAnchoredVwap(e,t,n),this.paintLabel(e,t,n,i);return}if(t instanceof Ve){this.paintFixedRangeVp(e,t,n,i),this.paintLabel(e,t,n,i);return}if(t instanceof ge){this.paintPattern(e,t,n,i);return}if(t instanceof bn){this.paintComment(e,t,n,i);return}if(t instanceof gn){this.paintPriceNote(e,t,n,i);return}if(t instanceof vn){this.paintSignpost(e,t,n,i);return}if(t instanceof st){this.paintCallout(e,t,n,i);return}if(t instanceof mn){this.paintNote(e,t,n,i);return}if(t instanceof fn){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]=Gr(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]=Gr(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=SE(t,n);if(!s)return;let a=ye(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=St(a),c=o.value.split(`
|
|
839
|
+
`);c.forEach((d,u)=>e.fillText(d,s.x,s.top+u*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)?vv.selected:l.hovered===t?vv.hovered:0;if(c===0)return;let d=St(s),u=Math.max(8,...o.map(h=>e.measureText(h).width));e.save(),e.setLineDash([]),e.lineWidth=1,e.strokeStyle=W(a.textColor,c),Wt(e,n-Xn,i-(d-s)/2-jn,u+Xn*2,o.length*d+jn*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=`${ye(t.numbersSize)}px ${i.fontFamily}`,a=`${ye(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=`${ye(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 dc){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),d=i.oy+s.k*i.py*Math.sin(l);a===0?e.moveTo(c,d):e.lineTo(c,d);}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=`${ye("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(xE(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 d of o)e.beginPath(),d.kind==="vline"?(e.moveTo(d.x,d.y0),e.lineTo(d.x,d.y1)):e.arc(d.cx,d.cy,d.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]),d=t.isUp()?J:X;e.save(),e.globalAlpha=.12*e.globalAlpha,e.fillStyle=d,e.fillRect(s,a,l,c),e.restore(),e.setLineDash(Kn(t.style.lineStyle,t.style.lineWidth)),e.strokeStyle=d,e.lineWidth=t.style.lineWidth,e.strokeRect(s,a,l,c),e.setLineDash([]);let u=t.measureLabel(n),h=ye(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-(u.length-1)*p/2;u.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:d}=o,u=a-s,h=(b,v,y)=>{e.save(),e.globalAlpha=.13*e.globalAlpha,e.fillStyle=y,e.fillRect(s,Math.min(b,v),u,Math.abs(v-b)),e.restore();};h(l,d,t.profitColor),h(l,c,t.lossColor);let p=(b,v)=>this.stroke(e,{...t.style,lineColor:v},()=>{e.moveTo(s,b),e.lineTo(a,b);});if(p(d,t.profitColor),p(c,t.lossColor),p(l,t.style.lineColor),!t.showText)return;let m=ye(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+u/2,g=Math.min(l,c,d)-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+d)/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,d,u,h,p)=>{e.save(),e.fillStyle=c,e.beginPath(),e.moveTo(o.x0,d),e.lineTo(o.x1,u),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,d,u,h)=>this.stroke(e,{lineColor:c,lineWidth:t.style.lineWidth,lineStyle:d},()=>{e.moveTo(o.x0,u),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 d=e.measureText(c).width,u=5,h=4,p=d+u*2,m=o.x0-h-p,f=o.midY0-9;e.save(),e.globalAlpha=.9*e.globalAlpha,Wt(e,m,f-8,p,16,3),e.fillStyle=bv,e.fill(),e.restore(),e.fillStyle=i.textColor,e.textAlign="left",e.textBaseline="middle",e.fillText(c,m+u,f),e.textBaseline="alphabetic";}}paintFixedRangeVp(e,t,n,i){let o=t.layout(n);if(!o)return;let s=t.frvp,{profile:a,maxW:l,anchorX:c,grow:d,yEdges:u}=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 v=u[f],y=u[f+1],w=Math.min(v,y),P=Math.max(1,Math.abs(y-v)-1),x=b/a.maxTotal*l,S=g.up/b*x,E=f>=a.vaFrom&&f<=a.vaTo,L=E?s.vaUpColor:s.upColor,T=E?s.vaDownColor:s.downColor,k=d===1?c:c-x;S>0&&(e.fillStyle=L,e.fillRect(k,w,S,P)),x-S>0&&(e.fillStyle=T,e.fillRect(k+S,w,x-S,P));}let h=t.style.lineWidth,p=(f,g,b,v)=>{!f||v==null||yv(g)||this.stroke(e,{lineColor:g,lineWidth:h,lineStyle:b},()=>{e.moveTo(o.x0,v),e.lineTo(o.x1,v);});};p(s.showVah,s.vahColor,s.vahStyle,o.vahY),p(s.showVal,s.valColor,s.valStyle,o.valY),p(s.showPoc,s.pocColor??Ne(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||yv(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],d=s[1][1],u=t.text,h=ye(u?.size??"normal");e.font=`${u?.bold?"bold ":""}${u?.italic?"italic ":""}${h}px ${i.fontFamily}`;let p=(u?.value??"").split(`
|
|
840
|
+
`),m=Math.max(8,...p.map(M=>e.measureText(M).width)),f=9,g=6,b=St(h),v=m+f*2,y=p.length*b+g*2,w=c-v/2,P=d-y/2,x=v/2,S=y/2,E=a-c,L=l-d,T=Math.min(o,v/2,y/2),k=null;if(Math.abs(E)>x||Math.abs(L)>S){let M=Math.max(6,Math.min(v,y)*.18);if(Math.abs(E)/x>=Math.abs(L)/S){let C=E>0?w+v:w,I=Math.max(P+T+M,Math.min(P+y-T-M,d+L*(C-c)/(E||1)));k={edge:E>0?"right":"left",at:I,apex:[a,l],half:M};}else {let C=L>0?P+y:P,I=Math.max(w+T+M,Math.min(w+v-T-M,c+E*(C-d)/(L||1)));k={edge:L>0?"bottom":"top",at:I,apex:[a,l],half:M};}}e.save(),e.fillStyle=je(t,i)??i.background,xv(e,w,P,v,y,T,k),e.fill(),e.restore(),this.applyStroke(e,t.style),xv(e,w,P,v,y,T,k),e.stroke(),e.setLineDash([]),e.fillStyle=u?.color??Ne(je(t,i)??i.background),e.textBaseline="top",e.textAlign="left",p.forEach((M,C)=>e.fillText(M,w+f,P+g+C*b));}paintTextPlate(e,t,n,i,o,s,a,l,c,d,u){e.save(),e.fillStyle=je(t,n)??n.background,Wt(e,i,o,s,a,5),e.fill(),e.restore(),this.applyStroke(e,t.style),Wt(e,i,o,s,a,5),e.stroke(),e.setLineDash([]),e.fillStyle=t.text?.color??Ne(je(t,n)??n.background),e.textBaseline="top",e.textAlign="left",l.forEach((h,p)=>e.fillText(h,i+d,o+u+p*c));}measureText(e,t,n,i){let o=t.text,s=ye(o?.size??"normal");e.font=`${o?.bold?"bold ":""}${o?.italic?"italic ":""}${s}px ${n.fontFamily}`;let a=(o?.value||i).split(`
|
|
841
|
+
`),l=Math.max(8,...a.map(c=>e.measureText(c).width));return {lines:a,tw:l,fs:s,lh:St(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:d}=this.measureText(e,t,i,"Note"),u=8,h=5;this.paintTextPlate(e,t,i,s,a,c+u*2,l.length*d+h*2,l,d,u,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,d]=o[1],u=wv(s.price),h=t.text,p=ye(h?.size??"normal");e.font=`${h?.bold?"bold ":""}${h?.italic?"italic ":""}${p}px ${i.fontFamily}`;let m=9,f=6,g=e.measureText(u).width+m*2,b=St(p)+f*2,v=c-g/2,y=d-b/2;this.stroke(e,t.style,()=>{e.moveTo(a,l),e.lineTo(c,d);}),e.fillStyle=t.style.lineColor,e.beginPath(),e.arc(a,l,3,0,Math.PI*2),e.fill(),e.save(),e.fillStyle=je(t,i)??i.background,Wt(e,v,y,g,b,5),e.fill(),e.restore(),this.applyStroke(e,t.style),Wt(e,v,y,g,b,5),e.stroke(),e.setLineDash([]),e.fillStyle=h?.color??Ne(je(t,i)??i.background),e.textBaseline="middle",e.textAlign="center",e.fillText(u,c,d+.5);}paintSignpost(e,t,n,i){let o=t.points(n);if(!o)return;let[s,a]=o[0],[l,c]=o[1],{lines:d,tw:u,lh:h}=this.measureText(e,t,i,"Signpost"),p=9,m=6,f=u+p*2,g=d.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,d,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=wv(s.price),d=t.text,u=ye(d?.size??"normal");e.font=`${d?.bold?"bold ":""}${d?.italic?"italic ":""}${u}px ${i.fontFamily}`;let h=e.measureText(c).width,p=8,m=4,f=6,g=h+p*2,b=St(u)+m*2,v=l-b/2,y=je(t,i)??i.background;e.save(),e.fillStyle=y,e.beginPath(),e.moveTo(a,l),e.lineTo(a+f,l-5),e.lineTo(a+f,l+5),e.closePath(),e.fill(),Wt(e,a+f,v,g,b,4),e.fill(),e.restore(),this.applyStroke(e,t.style),Wt(e,a+f,v,g,b,4),e.stroke(),e.setLineDash([]),e.fillStyle=d?.color??Ne(y),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=je(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=ac(h[0],h[1],p[0],p[1],o[0][0],o[0][1],o[1][0],o[1][1])??h,g=ac(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 d=t.vertexLabels();if(e.fillStyle=i.textColor,e.font=`bold 12px ${i.fontFamily}`,e.textAlign="center",o.forEach((h,p)=>{let m=d[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?wo:g===false?xo:i.textColor,e.fillText(p.toFixed(3),(m[0]+f[0])/2+6,(m[1]+f[1])/2);}}let u=t.patternName();if(u&&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?xo:wo,e.textAlign="center",e.textBaseline=m?"bottom":"top",e.fillText(`${u} ${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],d=t.anchors[1];if(!c||!d)return;let u=d.price-c.price,h=c.price!==0?u/c.price*100:0,p=n.barsBetween?Math.abs(Math.round(n.barsBetween(c.time,d.time))):0,m=u>=0?"+":"",f=`${m}${u.toFixed(2)} (${m}${h.toFixed(2)}%) ${p} bars`,g=(o+a)/2,b=(s+l)/2;e.font="11px monospace";let v=e.measureText(f).width+12,y=18,w=g-2,P=b-y-4;e.save(),e.globalAlpha=.9*e.globalAlpha,Wt(e,w,P,v,y,3),e.fillStyle=bv,e.fill(),e.strokeStyle=wE,e.lineWidth=1,e.stroke(),e.restore(),e.fillStyle=u>=0?J:X,e.textAlign="left",e.textBaseline="middle",e.fillText(f,w+6,P+y/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 d=l-s,u=c-a,h=Math.atan2(-u,d),p=h*(180/Math.PI),m=Math.min(30,Math.hypot(d,u)*.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(d),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+(u<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(Kn(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,gE,0,Math.PI*2),e.fillStyle=vE,e.fill(),e.strokeStyle=bE,e.stroke();}};function yv(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 wv(r){let e=su(r);return r.toLocaleString("en-US",{minimumFractionDigits:e,maximumFractionDigits:e})}function Wt(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 xv(r,e,t,n,i,o,s){let a=(l,c,d)=>{if(s&&s.edge===l){let[u,h]=s.apex;l==="top"?(r.lineTo(s.at-s.half,t),r.lineTo(u,h),r.lineTo(s.at+s.half,t)):l==="bottom"?(r.lineTo(s.at+s.half,t+i),r.lineTo(u,h),r.lineTo(s.at-s.half,t+i)):l==="right"?(r.lineTo(e+n,s.at-s.half),r.lineTo(u,h),r.lineTo(e+n,s.at+s.half)):(r.lineTo(e,s.at+s.half),r.lineTo(u,h),r.lineTo(e,s.at-s.half));}r.lineTo(c,d);};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 xE(r){if(!Number.isFinite(r))return "";let e=Math.round(r*1e3)/1e3;return String(e)}function SE(r,e){let t=r.text;if(!t)return null;let n=r.handlePoints(e),i=t.value.split(`
|
|
842
|
+
`).length,o=St(ye(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:Zb(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 Kr(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}var Sv=3,CE=4,Cv=Math.PI/4,Tv=new Set(["trendline","ray","extendedline","infoline","trendangle","arrow"]),Nl=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}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)/Cv)*Cv;return o.pxToPoint(s+l*Math.cos(c),a+l*Math.sin(c),t)}placingPivot(e){return Tv.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}down(e,t,n="off",i=false){let o=this.deps.projector();if(this.state.kind==="placing"){if(this.state.draft.placementMode()!=="click")return;let l=i?this.placingPivot(this.state.draft):null,c=l?this.resolveAngleSnapped(l,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,c)),this.state.draft.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let s=this.deps.activeTool();if(s){let l=o.paneIdAtY(t)??"price",c=qt(s,{paneId:l,anchors:[this.resolve(e,t,l,n)],style:this.deps.lastStyle()});if(!c)return;this.state={kind:"placing",draft:c,need:c.anchorSchema().max,cursor:null},c.placementMode()==="click"&&c.anchors.length>=this.state.need?this.finalize():this.deps.changed();return}let a=this.hitAt(e,t);if(a){if(i){this.deps.emit({kind:"select",ids:[a.id],additive:true});return}let l=a.hitHandle(e,t,o,6);this.state={kind:"pressed",id:a.id,handle:l,grab:o.pxToPoint(e,t,a.paneId),orig:TE(a),px:e,py:t,moved:false};}}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!=="pressed")return;let o=this.byId(this.state.id);if(!(!o||o.locked)&&!(!this.state.moved&&Math.abs(e-this.state.px)<=Sv&&Math.abs(t-this.state.py)<=Sv)){if(this.state.moved=true,this.state.handle>=0){let s=o.anchors[this.state.handle];if(s){let a=i&&Tv.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);EE(s,l,o.anchorSchema().slots[this.state.handle]?.free??"both");}o.constrainHandleDrag(this.state.handle);}else {let s=this.deps.projector().pxToPoint(e,t,o.paneId);this.snapAt=null;let a=s.time-this.state.grab.time,l=s.price-this.state.grab.price;o.anchors=o.translateBody(a,l,this.state.orig);}this.deps.changed();}}up(e,t){if(this.snapAt=null,this.state.kind==="placing"){let s=this.state.draft.placementMode();s==="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()):s==="freehand"&&(this.state.draft.anchors.length>=this.state.draft.anchorSchema().min?this.finalize():this.discardPlacing());return}if(this.state.kind!=="pressed")return;let{id:n,moved:i}=this.state;this.state={kind:"idle"};let o=this.byId(n);i?(o&&this.deps.emit({kind:"edit",doc:o.serialize()}),this.deps.changed()):this.deps.openSettings(n,e,t);}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"){let e=this.byId(this.state.id);return e&&this.state.moved&&(e.anchors=this.state.orig.map(t=>({time:t.time,price:t.price}))),this.state={kind:"idle"},this.deps.changed(),true}return 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?qt(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)>CE){if(n.anchors.length>=this.state.need){let l=n.anchors.length-1;n.anchors=n.anchors.filter((c,d)=>d%2===0||d===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 Kr(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 TE(r){return r.anchors.map(e=>({time:e.time,price:e.price}))}function EE(r,e,t){(t==="both"||t==="x")&&(r.time=e.time),(t==="both"||t==="y")&&(r.price=e.price);}var PE=[{value:"price",label:"Price"},{value:"points",label:"Points"}],LE=[{value:"right",label:"Right"},{value:"left",label:"Left"}],ME={position:"Position size",frvp:"Volume profile",levels:"Levels"},Vl=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=dt(e.serialize()),o=io({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 $e)this.buildPosition(o,e,t);else if(n==="frvp"&&e instanceof Ve)this.buildFrvp(o,e,t);else if(n==="levels")this.buildLevels(o,e,t);else return;let s=new Nt({host:this.host,title:ME[n],modal:false,contained:true,align:"center",draggable:true,flush:true,className:"vela-dialog--form",closeOnEscape:false,footer:l=>{l.append(Ev("Cancel",false,()=>{t.restore?.(i),this.close();}),Ev("Ok",true,()=>this.close()));},onOpenChange:l=>{l||this.close();}});ve(s.panel,this.theme),s.body.appendChild(o);let a=l=>{if(!(l.target!==s.backdrop&&l.target!==s.positioner)){if(xt()||$n(l)){de();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 $e?p:t},o=[],s=()=>o.forEach(p=>p()),a=p=>Math.round(p*1e8)/1e8,l=(p,m,f)=>{let g=q({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(he({label:p,control:g.el}));},c=(p,m,f)=>{let g="price",b=()=>a(i().levelDisplayValue(f,g)),v=q({kind:"number",value:b(),fill:false,commit:"blur",onChange:w=>{n.patch({[m]:i().levelPriceFromDisplay(f,g,w)}),s();}}),y=q({kind:"select",options:PE,value:g,fill:false,theme:this.theme,onChange:w=>{g=w,v.setValue?.(b());}});o.push(()=>{document.activeElement!==v.el.querySelector("input")&&v.setValue?.(b());}),e.appendChild(he({label:p,control:[v.el,y.el]}));};e.appendChild(Vt("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(Vt("Levels",{variant:"inputs"}));let d=q({kind:"select",options:Ys,value:i().direction,fill:false,theme:this.theme,onChange:p=>{n.patch({direction:p}),s();}});o.push(()=>d.setValue?.(i().direction)),e.appendChild(he({label:"Direction",control:d.el})),l("Entry price","entryPrice"),c("Stop","stopPrice","stop"),c("Target","targetPrice","target"),e.appendChild(Vt("Display",{variant:"inputs"}));let u=[["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 u)e.appendChild(he({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 d=n.resolve();return d instanceof Ve?d.frvp:t.frvp},o=i(),s=(d,u,h,p,m,f=true)=>{e.appendChild(he({label:d,control:q({kind:"number",value:o[u],min:h,max:p,step:m,integer:f,fill:false,commit:"blur",onChange:g=>n.patch({[`frvp.${u}`]:g})}).el}));};s("Rows","rows",1,500,1),s("Value Area","valueAreaPct",0,100,1),s("Width %","widthPct",0,100,1),e.appendChild(he({label:"Anchor",control:q({kind:"select",options:LE,value:o.anchor,fill:false,theme:this.theme,onChange:d=>n.patch({"frvp.anchor":d})}).el}));let a=(d,u)=>{e.appendChild(he({label:d,fit:true,control:q({kind:"color",theme:this.theme,get:()=>i()[u],onChange:h=>n.patch({[`frvp.${u}`]:h})}).el}));};a("Up Volume","upColor"),a("Down Volume","downColor"),a("Value Area Up","vaUpColor"),a("Value Area Down","vaDownColor");let l=Pe.map(d=>({value:d.value,label:d.label})),c=(d,u,h,p)=>{let m=document.createElement("div");m.className="vela-field-span",m.style.cssText="display:flex;align-items:center;gap:8px;";let f=q({kind:"switch",checked:!!o[u],onChange:w=>n.patch({[`frvp.${u}`]:w})}),g=document.createElement("span");g.className="vela-field-label",g.style.flex="1",g.textContent=d;let b=o[h]??Ne(this.theme.background),v=q({kind:"color",theme:this.theme,get:()=>b,onChange:w=>{b=w,n.patch({[`frvp.${h}`]:w});}}),y=q({kind:"select",options:l,value:o[p],fill:false,theme:this.theme,onChange:w=>n.patch({[`frvp.${p}`]:w})});m.append(f.el,g,v.el,y.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 Ae;if(o){let s=t;e.appendChild(he({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=q({kind:"switch",checked:s.enabled,onChange:m=>n.patch({[`levels.${a}.enabled`]:m})}),d=s.color,u=q({kind:"color",theme:this.theme,get:()=>d,onChange:m=>{d=m,n.patch({[`levels.${a}.color`]:m});}}),h=s.ratio,p=q({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,u.el,p.el),!o){let m=q({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 Ev(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 un=30,kE=21,Pv="vela-drawing-popup-styles",Lv="3";function IE(){if(typeof document>"u")return;let r=document.getElementById(Pv);if(r?.dataset.rev===Lv)return;let e=r??document.createElement("style");e.id=Pv,e.dataset.rev=Lv,e.textContent=`
|
|
843
843
|
.vela-dpop-btn{background:transparent;color:var(--vela-fg-muted);transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease;}
|
|
844
844
|
.vela-dpop-btn:hover{background:var(--vela-hover-strong);color:var(--vela-fg-bright);}
|
|
845
845
|
.vela-dpop-btn[data-active='1']{background:var(--vela-active);color:var(--vela-fg-bright);}
|
|
@@ -848,7 +848,7 @@ ${On(".vela-sd-pane")}
|
|
|
848
848
|
.vela-dpop-item[data-active='1']{background:var(--vela-active);}
|
|
849
849
|
/* A finger needs a wider grab zone than a cursor \u2014 grow the move handle on touch-first
|
|
850
850
|
devices (the glyph stays centered; only the hit target widens). */
|
|
851
|
-
@media (pointer: coarse){.vela-dpop-grip{width:${dn+14}px !important;}}`,r||document.head.appendChild(e);}var Nl=class{constructor(e,t){this.host=e;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?.();};this.theme=t,this.settingsDialog=new Fl(e,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(),TE(),this.onClose=i??null;let o=this.theme,s=e.schema(),a=new Set(s.fields.map(v=>v.path)),l=s.textIsContent===true||!a.has("text.value"),c=document.createElement("div");c.className="vela-dpop",c.style.cssText=`position:absolute;z-index:22;background:${o.background};border:1px solid var(--vela-border);border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow);color:${o.textColor};font:var(--vela-font-size-md) ${o.fontFamily};display:flex;flex-direction:column;pointer-events:auto;overflow:hidden;`,ve(c,o),c.addEventListener("pointerdown",v=>{v.target?.closest(".vela-select-trigger, .vela-color-field")||de();});let d=document.createElement("div");if(d.style.cssText="display:flex;align-items:center;gap:2px;padding:4px;",d.appendChild(this.dragHandle()),a.has("glyph")){let v=e.glyph??oi[0];d.appendChild(this.dropdown("Icon",oi,v,y=>zE(y),y=>n.patch({glyph:y})));}if(a.has("size")){let v=e.size??"normal";d.appendChild(this.dropdown("Icon size",ms,v,y=>$E(y),y=>n.patch({size:y}),{label:yo}));}if(a.has("style.lineColor")&&d.appendChild(this.colorButton("Line color",Jn,e.style.lineColor||R,v=>n.patch({"style.lineColor":v}))),a.has("style.lineWidth")){let v=s.fields.find(y=>y.path==="style.lineWidth");v?.kind==="number"&&(v.min??1)>1?d.appendChild(this.widthInput("Line width",e.style.lineWidth,v.min??1,v.max??60,v.step??1,y=>n.patch({"style.lineWidth":y}))):d.appendChild(this.dropdown("Line width",[1,2,3,4],e.style.lineWidth,y=>jr(y,"solid"),y=>n.patch({"style.lineWidth":y}),{label:y=>`${y}px`,labelInTrigger:true}));}a.has("style.lineStyle")&&d.appendChild(this.dropdown("Line style",Pe.map(v=>v.value),e.style.lineStyle,v=>jr(2,v),v=>n.patch({"style.lineStyle":v}),{label:wo})),a.has("style.fillColor")&&d.appendChild(this.colorButton("Fill",Xr,je(e,this.theme)??e.style.fillColor??R,v=>n.patch({"style.fillColor":v})));let u=a.has("frvp.rows")&&e instanceof Ve,h=a.has("riskPercent")&&e instanceof $e;if(h){let v=e;d.appendChild(this.colorButton("Profit zone",Xr,v.profitColor,y=>n.patch({profitColor:y}))),d.appendChild(this.colorButton("Loss zone",Xr,v.lossColor,y=>n.patch({lossColor:y})));}let p=e.reg;if(a.has("reg.midColor")&&p){let v=Pe.map(y=>y.value);d.appendChild(this.colorButton("Midline color",Jn,p.midColor,y=>n.patch({"reg.midColor":y}))),d.appendChild(this.dropdown("Midline style",v,p.midStyle,y=>jr(2,y),y=>n.patch({"reg.midStyle":y}),{label:wo})),d.appendChild(this.colorButton("Upper line color",Jn,p.upperColor,y=>n.patch({"reg.upperColor":y}))),d.appendChild(this.dropdown("Upper line style",v,p.upperStyle,y=>jr(2,y),y=>n.patch({"reg.upperStyle":y}),{label:wo})),d.appendChild(this.colorButton("Lower line color",Jn,p.lowerColor,y=>n.patch({"reg.lowerColor":y}))),d.appendChild(this.dropdown("Lower line style",v,p.lowerStyle,y=>jr(2,y),y=>n.patch({"reg.lowerStyle":y}),{label:wo})),d.appendChild(this.colorButton("Upper fill",Xr,p.upperFill,y=>n.patch({"reg.upperFill":y}))),d.appendChild(this.colorButton("Lower fill",Xr,p.lowerFill,y=>n.patch({"reg.lowerFill":y}))),d.appendChild(this.toggle("Show R\xB2",FE,p.showR2,y=>n.patch({"reg.showR2":y})));}let m=e.vwap;if(a.has("vwap.midColor")&&m){let v=Pe.map(w=>w.value),y=[.5,1,1.5,2,2.5,3,4,5];d.appendChild(this.colorButton("VWAP color",Jn,m.midColor,w=>n.patch({"vwap.midColor":w}))),d.appendChild(this.dropdown("VWAP style",v,m.midStyle,w=>jr(2,w),w=>n.patch({"vwap.midStyle":w}),{label:wo})),d.appendChild(this.dropdown("Band multiplier",y,m.multiplier,()=>NE,w=>n.patch({"vwap.multiplier":w}),{label:w=>`${w}\u03C3`,labelInTrigger:true})),d.appendChild(this.colorButton("Upper band color",Jn,m.upperColor,w=>n.patch({"vwap.upperColor":w}))),d.appendChild(this.colorButton("Lower band color",Jn,m.lowerColor,w=>n.patch({"vwap.lowerColor":w}))),d.appendChild(this.colorButton("Band fill",Xr,m.bandFill,w=>n.patch({"vwap.bandFill":w})));}if(a.has("maxCurvature")){let v=e.maxCurvature??24;d.appendChild(this.dropdown("Max curvature",lc,v,()=>VE,y=>n.patch({maxCurvature:y}),{label:y=>`n=${y}`,labelInTrigger:true}));}if(a.has("mach")){let v=e.mach??2;d.appendChild(this.dropdown("Mach number",dc,v,()=>BE,y=>n.patch({mach:y}),{label:y=>`M=${y}`,labelInTrigger:true}));}if(a.has("waveCount")){let v=e.waveCount??6;d.appendChild(this.dropdown("Waves",cc,v,()=>_E,y=>n.patch({waveCount:y}),{label:y=>`${y}`,labelInTrigger:true}));}let f=e;a.has("showPrice")&&d.appendChild(this.toggle("Show price",EE,f.showPrice!==false,v=>n.patch({showPrice:v}))),a.has("showDate")&&d.appendChild(this.toggle("Show date",PE,f.showDate!==false,v=>n.patch({showDate:v}))),a.has("text.color")&&l&&d.appendChild(this.colorButton("Text color",lu,e.text?.color||o.textColor,v=>n.patch({"text.color":v}))),a.has("text.size")&&l&&d.appendChild(this.dropdown("Text size",qe.map(v=>v.value),e.text?.size??"normal",v=>Pv(v),v=>n.patch({"text.size":v}),{label:yo})),a.has("text.bold")&&!a.has("text.value")&&d.appendChild(this.toggle("Bold",Tv,!!e.text?.bold,v=>n.patch({"text.bold":v}))),a.has("text.italic")&&!a.has("text.value")&&d.appendChild(this.toggle("Italic",Ev,!!e.text?.italic,v=>n.patch({"text.italic":v}))),a.has("text.value")&&d.appendChild(this.iconBtn("Text",lu,()=>this.toggleTextPanel(e,n,!l)));let g=e.editableLevels();if(g&&!(e instanceof Ae)){let v=e,y=qe.map(w=>w.value);d.appendChild(this.dropdown("Numbers size",y,v.numbersSize??"small",w=>GE(w),w=>n.patch({numbersSize:w}),{label:yo})),d.appendChild(this.dropdown("Label size",y,v.labelsSize??"normal",w=>Pv(w),w=>n.patch({labelsSize:w}),{label:yo}));}d.appendChild(this.divider()),u&&d.appendChild(this.iconBtn("Settings",cu,()=>this.settingsDialog.open(e,n,"frvp"))),h&&d.appendChild(this.iconBtn("Position size",cu,()=>this.settingsDialog.open(e,n,"position"))),g&&d.appendChild(this.iconBtn("Levels",cu,()=>this.settingsDialog.open(e,n,"levels"))),d.appendChild(this.toggle("Lock",LE,e.locked,v=>n.setLocked(v)));let b=this.iconBtn("Delete",IE,()=>n.remove());b.style.color="var(--vela-danger)",d.appendChild(b),d.appendChild(this.kebabButton(n)),c.append(d),this.host.appendChild(c),this.el=c,c.addEventListener("mouseover",v=>{let y=v.target.closest("[data-tip]");y?this.showTip(y):this.hideTip();}),c.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 Un({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",lu,i?.color||this.theme.textColor,l=>t.patch({"text.color":l}),14),this.dropdown("Text size",qe.map(l=>l.value),i?.size??"normal",l=>WE(l),l=>t.patch({"text.size":l}),{label:yo})),a.append(this.toggle("Bold",Tv,!!i?.bold,l=>t.patch({"text.bold":l})),this.toggle("Italic",Ev,!!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:${dn}px;height:${dn}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=Gt(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:${dn}px;height:${dn}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=Gt(AE),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=u=>{let h=n.offsetWidth,p=n.offsetHeight,m=a+(u.clientX-o),f=l+(u.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`;},d=()=>{e.style.cursor="grab",window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d);};window.addEventListener("pointermove",c),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d);}),e}kebabButton(e){let t=this.base("More");return t.innerHTML=Gt(RE),t.addEventListener("pointerdown",n=>n.stopPropagation()),t.addEventListener("click",n=>{if(n.stopPropagation(),this.menuOwner===t){this.closeMenu();return}this.openActionMenu(t,[{icon:ME,label:"Bring to front",onClick:()=>e.reorder("front")},{icon:kE,label:"Send to back",onClick:()=>e.reorder("back")},{icon:DE,label:"Reset settings",onClick:()=>e.resetSettings()}]);}),t}hostFloat(e,t){let n=this.theme,i=new Be({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);}}),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}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=Gt(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,d=s.left-o.left+s.width/2-a/2;d=Math.max(4,Math.min(d,o.width-a-4));let u=s.top-o.top-l-c,h=u>=4?u:s.bottom-o.top+c;i.style.left=`${Math.round(d)}px`,i.style.top=`${Math.round(h)}px`;}hideTip(){this.tipEl?.remove(),this.tipEl=null;}toggle(e,t,n,i){let o=this.base(e);o.innerHTML=Gt(t);let s=l=>{o.dataset.active=l?"1":"0";};s(n);let a=n;return o.addEventListener("click",()=>{a=!a,s(a),i(a);}),o}widthInput(e,t,n,i,o,s){let a=new Gn({value:t,min:n,max:i,step:o,integer:o>=1,size:"sm",fill:false,compact:true,commit:"blur",title:e,onChange:s});return a.el.dataset.tip=e,HE(a.el),a.el}dropdown(e,t,n,i,o,s={}){let a=this.base(e);a.style.width="auto",a.style.minWidth=`${dn}px`,a.style.padding="0 4px",a.style.gap="2px";let l=n,c=d=>{a.replaceChildren();let u=document.createElement("span");if(u.style.cssText="display:flex;",u.innerHTML=Gt(i(d)),a.appendChild(u),s.label&&s.labelInTrigger){let p=document.createElement("span");p.textContent=s.label(d),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=Gt(OE,12),a.appendChild(h);};return c(l),a.addEventListener("pointerdown",d=>d.stopPropagation()),a.addEventListener("click",d=>{if(d.stopPropagation(),this.menuOwner===a){this.closeMenu();return}this.openMenu(a,t,l,i,s.label,u=>{l=u,c(u),o(u);});}),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 d=c===n,u=document.createElement("button");u.type="button",u.className="vela-dpop-item",u.dataset.active=d?"1":"0",u.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=document.createElement("span");if(h.style.cssText="display:flex;flex:none;width:22px;justify-content:center;",h.innerHTML=Gt(i(c),18),u.appendChild(h),o){let p=document.createElement("span");p.textContent=o(c),p.style.cssText="flex:1;font-variant-numeric:tabular-nums;",u.appendChild(p);}u.addEventListener("click",p=>{p.stopPropagation(),l.hide(),s(c);}),a.appendChild(u);}}}),this.menuOwner=e;}closeMenu(){this.menuPop?.hide();}colorButton(e,t,n,i,o=17){let s=document.createElement("button");s.type="button",s.dataset.tip=e,s.className="vela-dpop-btn",s.style.cssText=`position:relative;width:${dn}px;height:${dn}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 a=document.createElement("span");a.style.cssText="display:flex;",a.innerHTML=Gt(t,o);let l=document.createElement("span");l.style.cssText=`display:block;height:3px;width:${Math.round(o*.85)}px;border-radius:2px;background:${n};`,s.append(a,l);let c=n;return s.addEventListener("pointerdown",d=>d.stopPropagation()),s.addEventListener("click",d=>{d.stopPropagation(),this.toggleColorPopover(s,c,u=>{c=u,l.style.background=u,i(u);});}),s}toggleColorPopover(e,t,n){if(this.colorOwner===e){this.closeColorPopover();return}this.openColorPopover(e,t,n);}openColorPopover(e,t,n){let i=this.theme;this.colorPop=this.hostFloat(e,{zIndex:25,padding:"10px",fill:o=>{o.appendChild(Ji(t,i,n));}}),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}},Jn=$("brush"),Xr=$("bucket"),lu=$("type"),EE=$("price-delta"),PE=$("date-delta"),LE=$("lock"),ME=$("bring-front"),kE=$("send-back"),IE=$("trash"),Tv=$("bold"),Ev=$("italic"),AE=$("grip"),RE=$("kebab"),DE=$("reset"),cu=$("gear"),OE=$("chevron-down"),FE=$("r-squared"),NE=$("bands"),VE=$("dedekind"),_E=$("sonic"),BE=$("supersonic");function jr(r,e){let t=e==="dashed"?"5,3":e==="dotted"?"1.5,3":"";return A(`<line x1="3.5" y1="12" x2="20.5" y2="12" stroke-width="${Number(r)||2}" stroke-dasharray="${t}"/>`)}function HE(r){r.addEventListener("keydown",e=>e.stopPropagation());}function xo(r,e,t=17,n=""){return rc(`<text x="12" y="${t}" font-size="${e}" text-anchor="middle"${n?" "+n:""}>${r}</text>`)}function zE(r){return xo(String(r),15)}function $E(r){return xo("\u25CF",(du[String(r)]??13)+4)}function WE(r){return xo(String(r).charAt(0).toUpperCase(),15)}var du={small:10,normal:13,large:16,huge:20};function GE(r){return xo("12",(du[String(r)]??13)-1,16.5,'font-weight="600"')}function Pv(r){return xo("T",(du[String(r)]??13)+2)}function Lv(r){return r.charAt(0).toUpperCase()+r.slice(1)}function yo(r){return qe.find(e=>e.value===r)?.label??Lv(String(r))}function wo(r){return Pe.find(e=>e.value===r)?.label??Lv(String(r))}function Gt(r,e=CE){return r.replace("<svg ",`<svg width="${e}" height="${e}" `)}var uu=44,hu=16,So=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??uu,this.dock=c.dock??"absolute",this.onCollapse=c.onCollapse??(()=>{}),this.onDrawingsSync=c.onDrawingsSync??null,UE(),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;ve(this.root,e);let t=this.collapsed?hu: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=_l(n?nP:tP);}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(YE,"Cursor",()=>this.onArm(null)),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(KE,"Measure",()=>this.onMeasure()),this.root.appendChild(this.measureBtn),this.eraserBtn=this.makeButton(JE,"Eraser (click/drag to delete)",()=>this.onEraser()),this.root.appendChild(this.eraserBtn),this.root.appendChild(this.makeMagnetCell()),this.stayBtn=this.makeButton(qE,"Stay in drawing mode",()=>this.toggleStay()),this.root.appendChild(this.stayBtn),this.onDrawingsSync&&(this.syncBtn=this.makeButton(ZE,"Sync drawings on all charts",()=>this.toggleDrawingsSync()),this.root.appendChild(this.syncBtn)),this.collapseBtn=this.makeButton(Iv,"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=Vl(this.collapsed?XE:Iv,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=Vl(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=rP(QE),o.addEventListener("click",a=>{a.stopPropagation(),s();}),n.appendChild(o);}return this.tipDisposers.push(ht(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:jE,multi:true,onIcon:()=>this.toggleMagnet(),onArrow:()=>this.onMagnetArrowClick()});return this.magnetCell=e,this.magnetIcon=t,e}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===Mv;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;`,ve(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(Mv,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=_l(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=_l(eP)),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=Vl(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=Vl(e)),this.tipDisposers.push(ht(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}},Mv="__magnet__",kv="vela-drawing-toolbar-styles";function UE(){if(typeof document>"u")return;let r=document.getElementById(kv);r||(r=document.createElement("style"),r.id=kv,document.head.appendChild(r)),r.textContent=`
|
|
851
|
+
@media (pointer: coarse){.vela-dpop-grip{width:${un+14}px !important;}}`,r||document.head.appendChild(e);}var _l=class{constructor(e,t){this.host=e;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?.();};this.theme=t,this.settingsDialog=new Vl(e,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(),IE(),this.onClose=i??null;let o=this.theme,s=e.schema(),a=new Set(s.fields.map(v=>v.path)),l=s.textIsContent===true||!a.has("text.value"),c=document.createElement("div");c.className="vela-dpop",c.style.cssText=`position:absolute;z-index:22;background:${o.background};border:1px solid var(--vela-border);border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow);color:${o.textColor};font:var(--vela-font-size-md) ${o.fontFamily};display:flex;flex-direction:column;pointer-events:auto;overflow:hidden;`,ve(c,o),c.addEventListener("pointerdown",v=>{v.target?.closest(".vela-select-trigger, .vela-color-field")||de();});let d=document.createElement("div");if(d.style.cssText="display:flex;align-items:center;gap:2px;padding:4px;",d.appendChild(this.dragHandle()),a.has("glyph")){let v=e.glyph??li[0];d.appendChild(this.dropdown("Icon",li,v,y=>KE(y),y=>n.patch({glyph:y})));}if(a.has("size")){let v=e.size??"normal";d.appendChild(this.dropdown("Icon size",gs,v,y=>XE(y),y=>n.patch({size:y}),{label:So}));}if(a.has("style.lineColor")&&d.appendChild(this.colorButton("Line color",Jn,e.style.lineColor||R,v=>n.patch({"style.lineColor":v}))),a.has("style.lineWidth")){let v=s.fields.find(y=>y.path==="style.lineWidth");v?.kind==="number"&&(v.min??1)>1?d.appendChild(this.widthInput("Line width",e.style.lineWidth,v.min??1,v.max??60,v.step??1,y=>n.patch({"style.lineWidth":y}))):d.appendChild(this.dropdown("Line width",[1,2,3,4],e.style.lineWidth,y=>jr(y,"solid"),y=>n.patch({"style.lineWidth":y}),{label:y=>`${y}px`,labelInTrigger:true}));}a.has("style.lineStyle")&&d.appendChild(this.dropdown("Line style",Pe.map(v=>v.value),e.style.lineStyle,v=>jr(2,v),v=>n.patch({"style.lineStyle":v}),{label:Co})),a.has("style.fillColor")&&d.appendChild(this.colorButton("Fill",Xr,je(e,this.theme)??e.style.fillColor??R,v=>n.patch({"style.fillColor":v})));let u=a.has("frvp.rows")&&e instanceof Ve,h=a.has("riskPercent")&&e instanceof $e;if(h){let v=e;d.appendChild(this.colorButton("Profit zone",Xr,v.profitColor,y=>n.patch({profitColor:y}))),d.appendChild(this.colorButton("Loss zone",Xr,v.lossColor,y=>n.patch({lossColor:y})));}let p=e.reg;if(a.has("reg.midColor")&&p){let v=Pe.map(y=>y.value);d.appendChild(this.colorButton("Midline color",Jn,p.midColor,y=>n.patch({"reg.midColor":y}))),d.appendChild(this.dropdown("Midline style",v,p.midStyle,y=>jr(2,y),y=>n.patch({"reg.midStyle":y}),{label:Co})),d.appendChild(this.colorButton("Upper line color",Jn,p.upperColor,y=>n.patch({"reg.upperColor":y}))),d.appendChild(this.dropdown("Upper line style",v,p.upperStyle,y=>jr(2,y),y=>n.patch({"reg.upperStyle":y}),{label:Co})),d.appendChild(this.colorButton("Lower line color",Jn,p.lowerColor,y=>n.patch({"reg.lowerColor":y}))),d.appendChild(this.dropdown("Lower line style",v,p.lowerStyle,y=>jr(2,y),y=>n.patch({"reg.lowerStyle":y}),{label:Co})),d.appendChild(this.colorButton("Upper fill",Xr,p.upperFill,y=>n.patch({"reg.upperFill":y}))),d.appendChild(this.colorButton("Lower fill",Xr,p.lowerFill,y=>n.patch({"reg.lowerFill":y}))),d.appendChild(this.toggle("Show R\xB2",zE,p.showR2,y=>n.patch({"reg.showR2":y})));}let m=e.vwap;if(a.has("vwap.midColor")&&m){let v=Pe.map(w=>w.value),y=[.5,1,1.5,2,2.5,3,4,5];d.appendChild(this.colorButton("VWAP color",Jn,m.midColor,w=>n.patch({"vwap.midColor":w}))),d.appendChild(this.dropdown("VWAP style",v,m.midStyle,w=>jr(2,w),w=>n.patch({"vwap.midStyle":w}),{label:Co})),d.appendChild(this.dropdown("Band multiplier",y,m.multiplier,()=>$E,w=>n.patch({"vwap.multiplier":w}),{label:w=>`${w}\u03C3`,labelInTrigger:true})),d.appendChild(this.colorButton("Upper band color",Jn,m.upperColor,w=>n.patch({"vwap.upperColor":w}))),d.appendChild(this.colorButton("Lower band color",Jn,m.lowerColor,w=>n.patch({"vwap.lowerColor":w}))),d.appendChild(this.colorButton("Band fill",Xr,m.bandFill,w=>n.patch({"vwap.bandFill":w})));}if(a.has("maxCurvature")){let v=e.maxCurvature??24;d.appendChild(this.dropdown("Max curvature",uc,v,()=>WE,y=>n.patch({maxCurvature:y}),{label:y=>`n=${y}`,labelInTrigger:true}));}if(a.has("mach")){let v=e.mach??2;d.appendChild(this.dropdown("Mach number",pc,v,()=>UE,y=>n.patch({mach:y}),{label:y=>`M=${y}`,labelInTrigger:true}));}if(a.has("waveCount")){let v=e.waveCount??6;d.appendChild(this.dropdown("Waves",hc,v,()=>GE,y=>n.patch({waveCount:y}),{label:y=>`${y}`,labelInTrigger:true}));}let f=e;a.has("showPrice")&&d.appendChild(this.toggle("Show price",AE,f.showPrice!==false,v=>n.patch({showPrice:v}))),a.has("showDate")&&d.appendChild(this.toggle("Show date",RE,f.showDate!==false,v=>n.patch({showDate:v}))),a.has("text.color")&&l&&d.appendChild(this.colorButton("Text color",uu,e.text?.color||o.textColor,v=>n.patch({"text.color":v}))),a.has("text.size")&&l&&d.appendChild(this.dropdown("Text size",qe.map(v=>v.value),e.text?.size??"normal",v=>Iv(v),v=>n.patch({"text.size":v}),{label:So})),a.has("text.bold")&&!a.has("text.value")&&d.appendChild(this.toggle("Bold",Mv,!!e.text?.bold,v=>n.patch({"text.bold":v}))),a.has("text.italic")&&!a.has("text.value")&&d.appendChild(this.toggle("Italic",kv,!!e.text?.italic,v=>n.patch({"text.italic":v}))),a.has("text.value")&&d.appendChild(this.iconBtn("Text",uu,()=>this.toggleTextPanel(e,n,!l)));let g=e.editableLevels();if(g&&!(e instanceof Ae)){let v=e,y=qe.map(w=>w.value);d.appendChild(this.dropdown("Numbers size",y,v.numbersSize??"small",w=>qE(w),w=>n.patch({numbersSize:w}),{label:So})),d.appendChild(this.dropdown("Label size",y,v.labelsSize??"normal",w=>Iv(w),w=>n.patch({labelsSize:w}),{label:So}));}d.appendChild(this.divider()),u&&d.appendChild(this.iconBtn("Settings",hu,()=>this.settingsDialog.open(e,n,"frvp"))),h&&d.appendChild(this.iconBtn("Position size",hu,()=>this.settingsDialog.open(e,n,"position"))),g&&d.appendChild(this.iconBtn("Levels",hu,()=>this.settingsDialog.open(e,n,"levels"))),d.appendChild(this.toggle("Lock",DE,e.locked,v=>n.setLocked(v)));let b=this.iconBtn("Delete",NE,()=>n.remove());b.style.color="var(--vela-danger)",d.appendChild(b),d.appendChild(this.kebabButton(n)),c.append(d),this.host.appendChild(c),this.el=c,c.addEventListener("mouseover",v=>{let y=v.target.closest("[data-tip]");y?this.showTip(y):this.hideTip();}),c.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 Un({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",uu,i?.color||this.theme.textColor,l=>t.patch({"text.color":l}),14),this.dropdown("Text size",qe.map(l=>l.value),i?.size??"normal",l=>jE(l),l=>t.patch({"text.size":l}),{label:So})),a.append(this.toggle("Bold",Mv,!!i?.bold,l=>t.patch({"text.bold":l})),this.toggle("Italic",kv,!!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:${un}px;height:${un}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=Gt(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:${un}px;height:${un}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=Gt(VE),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=u=>{let h=n.offsetWidth,p=n.offsetHeight,m=a+(u.clientX-o),f=l+(u.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`;},d=()=>{e.style.cursor="grab",window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d);};window.addEventListener("pointermove",c),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d);}),e}kebabButton(e){let t=this.base("More");return t.innerHTML=Gt(_E),t.addEventListener("pointerdown",n=>n.stopPropagation()),t.addEventListener("click",n=>{if(n.stopPropagation(),this.menuOwner===t){this.closeMenu();return}this.openActionMenu(t,[{icon:OE,label:"Bring to front",onClick:()=>e.reorder("front")},{icon:FE,label:"Send to back",onClick:()=>e.reorder("back")},{icon:BE,label:"Reset settings",onClick:()=>e.resetSettings()}]);}),t}hostFloat(e,t){let n=this.theme,i=new Be({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);}}),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}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=Gt(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,d=s.left-o.left+s.width/2-a/2;d=Math.max(4,Math.min(d,o.width-a-4));let u=s.top-o.top-l-c,h=u>=4?u:s.bottom-o.top+c;i.style.left=`${Math.round(d)}px`,i.style.top=`${Math.round(h)}px`;}hideTip(){this.tipEl?.remove(),this.tipEl=null;}toggle(e,t,n,i){let o=this.base(e);o.innerHTML=Gt(t);let s=l=>{o.dataset.active=l?"1":"0";};s(n);let a=n;return o.addEventListener("click",()=>{a=!a,s(a),i(a);}),o}widthInput(e,t,n,i,o,s){let a=new Gn({value:t,min:n,max:i,step:o,integer:o>=1,size:"sm",fill:false,compact:true,commit:"blur",title:e,onChange:s});return a.el.dataset.tip=e,YE(a.el),a.el}dropdown(e,t,n,i,o,s={}){let a=this.base(e);a.style.width="auto",a.style.minWidth=`${un}px`,a.style.padding="0 4px",a.style.gap="2px";let l=n,c=d=>{a.replaceChildren();let u=document.createElement("span");if(u.style.cssText="display:flex;",u.innerHTML=Gt(i(d)),a.appendChild(u),s.label&&s.labelInTrigger){let p=document.createElement("span");p.textContent=s.label(d),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=Gt(HE,12),a.appendChild(h);};return c(l),a.addEventListener("pointerdown",d=>d.stopPropagation()),a.addEventListener("click",d=>{if(d.stopPropagation(),this.menuOwner===a){this.closeMenu();return}this.openMenu(a,t,l,i,s.label,u=>{l=u,c(u),o(u);});}),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 d=c===n,u=document.createElement("button");u.type="button",u.className="vela-dpop-item",u.dataset.active=d?"1":"0",u.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=document.createElement("span");if(h.style.cssText="display:flex;flex:none;width:22px;justify-content:center;",h.innerHTML=Gt(i(c),18),u.appendChild(h),o){let p=document.createElement("span");p.textContent=o(c),p.style.cssText="flex:1;font-variant-numeric:tabular-nums;",u.appendChild(p);}u.addEventListener("click",p=>{p.stopPropagation(),l.hide(),s(c);}),a.appendChild(u);}}}),this.menuOwner=e;}closeMenu(){this.menuPop?.hide();}colorButton(e,t,n,i,o=17){let s=document.createElement("button");s.type="button",s.dataset.tip=e,s.className="vela-dpop-btn",s.style.cssText=`position:relative;width:${un}px;height:${un}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 a=document.createElement("span");a.style.cssText="display:flex;",a.innerHTML=Gt(t,o);let l=document.createElement("span");l.style.cssText=`display:block;height:3px;width:${Math.round(o*.85)}px;border-radius:2px;background:${n};`,s.append(a,l);let c=n;return s.addEventListener("pointerdown",d=>d.stopPropagation()),s.addEventListener("click",d=>{d.stopPropagation(),this.toggleColorPopover(s,c,u=>{c=u,l.style.background=u,i(u);});}),s}toggleColorPopover(e,t,n){if(this.colorOwner===e){this.closeColorPopover();return}this.openColorPopover(e,t,n);}openColorPopover(e,t,n){let i=this.theme;this.colorPop=this.hostFloat(e,{zIndex:25,padding:"10px",fill:o=>{o.appendChild(to(t,i,n));}}),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}},Jn=$("brush"),Xr=$("bucket"),uu=$("type"),AE=$("price-delta"),RE=$("date-delta"),DE=$("lock"),OE=$("bring-front"),FE=$("send-back"),NE=$("trash"),Mv=$("bold"),kv=$("italic"),VE=$("grip"),_E=$("kebab"),BE=$("reset"),hu=$("gear"),HE=$("chevron-down"),zE=$("r-squared"),$E=$("bands"),WE=$("dedekind"),GE=$("sonic"),UE=$("supersonic");function jr(r,e){let t=e==="dashed"?"5,3":e==="dotted"?"1.5,3":"";return A(`<line x1="3.5" y1="12" x2="20.5" y2="12" stroke-width="${Number(r)||2}" stroke-dasharray="${t}"/>`)}function YE(r){r.addEventListener("keydown",e=>e.stopPropagation());}function To(r,e,t=17,n=""){return sc(`<text x="12" y="${t}" font-size="${e}" text-anchor="middle"${n?" "+n:""}>${r}</text>`)}function KE(r){return To(String(r),15)}function XE(r){return To("\u25CF",(pu[String(r)]??13)+4)}function jE(r){return To(String(r).charAt(0).toUpperCase(),15)}var pu={small:10,normal:13,large:16,huge:20};function qE(r){return To("12",(pu[String(r)]??13)-1,16.5,'font-weight="600"')}function Iv(r){return To("T",(pu[String(r)]??13)+2)}function Av(r){return r.charAt(0).toUpperCase()+r.slice(1)}function So(r){return qe.find(e=>e.value===r)?.label??Av(String(r))}function Co(r){return Pe.find(e=>e.value===r)?.label??Av(String(r))}function Gt(r,e=kE){return r.replace("<svg ",`<svg width="${e}" height="${e}" `)}var mu=44,fu=16,Eo=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??mu,this.dock=c.dock??"absolute",this.onCollapse=c.onCollapse??(()=>{}),this.onDrawingsSync=c.onDrawingsSync??null,ZE(),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;ve(this.root,e);let t=this.collapsed?fu: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=Hl(n?lP:aP);}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(JE,"Cursor",()=>this.onArm(null)),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(QE,"Measure",()=>this.onMeasure()),this.root.appendChild(this.measureBtn),this.eraserBtn=this.makeButton(iP,"Eraser (click/drag to delete)",()=>this.onEraser()),this.root.appendChild(this.eraserBtn),this.root.appendChild(this.makeMagnetCell()),this.stayBtn=this.makeButton(nP,"Stay in drawing mode",()=>this.toggleStay()),this.root.appendChild(this.stayBtn),this.onDrawingsSync&&(this.syncBtn=this.makeButton(rP,"Sync drawings on all charts",()=>this.toggleDrawingsSync()),this.root.appendChild(this.syncBtn)),this.collapseBtn=this.makeButton(Ov,"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=Bl(this.collapsed?eP:Ov,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=Bl(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=cP(oP),o.addEventListener("click",a=>{a.stopPropagation(),s();}),n.appendChild(o);}return this.tipDisposers.push(pt(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:tP,multi:true,onIcon:()=>this.toggleMagnet(),onArrow:()=>this.onMagnetArrowClick()});return this.magnetCell=e,this.magnetIcon=t,e}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===Rv;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;`,ve(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(Rv,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=Hl(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=Hl(sP)),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=Bl(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=Bl(e)),this.tipDisposers.push(pt(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}},Rv="__magnet__",Dv="vela-drawing-toolbar-styles";function ZE(){if(typeof document>"u")return;let r=document.getElementById(Dv);r||(r=document.createElement("style"),r.id=Dv,document.head.appendChild(r)),r.textContent=`
|
|
852
852
|
.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;}
|
|
853
853
|
.vela-dtb-hit--arrow{width:11px;height:22px;}
|
|
854
854
|
.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;}
|
|
@@ -885,9 +885,9 @@ ${On(".vela-sd-pane")}
|
|
|
885
885
|
.vela-dtb-flyout::-webkit-scrollbar-button{display:none;width:0;height:0;}
|
|
886
886
|
.vela-dtb-flyout::-webkit-scrollbar-track,.vela-dtb-flyout::-webkit-scrollbar-track-piece,.vela-dtb-flyout::-webkit-scrollbar-corner{background:transparent;}
|
|
887
887
|
.vela-dtb-flyout::-webkit-scrollbar-thumb{background:var(--vela-scroll);border-radius:var(--vela-radius-sm);}
|
|
888
|
-
.vela-dtb-flyout::-webkit-scrollbar-thumb:hover{background:var(--vela-fg-muted);}`;}var YE=$("cursor"),KE=$("ruler"),Iv=$("chevrons-left"),XE=$("chevrons-right"),jE=$("magnet"),qE=$("pen-lock"),ZE=$("pen-sync"),JE=$("eraser"),QE=$("chevron-right"),eP=$("check"),tP=$("star"),nP=$("star-filled");function _l(r){return r.replace("<svg ",'<svg width="100%" height="100%" ')}function Av(r,e=18){return r?`<span style="width:${e}px;height:${e}px;display:flex;align-items:center;justify-content:center;">${_l(r)}</span>`:""}function Vl(r,e=18){return `<span class="vela-dtb-hit">${Av(r,e)}</span>`}function rP(r){return `<span class="vela-dtb-hit vela-dtb-hit--arrow">${Av(r,11)}</span>`}function Rv(r){return `${r>=0?"+":""}${r.toFixed(2)}`}var iP=J,oP=X,sP=3,Bl=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){if(this.state==="measuring"){this.end={x:e,y:t},this.state="finished";return}this.start={x:e,y:t},this.end={x:e,y:t},this.pressX=e,this.pressY=t,this.state="measuring";}move(e,t){this.state==="measuring"&&(this.end={x:e,y:t});}up(e,t){this.state==="measuring"&&Math.hypot(e-this.pressX,t-this.pressY)>sP&&(this.end={x:e,y:t},this.state="finished");}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),d=t.pxToPoint(s,a,l),u=d.price-c.price,h=c.price!==0?u/c.price*100:0,p=t.barsBetween?Math.round(t.barsBetween(c.time,d.time)):null,m=u>=0,f=m?iP:oP,g=Math.min(i,s),b=Math.max(i,s),v=Math.min(o,a),y=Math.max(o,a),w=(i+s)/2,P=(o+a)/2;e.save(),e.globalAlpha=.12,e.fillStyle=f,e.fillRect(g,v,b-g,y-v),e.globalAlpha=1,e.strokeStyle=f,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(w,o),e.lineTo(w,a),e.moveTo(i,P),e.lineTo(s,P),e.stroke(),e.setLineDash([]);let x=m?v:y,S=m?1:-1;e.fillStyle=f,e.beginPath(),e.moveTo(w,x),e.lineTo(w-5,x+S*7),e.lineTo(w+5,x+S*7),e.closePath(),e.fill(),e.restore(),this.paintLabel(e,t,n,w,v,y,f,[`${Rv(u)} (${Rv(h)}%)`,p!=null?`${p} bars \xB7 ${li(d.time-c.time)}`:li(d.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,d=16,u=l.length*d+8,h=s+8;h+u>t.height&&(h=o-u-8);let p=i-c/2;e.fillStyle=n.background,e.strokeStyle=a,e.lineWidth=1,e.beginPath(),e.roundRect(p,h,c,u,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+d/2+g*d)),e.restore();}};function Dv(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 Ov(r){let e=r;return !e||!e.tagName?false:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===true}var Fv="Enter Text",aP=8,pu=1;function mu(r){return r instanceof st||r instanceof Tt}var lP={};function Nv(r,e){return e.length===0||r>e[e.length-1]?null:e.find(t=>t>=r)}var Hl=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.lastDraftKey=null;this.measure=new Bl;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 Dl;this.ctx=n.getContext("2d"),this.popup=new Nl(t,i.theme()),this.toolbar=new So(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 Ol({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?hu:uu:0);}setExternalGhost(e){this.externalGhost=e?ct(e):null,this.render();}syncDrawings(e){this.drawings=e.map(t=>ct(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),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?true:this.interaction.claim(e,t)}deleteAt(e,t){let n=Kr(this.drawings,e,t,this.deps.projector(),6);return !n||n.locked?false:(this.popup.close(),this.emit({kind:"delete",ids:[n.id]}),true)}beginMeasureAt(e,t){return this.measureMode||this.eraserMode||this.activeTool!=null?false:(this.withModeIntent(()=>this.toggleMeasure()),this.measure.down(e,t),this.render(),true)}clearTransient(){this.textEditor&&this.finishTextEditor(true),this.measure.isFinished()&&(this.measure.clear(),this.render());}pointerDown(e,t,n="off",i=false){if(this.eraserMode){this.erasing=true,this.deleteAt(e,t);return}if(this.measureMode){this.measure.down(e,t),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}this.interaction.down(e,t,n,i);}pointerMove(e,t,n="off",i=false){if(this.eraserMode){this.erasing&&this.deleteAt(e,t);return}if(this.measureMode){this.measure.move(e,t),this.render();return}this.interaction.move(e,t,n,i),this.updateHover(e,t);}updateHover(e,t){let n=null;this.activeTool==null&&!this.interaction.isPlacing()&&!this.interaction.isDragging()&&(n=Kr(this.drawings,e,t,this.deps.projector(),6)?.id??null),n!==this.hoveredId&&(this.hoveredId=n,this.render());}pointerUp(e,t){if(this.eraserMode){this.erasing=false;return}if(this.measureMode){this.measure.up(e,t),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}this.interaction.up(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,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=Fv,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(`
|
|
889
|
-
`,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
|
|
890
|
-
`),h=Math.ceil(this.measureTextWidth(u,a))+aP;return l+`left:${Math.round(c[0]+2)-Xn}px;top:${Math.round(c[1]+2-(d-s)/2)-jn}px;width:${h+Xn*2}px;height:${u.length*d+jn*2}px;padding:${jn-pu}px ${Xn-pu}px;border:${pu}px solid ${W(i.textColor,.3)};border-radius:4px;background:transparent;color:${o?.color??i.textColor};font:${a};line-height:${d}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?"pointer":this.interaction.cursorAt(e,t)}cancelPlacement(){return this.interaction.isPlacing()?(this.interaction.cancel(),this.activeTool!=null&&this.emit({kind:"arm",type:null}),true):false}dblClick(e,t){if(this.interaction.finishPlacing(true))return true;let n=Kr(this.drawings,e,t,this.deps.projector(),6);return mu(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.selectedIds.size?(this.clearSelection(),true):false;if(e.key==="Enter"&&this.interaction.finishPlacing(false))return true;let t=Dv(e,{hasSelection:this.selectedIds.size>0,hasTarget:this.selectedIds.size>0||this.hoveredId!=null,editingText:Ov(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.selectionIds():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]}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 Nv(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=Nv(a.zIndex,this.lastBounds.get(a.paneId)??[]);if(l===null)continue;let c=`${a.paneId}|${l}`,d=s.get(c);d?d.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:d}]of s){let u=this.sliceCache.get(a);u||(u=document.createElement("canvas"),this.sliceCache.set(a,u)),(u.width!==this.canvas.width||u.height!==this.canvas.height)&&(u.width=this.canvas.width,u.height=this.canvas.height);let h=u.getContext("2d");if(!h)continue;h.setTransform(n,0,0,n,0,0),h.clearRect(0,0,u.width/n,u.height/n),this.painter.paintAll(h,d,i,o,lP);let p=t.get(l)??[];p.push({beforeZ:c,canvas:u}),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 Tt?i.id:null};this.painter.paintAll(e,this.drawings.filter(d=>!this.isInterleaved(d)),n,this.deps.theme(),o),this.painter.paintHighlights(e,this.drawings.filter(d=>this.isInterleaved(d)),n,au(o)),this.layoutTextEditor();let s=this.interaction.ghost();s&&this.painter.paintGhost(e,s,n,this.deps.theme()),this.externalGhost&&this.painter.paintGhost(e,this.externalGhost,n,this.deps.theme()),this.emitDraft(s);let a=this.interaction.placingMarkers(n);a&&this.painter.paintHandles(e,a);let l=this.interaction.snapMarker(),c=l?n.yOf(l.point.price,l.paneId):null;l&&c!=null&&this.painter.paintSnapRing(e,n.xOf(l.point.time),c,this.deps.theme()),this.measure.isActive()&&this.measure.paint(e,n,this.deps.theme());}destroy(){this.closeTextEditor(),this.popup.destroy(),this.toolbar.destroy(),this.intentCb=null,this.drawings=[];}clearSelection(){this.popup.close(),this.selectedIds.size&&this.emit({kind:"select",ids:[]}),this.render();}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.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}),resetSettings:()=>{let a=o();a&&(hc(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.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:Ne(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),mu(n)&&this.editTextInline(n.id));},0);return}this.intentCb?.(e);}};function Vv(r,e,t,n){return {xOf:i=>r.timeToX(i),yOf:(i,o)=>{let s=e(o);return s?r.priceToY(i,s.scale,s.bounds):null},pxToPoint:(i,o,s)=>{let a=e(s),l=r.logicalToTime(r.xToLogical(i)),c=a?r.yToPrice(o,a.scale,a.bounds):0;return {time:l,price:c}},paneIdAtY:t,paneRect:i=>{let o=e(i);return o?{top:o.bounds.top,height:o.collapsed?0:o.bounds.height}:null},barsBetween:(i,o)=>Math.abs(r.timeToLogical(o)-r.timeToLogical(i)),barsInRange:n?(i,o)=>n(i,o):void 0,width:r.width,height:r.height}}var _v=2/7,Bv=1/7;function zl(r,e,t,n,i,o,s=false,a=()=>0){let l=1/0,c=-1/0,d=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&&(d(p.high),d(p.low));}for(let h of r){let p=a(h.id);for(let m of h.series)if(m.kind==="candle"||m.kind==="bar")for(let f=n;f<=i;f+=1){let g=m.bars[f-p];g&&(d(g.high),d(g.low));}else if(be(m)){for(let f=n;f<=i;f+=1)d(m.points[f-p]?.value);m.kind==="histogram"||m.kind==="columns"?d(m.style?.base??0):m.style?.base!=null&&d(m.style.base);}for(let m of h.priceLines)d(m.price);}if(o&&(d(o.min),d(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*Bv),max:Math.exp(p+m*_v),log:true}}let u=c-l;return {min:l-u*Bv,max:c+u*_v}}function Hv(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}}function zv(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 $v(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 Wv(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,u=Math.max(l,Math.min(c,s+e))-n,h=i>0?o*(u/i):o/2;return {above:h,below:o-h}}var $l=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(),...t.highlights];if(i.length!==0)for(let o of i){let s=n.timeToX(o.from),a=n.timeToX(o.to);if(a<0||s>n.width||a<=s)continue;let l=Math.max(0,s),c=Math.min(n.width,a)-l;c<=0||(e.fillStyle=o.color,e.fillRect(l,0,c,n.height));}}drawGrid(e,t,n,i,o,s){let a=t.orderedPanes(),{gridVert:l,gridHorz:c}=t.style,d=l.color??i.gridColor,u=c.color??i.gridColor;if(e.lineWidth=1,t.showGrid&&l.visible){e.globalAlpha=s,e.strokeStyle=d;let h=n.visibleTimeRange(),p=fo((h.from+h.to)/2,t.timezone);e.beginPath();for(let m of Ll(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=u;let p=$t(t,h);e.beginPath();for(let m of po(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 Gv(r,e,t,n){let{i0:i,i1:o,xOf:s,halfW:a,bottomY:l,maxH:c,maxVol:d}=t;if(!(d<=0||c<=0)){r.globalAlpha=.5;for(let u=i;u<=o;u+=1){let h=e[u],p=h?.volume;if(h==null||p==null||!(p>0))continue;let m=Math.max(1,p/d*c);r.fillStyle=h.close>=h.open?n.up:n.down,r.fillRect(s(u)-a,l-m,a*2,m);}r.globalAlpha=1;}}var fu=.96;function cP(r){return Math.max(.5,Math.floor(r*.7)/2)}var Wl=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,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||l.height<=0)return;let u=a.visibleLogicalRange(),h=Math.max(0,Math.floor(u.from)),p=Math.min(i.length-1,Math.ceil(u.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(),Gv(t,i,{i0:h,i1:p,xOf:f=>a.logicalToX(f),halfW:cP(a.bodySpacing()),bottomY:l.top+l.height,maxH:l.height*(c?fu:o.heightFrac),maxVol:m},{up:o.upColor,down:o.downColor}),t.restore());}};function Uv(r,e){return e==null?r:r==null?{...e}:{candleBodyScale:gu(r.candleBodyScale,e.candleBodyScale),candleBodyAlpha:gu(r.candleBodyAlpha,e.candleBodyAlpha),gridAlpha:gu(r.gridAlpha,e.gridAlpha)}}function gu(r,e){return r==null?e:e==null?r:Math.min(r,e)}var bu=new Map;function dP(r){bu.set(r.id,r);}function uP(r){bu.delete(r);}function vu(){return [...bu.values()]}function Yv(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 Kv='<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>',Xv='<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 hP="https://luxalgo.com/vela",jv="vela-attribution-styles",pP=`
|
|
888
|
+
.vela-dtb-flyout::-webkit-scrollbar-thumb:hover{background:var(--vela-fg-muted);}`;}var JE=$("cursor"),QE=$("ruler"),Ov=$("chevrons-left"),eP=$("chevrons-right"),tP=$("magnet"),nP=$("pen-lock"),rP=$("pen-sync"),iP=$("eraser"),oP=$("chevron-right"),sP=$("check"),aP=$("star"),lP=$("star-filled");function Hl(r){return r.replace("<svg ",'<svg width="100%" height="100%" ')}function Fv(r,e=18){return r?`<span style="width:${e}px;height:${e}px;display:flex;align-items:center;justify-content:center;">${Hl(r)}</span>`:""}function Bl(r,e=18){return `<span class="vela-dtb-hit">${Fv(r,e)}</span>`}function cP(r){return `<span class="vela-dtb-hit vela-dtb-hit--arrow">${Fv(r,11)}</span>`}function Nv(r){return `${r>=0?"+":""}${r.toFixed(2)}`}var dP=J,uP=X,hP=3,zl=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){if(this.state==="measuring"){this.end={x:e,y:t},this.state="finished";return}this.start={x:e,y:t},this.end={x:e,y:t},this.pressX=e,this.pressY=t,this.state="measuring";}move(e,t){this.state==="measuring"&&(this.end={x:e,y:t});}up(e,t){this.state==="measuring"&&Math.hypot(e-this.pressX,t-this.pressY)>hP&&(this.end={x:e,y:t},this.state="finished");}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),d=t.pxToPoint(s,a,l),u=d.price-c.price,h=c.price!==0?u/c.price*100:0,p=t.barsBetween?Math.round(t.barsBetween(c.time,d.time)):null,m=u>=0,f=m?dP:uP,g=Math.min(i,s),b=Math.max(i,s),v=Math.min(o,a),y=Math.max(o,a),w=(i+s)/2,P=(o+a)/2;e.save(),e.globalAlpha=.12,e.fillStyle=f,e.fillRect(g,v,b-g,y-v),e.globalAlpha=1,e.strokeStyle=f,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(w,o),e.lineTo(w,a),e.moveTo(i,P),e.lineTo(s,P),e.stroke(),e.setLineDash([]);let x=m?v:y,S=m?1:-1;e.fillStyle=f,e.beginPath(),e.moveTo(w,x),e.lineTo(w-5,x+S*7),e.lineTo(w+5,x+S*7),e.closePath(),e.fill(),e.restore(),this.paintLabel(e,t,n,w,v,y,f,[`${Nv(u)} (${Nv(h)}%)`,p!=null?`${p} bars \xB7 ${ui(d.time-c.time)}`:ui(d.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,d=16,u=l.length*d+8,h=s+8;h+u>t.height&&(h=o-u-8);let p=i-c/2;e.fillStyle=n.background,e.strokeStyle=a,e.lineWidth=1,e.beginPath(),e.roundRect(p,h,c,u,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+d/2+g*d)),e.restore();}};function Vv(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 _v(r){let e=r;return !e||!e.tagName?false:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===true}var Bv="Enter Text",pP=8,gu=1;function bu(r){return r instanceof st||r instanceof Et}var mP={};function Hv(r,e){return e.length===0||r>e[e.length-1]?null:e.find(t=>t>=r)}var $l=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.lastDraftKey=null;this.measure=new zl;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 Fl;this.ctx=n.getContext("2d"),this.popup=new _l(t,i.theme()),this.toolbar=new Eo(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 Nl({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?fu:mu:0);}setExternalGhost(e){this.externalGhost=e?ct(e):null,this.render();}syncDrawings(e){this.drawings=e.map(t=>ct(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),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?true:this.interaction.claim(e,t)}deleteAt(e,t){let n=Kr(this.drawings,e,t,this.deps.projector(),6);return !n||n.locked?false:(this.popup.close(),this.emit({kind:"delete",ids:[n.id]}),true)}beginMeasureAt(e,t){return this.measureMode||this.eraserMode||this.activeTool!=null?false:(this.withModeIntent(()=>this.toggleMeasure()),this.measure.down(e,t),this.render(),true)}clearTransient(){this.textEditor&&this.finishTextEditor(true),this.measure.isFinished()&&(this.measure.clear(),this.render());}pointerDown(e,t,n="off",i=false){if(this.eraserMode){this.erasing=true,this.deleteAt(e,t);return}if(this.measureMode){this.measure.down(e,t),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}this.interaction.down(e,t,n,i);}pointerMove(e,t,n="off",i=false){if(this.eraserMode){this.erasing&&this.deleteAt(e,t);return}if(this.measureMode){this.measure.move(e,t),this.render();return}this.interaction.move(e,t,n,i),this.updateHover(e,t);}updateHover(e,t){let n=null;this.activeTool==null&&!this.interaction.isPlacing()&&!this.interaction.isDragging()&&(n=Kr(this.drawings,e,t,this.deps.projector(),6)?.id??null),n!==this.hoveredId&&(this.hoveredId=n,this.render());}pointerUp(e,t){if(this.eraserMode){this.erasing=false;return}if(this.measureMode){this.measure.up(e,t),this.measure.isFinished()&&this.withModeIntent(()=>this.exitMeasure(false)),this.render();return}this.interaction.up(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,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=Bv,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(`
|
|
889
|
+
`,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 bu(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 Et&&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=ye(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 st){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:${Rd(m,i.background,ln(m).alpha)};color:${o?.color??i.textColor};font:${a};`}let c=e.handlePoints(n)[0];if(!c)return null;let d=St(s),u=(t||Bv).split(`
|
|
890
|
+
`),h=Math.ceil(this.measureTextWidth(u,a))+pP;return l+`left:${Math.round(c[0]+2)-Xn}px;top:${Math.round(c[1]+2-(d-s)/2)-jn}px;width:${h+Xn*2}px;height:${u.length*d+jn*2}px;padding:${jn-gu}px ${Xn-gu}px;border:${gu}px solid ${W(i.textColor,.3)};border-radius:4px;background:transparent;color:${o?.color??i.textColor};font:${a};line-height:${d}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?"pointer":this.interaction.cursorAt(e,t)}cancelPlacement(){return this.interaction.isPlacing()?(this.interaction.cancel(),this.activeTool!=null&&this.emit({kind:"arm",type:null}),true):false}dblClick(e,t){if(this.interaction.finishPlacing(true))return true;let n=Kr(this.drawings,e,t,this.deps.projector(),6);return bu(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.selectedIds.size?(this.clearSelection(),true):false;if(e.key==="Enter"&&this.interaction.finishPlacing(false))return true;let t=Vv(e,{hasSelection:this.selectedIds.size>0,hasTarget:this.selectedIds.size>0||this.hoveredId!=null,editingText:_v(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.selectionIds():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]}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 Hv(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=Hv(a.zIndex,this.lastBounds.get(a.paneId)??[]);if(l===null)continue;let c=`${a.paneId}|${l}`,d=s.get(c);d?d.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:d}]of s){let u=this.sliceCache.get(a);u||(u=document.createElement("canvas"),this.sliceCache.set(a,u)),(u.width!==this.canvas.width||u.height!==this.canvas.height)&&(u.width=this.canvas.width,u.height=this.canvas.height);let h=u.getContext("2d");if(!h)continue;h.setTransform(n,0,0,n,0,0),h.clearRect(0,0,u.width/n,u.height/n),this.painter.paintAll(h,d,i,o,mP);let p=t.get(l)??[];p.push({beforeZ:c,canvas:u}),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 Et?i.id:null};this.painter.paintAll(e,this.drawings.filter(d=>!this.isInterleaved(d)),n,this.deps.theme(),o),this.painter.paintHighlights(e,this.drawings.filter(d=>this.isInterleaved(d)),n,du(o)),this.layoutTextEditor();let s=this.interaction.ghost();s&&this.painter.paintGhost(e,s,n,this.deps.theme()),this.externalGhost&&this.painter.paintGhost(e,this.externalGhost,n,this.deps.theme()),this.emitDraft(s);let a=this.interaction.placingMarkers(n);a&&this.painter.paintHandles(e,a);let l=this.interaction.snapMarker(),c=l?n.yOf(l.point.price,l.paneId):null;l&&c!=null&&this.painter.paintSnapRing(e,n.xOf(l.point.time),c,this.deps.theme()),this.measure.isActive()&&this.measure.paint(e,n,this.deps.theme());}destroy(){this.closeTextEditor(),this.popup.destroy(),this.toolbar.destroy(),this.intentCb=null,this.drawings=[];}clearSelection(){this.popup.close(),this.selectedIds.size&&this.emit({kind:"select",ids:[]}),this.render();}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.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}),resetSettings:()=>{let a=o();a&&(fc(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.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:Ne(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),bu(n)&&this.editTextInline(n.id));},0);return}this.intentCb?.(e);}};function zv(r,e,t,n){return {xOf:i=>r.timeToX(i),yOf:(i,o)=>{let s=e(o);return s?r.priceToY(i,s.scale,s.bounds):null},pxToPoint:(i,o,s)=>{let a=e(s),l=r.logicalToTime(r.xToLogical(i)),c=a?r.yToPrice(o,a.scale,a.bounds):0;return {time:l,price:c}},paneIdAtY:t,paneRect:i=>{let o=e(i);return o?{top:o.bounds.top,height:o.collapsed?0:o.bounds.height}:null},barsBetween:(i,o)=>Math.abs(r.timeToLogical(o)-r.timeToLogical(i)),barsInRange:n?(i,o)=>n(i,o):void 0,width:r.width,height:r.height}}var $v=2/7,Wv=1/7;function Wl(r,e,t,n,i,o,s=false,a=()=>0){let l=1/0,c=-1/0,d=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&&(d(p.high),d(p.low));}for(let h of r){let p=a(h.id);for(let m of h.series)if(m.kind==="candle"||m.kind==="bar")for(let f=n;f<=i;f+=1){let g=m.bars[f-p];g&&(d(g.high),d(g.low));}else if(be(m)){for(let f=n;f<=i;f+=1)d(m.points[f-p]?.value);m.kind==="histogram"||m.kind==="columns"?d(m.style?.base??0):m.style?.base!=null&&d(m.style.base);}for(let m of h.priceLines)d(m.price);}if(o&&(d(o.min),d(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*Wv),max:Math.exp(p+m*$v),log:true}}let u=c-l;return {min:l-u*Wv,max:c+u*$v}}function Gv(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}}function Uv(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 Yv(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 Kv(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,u=Math.max(l,Math.min(c,s+e))-n,h=i>0?o*(u/i):o/2;return {above:h,below:o-h}}var Gl=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(),...t.highlights];if(i.length!==0)for(let o of i){let s=n.timeToX(o.from),a=n.timeToX(o.to);if(a<0||s>n.width||a<=s)continue;let l=Math.max(0,s),c=Math.min(n.width,a)-l;c<=0||(e.fillStyle=o.color,e.fillRect(l,0,c,n.height));}}drawGrid(e,t,n,i,o,s){let a=t.orderedPanes(),{gridVert:l,gridHorz:c}=t.style,d=l.color??i.gridColor,u=c.color??i.gridColor;if(e.lineWidth=1,t.showGrid&&l.visible){e.globalAlpha=s,e.strokeStyle=d;let h=n.visibleTimeRange(),p=vo((h.from+h.to)/2,t.timezone);e.beginPath();for(let m of kl(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=u;let p=$t(t,h);e.beginPath();for(let m of go(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 Xv(r,e,t,n){let{i0:i,i1:o,xOf:s,halfW:a,bottomY:l,maxH:c,maxVol:d}=t;if(!(d<=0||c<=0)){r.globalAlpha=.5;for(let u=i;u<=o;u+=1){let h=e[u],p=h?.volume;if(h==null||p==null||!(p>0))continue;let m=Math.max(1,p/d*c);r.fillStyle=h.close>=h.open?n.up:n.down,r.fillRect(s(u)-a,l-m,a*2,m);}r.globalAlpha=1;}}var vu=.96;function fP(r){return Math.max(.5,Math.floor(r*.7)/2)}var Ul=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,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||l.height<=0)return;let u=a.visibleLogicalRange(),h=Math.max(0,Math.floor(u.from)),p=Math.min(i.length-1,Math.ceil(u.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(),Xv(t,i,{i0:h,i1:p,xOf:f=>a.logicalToX(f),halfW:fP(a.bodySpacing()),bottomY:l.top+l.height,maxH:l.height*(c?vu:o.heightFrac),maxVol:m},{up:o.upColor,down:o.downColor}),t.restore());}};function jv(r,e){return e==null?r:r==null?{...e}:{candleBodyScale:yu(r.candleBodyScale,e.candleBodyScale),candleBodyAlpha:yu(r.candleBodyAlpha,e.candleBodyAlpha),gridAlpha:yu(r.gridAlpha,e.gridAlpha)}}function yu(r,e){return r==null?e:e==null?r:Math.min(r,e)}var wu=new Map;function gP(r){wu.set(r.id,r);}function bP(r){wu.delete(r);}function xu(){return [...wu.values()]}function qv(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 Zv='<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>',Jv='<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 vP="https://luxalgo.com/vela",Qv="vela-attribution-styles",yP=`
|
|
891
891
|
.vela-attribution {
|
|
892
892
|
text-decoration: none;
|
|
893
893
|
display: flex;
|
|
@@ -948,5 +948,5 @@ ${On(".vela-sd-pane")}
|
|
|
948
948
|
[data-layout='mobile'] .vela-attribution .vela-attr-wordmark svg { height: 21px; }
|
|
949
949
|
[data-vela-layout='mobile'] .vela-attribution:hover .vela-attr-wordmark,
|
|
950
950
|
[data-layout='mobile'] .vela-attribution:hover .vela-attr-wordmark { transform: translateX(0); }
|
|
951
|
-
`;function mP(r){let e=r.getElementById(jv);e||(e=r.createElement("style"),e.id=jv,r.head.appendChild(e)),e.textContent=pP;}function yu(r){return _e(r)?"#ffffff":"#000000"}function wu(r,e){let t=_e(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 qv(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=yu(t),n.innerHTML=e,n}function Zv(r,e){mP(r);let t=r.createElement("a");t.className="vela-attribution",t.href=hP,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"}),wu(t,e);let n=r.createElement("span");n.className="vela-attr-symbol",n.setAttribute("aria-hidden","true"),n.innerHTML=Kv;let i=r.createElement("span");return i.className="vela-attr-wordmark",i.innerHTML=Xv,t.append(n,i),t}function Gl(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 Jv(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 xu(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 fP(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 Ul(r,e,t){let n=e.ownerDocument.defaultView;if(!n)return;r.save(),r.scale(t.dpr,t.dpr);let i=(c,d,u)=>{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=u,r.fillStyle=d.color,r.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`,r.textBaseline="middle",r.textAlign="left",r.fillText(h,m.left-t.left,m.top-t.top+m.height/2));},o=(c,d,u)=>{if(!c.complete||c.naturalWidth<=0||!fP(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=u,xu(r,p,m,h.width,h.height,Jv(d,h.width,h.height)),r.clip(),r.drawImage(c,p,m,h.width,h.height),r.restore();},s=(c,d)=>{for(let u of c.children){if(u.hasAttribute("transform"))continue;let h=u.tagName.toLowerCase();if(h==="g"){s(u,d);continue}let p=b=>parseFloat(u.getAttribute(b)??"0")||0,m=null;if(h==="path"){let b=u.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=(u.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 v=2;v+1<b.length;v+=2)m.lineTo(b[v],b[v+1]);h==="polygon"&&m.closePath();}if(!m)continue;let f=n.getComputedStyle(u);f.fill&&f.fill!=="none"&&Gl(f.fill)&&(r.globalAlpha=d*(parseFloat(f.fillOpacity)||1),r.fillStyle=f.fill,r.fill(m));let g=parseFloat(f.strokeWidth)||0;f.stroke&&f.stroke!=="none"&&Gl(f.stroke)&&g>0&&(r.globalAlpha=d*(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,d)=>{let u=c.getBoundingClientRect();if(u.width<=0||u.height<=0)return;let h=n.getComputedStyle(c);if(h.display==="none"||h.visibility==="hidden")return;let p=d*(parseFloat(h.opacity)||1);if(p<=.001)return;let m=c.viewBox.baseVal,f=m&&m.width>0?m.width:u.width,g=m&&m.height>0?m.height:u.height;r.save(),r.translate(u.left-t.left,u.top-t.top),r.scale(u.width/f,u.height/g),m&&r.translate(-m.x,-m.y),s(c,p),r.restore();},l=(c,d)=>{let u=n.getComputedStyle(c);if(u.display==="none"||u.visibility==="hidden")return;let h=d*(parseFloat(u.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=Jv(u,p.width,p.height);Gl(u.backgroundColor)&&(r.globalAlpha=h,r.fillStyle=u.backgroundColor,xu(r,m,f,p.width,p.height,g),r.fill());let b=parseFloat(u.borderTopWidth)||0;b>0&&u.borderTopStyle!=="none"&&Gl(u.borderTopColor)&&(r.globalAlpha=h,r.strokeStyle=u.borderTopColor,r.lineWidth=b,xu(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,u,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 Qv(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 y=o;y<=s;y+=1){let w=r[y];w.volume!=null&&w.volume>0&&(w.low<a&&(a=w.low),w.high>l&&(l=w.high));}if(!Number.isFinite(a))return null;let c=l>a?Math.max(1,Math.round(n)):1,d=l>a?(l-a)/c:1,u=Array.from({length:c},(y,w)=>({price:a+w*d,up:0,down:0}));for(let y=o;y<=s;y+=1){let w=r[y],P=w.volume;if(!(P!=null&&P>0))continue;let x=w.close>=w.open?"up":"down",S=w.high-w.low;if(S<=0){let T=Su(Math.floor((w.low-a)/d),c);u[T][x]+=P;continue}let E=Su(Math.floor((w.low-a)/d),c),L=Su(Math.floor((w.high-a)/d-1e-9),c);for(let T=E;T<=L;T+=1){let k=a+T*d,M=Math.min(w.high,k+d)-Math.max(w.low,k);M>0&&(u[T][x]+=P*M/S);}}let h=0,p=0,m=0;for(let y=0;y<c;y+=1){let w=u[y].up+u[y].down;h+=w,w>p&&(p=w,m=y);}if(p<=0)return null;let f=h*Math.min(1,Math.max(0,i)),g=m,b=m,v=p;for(;v<f&&(g>0||b<c-1);){let y=g>0?u[g-1].up+u[g-1].down:-1,w=b<c-1?u[b+1].up+u[b+1].down:-1;w>y?(b+=1,v+=w):(g-=1,v+=y);}return {rows:u,rowH:d,min:a,maxTotal:p,poc:m,vaFrom:g,vaTo:b}}function Su(r,e){return r<0?0:r>=e?e-1:r}function ey(r,e,t,n){let{rows:i,rowH:o,maxTotal:s,poc:a,vaFrom:l,vaTo:c}=e,{rightX:d,maxW:u,yOf:h}=t;if(!(s<=0||u<=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),v=f/s*u,y=m.up/f*v;r.globalAlpha=p>=l&&p<=c?.62:.28,y>0&&(r.fillStyle=n.upColor,r.fillRect(d-v,g,y,b)),v-y>0&&(r.fillStyle=n.downColor,r.fillRect(d-v+y,g,v-y,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(d-u+.5,m+.5,u-1,f);}r.globalAlpha=1;}}var Yl=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:d}=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||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=Qv(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(),ey(t,b,{rightX:a.width,maxW:a.width*o.widthFrac,yOf:v=>a.priceToY(v,l,c)},{upColor:o.upColor,downColor:o.downColor,showPoc:o.showPoc,pocColor:d.textColor}),t.restore());}};var we="price",yP=8,wP="rgba(0,0,0,0)",Kl=64,xP=56,ty=26,To=22,Co=26,Cu=24,SP=5,CP="0 2px 8px rgba(0,0,0,0.4)",TP=12,sy=12,ny=Kl+sy,Tu=To+14,EP=120,PP=2,ry=6,LP=70,qr=80,MP=110,Eu=90,kP=130,IP=.02,AP=.004,RP=.2,DP=4,Eo=class{constructor(e){this.capabilities=bb;this.surfaceBackground=ut.background;this.surfaceTextColor=ut.textColor;this.toolbarGutter=0;this.mountContainer=null;this.userDrawings=null;this.backdropRenderer=new $l;this.volumeRenderer=new Wl;this.extLayers=[];this.layerOrderSig="";this.attributionEl=null;this.attributionEnabled=true;this.attributionHtml=null;this.vpvrRenderer=new Yl;this.resizeObserver=null;this.dprMedia=null;this.coords=new gl;this.scene=new Sl;this.backendMode="auto";this.glowAmount=0;this.chrome=new kl;this.crosshairLayer=new Il;this.countdownTimer=null;this.symbolPicker=null;this.indicatorTitlesOn=true;this.indicatorValuesOn=true;this.legendActionsProvider=null;this.legendOverviewAction=null;this.keyboard=null;this.keyboardEnabled=true;this.historyChordsEnabled=true;this.liveRegion=null;this.animZoom=true;this.animPan=true;this.candleUp=J;this.candleDown=X;this.introStyle="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=Kl;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=Tu;this.scrollBtnRightPx=ny;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.tableOverlays=new Map;this.name="native";this.features=["logScale","currentPriceLine","priceLabel","countdown","upColor","downColor","glow","animZoom","animPan","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","indicatorTitles","indicatorValues"];this.onScrollProximityMove=e=>{if(!this.scrollButton||!this.plot)return;let t=this.plot.getBoundingClientRect(),n=t.width-this.scrollBtnRightPx-Co/2,i=t.height-this.scrollBtnBottomPx-Co/2,o=Math.hypot(e.clientX-t.left-n,e.clientY-t.top-i)<=EP;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=e.animZoom,this.animPan=e.animPan,this.glowAmount=e.glow,this.candleUp=e.upColor,this.candleDown=e.downColor,this.scene.priceStyle=e.priceStyle,this.scene.basePainting=zd(e.priceStyle),this.scene.candleOverride=dl(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??we,!!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=!!t;return;case "animPan":this.animPan=!!t;return;case "intro":{let n=t===false||t==="none"||t==="off"||t==null?"":String(t);this.introStyle=n,n&&this.playIntro(n);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=VP(t);break;case "sessionZones":this.scene.sessionZones=_P(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??we,iy(n.mode));return}this.scene.scaleMode=iy(t);break;case "invertScale":if(t&&typeof t=="object"){let n=t;this.setPaneInvert(n.pane??we,!!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(BP(t)?t:"candles");break;case "priceBaseline":this.scene.baselineValue=t==null?null:Number(t);break;case "tradeMarkers":this.scene.tradeMarkers=Hb(this.scene.tradeMarkers,t);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;case "animPan":return this.animPan;case "intro":return this.introStyle;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(we);return t?this.scene.baselinePriceFor(t.scale):this.scene.baselineValue}case "tradeMarkers":return {...this.scene.tradeMarkers,colors:{...this.scene.tradeMarkers.colors}};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){for(let i of this.tableOverlays.values())i.setVisible(!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:Hd,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},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},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??wP}})(),baseline:(()=>{let i=e.baseline.topLineColor??Vr,o=e.baseline.bottomLineColor??_r;return {topLineColor:i,bottomLineColor:o,topFillColor:e.baseline.topFillColor??W(i,Bt),topFillColor2:e.baseline.topFillColor2??W(i,Ht),bottomFillColor:e.baseline.bottomFillColor??W(o,Bt),bottomFillColor2:e.baseline.bottomFillColor2??W(o,Ht),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}}}applyConfig(e){let t=Sb(this.getConfig(),e),n=this.scene.style;for(let[d,u]of Object.entries(t.chartTypes))if(JSON.stringify(n.chartTypes[d])!==JSON.stringify(u)){this.scene.nativeData.set(`${d}-settings`,{...u});for(let h of this.chartTypeSettingsCbs)h(d,{...u});}n.chartTypes=Object.fromEntries(Object.entries(t.chartTypes).map(([d,u])=>[d,{...u}]));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&&_e(t.layout.textColor)===_e(t.layout.background)){let d=_e(t.layout.background)?ut:fi;l={textColor:d.textColor,gridColor:d.gridColor,borderColor:d.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=(d,u,h)=>d===null&&u===h?null:u;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(),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.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[d,u]of Object.entries(t.stacking.series))this.scene.setIndicatorZ(d,u);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},this.setPriceStyle(t.series.style),this.scene.candleOverride=dl(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&&(ve(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 d of this.configChangedCbs)d();}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 go(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=me("gear",14),Object.assign(e.style,{position:"absolute",bottom:`${To+10}px`,right:`${Kl+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 go(this.dialogHost??this.plot,this.theme),this.settingsDialog.setLayoutMode(this.layoutMode)),this.toggleSettingsDialog(e);}syncThemeControl(){this.settingsDialog?.setThemeControl(_e(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.setHiddenSettings(this.hiddenSettings),this.syncThemeControl(),this.settingsDialog.toggle(this.getConfig(),t=>this.applyConfig(t),t=>this.applyConfig(t),()=>{this.factoryConfig&&this.applyConfig(xb(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:`${Tu}px`,right:`${ny}px`,zIndex:"6",width:`${Co}px`,height:`${Co}px`,boxSizing:"border-box",display:"none",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:`${SP}px`,border:`1px solid ${this.theme.borderColor}`,boxShadow:CP,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 me("chevrons-right",TP)}scrollButtonSurface(){return W(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(ry);}glideRightOffset(e){let t=this.coords.getViewport();if(!this.animPan){this.applyViewport({barSpacing:t.barSpacing,rightOffset:e});return}this.panVelocity=0,this.targetBarSpacing=t.barSpacing,this.scrollTargetRO=e,this.animator.start();}screenshot(){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"&&Ul(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]")??[])Ul(t,s,i);for(let s of o)s.getAttribute("data-vela-screenshot")!=="under"&&Ul(t,s,i);}return e.toDataURL("image/png")}playIntro(e){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.introRaf=null;let t=this.bars,n=t.length;if(n===0)return;this.computeScales();for(let a of this.scene.panes.values())a.scale={...a.scaleTarget};this.modelAlpha=0;let i=650,o=performance.now(),s=a=>{let l=Math.min(1,(a-o)/i);this.scene.bars=l>=1?t:t.map((c,d)=>this.revealCandle(c,d,l,n,e)),this.paintData(),l<1?this.introRaf=requestAnimationFrame(s):(this.scene.bars=t,this.fadeInModels());};this.introRaf=requestAnimationFrame(s);}fadeInModels(){let t=performance.now(),n=i=>{this.modelAlpha=Math.min(1,(i-t)/350),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 u=a-1;l=1+(1.70158+1)*u*u*u+1.70158*u*u;}else {let d=1-a;l=1-d*d*d;}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:_e(this.surfaceBackground)?ut.borderColor:fi.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"}),ve(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=vu().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(fl()),this.scene.ensurePane(we,"price",0,3),this.scheduler=new bl(o=>this.renderFrame(o)),this.animator=new vl(o=>this.animTick(o)),this.targetBarSpacing=this.coords.getViewport().barSpacing,this.input=new yl({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=>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)=>this.userDrawings?.beginMeasureAt(o,s)??false,drawingsDeleteAt:(o,s)=>this.userDrawings?.deleteAt(o,s)??false,drawingsCancelPlacement:()=>this.userDrawings?.cancelPlacement()??false,drawingsSnapMode:()=>this.snapMode,drawingsPointerDown:(o,s,a,l)=>this.userDrawings?.pointerDown(o,s,a,l),drawingsPointerMove:(o,s,a,l)=>this.userDrawings?.pointerMove(o,s,a,l),drawingsPointerUp:(o,s)=>this.userDrawings?.pointerUp(o,s),drawingsCursor:(o,s)=>this.userDrawings?.cursorAt(o,s)??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.userDrawings=new Hl(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===we?this.scene.candleZ:null,requestDataPaint:()=>this.scheduler.invalidate(3),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=`${Cu}px`,this.scrollButton.style.height=`${Cu}px`)),this.keyboard=new wl({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 ol(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.setLegendOverviewAction(this.legendOverviewAction),this.inputsUI.setOnChange(o=>{for(let s of this.inputChangeCbs)s({indicatorId:o.indicatorId,key:o.key,value:o.value});}),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 sl(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.axisScaleButtons=new al(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,!$r(this.scene,s));}}),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(this.wrapper),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")&&vb()){let n=this.makeDataCanvas(),i=new ml;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 lo;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 lo;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&&ve(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();}syncCountdownTimer(){this.scene.showCountdown?this.countdownTimer==null&&(this.countdownTimer=setInterval(()=>{this.scene.showCountdown&&this.scene.bars.length>0&&this.scheduler?.invalidate(2);},1e3)):this.countdownTimer!=null&&(clearInterval(this.countdownTimer),this.countdownTimer=null);}destroy(){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.loadingEl?.remove(),this.loadingEl=null,this.countdownTimer!=null&&(clearInterval(this.countdownTimer),this.countdownTimer=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();for(let e of this.tableOverlays.values())e.destroy();this.tableOverlays.clear(),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.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-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=HP(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(d=>d.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.fitContent(),this.didInitialFit=true),!this.introPlayed&&this.bars.length>0&&(this.introPlayed=true,this.introStyle)){this.playIntro(this.introStyle);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.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);}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=Ke(this.liveEaseHigh,t.high,e,Eu),o=Ke(this.liveEaseLow,t.low,e,Eu),s=Ke(this.liveEaseClose,t.close,e,Eu),a=Math.abs(i-t.high)>n||Math.abs(o-t.low)>n||Math.abs(s-t.close)>n;return this.liveEaseHigh=a?i:t.high,this.liveEaseLow=a?o:t.low,this.liveEaseClose=a?s:t.close,a}ensurePane(e){this.scene.ensurePane(e.id,e.kind,e.order,e.heightWeight??(e.kind==="price"?3:1)),this.layoutPanes(),this.repositionTables(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}removePane(e){e!==we&&(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.syncTables(i),this.refreshAxisWidth(),this.layoutPanes(),this.repositionTables(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}orderPanes(e){this.scene.orderPanes(e),this.layoutPanes(),this.repositionTables(),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.repositionTables(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}setPaneMaximized(e){e!==null&&!this.scene.panes.has(e)&&(e=null),this.maximizedPaneId=e,this.layoutPanes(),this.repositionTables(),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=Kl+xP*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=OP(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.inputsUI.upsert(e.id,e.shorttitle??e.title,e.inputs,e.inputValues,e.paneId,{native:!!e.native,...e.shorttitle?{settingsTitle:e.title}:{}}),this.syncTables(e),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));}FP(n,t),this.syncTables(n),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.tableOverlays.get(e.id)?.destroy(),this.tableOverlays.delete(e.id),this.refreshAxisWidth(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}setIndicatorInputs(e,t){this.inputsUI.setValues(e.id,t);}setSymbolPicker(e){this.symbolPicker=e,this.inputsUI?.setSymbolPicker(e);}setLegendActions(e){this.legendActionsProvider=e,this.inputsUI?.setLegendActions(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.tableOverlays.get(e.id)?.destroy(),this.tableOverlays.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=zd(e),this.scene.candleOverride=dl(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.scrollButton){let t=e==="mobile"?Cu:Co;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 dv(this.hostSettingsSections)}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)}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=zt(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){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&&(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:zt(e),rightOffset:t};let o=Math.min(PP,n),s=this.coords.spacingScale,a=Math.min(1e3,i/(o*s)),l=Math.max(.5,Math.min(a,i/((n+ry)*s))),c=Math.max(l,Math.min(a,e)),u=i/(c*s)-(o-1),h=o-n,p=Math.max(h,Math.min(u,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=zt(Ke(n,s,e,LP)),i=this.anchoredRightOffset(n),o=true):n!==s&&(n=s,i=this.anchoredRightOffset(n));let a=IP/Math.max(1e-6,n*this.coords.spacingScale);if(Math.abs(this.panVelocity)>a&&(i+=this.panVelocity*e,this.panVelocity*=Math.exp(-e/MP),Math.abs(this.panVelocity)<=a?this.panVelocity=0:o=true),this.scrollTargetRO!=null){let c=this.scrollTargetRO,d=Ke(i,c,e,kP);Math.abs(d-c)<.001?(i=c,this.scrollTargetRO=null):(i=d,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;for(let n of this.scene.panes.values()){let i=n.scaleTarget,o=n.scale;if(i.log&&o.min>0&&i.min>0){let c=Math.log(i.min),d=Math.log(i.max),u=Math.max(1e-9,Math.abs(d-c)),h=Ke(Math.log(o.min),c,e,qr),p=Ke(Math.log(o.max),d,e,qr);Math.abs(h-c)<=u*.001&&Math.abs(p-d)<=u*.001?n.scale={min:i.min,max:i.max,log:true}:(t=true,n.scale={min:Math.exp(h),max:Math.exp(p),log:true});continue}let s=Math.max(1e-9,Math.abs(i.max-i.min)),a=Ke(o.min,i.min,e,qr),l=Ke(o.max,i.max,e,qr);Math.abs(a-i.min)<=s*.001&&Math.abs(l-i.max)<=s*.001?(a=i.min,l=i.max):t=true,n.scale={min:a,max:l,log:i.log};}for(let n of this.scene.indicatorScales.values()){let i=n.scaleTarget,o=n.scale,s=Math.max(1e-9,Math.abs(i.max-i.min)),a=Ke(o.min,i.min,e,qr),l=Ke(o.max,i.max,e,qr);Math.abs(a-i.min)<=s*.001&&Math.abs(l-i.max)<=s*.001?(a=i.min,l=i.max):t=true,n.scale={min:a,max:l};}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.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);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(be(f)){let g=f.points[i-m]?.value;g!=null&&c.set(f.id,g);}}let d=o?this.bars[i]:void 0,u=d?{time:d.time,open:d.open,high:d.high,low:d.low,close:d.close,volume:d.volume}:null;this.hoverLogical=o?i:null;let h={time:s,price:l,paneKind:n&&a?a.kind:null,values:c,ohlc:u};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});}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.scheduler.invalidate(4));}priceScaleBy(e){let t=this.scaleDragHolder,n=this.scaleDragStart;!t||!n||this.setManualScale(t,zv(n,Math.exp(e*AP)));}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,$v(n,e,this.scaleDragHeight));}resetPriceScale(e,t){let n=this.resolveScaleHolder(e,t);n&&(n.holder.manualScale=null,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.repositionTables(),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)<=DP)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=Wv(i,e);t.heightWeight=o.above,n.heightWeight=o.below,this.layoutPanes(),this.repositionTables(),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.repositionTables(),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=zt(t.barSpacing*Math.exp(e*RP));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(u=>u.kind==="price")??this.scene.orderedPanes()[0]??null,d=this.scene.crosshair?.y??(c?c.bounds.top+c.bounds.height/2:this.coords.height/2);this.handlePointerMove(this.coords.logicalToX(n),d),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(NP(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?ay(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?Pl(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?oy(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(be(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:oy(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||(Yd(e)?(this.computeScales(),this.paintData()):Ab(e)&&this.paintedData&&(this.chrome.prepare(this.scene,this.coords,this.theme),this.chrome.render(this.scene,this.coords,this.theme,this.axisSurface())),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx()),!Yd(e)&&this.paintedData&&this.repaintCursorLayers(),this.updateLegendValues());}repaintCursorLayers(){let e=this.scene.panes.get(we);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&&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(we);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 d of this.extLayers){let u=this.layerPane(d.def.id)??n;if(u.collapsed){this.clearLayerCanvas(d.canvas);continue}let h=this.extLayerArgs(d.def.id,u.scale,u.bounds,l);d.instance.render(h),u===n&&(c=Uv(c,d.instance.modulateBase?.(h)??null)),this.animZoom&&d.instance.animating?.()&&this.animator.start();}c&&(c.candleBodyScale!=null&&(this.backend.candleBodyScale=Pu(c.candleBodyScale)||.01),c.candleBodyAlpha!=null&&(this.backend.candleBodyAlpha=Pu(c.candleBodyAlpha)*this.candleBodyAlpha),c.gridAlpha!=null&&(e=Pu(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=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.userDrawings?.render(),s&&o&&(this.bars[i]=o),this.paintedData=true;}drawingProjector(){return Vv(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))}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!==we)l={time:a.time,price:e.price};else {let c=a.open;for(let d of [a.high,a.low,a.close])Math.abs(d-e.price)<Math.abs(c-e.price)&&(c=d);l={time:a.time,price:c};}if(n==="weak"&&i){let c=this.drawingProjector(),d=c.yOf(l.price,t);if(Math.hypot(c.xOf(l.time)-i.x,(d??i.y)-i.y)>yP)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 d=this.scene.indicatorsForPane(l.id).filter(p=>p.ownScale!==true),u=this.chrome.paneDrawingsRange(d,this.scene,l===s,t),h=l.kind==="price"&&!this.scene.candlesHidden;if(l.scaleTarget=zl(d,this.bars,h,n,i,u,$r(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=l.kind==="price"?this.bars[n]?.close??0:this.firstVisibleValue(d,n),l.axisFormat=void 0,l.axisBands=void 0,this.volumeOwnsPane(l,d)){let p=this.maxVisibleVolume(n,i);p>0&&(l.scaleTarget={min:0,max:p/fu},l.axisFormat="volume");}else if(this.layerNativesOwnPane(l,d)&&(l.scaleTarget=zl([],this.bars,true,n,i,u,$r(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=this.bars[n]?.close??0,d.every(p=>p.paneAxis!=null))){l.axisFormat="none";let p=d.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=Hv(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=zl([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=Gb(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;}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??we)??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??we:we;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}=Yv(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:Zd(this.scene,e),log:$r(this.scene,e),invert:Jd(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:$r(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===we)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===we?this.scene.orderedPanes().find(i=>i.kind==="price"):this.scene.panes.get(e);if(e===we)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===we)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=Jd(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(be(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}syncTables(e){let t=e.tables??[],n=this.tableOverlays.get(e.id);if(t.length===0){n&&(n.destroy(),this.tableOverlays.delete(e.id));return}n||(n=new ll(this.plot,this.theme,i=>this.paneBoundsFor(i)),n.setVisible(this.loadingEl===null),this.tableOverlays.set(e.id,n)),n.update(t);}repositionTables(){for(let e of this.tableOverlays.values())e.reposition();}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 d=0;for(let u of e)u===n?u.bounds={top:0,height:t}:u.bounds={top:t,height:0},d+=u.bounds.height;this.inputsUI?.reposition(),this.paneControls?.reposition(),this.axisScaleButtons?.reposition(),this.repositionScrollButton(),this.positionAttribution(),this.publishPricePaneBounds();return}let i=e.filter(d=>d.collapsed),o=e.filter(d=>!d.collapsed),s=i.length*ty,a=Math.max(0,t-s),l=o.reduce((d,u)=>d+(u.heightWeight||1),0)||1,c=0;for(let d of e){let u=d.collapsed?ty:a*(d.heightWeight||1)/l;d.bounds={top:c,height:u},c+=u;}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=Tu+Math.max(0,e-i),this.scrollBtnRightPx=this.rightAxisW+sy,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),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+To,t=this.scene.panes.get(we),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?qv(document,this.attributionHtml,this.theme.background):Zv(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:`${To+10+Math.max(0,e-i)}px`});}refreshAttributionColor(){this.attributionEl&&(this.attributionHtml!==null?this.attributionEl.style.color=yu(this.theme.background):wu(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=Math.max(1,e-this.toolbarGutter),o=t;this.dataCanvas.width=Math.round(i*n),this.dataCanvas.height=Math.round(o*n),this.backdropCanvas.width=this.dataCanvas.width,this.backdropCanvas.height=this.dataCanvas.height,this.volumeCanvas.width=this.dataCanvas.width,this.volumeCanvas.height=this.dataCanvas.height;for(let s of this.extLayers)s.canvas.width=this.dataCanvas.width,s.canvas.height=this.dataCanvas.height;this.vpvrCanvas.width=this.dataCanvas.width,this.vpvrCanvas.height=this.dataCanvas.height,this.chromeCanvas.width=this.dataCanvas.width,this.chromeCanvas.height=this.dataCanvas.height,this.drawingsCanvas.width=this.dataCanvas.width,this.drawingsCanvas.height=this.dataCanvas.height,this.cursorCanvas.width=this.dataCanvas.width,this.cursorCanvas.height=this.dataCanvas.height,this.coords.setSize(Math.max(1,i-this.rightAxisW),Math.max(1,o-To),n),this.scene.crosshair=null,this.layoutPanes(),this.repositionTables(),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 OP(r,e){for(let t of r.series){let n=t.kind==="candle"||t.kind==="bar"?t.bars:be(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 FP(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"&&be(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 ay(r,e){let t=Ml(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 NP(r,e){let{date:t,time:n}=ay(r,e);return `${t} ${n}`}function VP(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 _P(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)}}function Pu(r){return Math.max(0,Math.min(1,r))}function BP(r){return typeof r=="string"&&Br().includes(r)}function iy(r){return r==="percent"||r==="indexed"?r:"price"}function oy(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 HP(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 Lu(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 ly(r){let e=new Array(r.length),t;for(let n=0;n<r.length;n+=1)t=Lu(r[n],t),e[n]=t;return e}var zP={full:ly,next:Lu};function cy(){mc({id:"heikinashi",label:"Heikin Ashi",barTransform:zP});}var Mu=J,ku=X,Iu=20;function $P(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function dy(r,e){return typeof r=="string"&&r!==""?r:e}function Xl(r){return {upColor:dy(r.upColor,Mu),downColor:dy(r.downColor,ku),heightFrac:Math.min(.5,Math.max(.05,$P(r.heightPct,Iu)/100))}}var Au=class{constructor(){this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(Xl(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx.pushData(Xl(e));}suspend(){}resume(){this.ctx.pushData(Xl(this.inputs));}stop(){}},uy={type:"volume",title:"Volume",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"upColor",title:"Up color",type:"color",defval:Mu},{key:"downColor",title:"Down color",type:"color",defval:ku},{key:"heightPct",title:"Height %",type:"int",defval:Iu,min:5,max:50,step:1,tooltip:"Pane height the tallest visible bar occupies"}],defaultInputs:()=>({upColor:Mu,downColor:ku,heightPct:Iu}),create:()=>new Au};function Ru(){Qn(uy);}var Ou=24,Fu=30,Nu=Te,Vu=X,_u=70;function Du(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function hy(r,e){return typeof r=="string"&&r!==""?r:e}function jl(r){return {rows:Math.round(Math.min(400,Math.max(2,Du(r.rows,Ou)))),widthFrac:Math.min(.9,Math.max(.05,Du(r.widthPct,Fu)/100)),upColor:hy(r.upColor,Nu),downColor:hy(r.downColor,Vu),showPoc:r.showPoc!==false,valueAreaFrac:Math.min(1,Math.max(0,Du(r.valueAreaPct,_u)/100))}}var Bu=class{constructor(){this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(jl(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx.pushData(jl(e));}suspend(){}resume(){this.ctx.pushData(jl(this.inputs));}stop(){}},py={type:"vpvr",title:"Visible Range Volume Profile",shortTitle:"VRVP",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"rows",title:"Rows",type:"int",defval:Ou,min:2,max:400,step:1},{key:"widthPct",title:"Width %",type:"int",defval:Fu,min:5,max:90,step:1,tooltip:"Pane width the largest row occupies"},{key:"upColor",title:"Up color",type:"color",defval:Nu},{key:"downColor",title:"Down color",type:"color",defval:Vu},{key:"showPoc",title:"Point of control",type:"bool",defval:true},{key:"valueAreaPct",title:"Value area %",type:"int",defval:_u,min:0,max:100,step:1}],defaultInputs:()=>({rows:Ou,widthPct:Fu,upColor:Nu,downColor:Vu,showPoc:true,valueAreaPct:_u}),create:()=>new Bu};function Hu(){Qn(py);}var zu=class{constructor(e,t={},n={}){cy(),Ru(),Hu();let i=WP(e),o=dr(t.theme),s=true,a=true;typeof t.animations=="boolean"?(s=t.animations,a=t.animations):t.animations&&(s=t.animations.zoom??true,a=t.animations.pan??true);let l={currentPriceLine:t.currentPriceLine??true,logScale:t.logScale??false,nativeBackend:t.nativeBackend??"auto",animZoom:s,animPan:a,glow:t.glow??0,upColor:t.upColor??J,downColor:t.downColor??X,priceStyle:t.priceStyle??"candles"},c=t.renderer??Eo;if(typeof c!="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 d=n.renderer??new c(l),u=n.engines??[],h=n.dataFeed??new In,p={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??u[0]?.language??"pine",drawings:t.drawings,volume:t.volume??true};this.rendererControl=new gi(d),t.settings&&this.rendererControl.setSettingsVisibility(t.settings),this.dataControl=new wi(h),this.orchestrator=new qs(i,d,h,u,p,this.dataControl);let m=gc();Object.keys(m).length>0&&this.rendererControl.set(m),this.panesControl=new Zs(this.orchestrator),this.drawingsControl=new xi(this.orchestrator.drawings);}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",d=>{if(d.id===n.id){if(a){for(let u of i)u(d);return}a=true,c(),s({ok:true,run:d,error:null,onUpdate:u=>(i.add(u),()=>i.delete(u)),remove:()=>{l(),i.clear(),o();}});}}),c=n.on("error",({error:d})=>{a||(a=true,l(),c(),o(),s({ok:false,run:null,error:d,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}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(dr(e)),this}destroy(){this.orchestrator.destroy();}};function WP(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 Po=new Map,Lo=new Map,Mo=new Map;function GP(r){return Lo.set(r.id,r),()=>{Lo.get(r.id)===r&&Lo.delete(r.id);}}function UP(r){Lo.delete(r);}function YP(){return [...Lo.values()]}var my=100;function KP(r){return Mo.set(r.id,r),()=>{Mo.get(r.id)===r&&Mo.delete(r.id);}}function XP(r){Mo.delete(r);}function jP(){return [...Mo.values()].sort((r,e)=>(r.order??my)-(e.order??my))}function qP(r){return Po.set(r.id,r),()=>{Po.get(r.id)===r&&Po.delete(r.id);}}function ZP(r){Po.delete(r);}function JP(r,e){let t=[...Po.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 ko=new Map;function QP(r){return ko.set(r.id,r),()=>{ko.get(r.id)===r&&ko.delete(r.id);}}function eL(r){ko.delete(r);}function tL(){return [...ko.values()].sort((r,e)=>(r.order??0)-(e.order??0))}var Io=new Map;function nL(r){return Io.set(r.key,r),()=>{Io.get(r.key)===r&&Io.delete(r.key);}}function rL(r){Io.delete(r);}function iL(r){return [...Io.values()].filter(e=>e.scope===r)}var Ao=new Map;function oL(r,e){return Ao.set(r,e),()=>{Ao.get(r)===e&&Ao.delete(r);}}function sL(r){Ao.delete(r);}function aL(r){return {...Object.fromEntries(Ao),...r}}var fy=280,$u=200,gy=640;function lL(r,e=$u,t=gy){let n=Number.isFinite(e)&&e>0?e:$u,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 by(r){let e=r.title.trim().toLowerCase().replace(/\s+/g,"-");return `${r.instanceId}:${r.kind}:${e}#${r.ordinal}`}var vy="https://api.binance.com/api/v3",cL="https://api.binance.us/api/v3",Wu="https://fapi.binance.com/fapi/v1",dL="wss://stream.binance.com:9443",uL="wss://stream.binance.us:9443",hL="wss://fstream.binance.com";var yy={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"},wy={"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"},pL=[1,3,5,15,30,60,120,240,360,480,720],mL={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h",720:"12h"},fL=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function xy(r){return wy[r]??wy[r.toLowerCase()]??r}function Gu(r){let e=r.trim().toUpperCase();return e.endsWith(".P")?{apiSymbol:e.slice(0,-2),isFutures:true}:{apiSymbol:e,isFutures:false}}function Sy(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 gL(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 bL(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 vL(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 yL(r){return pL.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var ql=class{constructor(){this.spotBaseUrl=null;this.spotBaseProbe=null;this.symbolsPromise=null;}info(){return {name:"binance",displayName:"Binance",requiresApiKey:false,supportedTimeframes:fL,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let{apiSymbol:i,isFutures:o}=Gu(e),s=o?Wu:await this.spotBase(),a=xy(t),l=yy[a];if(l)return bL(Sy(await this.fetchKlines(s,i,l,n)));let c=/^\d+$/.test(a)?parseInt(a,10):null,d=c!=null?yL(c):null;if(c==null||d==null)return console.warn(`[vela] Binance: timeframe "${t}" is not supported and cannot be aggregated.`),[];let u=c/d,h={...n,limit:n.limit!=null?n.limit*u+u:void 0},p=Sy(await this.fetchKlines(s,i,mL[d],h)),m=vL(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}=Gu(e),i=n?Wu:await this.spotBase(),o=n?`${i}/exchangeInfo`:`${i}/exchangeInfo?symbol=${t}`,a=(await this.json(o).catch(()=>null))?.symbols??[],l=n?a.find(u=>u.symbol===t):a[0];if(!l)return;let c=l.filters?.find(u=>u.filterType==="PRICE_FILTER"),d=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:d,pricescale:Math.round(1/d),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}subscribe(e,t,n){let{apiSymbol:i,isFutures:o}=Gu(e),s=yy[xy(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,d=null,u=null,h=`${n.toLowerCase()}@kline_${o}`,p=()=>{d&&(clearTimeout(d),d=null);},m=()=>{if(!(a||u)){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.`),u=this.pollBars(e,t,s);}},f=async()=>{if(a)return;let g=i?hL:await this.spotWsBase();a||(l=new WebSocket(`${g}/ws/${h}`),d=setTimeout(m,15e3),l.onmessage=b=>{if(!(a||u))try{let v=JSON.parse(typeof b.data=="string"?b.data:"");v.k&&(p(),s(gL(v.k)));}catch{}},l.onclose=()=>{!a&&!u&&(c=setTimeout(()=>{f();},2e3));},l.onerror=()=>{try{l?.close();}catch{}});};return f(),()=>{a=true,p(),c&&clearTimeout(c),u?.();try{l?.close();}catch{}}}async spotWsBase(){return (await this.spotBase()).includes("binance.us")?uL:dL}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(`${Wu}/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 d=Math.min(a,1e3),u=await this.klinesChunk(e,{symbol:t,interval:n,limit:d,endTime:l});if(u.length===0||(s=u.concat(s),a-=u.length,l=Number(u[0][0])-1,u.length<d))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 [vy,cL])try{if((await fetch(`${e}/ping`,{signal:AbortSignal.timeout(5e3)})).ok)return this.spotBaseUrl=e}catch{}return vy}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 wL="https://api.hyperliquid.xyz/info",xL="wss://api.hyperliquid.xyz/ws";var Cy={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"},Ty={"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"},SL=[1,3,5,15,30,60,120,240,480,720],CL={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",480:"8h",720:"12h"},TL=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],Ey={D:864e5,W:6048e5,M:2592e6};function EL(r){if(Ey[r])return Ey[r];let e=parseInt(r,10);return Number.isFinite(e)&&e>0?e*6e4:36e5}function Py(r){return Ty[r]??Ty[r.toLowerCase()]??r}function Uu(r){let e=r.trim();return e.includes("/")?e:e.toUpperCase()}function Yu(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 PL(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 LL(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 ML(r){return SL.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var Zl=class{constructor(){this.metaPromise=null;this.spotMetaPromise=null;this.symbolsPromise=null;}info(){return {name:"hyperliquid",displayName:"Hyperliquid",requiresApiKey:false,supportedTimeframes:TL,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=Uu(e),o=Py(t),s=Cy[o];if(s)return PL((await this.fetchCandles(i,s,EL(o),n)).map(Yu));let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?ML(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,d={...n,limit:n.limit!=null?n.limit*c+c:void 0},u=(await this.fetchCandles(i,CL[l],l*6e4,d)).map(Yu),h=LL(u,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=Uu(e),i=(await this.fetchMeta().catch(()=>null))?.universe?.find(o=>o.name===t);if(i){let o=My(Math.max(0,6-(i.szDecimals??2)));return Ly(e,t,"USD","futures",`${t} / USD Perpetual`,o)}if(t.includes("/")){let o=await this.fetchSpotMeta().catch(()=>null),s=o?.universe?.find(u=>u.name===t),a=s&&o?.tokens?o.tokens[s.tokens?.[0]??-1]:void 0,[l=t,c="USDC"]=t.split("/"),d=My(Math.max(0,8-(a?.szDecimals??2)));return Ly(e,l,c,"crypto",`${l} / ${c}`,d)}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=Promise.all([this.listPerps().catch(()=>[]),this.listSpot().catch(()=>[])]).then(([e,t])=>[...e,...t])),this.symbolsPromise}subscribe(e,t,n){let i=Uu(e),o=Cy[Py(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,d=null,u=null,h=()=>{d&&(clearTimeout(d),d=null);},p=()=>{l&&(clearInterval(l),l=null);},m=()=>{if(!(s||u)){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.`),u=this.pollBars(e,t,o);}},f=()=>{s||u||(a=new WebSocket(xL),d=setTimeout(m,15e3),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||u))try{let b=JSON.parse(typeof g.data=="string"?g.data:"");b.channel==="candle"&&b.data&&b.data.s===n&&(h(),o(Yu(b.data)));}catch{}},a.onclose=()=>{p(),!s&&!u&&(c=setTimeout(f,2e3));},a.onerror=()=>{try{a?.close();}catch{}});};return f(),()=>{s=true,h(),p(),c&&clearTimeout(c),u?.();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(wL,{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 Ly(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 My(r){return Math.pow(10,-r)}var kL={now:()=>Date.now(),delay:r=>new Promise(e=>setTimeout(e,r))},Jl=class{constructor(e,t,n=kL){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 Ku="https://api.exchange.coinbase.com",IL="wss://ws-feed.exchange.coinbase.com",AL={Accept:"application/json"},RL=15e3,DL=2e3,OL=5e3,Ql=300,FL=4,NL=120,VL=4,_L=600,BL=400;function HL(r,e){let t=Number(r.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t*1e3:e}var ky={1:60,5:300,15:900,60:3600,360:21600,D:86400},Iy={"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"},zL=[1,5,15,60,360,1440],$L={1:60,5:300,15:900,60:3600,360:21600,1440:86400},WL=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],Xu=864e5;function Ay(r){return Iy[r]??Iy[r.toLowerCase()]??r}function ju(r){return r.trim().toUpperCase()}function GL(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 qu(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 UL(r,e){return Ry(r,t=>Math.floor(t/e)*e)}function YL(r,e){return Ry(r,e==="W"?KL:XL)}function Ry(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 KL(r){let e=new Date(r),t=(e.getUTCDay()+6)%7;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()-t)}function XL(r){let e=new Date(r);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)}function jL(r){return zL.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}function Zu(r,e){return e!=null&&r.length>e?r.slice(-e):r}var ec=class{constructor(){this.symbolsPromise=null;this.gate=new Jl(FL,NL);}info(){return {name:"coinbase",displayName:"Coinbase",requiresApiKey:false,supportedTimeframes:WL,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=ju(e),o=Ay(t),s=ky[o];if(s)return qu(await this.fetchCandles(i,s,n));if(o==="W"||o==="M"){let h=o==="W"?7*Xu:31*Xu,p=n.from!=null?n:{...n,limit:n.limit!=null?Math.ceil(n.limit*h/Xu)+31:void 0},m=await this.fetchCandles(i,86400,p);return Zu(YL(m,o),n.limit)}let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?jL(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,d={...n,limit:n.limit!=null?n.limit*c+c:void 0},u=await this.fetchCandles(i,$L[l],d);return Zu(UL(u,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=ju(e),n=await this.json(`${Ku}/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}subscribe(e,t,n){let i=ky[Ay(t)];return i&&typeof WebSocket<"u"?this.streamTicker(e,t,i,n):this.pollBars(e,t,n)}async fetchProducts(){let e=await this.json(`${Ku}/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/Ql)+4;for(;a>0&&c-- >0;){let d=Math.min(a,Ql),u=l-d*o,h=await this.candlesChunk(e,t,u,l);if(h.length===0||(s=h.concat(s),a-=h.length,l=h[0].time-1,h.length<d))break}return Zu(qu(s),n)}async paginateForward(e,t,n,i,o){let s=t*1e3,a=[],l=n,c=Math.ceil((i-n)/(Ql*s))+4;for(;l<i&&c-- >0;){let u=Math.min(l+Ql*s,i),h=await this.candlesChunk(e,t,l,u);if(h.length>0&&a.push(...h),l=u,o!=null&&a.length>=o)break}let d=qu(a);return o!=null?d.slice(0,o):d}async candlesChunk(e,t,n,i){let o=new URL(`${Ku}/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(GL).sort((a,l)=>a.time-l.time)}streamTicker(e,t,n,i){let o=ju(e),s=n*1e3,a=x=>Math.floor(x/s)*s,l=false,c=null,d=null,u=null,h=null,p=null,m=null,f=()=>{u&&(clearTimeout(u),u=null);},g=()=>{h&&(clearInterval(h),h=null);},b=()=>{m&&i({...m});},v=async x=>{try{let S=await this.getBars(e,t,{limit:2});if(l||S.length===0)return;x&&S.length>=2&&i(S[S.length-2]);let E=S[S.length-1];m=m&&m.time===E.time?{...E,high:Math.max(E.high,m.high),low:Math.min(E.low,m.low),close:m.close}:{...E},b();}catch{}},y=(x,S)=>{let E=Number(x);if(!Number.isFinite(E))return;let L=a(S);!m||L>m.time?(m={time:L,open:E,high:E,low:E,close:E,volume:0},b(),v(false)):L===m.time&&(m={...m,close:E,high:Math.max(m.high,E),low:Math.min(m.low,E)},b());},w=()=>{if(!(l||p)){f(),g(),d&&(clearTimeout(d),d=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);}},P=()=>{l||p||(c=new WebSocket(IL),u=setTimeout(w,RL),c.onopen=()=>{try{c?.send(JSON.stringify({type:"subscribe",product_ids:[o],channels:["ticker"]}));}catch{}v(false),h=setInterval(()=>{v(false);},OL);},c.onmessage=x=>{if(!(l||p))try{let S=JSON.parse(typeof x.data=="string"?x.data:"");S.type==="ticker"&&S.product_id===o&&S.price!=null&&(f(),y(S.price,S.time?Date.parse(S.time):Date.now()));}catch{}},c.onclose=()=>{g(),!l&&!p&&(d=setTimeout(P,DL));},c.onerror=()=>{try{c?.close();}catch{}});};return P(),()=>{l=true,f(),g(),d&&clearTimeout(d),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:AL}));if(n.status===429&&t<VL){let i=_L*2**t+Math.random()*BL;this.gate.pauseFor(Math.max(HL(n,0),i));continue}if(!n.ok)throw new Error(`Coinbase HTTP ${n.status} for ${e}`);return n}}};
|
|
952
|
-
exports.ACCENT=Te;exports.ACCENT_BRIGHT=tr;exports.BEARISH=X;exports.BULLISH=J;exports.BarStore=
|
|
951
|
+
`;function wP(r){let e=r.getElementById(Qv);e||(e=r.createElement("style"),e.id=Qv,r.head.appendChild(e)),e.textContent=yP;}function Su(r){return _e(r)?"#ffffff":"#000000"}function Cu(r,e){let t=_e(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 ey(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=Su(t),n.innerHTML=e,n}function ty(r,e){wP(r);let t=r.createElement("a");t.className="vela-attribution",t.href=vP,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"}),Cu(t,e);let n=r.createElement("span");n.className="vela-attr-symbol",n.setAttribute("aria-hidden","true"),n.innerHTML=Zv;let i=r.createElement("span");return i.className="vela-attr-wordmark",i.innerHTML=Jv,t.append(n,i),t}function Yl(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 ny(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 Tu(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 xP(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 Kl(r,e,t){let n=e.ownerDocument.defaultView;if(!n)return;r.save(),r.scale(t.dpr,t.dpr);let i=(c,d,u)=>{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=u,r.fillStyle=d.color,r.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`,r.textBaseline="middle",r.textAlign="left",r.fillText(h,m.left-t.left,m.top-t.top+m.height/2));},o=(c,d,u)=>{if(!c.complete||c.naturalWidth<=0||!xP(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=u,Tu(r,p,m,h.width,h.height,ny(d,h.width,h.height)),r.clip(),r.drawImage(c,p,m,h.width,h.height),r.restore();},s=(c,d)=>{for(let u of c.children){if(u.hasAttribute("transform"))continue;let h=u.tagName.toLowerCase();if(h==="g"){s(u,d);continue}let p=b=>parseFloat(u.getAttribute(b)??"0")||0,m=null;if(h==="path"){let b=u.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=(u.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 v=2;v+1<b.length;v+=2)m.lineTo(b[v],b[v+1]);h==="polygon"&&m.closePath();}if(!m)continue;let f=n.getComputedStyle(u);f.fill&&f.fill!=="none"&&Yl(f.fill)&&(r.globalAlpha=d*(parseFloat(f.fillOpacity)||1),r.fillStyle=f.fill,r.fill(m));let g=parseFloat(f.strokeWidth)||0;f.stroke&&f.stroke!=="none"&&Yl(f.stroke)&&g>0&&(r.globalAlpha=d*(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,d)=>{let u=c.getBoundingClientRect();if(u.width<=0||u.height<=0)return;let h=n.getComputedStyle(c);if(h.display==="none"||h.visibility==="hidden")return;let p=d*(parseFloat(h.opacity)||1);if(p<=.001)return;let m=c.viewBox.baseVal,f=m&&m.width>0?m.width:u.width,g=m&&m.height>0?m.height:u.height;r.save(),r.translate(u.left-t.left,u.top-t.top),r.scale(u.width/f,u.height/g),m&&r.translate(-m.x,-m.y),s(c,p),r.restore();},l=(c,d)=>{let u=n.getComputedStyle(c);if(u.display==="none"||u.visibility==="hidden")return;let h=d*(parseFloat(u.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=ny(u,p.width,p.height);Yl(u.backgroundColor)&&(r.globalAlpha=h,r.fillStyle=u.backgroundColor,Tu(r,m,f,p.width,p.height,g),r.fill());let b=parseFloat(u.borderTopWidth)||0;b>0&&u.borderTopStyle!=="none"&&Yl(u.borderTopColor)&&(r.globalAlpha=h,r.strokeStyle=u.borderTopColor,r.lineWidth=b,Tu(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,u,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 ry(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 y=o;y<=s;y+=1){let w=r[y];w.volume!=null&&w.volume>0&&(w.low<a&&(a=w.low),w.high>l&&(l=w.high));}if(!Number.isFinite(a))return null;let c=l>a?Math.max(1,Math.round(n)):1,d=l>a?(l-a)/c:1,u=Array.from({length:c},(y,w)=>({price:a+w*d,up:0,down:0}));for(let y=o;y<=s;y+=1){let w=r[y],P=w.volume;if(!(P!=null&&P>0))continue;let x=w.close>=w.open?"up":"down",S=w.high-w.low;if(S<=0){let T=Eu(Math.floor((w.low-a)/d),c);u[T][x]+=P;continue}let E=Eu(Math.floor((w.low-a)/d),c),L=Eu(Math.floor((w.high-a)/d-1e-9),c);for(let T=E;T<=L;T+=1){let k=a+T*d,M=Math.min(w.high,k+d)-Math.max(w.low,k);M>0&&(u[T][x]+=P*M/S);}}let h=0,p=0,m=0;for(let y=0;y<c;y+=1){let w=u[y].up+u[y].down;h+=w,w>p&&(p=w,m=y);}if(p<=0)return null;let f=h*Math.min(1,Math.max(0,i)),g=m,b=m,v=p;for(;v<f&&(g>0||b<c-1);){let y=g>0?u[g-1].up+u[g-1].down:-1,w=b<c-1?u[b+1].up+u[b+1].down:-1;w>y?(b+=1,v+=w):(g-=1,v+=y);}return {rows:u,rowH:d,min:a,maxTotal:p,poc:m,vaFrom:g,vaTo:b}}function Eu(r,e){return r<0?0:r>=e?e-1:r}function iy(r,e,t,n){let{rows:i,rowH:o,maxTotal:s,poc:a,vaFrom:l,vaTo:c}=e,{rightX:d,maxW:u,yOf:h}=t;if(!(s<=0||u<=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),v=f/s*u,y=m.up/f*v;r.globalAlpha=p>=l&&p<=c?.62:.28,y>0&&(r.fillStyle=n.upColor,r.fillRect(d-v,g,y,b)),v-y>0&&(r.fillStyle=n.downColor,r.fillRect(d-v+y,g,v-y,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(d-u+.5,m+.5,u-1,f);}r.globalAlpha=1;}}var Xl=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:d}=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||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=ry(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(),iy(t,b,{rightX:a.width,maxW:a.width*o.widthFrac,yOf:v=>a.priceToY(v,l,c)},{upColor:o.upColor,downColor:o.downColor,showPoc:o.showPoc,pocColor:d.textColor}),t.restore());}};var we="price",EP=8,PP="rgba(0,0,0,0)",jl=64,LP=56,oy=26,Lo=22,Po=26,Pu=24,MP=5,kP="0 2px 8px rgba(0,0,0,0.4)",IP=12,dy=12,sy=jl+dy,Lu=Lo+14,AP=120,RP=2,ay=6,DP=70,qr=80,OP=110,Mu=90,FP=130,NP=.02,VP=.004,_P=.2,BP=4,Mo=class{constructor(e){this.capabilities=xb;this.surfaceBackground=ht.background;this.surfaceTextColor=ht.textColor;this.toolbarGutter=0;this.mountContainer=null;this.userDrawings=null;this.backdropRenderer=new Gl;this.volumeRenderer=new Ul;this.extLayers=[];this.layerOrderSig="";this.attributionEl=null;this.attributionEnabled=true;this.attributionHtml=null;this.vpvrRenderer=new Xl;this.resizeObserver=null;this.dprMedia=null;this.coords=new vl;this.scene=new Tl;this.backendMode="auto";this.glowAmount=0;this.chrome=new Al;this.crosshairLayer=new Rl;this.countdownTimer=null;this.symbolPicker=null;this.indicatorTitlesOn=true;this.indicatorValuesOn=true;this.legendActionsProvider=null;this.legendOverviewAction=null;this.keyboard=null;this.keyboardEnabled=true;this.historyChordsEnabled=true;this.liveRegion=null;this.animZoom=true;this.animPan=true;this.candleUp=J;this.candleDown=X;this.introStyle="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=jl;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=Lu;this.scrollBtnRightPx=sy;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.tableOverlays=new Map;this.name="native";this.features=["logScale","currentPriceLine","priceLabel","countdown","upColor","downColor","glow","animZoom","animPan","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","indicatorTitles","indicatorValues"];this.onScrollProximityMove=e=>{if(!this.scrollButton||!this.plot)return;let t=this.plot.getBoundingClientRect(),n=t.width-this.scrollBtnRightPx-Po/2,i=t.height-this.scrollBtnBottomPx-Po/2,o=Math.hypot(e.clientX-t.left-n,e.clientY-t.top-i)<=AP;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=e.animZoom,this.animPan=e.animPan,this.glowAmount=e.glow,this.candleUp=e.upColor,this.candleDown=e.downColor,this.scene.priceStyle=e.priceStyle,this.scene.basePainting=Gd(e.priceStyle),this.scene.candleOverride=hl(e.priceStyle,this.scene.style.chartTypes)),this.theme=this.deriveTheme(ht);}applyFeature(e,t){switch(e){case "logScale":if(t&&typeof t=="object"){let n=t;this.setPaneLog(n.pane??we,!!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=!!t;return;case "animPan":this.animPan=!!t;return;case "intro":{let n=t===false||t==="none"||t==="off"||t==null?"":String(t);this.introStyle=n,n&&this.playIntro(n);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=WP(t);break;case "sessionZones":this.scene.sessionZones=GP(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??we,ly(n.mode));return}this.scene.scaleMode=ly(t);break;case "invertScale":if(t&&typeof t=="object"){let n=t;this.setPaneInvert(n.pane??we,!!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(UP(t)?t:"candles");break;case "priceBaseline":this.scene.baselineValue=t==null?null:Number(t);break;case "tradeMarkers":this.scene.tradeMarkers=Gb(this.scene.tradeMarkers,t);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;case "animPan":return this.animPan;case "intro":return this.introStyle;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(we);return t?this.scene.baselinePriceFor(t.scale):this.scene.baselineValue}case "tradeMarkers":return {...this.scene.tradeMarkers,colors:{...this.scene.tradeMarkers.colors}};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){for(let i of this.tableOverlays.values())i.setVisible(!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:Wd,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},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},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??PP}})(),baseline:(()=>{let i=e.baseline.topLineColor??Vr,o=e.baseline.bottomLineColor??_r;return {topLineColor:i,bottomLineColor:o,topFillColor:e.baseline.topFillColor??W(i,Bt),topFillColor2:e.baseline.topFillColor2??W(i,Ht),bottomFillColor:e.baseline.bottomFillColor??W(o,Bt),bottomFillColor2:e.baseline.bottomFillColor2??W(o,Ht),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}}}applyConfig(e){let t=Pb(this.getConfig(),e),n=this.scene.style;for(let[d,u]of Object.entries(t.chartTypes))if(JSON.stringify(n.chartTypes[d])!==JSON.stringify(u)){this.scene.nativeData.set(`${d}-settings`,{...u});for(let h of this.chartTypeSettingsCbs)h(d,{...u});}n.chartTypes=Object.fromEntries(Object.entries(t.chartTypes).map(([d,u])=>[d,{...u}]));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&&_e(t.layout.textColor)===_e(t.layout.background)){let d=_e(t.layout.background)?ht:vi;l={textColor:d.textColor,gridColor:d.gridColor,borderColor:d.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=(d,u,h)=>d===null&&u===h?null:u;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(),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.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[d,u]of Object.entries(t.stacking.series))this.scene.setIndicatorZ(d,u);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},this.setPriceStyle(t.series.style),this.scene.candleOverride=hl(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&&(ve(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 d of this.configChangedCbs)d();}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 yo(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=me("gear",14),Object.assign(e.style,{position:"absolute",bottom:`${Lo+10}px`,right:`${jl+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 yo(this.dialogHost??this.plot,this.theme),this.settingsDialog.setLayoutMode(this.layoutMode)),this.toggleSettingsDialog(e);}syncThemeControl(){this.settingsDialog?.setThemeControl(_e(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.setHiddenSettings(this.hiddenSettings),this.syncThemeControl(),this.settingsDialog.toggle(this.getConfig(),t=>this.applyConfig(t),t=>this.applyConfig(t),()=>{this.factoryConfig&&this.applyConfig(Eb(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:`${Lu}px`,right:`${sy}px`,zIndex:"6",width:`${Po}px`,height:`${Po}px`,boxSizing:"border-box",display:"none",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRadius:`${MP}px`,border:`1px solid ${this.theme.borderColor}`,boxShadow:kP,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 me("chevrons-right",IP)}scrollButtonSurface(){return W(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(ay);}glideRightOffset(e){let t=this.coords.getViewport();if(!this.animPan){this.applyViewport({barSpacing:t.barSpacing,rightOffset:e});return}this.panVelocity=0,this.targetBarSpacing=t.barSpacing,this.scrollTargetRO=e,this.animator.start();}screenshot(){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"&&Kl(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]")??[])Kl(t,s,i);for(let s of o)s.getAttribute("data-vela-screenshot")!=="under"&&Kl(t,s,i);}return e.toDataURL("image/png")}playIntro(e){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.introRaf=null;let t=this.bars,n=t.length;if(n===0)return;this.computeScales();for(let a of this.scene.panes.values())a.scale={...a.scaleTarget};this.modelAlpha=0;let i=650,o=performance.now(),s=a=>{let l=Math.min(1,(a-o)/i);this.scene.bars=l>=1?t:t.map((c,d)=>this.revealCandle(c,d,l,n,e)),this.paintData(),l<1?this.introRaf=requestAnimationFrame(s):(this.scene.bars=t,this.fadeInModels());};this.introRaf=requestAnimationFrame(s);}fadeInModels(){let t=performance.now(),n=i=>{this.modelAlpha=Math.min(1,(i-t)/350),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 u=a-1;l=1+(1.70158+1)*u*u*u+1.70158*u*u;}else {let d=1-a;l=1-d*d*d;}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:_e(this.surfaceBackground)?ht.borderColor:vi.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"}),ve(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=xu().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(bl()),this.scene.ensurePane(we,"price",0,3),this.scheduler=new yl(o=>this.renderFrame(o)),this.animator=new wl(o=>this.animTick(o)),this.targetBarSpacing=this.coords.getViewport().barSpacing,this.input=new xl({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=>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)=>this.userDrawings?.beginMeasureAt(o,s)??false,drawingsDeleteAt:(o,s)=>this.userDrawings?.deleteAt(o,s)??false,drawingsCancelPlacement:()=>this.userDrawings?.cancelPlacement()??false,drawingsSnapMode:()=>this.snapMode,drawingsPointerDown:(o,s,a,l)=>this.userDrawings?.pointerDown(o,s,a,l),drawingsPointerMove:(o,s,a,l)=>this.userDrawings?.pointerMove(o,s,a,l),drawingsPointerUp:(o,s)=>this.userDrawings?.pointerUp(o,s),drawingsCursor:(o,s)=>this.userDrawings?.cursorAt(o,s)??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.userDrawings=new $l(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===we?this.scene.candleZ:null,requestDataPaint:()=>this.scheduler.invalidate(3),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=`${Pu}px`,this.scrollButton.style.height=`${Pu}px`)),this.keyboard=new Sl({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 al(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.setLegendOverviewAction(this.legendOverviewAction),this.inputsUI.setOnChange(o=>{for(let s of this.inputChangeCbs)s({indicatorId:o.indicatorId,key:o.key,value:o.value});}),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 ll(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.axisScaleButtons=new cl(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,!$r(this.scene,s));}}),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(this.wrapper),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")&&Sb()){let n=this.makeDataCanvas(),i=new gl;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 ho;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 ho;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&&ve(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();}syncCountdownTimer(){this.scene.showCountdown?this.countdownTimer==null&&(this.countdownTimer=setInterval(()=>{this.scene.showCountdown&&this.scene.bars.length>0&&this.scheduler?.invalidate(2);},1e3)):this.countdownTimer!=null&&(clearInterval(this.countdownTimer),this.countdownTimer=null);}destroy(){this.introRaf!=null&&cancelAnimationFrame(this.introRaf),this.loadingEl?.remove(),this.loadingEl=null,this.countdownTimer!=null&&(clearInterval(this.countdownTimer),this.countdownTimer=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();for(let e of this.tableOverlays.values())e.destroy();this.tableOverlays.clear(),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.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-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=YP(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(d=>d.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.fitContent(),this.didInitialFit=true),!this.introPlayed&&this.bars.length>0&&(this.introPlayed=true,this.introStyle)){this.playIntro(this.introStyle);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.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);}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=Ke(this.liveEaseHigh,t.high,e,Mu),o=Ke(this.liveEaseLow,t.low,e,Mu),s=Ke(this.liveEaseClose,t.close,e,Mu),a=Math.abs(i-t.high)>n||Math.abs(o-t.low)>n||Math.abs(s-t.close)>n;return this.liveEaseHigh=a?i:t.high,this.liveEaseLow=a?o:t.low,this.liveEaseClose=a?s:t.close,a}ensurePane(e){this.scene.ensurePane(e.id,e.kind,e.order,e.heightWeight??(e.kind==="price"?3:1)),this.layoutPanes(),this.repositionTables(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}removePane(e){e!==we&&(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.syncTables(i),this.refreshAxisWidth(),this.layoutPanes(),this.repositionTables(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}orderPanes(e){this.scene.orderPanes(e),this.layoutPanes(),this.repositionTables(),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.repositionTables(),this.paneControls?.refresh(),this.scheduler.invalidate(4));}setPaneMaximized(e){e!==null&&!this.scene.panes.has(e)&&(e=null),this.maximizedPaneId=e,this.layoutPanes(),this.repositionTables(),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=jl+LP*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=HP(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.inputsUI.upsert(e.id,e.shorttitle??e.title,e.inputs,e.inputValues,e.paneId,{native:!!e.native,...e.shorttitle?{settingsTitle:e.title}:{}}),this.syncTables(e),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));}zP(n,t),this.syncTables(n),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.tableOverlays.get(e.id)?.destroy(),this.tableOverlays.delete(e.id),this.refreshAxisWidth(),this.paneControls?.refresh(),this.scheduler.invalidate(4);}setIndicatorInputs(e,t){this.inputsUI.setValues(e.id,t);}setSymbolPicker(e){this.symbolPicker=e,this.inputsUI?.setSymbolPicker(e);}setLegendActions(e){this.legendActionsProvider=e,this.inputsUI?.setLegendActions(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.tableOverlays.get(e.id)?.destroy(),this.tableOverlays.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=Gd(e),this.scene.candleOverride=hl(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.scrollButton){let t=e==="mobile"?Pu:Po;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 mv(this.hostSettingsSections)}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)}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=zt(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){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&&(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:zt(e),rightOffset:t};let o=Math.min(RP,n),s=this.coords.spacingScale,a=Math.min(1e3,i/(o*s)),l=Math.max(.5,Math.min(a,i/((n+ay)*s))),c=Math.max(l,Math.min(a,e)),u=i/(c*s)-(o-1),h=o-n,p=Math.max(h,Math.min(u,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=zt(Ke(n,s,e,DP)),i=this.anchoredRightOffset(n),o=true):n!==s&&(n=s,i=this.anchoredRightOffset(n));let a=NP/Math.max(1e-6,n*this.coords.spacingScale);if(Math.abs(this.panVelocity)>a&&(i+=this.panVelocity*e,this.panVelocity*=Math.exp(-e/OP),Math.abs(this.panVelocity)<=a?this.panVelocity=0:o=true),this.scrollTargetRO!=null){let c=this.scrollTargetRO,d=Ke(i,c,e,FP);Math.abs(d-c)<.001?(i=c,this.scrollTargetRO=null):(i=d,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;for(let n of this.scene.panes.values()){let i=n.scaleTarget,o=n.scale;if(i.log&&o.min>0&&i.min>0){let c=Math.log(i.min),d=Math.log(i.max),u=Math.max(1e-9,Math.abs(d-c)),h=Ke(Math.log(o.min),c,e,qr),p=Ke(Math.log(o.max),d,e,qr);Math.abs(h-c)<=u*.001&&Math.abs(p-d)<=u*.001?n.scale={min:i.min,max:i.max,log:true}:(t=true,n.scale={min:Math.exp(h),max:Math.exp(p),log:true});continue}let s=Math.max(1e-9,Math.abs(i.max-i.min)),a=Ke(o.min,i.min,e,qr),l=Ke(o.max,i.max,e,qr);Math.abs(a-i.min)<=s*.001&&Math.abs(l-i.max)<=s*.001?(a=i.min,l=i.max):t=true,n.scale={min:a,max:l,log:i.log};}for(let n of this.scene.indicatorScales.values()){let i=n.scaleTarget,o=n.scale,s=Math.max(1e-9,Math.abs(i.max-i.min)),a=Ke(o.min,i.min,e,qr),l=Ke(o.max,i.max,e,qr);Math.abs(a-i.min)<=s*.001&&Math.abs(l-i.max)<=s*.001?(a=i.min,l=i.max):t=true,n.scale={min:a,max:l};}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.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);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(be(f)){let g=f.points[i-m]?.value;g!=null&&c.set(f.id,g);}}let d=o?this.bars[i]:void 0,u=d?{time:d.time,open:d.open,high:d.high,low:d.low,close:d.close,volume:d.volume}:null;this.hoverLogical=o?i:null;let h={time:s,price:l,paneKind:n&&a?a.kind:null,values:c,ohlc:u};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});}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.scheduler.invalidate(4));}priceScaleBy(e){let t=this.scaleDragHolder,n=this.scaleDragStart;!t||!n||this.setManualScale(t,Uv(n,Math.exp(e*VP)));}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,Yv(n,e,this.scaleDragHeight));}resetPriceScale(e,t){let n=this.resolveScaleHolder(e,t);n&&(n.holder.manualScale=null,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.repositionTables(),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)<=BP)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=Kv(i,e);t.heightWeight=o.above,n.heightWeight=o.below,this.layoutPanes(),this.repositionTables(),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.repositionTables(),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=zt(t.barSpacing*Math.exp(e*_P));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(u=>u.kind==="price")??this.scene.orderedPanes()[0]??null,d=this.scene.crosshair?.y??(c?c.bounds.top+c.bounds.height/2:this.coords.height/2);this.handlePointerMove(this.coords.logicalToX(n),d),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($P(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?uy(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?Ml(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?cy(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(be(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:cy(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||(jd(e)?(this.computeScales(),this.paintData()):Fb(e)&&this.paintedData&&(this.chrome.prepare(this.scene,this.coords,this.theme),this.chrome.render(this.scene,this.coords,this.theme,this.axisSurface())),this.crosshairLayer.render(this.scene,this.coords,this.theme,this.hoverSeparatorY,this.externalCrossPx()),!jd(e)&&this.paintedData&&this.repaintCursorLayers(),this.updateLegendValues());}repaintCursorLayers(){let e=this.scene.panes.get(we);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&&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(we);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 d of this.extLayers){let u=this.layerPane(d.def.id)??n;if(u.collapsed){this.clearLayerCanvas(d.canvas);continue}let h=this.extLayerArgs(d.def.id,u.scale,u.bounds,l);d.instance.render(h),u===n&&(c=jv(c,d.instance.modulateBase?.(h)??null)),this.animZoom&&d.instance.animating?.()&&this.animator.start();}c&&(c.candleBodyScale!=null&&(this.backend.candleBodyScale=ku(c.candleBodyScale)||.01),c.candleBodyAlpha!=null&&(this.backend.candleBodyAlpha=ku(c.candleBodyAlpha)*this.candleBodyAlpha),c.gridAlpha!=null&&(e=ku(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=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.userDrawings?.render(),s&&o&&(this.bars[i]=o),this.paintedData=true;}drawingProjector(){return zv(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))}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!==we)l={time:a.time,price:e.price};else {let c=a.open;for(let d of [a.high,a.low,a.close])Math.abs(d-e.price)<Math.abs(c-e.price)&&(c=d);l={time:a.time,price:c};}if(n==="weak"&&i){let c=this.drawingProjector(),d=c.yOf(l.price,t);if(Math.hypot(c.xOf(l.time)-i.x,(d??i.y)-i.y)>EP)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 d=this.scene.indicatorsForPane(l.id).filter(p=>p.ownScale!==true),u=this.chrome.paneDrawingsRange(d,this.scene,l===s,t),h=l.kind==="price"&&!this.scene.candlesHidden;if(l.scaleTarget=Wl(d,this.bars,h,n,i,u,$r(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=l.kind==="price"?this.bars[n]?.close??0:this.firstVisibleValue(d,n),l.axisFormat=void 0,l.axisBands=void 0,this.volumeOwnsPane(l,d)){let p=this.maxVisibleVolume(n,i);p>0&&(l.scaleTarget={min:0,max:p/vu},l.axisFormat="volume");}else if(this.layerNativesOwnPane(l,d)&&(l.scaleTarget=Wl([],this.bars,true,n,i,u,$r(this.scene,l),p=>this.scene.offsetOf(p)),l.percentBaseline=this.bars[n]?.close??0,d.every(p=>p.paneAxis!=null))){l.axisFormat="none";let p=d.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=Gv(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=Wl([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=Xb(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;}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??we)??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??we:we;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}=qv(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:eu(this.scene,e),log:$r(this.scene,e),invert:tu(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:$r(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===we)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===we?this.scene.orderedPanes().find(i=>i.kind==="price"):this.scene.panes.get(e);if(e===we)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===we)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=tu(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(be(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}syncTables(e){let t=e.tables??[],n=this.tableOverlays.get(e.id);if(t.length===0){n&&(n.destroy(),this.tableOverlays.delete(e.id));return}n||(n=new dl(this.plot,this.theme,i=>this.paneBoundsFor(i)),n.setVisible(this.loadingEl===null),this.tableOverlays.set(e.id,n)),n.update(t);}repositionTables(){for(let e of this.tableOverlays.values())e.reposition();}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 d=0;for(let u of e)u===n?u.bounds={top:0,height:t}:u.bounds={top:t,height:0},d+=u.bounds.height;this.inputsUI?.reposition(),this.paneControls?.reposition(),this.axisScaleButtons?.reposition(),this.repositionScrollButton(),this.positionAttribution(),this.publishPricePaneBounds();return}let i=e.filter(d=>d.collapsed),o=e.filter(d=>!d.collapsed),s=i.length*oy,a=Math.max(0,t-s),l=o.reduce((d,u)=>d+(u.heightWeight||1),0)||1,c=0;for(let d of e){let u=d.collapsed?oy:a*(d.heightWeight||1)/l;d.bounds={top:c,height:u},c+=u;}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=Lu+Math.max(0,e-i),this.scrollBtnRightPx=this.rightAxisW+dy,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),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+Lo,t=this.scene.panes.get(we),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?ey(document,this.attributionHtml,this.theme.background):ty(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:`${Lo+10+Math.max(0,e-i)}px`});}refreshAttributionColor(){this.attributionEl&&(this.attributionHtml!==null?this.attributionEl.style.color=Su(this.theme.background):Cu(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=Math.max(1,e-this.toolbarGutter),o=t;this.dataCanvas.width=Math.round(i*n),this.dataCanvas.height=Math.round(o*n),this.backdropCanvas.width=this.dataCanvas.width,this.backdropCanvas.height=this.dataCanvas.height,this.volumeCanvas.width=this.dataCanvas.width,this.volumeCanvas.height=this.dataCanvas.height;for(let s of this.extLayers)s.canvas.width=this.dataCanvas.width,s.canvas.height=this.dataCanvas.height;this.vpvrCanvas.width=this.dataCanvas.width,this.vpvrCanvas.height=this.dataCanvas.height,this.chromeCanvas.width=this.dataCanvas.width,this.chromeCanvas.height=this.dataCanvas.height,this.drawingsCanvas.width=this.dataCanvas.width,this.drawingsCanvas.height=this.dataCanvas.height,this.cursorCanvas.width=this.dataCanvas.width,this.cursorCanvas.height=this.dataCanvas.height,this.coords.setSize(Math.max(1,i-this.rightAxisW),Math.max(1,o-Lo),n),this.scene.crosshair=null,this.layoutPanes(),this.repositionTables(),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 HP(r,e){for(let t of r.series){let n=t.kind==="candle"||t.kind==="bar"?t.bars:be(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 zP(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"&&be(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 uy(r,e){let t=Il(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 $P(r,e){let{date:t,time:n}=uy(r,e);return `${t} ${n}`}function WP(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 GP(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)}}function ku(r){return Math.max(0,Math.min(1,r))}function UP(r){return typeof r=="string"&&Br().includes(r)}function ly(r){return r==="percent"||r==="indexed"?r:"price"}function cy(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 YP(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 Iu(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 hy(r){let e=new Array(r.length),t;for(let n=0;n<r.length;n+=1)t=Iu(r[n],t),e[n]=t;return e}var KP={full:hy,next:Iu};function py(){bc({id:"heikinashi",label:"Heikin Ashi",barTransform:KP});}var Au=J,Ru=X,Du=20;function XP(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function my(r,e){return typeof r=="string"&&r!==""?r:e}function ql(r){return {upColor:my(r.upColor,Au),downColor:my(r.downColor,Ru),heightFrac:Math.min(.5,Math.max(.05,XP(r.heightPct,Du)/100))}}var Ou=class{constructor(){this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(ql(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx.pushData(ql(e));}suspend(){}resume(){this.ctx.pushData(ql(this.inputs));}stop(){}},fy={type:"volume",title:"Volume",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"upColor",title:"Up color",type:"color",defval:Au},{key:"downColor",title:"Down color",type:"color",defval:Ru},{key:"heightPct",title:"Height %",type:"int",defval:Du,min:5,max:50,step:1,tooltip:"Pane height the tallest visible bar occupies"}],defaultInputs:()=>({upColor:Au,downColor:Ru,heightPct:Du}),create:()=>new Ou};function Fu(){Qn(fy);}var Vu=24,_u=30,Bu=Te,Hu=X,zu=70;function Nu(r,e){return typeof r=="number"&&Number.isFinite(r)?r:e}function gy(r,e){return typeof r=="string"&&r!==""?r:e}function Zl(r){return {rows:Math.round(Math.min(400,Math.max(2,Nu(r.rows,Vu)))),widthFrac:Math.min(.9,Math.max(.05,Nu(r.widthPct,_u)/100)),upColor:gy(r.upColor,Bu),downColor:gy(r.downColor,Hu),showPoc:r.showPoc!==false,valueAreaFrac:Math.min(1,Math.max(0,Nu(r.valueAreaPct,zu)/100))}}var $u=class{constructor(){this.inputs={};}start(e,t){this.ctx=e,this.inputs=t,e.emit({}),e.pushData(Zl(t));}onBars(){}onViewport(){}setInputs(e){this.inputs=e,this.ctx.pushData(Zl(e));}suspend(){}resume(){this.ctx.pushData(Zl(this.inputs));}stop(){}},by={type:"vpvr",title:"Visible Range Volume Profile",shortTitle:"VRVP",paneHint:"price",overlay:true,inputsSchema:()=>[{key:"rows",title:"Rows",type:"int",defval:Vu,min:2,max:400,step:1},{key:"widthPct",title:"Width %",type:"int",defval:_u,min:5,max:90,step:1,tooltip:"Pane width the largest row occupies"},{key:"upColor",title:"Up color",type:"color",defval:Bu},{key:"downColor",title:"Down color",type:"color",defval:Hu},{key:"showPoc",title:"Point of control",type:"bool",defval:true},{key:"valueAreaPct",title:"Value area %",type:"int",defval:zu,min:0,max:100,step:1}],defaultInputs:()=>({rows:Vu,widthPct:_u,upColor:Bu,downColor:Hu,showPoc:true,valueAreaPct:zu}),create:()=>new $u};function Wu(){Qn(by);}var Gu=class{constructor(e,t={},n={}){py(),Fu(),Wu();let i=jP(e),o=dr(t.theme),s=true,a=true;typeof t.animations=="boolean"?(s=t.animations,a=t.animations):t.animations&&(s=t.animations.zoom??true,a=t.animations.pan??true);let l={currentPriceLine:t.currentPriceLine??true,logScale:t.logScale??false,nativeBackend:t.nativeBackend??"auto",animZoom:s,animPan:a,glow:t.glow??0,upColor:t.upColor??J,downColor:t.downColor??X,priceStyle:t.priceStyle??"candles"},c=t.renderer??Mo;if(typeof c!="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 d=n.renderer??new c(l),u=n.engines??[],h=n.dataFeed??new In,p={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??u[0]?.language??"pine",drawings:t.drawings,volume:t.volume??true};this.rendererControl=new yi(d),t.settings&&this.rendererControl.setSettingsVisibility(t.settings),this.dataControl=new Ci(h),this.orchestrator=new Js(i,d,h,u,p,this.dataControl);let m=yc();Object.keys(m).length>0&&this.rendererControl.set(m),this.panesControl=new Qs(this.orchestrator),this.drawingsControl=new Ti(this.orchestrator.drawings);}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",d=>{if(d.id===n.id){if(a){for(let u of i)u(d);return}a=true,c(),s({ok:true,run:d,error:null,onUpdate:u=>(i.add(u),()=>i.delete(u)),remove:()=>{l(),i.clear(),o();}});}}),c=n.on("error",({error:d})=>{a||(a=true,l(),c(),o(),s({ok:false,run:null,error:d,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}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(dr(e)),this}destroy(){this.orchestrator.destroy();}};function jP(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 vy=["symbol","timeframes","style","layout","indicators","actions","undo-redo","alerts","panels","screenshot"];var Zr=new Map,ko=new Map,Io=new Map;function qP(r){return ko.set(r.id,r),()=>{ko.get(r.id)===r&&ko.delete(r.id);}}function ZP(r){ko.delete(r);}function JP(){return [...ko.values()]}var yy=100;function QP(r){return Io.set(r.id,r),()=>{Io.get(r.id)===r&&Io.delete(r.id);}}function eL(r){Io.delete(r);}function tL(){return [...Io.values()].sort((r,e)=>(r.order??yy)-(e.order??yy))}var Uu=["indicators","screenshot"],wy=new Set(Uu),nL=new Set(vy);function rL(r){if(wy.has(r))return Zr.get(r)}function iL(r){return nL.has(r.id)&&!wy.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: ${Uu.join(", ")}.`),()=>{}):(Zr.set(r.id,r),()=>{Zr.get(r.id)===r&&Zr.delete(r.id);})}function oL(r){Zr.delete(r);}function sL(r,e){let t=[...Zr.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 Ao=new Map;function aL(r){return Ao.set(r.id,r),()=>{Ao.get(r.id)===r&&Ao.delete(r.id);}}function lL(r){Ao.delete(r);}function cL(){return [...Ao.values()].sort((r,e)=>(r.order??0)-(e.order??0))}var Ro=new Map;function dL(r){return Ro.set(r.key,r),()=>{Ro.get(r.key)===r&&Ro.delete(r.key);}}function uL(r){Ro.delete(r);}function hL(r){return [...Ro.values()].filter(e=>e.scope===r)}var Jl;function pL(r){return Jl=r,()=>{Jl===r&&(Jl=void 0);}}function mL(){return Jl}var Do=new Map;function fL(r,e){return Do.set(r,e),()=>{Do.get(r)===e&&Do.delete(r);}}function gL(r){Do.delete(r);}function bL(r){return {...Object.fromEntries(Do),...r}}var xy=280,Yu=200,Sy=640;function vL(r,e=Yu,t=Sy){let n=Number.isFinite(e)&&e>0?e:Yu,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 Cy(r){let e=r.title.trim().toLowerCase().replace(/\s+/g,"-");return `${r.instanceId}:${r.kind}:${e}#${r.ordinal}`}function Jr(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 Qr(r){let e=r.trim().toUpperCase();return e?`https://crypto-icons.ledger.com/${encodeURIComponent(e)}.png`:void 0}var Ty="https://api.binance.com/api/v3",yL="https://api.binance.us/api/v3",Ku="https://fapi.binance.com/fapi/v1",wL="wss://stream.binance.com:9443",xL="wss://stream.binance.us:9443",SL="wss://fstream.binance.com",CL=15e3,TL=2e3,Ey={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"},Py={"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"},EL=[1,3,5,15,30,60,120,240,360,480,720],PL={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h",720:"12h"},LL=["1","3","5","15","30","45","60","120","180","240","D","W","M"];function Ly(r){return Py[r]??Py[r.toLowerCase()]??r}function Xu(r){let e=r.trim().toUpperCase();return e.endsWith(".P")?{apiSymbol:e.slice(0,-2),isFutures:true}:{apiSymbol:e,isFutures:false}}function My(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 ML(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 kL(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 IL(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 AL(r){return EL.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var Ql=class{constructor(){this.spotBaseUrl=null;this.spotBaseProbe=null;this.symbolsPromise=null;}info(){return {name:"binance",displayName:"Binance",requiresApiKey:false,supportedTimeframes:LL,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let{apiSymbol:i,isFutures:o}=Xu(e),s=o?Ku:await this.spotBase(),a=Ly(t),l=Ey[a];if(l)return kL(My(await this.fetchKlines(s,i,l,n)));let c=/^\d+$/.test(a)?parseInt(a,10):null,d=c!=null?AL(c):null;if(c==null||d==null)return console.warn(`[vela] Binance: timeframe "${t}" is not supported and cannot be aggregated.`),[];let u=c/d,h={...n,limit:n.limit!=null?n.limit*u+u:void 0},p=My(await this.fetchKlines(s,i,PL[d],h)),m=IL(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}=Xu(e),i=n?Ku:await this.spotBase(),o=n?`${i}/exchangeInfo`:`${i}/exchangeInfo?symbol=${t}`,a=(await this.json(o).catch(()=>null))?.symbols??[],l=n?a.find(u=>u.symbol===t):a[0];if(!l)return;let c=l.filters?.find(u=>u.filterType==="PRICE_FILTER"),d=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:d,pricescale:Math.round(1/d),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 Qr(Jr(e))}subscribe(e,t,n){let{apiSymbol:i,isFutures:o}=Xu(e),s=Ey[Ly(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,d=null,u=null,h=`${n.toLowerCase()}@kline_${o}`,p=()=>{d&&(clearTimeout(d),d=null);},m=()=>{if(!(a||u)){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.`),u=this.pollBars(e,t,s);}},f=async()=>{if(a)return;let g=i?SL:await this.spotWsBase();a||(l=new WebSocket(`${g}/ws/${h}`),d=setTimeout(m,CL),l.onmessage=b=>{if(!(a||u))try{let v=JSON.parse(typeof b.data=="string"?b.data:"");v.k&&(p(),s(ML(v.k)));}catch{}},l.onclose=()=>{!a&&!u&&(c=setTimeout(()=>{f();},TL));},l.onerror=()=>{try{l?.close();}catch{}});};return f(),()=>{a=true,p(),c&&clearTimeout(c),u?.();try{l?.close();}catch{}}}async spotWsBase(){return (await this.spotBase()).includes("binance.us")?xL:wL}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(`${Ku}/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 d=Math.min(a,1e3),u=await this.klinesChunk(e,{symbol:t,interval:n,limit:d,endTime:l});if(u.length===0||(s=u.concat(s),a-=u.length,l=Number(u[0][0])-1,u.length<d))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 [Ty,yL])try{if((await fetch(`${e}/ping`,{signal:AbortSignal.timeout(5e3)})).ok)return this.spotBaseUrl=e}catch{}return Ty}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 RL="https://api.hyperliquid.xyz/info",DL="wss://api.hyperliquid.xyz/ws",OL=15e3,FL=2e3,ky={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"},Iy={"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"},NL=[1,3,5,15,30,60,120,240,480,720],VL={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",480:"8h",720:"12h"},_L=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],Ay={D:864e5,W:6048e5,M:2592e6};function BL(r){if(Ay[r])return Ay[r];let e=parseInt(r,10);return Number.isFinite(e)&&e>0?e*6e4:36e5}function Ry(r){return Iy[r]??Iy[r.toLowerCase()]??r}function ju(r){let e=r.trim();return e.includes("/")?e:e.toUpperCase()}function qu(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 HL(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 zL(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 $L(r){return NL.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}var ec=class{constructor(){this.metaPromise=null;this.spotMetaPromise=null;this.symbolsPromise=null;}info(){return {name:"hyperliquid",displayName:"Hyperliquid",requiresApiKey:false,supportedTimeframes:_L,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=ju(e),o=Ry(t),s=ky[o];if(s)return HL((await this.fetchCandles(i,s,BL(o),n)).map(qu));let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?$L(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,d={...n,limit:n.limit!=null?n.limit*c+c:void 0},u=(await this.fetchCandles(i,VL[l],l*6e4,d)).map(qu),h=zL(u,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=ju(e),i=(await this.fetchMeta().catch(()=>null))?.universe?.find(o=>o.name===t);if(i){let o=Oy(Math.max(0,6-(i.szDecimals??2)));return Dy(e,t,"USD","futures",`${t} / USD Perpetual`,o)}if(t.includes("/")){let o=await this.fetchSpotMeta().catch(()=>null),s=o?.universe?.find(u=>u.name===t),a=s&&o?.tokens?o.tokens[s.tokens?.[0]??-1]:void 0,[l=t,c="USDC"]=t.split("/"),d=Oy(Math.max(0,8-(a?.szDecimals??2)));return Dy(e,l,c,"crypto",`${l} / ${c}`,d)}}listSymbols(){return this.symbolsPromise||(this.symbolsPromise=Promise.all([this.listPerps().catch(()=>[]),this.listSpot().catch(()=>[])]).then(([e,t])=>[...e,...t])),this.symbolsPromise}resolveSymbolIcon(e){return Qr(Jr(e))}subscribe(e,t,n){let i=ju(e),o=ky[Ry(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,d=null,u=null,h=()=>{d&&(clearTimeout(d),d=null);},p=()=>{l&&(clearInterval(l),l=null);},m=()=>{if(!(s||u)){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.`),u=this.pollBars(e,t,o);}},f=()=>{s||u||(a=new WebSocket(DL),d=setTimeout(m,OL),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||u))try{let b=JSON.parse(typeof g.data=="string"?g.data:"");b.channel==="candle"&&b.data&&b.data.s===n&&(h(),o(qu(b.data)));}catch{}},a.onclose=()=>{p(),!s&&!u&&(c=setTimeout(f,FL));},a.onerror=()=>{try{a?.close();}catch{}});};return f(),()=>{s=true,h(),p(),c&&clearTimeout(c),u?.();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(RL,{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 Dy(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 Oy(r){return Math.pow(10,-r)}var WL={now:()=>Date.now(),delay:r=>new Promise(e=>setTimeout(e,r))},tc=class{constructor(e,t,n=WL){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 Zu="https://api.exchange.coinbase.com",GL="wss://ws-feed.exchange.coinbase.com",UL={Accept:"application/json"},YL=15e3,KL=2e3,XL=5e3,nc=300,jL=4,qL=120,ZL=4,JL=600,QL=400;function eM(r,e){let t=Number(r.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t*1e3:e}var Fy={1:60,5:300,15:900,60:3600,360:21600,D:86400},Ny={"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"},tM=[1,5,15,60,360,1440],nM={1:60,5:300,15:900,60:3600,360:21600,1440:86400},rM=["1","3","5","15","30","45","60","120","180","240","360","480","720","D","W","M"],Ju=864e5;function Vy(r){return Ny[r]??Ny[r.toLowerCase()]??r}function Qu(r){return r.trim().toUpperCase()}function iM(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 eh(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 oM(r,e){return _y(r,t=>Math.floor(t/e)*e)}function sM(r,e){return _y(r,e==="W"?aM:lM)}function _y(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 aM(r){let e=new Date(r),t=(e.getUTCDay()+6)%7;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()-t)}function lM(r){let e=new Date(r);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)}function cM(r){return tM.filter(e=>e<r&&r%e===0).sort((e,t)=>t-e)[0]??null}function th(r,e){return e!=null&&r.length>e?r.slice(-e):r}var rc=class{constructor(){this.symbolsPromise=null;this.gate=new tc(jL,qL);}info(){return {name:"coinbase",displayName:"Coinbase",requiresApiKey:false,supportedTimeframes:rM,capabilities:{enumerate:true,stream:true,symbolInfo:true}}}async getBars(e,t,n){try{let i=Qu(e),o=Vy(t),s=Fy[o];if(s)return eh(await this.fetchCandles(i,s,n));if(o==="W"||o==="M"){let h=o==="W"?7*Ju:31*Ju,p=n.from!=null?n:{...n,limit:n.limit!=null?Math.ceil(n.limit*h/Ju)+31:void 0},m=await this.fetchCandles(i,86400,p);return th(sM(m,o),n.limit)}let a=/^\d+$/.test(o)?parseInt(o,10):null,l=a!=null?cM(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,d={...n,limit:n.limit!=null?n.limit*c+c:void 0},u=await this.fetchCandles(i,nM[l],d);return th(oM(u,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=Qu(e),n=await this.json(`${Zu}/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 Qr(Jr(e))}subscribe(e,t,n){let i=Fy[Vy(t)];return i&&typeof WebSocket<"u"?this.streamTicker(e,t,i,n):this.pollBars(e,t,n)}async fetchProducts(){let e=await this.json(`${Zu}/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/nc)+4;for(;a>0&&c-- >0;){let d=Math.min(a,nc),u=l-d*o,h=await this.candlesChunk(e,t,u,l);if(h.length===0||(s=h.concat(s),a-=h.length,l=h[0].time-1,h.length<d))break}return th(eh(s),n)}async paginateForward(e,t,n,i,o){let s=t*1e3,a=[],l=n,c=Math.ceil((i-n)/(nc*s))+4;for(;l<i&&c-- >0;){let u=Math.min(l+nc*s,i),h=await this.candlesChunk(e,t,l,u);if(h.length>0&&a.push(...h),l=u,o!=null&&a.length>=o)break}let d=eh(a);return o!=null?d.slice(0,o):d}async candlesChunk(e,t,n,i){let o=new URL(`${Zu}/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(iM).sort((a,l)=>a.time-l.time)}streamTicker(e,t,n,i){let o=Qu(e),s=n*1e3,a=x=>Math.floor(x/s)*s,l=false,c=null,d=null,u=null,h=null,p=null,m=null,f=()=>{u&&(clearTimeout(u),u=null);},g=()=>{h&&(clearInterval(h),h=null);},b=()=>{m&&i({...m});},v=async x=>{try{let S=await this.getBars(e,t,{limit:2});if(l||S.length===0)return;x&&S.length>=2&&i(S[S.length-2]);let E=S[S.length-1];m=m&&m.time===E.time?{...E,high:Math.max(E.high,m.high),low:Math.min(E.low,m.low),close:m.close}:{...E},b();}catch{}},y=(x,S)=>{let E=Number(x);if(!Number.isFinite(E))return;let L=a(S);!m||L>m.time?(m={time:L,open:E,high:E,low:E,close:E,volume:0},b(),v(false)):L===m.time&&(m={...m,close:E,high:Math.max(m.high,E),low:Math.min(m.low,E)},b());},w=()=>{if(!(l||p)){f(),g(),d&&(clearTimeout(d),d=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);}},P=()=>{l||p||(c=new WebSocket(GL),u=setTimeout(w,YL),c.onopen=()=>{try{c?.send(JSON.stringify({type:"subscribe",product_ids:[o],channels:["ticker"]}));}catch{}v(false),h=setInterval(()=>{v(false);},XL);},c.onmessage=x=>{if(!(l||p))try{let S=JSON.parse(typeof x.data=="string"?x.data:"");S.type==="ticker"&&S.product_id===o&&S.price!=null&&(f(),y(S.price,S.time?Date.parse(S.time):Date.now()));}catch{}},c.onclose=()=>{g(),!l&&!p&&(d=setTimeout(P,KL));},c.onerror=()=>{try{c?.close();}catch{}});};return P(),()=>{l=true,f(),g(),d&&clearTimeout(d),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:UL}));if(n.status===429&&t<ZL){let i=JL*2**t+Math.random()*QL;this.gate.pauseFor(Math.max(eM(n,0),i));continue}if(!n.ok)throw new Error(`Coinbase HTTP ${n.status} for ${e}`);return n}}};
|
|
952
|
+
exports.ACCENT=Te;exports.ACCENT_BRIGHT=tr;exports.BEARISH=X;exports.BULLISH=J;exports.BarStore=ea;exports.BinanceProvider=Ql;exports.CATEGORICAL=sh;exports.CROSSHAIR=ch;exports.CachingDataFeed=Si;exports.CoinbaseProvider=rc;exports.DARK_THEME=ht;exports.DEFAULT_PANEL_MAX_WIDTH=Sy;exports.DEFAULT_PANEL_MIN_WIDTH=Yu;exports.DEFAULT_PANEL_WIDTH=xy;exports.DataControl=Ci;exports.Drawing=V;exports.DrawingStore=lr;exports.DrawingToolbar=Eo;exports.DrawingsControl=Ti;exports.HIGHLIGHT=ah;exports.HyperliquidProvider=ec;exports.INFO=Ct;exports.INVALID=_o;exports.LIGHT_THEME=vi;exports.MARKER=lh;exports.MultiProviderFeed=In;exports.NEUTRAL=Ee;exports.NativeRenderer=Mo;exports.OVERRIDABLE_TOPBAR_IDS=Uu;exports.RendererControl=yi;exports.SERIES_LINE=ni;exports.SESSION_OFF=xM;exports.SESSION_POST=wM;exports.SESSION_PRE=yM;exports.SLATE=Bo;exports.SLATE_DEEP=dh;exports.TRADE_EXIT=ph;exports.TRADE_LONG=uh;exports.TRADE_SHORT=hh;exports.TypedEventBus=hn;exports.VALID=Vo;exports.Vela=Gu;exports.WARNING=pn;exports.buildColorPicker=to;exports.buildToolbar=mi;exports.categoricalColor=SM;exports.chartType=kt;exports.chartTypes=Je;exports.clampPanelWidth=vL;exports.combineColor=qa;exports.createDrawing=qt;exports.defaultToolbar=pi;exports.deserializeDrawing=ct;exports.drawingTypes=Ks;exports.getDrawingType=jt;exports.getNativeIndicator=ti;exports.iconMarkup=zo;exports.inputVisible=qi;exports.legendActions=cL;exports.nativeIndicatorDescriptors=Fo;exports.nativeIndicatorTypes=rh;exports.normalizeSettingsRow=cr;exports.registerChartType=bc;exports.registerDefaultEngine=fL;exports.registerDrawingType=O;exports.registerIcon=D;exports.registerLegendAction=aL;exports.registerNativeIndicator=Qn;exports.registerRendererDefaults=TS;exports.registerRendererLayer=gP;exports.registerSidePanel=QP;exports.registerStatePersistence=dL;exports.registerSymbolRanking=pL;exports.registerWidgetAction=iL;exports.registerWidgetAttachment=qP;exports.rendererDefaults=yc;exports.rendererLayers=xu;exports.resolveEngines=bL;exports.resolveTheme=dr;exports.settingsRowValueKeys=gi;exports.sharedBarStore=wi;exports.sidePanels=tL;exports.splitColor=ln;exports.stableSeriesId=Cy;exports.statePersistenceHandlers=hL;exports.symbolRanking=mL;exports.tickerModifierIds=vc;exports.timeframeToMs=fi;exports.topbarActionOverride=rL;exports.unregisterChartType=gS;exports.unregisterDefaultEngine=gL;exports.unregisterLegendAction=lL;exports.unregisterNativeIndicator=nh;exports.unregisterRendererDefaults=ES;exports.unregisterRendererLayer=bP;exports.unregisterSidePanel=eL;exports.unregisterStatePersistence=uL;exports.unregisterWidgetAction=oL;exports.unregisterWidgetAttachment=ZP;exports.widgetActions=sL;exports.widgetAttachments=JP;return exports;})({});
|